Search in sources :

Example 1 with OrgEntity

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;
}
Also used : Organization(org.orcid.jaxb.model.message.Organization) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity)

Example 2 with OrgEntity

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);
}
Also used : OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity) AmbiguousOrgEntity(org.orcid.persistence.jpa.entities.AmbiguousOrgEntity)

Example 3 with 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;
}
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 4 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(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 5 with OrgEntity

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++;
        }
    }
}
Also used : OrgDisambiguatedEntity(org.orcid.persistence.jpa.entities.OrgDisambiguatedEntity) Iso3166Country(org.orcid.jaxb.model.message.Iso3166Country) Date(java.util.Date) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity)

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