Search in sources :

Example 36 with Keywords

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());
        }
    }
}
Also used : Response(javax.ws.rs.core.Response) Keywords(org.orcid.jaxb.model.record_v2.Keywords) Keyword(org.orcid.jaxb.model.record_v2.Keyword) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 37 with Keywords

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");
}
Also used : Response(javax.ws.rs.core.Response) Keywords(org.orcid.jaxb.model.record_v2.Keywords) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 38 with Keywords

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;
}
Also used : Keywords(org.orcid.jaxb.model.record_v2.Keywords) Keyword(org.orcid.jaxb.model.record_v2.Keyword)

Example 39 with 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;
}
Also used : ProfileKeywordEntity(org.orcid.persistence.jpa.entities.ProfileKeywordEntity) FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) ResearcherUrlEntity(org.orcid.persistence.jpa.entities.ResearcherUrlEntity) ExternalIdentifierEntity(org.orcid.persistence.jpa.entities.ExternalIdentifierEntity) CreditName(org.orcid.jaxb.model.record_v2.CreditName) EmailEntity(org.orcid.persistence.jpa.entities.EmailEntity) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) CreditName(org.orcid.jaxb.model.record_v2.CreditName) FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) Name(org.orcid.jaxb.model.record_v2.Name) GivenNames(org.orcid.jaxb.model.record_v2.GivenNames) Biography(org.orcid.jaxb.model.record_v2.Biography) OtherNameEntity(org.orcid.persistence.jpa.entities.OtherNameEntity) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 40 with Keywords

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);
    }
}
Also used : Addresses(org.orcid.jaxb.model.record_v2.Addresses) Keywords(org.orcid.jaxb.model.record_v2.Keywords) PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) ResearcherUrls(org.orcid.jaxb.model.record_v2.ResearcherUrls) Emails(org.orcid.jaxb.model.record_v2.Emails)

Aggregations

Test (org.junit.Test)62 Keywords (org.orcid.jaxb.model.record_v2.Keywords)54 Keyword (org.orcid.jaxb.model.record_v2.Keyword)53 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)37 Address (org.orcid.jaxb.model.record_v2.Address)36 Biography (org.orcid.jaxb.model.record_v2.Biography)36 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)36 Addresses (org.orcid.jaxb.model.record_v2.Addresses)35 Email (org.orcid.jaxb.model.record_v2.Email)35 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)35 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)35 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)35 OtherName (org.orcid.jaxb.model.record_v2.OtherName)34 Emails (org.orcid.jaxb.model.record_v2.Emails)33 Name (org.orcid.jaxb.model.record_v2.Name)30 Person (org.orcid.jaxb.model.record_v2.Person)28 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)17 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)17 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)17 Record (org.orcid.jaxb.model.record_v2.Record)17