Search in sources :

Example 6 with TranslatedTitle

use of org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle in project ORCID-Source by ORCID.

the class ActivityUtilsTest method getEmptyWorkSummary.

private WorkSummary getEmptyWorkSummary() {
    WorkSummary s = new WorkSummary();
    WorkTitle title = new WorkTitle();
    title.setTitle(new Title(""));
    title.setSubtitle(new Subtitle(""));
    title.setTranslatedTitle(new TranslatedTitle(""));
    s.setTitle(title);
    return s;
}
Also used : Subtitle(org.orcid.jaxb.model.v3.dev1.common.Subtitle) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) 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)

Example 7 with TranslatedTitle

use of org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_WorksTest method testCleanEmptyFieldsOnWorks.

@Test
public void testCleanEmptyFieldsOnWorks() {
    LastModifiedDate lmd = new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(System.currentTimeMillis()));
    Work work = new Work();
    work.setLastModifiedDate(lmd);
    work.setWorkCitation(new Citation("", CitationType.FORMATTED_UNSPECIFIED));
    WorkTitle title = new WorkTitle();
    title.setTitle(new Title("My Work"));
    title.setSubtitle(new Subtitle("My subtitle"));
    title.setTranslatedTitle(new TranslatedTitle("", ""));
    work.setWorkTitle(title);
    ActivityUtils.cleanEmptyFields(work);
    assertNotNull(work);
    Utils.verifyLastModified(work.getLastModifiedDate());
    assertNotNull(work.getWorkTitle());
    assertNotNull(work.getWorkTitle().getTitle());
    assertNotNull(work.getWorkTitle().getSubtitle());
    assertEquals("My Work", work.getWorkTitle().getTitle().getContent());
    assertEquals("My subtitle", work.getWorkTitle().getSubtitle().getContent());
    assertNull(work.getWorkCitation());
    assertNull(work.getWorkTitle().getTranslatedTitle());
}
Also used : LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) 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) Work(org.orcid.jaxb.model.v3.dev1.record.Work) Title(org.orcid.jaxb.model.v3.dev1.common.Title) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Citation(org.orcid.jaxb.model.v3.dev1.record.Citation) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 8 with TranslatedTitle

use of org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle in project ORCID-Source by ORCID.

the class FundingForm method valueOf.

public static FundingForm valueOf(Funding funding) {
    FundingForm result = new FundingForm();
    result.setDateSortString(PojoUtil.createDateSortString(funding.getStartDate(), funding.getEndDate()));
    if (funding.getPutCode() != null)
        result.setPutCode(Text.valueOf(funding.getPutCode()));
    if (funding.getAmount() != null) {
        if (StringUtils.isNotEmpty(funding.getAmount().getContent())) {
            String cleanNumber = funding.getAmount().getContent().trim();
            result.setAmount(Text.valueOf(cleanNumber));
        }
        if (funding.getAmount().getCurrencyCode() != null)
            result.setCurrencyCode(Text.valueOf(funding.getAmount().getCurrencyCode()));
        else
            result.setCurrencyCode(new Text());
    } else {
        result.setAmount(new Text());
        result.setCurrencyCode(new Text());
    }
    if (StringUtils.isNotEmpty(funding.getDescription()))
        result.setDescription(Text.valueOf(funding.getDescription()));
    else
        result.setDescription(new Text());
    if (funding.getStartDate() != null)
        result.setStartDate(Date.valueOf(funding.getStartDate()));
    if (funding.getEndDate() != null)
        result.setEndDate(Date.valueOf(funding.getEndDate()));
    if (funding.getType() != null)
        result.setFundingType(Text.valueOf(funding.getType().value()));
    else
        result.setFundingType(new Text());
    if (funding.getOrganizationDefinedType() != null) {
        OrgDefinedFundingSubType OrgDefinedFundingSubType = new OrgDefinedFundingSubType();
        OrgDefinedFundingSubType.setSubtype(Text.valueOf(funding.getOrganizationDefinedType().getContent()));
        OrgDefinedFundingSubType.setAlreadyIndexed(false);
        result.setOrganizationDefinedFundingSubType(OrgDefinedFundingSubType);
    }
    Source source = funding.getSource();
    if (source != null) {
        result.setSource(source.retrieveSourcePath());
        if (source.getSourceName() != null) {
            result.setSourceName(source.getSourceName().getContent());
        }
    }
    if (funding.getTitle() != null) {
        FundingTitleForm fundingTitle = new FundingTitleForm();
        if (funding.getTitle().getTitle() != null)
            fundingTitle.setTitle(Text.valueOf(funding.getTitle().getTitle().getContent()));
        else
            fundingTitle.setTitle(new Text());
        if (funding.getTitle().getTranslatedTitle() != null) {
            TranslatedTitleForm translatedTitle = new TranslatedTitleForm();
            translatedTitle.setContent(funding.getTitle().getTranslatedTitle().getContent());
            translatedTitle.setLanguageCode(funding.getTitle().getTranslatedTitle().getLanguageCode());
            fundingTitle.setTranslatedTitle(translatedTitle);
        }
        result.setFundingTitle(fundingTitle);
    } else {
        FundingTitleForm fundingTitle = new FundingTitleForm();
        fundingTitle.setTitle(new Text());
        result.setFundingTitle(fundingTitle);
    }
    if (funding.getUrl() != null)
        result.setUrl(Text.valueOf(funding.getUrl().getValue()));
    else
        result.setUrl(new Text());
    if (funding.getVisibility() != null)
        result.setVisibility(Visibility.valueOf(funding.getVisibility()));
    // Set the disambiguated organization
    Organization organization = funding.getOrganization();
    result.setFundingName(Text.valueOf(organization.getName()));
    DisambiguatedOrganization disambiguatedOrganization = organization.getDisambiguatedOrganization();
    if (disambiguatedOrganization != null) {
        if (StringUtils.isNotEmpty(disambiguatedOrganization.getDisambiguatedOrganizationIdentifier())) {
            result.setDisambiguatedFundingSourceId(Text.valueOf(disambiguatedOrganization.getDisambiguatedOrganizationIdentifier()));
            result.setDisambiguationSource(Text.valueOf(disambiguatedOrganization.getDisambiguationSource()));
        }
    }
    OrganizationAddress organizationAddress = organization.getAddress();
    if (organizationAddress != null) {
        if (!PojoUtil.isEmpty(organizationAddress.getCity()))
            result.setCity(Text.valueOf(organizationAddress.getCity()));
        else
            result.setCity(new Text());
        if (!PojoUtil.isEmpty(organizationAddress.getRegion()))
            result.setRegion(Text.valueOf(organizationAddress.getRegion()));
        else
            result.setRegion(new Text());
        if (organizationAddress.getCountry() != null)
            result.setCountry(Text.valueOf(organizationAddress.getCountry().value()));
        else
            result.setCountry(new Text());
    } else {
        result.setCountry(new Text());
        result.setCity(new Text());
        result.setRegion(new Text());
    }
    // Set contributors
    if (funding.getContributors() != null) {
        List<Contributor> contributors = new ArrayList<Contributor>();
        for (FundingContributor fContributor : funding.getContributors().getContributor()) {
            Contributor contributor = Contributor.valueOf(fContributor);
            contributors.add(contributor);
        }
        result.setContributors(contributors);
    }
    List<FundingExternalIdentifierForm> externalIdentifiersList = new ArrayList<FundingExternalIdentifierForm>();
    // Set external identifiers
    if (funding.getExternalIdentifiers() != null) {
        for (ExternalID fExternalIdentifier : funding.getExternalIdentifiers().getExternalIdentifier()) {
            FundingExternalIdentifierForm fundingExternalIdentifierForm = FundingExternalIdentifierForm.valueOf(fExternalIdentifier);
            externalIdentifiersList.add(fundingExternalIdentifierForm);
        }
    }
    result.setExternalIdentifiers(externalIdentifiersList);
    result.setCreatedDate(Date.valueOf(funding.getCreatedDate()));
    result.setLastModified(Date.valueOf(funding.getLastModifiedDate()));
    return result;
}
Also used : Organization(org.orcid.jaxb.model.v3.dev1.common.Organization) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) OrganizationAddress(org.orcid.jaxb.model.v3.dev1.common.OrganizationAddress) FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) ArrayList(java.util.ArrayList) FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor) Source(org.orcid.jaxb.model.v3.dev1.common.Source) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization)

Example 9 with TranslatedTitle

use of org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle in project ORCID-Source by ORCID.

the class TranslatedTitleForm method toTranslatedTitle.

public TranslatedTitle toTranslatedTitle() {
    TranslatedTitle result = new TranslatedTitle();
    result.setContent(StringUtils.isEmpty(content) ? null : content);
    result.setLanguageCode(StringUtils.isEmpty(languageCode) ? null : languageCode);
    return result;
}
Also used : TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle)

Example 10 with TranslatedTitle

use of org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_ActivitiesSummaryTest method testCleanEmptyFieldsOnActivities.

@Test
public void testCleanEmptyFieldsOnActivities() {
    LastModifiedDate lmd = new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(System.currentTimeMillis()));
    Works works = new Works();
    works.setLastModifiedDate(lmd);
    WorkGroup group = new WorkGroup();
    group.setLastModifiedDate(lmd);
    for (int i = 0; i < 5; i++) {
        WorkSummary summary = new WorkSummary();
        summary.setLastModifiedDate(lmd);
        WorkTitle title = new WorkTitle();
        title.setTitle(new Title("Work " + i));
        title.setTranslatedTitle(new TranslatedTitle("", ""));
        summary.setTitle(title);
        group.getWorkSummary().add(summary);
    }
    works.getWorkGroup().add(group);
    ActivitiesSummary as = new ActivitiesSummary();
    as.setWorks(works);
    ActivityUtils.cleanEmptyFields(as);
    assertNotNull(as);
    assertNotNull(as.getWorks());
    Utils.verifyLastModified(as.getWorks().getLastModifiedDate());
    assertNotNull(as.getWorks().getWorkGroup());
    assertEquals(1, as.getWorks().getWorkGroup().size());
    assertNotNull(as.getWorks().getWorkGroup().get(0).getWorkSummary());
    Utils.verifyLastModified(as.getWorks().getWorkGroup().get(0).getLastModifiedDate());
    assertEquals(5, as.getWorks().getWorkGroup().get(0).getWorkSummary().size());
    for (WorkSummary summary : as.getWorks().getWorkGroup().get(0).getWorkSummary()) {
        Utils.verifyLastModified(summary.getLastModifiedDate());
        assertNotNull(summary.getTitle());
        assertNotNull(summary.getTitle().getTitle());
        assertTrue(summary.getTitle().getTitle().getContent().startsWith("Work "));
        assertNull(summary.getTitle().getTranslatedTitle());
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Title(org.orcid.jaxb.model.v3.dev1.common.Title) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

TranslatedTitle (org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle)9 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)9 Title (org.orcid.jaxb.model.v3.dev1.common.Title)8 Work (org.orcid.jaxb.model.v3.dev1.record.Work)8 Subtitle (org.orcid.jaxb.model.v3.dev1.common.Subtitle)5 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)4 Test (org.junit.Test)3 ContributorOrcid (org.orcid.jaxb.model.v3.dev1.common.ContributorOrcid)3 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)3 FundingContributor (org.orcid.jaxb.model.v3.dev1.record.FundingContributor)3 FundingTitle (org.orcid.jaxb.model.v3.dev1.record.FundingTitle)3 WorkContributors (org.orcid.jaxb.model.v3.dev1.record.WorkContributors)3 MapperFactory (ma.glasnost.orika.MapperFactory)2 ConverterFactory (ma.glasnost.orika.converter.ConverterFactory)2 DefaultMapperFactory (ma.glasnost.orika.impl.DefaultMapperFactory)2 Amount (org.orcid.jaxb.model.v3.dev1.common.Amount)2 CreatedDate (org.orcid.jaxb.model.v3.dev1.common.CreatedDate)2 CreditName (org.orcid.jaxb.model.v3.dev1.common.CreditName)2 LastModifiedDate (org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate)2 Organization (org.orcid.jaxb.model.v3.dev1.common.Organization)2