Search in sources :

Example 11 with LastModifiedDate

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

the class KeywordForm method toKeyword.

public Keyword toKeyword() {
    Keyword keyword = new Keyword();
    if (!PojoUtil.isEmpty(putCode)) {
        keyword.setPutCode(Long.valueOf(putCode));
    }
    if (!PojoUtil.isEmpty(content)) {
        keyword.setContent(content);
    }
    if (visibility != null && visibility.getVisibility() != null) {
        keyword.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(visibility.getVisibility().value()));
    } else {
        keyword.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(OrcidVisibilityDefaults.KEYWORD_DEFAULT.getVisibility().value()));
    }
    if (createdDate != null) {
        keyword.setCreatedDate(new CreatedDate(DateUtils.convertToXMLGregorianCalendar(createdDate.toCalendar())));
    }
    if (lastModified != null) {
        keyword.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(lastModified.toCalendar())));
    }
    if (displayIndex != null) {
        keyword.setDisplayIndex(displayIndex);
    } else {
        keyword.setDisplayIndex(0L);
    }
    keyword.setSource(new Source(source));
    return keyword;
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Keyword(org.orcid.jaxb.model.record_v2.Keyword) CreatedDate(org.orcid.jaxb.model.common_v2.CreatedDate) Source(org.orcid.jaxb.model.common_v2.Source)

Example 12 with LastModifiedDate

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

the class MemberV2ApiServiceDelegator_GroupIdTest method testUpdateGroupIdRecord.

@Test
public void testUpdateGroupIdRecord() {
    SecurityContextTestUtils.setUpSecurityContextForGroupIdClientOnly();
    Response response = serviceDelegator.viewGroupIdRecord(Long.valueOf("3"));
    assertNotNull(response);
    GroupIdRecord groupIdRecord = (GroupIdRecord) response.getEntity();
    assertNotNull(groupIdRecord);
    Utils.verifyLastModified(groupIdRecord.getLastModifiedDate());
    LastModifiedDate before = groupIdRecord.getLastModifiedDate();
    // Verify the name
    assertEquals(groupIdRecord.getName(), "TestGroup3");
    // Set a new name for update
    groupIdRecord.setName("TestGroup33");
    serviceDelegator.updateGroupIdRecord(groupIdRecord, Long.valueOf("3"));
    // Get the entity again and verify the name
    response = serviceDelegator.viewGroupIdRecord(Long.valueOf("3"));
    assertNotNull(response);
    GroupIdRecord groupIdRecordNew = (GroupIdRecord) response.getEntity();
    assertNotNull(groupIdRecordNew);
    Utils.verifyLastModified(groupIdRecordNew.getLastModifiedDate());
    assertTrue(groupIdRecordNew.getLastModifiedDate().after(before));
    // Verify the name
    assertEquals(groupIdRecordNew.getName(), "TestGroup33");
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 13 with LastModifiedDate

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

the class MemberV2ApiServiceDelegator_OtherNamesTest method testUpdateOtherName.

@Test
public void testUpdateOtherName() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewOtherName("4444-4444-4444-4443", 1L);
    assertNotNull(response);
    OtherName otherName = (OtherName) response.getEntity();
    assertNotNull(otherName);
    Utils.verifyLastModified(otherName.getLastModifiedDate());
    LastModifiedDate before = otherName.getLastModifiedDate();
    assertEquals("Slibberdy Slabinah", otherName.getContent());
    assertEquals(Visibility.PUBLIC, otherName.getVisibility());
    otherName.setContent("Updated Other Name");
    response = serviceDelegator.updateOtherName("4444-4444-4444-4443", 1L, otherName);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewOtherName("4444-4444-4444-4443", 1L);
    assertNotNull(response);
    OtherName updatedOtherName = (OtherName) response.getEntity();
    assertNotNull(updatedOtherName);
    Utils.verifyLastModified(updatedOtherName.getLastModifiedDate());
    assertTrue(updatedOtherName.getLastModifiedDate().after(before));
    assertEquals("Updated Other Name", updatedOtherName.getContent());
    assertEquals(Visibility.PUBLIC, updatedOtherName.getVisibility());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) OtherName(org.orcid.jaxb.model.record_v2.OtherName) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 14 with LastModifiedDate

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

the class Api2_0_rc2_LastModifiedDatesHelper method calculateLatest.

public static Date calculateLatest(Keywords keywords) {
    Date latestAct = null;
    if (keywords != null && keywords.getKeywords() != null && !keywords.getKeywords().isEmpty()) {
        XMLGregorianCalendar latest = keywords.getKeywords().get(0).getLastModifiedDate().getValue();
        for (Keyword keyword : keywords.getKeywords()) {
            if (latest.compare(keyword.getLastModifiedDate().getValue()) == -1) {
                latest = keyword.getLastModifiedDate().getValue();
            }
        }
        latestAct = latest.toGregorianCalendar().getTime();
        keywords.setLastModifiedDate(new LastModifiedDate(latest));
    }
    return latestAct;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) LastModifiedDate(org.orcid.jaxb.model.common_rc2.LastModifiedDate) Keyword(org.orcid.jaxb.model.record_rc2.Keyword) LastModifiedDate(org.orcid.jaxb.model.common_rc2.LastModifiedDate) Date(java.util.Date)

Example 15 with LastModifiedDate

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

the class Api2_0_rc2_LastModifiedDatesHelper method calculateLatest.

public static Date calculateLatest(PersonExternalIdentifiers extIds) {
    Date latestAct = null;
    if (extIds != null && extIds.getExternalIdentifiers() != null && !extIds.getExternalIdentifiers().isEmpty()) {
        XMLGregorianCalendar latest = extIds.getExternalIdentifiers().get(0).getLastModifiedDate().getValue();
        for (PersonExternalIdentifier extId : extIds.getExternalIdentifiers()) {
            if (latest.compare(extId.getLastModifiedDate().getValue()) == -1) {
                latest = extId.getLastModifiedDate().getValue();
            }
        }
        latestAct = latest.toGregorianCalendar().getTime();
        extIds.setLastModifiedDate(new LastModifiedDate(latest));
    }
    return latestAct;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) LastModifiedDate(org.orcid.jaxb.model.common_rc2.LastModifiedDate) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc2.PersonExternalIdentifier) LastModifiedDate(org.orcid.jaxb.model.common_rc2.LastModifiedDate) Date(java.util.Date)

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