use of org.orcid.jaxb.model.v3.dev1.record.Group in project ORCID-Source by ORCID.
the class PeerReviewForm method toPeerReview.
public PeerReview toPeerReview() {
PeerReview peerReview = new PeerReview();
// Put Code
if (!PojoUtil.isEmpty(putCode)) {
peerReview.setPutCode(Long.valueOf(putCode.getValue()));
}
// Visibility
if (visibility != null && visibility.getVisibility() != null) {
peerReview.setVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.fromValue(visibility.getVisibility().value()));
}
// Completion date
if (completionDate != null) {
peerReview.setCompletionDate(new FuzzyDate(completionDate.toFuzzyDate()));
}
// External identifiers
if (externalIdentifiers != null && !externalIdentifiers.isEmpty()) {
peerReview.setExternalIdentifiers(new ExternalIDs());
for (WorkExternalIdentifier extId : externalIdentifiers) {
peerReview.getExternalIdentifiers().getExternalIdentifier().add(extId.toRecordWorkExternalIdentifier());
}
}
// Set Organization
Organization organization = new Organization();
OrganizationAddress organizationAddress = new OrganizationAddress();
organization.setAddress(organizationAddress);
if (!PojoUtil.isEmpty(orgName)) {
organization.setName(orgName.getValue());
}
if (!PojoUtil.isEmpty(city)) {
organizationAddress.setCity(city.getValue());
}
if (!PojoUtil.isEmpty(region)) {
organizationAddress.setRegion(region.getValue());
}
if (!PojoUtil.isEmpty(country)) {
organizationAddress.setCountry(Iso3166Country.fromValue(country.getValue()));
}
if (!PojoUtil.isEmpty(disambiguatedOrganizationSourceId)) {
organization.setDisambiguatedOrganization(new DisambiguatedOrganization());
organization.getDisambiguatedOrganization().setDisambiguatedOrganizationIdentifier(disambiguatedOrganizationSourceId.getValue());
organization.getDisambiguatedOrganization().setDisambiguationSource(disambiguationSource.getValue());
}
peerReview.setOrganization(organization);
// Role
if (!PojoUtil.isEmpty(role)) {
peerReview.setRole(Role.fromValue(role.getValue()));
}
// Type
if (!PojoUtil.isEmpty(type)) {
peerReview.setType(PeerReviewType.fromValue(type.getValue()));
}
// Url
if (!PojoUtil.isEmpty(url)) {
peerReview.setUrl(new Url(url.getValue()));
}
// Group id
if (!PojoUtil.isEmpty(groupId)) {
peerReview.setGroupId(groupId.getValue());
}
// Subject external id
if (!PojoUtil.isEmpty(subjectExternalIdentifier)) {
ExternalID subjectExtId = new ExternalID();
if (!PojoUtil.isEmpty(subjectExternalIdentifier.getRelationship())) {
subjectExtId.setRelationship(Relationship.fromValue(subjectExternalIdentifier.getRelationship().getValue()));
}
if (!PojoUtil.isEmpty(subjectExternalIdentifier.getUrl())) {
subjectExtId.setUrl(new Url(subjectExternalIdentifier.getUrl().getValue()));
}
if (!PojoUtil.isEmpty(subjectExternalIdentifier.getWorkExternalIdentifierId())) {
subjectExtId.setValue(subjectExternalIdentifier.getWorkExternalIdentifierId().getValue());
}
if (!PojoUtil.isEmpty(subjectExternalIdentifier.getWorkExternalIdentifierType())) {
subjectExtId.setType(subjectExternalIdentifier.getWorkExternalIdentifierType().getValue());
}
peerReview.setSubjectExternalIdentifier(subjectExtId);
}
// Subject container name
if (!PojoUtil.isEmpty(subjectContainerName)) {
Title containerName = new Title(subjectContainerName.getValue());
peerReview.setSubjectContainerName(containerName);
}
// Subject type
if (!PojoUtil.isEmpty(subjectType)) {
peerReview.setSubjectType(WorkType.fromValue(subjectType.getValue()));
}
// Subject name and subject translated name
if (!PojoUtil.isEmpty(subjectName) || !PojoUtil.isEmpty(translatedSubjectName)) {
WorkTitle workTitle = new WorkTitle();
if (!PojoUtil.isEmpty(subjectName)) {
workTitle.setTitle(new Title(subjectName.getValue()));
}
if (translatedSubjectName != null) {
org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle tTitle = new org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle();
if (!PojoUtil.isEmpty(translatedSubjectName.getContent())) {
tTitle.setContent(translatedSubjectName.getContent());
}
if (!PojoUtil.isEmpty(translatedSubjectName.getLanguageCode())) {
tTitle.setLanguageCode(translatedSubjectName.getLanguageCode());
}
workTitle.setTranslatedTitle(tTitle);
}
peerReview.setSubjectName(workTitle);
}
// Subject url
if (!PojoUtil.isEmpty(subjectUrl)) {
peerReview.setSubjectUrl(new Url(subjectUrl.getValue()));
}
return peerReview;
}
use of org.orcid.jaxb.model.v3.dev1.record.Group in project ORCID-Source by ORCID.
the class WorksPaginatorTest method testGetWorkWithNulltitle.
/**
* Check null titles don't cause errors
*/
@Test
public void testGetWorkWithNulltitle() {
WorkGroup workGroup = getPublicWorkGroup(0);
for (WorkSummary workSummary : workGroup.getWorkSummary()) {
workSummary.setTitle(null);
}
Works works = new Works();
works.getWorkGroup().add(workGroup);
Mockito.when(worksCacheManager.getGroupedWorks(Mockito.anyString())).thenReturn(works);
WorksPage page = worksPaginator.getAllWorks("orcid", WorksPaginator.TITLE_SORT_KEY, true);
for (org.orcid.pojo.WorkGroup group : page.getWorkGroups()) {
for (WorkForm work : group.getWorks()) {
assertEquals("", work.getTitle().getValue());
}
}
}
use of org.orcid.jaxb.model.v3.dev1.record.Group in project ORCID-Source by ORCID.
the class WorksPaginator method refreshWorks.
public WorksPage refreshWorks(String orcid, int limit, String sort, boolean sortAsc) {
Works works = worksCacheManager.getGroupedWorks(orcid);
List<org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup> sortedGroups = sort(works.getWorkGroup(), sort, sortAsc);
WorksPage worksPage = new WorksPage();
worksPage.setTotalGroups(sortedGroups.size());
List<WorkGroup> workGroups = new ArrayList<>();
for (int i = 0; i < limit && i < sortedGroups.size(); i++) {
org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup group = sortedGroups.get(i);
workGroups.add(WorkGroup.valueOf(group, i, orcid));
}
worksPage.setWorkGroups(workGroups);
worksPage.setNextOffset(limit);
return worksPage;
}
use of org.orcid.jaxb.model.v3.dev1.record.Group in project ORCID-Source by ORCID.
the class WorkManagerTest method testGroupWorks.
@Test
public void testGroupWorks() {
/**
* @formatter:off
* They should be grouped as
*
* Group 1: Work 1 + Work 4
* Group 2: Work 2 + Work 5
* Group 3: Work 3
* Group 4: Work 6
* @formatter:on
*/
WorkSummary s1 = getWorkSummary("Work 1", "ext-id-1", Visibility.PUBLIC);
WorkSummary s2 = getWorkSummary("Work 2", "ext-id-2", Visibility.LIMITED);
WorkSummary s3 = getWorkSummary("Work 3", "ext-id-3", Visibility.PRIVATE);
WorkSummary s4 = getWorkSummary("Work 4", "ext-id-1", Visibility.PRIVATE);
WorkSummary s5 = getWorkSummary("Work 5", "ext-id-2", Visibility.PUBLIC);
WorkSummary s6 = getWorkSummary("Work 6", "ext-id-4", Visibility.PRIVATE);
List<WorkSummary> workList1 = Arrays.asList(s1, s2, s3, s4, s5, s6);
Works works1 = workManager.groupWorks(workList1, false);
assertNotNull(works1);
assertEquals(4, works1.getWorkGroup().size());
// Group 1 have all with ext-id-1
assertEquals(2, works1.getWorkGroup().get(0).getWorkSummary().size());
assertEquals(1, works1.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertEquals("ext-id-1", works1.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
// Group 2 have all with ext-id-2
assertEquals(2, works1.getWorkGroup().get(1).getWorkSummary().size());
assertEquals(1, works1.getWorkGroup().get(1).getIdentifiers().getExternalIdentifier().size());
assertEquals("ext-id-2", works1.getWorkGroup().get(1).getIdentifiers().getExternalIdentifier().get(0).getValue());
// Group 3 have ext-id-3
assertEquals(1, works1.getWorkGroup().get(2).getWorkSummary().size());
assertEquals(1, works1.getWorkGroup().get(2).getIdentifiers().getExternalIdentifier().size());
assertEquals("ext-id-3", works1.getWorkGroup().get(2).getIdentifiers().getExternalIdentifier().get(0).getValue());
// Group 4 have ext-id-4
assertEquals(1, works1.getWorkGroup().get(3).getWorkSummary().size());
assertEquals(1, works1.getWorkGroup().get(3).getIdentifiers().getExternalIdentifier().size());
assertEquals("ext-id-4", works1.getWorkGroup().get(3).getIdentifiers().getExternalIdentifier().get(0).getValue());
WorkSummary s7 = getWorkSummary("Work 7", "ext-id-4", Visibility.PRIVATE);
// Add ext-id-3 to work 7, so, it join group 3 and group 4 in a single
// group
ExternalID extId = new ExternalID();
extId.setRelationship(Relationship.SELF);
extId.setType("doi");
extId.setUrl(new Url("http://orcid.org"));
extId.setValue("ext-id-3");
s7.getExternalIdentifiers().getExternalIdentifier().add(extId);
/**
* @formatter:off
* Now, they should be grouped as
*
* Group 1: Work 1 + Work 4
* Group 2: Work 2 + Work 5
* Group 3: Work 3 + Work 6 + Work 7
* @formatter:on
*/
List<WorkSummary> workList2 = Arrays.asList(s1, s2, s3, s4, s5, s6, s7);
Works works2 = workManager.groupWorks(workList2, false);
assertNotNull(works2);
assertEquals(3, works2.getWorkGroup().size());
// Group 1 have all with ext-id-1
assertEquals(2, works2.getWorkGroup().get(0).getWorkSummary().size());
assertEquals(1, works2.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertEquals("ext-id-1", works2.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
// Group 2 have all with ext-id-2
assertEquals(2, works2.getWorkGroup().get(1).getWorkSummary().size());
assertEquals(1, works2.getWorkGroup().get(1).getIdentifiers().getExternalIdentifier().size());
assertEquals("ext-id-2", works2.getWorkGroup().get(1).getIdentifiers().getExternalIdentifier().get(0).getValue());
// Group 3 have all with ext-id-3 and ext-id-4
assertEquals(3, works2.getWorkGroup().get(2).getWorkSummary().size());
assertEquals(2, works2.getWorkGroup().get(2).getIdentifiers().getExternalIdentifier().size());
assertThat(works2.getWorkGroup().get(2).getIdentifiers().getExternalIdentifier().get(0).getValue(), anyOf(is("ext-id-3"), is("ext-id-4")));
assertThat(works2.getWorkGroup().get(2).getIdentifiers().getExternalIdentifier().get(1).getValue(), anyOf(is("ext-id-3"), is("ext-id-4")));
}
use of org.orcid.jaxb.model.v3.dev1.record.Group in project ORCID-Source by ORCID.
the class ActivityValidatorTest method getPeerReview.
public PeerReview getPeerReview() {
PeerReview peerReview = new PeerReview();
peerReview.setCompletionDate(getFuzzyDate());
peerReview.setExternalIdentifiers(getExternalIDs());
peerReview.setGroupId("group-id");
peerReview.setOrganization(getOrganization());
peerReview.setRole(Role.CHAIR);
peerReview.setSubjectContainerName(new Title("subject-container-name"));
peerReview.setSubjectExternalIdentifier(getExternalID());
peerReview.setSubjectName(getWorkTitle());
peerReview.setSubjectType(WorkType.ARTISTIC_PERFORMANCE);
peerReview.setSubjectUrl(new Url("http://test.orcid.org"));
peerReview.setType(PeerReviewType.EVALUATION);
peerReview.setUrl(new Url("http://test.orcid.org"));
peerReview.setVisibility(Visibility.PUBLIC);
return peerReview;
}
Aggregations