Search in sources :

Example 31 with ActivitiesSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary in project ORCID-Source by ORCID.

the class ValidateV3_dev1SamplesTest method testmarshallActivities.

@Test
public void testmarshallActivities() throws JAXBException, SAXException, URISyntaxException {
    ActivitiesSummary object = (ActivitiesSummary) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/activities-3.0_dev1.xml", ActivitiesSummary.class);
    marshall(object, "/record_3.0_dev1/activities-3.0_dev1.xsd");
}
Also used : ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) Test(org.junit.Test)

Example 32 with ActivitiesSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorImpl method viewActivities.

/**
 * finds and returns the {@link org.orcid.jaxb.model.message.OrcidMessage}
 * wrapped in a {@link javax.xml.ws.Response} with only the profile's bio
 * details
 *
 * @param orcid
 *            the ORCID to be used to identify the record
 * @return the {@link javax.xml.ws.Response} with the
 *         {@link org.orcid.jaxb.model.message.OrcidMessage} within it
 */
@Override
public Response viewActivities(String orcid) {
    ActivitiesSummary as = activitiesSummaryManagerReadOnly.getPublicActivitiesSummary(orcid);
    publicAPISecurityManagerV3.filter(as);
    ActivityUtils.cleanEmptyFields(as);
    ActivityUtils.setPathToActivity(as, orcid);
    Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(as);
    sourceUtilsReadOnly.setSourceName(as);
    return Response.ok(as).build();
}
Also used : ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)

Example 33 with ActivitiesSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary in project ORCID-Source by ORCID.

the class SourceUtils method setSourceName.

public void setSourceName(ActivitiesSummary as) {
    if (as == null) {
        return;
    }
    if (as.getEducations() != null) {
        Educations educations = as.getEducations();
        List<EducationSummary> list = educations.getSummaries();
        if (list != null) {
            for (EducationSummary summary : list) {
                setSourceName(summary);
            }
        }
    }
    if (as.getEmployments() != null) {
        Employments employments = as.getEmployments();
        List<EmploymentSummary> list = employments.getSummaries();
        if (list != null) {
            for (EmploymentSummary summary : list) {
                setSourceName(summary);
            }
        }
    }
    if (as.getFundings() != null) {
        Fundings fundings = as.getFundings();
        List<FundingGroup> groups = fundings.getFundingGroup();
        if (groups != null) {
            for (FundingGroup group : groups) {
                List<FundingSummary> summaryList = group.getFundingSummary();
                if (summaryList != null) {
                    for (FundingSummary summary : summaryList) {
                        setSourceName(summary);
                    }
                }
            }
        }
    }
    if (as.getPeerReviews() != null) {
        PeerReviews peerReviews = as.getPeerReviews();
        List<PeerReviewGroup> groups = peerReviews.getPeerReviewGroup();
        if (groups != null) {
            for (PeerReviewGroup group : groups) {
                List<PeerReviewSummary> summaryList = group.getPeerReviewSummary();
                if (summaryList != null) {
                    for (PeerReviewSummary summary : summaryList) {
                        setSourceName(summary);
                    }
                }
            }
        }
    }
    if (as.getWorks() != null) {
        Works works = as.getWorks();
        List<WorkGroup> groups = works.getWorkGroup();
        if (groups != null) {
            for (WorkGroup group : groups) {
                List<WorkSummary> summaryList = group.getWorkSummary();
                if (summaryList != null) {
                    for (WorkSummary summary : summaryList) {
                        setSourceName(summary);
                    }
                }
            }
        }
    }
}
Also used : PeerReviewGroup(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup) Fundings(org.orcid.jaxb.model.v3.dev1.record.summary.Fundings) PeerReviews(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviews) FundingGroup(org.orcid.jaxb.model.v3.dev1.record.summary.FundingGroup) Employments(org.orcid.jaxb.model.v3.dev1.record.summary.Employments) WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) EducationSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary) Educations(org.orcid.jaxb.model.v3.dev1.record.summary.Educations) FundingSummary(org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary) EmploymentSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works)

Example 34 with ActivitiesSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary in project ORCID-Source by ORCID.

the class ActivityUtilsTest method setPathToActivitiesSummaryTest.

@Test
public void setPathToActivitiesSummaryTest() {
    ActivitiesSummary x = new ActivitiesSummary();
    x.setDistinctions(getDistinctions());
    x.setEducations(getEducations());
    x.setEmployments(getEmployments());
    x.setInvitedPositions(getInvitedPositions());
    x.setFundings(getFundings());
    x.setMemberships(getMemberships());
    x.setQualifications(getQualifications());
    x.setServices(getServices());
    x.setWorks(getWorks());
    x.setPeerReviews(getPeerReviews());
    ActivityUtils.setPathToActivity(x, ORCID);
    assertEquals("/" + ORCID + "/activities", x.getPath());
    assertEquals("/" + ORCID + "/distinction/123", x.getDistinctions().getSummaries().get(0).getPath());
    assertEquals("/" + ORCID + "/education/123", x.getEducations().getSummaries().get(0).getPath());
    assertEquals("/" + ORCID + "/employment/123", x.getEmployments().getSummaries().get(0).getPath());
    assertEquals("/" + ORCID + "/invited-position/123", x.getInvitedPositions().getSummaries().get(0).getPath());
    assertEquals("/" + ORCID + "/funding/123", x.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getPath());
    assertEquals("/" + ORCID + "/membership/123", x.getMemberships().getSummaries().get(0).getPath());
    assertEquals("/" + ORCID + "/qualification/123", x.getQualifications().getSummaries().get(0).getPath());
    assertEquals("/" + ORCID + "/service/123", x.getServices().getSummaries().get(0).getPath());
    assertEquals("/" + ORCID + "/work/123", x.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getPath());
    assertEquals("/" + ORCID + "/peer-review/123", x.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getPath());
}
Also used : ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) Test(org.junit.Test)

Example 35 with ActivitiesSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_QualificationsTest method testAddQualification.

@Test
public void testAddQualification() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewActivities(ORCID);
    assertNotNull(response);
    ActivitiesSummary originalSummary = (ActivitiesSummary) response.getEntity();
    assertNotNull(originalSummary);
    Utils.verifyLastModified(originalSummary.getLastModifiedDate());
    assertNotNull(originalSummary.getQualifications());
    Utils.verifyLastModified(originalSummary.getQualifications().getLastModifiedDate());
    assertNotNull(originalSummary.getQualifications().getSummaries());
    assertNotNull(originalSummary.getQualifications().getSummaries().get(0));
    Utils.verifyLastModified(originalSummary.getQualifications().getSummaries().get(0).getLastModifiedDate());
    assertEquals(4, originalSummary.getQualifications().getSummaries().size());
    response = serviceDelegator.createQualification(ORCID, (Qualification) Utils.getAffiliation(AffiliationType.QUALIFICATION));
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    Map<?, ?> map = response.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    List<?> resultWithPutCode = (List<?>) map.get("Location");
    Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    response = serviceDelegator.viewActivities(ORCID);
    assertNotNull(response);
    ActivitiesSummary summaryWithNewElement = (ActivitiesSummary) response.getEntity();
    assertNotNull(summaryWithNewElement);
    Utils.verifyLastModified(summaryWithNewElement.getLastModifiedDate());
    assertNotNull(summaryWithNewElement.getQualifications());
    Utils.verifyLastModified(summaryWithNewElement.getQualifications().getLastModifiedDate());
    assertNotNull(summaryWithNewElement.getQualifications().getSummaries());
    assertEquals(5, summaryWithNewElement.getQualifications().getSummaries().size());
    boolean haveNew = false;
    for (QualificationSummary qualificationSummary : summaryWithNewElement.getQualifications().getSummaries()) {
        assertNotNull(qualificationSummary.getPutCode());
        Utils.verifyLastModified(qualificationSummary.getLastModifiedDate());
        if (qualificationSummary.getPutCode().equals(putCode)) {
            assertEquals("My department name", qualificationSummary.getDepartmentName());
            haveNew = true;
        } else {
            assertTrue(originalSummary.getQualifications().getSummaries().contains(qualificationSummary));
        }
    }
    assertTrue(haveNew);
    // Remove new element
    serviceDelegator.deleteAffiliation(ORCID, putCode);
}
Also used : Response(javax.ws.rs.core.Response) Qualification(org.orcid.jaxb.model.v3.dev1.record.Qualification) QualificationSummary(org.orcid.jaxb.model.v3.dev1.record.summary.QualificationSummary) List(java.util.List) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)75 Test (org.junit.Test)69 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)45 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)40 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)40 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)39 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)38 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)34 InvitedPositionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary)34 MembershipSummary (org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary)34 QualificationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.QualificationSummary)34 ServiceSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary)34 DBUnitTest (org.orcid.test.DBUnitTest)26 Response (javax.ws.rs.core.Response)21 Person (org.orcid.jaxb.model.v3.dev1.record.Person)16 Record (org.orcid.jaxb.model.v3.dev1.record.Record)16 Address (org.orcid.jaxb.model.v3.dev1.record.Address)14 Email (org.orcid.jaxb.model.v3.dev1.record.Email)14 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)14 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)14