Search in sources :

Example 91 with ExternalID

use of org.orcid.jaxb.model.record_rc2.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());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) Organization(org.orcid.jaxb.model.common_v2.Organization) GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) OrganizationAddress(org.orcid.jaxb.model.common_v2.OrganizationAddress) FuzzyDate(org.orcid.jaxb.model.common_v2.FuzzyDate) URISyntaxException(java.net.URISyntaxException) JSONException(org.codehaus.jettison.json.JSONException) Month(org.orcid.jaxb.model.common_v2.Month) Year(org.orcid.jaxb.model.common_v2.Year) Day(org.orcid.jaxb.model.common_v2.Day) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Test(org.junit.Test)

Example 92 with ExternalID

use of org.orcid.jaxb.model.record_rc2.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());
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) Funding(org.orcid.jaxb.model.record_v2.Funding) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) Title(org.orcid.jaxb.model.common_v2.Title) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) Url(org.orcid.jaxb.model.common_v2.Url)

Example 93 with ExternalID

use of org.orcid.jaxb.model.record_rc2.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;
}
Also used : DisambiguatedOrganization(org.orcid.jaxb.model.common_v2.DisambiguatedOrganization) Organization(org.orcid.jaxb.model.common_v2.Organization) OrganizationAddress(org.orcid.jaxb.model.common_v2.OrganizationAddress) FundingContributor(org.orcid.jaxb.model.record_v2.FundingContributor) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) ArrayList(java.util.ArrayList) FundingContributor(org.orcid.jaxb.model.record_v2.FundingContributor) Source(org.orcid.jaxb.model.common_v2.Source) DisambiguatedOrganization(org.orcid.jaxb.model.common_v2.DisambiguatedOrganization)

Example 94 with ExternalID

use of org.orcid.jaxb.model.record_rc2.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);
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Work(org.orcid.jaxb.model.record_v2.Work) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) Title(org.orcid.jaxb.model.common_v2.Title)

Example 95 with ExternalID

use of org.orcid.jaxb.model.record_rc2.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;
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) Organization(org.orcid.jaxb.model.common_v2.Organization) Funding(org.orcid.jaxb.model.record_v2.Funding) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) OrganizationAddress(org.orcid.jaxb.model.common_v2.OrganizationAddress) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) Title(org.orcid.jaxb.model.common_v2.Title) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) Url(org.orcid.jaxb.model.common_v2.Url)

Aggregations

ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)110 Test (org.junit.Test)97 Url (org.orcid.jaxb.model.common_v2.Url)55 ClientResponse (com.sun.jersey.api.client.ClientResponse)52 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)50 Work (org.orcid.jaxb.model.record_v2.Work)32 Title (org.orcid.jaxb.model.common_v2.Title)28 WorkTitle (org.orcid.jaxb.model.record_v2.WorkTitle)22 Funding (org.orcid.jaxb.model.record_v2.Funding)16 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)16 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)14 ArrayList (java.util.ArrayList)13 ExternalID (org.orcid.jaxb.model.record_rc3.ExternalID)13 ExternalID (org.orcid.jaxb.model.record_rc4.ExternalID)13 FundingTitle (org.orcid.jaxb.model.record_v2.FundingTitle)11 OrcidError (org.orcid.jaxb.model.error_v2.OrcidError)9 WorkGroup (org.orcid.jaxb.model.record.summary_v2.WorkGroup)8 ExternalID (org.orcid.jaxb.model.record_rc2.ExternalID)8 List (java.util.List)7 Validator (javax.xml.validation.Validator)7