Skip to content

Commit

Permalink
TRM-31758: Add submitted date to community publications
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonardoGonzales committed Sep 17, 2024
1 parent fbb9314 commit b334374
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -15,4 +18,6 @@ public interface CommunityAnnotation extends Serializable {
String getDisease();

String getComment();

LocalDate getSubmissionDate();
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import org.uniprot.core.Builder;
import org.uniprot.core.publication.CommunityAnnotation;

import java.time.LocalDate;

/**
* Created 02/12/2020
*
Expand All @@ -15,6 +17,7 @@ public class CommunityAnnotationBuilder implements Builder<CommunityAnnotation>
private String function;
private String disease;
private String comment;
private LocalDate submissionDate;

public CommunityAnnotationBuilder proteinOrGene(String proteinOrGene) {
this.proteinOrGene = proteinOrGene;
Expand All @@ -36,17 +39,28 @@ 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) {
return new CommunityAnnotationBuilder()
.function(instance.getFunction())
.disease(instance.getDisease())
.comment(instance.getComment())
.proteinOrGene(instance.getProteinOrGene());
.proteinOrGene(instance.getProteinOrGene())
.submissionDate(instance.getSubmissionDate());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.uniprot.core.publication.impl;

import java.time.LocalDate;
import java.util.Objects;

import org.uniprot.core.publication.CommunityAnnotation;
Expand All @@ -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
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -80,6 +89,9 @@ public String toString() {
+ ", comment='"
+ comment
+ '\''
+ ", submissionDate='"
+ submissionDate
+ '\''
+ '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b334374

Please sign in to comment.