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