Search in sources :

Example 1 with DisambiguatedOrganization

use of org.orcid.jaxb.model.message.DisambiguatedOrganization 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 DisambiguatedOrganization

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

the class T2OrcidApiServiceVersionedDelegatorTest method preventDuplicatedAffiliations2Test.

@Test
public void preventDuplicatedAffiliations2Test() {
    setUpSecurityContext("4444-4444-4444-4499");
    OrcidMessage orcidMessage = buildMessageWithAffiliation(AffiliationType.EDUCATION, "My dept", "My Role", "4444-4444-4444-4499");
    //Set an existing organization, but, with a bad disambiguated org 
    Organization organization = new Organization();
    organization.setName("An institution");
    OrganizationAddress orgAdd = new OrganizationAddress();
    orgAdd.setCity("London");
    orgAdd.setCountry(Iso3166Country.GB);
    DisambiguatedOrganization dorg = new DisambiguatedOrganization();
    dorg.setDisambiguatedOrganizationIdentifier("XXX");
    dorg.setDisambiguationSource("123456");
    organization.setAddress(orgAdd);
    organization.setDisambiguatedOrganization(dorg);
    orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliation().get(0).setOrganization(organization);
    Response response = t2OrcidApiServiceDelegatorLatest.addAffiliations(mockedUriInfo, "4444-4444-4444-4499", orcidMessage);
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    assertEquals(1, orgAffiliationRelationDao.getByUserAndType("4444-4444-4444-4499", org.orcid.jaxb.model.record_v2.AffiliationType.EDUCATION).size());
    orcidMessage = buildMessageWithAffiliation(AffiliationType.EDUCATION, "My dept", "My Role", "4444-4444-4444-4499");
    //Set an existing organization, but, with a bad disambiguated org 
    organization = new Organization();
    organization.setName("An institution");
    orgAdd = new OrganizationAddress();
    orgAdd.setCity("London");
    orgAdd.setCountry(Iso3166Country.GB);
    dorg = new DisambiguatedOrganization();
    dorg.setDisambiguatedOrganizationIdentifier("YYY");
    dorg.setDisambiguationSource("654321");
    organization.setAddress(orgAdd);
    organization.setDisambiguatedOrganization(dorg);
    orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliation().get(0).setOrganization(organization);
    response = t2OrcidApiServiceDelegatorLatest.addAffiliations(mockedUriInfo, "4444-4444-4444-4499", orcidMessage);
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    assertEquals(1, orgAffiliationRelationDao.getByUserAndType("4444-4444-4444-4499", org.orcid.jaxb.model.record_v2.AffiliationType.EDUCATION).size());
    OrgAffiliationRelationEntity orgEntity = orgAffiliationRelationDao.getByUserAndType("4444-4444-4444-4499", org.orcid.jaxb.model.record_v2.AffiliationType.EDUCATION).get(0);
    assertNotNull(orgEntity);
    assertNotNull(orgEntity.getOrg());
    assertEquals("An institution", orgEntity.getOrg().getName());
    assertEquals("London", orgEntity.getOrg().getCity());
    assertEquals(Iso3166Country.GB, orgEntity.getOrg().getCountry());
    assertEquals(Long.valueOf(1), orgEntity.getOrg().getId());
    assertNotNull(orgEntity.getOrg().getOrgDisambiguated());
    assertEquals("London", orgEntity.getOrg().getOrgDisambiguated().getCity());
    assertEquals(Iso3166Country.GB, orgEntity.getOrg().getOrgDisambiguated().getCountry());
    assertEquals(Long.valueOf(1), orgEntity.getOrg().getOrgDisambiguated().getId());
}
Also used : Response(javax.ws.rs.core.Response) DisambiguatedOrganization(org.orcid.jaxb.model.message.DisambiguatedOrganization) Organization(org.orcid.jaxb.model.message.Organization) DisambiguatedOrganization(org.orcid.jaxb.model.message.DisambiguatedOrganization) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 3 with DisambiguatedOrganization

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

the class JpaJaxbEntityAdapterToOrcidProfileTest method checkAffiliations.

private void checkAffiliations(List<Affiliation> affiliations) {
    assertNotNull(affiliations);
    assertEquals(3, affiliations.size());
    Affiliation affiliation = affiliations.get(2);
    assertEquals(Visibility.LIMITED, affiliation.getVisibility());
    assertEquals("An institution", affiliation.getOrganization().getName());
    assertEquals("A Department", affiliation.getDepartmentName());
    assertEquals("2010-07-02", affiliation.getStartDate().toString());
    assertEquals("2011-07-02", affiliation.getEndDate().toString());
    assertEquals("Primary Researcher", affiliation.getRoleTitle());
    DisambiguatedOrganization disambiguatedAffiliation = affiliation.getOrganization().getDisambiguatedOrganization();
    assertNotNull(disambiguatedAffiliation);
    assertEquals("abc456", disambiguatedAffiliation.getDisambiguatedOrganizationIdentifier());
    assertEquals("WDB", disambiguatedAffiliation.getDisambiguationSource());
    checkAddress(affiliation.getOrganization().getAddress());
}
Also used : DisambiguatedOrganization(org.orcid.jaxb.model.message.DisambiguatedOrganization) Affiliation(org.orcid.jaxb.model.message.Affiliation)

Aggregations

DisambiguatedOrganization (org.orcid.jaxb.model.message.DisambiguatedOrganization)3 Affiliation (org.orcid.jaxb.model.message.Affiliation)2 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)2 Organization (org.orcid.jaxb.model.message.Organization)2 OrganizationAddress (org.orcid.jaxb.model.message.OrganizationAddress)2 Response (javax.ws.rs.core.Response)1 Test (org.junit.Test)1 Affiliations (org.orcid.jaxb.model.message.Affiliations)1 FuzzyDate (org.orcid.jaxb.model.message.FuzzyDate)1 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)1 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)1 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)1 OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)1 DBUnitTest (org.orcid.test.DBUnitTest)1