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());
}
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());
}
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;
}
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());
}
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;
}
Aggregations