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;
}
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());
}
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());
}
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());
}
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);
}
Aggregations