Search in sources :

Example 11 with OrganizationAddress

use of org.orcid.jaxb.model.common_v2.OrganizationAddress 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 12 with OrganizationAddress

use of org.orcid.jaxb.model.common_v2.OrganizationAddress 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 13 with OrganizationAddress

use of org.orcid.jaxb.model.common_v2.OrganizationAddress 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)

Example 14 with OrganizationAddress

use of org.orcid.jaxb.model.common_v2.OrganizationAddress 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;
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) Organization(org.orcid.jaxb.model.common_v2.Organization) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) OrganizationAddress(org.orcid.jaxb.model.common_v2.OrganizationAddress) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) 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

Organization (org.orcid.jaxb.model.common_v2.Organization)14 OrganizationAddress (org.orcid.jaxb.model.common_v2.OrganizationAddress)14 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)6 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)6 DisambiguatedOrganization (org.orcid.jaxb.model.common_v2.DisambiguatedOrganization)5 FuzzyDate (org.orcid.jaxb.model.common_v2.FuzzyDate)5 Url (org.orcid.jaxb.model.common_v2.Url)5 Title (org.orcid.jaxb.model.common_v2.Title)4 Day (org.orcid.jaxb.model.common_v2.Day)3 Month (org.orcid.jaxb.model.common_v2.Month)3 Year (org.orcid.jaxb.model.common_v2.Year)3 Education (org.orcid.jaxb.model.record_v2.Education)3 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)3 Source (org.orcid.jaxb.model.common_v2.Source)2 Employment (org.orcid.jaxb.model.record_v2.Employment)2 Funding (org.orcid.jaxb.model.record_v2.Funding)2 FundingContributor (org.orcid.jaxb.model.record_v2.FundingContributor)2 FundingTitle (org.orcid.jaxb.model.record_v2.FundingTitle)2 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 URISyntaxException (java.net.URISyntaxException)1