Search in sources :

Example 16 with CreditName

use of org.orcid.jaxb.model.v3.dev1.record.CreditName in project ORCID-Source by ORCID.

the class ActivityUtilsTest method getEmptyWork.

private Work getEmptyWork() {
    Work w = new Work();
    // Title
    WorkTitle title = new WorkTitle();
    title.setTitle(new Title(""));
    title.setSubtitle(new Subtitle(""));
    title.setTranslatedTitle(new TranslatedTitle(""));
    w.setWorkTitle(title);
    // Citation
    w.setWorkCitation(new Citation());
    WorkContributors wc = new WorkContributors();
    // Contributors
    Contributor c = new Contributor();
    c.setCreditName(new CreditName(""));
    wc.getContributor().add(c);
    w.setWorkContributors(wc);
    return w;
}
Also used : Subtitle(org.orcid.jaxb.model.v3.dev1.common.Subtitle) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) WorkContributors(org.orcid.jaxb.model.v3.dev1.record.WorkContributors) Work(org.orcid.jaxb.model.v3.dev1.record.Work) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) Title(org.orcid.jaxb.model.v3.dev1.common.Title) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor) Contributor(org.orcid.jaxb.model.v3.dev1.common.Contributor) Citation(org.orcid.jaxb.model.v3.dev1.record.Citation)

Example 17 with CreditName

use of org.orcid.jaxb.model.v3.dev1.record.CreditName in project ORCID-Source by ORCID.

the class Contributor method toFundingContributor.

public FundingContributor toFundingContributor() {
    FundingContributor c = new FundingContributor();
    if (this.getContributorRole() != null || this.getContributorSequence() != null) {
        FundingContributorAttributes ca = new FundingContributorAttributes();
        if (!PojoUtil.isEmpty(this.getContributorRole()))
            ca.setContributorRole(FundingContributorRole.fromValue(this.getContributorRole().getValue()));
        c.setContributorAttributes(ca);
    }
    if (this.getEmail() != null)
        c.setContributorEmail(new ContributorEmail(this.getEmail().getValue()));
    if (this.getOrcid() != null) {
        ContributorOrcid contributorOrcid = new ContributorOrcid(this.getOrcid().getValue());
        if (this.getUri() != null) {
            String uriString = this.getUri().getValue();
            if (StringUtils.isNotBlank(uriString)) {
                try {
                    URI uri = new URI(uriString);
                    contributorOrcid.setHost(uri.getHost());
                } catch (URISyntaxException e) {
                    throw new RuntimeException("Problem parsing contributor orcid uri", e);
                }
            }
        }
        contributorOrcid.setUri(this.getUri().getValue());
        c.setContributorOrcid(contributorOrcid);
    }
    if (this.getCreditName() != null) {
        CreditName cn = new CreditName(this.getCreditName().getValue());
        c.setCreditName(cn);
    }
    return c;
}
Also used : FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) FundingContributorAttributes(org.orcid.jaxb.model.v3.dev1.record.FundingContributorAttributes) ContributorOrcid(org.orcid.jaxb.model.v3.dev1.common.ContributorOrcid) URISyntaxException(java.net.URISyntaxException) ContributorEmail(org.orcid.jaxb.model.v3.dev1.common.ContributorEmail) URI(java.net.URI)

Example 18 with CreditName

use of org.orcid.jaxb.model.v3.dev1.record.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);
                }
            }
        }
    }
}
Also used : CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor) Contributor(org.orcid.jaxb.model.v3.dev1.common.Contributor) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity)

Example 19 with CreditName

use of org.orcid.jaxb.model.v3.dev1.record.CreditName in project ORCID-Source by ORCID.

the class JpaJaxbWorkAdapterTest method testToWorkEntity.

@Test
public void testToWorkEntity() throws JAXBException {
    Work work = getWork(true);
    assertNotNull(work);
    WorkEntity workEntity = jpaJaxbWorkAdapter.toWorkEntity(work);
    assertNotNull(workEntity);
    assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE, workEntity.getVisibility());
    assertNotNull(workEntity);
    assertEquals(123, workEntity.getId().longValue());
    assertEquals("common:title", workEntity.getTitle());
    assertTrue(PojoUtil.isEmpty(workEntity.getSubtitle()));
    assertEquals("common:translated-title", workEntity.getTranslatedTitle());
    assertEquals("en", workEntity.getTranslatedTitleLanguageCode());
    assertEquals("work:short-description", workEntity.getDescription());
    assertEquals(org.orcid.jaxb.model.record_v2.CitationType.FORMATTED_UNSPECIFIED, workEntity.getCitationType());
    assertEquals(org.orcid.jaxb.model.record_v2.WorkType.ARTISTIC_PERFORMANCE, workEntity.getWorkType());
    PublicationDateEntity publicationDateEntity = workEntity.getPublicationDate();
    assertNotNull(publicationDateEntity);
    assertEquals(1848, publicationDateEntity.getYear().intValue());
    assertEquals(02, publicationDateEntity.getMonth().intValue());
    assertEquals(02, publicationDateEntity.getDay().intValue());
    assertEquals("{\"workExternalIdentifier\":[{\"relationship\":\"SELF\",\"url\":{\"value\":\"http://orcid.org\"},\"workExternalIdentifierType\":\"AGR\",\"workExternalIdentifierId\":{\"content\":\"work:external-identifier-id\"}}]}", workEntity.getExternalIdentifiersJson());
    assertEquals("http://tempuri.org", workEntity.getWorkUrl());
    assertEquals("{\"contributor\":[{\"contributorOrcid\":{\"uri\":\"http://orcid.org/8888-8888-8888-8880\",\"path\":\"8888-8888-8888-8880\",\"host\":\"orcid.org\"},\"creditName\":{\"content\":\"work:credit-name\"},\"contributorEmail\":{\"value\":\"work@contributor.email\"},\"contributorAttributes\":{\"contributorSequence\":\"FIRST\",\"contributorRole\":\"AUTHOR\"}}]}", workEntity.getContributorsJson());
    assertEquals("en", workEntity.getLanguageCode());
    assertEquals(org.orcid.jaxb.model.common_v2.Iso3166Country.AF, workEntity.getIso2Country());
    // Source
    assertNull(workEntity.getSourceId());
    assertNull(workEntity.getClientSourceId());
    assertNull(workEntity.getElementSourceId());
}
Also used : WorkEntity(org.orcid.persistence.jpa.entities.WorkEntity) PublicationDateEntity(org.orcid.persistence.jpa.entities.PublicationDateEntity) Work(org.orcid.jaxb.model.v3.dev1.record.Work) Test(org.junit.Test)

Example 20 with CreditName

use of org.orcid.jaxb.model.v3.dev1.record.CreditName in project ORCID-Source by ORCID.

the class JpaJaxbFundingAdapterTest method toFundingEntityTest.

@Test
public void toFundingEntityTest() throws JAXBException {
    Funding f = getFunding(true);
    assertNotNull(f);
    ProfileFundingEntity pfe = jpaJaxbFundingAdapter.toProfileFundingEntity(f);
    assertNotNull(pfe);
    // Enums
    assertEquals(Visibility.PRIVATE.value(), pfe.getVisibility().value());
    assertEquals(FundingType.GRANT.value(), pfe.getType().value());
    // General info
    assertEquals(Long.valueOf(0), pfe.getId());
    assertEquals("common:title", pfe.getTitle());
    assertEquals("common:translated-title", pfe.getTranslatedTitle());
    assertEquals("en", pfe.getTranslatedTitleLanguageCode());
    assertEquals("funding:organization-defined-type", pfe.getOrganizationDefinedType());
    assertEquals("funding:short-description", pfe.getDescription());
    assertEquals("1234", pfe.getNumericAmount().toString());
    assertEquals("ADP", pfe.getCurrencyCode());
    assertEquals("http://tempuri.org", pfe.getUrl());
    // Dates
    assertEquals(Integer.valueOf(2), pfe.getStartDate().getDay());
    assertEquals(Integer.valueOf(2), pfe.getStartDate().getMonth());
    assertEquals(Integer.valueOf(1848), pfe.getStartDate().getYear());
    assertEquals(Integer.valueOf(2), pfe.getEndDate().getDay());
    assertEquals(Integer.valueOf(2), pfe.getEndDate().getMonth());
    assertEquals(Integer.valueOf(1848), pfe.getEndDate().getYear());
    // Contributors
    assertEquals("{\"contributor\":[{\"contributorOrcid\":{\"uri\":\"http://orcid.org/8888-8888-8888-8880\",\"path\":\"8888-8888-8888-8880\",\"host\":\"orcid.org\"},\"creditName\":{\"content\":\"funding:credit-name\"},\"contributorEmail\":{\"value\":\"funding@contributor.email\"},\"contributorAttributes\":{\"contributorRole\":\"LEAD\"}}]}", pfe.getContributorsJson());
    // External identifiers
    assertEquals("{\"fundingExternalIdentifier\":[{\"type\":\"GRANT_NUMBER\",\"value\":\"funding:external-identifier-value\",\"url\":{\"value\":\"http://tempuri.org\"},\"relationship\":\"SELF\"},{\"type\":\"GRANT_NUMBER\",\"value\":\"funding:external-identifier-value2\",\"url\":{\"value\":\"http://tempuri.org/2\"},\"relationship\":\"SELF\"}]}", pfe.getExternalIdentifiersJson());
    // Check org is null
    assertNull(pfe.getOrg());
    // Source
    assertNull(pfe.getSourceId());
    assertNull(pfe.getClientSourceId());
    assertNull(pfe.getElementSourceId());
}
Also used : Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) Test(org.junit.Test)

Aggregations

CreditName (org.orcid.jaxb.model.v3.dev1.common.CreditName)18 FundingContributor (org.orcid.jaxb.model.v3.dev1.record.FundingContributor)10 Test (org.junit.Test)8 Name (org.orcid.jaxb.model.v3.dev1.record.Name)8 Contributor (org.orcid.jaxb.model.v3.dev1.common.Contributor)7 FamilyName (org.orcid.jaxb.model.v3.dev1.record.FamilyName)7 GivenNames (org.orcid.jaxb.model.v3.dev1.record.GivenNames)7 Work (org.orcid.jaxb.model.v3.dev1.record.Work)7 ContributorEmail (org.orcid.jaxb.model.v3.dev1.common.ContributorEmail)6 ContributorOrcid (org.orcid.jaxb.model.v3.dev1.common.ContributorOrcid)6 Title (org.orcid.jaxb.model.v3.dev1.common.Title)4 CreditName (org.orcid.jaxb.model.v3.dev1.record.CreditName)4 WorkContributors (org.orcid.jaxb.model.v3.dev1.record.WorkContributors)4 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)4 ArrayList (java.util.ArrayList)3 Country (org.orcid.jaxb.model.v3.dev1.common.Country)3 Day (org.orcid.jaxb.model.v3.dev1.common.Day)3 Iso3166Country (org.orcid.jaxb.model.v3.dev1.common.Iso3166Country)3 PublicationDate (org.orcid.jaxb.model.v3.dev1.common.PublicationDate)3 Subtitle (org.orcid.jaxb.model.v3.dev1.common.Subtitle)3