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");
}
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();
}
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);
}
}
}
}
}
}
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());
}
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);
}
Aggregations