Search in sources :

Example 1 with ProfileFundingEntity

use of org.orcid.persistence.jpa.entities.ProfileFundingEntity in project ORCID-Source by ORCID.

the class ProfileFundingDaoImpl method updateProfileFunding.

/**
     * Edits a profileFunding
     * 
     * @param profileFunding
     *            The profileFunding to be edited
     * @return the updated profileFunding
     * */
@Override
@Transactional
public ProfileFundingEntity updateProfileFunding(ProfileFundingEntity profileFunding) {
    ProfileFundingEntity toUpdate = this.find(profileFunding.getId());
    mergeProfileFunding(toUpdate, profileFunding);
    toUpdate = this.merge(toUpdate);
    return toUpdate;
}
Also used : ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with ProfileFundingEntity

use of org.orcid.persistence.jpa.entities.ProfileFundingEntity 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 3 with ProfileFundingEntity

use of org.orcid.persistence.jpa.entities.ProfileFundingEntity in project ORCID-Source by ORCID.

the class OrcidProfileManagerImplTest method addNewFundingModifyExistingWorksDisplayIndex.

@Test
@Transactional
@Rollback(true)
public void addNewFundingModifyExistingWorksDisplayIndex() {
    OrcidProfile profile1 = createBasicProfile();
    String orcidIdentifier = null;
    profile1.setOrcidIdentifier(orcidIdentifier);
    setBio(profile1, Visibility.PUBLIC);
    profile1 = orcidProfileManager.createOrcidProfile(profile1, true, false);
    assertNotNull(profile1);
    assertNotNull(profile1.getOrcidIdentifier());
    String orcidId = profile1.getOrcidIdentifier().getPath();
    OrcidProfile profile = getFundingInsideOrcidProfile("f1", orcidId);
    orcidProfileManager.addFundings(profile);
    profile = getFundingInsideOrcidProfile("f2", orcidId);
    orcidProfileManager.addFundings(profile);
    profile = getFundingInsideOrcidProfile("f3", orcidId);
    orcidProfileManager.addFundings(profile);
    profile = getFundingInsideOrcidProfile("f4", orcidId);
    orcidProfileManager.addFundings(profile);
    List<ProfileFundingEntity> all = profileFundingDao.getByUser(orcidId);
    assertNotNull(all);
    Long displayIndex1 = null;
    Long displayIndex2 = null;
    Long displayIndex3 = null;
    for (ProfileFundingEntity entity : all) {
        Long displayIndex = entity.getDisplayIndex();
        if ("f1".equals(entity.getTitle())) {
            displayIndex1 = displayIndex;
        } else if ("f2".equals(entity.getTitle())) {
            displayIndex2 = displayIndex;
        } else if ("f3".equals(entity.getTitle())) {
            displayIndex3 = displayIndex;
        }
    }
    assertNotNull(displayIndex1);
    assertNotNull(displayIndex2);
    assertNotNull(displayIndex3);
    assertEquals(Long.valueOf(0L), displayIndex3);
//TODO: Might need to be readed in a later release
//assertTrue(displayIndex3 < displayIndex2);
//assertTrue(displayIndex2 < displayIndex1);
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with ProfileFundingEntity

use of org.orcid.persistence.jpa.entities.ProfileFundingEntity in project ORCID-Source by ORCID.

the class Jaxb2JpaAdapterImpl method getUpdatedProfileFundingEntity.

/**
     * Transforms a OrcidGrant object into a ProfileFundingEntity object
     * 
     * @param updatedFunding
     * @param profileEntity
     * @return ProfileFundingEntity
     * */
@Override
public ProfileFundingEntity getUpdatedProfileFundingEntity(Funding updatedFunding) {
    ProfileFundingEntity existingProfileFundingEntity = profileFundingManager.getProfileFundingEntity(Long.valueOf(updatedFunding.getPutCode()));
    ProfileFundingEntity profileFundingEntity = getProfileFundingEntity(updatedFunding, existingProfileFundingEntity);
    return profileFundingEntity;
}
Also used : ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity)

Example 5 with ProfileFundingEntity

use of org.orcid.persistence.jpa.entities.ProfileFundingEntity in project ORCID-Source by ORCID.

the class Jaxb2JpaAdapterImpl method getNewProfileFundingEntity.

/**
     * Transforms a OrcidGrant object into a ProfileFundingEntity object
     * 
     * @param updatedFunding
     * @param profileEntity
     * @return ProfileFundingEntity
     * */
@Override
public ProfileFundingEntity getNewProfileFundingEntity(Funding updatedFunding, ProfileEntity profileEntity) {
    ProfileFundingEntity profileFundingEntity = getProfileFundingEntity(updatedFunding, null);
    profileFundingEntity.setProfile(profileEntity);
    return profileFundingEntity;
}
Also used : ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity)

Aggregations

ProfileFundingEntity (org.orcid.persistence.jpa.entities.ProfileFundingEntity)26 Test (org.junit.Test)9 Funding (org.orcid.jaxb.model.record_v2.Funding)8 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)5 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)5 Transactional (org.springframework.transaction.annotation.Transactional)5 OrgEntity (org.orcid.persistence.jpa.entities.OrgEntity)4 Query (javax.persistence.Query)3 TypedQuery (javax.persistence.TypedQuery)3 BaseTest (org.orcid.core.BaseTest)3 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)3 EmailEntity (org.orcid.persistence.jpa.entities.EmailEntity)3 ExternalIdentifierEntity (org.orcid.persistence.jpa.entities.ExternalIdentifierEntity)3 OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)3 OtherNameEntity (org.orcid.persistence.jpa.entities.OtherNameEntity)3 ProfileKeywordEntity (org.orcid.persistence.jpa.entities.ProfileKeywordEntity)3 ResearcherUrlEntity (org.orcid.persistence.jpa.entities.ResearcherUrlEntity)3 BigDecimal (java.math.BigDecimal)2 TreeSet (java.util.TreeSet)2 Funding (org.orcid.jaxb.model.message.Funding)2