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