Search in sources :

Example 11 with OrgAffiliationRelationEntity

use of org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity in project ORCID-Source by ORCID.

the class JpaJaxbEmploymentAdapterTest method fromOrgAffiliationRelationEntityToEmployment.

@Test
public void fromOrgAffiliationRelationEntityToEmployment() {
    OrgAffiliationRelationEntity entity = getEmploymentEntity();
    assertNotNull(entity);
    Employment employment = jpaJaxbEmploymentAdapter.toEmployment(entity);
    assertNotNull(employment);
    assertEquals("employment:department", employment.getDepartmentName());
    assertEquals(Long.valueOf(123456), employment.getPutCode());
    assertEquals("employment:title", employment.getRoleTitle());
    assertEquals("private", employment.getVisibility().value());
    assertNotNull(employment.getStartDate());
    assertEquals("2000", employment.getStartDate().getYear().getValue());
    assertEquals("01", employment.getStartDate().getMonth().getValue());
    assertEquals("01", employment.getStartDate().getDay().getValue());
    assertEquals("2020", employment.getEndDate().getYear().getValue());
    assertEquals("02", employment.getEndDate().getMonth().getValue());
    assertEquals("02", employment.getEndDate().getDay().getValue());
    assertNotNull(employment.getOrganization());
    assertEquals("org:name", employment.getOrganization().getName());
    assertNotNull(employment.getOrganization().getAddress());
    assertEquals("org:city", employment.getOrganization().getAddress().getCity());
    assertEquals("org:region", employment.getOrganization().getAddress().getRegion());
    assertEquals(org.orcid.jaxb.model.common_v2.Iso3166Country.US, employment.getOrganization().getAddress().getCountry());
    assertNotNull(employment.getSource());
    assertNotNull(employment.getSource().retrieveSourcePath());
    assertEquals("APP-000000001", employment.getSource().retrieveSourcePath());
}
Also used : Employment(org.orcid.jaxb.model.record_v2.Employment) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) Test(org.junit.Test)

Example 12 with OrgAffiliationRelationEntity

use of org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity in project ORCID-Source by ORCID.

the class JpaJaxbEmploymentAdapterTest method fromOrgAffiliationRelationEntityToEmploymentSummary.

@Test
public void fromOrgAffiliationRelationEntityToEmploymentSummary() {
    OrgAffiliationRelationEntity entity = getEmploymentEntity();
    assertNotNull(entity);
    EmploymentSummary employmentSummary = jpaJaxbEmploymentAdapter.toEmploymentSummary(entity);
    assertNotNull(employmentSummary);
    assertEquals("employment:department", employmentSummary.getDepartmentName());
    assertEquals(Long.valueOf(123456), employmentSummary.getPutCode());
    assertEquals("employment:title", employmentSummary.getRoleTitle());
    assertEquals("private", employmentSummary.getVisibility().value());
    assertNotNull(employmentSummary.getStartDate());
    assertEquals("2000", employmentSummary.getStartDate().getYear().getValue());
    assertEquals("01", employmentSummary.getStartDate().getMonth().getValue());
    assertEquals("01", employmentSummary.getStartDate().getDay().getValue());
    assertEquals("2020", employmentSummary.getEndDate().getYear().getValue());
    assertEquals("02", employmentSummary.getEndDate().getMonth().getValue());
    assertEquals("02", employmentSummary.getEndDate().getDay().getValue());
    assertNotNull(employmentSummary.getSource());
    assertNotNull(employmentSummary.getSource().retrieveSourcePath());
    assertEquals("APP-000000001", employmentSummary.getSource().retrieveSourcePath());
}
Also used : EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) Test(org.junit.Test)

Example 13 with OrgAffiliationRelationEntity

use of org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity in project ORCID-Source by ORCID.

the class JpaJaxbEmploymentAdapterTest method getEmploymentEntity.

private OrgAffiliationRelationEntity getEmploymentEntity() {
    OrgEntity orgEntity = new OrgEntity();
    orgEntity.setCity("org:city");
    orgEntity.setCountry(org.orcid.jaxb.model.message.Iso3166Country.US);
    orgEntity.setName("org:name");
    orgEntity.setRegion("org:region");
    orgEntity.setUrl("org:url");
    orgEntity.setSource(new SourceEntity("APP-000000001"));
    OrgAffiliationRelationEntity result = new OrgAffiliationRelationEntity();
    result.setAffiliationType(AffiliationType.EMPLOYMENT);
    result.setDepartment("employment:department");
    result.setEndDate(new EndDateEntity(2020, 2, 2));
    result.setId(123456L);
    result.setOrg(orgEntity);
    result.setProfile(new ProfileEntity("0000-0001-0002-0003"));
    result.setStartDate(new StartDateEntity(2000, 1, 1));
    result.setTitle("employment:title");
    result.setVisibility(Visibility.PRIVATE);
    result.setClientSourceId("APP-000000001");
    return result;
}
Also used : EndDateEntity(org.orcid.persistence.jpa.entities.EndDateEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) StartDateEntity(org.orcid.persistence.jpa.entities.StartDateEntity) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity)

Example 14 with OrgAffiliationRelationEntity

use of org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity 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 15 with OrgAffiliationRelationEntity

use of org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity in project ORCID-Source by ORCID.

the class Jaxb2JpaAdapterImpl method getNewOrgAffiliationRelationEntity.

@Override
public OrgAffiliationRelationEntity getNewOrgAffiliationRelationEntity(Affiliation affiliation, ProfileEntity profileEntity) {
    OrgAffiliationRelationEntity orgAffiliationRelationEntity = getOrgAffiliationRelationEntity(affiliation, null);
    orgAffiliationRelationEntity.setProfile(profileEntity);
    return orgAffiliationRelationEntity;
}
Also used : OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)

Aggregations

OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)28 Test (org.junit.Test)8 OrgEntity (org.orcid.persistence.jpa.entities.OrgEntity)8 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)7 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)6 Education (org.orcid.jaxb.model.record_v2.Education)3 Employment (org.orcid.jaxb.model.record_v2.Employment)3 EndDateEntity (org.orcid.persistence.jpa.entities.EndDateEntity)3 ExternalIdentifierEntity (org.orcid.persistence.jpa.entities.ExternalIdentifierEntity)3 OtherNameEntity (org.orcid.persistence.jpa.entities.OtherNameEntity)3 ProfileFundingEntity (org.orcid.persistence.jpa.entities.ProfileFundingEntity)3 ProfileKeywordEntity (org.orcid.persistence.jpa.entities.ProfileKeywordEntity)3 ResearcherUrlEntity (org.orcid.persistence.jpa.entities.ResearcherUrlEntity)3 StartDateEntity (org.orcid.persistence.jpa.entities.StartDateEntity)3 TreeSet (java.util.TreeSet)2 MapperFactory (ma.glasnost.orika.MapperFactory)2 DefaultMapperFactory (ma.glasnost.orika.impl.DefaultMapperFactory)2 Visibility (org.orcid.jaxb.model.common_v2.Visibility)2 Affiliation (org.orcid.jaxb.model.message.Affiliation)2 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)2