-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from imsweb/year-based-metadata
Year based metadata
- Loading branch information
Showing
16 changed files
with
229 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.1-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (C) 2021 Information Management Services, Inc. | ||
*/ | ||
package com.imsweb.staging.entities; | ||
|
||
public interface Metadata { | ||
|
||
/** | ||
* Name of metadata item | ||
* @return String | ||
*/ | ||
String getName(); | ||
|
||
/** | ||
* Start year of metadata | ||
* @return Integer representing year | ||
*/ | ||
Integer getStart(); | ||
|
||
/** | ||
* End year of metadata | ||
* @return Integer representing year | ||
*/ | ||
Integer getEnd(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
src/main/java/com/imsweb/staging/entities/impl/StagingMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright (C) 2021 Information Management Services, Inc. | ||
*/ | ||
package com.imsweb.staging.entities.impl; | ||
|
||
import java.util.Objects; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
|
||
import com.imsweb.staging.entities.Metadata; | ||
|
||
@JsonPropertyOrder({"name", "start", "end"}) | ||
@JsonDeserialize(using = StagingMetadataDeserializer.class) | ||
public class StagingMetadata implements Metadata { | ||
|
||
private String _name; | ||
private Integer _start; | ||
private Integer _end; | ||
|
||
public StagingMetadata() { | ||
} | ||
|
||
public StagingMetadata(String name) { | ||
_name = name; | ||
} | ||
|
||
public StagingMetadata(String name, Integer start) { | ||
_name = name; | ||
_start = start; | ||
} | ||
|
||
public StagingMetadata(String name, Integer start, Integer end) { | ||
_name = name; | ||
_start = start; | ||
_end = end; | ||
} | ||
|
||
@JsonProperty("name") | ||
@Override | ||
public String getName() { | ||
return _name; | ||
} | ||
|
||
public void setName(String name) { | ||
_name = name; | ||
} | ||
|
||
@JsonProperty("start") | ||
@Override | ||
public Integer getStart() { | ||
return _start; | ||
} | ||
|
||
public void setStart(Integer start) { | ||
_start = start; | ||
} | ||
|
||
@JsonProperty("end") | ||
@Override | ||
public Integer getEnd() { | ||
return _end; | ||
} | ||
|
||
public void setEnd(Integer end) { | ||
_end = end; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) | ||
return true; | ||
if (o == null || getClass() != o.getClass()) | ||
return false; | ||
|
||
StagingMetadata that = (StagingMetadata)o; | ||
return Objects.equals(_name, that._name) && | ||
Objects.equals(_start, that._start) && | ||
Objects.equals(_end, that._end); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(_name, _start, _end); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/com/imsweb/staging/entities/impl/StagingMetadataDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (C) 2021 Information Management Services, Inc. | ||
*/ | ||
package com.imsweb.staging.entities.impl; | ||
|
||
import java.io.IOException; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer; | ||
|
||
public class StagingMetadataDeserializer extends StdDeserializer<StagingMetadata> { | ||
|
||
public StagingMetadataDeserializer() { | ||
this(null); | ||
} | ||
|
||
protected StagingMetadataDeserializer(Class<?> vc) { | ||
super(vc); | ||
} | ||
|
||
@Override | ||
public StagingMetadata deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { | ||
JsonNode node = jp.getCodec().readTree(jp); | ||
|
||
if (node.isNull()) | ||
return null; | ||
|
||
if (node.isObject()) { | ||
StagingMetadata meta = new StagingMetadata(); | ||
|
||
if (node.get("name") != null) | ||
meta.setName(node.get("name").asText()); | ||
if (node.get("start") != null) | ||
meta.setStart(node.get("start").asInt()); | ||
if (node.get("end") != null) | ||
meta.setEnd(node.get("end").asInt()); | ||
|
||
return meta; | ||
} | ||
|
||
return new StagingMetadata(node.asText()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.