Search in sources :

Example 36 with LastModifiedDate

use of org.orcid.jaxb.model.common_rc3.LastModifiedDate in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ResearcherUrlsTest method testUpdateResearcherUrl.

@Test
public void testUpdateResearcherUrl() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewResearcherUrl("4444-4444-4444-4443", 5L);
    assertNotNull(response);
    ResearcherUrl researcherUrl = (ResearcherUrl) response.getEntity();
    assertNotNull(researcherUrl);
    Utils.verifyLastModified(researcherUrl.getLastModifiedDate());
    LastModifiedDate before = researcherUrl.getLastModifiedDate();
    assertNotNull(researcherUrl.getUrl());
    assertEquals("http://www.researcherurl2.com?id=5", researcherUrl.getUrl().getValue());
    assertEquals("443_3", researcherUrl.getUrlName());
    researcherUrl.setUrl(new Url("http://theNewResearcherUrl.com"));
    researcherUrl.setUrlName("My Updated Researcher Url");
    response = serviceDelegator.updateResearcherUrl("4444-4444-4444-4443", 5L, researcherUrl);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewResearcherUrl("4444-4444-4444-4443", 5L);
    assertNotNull(response);
    researcherUrl = (ResearcherUrl) response.getEntity();
    assertNotNull(researcherUrl);
    Utils.verifyLastModified(researcherUrl.getLastModifiedDate());
    assertTrue(researcherUrl.getLastModifiedDate().after(before));
    assertNotNull(researcherUrl.getUrl());
    assertEquals("http://theNewResearcherUrl.com", researcherUrl.getUrl().getValue());
    assertEquals("My Updated Researcher Url", researcherUrl.getUrlName());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Url(org.orcid.jaxb.model.common_v2.Url) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 37 with LastModifiedDate

use of org.orcid.jaxb.model.common_rc3.LastModifiedDate in project ORCID-Source by ORCID.

the class Api2_0_rc3_LastModifiedDatesHelper 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.common_rc3.LastModifiedDate) Email(org.orcid.jaxb.model.record_rc3.Email)

Example 38 with LastModifiedDate

use of org.orcid.jaxb.model.common_rc3.LastModifiedDate in project ORCID-Source by ORCID.

the class Api2_0_rc4_LastModifiedDatesHelper 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.common_rc4.LastModifiedDate) Email(org.orcid.jaxb.model.record_rc4.Email)

Example 39 with LastModifiedDate

use of org.orcid.jaxb.model.common_rc3.LastModifiedDate in project ORCID-Source by ORCID.

the class Api2_0_rc4_LastModifiedDatesHelper method calculateLastModified.

public static void calculateLastModified(GroupIdRecords groupIdRecords) {
    if (groupIdRecords != null && groupIdRecords.getGroupIdRecord() != null && !groupIdRecords.getGroupIdRecord().isEmpty()) {
        LastModifiedDate latest = null;
        for (GroupIdRecord groupid : groupIdRecords.getGroupIdRecord()) {
            if (groupid.getLastModifiedDate() != null && groupid.getLastModifiedDate().after(latest)) {
                latest = groupid.getLastModifiedDate();
            }
        }
        groupIdRecords.setLastModifiedDate(latest);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_rc4.LastModifiedDate) GroupIdRecord(org.orcid.jaxb.model.groupid_rc4.GroupIdRecord)

Example 40 with LastModifiedDate

use of org.orcid.jaxb.model.common_rc3.LastModifiedDate in project ORCID-Source by ORCID.

the class Api2_0_rc4_LastModifiedDatesHelper method calculateLastModified.

public static void calculateLastModified(ActivitiesContainer actContainerRc4) {
    if (actContainerRc4 != null) {
        Collection<? extends Activity> activities = actContainerRc4.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();
                }
            }
            actContainerRc4.setLastModifiedDate(new LastModifiedDate(latest));
        }
    }
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) LastModifiedDate(org.orcid.jaxb.model.common_rc4.LastModifiedDate) Activity(org.orcid.jaxb.model.record_rc4.Activity) GroupableActivity(org.orcid.jaxb.model.record_rc4.GroupableActivity)

Aggregations

LastModifiedDate (org.orcid.jaxb.model.common_v2.LastModifiedDate)34 Test (org.junit.Test)13 LastModifiedDate (org.orcid.jaxb.model.common_rc3.LastModifiedDate)13 LastModifiedDate (org.orcid.jaxb.model.common_rc4.LastModifiedDate)13 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)12 DBUnitTest (org.orcid.test.DBUnitTest)12 Date (java.util.Date)11 Response (javax.ws.rs.core.Response)10 LastModifiedDate (org.orcid.jaxb.model.common_rc2.LastModifiedDate)10 ArrayList (java.util.ArrayList)7 CreatedDate (org.orcid.jaxb.model.common_v2.CreatedDate)5 Url (org.orcid.jaxb.model.common_v2.Url)5 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)5 Title (org.orcid.jaxb.model.common_v2.Title)3 OtherName (org.orcid.jaxb.model.record_v2.OtherName)3 CreditName (org.orcid.jaxb.model.common_v2.CreditName)2 FuzzyDate (org.orcid.jaxb.model.common_v2.FuzzyDate)2 PublicationDate (org.orcid.jaxb.model.common_v2.PublicationDate)2 Source (org.orcid.jaxb.model.common_v2.Source)2 Subtitle (org.orcid.jaxb.model.common_v2.Subtitle)2