use of org.orcid.jaxb.model.record_rc3.ExternalID in project ORCID-Source by ORCID.
the class MemberV2PerformanceTest method createManyWorks.
@Test
public void createManyWorks() throws JSONException, InterruptedException, URISyntaxException {
int numWorks = 1000;
// Amount of linear increase allowed
float scalingFactor = 1.5f;
int numInitialSample = numWorks / 10;
long initialSampleTime = 0;
StopWatch stopWatch = new StopWatch();
stopWatch.start();
for (int i = 1; i <= numWorks; i++) {
StopWatch singleWorkStopWatch = new StopWatch();
singleWorkStopWatch.start();
long time = System.currentTimeMillis();
Work workToCreate = (Work) unmarshallFromPath("/record_2.0/samples/work-2.0.xml", Work.class);
workToCreate.setPutCode(null);
workToCreate.getExternalIdentifiers().getExternalIdentifier().clear();
ExternalID wExtId = new ExternalID();
wExtId.setValue("Work Id " + i + " " + time);
wExtId.setType(WorkExternalIdentifierType.AGR.value());
wExtId.setRelationship(Relationship.SELF);
workToCreate.getExternalIdentifiers().getExternalIdentifier().add(wExtId);
String accessToken = getAccessToken();
ClientResponse postResponse = memberV2ApiClient.createWorkXml(this.getUser1OrcidId(), workToCreate, accessToken);
stopWatch.split();
long splitTime = stopWatch.getSplitTime();
System.out.println("Split time: " + splitTime);
if (i == numInitialSample) {
initialSampleTime = splitTime;
} else if (i > numInitialSample) {
float maxTime = (initialSampleTime / numInitialSample) * scalingFactor * i;
System.out.println("Max time: " + maxTime);
assertTrue("Split time = " + splitTime + ", but max allowed time = " + maxTime + ", when num added = " + i, splitTime <= maxTime);
}
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
String locationPath = postResponse.getLocation().getPath();
assertTrue("Location header path should match pattern, but was " + locationPath, locationPath.matches(".*/v2.0/" + this.getUser1OrcidId() + "/work/\\d+"));
ClientResponse getResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
Work gotWork = getResponse.getEntity(Work.class);
assertEquals("common:title", gotWork.getWorkTitle().getTitle().getContent());
System.out.println("Time for single work = " + singleWorkStopWatch);
}
}
use of org.orcid.jaxb.model.record_rc3.ExternalID in project ORCID-Source by ORCID.
the class SourceInActivitiesTest method getFunding.
private Funding getFunding(String userOrcid) {
Funding funding = new Funding();
funding.setOrganization(getOrganization());
FundingTitle title = new FundingTitle();
title.setTitle(new Title("Title " + System.currentTimeMillis()));
funding.setTitle(title);
funding.setType(org.orcid.jaxb.model.record_v2.FundingType.AWARD);
ExternalID extId = new ExternalID();
extId.setValue("111");
extId.setType(FundingExternalIdentifierType.GRANT_NUMBER.value());
extId.setUrl(new Url("http://test.com"));
extId.setRelationship(Relationship.PART_OF);
ExternalIDs extIdentifiers = new ExternalIDs();
extIdentifiers.getExternalIdentifier().add(extId);
funding.setExternalIdentifiers(extIdentifiers);
funding = profileFundingManager.createFunding(userOrcid, funding, true);
return profileFundingManager.getFunding(userOrcid, funding.getPutCode());
}
use of org.orcid.jaxb.model.record_rc3.ExternalID in project ORCID-Source by ORCID.
the class ProfileFundingManagerTest method getFunding.
private Funding getFunding(String grantNumber) {
Funding funding = new Funding();
ExternalIDs extIds = new ExternalIDs();
ExternalID extId = new ExternalID();
extId.setRelationship(Relationship.SELF);
extId.setType("grant_number");
extId.setUrl(new Url("http://orcid.org"));
if (grantNumber == null) {
extId.setValue("ext-id-value");
} else {
extId.setValue(grantNumber);
}
extIds.getExternalIdentifier().add(extId);
funding.setExternalIdentifiers(extIds);
FundingTitle title = new FundingTitle();
if (grantNumber == null) {
title.setTitle(new Title("Funding title"));
} else {
title.setTitle(new Title("Funding title " + grantNumber));
}
funding.setTitle(title);
Organization org = new Organization();
org.setName("org-name");
OrganizationAddress address = new OrganizationAddress();
address.setCity("city");
address.setCountry(Iso3166Country.US);
org.setAddress(address);
funding.setOrganization(org);
funding.setVisibility(Visibility.PUBLIC);
funding.setType(FundingType.AWARD);
return funding;
}
use of org.orcid.jaxb.model.record_rc3.ExternalID in project ORCID-Source by ORCID.
the class ProfileFundingManagerTest method getFundingSummary.
private FundingSummary getFundingSummary(String titleValue, String extIdValue, Visibility visibility) {
FundingSummary summary = new FundingSummary();
FundingTitle fundingTitle = new FundingTitle();
fundingTitle.setTitle(new Title(titleValue));
summary.setTitle(fundingTitle);
summary.setVisibility(visibility);
ExternalIDs extIds = new ExternalIDs();
ExternalID extId = new ExternalID();
extId.setRelationship(Relationship.SELF);
extId.setType("doi");
extId.setUrl(new Url("http://orcid.org"));
extId.setValue(extIdValue);
extIds.getExternalIdentifier().add(extId);
summary.setExternalIdentifiers(extIds);
Organization org = new Organization();
org.setName("org-name");
OrganizationAddress address = new OrganizationAddress();
address.setCity("city");
address.setCountry(Iso3166Country.US);
org.setAddress(address);
summary.setOrganization(org);
return summary;
}
use of org.orcid.jaxb.model.record_rc3.ExternalID in project ORCID-Source by ORCID.
the class JpaJaxbWorkAdapterTest method fromProfileWorkEntityToWorkTest.
@Test
public void fromProfileWorkEntityToWorkTest() {
// Set base url to https to ensure source URI is converted to http
orcidUrlManager.setBaseUrl("https://testserver.orcid.org");
WorkEntity work = getWorkEntity();
assertNotNull(work);
Work w = jpaJaxbWorkAdapter.toWork(work);
assertNotNull(w);
assertNotNull(w.getCreatedDate());
assertEquals(DateUtils.convertToDate("2015-06-05T10:15:20"), DateUtils.convertToDate(w.getCreatedDate().getValue()));
assertNotNull(w.getLastModifiedDate());
assertEquals(DateUtils.convertToDate("2015-06-05T10:15:20"), DateUtils.convertToDate(w.getLastModifiedDate().getValue()));
assertEquals(org.orcid.jaxb.model.common_v2.Iso3166Country.CR.value(), w.getCountry().getValue().value());
assertEquals("work:citation", w.getWorkCitation().getCitation());
assertEquals("work:description", w.getShortDescription());
assertEquals("work:journalTitle", w.getJournalTitle().getContent());
assertEquals(CitationType.BIBTEX.value(), w.getWorkCitation().getWorkCitationType().value());
assertEquals(Long.valueOf(12345), w.getPutCode());
assertEquals(Visibility.LIMITED.value(), w.getVisibility().value());
assertEquals("work:title", w.getWorkTitle().getTitle().getContent());
assertEquals("work:subtitle", w.getWorkTitle().getSubtitle().getContent());
assertEquals("work:translatedTitle", w.getWorkTitle().getTranslatedTitle().getContent());
assertEquals("ES", w.getWorkTitle().getTranslatedTitle().getLanguageCode());
assertEquals(WorkType.ARTISTIC_PERFORMANCE.value(), w.getWorkType().value());
assertNotNull(w.getWorkExternalIdentifiers());
assertNotNull(w.getWorkExternalIdentifiers().getExternalIdentifier());
assertEquals(1, w.getWorkExternalIdentifiers().getExternalIdentifier().size());
ExternalID workExtId = w.getWorkExternalIdentifiers().getExternalIdentifier().get(0);
assertNotNull(workExtId.getValue());
assertEquals("123", workExtId.getValue());
assertNotNull(workExtId.getType());
assertEquals(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value(), workExtId.getType());
String sourcePath = w.getSource().retrieveSourcePath();
assertNotNull(sourcePath);
assertEquals("APP-5555555555555555", sourcePath);
// Identifier URIs should always be http, event if base url is https
assertEquals("http://testserver.orcid.org/client/APP-5555555555555555", w.getSource().retriveSourceUri());
}
Aggregations