use of org.orcid.jaxb.model.record_rc4.ResearcherUrl in project ORCID-Source by ORCID.
the class ValidateV2_1SamplesTest method testUnmarshallResearcherUrl.
@Test
public void testUnmarshallResearcherUrl() throws SAXException, URISyntaxException {
ResearcherUrls rUrls = (ResearcherUrls) unmarshallFromPath("/record_2.1/samples/read_samples/researcher-urls-2.1.xml", ResearcherUrls.class, "/record_2.1/researcher-url-2.1.xsd");
assertNotNull(rUrls);
assertNotNull(rUrls.getResearcherUrls());
assertEquals(1, rUrls.getResearcherUrls().size());
assertNotNull(rUrls.getResearcherUrls().get(0).getCreatedDate());
assertNotNull(rUrls.getResearcherUrls().get(0).getLastModifiedDate());
validateSourceInHttps(rUrls.getResearcherUrls().get(0).getSource());
assertEquals("Site # 1", rUrls.getResearcherUrls().get(0).getUrlName());
assertEquals("http://site1.com/", rUrls.getResearcherUrls().get(0).getUrl().getValue());
assertEquals(Long.valueOf(1248), rUrls.getResearcherUrls().get(0).getPutCode());
assertEquals(Visibility.PUBLIC.value(), rUrls.getResearcherUrls().get(0).getVisibility().value());
assertNotNull(rUrls.getResearcherUrls().get(0).getSource());
assertEquals("https://www.orcid.org/8888-8888-8888-8880", rUrls.getResearcherUrls().get(0).getSource().retriveSourceUri());
assertEquals("8888-8888-8888-8880", rUrls.getResearcherUrls().get(0).getSource().retrieveSourcePath());
ResearcherUrl rUrl = (ResearcherUrl) unmarshallFromPath("/record_2.1/samples/read_samples/researcher-url-2.1.xml", ResearcherUrl.class);
assertNotNull(rUrl);
assertEquals("Site # 1", rUrl.getUrlName());
assertNotNull(rUrl.getUrl());
assertEquals("http://site1.com/", rUrl.getUrl().getValue());
assertNotNull(rUrl.getCreatedDate());
assertNotNull(rUrl.getLastModifiedDate());
assertNotNull(rUrl.getSource());
validateSourceInHttps(rUrl.getSource());
assertEquals("8888-8888-8888-8880", rUrl.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.record_rc4.ResearcherUrl in project ORCID-Source by ORCID.
the class ValidateV2_1SamplesTest method unmarshallFromPath.
private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
Object obj = unmarshall(reader, type, schemaPath);
Object result = null;
if (ResearcherUrls.class.equals(type)) {
result = (ResearcherUrls) obj;
} else if (ResearcherUrl.class.equals(type)) {
result = (ResearcherUrl) obj;
} else if (PersonalDetails.class.equals(type)) {
result = (PersonalDetails) obj;
} else if (PersonExternalIdentifier.class.equals(type)) {
result = (PersonExternalIdentifier) obj;
} else if (PersonExternalIdentifiers.class.equals(type)) {
result = (PersonExternalIdentifiers) obj;
} else if (Biography.class.equals(type)) {
result = (Biography) obj;
} else if (Name.class.equals(type)) {
result = (Name) obj;
} else if (CreditName.class.equals(type)) {
result = (CreditName) obj;
} else if (OtherName.class.equals(type)) {
result = (OtherName) obj;
} else if (OtherNames.class.equals(type)) {
result = (OtherNames) obj;
} else if (Keywords.class.equals(type)) {
result = (Keywords) obj;
} else if (Keyword.class.equals(type)) {
result = (Keyword) obj;
} else if (Addresses.class.equals(type)) {
result = (Addresses) obj;
} else if (Address.class.equals(type)) {
result = (Address) obj;
} else if (Emails.class.equals(type)) {
result = (Emails) obj;
} else if (Email.class.equals(type)) {
result = (Email) obj;
} else if (Person.class.equals(type)) {
result = (Person) obj;
} else if (Deprecated.class.equals(type)) {
result = (Deprecated) obj;
} else if (Preferences.class.equals(type)) {
result = (Preferences) obj;
} else if (History.class.equals(type)) {
result = (History) obj;
} else if (Record.class.equals(type)) {
result = (Record) obj;
} else if (ActivitiesSummary.class.equals(type)) {
result = (ActivitiesSummary) obj;
} else if (Works.class.equals(type)) {
result = (Works) obj;
}
return result;
} catch (IOException e) {
throw new RuntimeException("Error reading notification from classpath", e);
}
}
use of org.orcid.jaxb.model.record_rc4.ResearcherUrl in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorTest method testViewResearcherUrls.
@Test
public void testViewResearcherUrls() {
Response response = serviceDelegator.viewResearcherUrls(ORCID);
assertNotNull(response);
ResearcherUrls rUrls = (ResearcherUrls) response.getEntity();
assertNotNull(rUrls);
assertNotNull(rUrls.getLastModifiedDate());
assertNotNull(rUrls.getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/researcher-urls", rUrls.getPath());
assertEquals(1, rUrls.getResearcherUrls().size());
ResearcherUrl rUrl = rUrls.getResearcherUrls().get(0);
assertNotNull(rUrl);
assertNotNull(rUrl.getLastModifiedDate());
assertNotNull(rUrl.getLastModifiedDate().getValue());
assertNotNull(rUrl.getUrl());
assertEquals("http://www.researcherurl.com?id=13", rUrl.getUrl().getValue());
assertEquals("public_rurl", rUrl.getUrlName());
assertEquals(Visibility.PUBLIC.value(), rUrl.getVisibility().value());
assertEquals("/0000-0000-0000-0003/researcher-urls/13", rUrl.getPath());
assertEquals("APP-5555555555555555", rUrl.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.record_rc4.ResearcherUrl in project ORCID-Source by ORCID.
the class Utils method getResearcherUrl.
public static ResearcherUrl getResearcherUrl() {
ResearcherUrl rUrl = new ResearcherUrl();
rUrl.setUrl(new Url("http://www.myRUrl.com"));
rUrl.setUrlName("My researcher Url");
rUrl.setVisibility(Visibility.LIMITED);
return rUrl;
}
use of org.orcid.jaxb.model.record_rc4.ResearcherUrl in project ORCID-Source by ORCID.
the class Api2_0_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);
}
}
Aggregations