Search in sources :

Example 41 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(Addresses addresses) {
    if (addresses != null && addresses.getAddress() != null && !addresses.getAddress().isEmpty()) {
        LastModifiedDate latest = null;
        for (Address address : addresses.getAddress()) {
            if (address.getLastModifiedDate() != null && address.getLastModifiedDate().after(latest)) {
                latest = address.getLastModifiedDate();
            }
        }
        addresses.setLastModifiedDate(latest);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_rc4.LastModifiedDate) Address(org.orcid.jaxb.model.record_rc4.Address)

Example 42 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(GroupsContainer groupsContainerRc4) {
    if (groupsContainerRc4.retrieveGroups() != null && !groupsContainerRc4.retrieveGroups().isEmpty()) {
        List<? extends Group> groupsRc1 = new ArrayList<>(groupsContainerRc4.retrieveGroups());
        List<org.orcid.jaxb.model.record_rc4.Group> groupsRc4 = new ArrayList<>(groupsContainerRc4.retrieveGroups());
        if (groupsRc1.get(0).getActivities() != null && !groupsRc1.get(0).getActivities().isEmpty()) {
            LastModifiedDate latest = null;
            for (Group group : groupsRc4) {
                calculateLastModified(group);
                if (group.getLastModifiedDate() != null && group.getLastModifiedDate().after(latest)) {
                    latest = group.getLastModifiedDate();
                }
            }
            groupsContainerRc4.setLastModifiedDate(latest);
        }
    }
}
Also used : Group(org.orcid.jaxb.model.record_rc4.Group) LastModifiedDate(org.orcid.jaxb.model.common_rc4.LastModifiedDate) ArrayList(java.util.ArrayList)

Example 43 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(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);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_rc4.LastModifiedDate) ResearcherUrl(org.orcid.jaxb.model.record_rc4.ResearcherUrl)

Example 44 with LastModifiedDate

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

the class MemberV2ApiServiceDelegator_ActivitiesSummaryTest method testCleanEmptyFieldsOnActivities.

@Test
public void testCleanEmptyFieldsOnActivities() {
    LastModifiedDate lmd = new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(System.currentTimeMillis()));
    Works works = new Works();
    works.setLastModifiedDate(lmd);
    WorkGroup group = new WorkGroup();
    group.setLastModifiedDate(lmd);
    for (int i = 0; i < 5; i++) {
        WorkSummary summary = new WorkSummary();
        summary.setLastModifiedDate(lmd);
        WorkTitle title = new WorkTitle();
        title.setTitle(new Title("Work " + i));
        title.setTranslatedTitle(new TranslatedTitle("", ""));
        summary.setTitle(title);
        group.getWorkSummary().add(summary);
    }
    works.getWorkGroup().add(group);
    ActivitiesSummary as = new ActivitiesSummary();
    as.setWorks(works);
    ActivityUtils.cleanEmptyFields(as);
    assertNotNull(as);
    assertNotNull(as.getWorks());
    Utils.verifyLastModified(as.getWorks().getLastModifiedDate());
    assertNotNull(as.getWorks().getWorkGroup());
    assertEquals(1, as.getWorks().getWorkGroup().size());
    assertNotNull(as.getWorks().getWorkGroup().get(0).getWorkSummary());
    Utils.verifyLastModified(as.getWorks().getWorkGroup().get(0).getLastModifiedDate());
    assertEquals(5, as.getWorks().getWorkGroup().get(0).getWorkSummary().size());
    for (WorkSummary summary : as.getWorks().getWorkGroup().get(0).getWorkSummary()) {
        Utils.verifyLastModified(summary.getLastModifiedDate());
        assertNotNull(summary.getTitle());
        assertNotNull(summary.getTitle().getTitle());
        assertTrue(summary.getTitle().getTitle().getContent().startsWith("Work "));
        assertNull(summary.getTitle().getTranslatedTitle());
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) Title(org.orcid.jaxb.model.common_v2.Title) Works(org.orcid.jaxb.model.record.summary_v2.Works) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 45 with LastModifiedDate

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

the class MemberV2ApiServiceDelegator_AddressesTest method testUpdateAddress.

@Test
public void testUpdateAddress() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewAddress("4444-4444-4444-4442", 1L);
    assertNotNull(response);
    Address address = (Address) response.getEntity();
    assertNotNull(address);
    Utils.verifyLastModified(address.getLastModifiedDate());
    LastModifiedDate before = address.getLastModifiedDate();
    assertEquals(Iso3166Country.US, address.getCountry().getValue());
    assertEquals(Visibility.PUBLIC, address.getVisibility());
    address.getCountry().setValue(Iso3166Country.PA);
    response = serviceDelegator.updateAddress("4444-4444-4444-4442", 1L, address);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewAddress("4444-4444-4444-4442", 1L);
    assertNotNull(response);
    address = (Address) response.getEntity();
    assertNotNull(address);
    Utils.verifyLastModified(address.getLastModifiedDate());
    LastModifiedDate after = address.getLastModifiedDate();
    assertTrue(after.after(before));
    assertEquals(Iso3166Country.PA, address.getCountry().getValue());
    // Set it back to US again
    address.getCountry().setValue(Iso3166Country.US);
    response = serviceDelegator.updateAddress("4444-4444-4444-4442", 1L, address);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewAddress("4444-4444-4444-4442", 1L);
    address = (Address) response.getEntity();
    assertNotNull(address);
    Utils.verifyLastModified(address.getLastModifiedDate());
    assertNotNull(address.getLastModifiedDate());
    assertTrue(address.getLastModifiedDate().after(after));
    assertEquals(Iso3166Country.US, address.getCountry().getValue());
    assertEquals(Visibility.PUBLIC, address.getVisibility());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Address(org.orcid.jaxb.model.record_v2.Address) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

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