use of org.orcid.jaxb.model.record.summary_rc1.WorkGroup in project ORCID-Source by ORCID.
the class ActivityUtilsTest method cleanWorksTest.
@Test
public void cleanWorksTest() {
// Test it cleans empty fields
WorkSummary s = getEmptyWorkSummary();
Works w = new Works();
WorkGroup g = new WorkGroup();
g.getWorkSummary().add(s);
w.getWorkGroup().add(g);
assertNotNull(w.getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle());
ActivityUtils.cleanEmptyFields(w);
assertNull(w.getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle());
// Test it doesn't remove non empty fields
s = getEmptyWorkSummary();
s.getTitle().getTranslatedTitle().setContent("test");
s.getTitle().getTranslatedTitle().setLanguageCode("en_us");
w = new Works();
g = new WorkGroup();
g.getWorkSummary().add(s);
w.getWorkGroup().add(g);
assertEquals("test", w.getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle().getContent());
assertEquals("en_us", w.getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle().getLanguageCode());
ActivityUtils.cleanEmptyFields(w);
assertEquals("test", w.getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle().getContent());
assertEquals("en_us", w.getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle().getLanguageCode());
}
use of org.orcid.jaxb.model.record.summary_rc1.WorkGroup in project ORCID-Source by ORCID.
the class ActivityUtilsTest method cleanEmptyActivitiesSummaryTest.
@Test
public void cleanEmptyActivitiesSummaryTest() {
// Test it cleans empty fields
WorkSummary s = getEmptyWorkSummary();
ActivitiesSummary x = new ActivitiesSummary();
Works w = new Works();
WorkGroup g = new WorkGroup();
g.getWorkSummary().add(s);
w.getWorkGroup().add(g);
x.setWorks(w);
assertNotNull(x.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle());
ActivityUtils.cleanEmptyFields(x);
assertNull(x.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle());
// Test it doesn't remove non empty fields
s = getEmptyWorkSummary();
s.getTitle().getTranslatedTitle().setContent("test");
s.getTitle().getTranslatedTitle().setLanguageCode("en_us");
x = new ActivitiesSummary();
w = new Works();
g = new WorkGroup();
g.getWorkSummary().add(s);
w.getWorkGroup().add(g);
x.setWorks(w);
assertEquals("test", x.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle().getContent());
assertEquals("en_us", x.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle().getLanguageCode());
ActivityUtils.cleanEmptyFields(x);
assertEquals("test", x.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle().getContent());
assertEquals("en_us", x.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle().getLanguageCode());
}
use of org.orcid.jaxb.model.record.summary_rc1.WorkGroup 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.record.summary_rc1.WorkGroup in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_ActivitiesSummaryTest method testCleanEmptyFieldsOnActivities.
@Test
public void testCleanEmptyFieldsOnActivities() {
LastModifiedDate lmd = new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(System.currentTimeMillis()));
Works works = new Works();
works.setLastModifiedDate(lmd);
WorkGroup group = new WorkGroup();
group.setLastModifiedDate(lmd);
for (int i = 0; i < 5; i++) {
WorkSummary summary = new WorkSummary();
summary.setLastModifiedDate(lmd);
WorkTitle title = new WorkTitle();
title.setTitle(new Title("Work " + i));
title.setTranslatedTitle(new TranslatedTitle("", ""));
summary.setTitle(title);
group.getWorkSummary().add(summary);
}
works.getWorkGroup().add(group);
ActivitiesSummary as = new ActivitiesSummary();
as.setWorks(works);
ActivityUtils.cleanEmptyFields(as);
assertNotNull(as);
assertNotNull(as.getWorks());
Utils.verifyLastModified(as.getWorks().getLastModifiedDate());
assertNotNull(as.getWorks().getWorkGroup());
assertEquals(1, as.getWorks().getWorkGroup().size());
assertNotNull(as.getWorks().getWorkGroup().get(0).getWorkSummary());
Utils.verifyLastModified(as.getWorks().getWorkGroup().get(0).getLastModifiedDate());
assertEquals(5, as.getWorks().getWorkGroup().get(0).getWorkSummary().size());
for (WorkSummary summary : as.getWorks().getWorkGroup().get(0).getWorkSummary()) {
Utils.verifyLastModified(summary.getLastModifiedDate());
assertNotNull(summary.getTitle());
assertNotNull(summary.getTitle().getTitle());
assertTrue(summary.getTitle().getTitle().getContent().startsWith("Work "));
assertNull(summary.getTitle().getTranslatedTitle());
}
}
use of org.orcid.jaxb.model.record.summary_rc1.WorkGroup in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_ActivitiesSummaryTest method testViewActitivies_WorksReadLimited_NoSource.
@Test
public void testViewActitivies_WorksReadLimited_NoSource() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, "APP-5555555555555556", ScopePathType.ORCID_WORKS_READ_LIMITED);
Response response = serviceDelegator.viewActivities(ORCID);
ActivitiesSummary as = (ActivitiesSummary) response.getEntity();
assertNotNull(as);
assertNotNull(as.getPath());
Utils.verifyLastModified(as.getLastModifiedDate());
// Only public educations
assertNotNull(as.getEducations());
assertEquals(1, as.getEducations().getSummaries().size());
assertEquals(Long.valueOf(20), as.getEducations().getSummaries().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getEducations().getSummaries().get(0).getVisibility());
// Only public employments
assertNotNull(as.getEmployments());
assertEquals(1, as.getEmployments().getSummaries().size());
assertEquals(Long.valueOf(17), as.getEmployments().getSummaries().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getEmployments().getSummaries().get(0).getVisibility());
// Only public funding
assertNotNull(as.getFundings());
assertEquals(1, as.getFundings().getFundingGroup().size());
assertEquals(1, as.getFundings().getFundingGroup().get(0).getFundingSummary().size());
assertEquals(Long.valueOf(10), as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getVisibility());
// Only public peer reviews
assertNotNull(as.getPeerReviews());
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().size());
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().size());
assertEquals(Long.valueOf(9), as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getVisibility());
// Limited works
assertNotNull(as.getWorks());
assertEquals(3, as.getWorks().getWorkGroup().size());
boolean found1 = false, found2 = false, found3 = false;
for (WorkGroup group : as.getWorks().getWorkGroup()) {
assertEquals(1, group.getWorkSummary().size());
WorkSummary element = group.getWorkSummary().get(0);
if (element.getPutCode().equals(Long.valueOf(11))) {
assertEquals(Visibility.PUBLIC, element.getVisibility());
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(12))) {
assertEquals(Visibility.LIMITED, element.getVisibility());
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(14))) {
assertEquals(Visibility.LIMITED, element.getVisibility());
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
}
Aggregations