Search in sources :

Example 16 with WorkGroup

use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_WorksTest method viewWorksTest.

@Test
public void viewWorksTest() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewWorks(ORCID);
    assertNotNull(r);
    Works works = (Works) r.getEntity();
    assertNotNull(works);
    assertEquals("/0000-0000-0000-0003/works", works.getPath());
    Utils.verifyLastModified(works.getLastModifiedDate());
    assertNotNull(works.getWorkGroup());
    assertNotNull(works.getPath());
    assertEquals(4, works.getWorkGroup().size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false;
    for (WorkGroup workGroup : works.getWorkGroup()) {
        Utils.verifyLastModified(workGroup.getLastModifiedDate());
        assertNotNull(workGroup.getIdentifiers());
        assertNotNull(workGroup.getIdentifiers().getExternalIdentifier());
        assertEquals(1, workGroup.getIdentifiers().getExternalIdentifier().size());
        assertNotNull(workGroup.getWorkSummary());
        assertEquals(1, workGroup.getWorkSummary().size());
        WorkSummary summary = workGroup.getWorkSummary().get(0);
        Utils.verifyLastModified(summary.getLastModifiedDate());
        assertNotNull(summary.getTitle());
        assertNotNull(summary.getTitle().getTitle());
        switch(workGroup.getIdentifiers().getExternalIdentifier().get(0).getValue()) {
            case "1":
                assertEquals("PUBLIC", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(11), summary.getPutCode());
                found1 = true;
                break;
            case "2":
                assertEquals("LIMITED", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(12), summary.getPutCode());
                found2 = true;
                break;
            case "3":
                assertEquals("PRIVATE", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(13), summary.getPutCode());
                found3 = true;
                break;
            case "4":
                assertEquals("SELF LIMITED", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(14), summary.getPutCode());
                found4 = true;
                break;
            default:
                fail("Invalid external id found: " + workGroup.getIdentifiers().getExternalIdentifier().get(0).getValue());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
}
Also used : Response(javax.ws.rs.core.Response) WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 17 with WorkGroup

use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup in project ORCID-Source by ORCID.

the class WorkGroup method valueOf.

public static WorkGroup valueOf(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup workGroup, int id, String orcid) {
    WorkGroup group = new WorkGroup();
    group.setGroupId(id);
    group.setWorks(new ArrayList<>());
    WorkType workType = null;
    Long maxDisplayIndex = null;
    for (WorkSummary workSummary : workGroup.getWorkSummary()) {
        WorkForm workForm = getWorkForm(workSummary);
        group.getWorks().add(workForm);
        Long displayIndex = Long.parseLong(workSummary.getDisplayIndex());
        if (maxDisplayIndex == null || displayIndex > maxDisplayIndex) {
            maxDisplayIndex = displayIndex;
            group.setActivePutCode(workSummary.getPutCode());
            group.setActiveVisibility(workSummary.getVisibility().name());
            group.setDefaultWork(workForm);
        }
        if (workSummary.getSource().retrieveSourcePath().equals(orcid)) {
            group.setUserVersionPresent(true);
        }
        workType = workSummary.getType();
    }
    if (workGroup.getIdentifiers() != null) {
        List<WorkExternalIdentifier> workExternalIdentifiersList = new ArrayList<WorkExternalIdentifier>();
        for (ExternalID extId : workGroup.getIdentifiers().getExternalIdentifier()) {
            if (extId.getRelationship() == null) {
                if (org.orcid.jaxb.model.message.WorkExternalIdentifierType.ISSN.equals(extId.getType())) {
                    if (WorkType.BOOK.equals(workType)) {
                        extId.setRelationship(Relationship.PART_OF);
                    } else {
                        extId.setRelationship(Relationship.SELF);
                    }
                } else if (org.orcid.jaxb.model.message.WorkExternalIdentifierType.ISBN.equals(extId.getType())) {
                    if (WorkType.BOOK_CHAPTER.equals(workType) || WorkType.CONFERENCE_PAPER.equals(workType)) {
                        extId.setRelationship(Relationship.PART_OF);
                    } else {
                        extId.setRelationship(Relationship.SELF);
                    }
                } else {
                    extId.setRelationship(Relationship.SELF);
                }
            }
            workExternalIdentifiersList.add(WorkExternalIdentifier.valueOf(extId));
        }
        group.setWorkExternalIdentifiers(workExternalIdentifiersList);
    }
    return group;
}
Also used : WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) WorkForm(org.orcid.pojo.ajaxForm.WorkForm) WorkType(org.orcid.jaxb.model.v3.dev1.record.WorkType) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) ArrayList(java.util.ArrayList) WorkExternalIdentifier(org.orcid.pojo.ajaxForm.WorkExternalIdentifier)

Example 18 with WorkGroup

use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup in project ORCID-Source by ORCID.

the class OrcidSecurityManagerImpl method checkAndFilter.

@Override
public void checkAndFilter(String orcid, ActivitiesSummary activities) {
    if (activities == null) {
        return;
    }
    // Check the token
    isMyToken(orcid);
    // Distinctions
    if (activities.getDistinctions() != null) {
        checkAndFilter(orcid, activities.getDistinctions().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Educations
    if (activities.getEducations() != null) {
        checkAndFilter(orcid, activities.getEducations().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Employments
    if (activities.getEmployments() != null) {
        checkAndFilter(orcid, activities.getEmployments().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Invited positions
    if (activities.getInvitedPositions() != null) {
        checkAndFilter(orcid, activities.getInvitedPositions().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Memberships
    if (activities.getMemberships() != null) {
        checkAndFilter(orcid, activities.getMemberships().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Qualifications
    if (activities.getQualifications() != null) {
        checkAndFilter(orcid, activities.getQualifications().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Services
    if (activities.getServices() != null) {
        checkAndFilter(orcid, activities.getServices().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Funding
    if (activities.getFundings() != null) {
        Iterator<FundingGroup> groupIt = activities.getFundings().getFundingGroup().iterator();
        while (groupIt.hasNext()) {
            FundingGroup group = groupIt.next();
            // Filter the list of elements
            checkAndFilter(orcid, group.getFundingSummary(), READ_FUNDING_REQUIRED_SCOPE, true);
            // Clean external identifiers
            if (group.getFundingSummary().isEmpty()) {
                groupIt.remove();
            } else {
                filterExternalIdentifiers(group);
            }
        }
    }
    // PeerReviews
    if (activities.getPeerReviews() != null) {
        Iterator<PeerReviewGroup> groupIt = activities.getPeerReviews().getPeerReviewGroup().iterator();
        while (groupIt.hasNext()) {
            PeerReviewGroup group = groupIt.next();
            // Filter the list of elements
            checkAndFilter(orcid, group.getPeerReviewSummary(), READ_PEER_REVIEWS_REQUIRED_SCOPE, true);
            if (group.getPeerReviewSummary().isEmpty()) {
                groupIt.remove();
            }
        }
    }
    // Works
    if (activities.getWorks() != null) {
        Iterator<WorkGroup> groupIt = activities.getWorks().getWorkGroup().iterator();
        while (groupIt.hasNext()) {
            WorkGroup group = groupIt.next();
            // Filter the list of elements
            checkAndFilter(orcid, group.getWorkSummary(), READ_WORKS_REQUIRED_SCOPE, true);
            // Clean external identifiers
            if (group.getWorkSummary().isEmpty()) {
                groupIt.remove();
            } else {
                filterExternalIdentifiers(group);
            }
        }
    }
}
Also used : PeerReviewGroup(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup) WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) FundingGroup(org.orcid.jaxb.model.v3.dev1.record.summary.FundingGroup)

Example 19 with WorkGroup

use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup in project ORCID-Source by ORCID.

the class BibtexManagerImpl method generateBibtexReferenceList.

@Override
public String generateBibtexReferenceList(String 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());
            String bibtex = generateBibtex(orcid, work);
            if (bibtex != null)
                citations.add(bibtex);
        }
    }
    return Joiner.on(",\n").join(citations);
}
Also used : WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) ArrayList(java.util.ArrayList) Work(org.orcid.jaxb.model.v3.dev1.record.Work) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)

Example 20 with WorkGroup

use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup in project ORCID-Source by ORCID.

the class ValidateV3_dev1SamplesTest method testUnmarshallWorks.

@Test
public void testUnmarshallWorks() throws JAXBException, SAXException, URISyntaxException {
    Works works = (Works) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/works-3.0_dev1.xml", Works.class, "/record_3.0_dev1/activities-3.0_dev1.xsd");
    assertNotNull(works);
    assertNotNull(works.getLastModifiedDate());
    assertNotNull(works.getLastModifiedDate().getValue());
    assertEquals(3, works.getWorkGroup().size());
    boolean foundWorkWithNoExtIds = false;
    for (WorkGroup group : works.getWorkGroup()) {
        assertNotNull(group.getLastModifiedDate().getValue());
        assertNotNull(group.getIdentifiers().getExternalIdentifier());
        if (group.getIdentifiers().getExternalIdentifier().isEmpty()) {
            WorkSummary summary = group.getWorkSummary().get(0);
            assertEquals("1", summary.getDisplayIndex());
            assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
            assertEquals("doi", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
            assertEquals("https://doi.org/123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
            assertEquals("123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
            assertEquals("/8888-8888-8888-8880/work/3356", summary.getPath());
            assertEquals("03", summary.getPublicationDate().getDay().getValue());
            assertEquals("03", summary.getPublicationDate().getMonth().getValue());
            assertEquals("2017", summary.getPublicationDate().getYear().getValue());
            assertEquals("Work # 0", summary.getTitle().getTitle().getContent());
            assertEquals(WorkType.CONFERENCE_PAPER, summary.getType());
            assertEquals(Visibility.PUBLIC, summary.getVisibility());
            foundWorkWithNoExtIds = true;
        } else {
            assertEquals(1, group.getIdentifiers().getExternalIdentifier().size());
            ExternalID extId = group.getIdentifiers().getExternalIdentifier().get(0);
            if (extId.getType().equals("arxiv")) {
                assertEquals(Relationship.SELF, extId.getRelationship());
                assertEquals("http://arxiv.org/abs/123456", extId.getUrl().getValue());
                assertEquals("123456", extId.getValue());
            } else if (extId.getType().equals("bibcode")) {
                assertEquals(Relationship.SELF, extId.getRelationship());
                assertEquals("http://adsabs.harvard.edu/abs/4567", extId.getUrl().getValue());
                assertEquals("4567", extId.getValue());
            } else {
                fail("Invalid ext id type " + extId.getType());
            }
            assertEquals(1, group.getWorkSummary().size());
            WorkSummary summary = group.getWorkSummary().get(0);
            if (summary.getPutCode().equals(Long.valueOf(3357))) {
                assertEquals("1", summary.getDisplayIndex());
                assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
                assertEquals("arxiv", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
                assertEquals("http://arxiv.org/abs/123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
                assertEquals("123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
                assertEquals("/8888-8888-8888-8880/work/3357", summary.getPath());
                assertEquals("02", summary.getPublicationDate().getDay().getValue());
                assertEquals("02", summary.getPublicationDate().getMonth().getValue());
                assertEquals("2017", summary.getPublicationDate().getYear().getValue());
                assertEquals("Work # 1", summary.getTitle().getTitle().getContent());
                assertEquals(WorkType.CONFERENCE_PAPER, summary.getType());
                assertEquals(Visibility.PUBLIC, summary.getVisibility());
            } else if (summary.getPutCode().equals(Long.valueOf(3358))) {
                assertEquals("1", summary.getDisplayIndex());
                assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
                assertEquals("bibcode", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
                assertEquals("http://adsabs.harvard.edu/abs/4567", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
                assertEquals("4567", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
                assertEquals("/8888-8888-8888-8880/work/3358", summary.getPath());
                assertEquals("03", summary.getPublicationDate().getDay().getValue());
                assertEquals("03", summary.getPublicationDate().getMonth().getValue());
                assertEquals("2017", summary.getPublicationDate().getYear().getValue());
                assertEquals("Work # 2", summary.getTitle().getTitle().getContent());
                assertEquals(WorkType.JOURNAL_ARTICLE, summary.getType());
                assertEquals(Visibility.PUBLIC, summary.getVisibility());
            } else {
                fail("Invalid put code " + summary.getPutCode());
            }
        }
    }
    assertTrue(foundWorkWithNoExtIds);
}
Also used : WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) 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) Test(org.junit.Test)

Aggregations

WorkGroup (org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup)28 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)28 Test (org.junit.Test)17 Works (org.orcid.jaxb.model.v3.dev1.record.summary.Works)17 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)10 FundingGroup (org.orcid.jaxb.model.v3.dev1.record.summary.FundingGroup)9 PeerReviewGroup (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup)9 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)8 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)8 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)8 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)8 ArrayList (java.util.ArrayList)6 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)6 DBUnitTest (org.orcid.test.DBUnitTest)6 ClientResponse (com.sun.jersey.api.client.ClientResponse)5 Response (javax.ws.rs.core.Response)5 Work (org.orcid.jaxb.model.v3.dev1.record.Work)5 LastModifiedDate (org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate)4 Title (org.orcid.jaxb.model.v3.dev1.common.Title)4 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)4