Search in sources :

Example 26 with ActivitiesSummary

use of org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_WorksTest method testAddWork.

@Test
public void testAddWork() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4445", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewActivities("4444-4444-4444-4445");
    assertNotNull(response);
    ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
    assertNotNull(summary);
    Utils.verifyLastModified(summary.getLastModifiedDate());
    // Check works
    assertNotNull(summary.getWorks());
    assertNotNull(summary.getWorks().getWorkGroup());
    assertEquals(1, summary.getWorks().getWorkGroup().size());
    Utils.verifyLastModified(summary.getWorks().getLastModifiedDate());
    assertNotNull(summary.getWorks().getWorkGroup().get(0));
    Utils.verifyLastModified(summary.getWorks().getWorkGroup().get(0).getLastModifiedDate());
    assertNotNull(summary.getWorks().getWorkGroup().get(0).getWorkSummary());
    assertEquals(1, summary.getWorks().getWorkGroup().get(0).getWorkSummary().size());
    String title = "work # 1 " + System.currentTimeMillis();
    Work work = Utils.getWork(title);
    response = serviceDelegator.createWork("4444-4444-4444-4445", work);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    Long putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewActivities("4444-4444-4444-4445");
    assertNotNull(response);
    summary = (ActivitiesSummary) response.getEntity();
    assertNotNull(summary);
    Utils.verifyLastModified(summary.getLastModifiedDate());
    // Check works
    assertNotNull(summary.getWorks());
    assertNotNull(summary.getWorks().getWorkGroup());
    assertEquals(2, summary.getWorks().getWorkGroup().size());
    boolean haveOld = false;
    boolean haveNew = false;
    for (WorkGroup group : summary.getWorks().getWorkGroup()) {
        Utils.verifyLastModified(group.getLastModifiedDate());
        assertNotNull(group.getWorkSummary());
        assertNotNull(group.getWorkSummary().get(0));
        WorkSummary workSummary = group.getWorkSummary().get(0);
        Utils.verifyLastModified(workSummary.getLastModifiedDate());
        assertNotNull(workSummary.getTitle());
        assertNotNull(workSummary.getTitle().getTitle());
        if ("A Book With Contributors JSON".equals(workSummary.getTitle().getTitle().getContent())) {
            haveOld = true;
        } else if (title.equals(workSummary.getTitle().getTitle().getContent())) {
            haveNew = true;
        }
    }
    assertTrue(haveOld);
    assertTrue(haveNew);
    // Delete them
    serviceDelegator.deleteWork("4444-4444-4444-4445", putCode);
}
Also used : Response(javax.ws.rs.core.Response) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) Work(org.orcid.jaxb.model.record_v2.Work) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 27 with ActivitiesSummary

use of org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary in project ORCID-Source by ORCID.

the class BibtexManagerImpl method generateBibtexReferenceList.

@Override
public String generateBibtexReferenceList(String orcid) {
    long last = workManager.getLastModified(orcid);
    ActivitiesSummary summary = activitiesManager.getActivitiesSummary(orcid);
    List<String> citations = new ArrayList<String>();
    if (summary.getWorks() != null) {
        for (WorkGroup group : summary.getWorks().getWorkGroup()) {
            WorkSummary workSummary = group.getWorkSummary().get(0);
            Work work = workManager.getWork(orcid, workSummary.getPutCode(), last);
            String bibtex = generateBibtex(orcid, work);
            if (bibtex != null)
                citations.add(bibtex);
        }
    }
    return Joiner.on(",\n").join(citations);
}
Also used : WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) ArrayList(java.util.ArrayList) Work(org.orcid.jaxb.model.record_v2.Work) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)

Example 28 with ActivitiesSummary

use of org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary in project ORCID-Source by ORCID.

the class ActivitiesSummaryManagerReadOnlyImpl method getActivitiesSummary.

public ActivitiesSummary getActivitiesSummary(String orcid, boolean justPublic) {
    long lastModifiedTime = getLastModified(orcid);
    ActivitiesSummary activities = new ActivitiesSummary();
    // Set educations
    List<EducationSummary> educationsList = affiliationsManager.getEducationSummaryList(orcid, lastModifiedTime);
    Educations educations = new Educations();
    for (EducationSummary summary : educationsList) {
        if (justPublic) {
            if (Visibility.PUBLIC.equals(summary.getVisibility())) {
                educations.getSummaries().add(summary);
            }
        } else {
            educations.getSummaries().add(summary);
        }
    }
    activities.setEducations(educations);
    // Set employments
    List<EmploymentSummary> employmentList = affiliationsManager.getEmploymentSummaryList(orcid, lastModifiedTime);
    Employments employments = new Employments();
    for (EmploymentSummary summary : employmentList) {
        if (justPublic) {
            if (Visibility.PUBLIC.equals(summary.getVisibility())) {
                employments.getSummaries().add(summary);
            }
        } else {
            employments.getSummaries().add(summary);
        }
    }
    activities.setEmployments(employments);
    // Set fundings
    List<FundingSummary> fundingSummaries = fundingManager.getFundingSummaryList(orcid, lastModifiedTime);
    Fundings fundings = fundingManager.groupFundings(fundingSummaries, justPublic);
    activities.setFundings(fundings);
    // Set peer reviews
    List<PeerReviewSummary> peerReviewSummaries = peerReviewManager.getPeerReviewSummaryList(orcid, lastModifiedTime);
    PeerReviews peerReviews = peerReviewManager.groupPeerReviews(peerReviewSummaries, justPublic);
    activities.setPeerReviews(peerReviews);
    // Set works
    List<WorkSummary> workSummaries = workManager.getWorksSummaryList(orcid, lastModifiedTime);
    Works works = workManager.groupWorks(workSummaries, justPublic);
    activities.setWorks(works);
    return activities;
}
Also used : Fundings(org.orcid.jaxb.model.record.summary_v2.Fundings) PeerReviews(org.orcid.jaxb.model.record.summary_v2.PeerReviews) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) Employments(org.orcid.jaxb.model.record.summary_v2.Employments) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) EducationSummary(org.orcid.jaxb.model.record.summary_v2.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) Educations(org.orcid.jaxb.model.record.summary_v2.Educations) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary) Works(org.orcid.jaxb.model.record.summary_v2.Works)

Example 29 with ActivitiesSummary

use of org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary in project ORCID-Source by ORCID.

the class ActivitiesSummaryManagerTest method testGetActivitiesSummary.

@Test
public void testGetActivitiesSummary() {
    ActivitiesSummary summary = activitiesSummaryManager.getActivitiesSummary(ORCID);
    assertNotNull(summary);
    assertNotNull(summary.getEducations());
    assertNotNull(summary.getEducations().getSummaries());
    assertEquals(5, summary.getEducations().getSummaries().size());
    assertNotNull(summary.getEmployments());
    assertNotNull(summary.getEmployments().getSummaries());
    assertEquals(5, summary.getEmployments().getSummaries().size());
    assertNotNull(summary.getFundings());
    assertNotNull(summary.getFundings().getFundingGroup());
    assertEquals(5, summary.getFundings().getFundingGroup().size());
    assertNotNull(summary.getPeerReviews());
    assertNotNull(summary.getPeerReviews().getPeerReviewGroup());
    assertEquals(5, summary.getPeerReviews().getPeerReviewGroup().size());
    assertNotNull(summary.getWorks());
    assertNotNull(summary.getWorks().getWorkGroup());
    assertEquals(5, summary.getWorks().getWorkGroup().size());
}
Also used : ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) Test(org.junit.Test) DBUnitTest(org.orcid.test.DBUnitTest)

Example 30 with ActivitiesSummary

use of org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary in project ORCID-Source by ORCID.

the class ActivitiesSummaryManagerTest method testGetPublicActivitiesSummary.

@Test
public void testGetPublicActivitiesSummary() {
    ActivitiesSummary summary = activitiesSummaryManager.getPublicActivitiesSummary(ORCID);
    assertNotNull(summary);
    assertNotNull(summary.getEducations());
    assertNotNull(summary.getEducations().getSummaries());
    assertEquals(1, summary.getEducations().getSummaries().size());
    assertEquals(Long.valueOf(20), summary.getEducations().getSummaries().get(0).getPutCode());
    assertNotNull(summary.getEmployments());
    assertNotNull(summary.getEmployments().getSummaries());
    assertEquals(1, summary.getEmployments().getSummaries().size());
    assertEquals(Long.valueOf(17), summary.getEmployments().getSummaries().get(0).getPutCode());
    assertNotNull(summary.getFundings());
    assertNotNull(summary.getFundings().getFundingGroup());
    assertEquals(1, summary.getFundings().getFundingGroup().size());
    assertEquals(Long.valueOf(10), summary.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getPutCode());
    assertNotNull(summary.getPeerReviews());
    assertNotNull(summary.getPeerReviews().getPeerReviewGroup());
    assertEquals(1, summary.getPeerReviews().getPeerReviewGroup().size());
    assertEquals(Long.valueOf(9), summary.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getPutCode());
    assertNotNull(summary.getWorks());
    assertNotNull(summary.getWorks().getWorkGroup());
    assertEquals(1, summary.getWorks().getWorkGroup().size());
    assertEquals(Long.valueOf(11), summary.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getPutCode());
}
Also used : ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) Test(org.junit.Test) DBUnitTest(org.orcid.test.DBUnitTest)

Aggregations

Test (org.junit.Test)101 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)81 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)47 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)43 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)43 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)42 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)40 DBUnitTest (org.orcid.test.DBUnitTest)23 Record (org.orcid.jaxb.model.record_v2.Record)21 Person (org.orcid.jaxb.model.record_v2.Person)19 ClientResponse (com.sun.jersey.api.client.ClientResponse)18 Response (javax.ws.rs.core.Response)18 Address (org.orcid.jaxb.model.record_v2.Address)16 Email (org.orcid.jaxb.model.record_v2.Email)16 Keyword (org.orcid.jaxb.model.record_v2.Keyword)16 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)16 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)16 WorkGroup (org.orcid.jaxb.model.record.summary_v2.WorkGroup)15 OtherName (org.orcid.jaxb.model.record_v2.OtherName)14 Biography (org.orcid.jaxb.model.record_v2.Biography)13