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;
}
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();
}
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);
}
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;
}
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;
}
Aggregations