Search in sources :

Example 26 with OrgEntity

use of org.orcid.persistence.jpa.entities.OrgEntity 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(org.orcid.jaxb.model.common_v2.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 27 with OrgEntity

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

the class LoadRinggoldData method createOrUpdateOrg.

private void createOrUpdateOrg(String name, String city, Iso3166Country country, String state, Long orgDisambiguatedId) {
    // Ensure there is a corresponding org and that the org is linked to the
    // disambiguated org
    OrgEntity orgEntity = new OrgEntity();
    orgEntity.setName(name);
    orgEntity.setRegion(state);
    orgEntity.setCity(city);
    orgEntity.setCountry(country);
    orgManager.createUpdate(orgEntity, orgDisambiguatedId);
}
Also used : OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity)

Example 28 with OrgEntity

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

the class OrgManagerImpl method createUpdate.

@Override
public OrgEntity createUpdate(OrgEntity org, Long orgDisambiguatedId) {
    OrgEntity existingOrg = orgDao.findByNameCityRegionAndCountry(org.getName(), org.getCity(), org.getRegion(), org.getCountry());
    if (existingOrg != null) {
        org = existingOrg;
    }
    if (org.getOrgDisambiguated() == null) {
        OrgDisambiguatedEntity disambiguatedOrg = orgDisambiguatedDao.find(orgDisambiguatedId);
        if (disambiguatedOrg == null) {
            throw new IllegalArgumentException("No such disambiguated org with id=" + orgDisambiguatedId);
        }
        org.setOrgDisambiguated(disambiguatedOrg);
    }
    if (org.getSource() == null) {
        org.setSource(new SourceEntity(sourceManager.retrieveSourceOrcid()));
    }
    return orgDao.merge(org);
}
Also used : SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) OrgDisambiguatedEntity(org.orcid.persistence.jpa.entities.OrgDisambiguatedEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity) AmbiguousOrgEntity(org.orcid.persistence.jpa.entities.AmbiguousOrgEntity)

Example 29 with OrgEntity

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

the class OrgManagerTest method testCreateUpdateWhenAlreadyExists.

@Test
@Transactional
public void testCreateUpdateWhenAlreadyExists() {
    OrgEntity inputOrg = new OrgEntity();
    inputOrg.setName("An institution");
    inputOrg.setCity("London");
    inputOrg.setCountry(Iso3166Country.GB);
    OrgEntity resultOrg = orgManager.createUpdate(inputOrg);
    assertNotNull(resultOrg);
    assertEquals(inputOrg.getName(), resultOrg.getName());
    assertEquals(inputOrg.getCity(), resultOrg.getCity());
    assertEquals(inputOrg.getRegion(), resultOrg.getRegion());
    assertEquals(inputOrg.getCountry(), resultOrg.getCountry());
    assertEquals(1, resultOrg.getId().longValue());
}
Also used : OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity) AmbiguousOrgEntity(org.orcid.persistence.jpa.entities.AmbiguousOrgEntity) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 30 with OrgEntity

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

the class OrgManagerTest method testCreateUpdateWhenDoesNotAlreadyExists.

@Test
@Transactional
public void testCreateUpdateWhenDoesNotAlreadyExists() {
    OrgEntity inputOrg = new OrgEntity();
    inputOrg.setName("Le Institution");
    inputOrg.setCity("Paris");
    inputOrg.setCountry(Iso3166Country.FR);
    OrgEntity resultOrg = orgManager.createUpdate(inputOrg);
    assertNotNull(resultOrg);
    assertEquals(inputOrg.getName(), resultOrg.getName());
    assertEquals(inputOrg.getCity(), resultOrg.getCity());
    assertEquals(inputOrg.getRegion(), resultOrg.getRegion());
    assertEquals(inputOrg.getCountry(), resultOrg.getCountry());
    assertFalse(resultOrg.getId().equals(1));
}
Also used : OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity) AmbiguousOrgEntity(org.orcid.persistence.jpa.entities.AmbiguousOrgEntity) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

OrgEntity (org.orcid.persistence.jpa.entities.OrgEntity)53 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)30 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)26 OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)17 EndDateEntity (org.orcid.persistence.jpa.entities.EndDateEntity)11 StartDateEntity (org.orcid.persistence.jpa.entities.StartDateEntity)11 Test (org.junit.Test)10 OrgDisambiguatedEntity (org.orcid.persistence.jpa.entities.OrgDisambiguatedEntity)8 PeerReviewEntity (org.orcid.persistence.jpa.entities.PeerReviewEntity)8 AmbiguousOrgEntity (org.orcid.persistence.jpa.entities.AmbiguousOrgEntity)7 File (java.io.File)6 Path (java.nio.file.Path)6 ProfileFundingEntity (org.orcid.persistence.jpa.entities.ProfileFundingEntity)6 Transactional (org.springframework.transaction.annotation.Transactional)5 Date (java.util.Date)4 Visibility (org.orcid.jaxb.model.common_v2.Visibility)4 Organization (org.orcid.jaxb.model.message.Organization)4 CompletionDateEntity (org.orcid.persistence.jpa.entities.CompletionDateEntity)4 HashSet (java.util.HashSet)3 Iso3166Country (org.orcid.jaxb.model.message.Iso3166Country)3