use of org.orcid.persistence.jpa.entities.ProfileFundingEntity in project ORCID-Source by ORCID.
the class ProfileFundingManagerTest method testAddMultipleModifiesIndexingStatus.
@Test
public void testAddMultipleModifiesIndexingStatus() {
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
Funding f1 = getFunding("F1");
f1 = profileFundingManager.createFunding(claimedOrcid, f1, true);
Funding f2 = getFunding("F2");
f2 = profileFundingManager.createFunding(claimedOrcid, f2, true);
Funding f3 = getFunding("F3");
f3 = profileFundingManager.createFunding(claimedOrcid, f3, true);
ProfileFundingEntity entity1 = profileFundingDao.find(f1.getPutCode());
ProfileFundingEntity entity2 = profileFundingDao.find(f2.getPutCode());
ProfileFundingEntity entity3 = profileFundingDao.find(f3.getPutCode());
assertNotNull(entity1.getDisplayIndex());
assertNotNull(entity2.getDisplayIndex());
assertNotNull(entity3.getDisplayIndex());
assertEquals(Long.valueOf(0), entity3.getDisplayIndex());
//Rollback all changes
profileFundingDao.remove(entity1.getId());
profileFundingDao.remove(entity2.getId());
profileFundingDao.remove(entity3.getId());
}
use of org.orcid.persistence.jpa.entities.ProfileFundingEntity in project ORCID-Source by ORCID.
the class ProfileFundingManagerTest method displayIndexIsSetTo_1_FromUI.
@Test
public void displayIndexIsSetTo_1_FromUI() {
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
Funding f1 = getFunding("fromUI-1");
f1 = profileFundingManager.createFunding(claimedOrcid, f1, false);
ProfileFundingEntity f = profileFundingDao.find(f1.getPutCode());
assertNotNull(f);
assertEquals(Long.valueOf(1), f.getDisplayIndex());
}
use of org.orcid.persistence.jpa.entities.ProfileFundingEntity in project ORCID-Source by ORCID.
the class OrcidProfileManagerImpl method persistAddedFundings.
private void persistAddedFundings(String orcid, List<Funding> updatedFundingList) {
ProfileEntity profileEntity = profileDao.find(orcid);
for (Funding updatedFunding : updatedFundingList) {
ProfileFundingEntity profileFundingEntity = jaxb2JpaAdapter.getNewProfileFundingEntity(updatedFunding, profileEntity);
// Save the profile grant
profileFundingDao.addProfileFunding(profileFundingEntity);
}
orcidProfileCacheManager.remove(orcid);
}
use of org.orcid.persistence.jpa.entities.ProfileFundingEntity 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());
}
use of org.orcid.persistence.jpa.entities.ProfileFundingEntity in project ORCID-Source by ORCID.
the class JpaJaxbFundingAdapterTest method fromFundingEntityToSummaryTest.
@Test
public void fromFundingEntityToSummaryTest() throws JAXBException {
ProfileFundingEntity entity = getProfileFundingEntity();
assertNotNull(entity);
assertEquals("123456", entity.getNumericAmount().toString());
FundingSummary summary = jpaJaxbFundingAdapter.toFundingSummary(entity);
assertNotNull(summary);
assertEquals(Long.valueOf(12345), summary.getPutCode());
assertNotNull(summary.getStartDate());
assertEquals("01", summary.getStartDate().getDay().getValue());
assertEquals("01", summary.getStartDate().getMonth().getValue());
assertEquals("2000", summary.getStartDate().getYear().getValue());
assertNotNull(summary.getEndDate());
assertEquals("01", summary.getEndDate().getDay().getValue());
assertEquals("01", summary.getEndDate().getMonth().getValue());
assertEquals("2020", summary.getEndDate().getYear().getValue());
assertEquals("funding:title", summary.getTitle().getTitle().getContent());
assertEquals(FundingType.SALARY_AWARD, summary.getType());
assertEquals(Visibility.PRIVATE, summary.getVisibility());
}
Aggregations