use of org.orcid.persistence.jpa.entities.RecordNameEntity in project ORCID-Source by ORCID.
the class OrcidClientGroupManagerImpl method updateGroup.
/**
* Updates an existing group profile. If the group doesnt exists it will
* throw a OrcidClientGroupManagementException
*
* @param orcidClientGroup
* The group to be updated
*/
@Transactional
public void updateGroup(OrcidClientGroup orcidClientGroup) {
String groupOrcid = orcidClientGroup.getGroupOrcid();
// If the incoming client group ORCID is not null, then lookup the
// existing client group.
ProfileEntity groupProfileEntity = profileDao.find(groupOrcid);
if (groupProfileEntity == null) {
// then raise an error.
throw new OrcidClientGroupManagementException("Group ORCID was specified but does not yet exist: " + groupOrcid);
} else {
boolean updateClientScopes = false;
// profile DAO
if (!orcidClientGroup.getEmail().equals(groupProfileEntity.getPrimaryEmail().getId())) {
EmailEntity primaryEmailEntity = new EmailEntity();
primaryEmailEntity.setId(orcidClientGroup.getEmail().toLowerCase().trim());
primaryEmailEntity.setCurrent(true);
primaryEmailEntity.setVerified(true);
primaryEmailEntity.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
groupProfileEntity.setPrimaryEmail(primaryEmailEntity);
}
if (groupProfileEntity.getRecordNameEntity() == null) {
groupProfileEntity.setRecordNameEntity(new RecordNameEntity());
groupProfileEntity.getRecordNameEntity().setProfile(groupProfileEntity);
}
// Set the record name entity table
groupProfileEntity.getRecordNameEntity().setCreditName(orcidClientGroup.getGroupName());
groupProfileEntity.getRecordNameEntity().setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
groupProfileEntity.setSalesforeId(orcidClientGroup.getSalesforceId());
// If group type changed
if (!groupProfileEntity.getGroupType().equals(orcidClientGroup.getType())) {
// Update the group type
groupProfileEntity.setGroupType(orcidClientGroup.getType());
// Set the flag to update the client scopes
updateClientScopes = true;
}
// Merge changes
profileDao.merge(groupProfileEntity);
profileEntityManager.updateLastModifed(groupOrcid);
// Update client types and scopes
if (updateClientScopes)
updateClientTypeDueGroupTypeUpdate(groupProfileEntity);
}
}
use of org.orcid.persistence.jpa.entities.RecordNameEntity in project ORCID-Source by ORCID.
the class Jaxb2JpaAdapterImpl method setFamilyName.
private void setFamilyName(ProfileEntity profileEntity, FamilyName familyName) {
if (familyName != null && StringUtils.isNotBlank(familyName.getContent())) {
if (profileEntity.getRecordNameEntity() == null) {
profileEntity.setRecordNameEntity(new RecordNameEntity());
profileEntity.getRecordNameEntity().setProfile(profileEntity);
}
profileEntity.getRecordNameEntity().setFamilyName(familyName.getContent());
}
}
use of org.orcid.persistence.jpa.entities.RecordNameEntity in project ORCID-Source by ORCID.
the class ProfileEntityManagerImpl method reactivate.
@Override
public void reactivate(String orcid, String givenNames, String familyName, String password, Visibility defaultVisibility) {
LOGGER.info("About to reactivate record, orcid={}", orcid);
ProfileEntity profileEntity = profileEntityCacheManager.retrieve(orcid);
profileEntity.setDeactivationDate(null);
profileEntity.setClaimed(true);
profileEntity.setEncryptedPassword(encryptionManager.hashForInternalUse(password));
profileEntity.setActivitiesVisibilityDefault(defaultVisibility);
RecordNameEntity recordNameEntity = profileEntity.getRecordNameEntity();
recordNameEntity.setGivenNames(givenNames);
recordNameEntity.setFamilyName(familyName);
profileDao.merge(profileEntity);
}
use of org.orcid.persistence.jpa.entities.RecordNameEntity in project ORCID-Source by ORCID.
the class ProfileEntityManagerImpl method retrivePublicDisplayName.
@Override
public String retrivePublicDisplayName(String orcid) {
String publicName = "";
ProfileEntity profile = profileEntityCacheManager.retrieve(orcid);
if (profile != null) {
RecordNameEntity recordName = profile.getRecordNameEntity();
if (recordName != null) {
Visibility namesVisibility = (recordName.getVisibility() != null) ? Visibility.fromValue(recordName.getVisibility().value()) : Visibility.fromValue(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility().value());
if (Visibility.PUBLIC.equals(namesVisibility)) {
if (!PojoUtil.isEmpty(recordName.getCreditName())) {
publicName = recordName.getCreditName();
} else {
publicName = PojoUtil.isEmpty(recordName.getGivenNames()) ? "" : recordName.getGivenNames();
publicName += PojoUtil.isEmpty(recordName.getFamilyName()) ? "" : " " + recordName.getFamilyName();
}
}
}
}
return publicName;
}
use of org.orcid.persistence.jpa.entities.RecordNameEntity in project ORCID-Source by ORCID.
the class ProfileEntityManagerImpl method deactivateRecord.
@Override
@Transactional
public boolean deactivateRecord(String orcid) {
//Clear the record
ProfileEntity toClear = profileDao.find(orcid);
toClear.setLastModified(new Date());
toClear.setDeactivationDate(new Date());
toClear.setActivitiesVisibilityDefault(Visibility.PRIVATE);
toClear.setIndexingStatus(IndexingStatus.REINDEX);
// Remove works
workManager.removeAllWorks(orcid);
// Remove funding
if (toClear.getProfileFunding() != null) {
toClear.getProfileFunding().clear();
}
// Remove affiliations
if (toClear.getOrgAffiliationRelations() != null) {
toClear.getOrgAffiliationRelations().clear();
}
// Remove external identifiers
if (toClear.getExternalIdentifiers() != null) {
toClear.getExternalIdentifiers().clear();
}
// Remove researcher urls
if (toClear.getResearcherUrls() != null) {
toClear.getResearcherUrls().clear();
}
// Remove other names
if (toClear.getOtherNames() != null) {
toClear.getOtherNames().clear();
}
// Remove keywords
if (toClear.getKeywords() != null) {
toClear.getKeywords().clear();
}
// Remove address
if (toClear.getAddresses() != null) {
toClear.getAddresses().clear();
}
BiographyEntity bioEntity = toClear.getBiographyEntity();
if (bioEntity != null) {
bioEntity.setBiography("");
bioEntity.setVisibility(Visibility.PRIVATE);
}
//Set the deactivated names
RecordNameEntity recordName = toClear.getRecordNameEntity();
if (recordName != null) {
recordName.setCreditName(null);
recordName.setGivenNames("Given Names Deactivated");
recordName.setFamilyName("Family Name Deactivated");
recordName.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
}
Set<EmailEntity> emails = toClear.getEmails();
if (emails != null) {
// For each email in the deprecated profile
for (EmailEntity email : emails) {
email.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
}
}
profileDao.merge(toClear);
profileDao.flush();
//Delete all connections
userConnectionDao.deleteByOrcid(orcid);
notificationManager.sendAmendEmail(orcid, AmendedSection.UNKNOWN, null);
return true;
}
Aggregations