Search in sources :

Example 1 with InvalidDisambiguatedOrgException

use of org.orcid.core.exception.InvalidDisambiguatedOrgException 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.v3.dev1.common.Organization organization = holder.getOrganization();
    orgEntity.setName(organization.getName());
    org.orcid.jaxb.model.v3.dev1.common.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) {
        // if disambiguated org is present (must be for v3 API, but not UI) it must be valid
        OrgDisambiguatedEntity disambiguatedOrg = orgDisambiguatedDao.findBySourceIdAndSourceType(organization.getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier(), organization.getDisambiguatedOrganization().getDisambiguationSource());
        if (disambiguatedOrg == null) {
            throw new InvalidDisambiguatedOrgException();
        }
        orgEntity.setOrgDisambiguated(disambiguatedOrg);
    }
    return matchOrCreateOrg(orgEntity);
}
Also used : InvalidDisambiguatedOrgException(org.orcid.core.exception.InvalidDisambiguatedOrgException) OrgDisambiguatedEntity(org.orcid.persistence.jpa.entities.OrgDisambiguatedEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity) AmbiguousOrgEntity(org.orcid.persistence.jpa.entities.AmbiguousOrgEntity)

Aggregations

InvalidDisambiguatedOrgException (org.orcid.core.exception.InvalidDisambiguatedOrgException)1 AmbiguousOrgEntity (org.orcid.persistence.jpa.entities.AmbiguousOrgEntity)1 OrgDisambiguatedEntity (org.orcid.persistence.jpa.entities.OrgDisambiguatedEntity)1 OrgEntity (org.orcid.persistence.jpa.entities.OrgEntity)1