Search in sources :

Example 46 with Funding

use of org.orcid.jaxb.model.record_rc1.Funding in project ORCID-Source by ORCID.

the class BlackBoxBaseV2_1Release method unmarshallFromPath.

public Object unmarshallFromPath(String path, Class<?> type) {
    try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
        Object obj = unmarshall(reader, type);
        Object result = null;
        if (Address.class.equals(type)) {
            result = (Address) obj;
        } else if (Education.class.equals(type)) {
            result = (Education) obj;
        } else if (Employment.class.equals(type)) {
            result = (Employment) obj;
        } else if (Funding.class.equals(type)) {
            result = (Funding) obj;
        } else if (Keyword.class.equals(type)) {
            result = (Keyword) obj;
        } else if (Work.class.equals(type)) {
            result = (Work) obj;
        } else if (PeerReview.class.equals(type)) {
            result = (PeerReview) obj;
        } else if (ResearcherUrl.class.equals(type)) {
            result = (ResearcherUrl) obj;
        } else if (PersonalDetails.class.equals(type)) {
            result = (PersonalDetails) obj;
        } else if (OtherName.class.equals(type)) {
            result = (OtherName) obj;
        } else if (PersonExternalIdentifier.class.equals(type)) {
            result = (PersonExternalIdentifier) obj;
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error reading notification from classpath", e);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) Education(org.orcid.jaxb.model.record_v2.Education) Funding(org.orcid.jaxb.model.record_v2.Funding) Work(org.orcid.jaxb.model.record_v2.Work) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) IOException(java.io.IOException)

Example 47 with Funding

use of org.orcid.jaxb.model.record_rc1.Funding in project ORCID-Source by ORCID.

the class ValidateV2RC4Identifiers method testFunding.

@Test
public void testFunding() throws SAXException, IOException, JAXBException, ParserConfigurationException {
    Funding funding = unmarshallFromPath("/record_2.0_rc4/samples/funding-2.0_rc4.xml", Funding.class);
    assertEquals("funding:organization-defined-type", funding.getOrganizationDefinedType().getContent());
    assertNotNull(funding.getExternalIdentifiers());
    assertNotNull(funding.getExternalIdentifiers().getExternalIdentifier());
    Assert.notEmpty(funding.getExternalIdentifiers().getExternalIdentifier());
    assertEquals("grant_number", funding.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
    assertEquals("funding:external-identifier-value", funding.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals(new Url("http://tempuri.org"), funding.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl());
    assertEquals(Relationship.SELF, funding.getExternalIdentifiers().getExternalIdentifier().get(0).getRelationship());
    Validator validator = getValidator("funding");
    validator.validate(marshall(Funding.class, funding));
    validator.validate(marshallToDOM(Funding.class, funding));
}
Also used : Funding(org.orcid.jaxb.model.record_rc4.Funding) Url(org.orcid.jaxb.model.common_rc4.Url) Validator(javax.xml.validation.Validator) MarshallingTest(org.orcid.jaxb.model.notification.custom.MarshallingTest) Test(org.junit.Test)

Example 48 with Funding

use of org.orcid.jaxb.model.record_rc1.Funding in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorTest method testViewFunding.

@Test
public void testViewFunding() {
    Response response = serviceDelegator.viewFunding(ORCID, 10L);
    assertNotNull(response);
    Funding funding = (Funding) response.getEntity();
    assertNotNull(funding);
    assertNotNull(funding.getLastModifiedDate());
    assertNotNull(funding.getLastModifiedDate().getValue());
    assertNotNull(funding.getTitle());
    assertNotNull(funding.getTitle().getTitle());
    assertEquals(Long.valueOf(10), funding.getPutCode());
    assertEquals("/0000-0000-0000-0003/funding/10", funding.getPath());
    assertEquals("PUBLIC", funding.getTitle().getTitle().getContent());
    assertEquals(Visibility.PUBLIC.value(), funding.getVisibility().value());
    assertEquals("APP-5555555555555555", funding.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) Funding(org.orcid.jaxb.model.record_v2.Funding) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 49 with Funding

use of org.orcid.jaxb.model.record_rc1.Funding in project ORCID-Source by ORCID.

the class MapperFacadeFactory method getFundingMapperFacade.

public MapperFacade getFundingMapperFacade() {
    MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
    ConverterFactory converterFactory = mapperFactory.getConverterFactory();
    converterFactory.registerConverter("fundingExternalIdentifiersConverterId", new FundingExternalIDsConverter());
    converterFactory.registerConverter("fundingContributorsConverterId", new JsonOrikaConverter<FundingContributors>());
    ClassMapBuilder<Funding, ProfileFundingEntity> fundingClassMap = mapperFactory.classMap(Funding.class, ProfileFundingEntity.class);
    addV2CommonFields(fundingClassMap);
    registerSourceConverters(mapperFactory, fundingClassMap);
    fundingClassMap.field("type", "type");
    fundingClassMap.field("organizationDefinedType.content", "organizationDefinedType");
    fundingClassMap.field("title.title.content", "title");
    fundingClassMap.field("title.translatedTitle.content", "translatedTitle");
    fundingClassMap.field("title.translatedTitle.languageCode", "translatedTitleLanguageCode");
    fundingClassMap.field("description", "description");
    fundingClassMap.field("amount.content", "numericAmount");
    fundingClassMap.field("amount.currencyCode", "currencyCode");
    fundingClassMap.field("url.value", "url");
    fundingClassMap.fieldBToA("org.name", "organization.name");
    fundingClassMap.fieldBToA("org.city", "organization.address.city");
    fundingClassMap.fieldBToA("org.region", "organization.address.region");
    fundingClassMap.fieldBToA("org.country", "organization.address.country");
    fundingClassMap.fieldBToA("org.orgDisambiguated.sourceId", "organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier");
    fundingClassMap.fieldBToA("org.orgDisambiguated.sourceType", "organization.disambiguatedOrganization.disambiguationSource");
    fundingClassMap.fieldBToA("org.orgDisambiguated.id", "organization.disambiguatedOrganization.id");
    fundingClassMap.fieldMap("externalIdentifiers", "externalIdentifiersJson").converter("fundingExternalIdentifiersConverterId").add();
    fundingClassMap.fieldMap("contributors", "contributorsJson").converter("fundingContributorsConverterId").add();
    fundingClassMap.register();
    ClassMapBuilder<FundingSummary, ProfileFundingEntity> fundingSummaryClassMap = mapperFactory.classMap(FundingSummary.class, ProfileFundingEntity.class);
    addV2CommonFields(fundingSummaryClassMap);
    registerSourceConverters(mapperFactory, fundingSummaryClassMap);
    fundingSummaryClassMap.field("type", "type");
    fundingSummaryClassMap.field("title.title.content", "title");
    fundingSummaryClassMap.field("title.translatedTitle.content", "translatedTitle");
    fundingSummaryClassMap.field("title.translatedTitle.languageCode", "translatedTitleLanguageCode");
    fundingSummaryClassMap.fieldMap("externalIdentifiers", "externalIdentifiersJson").converter("fundingExternalIdentifiersConverterId").add();
    fundingSummaryClassMap.fieldBToA("org.name", "organization.name");
    fundingSummaryClassMap.fieldBToA("org.city", "organization.address.city");
    fundingSummaryClassMap.fieldBToA("org.region", "organization.address.region");
    fundingSummaryClassMap.fieldBToA("org.country", "organization.address.country");
    fundingSummaryClassMap.fieldBToA("org.orgDisambiguated.sourceId", "organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier");
    fundingSummaryClassMap.fieldBToA("org.orgDisambiguated.sourceType", "organization.disambiguatedOrganization.disambiguationSource");
    fundingSummaryClassMap.fieldBToA("org.orgDisambiguated.id", "organization.disambiguatedOrganization.id");
    fundingSummaryClassMap.register();
    mapperFactory.classMap(FuzzyDate.class, StartDateEntity.class).field("year.value", "year").field("month.value", "month").field("day.value", "day").register();
    mapperFactory.classMap(FuzzyDate.class, EndDateEntity.class).field("year.value", "year").field("month.value", "month").field("day.value", "day").register();
    return mapperFactory.getMapperFacade();
}
Also used : Funding(org.orcid.jaxb.model.record_v2.Funding) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) FundingContributors(org.orcid.jaxb.model.record_v2.FundingContributors) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) ConverterFactory(ma.glasnost.orika.converter.ConverterFactory) FundingExternalIDsConverter(org.orcid.core.adapter.impl.jsonidentifiers.FundingExternalIDsConverter) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity)

Example 50 with Funding

use of org.orcid.jaxb.model.record_rc1.Funding in project ORCID-Source by ORCID.

the class ActivityCacheManagerImpl method fundingMap.

@Cacheable(value = "pub-funding-maps", key = "#orcid.concat('-').concat(#lastModified)")
public LinkedHashMap<Long, Funding> fundingMap(String orcid, long lastModified) {
    List<Funding> fundings = profileFundingManager.getFundingList(orcid, lastModified);
    LinkedHashMap<Long, Funding> fundingMap = new LinkedHashMap<>();
    if (fundings != null) {
        for (Funding funding : fundings) {
            if (funding.getVisibility().equals(Visibility.PUBLIC))
                fundingMap.put(Long.valueOf(funding.getPutCode()), funding);
        }
    }
    return fundingMap;
}
Also used : Funding(org.orcid.jaxb.model.record_v2.Funding) LinkedHashMap(java.util.LinkedHashMap) Cacheable(org.springframework.cache.annotation.Cacheable)

Aggregations

Funding (org.orcid.jaxb.model.record_v2.Funding)82 Test (org.junit.Test)70 ClientResponse (com.sun.jersey.api.client.ClientResponse)28 ArrayList (java.util.ArrayList)17 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)16 Response (javax.ws.rs.core.Response)15 Url (org.orcid.jaxb.model.common_v2.Url)15 DBUnitTest (org.orcid.test.DBUnitTest)15 Title (org.orcid.jaxb.model.common_v2.Title)11 Work (org.orcid.jaxb.model.record_v2.Work)10 List (java.util.List)9 FundingTitle (org.orcid.jaxb.model.record_v2.FundingTitle)9 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)9 IOException (java.io.IOException)8 Funding (org.orcid.jaxb.model.record_rc1.Funding)8 Education (org.orcid.jaxb.model.record_v2.Education)8 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)8 WorkTitle (org.orcid.jaxb.model.record_v2.WorkTitle)8 InputStreamReader (java.io.InputStreamReader)7 Reader (java.io.Reader)7