Search in sources :

Example 16 with Group

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;
}
Also used : ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) Organization(org.orcid.jaxb.model.v3.dev1.common.Organization) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) OrganizationAddress(org.orcid.jaxb.model.v3.dev1.common.OrganizationAddress) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) FuzzyDate(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate) Title(org.orcid.jaxb.model.v3.dev1.common.Title) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Url(org.orcid.jaxb.model.v3.dev1.common.Url) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview)

Example 17 with Group

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());
        }
    }
}
Also used : WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) WorkForm(org.orcid.pojo.ajaxForm.WorkForm) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works) Test(org.junit.Test)

Example 18 with Group

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;
}
Also used : ArrayList(java.util.ArrayList) WorkGroup(org.orcid.pojo.WorkGroup) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works)

Example 19 with Group

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")));
}
Also used : WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works) Url(org.orcid.jaxb.model.v3.dev1.common.Url) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 20 with Group

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;
}
Also used : Title(org.orcid.jaxb.model.v3.dev1.common.Title) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) FundingTitle(org.orcid.jaxb.model.v3.dev1.record.FundingTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) Url(org.orcid.jaxb.model.v3.dev1.common.Url)

Aggregations

Test (org.junit.Test)47 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)26 WorkGroup (org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup)18 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)17 BaseTest (org.orcid.core.BaseTest)16 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)15 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)14 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)13 PeerReviewGroup (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup)13 Works (org.orcid.jaxb.model.v3.dev1.record.summary.Works)13 FundingGroup (org.orcid.jaxb.model.v3.dev1.record.summary.FundingGroup)12 DBUnitTest (org.orcid.test.DBUnitTest)11 ArrayList (java.util.ArrayList)10 Response (javax.ws.rs.core.Response)10 Url (org.orcid.jaxb.model.v3.dev1.common.Url)8 GroupIdRecord (org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord)8 GroupableActivity (org.orcid.jaxb.model.v3.dev1.record.GroupableActivity)8 PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)8 ClientResponse (com.sun.jersey.api.client.ClientResponse)7 TransientNonEmptyString (org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString)7