Search in sources :

Example 46 with ResearcherUrl

use of org.orcid.jaxb.model.record_rc2.ResearcherUrl in project ORCID-Source by ORCID.

the class Api2_0_rc2_LastModifiedDatesHelper method calculateLatest.

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

Example 47 with ResearcherUrl

use of org.orcid.jaxb.model.record_rc2.ResearcherUrl in project ORCID-Source by ORCID.

the class ResearcherUrlManagerTest method displayIndexIsSetTo_0_FromAPI.

@Test
public void displayIndexIsSetTo_0_FromAPI() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    ResearcherUrl rUrl = getResearcherUrl();
    rUrl.getUrl().setValue(rUrl.getUrl().getValue() + "/fromAPI");
    rUrl = researcherUrlManager.createResearcherUrl(claimedOrcid, rUrl, true);
    rUrl = researcherUrlManager.getResearcherUrl(claimedOrcid, rUrl.getPutCode());
    assertNotNull(rUrl);
    assertEquals(Long.valueOf(0), rUrl.getDisplayIndex());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 48 with ResearcherUrl

use of org.orcid.jaxb.model.record_rc2.ResearcherUrl in project ORCID-Source by ORCID.

the class ResearcherUrlManagerTest method displayIndexIsSetTo_1_FromUI.

@Test
public void displayIndexIsSetTo_1_FromUI() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    ResearcherUrl rUrl = getResearcherUrl();
    rUrl.getUrl().setValue(rUrl.getUrl().getValue() + "/fromUI");
    rUrl = researcherUrlManager.createResearcherUrl(claimedOrcid, rUrl, false);
    rUrl = researcherUrlManager.getResearcherUrl(claimedOrcid, rUrl.getPutCode());
    assertNotNull(rUrl);
    assertEquals(Long.valueOf(1), rUrl.getDisplayIndex());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 49 with ResearcherUrl

use of org.orcid.jaxb.model.record_rc2.ResearcherUrl in project ORCID-Source by ORCID.

the class ResearcherUrlManagerTest method testAddResearcherUrToClaimedRecordPreserveUserDefaultVisibility.

@Test
public void testAddResearcherUrToClaimedRecordPreserveUserDefaultVisibility() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    ResearcherUrl rUrl = getResearcherUrl();
    rUrl = researcherUrlManager.createResearcherUrl(claimedOrcid, rUrl, true);
    rUrl = researcherUrlManager.getResearcherUrl(claimedOrcid, rUrl.getPutCode());
    assertNotNull(rUrl);
    assertEquals(Visibility.LIMITED, rUrl.getVisibility());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 50 with ResearcherUrl

use of org.orcid.jaxb.model.record_rc2.ResearcherUrl in project ORCID-Source by ORCID.

the class ResearcherUrlManagerTest method getAllTest.

@Test
public void getAllTest() {
    String orcid = "0000-0000-0000-0003";
    ResearcherUrls elements = researcherUrlManager.getResearcherUrls(orcid, System.currentTimeMillis());
    assertNotNull(elements);
    assertNotNull(elements.getResearcherUrls());
    assertEquals(5, elements.getResearcherUrls().size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false, found5 = false;
    for (ResearcherUrl element : elements.getResearcherUrls()) {
        if (13 == element.getPutCode()) {
            found1 = true;
        } else if (14 == element.getPutCode()) {
            found2 = true;
        } else if (15 == element.getPutCode()) {
            found3 = true;
        } else if (16 == element.getPutCode()) {
            found4 = true;
        } else if (17 == element.getPutCode()) {
            found5 = true;
        } else {
            fail("Invalid element found: " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
    assertTrue(found5);
}
Also used : ResearcherUrls(org.orcid.jaxb.model.record_v2.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Aggregations

ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)86 Test (org.junit.Test)76 OtherName (org.orcid.jaxb.model.record_v2.OtherName)45 Address (org.orcid.jaxb.model.record_v2.Address)44 Keyword (org.orcid.jaxb.model.record_v2.Keyword)44 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)44 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)43 Email (org.orcid.jaxb.model.record_v2.Email)41 Biography (org.orcid.jaxb.model.record_v2.Biography)33 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)33 Addresses (org.orcid.jaxb.model.record_v2.Addresses)31 Emails (org.orcid.jaxb.model.record_v2.Emails)31 Keywords (org.orcid.jaxb.model.record_v2.Keywords)31 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)31 Person (org.orcid.jaxb.model.record_v2.Person)30 Name (org.orcid.jaxb.model.record_v2.Name)29 DBUnitTest (org.orcid.test.DBUnitTest)22 Response (javax.ws.rs.core.Response)20 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)18 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)18