use of org.orcid.jaxb.model.common_v2.LastModifiedDate in project ORCID-Source by ORCID.
the class RecordManagerReadOnlyImpl method getHistory.
private History getHistory(String orcid) {
History history = new History();
ProfileEntity profile = profileEntityCacheManager.retrieve(orcid);
history.setClaimed(profile.getClaimed());
if (profile.getCompletedDate() != null) {
history.setCompletionDate(new CompletionDate(DateUtils.convertToXMLGregorianCalendar(profile.getCompletedDate())));
}
if (!PojoUtil.isEmpty(profile.getCreationMethod())) {
history.setCreationMethod(CreationMethod.fromValue(profile.getCreationMethod()));
}
if (profile.getDeactivationDate() != null) {
history.setDeactivationDate(new DeactivationDate(DateUtils.convertToXMLGregorianCalendar(profile.getDeactivationDate())));
}
if (profile.getLastModified() != null) {
history.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(profile.getLastModified())));
}
if (profile.getSubmissionDate() != null) {
history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(profile.getSubmissionDate())));
}
if (profile.getSource() != null) {
history.setSource(new Source(profile.getSource().getSourceId()));
}
boolean verfiedEmail = false;
boolean verfiedPrimaryEmail = false;
Emails emails = emailManager.getEmails(orcid, profile.getLastModified().getTime());
if (emails != null) {
for (Email email : emails.getEmails()) {
if (email.isVerified()) {
verfiedEmail = true;
if (email.isPrimary()) {
verfiedPrimaryEmail = true;
break;
}
}
}
}
history.setVerifiedEmail(verfiedEmail);
history.setVerifiedPrimaryEmail(verfiedPrimaryEmail);
return history;
}
use of org.orcid.jaxb.model.common_v2.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.common_v2.LastModifiedDate in project ORCID-Source by ORCID.
the class Api2_0_LastModifiedDatesHelper method calculateLastModified.
public static void calculateLastModified(ActivitiesSummary activitiesSummary) {
if (activitiesSummary != null) {
calculateLastModified(activitiesSummary.getEducations());
calculateLastModified(activitiesSummary.getEmployments());
calculateLastModified(activitiesSummary.getFundings());
calculateLastModified(activitiesSummary.getPeerReviews());
calculateLastModified(activitiesSummary.getWorks());
LastModifiedDate l1 = activitiesSummary.getEducations() == null ? null : activitiesSummary.getEducations().getLastModifiedDate();
LastModifiedDate l2 = activitiesSummary.getEmployments() == null ? null : activitiesSummary.getEmployments().getLastModifiedDate();
LastModifiedDate l3 = activitiesSummary.getFundings() == null ? null : activitiesSummary.getFundings().getLastModifiedDate();
LastModifiedDate l4 = activitiesSummary.getPeerReviews() == null ? null : activitiesSummary.getPeerReviews().getLastModifiedDate();
LastModifiedDate l5 = activitiesSummary.getWorks() == null ? null : activitiesSummary.getWorks().getLastModifiedDate();
LastModifiedDate globalLatest = calculateLatest(l1, l2, l3, l4, l5);
activitiesSummary.setLastModifiedDate(globalLatest);
}
}
use of org.orcid.jaxb.model.common_v2.LastModifiedDate in project ORCID-Source by ORCID.
the class Api2_0_LastModifiedDatesHelper method calculateLastModified.
public static void calculateLastModified(ActivitiesContainer actContainerV2) {
if (actContainerV2 != null) {
Collection<? extends Activity> activities = actContainerV2.retrieveActivities();
if (activities != null && !activities.isEmpty()) {
Iterator<? extends Activity> activitiesIterator = activities.iterator();
XMLGregorianCalendar latest = activitiesIterator.next().getLastModifiedDate().getValue();
while (activitiesIterator.hasNext()) {
Activity activity = activitiesIterator.next();
if (latest.compare(activity.getLastModifiedDate().getValue()) == -1) {
latest = activity.getLastModifiedDate().getValue();
}
}
actContainerV2.setLastModifiedDate(new LastModifiedDate(latest));
}
}
}
use of org.orcid.jaxb.model.common_v2.LastModifiedDate in project ORCID-Source by ORCID.
the class Api2_0_LastModifiedDatesHelper method calculateLastModified.
public static void calculateLastModified(ResearcherUrls researcherUrls) {
if (researcherUrls != null && researcherUrls.getResearcherUrls() != null && !researcherUrls.getResearcherUrls().isEmpty()) {
LastModifiedDate latest = null;
for (ResearcherUrl researcherUrl : researcherUrls.getResearcherUrls()) {
if (researcherUrl.getLastModifiedDate() != null && researcherUrl.getLastModifiedDate().after(latest)) {
latest = researcherUrl.getLastModifiedDate();
}
}
researcherUrls.setLastModifiedDate(latest);
}
}
Aggregations