use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorImpl method viewWorkSummary.
@Override
public Response viewWorkSummary(String orcid, Long putCode) {
WorkSummary ws = workManagerReadOnly.getWorkSummary(orcid, putCode);
ActivityUtils.cleanEmptyFields(ws);
publicAPISecurityManagerV3.checkIsPublic(ws);
ActivityUtils.setPathToActivity(ws, orcid);
sourceUtilsReadOnly.setSourceName(ws);
return Response.ok(ws).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary 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.WorkSummary in project ORCID-Source by ORCID.
the class ActivitiesGroupGenerator_GroupingWorksTest method groupWorks_2GroupsOf2Works_Test.
/**
* Test grouping (work-1 and work-2) and (work-6 and work-7)
*/
@Test
public void groupWorks_2GroupsOf2Works_Test() {
ActivitiesGroupGenerator generator = new ActivitiesGroupGenerator();
Map<String, WorkSummary> works = generateWorks();
WorkSummary work1 = works.get("work-1");
WorkSummary work2 = works.get("work-2");
WorkSummary work6 = works.get("work-6");
WorkSummary work7 = works.get("work-7");
generator.group(work1);
generator.group(work2);
generator.group(work6);
generator.group(work7);
List<ActivitiesGroup> groups = generator.getGroups();
assertNotNull(groups);
assertEquals(2, groups.size());
// Check there are two activities in each group
assertEquals(2, groups.get(0).getActivities().size());
assertEquals(2, groups.get(1).getActivities().size());
// Check there are five external ids in each group
assertEquals(5, groups.get(0).getGroupKeys().size());
assertEquals(5, groups.get(1).getGroupKeys().size());
// Check each work
checkActivityIsOnGroups(work1, groups);
checkActivityIsOnGroups(work2, groups);
checkActivityIsOnGroups(work6, groups);
checkActivityIsOnGroups(work7, groups);
// Check work1 and work2 are in the same group
checkActivitiesBelongsToTheSameGroup(groups, work1, work2);
// Check work6 and work7 are in the same group
checkActivitiesBelongsToTheSameGroup(groups, work6, work7);
// Check works are not mixed
checkActivitiesDontBelongsToTheSameGroup(groups, work1, work6);
checkActivitiesDontBelongsToTheSameGroup(groups, work1, work7);
checkActivitiesDontBelongsToTheSameGroup(groups, work2, work6);
checkActivitiesDontBelongsToTheSameGroup(groups, work2, work7);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary in project ORCID-Source by ORCID.
the class ActivitiesGroupGenerator_GroupingWorksTest method testNormalizedGrouping.
@Test
public void testNormalizedGrouping() {
ActivitiesGroupGenerator generator = new ActivitiesGroupGenerator();
List<WorkSummary> sums = new ArrayList<WorkSummary>();
for (int i = 0; i < 2; i++) {
String title = "work-" + i;
WorkSummary work = new WorkSummary();
// Set title
WorkTitle workTitle = new WorkTitle();
workTitle.setTitle(new Title(title));
work.setTitle(workTitle);
ExternalIDs wei = new ExternalIDs();
ExternalID e1 = new ExternalID();
e1.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.DOI.value());
e1.setValue("a");
e1.setNormalized(new TransientNonEmptyString("a"));
wei.getExternalIdentifier().add(e1);
work.setExternalIdentifiers(wei);
sums.add(work);
}
sums.get(0).getExternalIdentifiers().getExternalIdentifier().get(0).setValue("A");
generator.group(sums.get(0));
generator.group(sums.get(1));
assertEquals(1, generator.getGroups().size());
checkActivitiesBelongsToTheSameGroup(generator.getGroups(), sums.get(0), sums.get(1));
for (int i = 2; i < 4; i++) {
String title = "work-" + i;
WorkSummary work = new WorkSummary();
// Set title
WorkTitle workTitle = new WorkTitle();
workTitle.setTitle(new Title(title));
work.setTitle(workTitle);
ExternalIDs wei = new ExternalIDs();
ExternalID e1 = new ExternalID();
e1.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value());
e1.setValue("https://dx.doi.org/10/UPPER");
e1.setNormalized(new TransientNonEmptyString("10/upper"));
wei.getExternalIdentifier().add(e1);
work.setExternalIdentifiers(wei);
sums.add(work);
}
sums.get(0).getExternalIdentifiers().getExternalIdentifier().get(0).setValue("http://doi.org/10/upper");
generator.group(sums.get(2));
generator.group(sums.get(3));
assertEquals(2, generator.getGroups().size());
checkActivitiesBelongsToTheSameGroup(generator.getGroups(), sums.get(0), sums.get(1));
checkActivitiesBelongsToTheSameGroup(generator.getGroups(), sums.get(2), sums.get(3));
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary in project ORCID-Source by ORCID.
the class ActivitiesGroupGenerator_GroupingWorksTest method groupWorks_1GroupsOf2Works_Test.
/**
* Test grouping work-1 and work-2
*/
@Test
public void groupWorks_1GroupsOf2Works_Test() {
ActivitiesGroupGenerator generator = new ActivitiesGroupGenerator();
Map<String, WorkSummary> works = generateWorks();
WorkSummary work1 = works.get("work-1");
WorkSummary work2 = works.get("work-2");
generator.group(work1);
generator.group(work2);
List<ActivitiesGroup> groups = generator.getGroups();
assertNotNull(groups);
assertEquals(1, groups.size());
ActivitiesGroup g1 = groups.get(0);
assertNotNull(g1);
assertNotNull(g1.getActivities());
assertEquals(2, g1.getActivities().size());
assertTrue(g1.getActivities().contains(work1));
assertTrue(g1.getActivities().contains(work2));
assertNotNull(g1.getGroupKeys());
assertEquals(5, g1.getGroupKeys().size());
checkExternalIdentifiers(work1, g1);
checkExternalIdentifiers(work2, g1);
}
Aggregations