Search in sources :

Example 26 with LastModifiedDate

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);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) Email(org.orcid.jaxb.model.v3.dev1.record.Email)

Example 27 with LastModifiedDate

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());
}
Also used : LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) Subtitle(org.orcid.jaxb.model.v3.dev1.common.Subtitle) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Work(org.orcid.jaxb.model.v3.dev1.record.Work) Title(org.orcid.jaxb.model.v3.dev1.common.Title) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Citation(org.orcid.jaxb.model.v3.dev1.record.Citation) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 28 with LastModifiedDate

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;
}
Also used : LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) CreatedDate(org.orcid.jaxb.model.v3.dev1.common.CreatedDate)

Example 29 with LastModifiedDate

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);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate)

Example 30 with LastModifiedDate

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);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate)

Aggregations

LastModifiedDate (org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate)45 Test (org.junit.Test)18 DBUnitTest (org.orcid.test.DBUnitTest)17 Response (javax.ws.rs.core.Response)15 CreatedDate (org.orcid.jaxb.model.v3.dev1.common.CreatedDate)8 DisambiguatedOrganization (org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization)7 Url (org.orcid.jaxb.model.v3.dev1.common.Url)5 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)5 ArrayList (java.util.ArrayList)4 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)4 FuzzyDate (org.orcid.jaxb.model.v3.dev1.common.FuzzyDate)3 PublicationDate (org.orcid.jaxb.model.v3.dev1.common.PublicationDate)3 Title (org.orcid.jaxb.model.v3.dev1.common.Title)3 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)3 Name (org.orcid.jaxb.model.v3.dev1.record.Name)3 WorkGroup (org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup)3 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)3 Works (org.orcid.jaxb.model.v3.dev1.record.summary.Works)3 Date (java.util.Date)2 CreditName (org.orcid.jaxb.model.v3.dev1.common.CreditName)2