Search in sources :

Example 1 with FuzzyDate

use of org.orcid.jaxb.model.message.FuzzyDate in project ORCID-Source by ORCID.

the class T2OrcidApiServiceVersionedDelegatorTest method buildMessageWithAffiliation.

private OrcidMessage buildMessageWithAffiliation(AffiliationType type, String dept, String role, String orcid) {
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier(orcid));
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    Affiliations affiliations = new Affiliations();
    Affiliation affiliation = new Affiliation();
    affiliation.setStartDate(new FuzzyDate(2010, 01, 01));
    affiliation.setEndDate(new FuzzyDate(2015, 01, 01));
    affiliation.setDepartmentName(dept);
    affiliation.setRoleTitle(role);
    affiliation.setType(type);
    Organization organization = new Organization();
    organization.setName("My Org");
    OrganizationAddress add = new OrganizationAddress();
    add.setCity("My City");
    add.setCountry(Iso3166Country.US);
    organization.setAddress(add);
    DisambiguatedOrganization dorg = new DisambiguatedOrganization();
    dorg.setDisambiguatedOrganizationIdentifier("disambiguated org ID");
    dorg.setDisambiguationSource("THESOURCE");
    organization.setDisambiguatedOrganization(dorg);
    affiliation.setOrganization(organization);
    affiliations.getAffiliation().add(affiliation);
    orcidActivities.setAffiliations(affiliations);
    return orcidMessage;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) DisambiguatedOrganization(org.orcid.jaxb.model.message.DisambiguatedOrganization) Organization(org.orcid.jaxb.model.message.Organization) DisambiguatedOrganization(org.orcid.jaxb.model.message.DisambiguatedOrganization) Affiliations(org.orcid.jaxb.model.message.Affiliations) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) FuzzyDate(org.orcid.jaxb.model.message.FuzzyDate) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) Affiliation(org.orcid.jaxb.model.message.Affiliation)

Example 2 with FuzzyDate

use of org.orcid.jaxb.model.message.FuzzyDate in project ORCID-Source by ORCID.

the class Api12Helper method addFunding.

protected static void addFunding(String userOrcid, String token, String title, T2OAuthAPIService<ClientResponse> oauthT2Client) {
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion(OrcidMessage.DEFAULT_VERSION);
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    FundingList fundings = new FundingList();
    Funding funding = new Funding();
    funding.setVisibility(Visibility.LIMITED);
    FundingTitle fundingTitle = new FundingTitle();
    fundingTitle.setTitle(new Title(title));
    funding.setTitle(fundingTitle);
    funding.setType(FundingType.SALARY_AWARD);
    Amount amount = new Amount();
    amount.setCurrencyCode("CRC");
    amount.setContent("1,250,000");
    funding.setAmount(amount);
    funding.setStartDate(new FuzzyDate(2010, 1, 1));
    funding.setEndDate(new FuzzyDate(2013, 1, 1));
    funding.setDescription("My Grant description");
    funding.setUrl(new Url("http://url.com"));
    Organization org = new Organization();
    org.setName("Orcid Integration Test Org");
    OrganizationAddress add = new OrganizationAddress();
    add.setCity("My City");
    add.setCountry(Iso3166Country.CR);
    org.setAddress(add);
    funding.setOrganization(org);
    FundingExternalIdentifier extIdentifier = new FundingExternalIdentifier();
    extIdentifier.setType(FundingExternalIdentifierType.fromValue("grant_number"));
    extIdentifier.setUrl(new Url("http://url.com"));
    extIdentifier.setValue("My value");
    FundingExternalIdentifiers extIdentifiers = new FundingExternalIdentifiers();
    extIdentifiers.getFundingExternalIdentifier().add(extIdentifier);
    funding.setFundingExternalIdentifiers(extIdentifiers);
    FundingContributors contributors = new FundingContributors();
    FundingContributor contributor = new FundingContributor();
    contributor.setCreditName(new CreditName("My Credit Name"));
    contributor.setContributorEmail(new ContributorEmail("my.email@orcid-integration-test.com"));
    FundingContributorAttributes attributes = new FundingContributorAttributes();
    attributes.setContributorRole(FundingContributorRole.LEAD);
    contributor.setContributorAttributes(attributes);
    contributors.getContributor().add(contributor);
    funding.setFundingContributors(contributors);
    fundings.getFundings().add(funding);
    orcidMessage.getOrcidProfile().getOrcidActivities().setFundings(fundings);
    ClientResponse clientResponse = oauthT2Client.addFundingXml(userOrcid, orcidMessage, token);
    assertEquals(201, clientResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Organization(org.orcid.jaxb.model.message.Organization) Funding(org.orcid.jaxb.model.message.Funding) Amount(org.orcid.jaxb.model.message.Amount) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) FundingContributor(org.orcid.jaxb.model.message.FundingContributor) FuzzyDate(org.orcid.jaxb.model.message.FuzzyDate) CreditName(org.orcid.jaxb.model.message.CreditName) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) FundingExternalIdentifier(org.orcid.jaxb.model.message.FundingExternalIdentifier) ContributorEmail(org.orcid.jaxb.model.message.ContributorEmail) Url(org.orcid.jaxb.model.message.Url) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) FundingList(org.orcid.jaxb.model.message.FundingList) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) FundingContributors(org.orcid.jaxb.model.message.FundingContributors) FundingContributorAttributes(org.orcid.jaxb.model.message.FundingContributorAttributes) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) FundingExternalIdentifiers(org.orcid.jaxb.model.message.FundingExternalIdentifiers)

Example 3 with FuzzyDate

use of org.orcid.jaxb.model.message.FuzzyDate in project ORCID-Source by ORCID.

the class Jaxb2JpaAdapterImpl method getOrgAffiliationRelationEntity.

private OrgAffiliationRelationEntity getOrgAffiliationRelationEntity(Affiliation affiliation, OrgAffiliationRelationEntity exisitingOrgAffiliationEntity) {
    if (affiliation != null) {
        // Get the org
        OrgEntity orgEntity = getOrgEntity(affiliation);
        OrgAffiliationRelationEntity orgRelationEntity = null;
        if (exisitingOrgAffiliationEntity == null) {
            String putCode = affiliation.getPutCode();
            if (StringUtils.isNotBlank(putCode) && !"-1".equals(putCode)) {
                throw new IllegalArgumentException("Invalid put-code was supplied for an affiliation: " + putCode);
            }
            orgRelationEntity = new OrgAffiliationRelationEntity();
        } else {
            orgRelationEntity = exisitingOrgAffiliationEntity;
            orgRelationEntity.clean();
        }
        FuzzyDate startDate = affiliation.getStartDate();
        FuzzyDate endDate = affiliation.getEndDate();
        if (affiliation.getType() != null) {
            orgRelationEntity.setAffiliationType(AffiliationType.fromValue(affiliation.getType().value()));
        }
        if (affiliation.getVisibility() != null) {
            orgRelationEntity.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(affiliation.getVisibility().value()));
        } else {
            orgRelationEntity.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
        }
        //Set source
        setSource(affiliation.getSource(), orgRelationEntity);
        orgRelationEntity.setDepartment(affiliation.getDepartmentName());
        orgRelationEntity.setEndDate(endDate != null ? new EndDateEntity(endDate) : null);
        orgRelationEntity.setOrg(orgEntity);
        orgRelationEntity.setTitle(affiliation.getRoleTitle());
        orgRelationEntity.setStartDate(startDate != null ? new StartDateEntity(startDate) : null);
        if (affiliation.getCreatedDate() != null && affiliation.getCreatedDate().getValue() != null)
            orgRelationEntity.setDateCreated(affiliation.getCreatedDate().getValue().toGregorianCalendar().getTime());
        if (affiliation.getLastModifiedDate() != null && affiliation.getLastModifiedDate().getValue() != null)
            orgRelationEntity.setLastModified(affiliation.getLastModifiedDate().getValue().toGregorianCalendar().getTime());
        return orgRelationEntity;
    }
    return null;
}
Also used : EndDateEntity(org.orcid.persistence.jpa.entities.EndDateEntity) StartDateEntity(org.orcid.persistence.jpa.entities.StartDateEntity) FuzzyDate(org.orcid.jaxb.model.message.FuzzyDate) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity)

Example 4 with FuzzyDate

use of org.orcid.jaxb.model.message.FuzzyDate in project ORCID-Source by ORCID.

the class T2OrcidApiServiceVersionedDelegatorTest method addAffiliationTest.

@Test
public void addAffiliationTest() {
    setUpSecurityContext();
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4441"));
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    Affiliations affiliations = new Affiliations();
    Affiliation affiliation = new Affiliation();
    affiliation.setStartDate(new FuzzyDate(2010, 01, 01));
    affiliation.setEndDate(new FuzzyDate(2015, 01, 01));
    affiliation.setDepartmentName("Dep Name");
    affiliation.setRoleTitle("Role Title");
    affiliation.setType(AffiliationType.EDUCATION);
    Organization organization = new Organization();
    organization.setName("My Org");
    OrganizationAddress add = new OrganizationAddress();
    add.setCity("My City");
    add.setCountry(Iso3166Country.US);
    organization.setAddress(add);
    affiliation.setOrganization(organization);
    affiliations.getAffiliation().add(affiliation);
    orcidActivities.setAffiliations(affiliations);
    Response response = t2OrcidApiServiceDelegatorLatest.addAffiliations(mockedUriInfo, "4444-4444-4444-4441", orcidMessage);
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    assertEquals(1, orgAffiliationRelationDao.getByUserAndType("4444-4444-4444-4441", org.orcid.jaxb.model.record_v2.AffiliationType.EDUCATION).size());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Response(javax.ws.rs.core.Response) DisambiguatedOrganization(org.orcid.jaxb.model.message.DisambiguatedOrganization) Organization(org.orcid.jaxb.model.message.Organization) Affiliations(org.orcid.jaxb.model.message.Affiliations) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) FuzzyDate(org.orcid.jaxb.model.message.FuzzyDate) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) Affiliation(org.orcid.jaxb.model.message.Affiliation) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 5 with FuzzyDate

use of org.orcid.jaxb.model.message.FuzzyDate in project ORCID-Source by ORCID.

the class OrcidProfileManagerBaseTest method getAffiliation.

public Affiliation getAffiliation() throws DatatypeConfigurationException {
    GregorianCalendar cal = new GregorianCalendar();
    XMLGregorianCalendar calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
    Affiliation affiliation = new Affiliation();
    affiliation.setStartDate(new FuzzyDate(calendar.getYear(), calendar.getMonth(), calendar.getDay()));
    affiliation.setEndDate(new FuzzyDate(calendar.getYear(), calendar.getMonth(), calendar.getDay()));
    affiliation.setType(AffiliationType.EDUCATION);
    affiliation.setRoleTitle("A Role");
    affiliation.setDepartmentName("A Department");
    Organization organization = new Organization();
    affiliation.setOrganization(organization);
    organization.setName("Past Institution");
    OrganizationAddress address = new OrganizationAddress();
    address.setCountry(Iso3166Country.GB);
    organization.setAddress(address);
    return affiliation;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Organization(org.orcid.jaxb.model.message.Organization) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) FuzzyDate(org.orcid.jaxb.model.message.FuzzyDate) Affiliation(org.orcid.jaxb.model.message.Affiliation)

Aggregations

FuzzyDate (org.orcid.jaxb.model.message.FuzzyDate)6 Organization (org.orcid.jaxb.model.message.Organization)4 OrganizationAddress (org.orcid.jaxb.model.message.OrganizationAddress)4 Affiliation (org.orcid.jaxb.model.message.Affiliation)3 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)3 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)3 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)3 Affiliations (org.orcid.jaxb.model.message.Affiliations)2 DisambiguatedOrganization (org.orcid.jaxb.model.message.DisambiguatedOrganization)2 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)2 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)2 EndDateEntity (org.orcid.persistence.jpa.entities.EndDateEntity)2 OrgEntity (org.orcid.persistence.jpa.entities.OrgEntity)2 StartDateEntity (org.orcid.persistence.jpa.entities.StartDateEntity)2 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 BigDecimal (java.math.BigDecimal)1 GregorianCalendar (java.util.GregorianCalendar)1 Response (javax.ws.rs.core.Response)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 Test (org.junit.Test)1