Search in sources :

Example 11 with ProfileFundingEntity

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());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Funding(org.orcid.jaxb.model.record_v2.Funding) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 12 with ProfileFundingEntity

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());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Funding(org.orcid.jaxb.model.record_v2.Funding) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 13 with ProfileFundingEntity

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);
}
Also used : Funding(org.orcid.jaxb.model.message.Funding) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity)

Example 14 with ProfileFundingEntity

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());
}
Also used : Funding(org.orcid.jaxb.model.record_v2.Funding) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) Test(org.junit.Test)

Example 15 with ProfileFundingEntity

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());
}
Also used : FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) Test(org.junit.Test)

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