Search in sources :

Example 11 with OrcidWork

use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.

the class OrcidIndexManagerImplTest method onlyDoiPersistedFromOrcidWorks.

@Test
@Rollback
public void onlyDoiPersistedFromOrcidWorks() {
    OrcidProfile orcidProfileWithDOI = getStandardOrcidWithDoiInformation();
    OrcidSolrDocument doiListings = solrDocumentLimitedtoVisibleDoi();
    // check that the limited profiles or non doi identifiers aren't
    // included
    orcidIndexManager.persistProfileInformationForIndexing(orcidProfileWithDOI);
    verify(solrDao).persist(eq(doiListings));
    // now check null values aren't persisted when either the type or value
    // are missing
    OrcidWork orcidWork1 = orcidProfileWithDOI.retrieveOrcidWorks().getOrcidWork().get(0);
    orcidWork1.getWorkExternalIdentifiers().getWorkExternalIdentifier().get(0).setWorkExternalIdentifierType(null);
    OrcidWork orcidWork2 = orcidProfileWithDOI.retrieveOrcidWorks().getOrcidWork().get(1);
    orcidWork2.getWorkExternalIdentifiers().getWorkExternalIdentifier().get(0).setWorkExternalIdentifierId(null);
    // so this should leave only the second doi
    doiListings.setDigitalObjectIds(Arrays.asList(new String[] { "work2-doi2" }));
    OrcidMessage orcidMessage = createFilteredOrcidMessage(orcidProfileWithDOI);
    doiListings.setPublicProfileMessage(orcidMessage.toString());
    orcidIndexManager.persistProfileInformationForIndexing(orcidProfileWithDOI);
    verify(solrDao).persist(eq(doiListings));
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidSolrDocument(org.orcid.utils.solr.entities.OrcidSolrDocument) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 12 with OrcidWork

use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.

the class OrcidProfileManagerContributorVisibilityTest method emailProvidedButDoesNotExistInDb.

@Test
@Transactional
public void emailProvidedButDoesNotExistInDb() {
    // Unmarshall message containing contributor email that does not exist
    // in DB
    OrcidMessage orcidMessage = unmarshallOrcidMessage("new_work_with_contributor_email_and_name.xml");
    // Add the work
    orcidProfileManager.addOrcidWorks(orcidMessage.getOrcidProfile());
    // Get it back from the API
    OrcidWork retrievedWork = retrieveAddedWorkFromApi();
    Contributor workContributor = retrievedWork.getWorkContributors().getContributor().get(0);
    // Check that the contributor name is included in the resulting work
    assertEquals("Test Contributor Name", workContributor.getCreditName().getContent());
    // Check that the email is not included in the resulting work, because
    // never want to show email
    assertNull(workContributor.getContributorEmail());
    // Get the contributor directly from the DB so can see stuff not
    // included in the API
    Contributor workContributorDirectFromDb = retrieveWorkContributorEntityDirectlyFromDb(retrievedWork);
    // Check the email is in the DB for later use if needed
    assertEquals("doesnotexist@orcid.org", workContributorDirectFromDb.getContributorEmail().getValue());
}
Also used : OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Contributor(org.orcid.jaxb.model.message.Contributor) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with OrcidWork

use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.

the class OrcidProfileManagerContributorVisibilityTest method onlyNameProvided.

@Test
@Transactional
public void onlyNameProvided() {
    // Unmarshall message containing contributor name only
    OrcidMessage orcidMessage = unmarshallOrcidMessage("new_work_with_contributor_name.xml");
    // Add the work
    orcidProfileManager.addOrcidWorks(orcidMessage.getOrcidProfile());
    // Get it back from the API
    OrcidWork retrievedWork = retrieveAddedWorkFromApi();
    Contributor workContributor = retrievedWork.getWorkContributors().getContributor().get(0);
    // Check that the contributor name is included in the resulting work
    assertEquals("Test Contributor Name", workContributor.getCreditName().getContent());
    // Check that the email is not included in the resulting work, because
    // never want to show email
    assertNull(workContributor.getContributorEmail());
}
Also used : OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Contributor(org.orcid.jaxb.model.message.Contributor) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with OrcidWork

use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.

the class OrcidProfileManagerImpl method addSourceToWorks.

private void addSourceToWorks(OrcidWorks orcidWorks, String amenderOrcid) {
    if (orcidWorks != null && !orcidWorks.getOrcidWork().isEmpty() && amenderOrcid != null) {
        for (OrcidWork orcidWork : orcidWorks.getOrcidWork()) {
            Source source = createSource(amenderOrcid);
            orcidWork.setSource(source);
        }
    }
}
Also used : OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Source(org.orcid.jaxb.model.message.Source)

Example 15 with OrcidWork

use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.

the class OrcidProfileManagerImpl method dedupeWorks.

@Override
public OrcidWorks dedupeWorks(OrcidWorks orcidWorks) {
    Set<OrcidWork> workSet = new LinkedHashSet<OrcidWork>();
    for (OrcidWork orcidWork : orcidWorks.getOrcidWork()) {
        orcidProfileCleaner.clean(orcidWork);
        workSet.add(orcidWork);
    }
    OrcidWorks dedupedOrcidWorks = new OrcidWorks();
    dedupedOrcidWorks.getOrcidWork().addAll(workSet);
    return dedupedOrcidWorks;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks)

Aggregations

OrcidWork (org.orcid.jaxb.model.message.OrcidWork)81 Test (org.junit.Test)44 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)42 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)32 Transactional (org.springframework.transaction.annotation.Transactional)26 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)24 Title (org.orcid.jaxb.model.message.Title)23 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)20 WorkTitle (org.orcid.jaxb.model.message.WorkTitle)18 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)16 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)16 Source (org.orcid.jaxb.model.message.Source)14 Rollback (org.springframework.test.annotation.Rollback)13 ArrayList (java.util.ArrayList)12 Funding (org.orcid.jaxb.model.message.Funding)12 WorkExternalIdentifierId (org.orcid.jaxb.model.message.WorkExternalIdentifierId)12 BaseTest (org.orcid.core.BaseTest)11 Contributor (org.orcid.jaxb.model.message.Contributor)11 WorkExternalIdentifiers (org.orcid.jaxb.model.message.WorkExternalIdentifiers)11 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)10