use of org.orcid.persistence.jpa.entities.OrgEntity in project ORCID-Source by ORCID.
the class Jaxb2JpaAdapterImpl method getOrgEntity.
private OrgEntity getOrgEntity(Affiliation affiliation) {
if (affiliation != null) {
OrgEntity orgEntity = new OrgEntity();
Organization organization = affiliation.getOrganization();
orgEntity.setName(organization.getName());
OrganizationAddress address = organization.getAddress();
orgEntity.setCity(address.getCity());
orgEntity.setRegion(address.getRegion());
orgEntity.setCountry(address.getCountry());
if (organization.getDisambiguatedOrganization() != null && organization.getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier() != null) {
orgEntity.setOrgDisambiguated(orgDisambiguatedDao.findBySourceIdAndSourceType(organization.getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier(), organization.getDisambiguatedOrganization().getDisambiguationSource()));
}
return orgManager.createUpdate(orgEntity);
}
return null;
}
use of org.orcid.persistence.jpa.entities.OrgEntity in project ORCID-Source by ORCID.
the class OrgManagerImpl method getOrgEntity.
@Override
public OrgEntity getOrgEntity(OrganizationHolder holder) {
if (holder == null)
return null;
OrgEntity orgEntity = new OrgEntity();
org.orcid.jaxb.model.common_v2.Organization organization = holder.getOrganization();
orgEntity.setName(organization.getName());
org.orcid.jaxb.model.common_v2.OrganizationAddress address = organization.getAddress();
orgEntity.setCity(address.getCity());
orgEntity.setRegion(address.getRegion());
orgEntity.setCountry(Iso3166Country.fromValue(address.getCountry().value()));
if (organization.getDisambiguatedOrganization() != null && organization.getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier() != null) {
orgEntity.setOrgDisambiguated(orgDisambiguatedDao.findBySourceIdAndSourceType(organization.getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier(), organization.getDisambiguatedOrganization().getDisambiguationSource()));
}
return createUpdate(orgEntity);
}
use of org.orcid.persistence.jpa.entities.OrgEntity in project ORCID-Source by ORCID.
the class JpaJaxbEducationAdapterTest method getEducationEntity.
private OrgAffiliationRelationEntity getEducationEntity() {
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.EDUCATION);
result.setDepartment("education: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("education:title");
result.setVisibility(Visibility.PRIVATE);
result.setClientSourceId("APP-000000001");
return result;
}
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(Visibility.PRIVATE);
result.setClientSourceId("APP-000000001");
return result;
}
use of org.orcid.persistence.jpa.entities.OrgEntity in project ORCID-Source by ORCID.
the class LoadLEIData method processOrg.
/**
* Add/Update Orgs in the DB
*
* @param org
*/
public void processOrg(LEIOrganization org) {
Date now = new Date();
OrgDisambiguatedEntity existingDO = orgDisambiguatedDao.findBySourceIdAndSourceType(org.id, LEI_SOURCE_TYPE);
if (existingDO != null) {
// update
if (org.differentFrom(existingDO)) {
existingDO.setCity(org.hqAddres.city);
existingDO.setCountry(org.hqAddres.country);
existingDO.setName(org.name);
existingDO.setOrgType(org.type);
existingDO.setRegion(org.hqAddres.region);
existingDO.setUrl("https://www.gleif.org/lei/" + org.id);
existingDO.setLastModified(now);
existingDO.setIndexingStatus(IndexingStatus.PENDING);
// Is it replaced?
if (!PojoUtil.isEmpty(org.successorLEI)) {
existingDO.setSourceParentId(org.successorLEI);
existingDO.setStatus(OrganizationStatus.DEPRECATED.name());
} else // or is is simply gone
if ("INACTIVE".equals(org.status)) {
existingDO.setStatus(OrganizationStatus.OBSOLETE.name());
}
LOGGER.info("Merging LEI:" + org.id);
existingDO = orgDisambiguatedDao.merge(existingDO);
updatedDisambiguatedOrgs++;
}
} else {
// create
Iso3166Country country = org.hqAddres.country;
OrgDisambiguatedEntity orgDisambiguatedEntity = new OrgDisambiguatedEntity();
orgDisambiguatedEntity.setName(org.name);
orgDisambiguatedEntity.setCountry(country);
orgDisambiguatedEntity.setCity(org.hqAddres.city);
orgDisambiguatedEntity.setRegion(org.hqAddres.region);
orgDisambiguatedEntity.setOrgType(org.type);
orgDisambiguatedEntity.setSourceId(org.id);
orgDisambiguatedEntity.setSourceUrl("https://www.gleif.org/lei/" + org.id);
// Is it replaced?
if (!PojoUtil.isEmpty(org.successorLEI)) {
orgDisambiguatedEntity.setSourceParentId(org.successorLEI);
orgDisambiguatedEntity.setStatus(OrganizationStatus.DEPRECATED.name());
} else // or is is simply gone
if ("INACTIVE".equals(org.status)) {
orgDisambiguatedEntity.setStatus(OrganizationStatus.OBSOLETE.name());
}
orgDisambiguatedEntity.setSourceType(LEI_SOURCE_TYPE);
LOGGER.info("Creating LEI:" + org.id);
orgDisambiguatedDao.persist(orgDisambiguatedEntity);
existingDO = orgDisambiguatedEntity;
addedDisambiguatedOrgs++;
}
// Other names
for (LEIOrganization otherOrg : org.toOtherOrgs()) {
OrgEntity existingOrg = orgDao.findByAddressAndDisambiguatedOrg(otherOrg.name, otherOrg.hqAddres.city, otherOrg.hqAddres.region, otherOrg.hqAddres.country, existingDO);
if (existingOrg != null) {
// do nothing (nothing to update!)
} else {
OrgEntity newOrg = new OrgEntity();
newOrg.setDateCreated(now);
newOrg.setLastModified(now);
newOrg.setCity(otherOrg.hqAddres.city);
newOrg.setCountry(otherOrg.hqAddres.country);
newOrg.setRegion(otherOrg.hqAddres.region);
newOrg.setName(otherOrg.name);
newOrg.setOrgDisambiguated(existingDO);
LOGGER.info("Creating org LEI:" + org.id);
orgDao.persist(newOrg);
addedOrgs++;
}
}
}
Aggregations