Search in sources :

Example 1 with FundingGroup

use of org.orcid.jaxb.model.record.summary_rc4.FundingGroup in project ORCID-Source by ORCID.

the class SolrMessageProcessor method updateSolrIndex.

private void updateSolrIndex(String orcid) {
    LOG.info("Updating using Record " + orcid + " in SOLR index");
    if (!isSolrIndexingEnabled) {
        LOG.info("Solr indexing is disabled");
        return;
    }
    try {
        org.orcid.jaxb.model.record_v2.Record record = orcid20ApiClient.fetchPublicProfile(orcid);
        //get detailed funding so we can discover org name and id
        List<Funding> fundings = new ArrayList<Funding>();
        if (record.getActivitiesSummary() != null && record.getActivitiesSummary().getFundings() != null && record.getActivitiesSummary().getFundings().getFundingGroup() != null) {
            for (FundingGroup group : record.getActivitiesSummary().getFundings().getFundingGroup()) {
                if (group.getFundingSummary() != null) {
                    for (FundingSummary f : group.getFundingSummary()) {
                        fundings.add(orcid20ApiClient.fetchFunding(record.getOrcidIdentifier().getPath(), f.getPutCode()));
                    }
                }
            }
        }
        solrUpdater.persist(recordConv.convert(record, fundings));
        recordStatusManager.markAsSent(orcid, AvailableBroker.SOLR);
    } catch (LockedRecordException lre) {
        LOG.error("Record " + orcid + " is locked");
        solrUpdater.updateSolrIndexForLockedOrDeprecatedRecord(orcid, solrUpdater.retrieveLastModified(orcid));
        recordStatusManager.markAsSent(orcid, AvailableBroker.SOLR);
    } catch (DeprecatedRecordException dre) {
        LOG.error("Record " + orcid + " is deprecated");
        solrUpdater.updateSolrIndexForLockedOrDeprecatedRecord(orcid, solrUpdater.retrieveLastModified(orcid));
        recordStatusManager.markAsSent(orcid, AvailableBroker.SOLR);
    } catch (Exception e) {
        LOG.error("Unable to fetch record " + orcid + " for SOLR");
        LOG.error(e.getMessage(), e);
        recordStatusManager.markAsFailed(orcid, AvailableBroker.SOLR);
    }
}
Also used : LockedRecordException(org.orcid.listener.exception.LockedRecordException) Funding(org.orcid.jaxb.model.record_v2.Funding) DeprecatedRecordException(org.orcid.listener.exception.DeprecatedRecordException) ArrayList(java.util.ArrayList) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) FundingGroup(org.orcid.jaxb.model.record.summary_v2.FundingGroup) LockedRecordException(org.orcid.listener.exception.LockedRecordException) DeprecatedRecordException(org.orcid.listener.exception.DeprecatedRecordException) JAXBException(javax.xml.bind.JAXBException)

Example 2 with FundingGroup

use of org.orcid.jaxb.model.record.summary_rc4.FundingGroup in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_FundingTest method testViewFundings.

@Test
public void testViewFundings() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewFundings(ORCID);
    assertNotNull(r);
    Fundings fundings = (Fundings) r.getEntity();
    assertNotNull(fundings);
    assertEquals("/0000-0000-0000-0003/fundings", fundings.getPath());
    assertNotNull(fundings.getPath());
    Utils.verifyLastModified(fundings.getLastModifiedDate());
    assertNotNull(fundings.getFundingGroup());
    assertEquals(4, fundings.getFundingGroup().size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false;
    for (FundingGroup fundingGroup : fundings.getFundingGroup()) {
        Utils.verifyLastModified(fundingGroup.getLastModifiedDate());
        assertNotNull(fundingGroup.getIdentifiers());
        assertNotNull(fundingGroup.getIdentifiers().getExternalIdentifier());
        assertEquals(1, fundingGroup.getIdentifiers().getExternalIdentifier().size());
        assertNotNull(fundingGroup.getFundingSummary());
        assertEquals(1, fundingGroup.getFundingSummary().size());
        FundingSummary summary = fundingGroup.getFundingSummary().get(0);
        Utils.verifyLastModified(summary.getLastModifiedDate());
        assertNotNull(summary.getTitle());
        assertNotNull(summary.getTitle().getTitle());
        switch(fundingGroup.getIdentifiers().getExternalIdentifier().get(0).getValue()) {
            case "1":
                assertEquals("PUBLIC", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(10), summary.getPutCode());
                found1 = true;
                break;
            case "2":
                assertEquals("LIMITED", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(11), summary.getPutCode());
                found2 = true;
                break;
            case "3":
                assertEquals("PRIVATE", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(12), summary.getPutCode());
                found3 = true;
                break;
            case "4":
                assertEquals("SELF LIMITED", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(13), summary.getPutCode());
                found4 = true;
                break;
            default:
                fail("Invalid external id found: " + fundingGroup.getIdentifiers().getExternalIdentifier().get(0).getValue());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
}
Also used : Response(javax.ws.rs.core.Response) Fundings(org.orcid.jaxb.model.record.summary_v2.Fundings) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) FundingGroup(org.orcid.jaxb.model.record.summary_v2.FundingGroup) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 3 with FundingGroup

use of org.orcid.jaxb.model.record.summary_rc4.FundingGroup in project ORCID-Source by ORCID.

the class OrcidSecurityManagerImpl method checkAndFilter.

@Override
public void checkAndFilter(String orcid, ActivitiesSummary activities) {
    if (activities == null) {
        return;
    }
    // Check the token
    isMyToken(orcid);
    // Educations
    if (activities.getEducations() != null) {
        checkAndFilter(orcid, activities.getEducations().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Employments
    if (activities.getEmployments() != null) {
        checkAndFilter(orcid, activities.getEmployments().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Funding
    if (activities.getFundings() != null) {
        Iterator<FundingGroup> groupIt = activities.getFundings().getFundingGroup().iterator();
        while (groupIt.hasNext()) {
            FundingGroup group = groupIt.next();
            // Filter the list of elements
            checkAndFilter(orcid, group.getFundingSummary(), READ_FUNDING_REQUIRED_SCOPE, true);
            // Clean external identifiers
            if (group.getFundingSummary().isEmpty()) {
                groupIt.remove();
            } else {
                filterExternalIdentifiers(group);
            }
        }
    }
    // PeerReviews
    if (activities.getPeerReviews() != null) {
        Iterator<PeerReviewGroup> groupIt = activities.getPeerReviews().getPeerReviewGroup().iterator();
        while (groupIt.hasNext()) {
            PeerReviewGroup group = groupIt.next();
            // Filter the list of elements
            checkAndFilter(orcid, group.getPeerReviewSummary(), READ_PEER_REVIEWS_REQUIRED_SCOPE, true);
            if (group.getPeerReviewSummary().isEmpty()) {
                groupIt.remove();
            }
        }
    }
    // Works
    if (activities.getWorks() != null) {
        Iterator<WorkGroup> groupIt = activities.getWorks().getWorkGroup().iterator();
        while (groupIt.hasNext()) {
            WorkGroup group = groupIt.next();
            // Filter the list of elements
            checkAndFilter(orcid, group.getWorkSummary(), READ_WORKS_REQUIRED_SCOPE, true);
            // Clean external identifiers
            if (group.getWorkSummary().isEmpty()) {
                groupIt.remove();
            } else {
                filterExternalIdentifiers(group);
            }
        }
    }
}
Also used : PeerReviewGroup(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) FundingGroup(org.orcid.jaxb.model.record.summary_v2.FundingGroup)

Example 4 with FundingGroup

use of org.orcid.jaxb.model.record.summary_rc4.FundingGroup in project ORCID-Source by ORCID.

the class PublicV2Test method cleanActivities.

public void cleanActivities() throws JSONException, InterruptedException, URISyntaxException {
    // Remove all activities
    String token = getAccessToken();
    ClientResponse activitiesResponse = memberV2ApiClient.viewActivities(getUser1OrcidId(), token);
    assertNotNull(activitiesResponse);
    ActivitiesSummary summary = activitiesResponse.getEntity(ActivitiesSummary.class);
    assertNotNull(summary);
    if (summary.getEducations() != null && !summary.getEducations().getSummaries().isEmpty()) {
        for (EducationSummary education : summary.getEducations().getSummaries()) {
            memberV2ApiClient.deleteEducationXml(getUser1OrcidId(), education.getPutCode(), token);
        }
    }
    if (summary.getEmployments() != null && !summary.getEmployments().getSummaries().isEmpty()) {
        for (EmploymentSummary employment : summary.getEmployments().getSummaries()) {
            memberV2ApiClient.deleteEmploymentXml(getUser1OrcidId(), employment.getPutCode(), token);
        }
    }
    if (summary.getFundings() != null && !summary.getFundings().getFundingGroup().isEmpty()) {
        for (FundingGroup group : summary.getFundings().getFundingGroup()) {
            for (FundingSummary funding : group.getFundingSummary()) {
                memberV2ApiClient.deleteFundingXml(getUser1OrcidId(), funding.getPutCode(), token);
            }
        }
    }
    if (summary.getWorks() != null && !summary.getWorks().getWorkGroup().isEmpty()) {
        for (WorkGroup group : summary.getWorks().getWorkGroup()) {
            for (WorkSummary work : group.getWorkSummary()) {
                memberV2ApiClient.deleteWorkXml(getUser1OrcidId(), work.getPutCode(), token);
            }
        }
    }
    if (summary.getPeerReviews() != null && !summary.getPeerReviews().getPeerReviewGroup().isEmpty()) {
        for (PeerReviewGroup group : summary.getPeerReviews().getPeerReviewGroup()) {
            for (PeerReviewSummary peerReview : group.getPeerReviewSummary()) {
                memberV2ApiClient.deletePeerReviewXml(getUser1OrcidId(), peerReview.getPutCode(), token);
            }
        }
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) WorkGroup(org.orcid.jaxb.model.record.summary_rc1.WorkGroup) PeerReviewGroup(org.orcid.jaxb.model.record.summary_rc1.PeerReviewGroup) WorkSummary(org.orcid.jaxb.model.record.summary_rc1.WorkSummary) EducationSummary(org.orcid.jaxb.model.record.summary_rc1.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.record.summary_rc1.PeerReviewSummary) FundingSummary(org.orcid.jaxb.model.record.summary_rc1.FundingSummary) EmploymentSummary(org.orcid.jaxb.model.record.summary_rc1.EmploymentSummary) FundingGroup(org.orcid.jaxb.model.record.summary_rc1.FundingGroup) ActivitiesSummary(org.orcid.jaxb.model.record.summary_rc1.ActivitiesSummary)

Example 5 with FundingGroup

use of org.orcid.jaxb.model.record.summary_rc4.FundingGroup in project ORCID-Source by ORCID.

the class PublicV2Test method checkPublicActivities.

public void checkPublicActivities(String readPublicToken) throws JSONException, InterruptedException, URISyntaxException {
    createActivities();
    ClientResponse activitiesResponse = null;
    if (readPublicToken != null) {
        activitiesResponse = publicV2ApiClient.viewActivities(getUser1OrcidId(), readPublicToken);
    } else {
        activitiesResponse = publicV2ApiClient.viewActivities(getUser1OrcidId());
    }
    assertNotNull(activitiesResponse);
    ActivitiesSummary summary = activitiesResponse.getEntity(ActivitiesSummary.class);
    assertNotNull(summary);
    assertNotNull("There are no educations, please verify users default visibility is public", summary.getEducations());
    assertFalse(summary.getEducations().getSummaries().isEmpty());
    boolean found0 = false, found3 = false;
    for (EducationSummary education : summary.getEducations().getSummaries()) {
        if (education.getDepartmentName() != null) {
            if (education.getDepartmentName().equals("Education # 0")) {
                found0 = true;
            } else if (education.getDepartmentName().equals("Education # 3")) {
                found3 = true;
            }
        }
    }
    assertTrue("One of the educations was not found: 0(" + found0 + ") 3(" + found3 + "), please verify users default visibility is public", found0 == found3 == true);
    assertNotNull("There are no employment, please verify users default visibility is public", summary.getEmployments());
    assertFalse(summary.getEmployments().getSummaries().isEmpty());
    found0 = found3 = false;
    for (EmploymentSummary employment : summary.getEmployments().getSummaries()) {
        if (employment.getDepartmentName() != null) {
            if (employment.getDepartmentName().equals("Employment # 0")) {
                found0 = true;
            } else if (employment.getDepartmentName().equals("Employment # 3")) {
                found3 = true;
            }
        }
    }
    assertTrue("One of the employments was not found: 0(" + found0 + ") 3(" + found3 + "), please verify users default visibility is public", found0 == found3 == true);
    assertNotNull(summary.getFundings());
    found0 = found3 = false;
    for (FundingGroup group : summary.getFundings().getFundingGroup()) {
        for (FundingSummary funding : group.getFundingSummary()) {
            if (funding.getTitle() != null && funding.getTitle().getTitle() != null) {
                if (funding.getTitle().getTitle().getContent().equals("Funding # 0")) {
                    found0 = true;
                } else if (funding.getTitle().getTitle().getContent().equals("Funding # 3")) {
                    found3 = true;
                }
            }
        }
    }
    assertTrue("One of the fundings was not found: 0(" + found0 + ") 3(" + found3 + "), please verify users default visibility is public", found0 == found3 == true);
    assertNotNull(summary.getWorks());
    found0 = found3 = false;
    for (WorkGroup group : summary.getWorks().getWorkGroup()) {
        for (WorkSummary work : group.getWorkSummary()) {
            if (work.getTitle().getTitle().getContent().equals("Work # 0")) {
                found0 = true;
            } else if (work.getTitle().getTitle().getContent().equals("Work # 3")) {
                found3 = true;
            }
        }
    }
    assertTrue("One of the works was not found: 0(" + found0 + ") 3(" + found3 + "), please verify users default visibility is public", found0 == found3 == true);
    assertNotNull(summary.getPeerReviews());
    found0 = found3 = false;
    for (PeerReviewGroup group : summary.getPeerReviews().getPeerReviewGroup()) {
        for (PeerReviewSummary peerReview : group.getPeerReviewSummary()) {
            if (peerReview.getCompletionDate() != null && peerReview.getCompletionDate().getYear() != null) {
                if (peerReview.getCompletionDate().getYear().getValue().equals("1000")) {
                    found0 = true;
                } else if (peerReview.getCompletionDate().getYear().getValue().equals("4000")) {
                    found3 = true;
                }
            }
        }
    }
    assertTrue("One of the peer reviews was not found: 0(" + found0 + ") 3(" + found3 + "), please verify users default visibility is public", found0 == found3 == true);
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) WorkGroup(org.orcid.jaxb.model.record.summary_rc1.WorkGroup) PeerReviewGroup(org.orcid.jaxb.model.record.summary_rc1.PeerReviewGroup) WorkSummary(org.orcid.jaxb.model.record.summary_rc1.WorkSummary) EducationSummary(org.orcid.jaxb.model.record.summary_rc1.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.record.summary_rc1.PeerReviewSummary) FundingSummary(org.orcid.jaxb.model.record.summary_rc1.FundingSummary) EmploymentSummary(org.orcid.jaxb.model.record.summary_rc1.EmploymentSummary) FundingGroup(org.orcid.jaxb.model.record.summary_rc1.FundingGroup) ActivitiesSummary(org.orcid.jaxb.model.record.summary_rc1.ActivitiesSummary)

Aggregations

Test (org.junit.Test)22 FundingGroup (org.orcid.jaxb.model.record.summary_v2.FundingGroup)22 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)20 ClientResponse (com.sun.jersey.api.client.ClientResponse)19 PeerReviewGroup (org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup)13 WorkGroup (org.orcid.jaxb.model.record.summary_v2.WorkGroup)13 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)12 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)12 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)12 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)12 Fundings (org.orcid.jaxb.model.record.summary_v2.Fundings)10 ArrayList (java.util.ArrayList)8 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)7 Response (javax.ws.rs.core.Response)5 Educations (org.orcid.jaxb.model.record.summary_v2.Educations)5 Employments (org.orcid.jaxb.model.record.summary_v2.Employments)5 PeerReviews (org.orcid.jaxb.model.record.summary_v2.PeerReviews)5 Works (org.orcid.jaxb.model.record.summary_v2.Works)5 Address (org.orcid.jaxb.model.record_v2.Address)5 Email (org.orcid.jaxb.model.record_v2.Email)5