use of org.orcid.jaxb.model.record_rc3.CreditName in project ORCID-Source by ORCID.
the class ContributorUtils method filterContributorPrivateData.
public void filterContributorPrivateData(Work work) {
if (work.getWorkContributors() != null && work.getWorkContributors().getContributor() != null) {
for (Contributor contributor : work.getWorkContributors().getContributor()) {
contributor.setContributorEmail(null);
if (!PojoUtil.isEmpty(contributor.getContributorOrcid())) {
String contributorOrcid = contributor.getContributorOrcid().getPath();
if (profileEntityManager.orcidExists(contributorOrcid)) {
// contributor is an ORCID user - visibility of user's
// name in record must be taken into account
ProfileEntity profileEntity = profileEntityCacheManager.retrieve(contributorOrcid);
String publicContributorCreditName = cacheManager.getPublicCreditName(profileEntity);
CreditName creditName = new CreditName(publicContributorCreditName != null ? publicContributorCreditName : "");
contributor.setCreditName(creditName);
}
}
}
}
}
use of org.orcid.jaxb.model.record_rc3.CreditName in project ORCID-Source by ORCID.
the class JpaJaxbNameAdapterTest method fromNameToRecordNameEntityTest.
@Test
public void fromNameToRecordNameEntityTest() throws JAXBException {
Name name = new Name();
name.setCreditName(new CreditName("Credit Name"));
name.setFamilyName(new FamilyName("Family Name"));
name.setGivenNames(new GivenNames("Given Names"));
name.setPath("0000-0000-0000-0000");
name.setVisibility(Visibility.PUBLIC);
name.setSource(new Source("0000-0000-0000-0000"));
RecordNameEntity entity = adapter.toRecordNameEntity(name);
assertNotNull(entity);
assertEquals("Credit Name", entity.getCreditName());
assertEquals("Family Name", entity.getFamilyName());
assertEquals("Given Names", entity.getGivenNames());
assertEquals(Visibility.PUBLIC, entity.getVisibility());
assertNotNull(entity.getProfile());
assertEquals("0000-0000-0000-0000", entity.getProfile().getId());
}
use of org.orcid.jaxb.model.record_rc3.CreditName in project ORCID-Source by ORCID.
the class RecordNameManagerTest method testCreateRecordName.
@Test
public void testCreateRecordName() {
Name name = new Name();
long time = System.currentTimeMillis();
name.setCreditName(new CreditName("Credit Name " + time));
name.setFamilyName(new FamilyName("Family Name " + time));
name.setGivenNames(new GivenNames("Given Names " + time));
name.setVisibility(Visibility.PRIVATE);
String orcid = "0000-0000-0000-0005";
recordNameManager.createRecordName(orcid, name);
Name newName = recordNameManager.getRecordName(orcid, 0);
assertNotNull(newName);
assertEquals("Credit Name " + time, newName.getCreditName().getContent());
assertEquals("Family Name " + time, newName.getFamilyName().getContent());
assertEquals("Given Names " + time, newName.getGivenNames().getContent());
assertEquals(Visibility.PRIVATE, newName.getVisibility());
}
use of org.orcid.jaxb.model.record_rc3.CreditName in project ORCID-Source by ORCID.
the class SetUpClientsAndUsers method createUser.
private void createUser(Map<String, String> params) throws Exception {
// Create it
OrcidProfile orcidProfile = new OrcidProfile();
orcidProfile.setOrcidIdentifier(new OrcidIdentifier(params.get(ORCID)));
orcidProfile.setType(OrcidType.fromValue(params.get(ORCID_TYPE)));
if (params.get(MEMBER_TYPE) != null) {
orcidProfile.setGroupType(MemberType.fromValue(params.get(MEMBER_TYPE)));
}
orcidProfile.setPassword(params.get(PASSWORD));
OrcidInternal internal = new OrcidInternal();
Preferences preferences = new Preferences();
ActivitiesVisibilityDefault visibilityDefaults = new ActivitiesVisibilityDefault();
visibilityDefaults.setValue(Visibility.PUBLIC);
preferences.setActivitiesVisibilityDefault(visibilityDefaults);
internal.setPreferences(preferences);
orcidProfile.setOrcidInternal(internal);
Email email = new Email(params.get(EMAIL));
email.setCurrent(true);
email.setPrimary(true);
email.setVerified(true);
email.setVisibility(Visibility.PUBLIC);
List<Email> emails = new ArrayList<Email>();
emails.add(email);
ContactDetails contactDetails = new ContactDetails();
contactDetails.setEmail(emails);
org.orcid.jaxb.model.message.PersonalDetails personalDetails = new org.orcid.jaxb.model.message.PersonalDetails();
org.orcid.jaxb.model.message.CreditName creditName = new org.orcid.jaxb.model.message.CreditName(params.get(CREDIT_NAME));
creditName.setVisibility(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility());
personalDetails.setCreditName(creditName);
personalDetails.setFamilyName(new org.orcid.jaxb.model.message.FamilyName(params.get(FAMILY_NAMES)));
personalDetails.setGivenNames(new org.orcid.jaxb.model.message.GivenNames(params.get(GIVEN_NAMES)));
OrcidBio bio = new OrcidBio();
bio.setContactDetails(contactDetails);
bio.setPersonalDetails(personalDetails);
bio.setBiography(new Biography(params.get(BIO), OrcidVisibilityDefaults.BIOGRAPHY_DEFAULT.getVisibility()));
orcidProfile.setOrcidBio(bio);
OrcidHistory history = new OrcidHistory();
history.setClaimed(new Claimed(true));
history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
history.setCreationMethod(CreationMethod.DIRECT);
orcidProfile.setOrcidHistory(history);
orcidProfileManager.createOrcidProfile(orcidProfile, false, false);
if (params.containsKey(LOCKED)) {
orcidProfileManager.lockProfile(params.get(ORCID), LockReason.SPAM.getLabel(), null);
}
if (params.containsKey(DEVELOPER_TOOLS)) {
profileEntityManager.enableDeveloperTools(orcidProfile);
}
}
use of org.orcid.jaxb.model.record_rc3.CreditName in project ORCID-Source by ORCID.
the class SetUpClientsAndUsers method clearRegistry.
private boolean clearRegistry(OrcidProfile existingProfile, Map<String, String> params) {
if (existingProfile != null) {
String orcid = params.get(ORCID);
String email = params.get(EMAIL);
// exception
if (existingProfile.getOrcidBio() == null || existingProfile.getOrcidBio().getContactDetails() == null || existingProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail() == null || !email.equals(existingProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail().getValue())) {
throw new ApplicationException("User with email " + params.get(EMAIL) + " must have orcid id '" + orcid + "' but it is '" + existingProfile.getOrcidId() + "'");
}
// Check if the profile have the same password, if not, update the
// password
String encryptedPassword = encryptionManager.hashForInternalUse(params.get(PASSWORD));
if (!encryptedPassword.equals(existingProfile.getPassword())) {
existingProfile.setPassword(params.get(PASSWORD));
orcidProfileManager.updatePasswordInformation(existingProfile);
}
// Set default names
Name name = new Name();
name.setCreditName(new CreditName(params.get(CREDIT_NAME)));
name.setGivenNames(new GivenNames(params.get(GIVEN_NAMES)));
name.setFamilyName(new FamilyName(params.get(FAMILY_NAMES)));
name.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility().value()));
if (recordNameManager.exists(orcid)) {
recordNameManager.updateRecordName(orcid, name);
} else {
recordNameManager.createRecordName(orcid, name);
}
profileDao.updatePreferences(orcid, true, true, true, true, org.orcid.jaxb.model.common_v2.Visibility.PUBLIC, true, 1f);
// Set default bio
org.orcid.jaxb.model.record_v2.Biography bio = biographyManager.getBiography(orcid, 0L);
if (bio == null || bio.getContent() == null) {
bio = new org.orcid.jaxb.model.record_v2.Biography(params.get(BIO));
bio.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(OrcidVisibilityDefaults.BIOGRAPHY_DEFAULT.getVisibility().value()));
biographyManager.createBiography(orcid, bio);
} else {
bio.setContent(params.get(BIO));
bio.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(OrcidVisibilityDefaults.BIOGRAPHY_DEFAULT.getVisibility().value()));
biographyManager.updateBiography(orcid, bio);
}
// Remove other names
List<OtherNameEntity> otherNames = otherNameDao.getOtherNames(orcid, 0L);
if (otherNames != null && !otherNames.isEmpty()) {
for (OtherNameEntity otherName : otherNames) {
otherNameDao.deleteOtherName(otherName);
}
}
// Remove keywords
List<ProfileKeywordEntity> keywords = profileKeywordDao.getProfileKeywors(orcid, 0L);
if (keywords != null && !keywords.isEmpty()) {
for (ProfileKeywordEntity keyword : keywords) {
profileKeywordDao.deleteProfileKeyword(keyword);
}
}
//Remove researcher urls
List<ResearcherUrlEntity> rUrls = researcherUrlDao.getResearcherUrls(orcid, 0L);
if (rUrls != null && !rUrls.isEmpty()) {
for (ResearcherUrlEntity rUrl : rUrls) {
researcherUrlDao.deleteResearcherUrl(orcid, rUrl.getId());
}
}
// Remove external ids
List<ExternalIdentifierEntity> extIds = externalIdentifierDao.getExternalIdentifiers(orcid, System.currentTimeMillis());
if (extIds != null && !extIds.isEmpty()) {
for (ExternalIdentifierEntity extId : extIds) {
externalIdentifierDao.removeExternalIdentifier(orcid, extId.getId());
}
}
// Remove addresses
List<AddressEntity> addresses = addressDao.getAddresses(orcid, 0L);
if (addresses != null && !addresses.isEmpty()) {
for (AddressEntity address : addresses) {
addressDao.deleteAddress(orcid, address.getId());
}
}
// Remove emails
List<EmailEntity> emails = emailDao.findByOrcid(orcid);
if (emails != null && !emails.isEmpty()) {
for (EmailEntity rc2Email : emails) {
if (!params.get(EMAIL).equals(rc2Email.getId())) {
emailDao.removeEmail(orcid, rc2Email.getId());
}
}
}
// Remove notifications
List<NotificationEntity> notifications = notificationDao.findByOrcid(orcid, true, 0, 10000);
if (notifications != null && !notifications.isEmpty()) {
for (NotificationEntity notification : notifications) {
notificationDao.deleteNotificationItemByNotificationId(notification.getId());
notificationDao.deleteNotificationWorkByNotificationId(notification.getId());
notificationDao.deleteNotificationById(notification.getId());
}
}
// Remove works
List<MinimizedWorkEntity> works = workDao.findWorks(orcid, 0L);
if (works != null && !works.isEmpty()) {
for (MinimizedWorkEntity work : works) {
workDao.removeWork(orcid, work.getId());
}
}
// Remove affiliations
List<OrgAffiliationRelationEntity> affiliations = orgAffiliationRelationDao.getByUser(orcid);
if (affiliations != null && !affiliations.isEmpty()) {
for (OrgAffiliationRelationEntity affiliation : affiliations) {
orgAffiliationRelationDao.remove(affiliation.getId());
}
}
// Remove fundings
List<ProfileFundingEntity> fundings = profileFundingDao.getByUser(orcid);
if (fundings != null && !fundings.isEmpty()) {
for (ProfileFundingEntity funding : fundings) {
profileFundingDao.removeProfileFunding(orcid, funding.getId());
}
}
// Remove peer reviews
List<PeerReviewEntity> peerReviews = peerReviewDao.getByUser(orcid);
if (peerReviews != null && !peerReviews.isEmpty()) {
for (PeerReviewEntity peerReview : peerReviews) {
peerReviewDao.removePeerReview(orcid, peerReview.getId());
}
}
// Remove 3d party links
List<OrcidOauth2TokenDetail> tokenDetails = orcidOauth2TokenDetailDao.findByUserName(orcid);
if (tokenDetails != null && !tokenDetails.isEmpty()) {
for (OrcidOauth2TokenDetail token : tokenDetails) {
orcidOauth2TokenDetailDao.remove(token.getId());
}
}
//Unlock just in case it is locked
profileDao.unlockProfile(orcid);
return true;
}
return false;
}
Aggregations