Search in sources :

Example 46 with Employment

use of org.orcid.jaxb.model.record_rc1.Employment in project ORCID-Source by ORCID.

the class JpaJaxbEmploymentAdapterTest method testToOrgAffiliationRelationEntity.

@Test
public void testToOrgAffiliationRelationEntity() throws JAXBException {
    Employment e = getEmployment(true);
    assertNotNull(e);
    OrgAffiliationRelationEntity oar = jpaJaxbEmploymentAdapter.toOrgAffiliationRelationEntity(e);
    assertNotNull(oar);
    // General info
    assertEquals(Long.valueOf(0), oar.getId());
    assertEquals(Visibility.PRIVATE.value(), oar.getVisibility().value());
    assertEquals("employment:department-name", oar.getDepartment());
    assertEquals("employment:role-title", oar.getTitle());
    // Dates
    assertEquals(Integer.valueOf(2), oar.getStartDate().getDay());
    assertEquals(Integer.valueOf(2), oar.getStartDate().getMonth());
    assertEquals(Integer.valueOf(1848), oar.getStartDate().getYear());
    assertEquals(Integer.valueOf(2), oar.getEndDate().getDay());
    assertEquals(Integer.valueOf(2), oar.getEndDate().getMonth());
    assertEquals(Integer.valueOf(1848), oar.getEndDate().getYear());
    // Source
    assertNull(oar.getSourceId());
    assertNull(oar.getClientSourceId());
    assertNull(oar.getElementSourceId());
}
Also used : Employment(org.orcid.jaxb.model.record_v2.Employment) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) Test(org.junit.Test)

Example 47 with Employment

use of org.orcid.jaxb.model.record_rc1.Employment in project ORCID-Source by ORCID.

the class JpaJaxbEmploymentAdapterTest method testToOrgAffiliationRelationEntityWithNullMonthAndDay.

@Test
public void testToOrgAffiliationRelationEntityWithNullMonthAndDay() throws JAXBException {
    Employment e = getEmploymentWithDates();
    OrgAffiliationRelationEntity oar = jpaJaxbEmploymentAdapter.toOrgAffiliationRelationEntity(e);
    assertNotNull(oar.getStartDate().getYear());
    assertNotNull(oar.getStartDate().getMonth());
    assertNotNull(oar.getStartDate().getDay());
    e = getEmploymentWithDatesWithNullMonthAndDay();
    oar = jpaJaxbEmploymentAdapter.toOrgAffiliationRelationEntity(e, oar);
    assertNotNull(oar.getStartDate().getYear());
    assertNull(oar.getStartDate().getMonth());
    assertNull(oar.getStartDate().getDay());
}
Also used : Employment(org.orcid.jaxb.model.record_v2.Employment) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) Test(org.junit.Test)

Example 48 with Employment

use of org.orcid.jaxb.model.record_rc1.Employment in project ORCID-Source by ORCID.

the class JpaJaxbEmploymentAdapterTest method getEmploymentWithDates.

private Employment getEmploymentWithDates() {
    Employment employment = new Employment();
    employment.setRoleTitle("role title");
    FuzzyDate startDate = new FuzzyDate(new Year(2017), new Month(1), new Day(1));
    FuzzyDate endDate = new FuzzyDate(new Year(2017), new Month(3), new Day(1));
    employment.setStartDate(startDate);
    employment.setEndDate(endDate);
    return employment;
}
Also used : Month(org.orcid.jaxb.model.common_v2.Month) Year(org.orcid.jaxb.model.common_v2.Year) Employment(org.orcid.jaxb.model.record_v2.Employment) FuzzyDate(org.orcid.jaxb.model.common_v2.FuzzyDate) Day(org.orcid.jaxb.model.common_v2.Day)

Example 49 with Employment

use of org.orcid.jaxb.model.record_rc1.Employment in project ORCID-Source by ORCID.

the class ActivityValidatorTest method validateEmployment_validEmploymentTest.

/**
 * VALIDATE AFFILIATIONS
 */
@Test
public void validateEmployment_validEmploymentTest() {
    Employment employment = getEmployment();
    activityValidator.validateEmployment(employment, null, true, true, Visibility.PUBLIC);
}
Also used : Employment(org.orcid.jaxb.model.record_v2.Employment) Test(org.junit.Test)

Example 50 with Employment

use of org.orcid.jaxb.model.record_rc1.Employment in project ORCID-Source by ORCID.

the class MapperFacadeFactory method getEmploymentMapperFacade.

public MapperFacade getEmploymentMapperFacade() {
    MapperFactory mapperFactory = getNewMapperFactory();
    ClassMapBuilder<Employment, OrgAffiliationRelationEntity> classMap = mapperFactory.classMap(Employment.class, OrgAffiliationRelationEntity.class);
    addV2CommonFields(classMap);
    registerSourceConverters(mapperFactory, classMap);
    classMap.fieldBToA("org.name", "organization.name");
    classMap.fieldBToA("org.city", "organization.address.city");
    classMap.fieldBToA("org.region", "organization.address.region");
    classMap.fieldBToA("org.country", "organization.address.country");
    classMap.fieldBToA("org.orgDisambiguated.sourceId", "organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier");
    classMap.fieldBToA("org.orgDisambiguated.sourceType", "organization.disambiguatedOrganization.disambiguationSource");
    classMap.fieldBToA("org.orgDisambiguated.id", "organization.disambiguatedOrganization.id");
    classMap.field("departmentName", "department");
    classMap.field("roleTitle", "title");
    classMap.register();
    ClassMapBuilder<EmploymentSummary, OrgAffiliationRelationEntity> employmentSummaryClassMap = mapperFactory.classMap(EmploymentSummary.class, OrgAffiliationRelationEntity.class);
    addV2CommonFields(employmentSummaryClassMap);
    registerSourceConverters(mapperFactory, employmentSummaryClassMap);
    employmentSummaryClassMap.fieldBToA("org.name", "organization.name");
    employmentSummaryClassMap.fieldBToA("org.city", "organization.address.city");
    employmentSummaryClassMap.fieldBToA("org.region", "organization.address.region");
    employmentSummaryClassMap.fieldBToA("org.country", "organization.address.country");
    employmentSummaryClassMap.fieldBToA("org.orgDisambiguated.sourceId", "organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier");
    employmentSummaryClassMap.fieldBToA("org.orgDisambiguated.sourceType", "organization.disambiguatedOrganization.disambiguationSource");
    employmentSummaryClassMap.fieldBToA("org.orgDisambiguated.id", "organization.disambiguatedOrganization.id");
    employmentSummaryClassMap.field("departmentName", "department");
    employmentSummaryClassMap.field("roleTitle", "title");
    employmentSummaryClassMap.register();
    mapFuzzyDateToStartDateEntityAndEndDateEntity(mapperFactory);
    return mapperFactory.getMapperFacade();
}
Also used : Employment(org.orcid.jaxb.model.record_v2.Employment) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)

Aggregations

Test (org.junit.Test)41 Employment (org.orcid.jaxb.model.record_v2.Employment)39 ClientResponse (com.sun.jersey.api.client.ClientResponse)22 Response (javax.ws.rs.core.Response)13 DBUnitTest (org.orcid.test.DBUnitTest)13 Employment (org.orcid.jaxb.model.record_rc1.Employment)8 ArrayList (java.util.ArrayList)6 Year (org.orcid.jaxb.model.common_v2.Year)5 Day (org.orcid.jaxb.model.common_v2.Day)4 Month (org.orcid.jaxb.model.common_v2.Month)4 OrcidError (org.orcid.jaxb.model.error_rc1.OrcidError)4 Education (org.orcid.jaxb.model.record_v2.Education)4 Funding (org.orcid.jaxb.model.record_v2.Funding)4 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)4 Work (org.orcid.jaxb.model.record_v2.Work)4 Address (org.orcid.jaxb.model.record_v2.Address)3 Keyword (org.orcid.jaxb.model.record_v2.Keyword)3 OtherName (org.orcid.jaxb.model.record_v2.OtherName)3 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)3 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)3