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