diff --git a/core-domain/src/main/java/org/uniprot/core/publication/CommunityAnnotation.java b/core-domain/src/main/java/org/uniprot/core/publication/CommunityAnnotation.java index a78e3fbc5..fa8af4b1f 100644 --- a/core-domain/src/main/java/org/uniprot/core/publication/CommunityAnnotation.java +++ b/core-domain/src/main/java/org/uniprot/core/publication/CommunityAnnotation.java @@ -1,6 +1,9 @@ package org.uniprot.core.publication; +import org.uniprot.core.util.Utils; + import java.io.Serializable; +import java.time.LocalDate; /** * Created 02/12/2020 @@ -15,4 +18,6 @@ public interface CommunityAnnotation extends Serializable { String getDisease(); String getComment(); + + LocalDate getSubmissionDate(); } diff --git a/core-domain/src/main/java/org/uniprot/core/publication/impl/CommunityAnnotationBuilder.java b/core-domain/src/main/java/org/uniprot/core/publication/impl/CommunityAnnotationBuilder.java index 56920b849..7f1ad2b45 100644 --- a/core-domain/src/main/java/org/uniprot/core/publication/impl/CommunityAnnotationBuilder.java +++ b/core-domain/src/main/java/org/uniprot/core/publication/impl/CommunityAnnotationBuilder.java @@ -5,6 +5,8 @@ import org.uniprot.core.Builder; import org.uniprot.core.publication.CommunityAnnotation; +import java.time.LocalDate; + /** * Created 02/12/2020 * @@ -15,6 +17,7 @@ public class CommunityAnnotationBuilder implements Builder private String function; private String disease; private String comment; + private LocalDate submissionDate; public CommunityAnnotationBuilder proteinOrGene(String proteinOrGene) { this.proteinOrGene = proteinOrGene; @@ -36,10 +39,20 @@ public CommunityAnnotationBuilder comment(String comment) { return this; } + public CommunityAnnotationBuilder submissionDate(String submissionDate) { + this.submissionDate = LocalDate.parse(submissionDate); + return this; + } + + public CommunityAnnotationBuilder submissionDate(LocalDate submissionDate) { + this.submissionDate = submissionDate; + return this; + } + @Nonnull @Override public CommunityAnnotation build() { - return new CommunityAnnotationImpl(proteinOrGene, function, disease, comment); + return new CommunityAnnotationImpl(proteinOrGene, function, disease, comment, submissionDate); } public static CommunityAnnotationBuilder from(@Nonnull CommunityAnnotation instance) { @@ -47,6 +60,7 @@ public static CommunityAnnotationBuilder from(@Nonnull CommunityAnnotation insta .function(instance.getFunction()) .disease(instance.getDisease()) .comment(instance.getComment()) - .proteinOrGene(instance.getProteinOrGene()); + .proteinOrGene(instance.getProteinOrGene()) + .submissionDate(instance.getSubmissionDate()); } } diff --git a/core-domain/src/main/java/org/uniprot/core/publication/impl/CommunityAnnotationImpl.java b/core-domain/src/main/java/org/uniprot/core/publication/impl/CommunityAnnotationImpl.java index bf7841248..9b7c95603 100644 --- a/core-domain/src/main/java/org/uniprot/core/publication/impl/CommunityAnnotationImpl.java +++ b/core-domain/src/main/java/org/uniprot/core/publication/impl/CommunityAnnotationImpl.java @@ -1,5 +1,6 @@ package org.uniprot.core.publication.impl; +import java.time.LocalDate; import java.util.Objects; import org.uniprot.core.publication.CommunityAnnotation; @@ -10,23 +11,25 @@ * @author Edd */ public class CommunityAnnotationImpl implements CommunityAnnotation { - private static final long serialVersionUID = 6579256221026737892L; + private static final long serialVersionUID = 8368111594497409648L; private final String proteinOrGene; private final String function; private final String disease; private final String comment; + private final LocalDate submissionDate; public CommunityAnnotationImpl() { - this(null, null, null, null); + this(null, null, null, null, null); } public CommunityAnnotationImpl( - String proteinOrGene, String function, String disease, String comment) { + String proteinOrGene, String function, String disease, String comment, LocalDate submissionDate) { this.proteinOrGene = proteinOrGene; this.function = function; this.disease = disease; this.comment = comment; + this.submissionDate = submissionDate; } @Override @@ -49,6 +52,11 @@ public String getComment() { return comment; } + @Override + public LocalDate getSubmissionDate() { + return submissionDate; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -57,12 +65,13 @@ public boolean equals(Object o) { return Objects.equals(proteinOrGene, that.proteinOrGene) && Objects.equals(function, that.function) && Objects.equals(disease, that.disease) - && Objects.equals(comment, that.comment); + && Objects.equals(comment, that.comment) + && Objects.equals(submissionDate, that.submissionDate); } @Override public int hashCode() { - return Objects.hash(proteinOrGene, function, disease, comment); + return Objects.hash(proteinOrGene, function, disease, comment, submissionDate); } @Override @@ -80,6 +89,9 @@ public String toString() { + ", comment='" + comment + '\'' + + ", submissionDate='" + + submissionDate + + '\'' + '}'; } } diff --git a/json-parser/src/main/java/org/uniprot/core/json/parser/publication/MappedPublicationsJsonConfig.java b/json-parser/src/main/java/org/uniprot/core/json/parser/publication/MappedPublicationsJsonConfig.java index d7a9d9373..f5a08daf7 100644 --- a/json-parser/src/main/java/org/uniprot/core/json/parser/publication/MappedPublicationsJsonConfig.java +++ b/json-parser/src/main/java/org/uniprot/core/json/parser/publication/MappedPublicationsJsonConfig.java @@ -9,6 +9,7 @@ import org.uniprot.core.citation.impl.*; import org.uniprot.core.impl.CrossReferenceImpl; import org.uniprot.core.json.parser.JsonConfig; +import org.uniprot.core.json.parser.deserializer.LocalDateDeserializer; import org.uniprot.core.json.parser.serializer.*; import org.uniprot.core.json.parser.uniprot.serializer.*; import org.uniprot.core.publication.*; @@ -64,6 +65,8 @@ private ObjectMapper initFullObjectMapper() { // customise the default mapper SimpleModule mod = new SimpleModule(); + mod.addSerializer(LocalDate.class, new LocalDateSerializer()); + mod.addDeserializer(LocalDate.class, new LocalDateDeserializer()); mod.addAbstractTypeMapping(MappedPublications.class, MappedPublicationsImpl.class); mod.addAbstractTypeMapping( CommunityMappedReference.class, CommunityMappedReferenceImpl.class); diff --git a/json-parser/src/test/java/org/uniprot/core/json/parser/publication/MappedPublicationsJsonConfigTest.java b/json-parser/src/test/java/org/uniprot/core/json/parser/publication/MappedPublicationsJsonConfigTest.java index 6fd7ad1e5..eae9eff8e 100644 --- a/json-parser/src/test/java/org/uniprot/core/json/parser/publication/MappedPublicationsJsonConfigTest.java +++ b/json-parser/src/test/java/org/uniprot/core/json/parser/publication/MappedPublicationsJsonConfigTest.java @@ -4,6 +4,7 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; +import java.time.LocalDate; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -109,7 +110,8 @@ static CommunityMappedReference getCompleteCommunityMappedReference() { .comment(comment) .proteinOrGene(protOrGene) .function(function) - .disease(disease); + .disease(disease) + .submissionDate(LocalDate.of(2024,9,16)); CommunityMappedReferenceBuilder builder = new CommunityMappedReferenceBuilder(); builder.communityAnnotation(communityAnnotationBuilder.build()); builder.uniProtKBAccession(accession).source(mappedSource);