use of org.orcid.jaxb.model.record_rc4.ExternalID in project ORCID-Source by ORCID.
the class PublicProfileVisibilityTest method peerReviewPrivacyTest.
@Test
public void peerReviewPrivacyTest() throws InterruptedException, JSONException, URISyntaxException {
// Create peer review group
String accessToken = getAccessToken(getScopes(ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE, ScopePathType.ACTIVITIES_READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE));
List<GroupIdRecord> groups = createGroupIds();
assertNotNull(groups);
assertTrue(groups.size() > 0);
GroupIdRecord g1 = groups.get(0);
// Create peer review
long time = System.currentTimeMillis();
PeerReview peerReview = new PeerReview();
peerReview.setGroupId(g1.getGroupId());
ExternalIDs extIds = new ExternalIDs();
peerReview.setExternalIdentifiers(extIds);
peerReview.getExternalIdentifiers().getExternalIdentifier().clear();
ExternalID wExtId = new ExternalID();
wExtId.setValue("Work Id " + time);
wExtId.setType(WorkExternalIdentifierType.AGR.value());
wExtId.setRelationship(Relationship.SELF);
peerReview.getExternalIdentifiers().getExternalIdentifier().add(wExtId);
Organization organization = new Organization();
organization.setName("My org name " + System.currentTimeMillis());
OrganizationAddress address = new OrganizationAddress();
address.setCity("Imagination city");
address.setCountry(Iso3166Country.US);
organization.setAddress(address);
peerReview.setOrganization(organization);
peerReview.setRole(Role.CHAIR);
peerReview.setType(PeerReviewType.EVALUATION);
peerReview.setCompletionDate(new FuzzyDate(new Year(2016), new Month(1), new Day(1)));
ClientResponse postResponse = memberV2ApiClient.createPeerReviewXml(this.getUser1OrcidId(), peerReview, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
ClientResponse getResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
peerReview = getResponse.getEntity(PeerReview.class);
showMyOrcidPage();
changePeerReviewVisibility(g1.getName(), Visibility.PRIVATE);
try {
//Verify it doesn't appear in the public page
showPublicProfilePage(getUser1OrcidId());
peerReviewAppearsInPublicPage(g1.getName());
fail();
} catch (Exception e) {
}
showMyOrcidPage();
changePeerReviewVisibility(g1.getName(), Visibility.LIMITED);
try {
//Verify it doesn't appear in the public page
showPublicProfilePage(getUser1OrcidId());
peerReviewAppearsInPublicPage(g1.getName());
fail();
} catch (Exception e) {
}
showMyOrcidPage();
changePeerReviewVisibility(g1.getName(), Visibility.PUBLIC);
showPublicProfilePage(getUser1OrcidId());
peerReviewAppearsInPublicPage(g1.getName());
// Rollback
ClientResponse deleteResponse = memberV2ApiClient.deletePeerReviewXml(this.getUser1OrcidId(), peerReview.getPutCode(), accessToken);
assertNotNull(deleteResponse);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
use of org.orcid.jaxb.model.record_rc4.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_rc4.ExternalID in project ORCID-Source by ORCID.
the class FundingForm method valueOf.
public static FundingForm valueOf(Funding funding) {
FundingForm result = new FundingForm();
result.setDateSortString(PojoUtil.createDateSortString(funding.getStartDate(), funding.getEndDate()));
if (funding.getPutCode() != null)
result.setPutCode(Text.valueOf(funding.getPutCode()));
if (funding.getAmount() != null) {
if (StringUtils.isNotEmpty(funding.getAmount().getContent())) {
String cleanNumber = funding.getAmount().getContent().trim();
result.setAmount(Text.valueOf(cleanNumber));
}
if (funding.getAmount().getCurrencyCode() != null)
result.setCurrencyCode(Text.valueOf(funding.getAmount().getCurrencyCode()));
else
result.setCurrencyCode(new Text());
} else {
result.setAmount(new Text());
result.setCurrencyCode(new Text());
}
if (StringUtils.isNotEmpty(funding.getDescription()))
result.setDescription(Text.valueOf(funding.getDescription()));
else
result.setDescription(new Text());
if (funding.getStartDate() != null)
result.setStartDate(Date.valueOf(funding.getStartDate()));
if (funding.getEndDate() != null)
result.setEndDate(Date.valueOf(funding.getEndDate()));
if (funding.getType() != null)
result.setFundingType(Text.valueOf(funding.getType().value()));
else
result.setFundingType(new Text());
if (funding.getOrganizationDefinedType() != null) {
OrgDefinedFundingSubType OrgDefinedFundingSubType = new OrgDefinedFundingSubType();
OrgDefinedFundingSubType.setSubtype(Text.valueOf(funding.getOrganizationDefinedType().getContent()));
OrgDefinedFundingSubType.setAlreadyIndexed(false);
result.setOrganizationDefinedFundingSubType(OrgDefinedFundingSubType);
}
Source source = funding.getSource();
if (source != null) {
result.setSource(source.retrieveSourcePath());
if (source.getSourceName() != null) {
result.setSourceName(source.getSourceName().getContent());
}
}
if (funding.getTitle() != null) {
FundingTitleForm fundingTitle = new FundingTitleForm();
if (funding.getTitle().getTitle() != null)
fundingTitle.setTitle(Text.valueOf(funding.getTitle().getTitle().getContent()));
else
fundingTitle.setTitle(new Text());
if (funding.getTitle().getTranslatedTitle() != null) {
TranslatedTitleForm translatedTitle = new TranslatedTitleForm();
translatedTitle.setContent(funding.getTitle().getTranslatedTitle().getContent());
translatedTitle.setLanguageCode(funding.getTitle().getTranslatedTitle().getLanguageCode());
fundingTitle.setTranslatedTitle(translatedTitle);
}
result.setFundingTitle(fundingTitle);
} else {
FundingTitleForm fundingTitle = new FundingTitleForm();
fundingTitle.setTitle(new Text());
result.setFundingTitle(fundingTitle);
}
if (funding.getUrl() != null)
result.setUrl(Text.valueOf(funding.getUrl().getValue()));
else
result.setUrl(new Text());
if (funding.getVisibility() != null)
result.setVisibility(Visibility.valueOf(funding.getVisibility()));
// Set the disambiguated organization
Organization organization = funding.getOrganization();
result.setFundingName(Text.valueOf(organization.getName()));
DisambiguatedOrganization disambiguatedOrganization = organization.getDisambiguatedOrganization();
if (disambiguatedOrganization != null) {
if (StringUtils.isNotEmpty(disambiguatedOrganization.getDisambiguatedOrganizationIdentifier())) {
result.setDisambiguatedFundingSourceId(Text.valueOf(disambiguatedOrganization.getDisambiguatedOrganizationIdentifier()));
result.setDisambiguationSource(Text.valueOf(disambiguatedOrganization.getDisambiguationSource()));
}
}
OrganizationAddress organizationAddress = organization.getAddress();
if (organizationAddress != null) {
if (!PojoUtil.isEmpty(organizationAddress.getCity()))
result.setCity(Text.valueOf(organizationAddress.getCity()));
else
result.setCity(new Text());
if (!PojoUtil.isEmpty(organizationAddress.getRegion()))
result.setRegion(Text.valueOf(organizationAddress.getRegion()));
else
result.setRegion(new Text());
if (organizationAddress.getCountry() != null)
result.setCountry(Text.valueOf(organizationAddress.getCountry().value()));
else
result.setCountry(new Text());
} else {
result.setCountry(new Text());
result.setCity(new Text());
result.setRegion(new Text());
}
// Set contributors
if (funding.getContributors() != null) {
List<Contributor> contributors = new ArrayList<Contributor>();
for (FundingContributor fContributor : funding.getContributors().getContributor()) {
Contributor contributor = Contributor.valueOf(fContributor);
contributors.add(contributor);
}
result.setContributors(contributors);
}
List<FundingExternalIdentifierForm> externalIdentifiersList = new ArrayList<FundingExternalIdentifierForm>();
// Set external identifiers
if (funding.getExternalIdentifiers() != null) {
for (ExternalID fExternalIdentifier : funding.getExternalIdentifiers().getExternalIdentifier()) {
FundingExternalIdentifierForm fundingExternalIdentifierForm = FundingExternalIdentifierForm.valueOf(fExternalIdentifier);
externalIdentifiersList.add(fundingExternalIdentifierForm);
}
}
result.setExternalIdentifiers(externalIdentifiersList);
result.setCreatedDate(Date.valueOf(funding.getCreatedDate()));
result.setLastModified(Date.valueOf(funding.getLastModifiedDate()));
return result;
}
use of org.orcid.jaxb.model.record_rc4.ExternalID in project ORCID-Source by ORCID.
the class SourceInActivitiesTest method getWorkWithPutCode.
private Work getWorkWithPutCode(String userOrcid, boolean validate) {
Work work = new Work();
WorkTitle title = new WorkTitle();
title.setTitle(new Title("Work " + System.currentTimeMillis()));
work.setWorkTitle(title);
ExternalID extId = new ExternalID();
extId.setValue("111");
extId.setType(WorkExternalIdentifierType.DOI.value());
ExternalIDs extIdentifiers = new ExternalIDs();
extIdentifiers.getExternalIdentifier().add(extId);
work.setWorkExternalIdentifiers(extIdentifiers);
work.setWorkType(org.orcid.jaxb.model.record_v2.WorkType.BOOK);
work.setPutCode(Long.valueOf(111));
work = workManager.createWork(userOrcid, work, validate);
return workManager.getWork(userOrcid, work.getPutCode(), 0L);
}
use of org.orcid.jaxb.model.record_rc4.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;
}
Aggregations