Search in sources :

Example 6 with Visibility

use of org.orcid.jaxb.model.common_rc3.Visibility in project ORCID-Source by ORCID.

the class AddressManagerImpl method setIncomingPrivacy.

private void setIncomingPrivacy(AddressEntity entity, ProfileEntity profile) {
    org.orcid.jaxb.model.common_v2.Visibility incomingCountryVisibility = entity.getVisibility();
    org.orcid.jaxb.model.common_v2.Visibility defaultCountryVisibility = (profile.getActivitiesVisibilityDefault() == null) ? org.orcid.jaxb.model.common_v2.Visibility.PRIVATE : org.orcid.jaxb.model.common_v2.Visibility.fromValue(profile.getActivitiesVisibilityDefault().value());
    if (profile.getClaimed() != null && profile.getClaimed()) {
        entity.setVisibility(defaultCountryVisibility);
    } else if (incomingCountryVisibility == null) {
        entity.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
    }
}
Also used : Visibility(org.orcid.jaxb.model.common_v2.Visibility)

Example 7 with Visibility

use of org.orcid.jaxb.model.common_rc3.Visibility in project ORCID-Source by ORCID.

the class ExternalIdentifierManagerImpl method setIncomingPrivacy.

private void setIncomingPrivacy(ExternalIdentifierEntity entity, ProfileEntity profile) {
    org.orcid.jaxb.model.common_v2.Visibility incomingExternalIdentifierVisibility = entity.getVisibility();
    org.orcid.jaxb.model.common_v2.Visibility defaultExternalIdentifierVisibility = (profile.getActivitiesVisibilityDefault() == null) ? org.orcid.jaxb.model.common_v2.Visibility.PRIVATE : org.orcid.jaxb.model.common_v2.Visibility.fromValue(profile.getActivitiesVisibilityDefault().value());
    if (profile.getClaimed() != null && profile.getClaimed()) {
        entity.setVisibility(defaultExternalIdentifierVisibility);
    } else if (incomingExternalIdentifierVisibility == null) {
        entity.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
    }
}
Also used : Visibility(org.orcid.jaxb.model.common_v2.Visibility)

Example 8 with Visibility

use of org.orcid.jaxb.model.common_rc3.Visibility in project ORCID-Source by ORCID.

the class ExternalIdentifierManagerImpl method updateExternalIdentifier.

@Override
public PersonExternalIdentifier updateExternalIdentifier(String orcid, PersonExternalIdentifier externalIdentifier, boolean isApiRequest) {
    SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
    ExternalIdentifierEntity updatedExternalIdentifierEntity = externalIdentifierDao.getExternalIdentifierEntity(orcid, externalIdentifier.getPutCode());
    //Save the original source
    String existingSourceId = updatedExternalIdentifierEntity.getSourceId();
    String existingClientSourceId = updatedExternalIdentifierEntity.getClientSourceId();
    Visibility originalVisibility = Visibility.fromValue(updatedExternalIdentifierEntity.getVisibility().value());
    // Validate external identifier
    PersonValidator.validateExternalIdentifier(externalIdentifier, sourceEntity, false, isApiRequest, originalVisibility, requireRelationshipOnExternalIdentifier);
    // Validate it is not duplicated
    List<ExternalIdentifierEntity> existingExternalIdentifiers = externalIdentifierDao.getExternalIdentifiers(orcid, getLastModified(orcid));
    for (ExternalIdentifierEntity existing : existingExternalIdentifiers) {
        if (isDuplicated(existing, externalIdentifier, sourceEntity)) {
            Map<String, String> params = new HashMap<String, String>();
            params.put("type", "external-identifier");
            params.put("value", externalIdentifier.getUrl().getValue());
            throw new OrcidDuplicatedElementException(params);
        }
    }
    orcidSecurityManager.checkSource(updatedExternalIdentifierEntity);
    jpaJaxbExternalIdentifierAdapter.toExternalIdentifierEntity(externalIdentifier, updatedExternalIdentifierEntity);
    updatedExternalIdentifierEntity.setLastModified(new Date());
    //Set source
    updatedExternalIdentifierEntity.setSourceId(existingSourceId);
    updatedExternalIdentifierEntity.setClientSourceId(existingClientSourceId);
    externalIdentifierDao.merge(updatedExternalIdentifierEntity);
    return jpaJaxbExternalIdentifierAdapter.toExternalIdentifier(updatedExternalIdentifierEntity);
}
Also used : HashMap(java.util.HashMap) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ExternalIdentifierEntity(org.orcid.persistence.jpa.entities.ExternalIdentifierEntity) OrcidDuplicatedElementException(org.orcid.core.exception.OrcidDuplicatedElementException) Visibility(org.orcid.jaxb.model.common_v2.Visibility) Date(java.util.Date)

Example 9 with Visibility

use of org.orcid.jaxb.model.common_rc3.Visibility in project ORCID-Source by ORCID.

the class AffiliationsManagerImpl method updateEmploymentAffiliation.

/**
     * Updates a employment that belongs to the given user
     * 
     * @param orcid
     *            The user
     * @param employment
     *            The employment to update
     * @return the updated employment
     * */
@Override
public Employment updateEmploymentAffiliation(String orcid, Employment employment, boolean isApiRequest) {
    OrgAffiliationRelationEntity employmentEntity = orgAffiliationRelationDao.getOrgAffiliationRelation(orcid, employment.getPutCode());
    Visibility originalVisibility = employmentEntity.getVisibility();
    SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
    //Save the original source
    String existingSourceId = employmentEntity.getSourceId();
    String existingClientSourceId = employmentEntity.getClientSourceId();
    orcidSecurityManager.checkSource(employmentEntity);
    activityValidator.validateEmployment(employment, sourceEntity, false, isApiRequest, originalVisibility);
    jpaJaxbEmploymentAdapter.toOrgAffiliationRelationEntity(employment, employmentEntity);
    employmentEntity.setVisibility(originalVisibility);
    //Be sure it doesn't overwrite the source
    employmentEntity.setSourceId(existingSourceId);
    employmentEntity.setClientSourceId(existingClientSourceId);
    // Updates the give organization with the latest organization from
    // database, or, create a new one
    OrgEntity updatedOrganization = orgManager.getOrgEntity(employment);
    employmentEntity.setOrg(updatedOrganization);
    employmentEntity.setAffiliationType(AffiliationType.EMPLOYMENT);
    employmentEntity = orgAffiliationRelationDao.merge(employmentEntity);
    orgAffiliationRelationDao.flush();
    notificationManager.sendAmendEmail(orcid, AmendedSection.EMPLOYMENT, createItem(employmentEntity));
    return jpaJaxbEmploymentAdapter.toEmployment(employmentEntity);
}
Also used : SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) Visibility(org.orcid.jaxb.model.common_v2.Visibility) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity)

Example 10 with Visibility

use of org.orcid.jaxb.model.common_rc3.Visibility in project ORCID-Source by ORCID.

the class AffiliationsManagerImpl method updateEducationAffiliation.

/**
     * Updates a education that belongs to the given user
     * 
     * @param orcid
     *            The user
     * @param education
     *            The education to update
     * @return the updated education
     * */
@Override
public Education updateEducationAffiliation(String orcid, Education education, boolean isApiRequest) {
    OrgAffiliationRelationEntity educationEntity = orgAffiliationRelationDao.getOrgAffiliationRelation(orcid, education.getPutCode());
    SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
    //Save the original source
    String existingSourceId = educationEntity.getSourceId();
    String existingClientSourceId = educationEntity.getClientSourceId();
    Visibility originalVisibility = educationEntity.getVisibility();
    orcidSecurityManager.checkSource(educationEntity);
    activityValidator.validateEducation(education, sourceEntity, false, isApiRequest, originalVisibility);
    jpaJaxbEducationAdapter.toOrgAffiliationRelationEntity(education, educationEntity);
    educationEntity.setVisibility(originalVisibility);
    //Be sure it doesn't overwrite the source
    educationEntity.setSourceId(existingSourceId);
    educationEntity.setClientSourceId(existingClientSourceId);
    // Updates the give organization with the latest organization from
    // database, or, create a new one
    OrgEntity updatedOrganization = orgManager.getOrgEntity(education);
    educationEntity.setOrg(updatedOrganization);
    educationEntity.setAffiliationType(AffiliationType.EDUCATION);
    educationEntity = orgAffiliationRelationDao.merge(educationEntity);
    orgAffiliationRelationDao.flush();
    notificationManager.sendAmendEmail(orcid, AmendedSection.EDUCATION, createItem(educationEntity));
    return jpaJaxbEducationAdapter.toEducation(educationEntity);
}
Also used : SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) Visibility(org.orcid.jaxb.model.common_v2.Visibility) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity)

Aggregations

Visibility (org.orcid.jaxb.model.common_v2.Visibility)55 Test (org.junit.Test)36 ClientResponse (com.sun.jersey.api.client.ClientResponse)35 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)12 HashMap (java.util.HashMap)10 OrcidError (org.orcid.jaxb.model.error_v2.OrcidError)10 OrcidError (org.orcid.jaxb.model.error_rc1.OrcidError)9 Visibility (org.orcid.jaxb.model.common_rc2.Visibility)8 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)8 Date (java.util.Date)7 Visibility (org.orcid.jaxb.model.common_rc1.Visibility)7 Visibility (org.orcid.jaxb.model.common_rc3.Visibility)6 OrcidDuplicatedElementException (org.orcid.core.exception.OrcidDuplicatedElementException)5 Funding (org.orcid.jaxb.model.record_v2.Funding)5 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)5 Work (org.orcid.jaxb.model.record_v2.Work)5 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)5 Visibility (org.orcid.jaxb.model.common_rc4.Visibility)4 OrcidError (org.orcid.jaxb.model.error_rc3.OrcidError)4 OrgEntity (org.orcid.persistence.jpa.entities.OrgEntity)4