use of org.orcid.jaxb.model.record_v2.Keywords in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_KeywordsTest method testViewKeywords.
@Test
public void testViewKeywords() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED);
Response response = serviceDelegator.viewKeywords("4444-4444-4444-4443");
assertNotNull(response);
Keywords keywords = (Keywords) response.getEntity();
assertNotNull(keywords);
assertEquals("/4444-4444-4444-4443/keywords", keywords.getPath());
Utils.verifyLastModified(keywords.getLastModifiedDate());
assertNotNull(keywords.getKeywords());
assertEquals(3, keywords.getKeywords().size());
for (Keyword keyword : keywords.getKeywords()) {
Utils.verifyLastModified(keyword.getLastModifiedDate());
assertThat(keyword.getPutCode(), anyOf(is(1L), is(2L), is(4L)));
assertThat(keyword.getContent(), anyOf(is("tea making"), is("coffee making"), is("what else can we make?")));
if (keyword.getPutCode() == 1L) {
assertEquals(Visibility.PUBLIC, keyword.getVisibility());
assertEquals("APP-5555555555555555", keyword.getSource().retrieveSourcePath());
} else if (keyword.getPutCode() == 2L) {
assertEquals(Visibility.LIMITED, keyword.getVisibility());
assertEquals("4444-4444-4444-4443", keyword.getSource().retrieveSourcePath());
} else {
assertEquals(Visibility.PRIVATE, keyword.getVisibility());
assertEquals("APP-5555555555555555", keyword.getSource().retrieveSourcePath());
}
}
}
use of org.orcid.jaxb.model.record_v2.Keywords in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_KeywordsTest method testViewKeywordsReadPublic.
@Test
public void testViewKeywordsReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewKeywords(ORCID);
Keywords element = (Keywords) r.getEntity();
assertNotNull(element);
assertEquals("/0000-0000-0000-0003/keywords", element.getPath());
Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
use of org.orcid.jaxb.model.record_v2.Keywords in project ORCID-Source by ORCID.
the class JpaJaxbKeywordAdapterImpl method toKeywords.
@Override
public Keywords toKeywords(Collection<ProfileKeywordEntity> entities) {
if (entities == null) {
return null;
}
List<Keyword> keywordList = mapperFacade.mapAsList(entities, Keyword.class);
Keywords keywords = new Keywords();
keywords.setKeywords(keywordList);
return keywords;
}
use of org.orcid.jaxb.model.record_v2.Keywords in project ORCID-Source by ORCID.
the class ProfileEntityManagerImpl method deprecateProfile.
/**
* Deprecates a profile
*
* @param deprecatedProfile
* The profile that want to be deprecated
* @param primaryProfile
* The primary profile for the deprecated profile
* @return true if the account was successfully deprecated, false otherwise
*/
@Override
@Transactional
public boolean deprecateProfile(String deprecatedOrcid, String primaryOrcid) {
boolean wasDeprecated = profileDao.deprecateProfile(deprecatedOrcid, primaryOrcid);
// If it was successfully deprecated
if (wasDeprecated) {
LOGGER.info("Account {} was deprecated to primary account: {}", deprecatedOrcid, primaryOrcid);
ProfileEntity deprecated = profileDao.find(deprecatedOrcid);
// Remove works
workManager.removeAllWorks(deprecatedOrcid);
// Remove funding
if (deprecated.getProfileFunding() != null) {
for (ProfileFundingEntity funding : deprecated.getProfileFunding()) {
fundingManager.removeProfileFunding(funding.getProfile().getId(), funding.getId());
}
}
// Remove affiliations
if (deprecated.getOrgAffiliationRelations() != null) {
for (OrgAffiliationRelationEntity affiliation : deprecated.getOrgAffiliationRelations()) {
orgAffiliationRelationDao.removeOrgAffiliationRelation(affiliation.getProfile().getId(), affiliation.getId());
}
}
// Remove external identifiers
if (deprecated.getExternalIdentifiers() != null) {
for (ExternalIdentifierEntity externalIdentifier : deprecated.getExternalIdentifiers()) {
externalIdentifierManager.deleteExternalIdentifier(deprecated.getId(), externalIdentifier.getId(), false);
}
}
// Remove researcher urls
if (deprecated.getResearcherUrls() != null) {
for (ResearcherUrlEntity rUrl : deprecated.getResearcherUrls()) {
researcherUrlManager.deleteResearcherUrl(deprecatedOrcid, rUrl.getId(), false);
}
}
// Remove other names
if (deprecated.getOtherNames() != null) {
for (OtherNameEntity otherName : deprecated.getOtherNames()) {
otherNamesManager.deleteOtherName(deprecatedOrcid, otherName.getId(), false);
}
}
// Remove keywords
if (deprecated.getKeywords() != null) {
for (ProfileKeywordEntity keyword : deprecated.getKeywords()) {
profileKeywordManager.deleteKeyword(deprecatedOrcid, keyword.getId(), false);
}
}
//Remove biography
if (biographyManager.exists(deprecatedOrcid)) {
Biography deprecatedBio = new Biography();
deprecatedBio.setContent(null);
deprecatedBio.setVisibility(Visibility.PRIVATE);
biographyManager.updateBiography(deprecatedOrcid, deprecatedBio);
}
//Set the deactivated names
if (recordNameManager.exists(deprecatedOrcid)) {
Name name = new Name();
name.setCreditName(new CreditName());
name.setGivenNames(new GivenNames("Given Names Deactivated"));
name.setFamilyName(new FamilyName("Family Name Deactivated"));
name.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
name.setPath(deprecatedOrcid);
recordNameManager.updateRecordName(deprecatedOrcid, name);
}
userConnectionDao.deleteByOrcid(deprecatedOrcid);
// Move all emails to the primary email
Set<EmailEntity> deprecatedAccountEmails = deprecated.getEmails();
if (deprecatedAccountEmails != null) {
// For each email in the deprecated profile
for (EmailEntity email : deprecatedAccountEmails) {
// Delete each email from the deprecated
// profile
LOGGER.info("About to move email {} from profile {} to profile {}", new Object[] { email.getId(), deprecatedOrcid, primaryOrcid });
emailManager.moveEmailToOtherAccount(email.getId(), deprecatedOrcid, primaryOrcid);
}
}
return true;
}
return false;
}
use of org.orcid.jaxb.model.record_v2.Keywords in project ORCID-Source by ORCID.
the class SourceUtils method setSourceName.
public void setSourceName(Person person) {
if (person == null) {
return;
}
if (person.getAddresses() != null) {
Addresses addresses = person.getAddresses();
setSourceName(addresses);
}
if (person.getEmails() != null) {
Emails emails = person.getEmails();
setSourceName(emails);
}
if (person.getExternalIdentifiers() != null) {
PersonExternalIdentifiers extIds = person.getExternalIdentifiers();
setSourceName(extIds);
}
if (person.getKeywords() != null) {
Keywords keywords = person.getKeywords();
setSourceName(keywords);
}
if (person.getOtherNames() != null) {
OtherNames otherNames = person.getOtherNames();
setSourceName(otherNames);
}
if (person.getResearcherUrls() != null) {
ResearcherUrls researcherUrls = person.getResearcherUrls();
setSourceName(researcherUrls);
}
}
Aggregations