use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate in project ORCID-Source by ORCID.
the class Api3_0_Dev1LastModifiedDatesHelper method calculateLastModified.
public static void calculateLastModified(Emails emails) {
if (emails != null && emails.getEmails() != null && !emails.getEmails().isEmpty()) {
LastModifiedDate latest = null;
for (Email email : emails.getEmails()) {
if (email.getLastModifiedDate() != null && email.getLastModifiedDate().after(latest)) {
latest = email.getLastModifiedDate();
}
}
emails.setLastModifiedDate(latest);
}
}
use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_WorksTest method testCleanEmptyFieldsOnWorks.
@Test
public void testCleanEmptyFieldsOnWorks() {
LastModifiedDate lmd = new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(System.currentTimeMillis()));
Work work = new Work();
work.setLastModifiedDate(lmd);
work.setWorkCitation(new Citation("", CitationType.FORMATTED_UNSPECIFIED));
WorkTitle title = new WorkTitle();
title.setTitle(new Title("My Work"));
title.setSubtitle(new Subtitle("My subtitle"));
title.setTranslatedTitle(new TranslatedTitle("", ""));
work.setWorkTitle(title);
ActivityUtils.cleanEmptyFields(work);
assertNotNull(work);
Utils.verifyLastModified(work.getLastModifiedDate());
assertNotNull(work.getWorkTitle());
assertNotNull(work.getWorkTitle().getTitle());
assertNotNull(work.getWorkTitle().getSubtitle());
assertEquals("My Work", work.getWorkTitle().getTitle().getContent());
assertEquals("My subtitle", work.getWorkTitle().getSubtitle().getContent());
assertNull(work.getWorkCitation());
assertNull(work.getWorkTitle().getTranslatedTitle());
}
use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate in project ORCID-Source by ORCID.
the class KeywordForm method valueOf.
public static KeywordForm valueOf(Keyword keyword) {
KeywordForm form = new KeywordForm();
if (keyword == null) {
return form;
}
if (keyword.getPutCode() != null) {
form.setPutCode(String.valueOf(keyword.getPutCode()));
}
if (!PojoUtil.isEmpty(keyword.getContent())) {
form.setContent(keyword.getContent());
}
if (keyword.getVisibility() != null) {
form.setVisibility(Visibility.valueOf(keyword.getVisibility()));
} else {
form.setVisibility(Visibility.valueOf(org.orcid.jaxb.model.common_v2.Visibility.fromValue(OrcidVisibilityDefaults.KEYWORD_DEFAULT.getVisibility().value())));
}
if (keyword.getCreatedDate() != null) {
Date createdDate = new Date();
createdDate.setYear(String.valueOf(keyword.getCreatedDate().getValue().getYear()));
createdDate.setMonth(String.valueOf(keyword.getCreatedDate().getValue().getMonth()));
createdDate.setDay(String.valueOf(keyword.getCreatedDate().getValue().getDay()));
form.setCreatedDate(createdDate);
}
if (keyword.getLastModifiedDate() != null) {
Date lastModifiedDate = new Date();
lastModifiedDate.setYear(String.valueOf(keyword.getLastModifiedDate().getValue().getYear()));
lastModifiedDate.setMonth(String.valueOf(keyword.getLastModifiedDate().getValue().getMonth()));
lastModifiedDate.setDay(String.valueOf(keyword.getLastModifiedDate().getValue().getDay()));
form.setLastModified(lastModifiedDate);
}
if (keyword.getSource() != null) {
// Set source
form.setSource(keyword.getSource().retrieveSourcePath());
if (keyword.getSource().getSourceName() != null) {
form.setSourceName(keyword.getSource().getSourceName().getContent());
}
}
if (keyword.getDisplayIndex() != null) {
form.setDisplayIndex(keyword.getDisplayIndex());
} else {
form.setDisplayIndex(0L);
}
return form;
}
use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate in project ORCID-Source by ORCID.
the class Api3_0_Dev1LastModifiedDatesHelper method calculateLastModified.
public static void calculateLastModified(ActivitiesSummary activitiesSummary) {
if (activitiesSummary != null) {
calculateLastModified(activitiesSummary.getDistinctions());
calculateLastModified(activitiesSummary.getEducations());
calculateLastModified(activitiesSummary.getEmployments());
calculateLastModified(activitiesSummary.getInvitedPositions());
calculateLastModified(activitiesSummary.getMemberships());
calculateLastModified(activitiesSummary.getQualifications());
calculateLastModified(activitiesSummary.getServices());
calculateLastModified(activitiesSummary.getFundings());
calculateLastModified(activitiesSummary.getPeerReviews());
calculateLastModified(activitiesSummary.getWorks());
LastModifiedDate l0 = activitiesSummary.getDistinctions() == null ? null : activitiesSummary.getDistinctions().getLastModifiedDate();
LastModifiedDate l1 = activitiesSummary.getEducations() == null ? null : activitiesSummary.getEducations().getLastModifiedDate();
LastModifiedDate l2 = activitiesSummary.getEmployments() == null ? null : activitiesSummary.getEmployments().getLastModifiedDate();
LastModifiedDate l3 = activitiesSummary.getMemberships() == null ? null : activitiesSummary.getMemberships().getLastModifiedDate();
LastModifiedDate l4 = activitiesSummary.getInvitedPositions() == null ? null : activitiesSummary.getInvitedPositions().getLastModifiedDate();
LastModifiedDate l5 = activitiesSummary.getQualifications() == null ? null : activitiesSummary.getQualifications().getLastModifiedDate();
LastModifiedDate l6 = activitiesSummary.getServices() == null ? null : activitiesSummary.getServices().getLastModifiedDate();
LastModifiedDate l7 = activitiesSummary.getFundings() == null ? null : activitiesSummary.getFundings().getLastModifiedDate();
LastModifiedDate l8 = activitiesSummary.getPeerReviews() == null ? null : activitiesSummary.getPeerReviews().getLastModifiedDate();
LastModifiedDate l9 = activitiesSummary.getWorks() == null ? null : activitiesSummary.getWorks().getLastModifiedDate();
LastModifiedDate globalLatest = calculateLatest(l0, l1, l2, l3, l4, l5, l6, l7, l8, l9);
activitiesSummary.setLastModifiedDate(globalLatest);
}
}
use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate in project ORCID-Source by ORCID.
the class Api3_0_Dev1LastModifiedDatesHelper method calculateLastModified.
public static void calculateLastModified(Person person) {
if (person != null) {
calculateLastModified(person.getAddresses());
calculateLastModified(person.getEmails());
calculateLastModified(person.getExternalIdentifiers());
calculateLastModified(person.getKeywords());
calculateLastModified(person.getOtherNames());
calculateLastModified(person.getResearcherUrls());
LastModifiedDate l1 = person.getAddresses() == null ? null : person.getAddresses().getLastModifiedDate();
LastModifiedDate l2 = person.getEmails() == null ? null : person.getEmails().getLastModifiedDate();
LastModifiedDate l3 = person.getExternalIdentifiers() == null ? null : person.getExternalIdentifiers().getLastModifiedDate();
LastModifiedDate l4 = person.getKeywords() == null ? null : person.getKeywords().getLastModifiedDate();
LastModifiedDate l5 = person.getOtherNames() == null ? null : person.getOtherNames().getLastModifiedDate();
LastModifiedDate l6 = person.getResearcherUrls() == null ? null : person.getResearcherUrls().getLastModifiedDate();
LastModifiedDate globalLatest = calculateLatest(l1, l2, l3, l4, l5, l6);
person.setLastModifiedDate(globalLatest);
}
}
Aggregations