Search in sources :

Example 71 with Record

use of nikita.common.model.noark5.v4.Record in project ORCID-Source by ORCID.

the class ValidateV2RC4Identifiers method testRecord.

@Test
public void testRecord() {
    Record record = unmarshallFromPath("/record_2.0_rc4/samples/record-2.0_rc4.xml", Record.class);
    ActivitiesSummary as = record.getActivitiesSummary();
    ExternalIDs fundingIDs = as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getExternalIdentifiers();
    ExternalIDs fundingIDs2 = as.getFundings().getFundingGroup().get(0).getIdentifiers();
    assertEquals("grant_number", fundingIDs.getExternalIdentifier().get(0).getType());
    assertEquals("external-id-value", fundingIDs.getExternalIdentifier().get(0).getValue());
    assertEquals(new Url("http://tempuri.org"), fundingIDs.getExternalIdentifier().get(0).getUrl());
    assertEquals(Relationship.SELF, fundingIDs.getExternalIdentifier().get(0).getRelationship());
    assertEquals(fundingIDs.getExternalIdentifier().get(0).getType(), fundingIDs2.getExternalIdentifier().get(0).getType());
    assertEquals(fundingIDs.getExternalIdentifier().get(0).getValue(), fundingIDs2.getExternalIdentifier().get(0).getValue());
    ExternalIDs workIDs = as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getExternalIdentifiers();
    ExternalIDs workIDs2 = as.getWorks().getWorkGroup().get(0).getIdentifiers();
    assertEquals("agr", workIDs.getExternalIdentifier().get(0).getType());
    assertEquals("external-id-value", workIDs.getExternalIdentifier().get(0).getValue());
    assertEquals(new Url("http://tempuri.org"), workIDs.getExternalIdentifier().get(0).getUrl());
    assertEquals(Relationship.SELF, workIDs.getExternalIdentifier().get(0).getRelationship());
    assertEquals(workIDs.getExternalIdentifier().get(0).getType(), workIDs2.getExternalIdentifier().get(0).getType());
    assertEquals(workIDs.getExternalIdentifier().get(0).getValue(), workIDs2.getExternalIdentifier().get(0).getValue());
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_rc4.ExternalIDs) Record(org.orcid.jaxb.model.record_rc4.Record) Url(org.orcid.jaxb.model.common_rc4.Url) ActivitiesSummary(org.orcid.jaxb.model.record.summary_rc4.ActivitiesSummary) MarshallingTest(org.orcid.jaxb.model.notification.custom.MarshallingTest) Test(org.junit.Test)

Example 72 with Record

use of nikita.common.model.noark5.v4.Record in project ORCID-Source by ORCID.

the class ValidateV2IdentifiersTest method testRecord.

@Test
public void testRecord() {
    Record record = unmarshallFromPath("/record_2.0/samples/read_samples/record-2.0.xml", Record.class);
    ActivitiesSummary as = record.getActivitiesSummary();
    ExternalIDs fundingIDs = as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getExternalIdentifiers();
    ExternalIDs fundingIDs2 = as.getFundings().getFundingGroup().get(0).getIdentifiers();
    assertEquals("grant_number", fundingIDs.getExternalIdentifier().get(0).getType());
    assertEquals("external-id-value", fundingIDs.getExternalIdentifier().get(0).getValue());
    assertEquals(new Url("http://tempuri.org"), fundingIDs.getExternalIdentifier().get(0).getUrl());
    assertEquals(Relationship.SELF, fundingIDs.getExternalIdentifier().get(0).getRelationship());
    assertEquals(fundingIDs.getExternalIdentifier().get(0).getType(), fundingIDs2.getExternalIdentifier().get(0).getType());
    assertEquals(fundingIDs.getExternalIdentifier().get(0).getValue(), fundingIDs2.getExternalIdentifier().get(0).getValue());
    ExternalIDs workIDs = as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getExternalIdentifiers();
    ExternalIDs workIDs2 = as.getWorks().getWorkGroup().get(0).getIdentifiers();
    assertEquals("agr", workIDs.getExternalIdentifier().get(0).getType());
    assertEquals("external-id-value", workIDs.getExternalIdentifier().get(0).getValue());
    assertEquals(new Url("http://tempuri.org"), workIDs.getExternalIdentifier().get(0).getUrl());
    assertEquals(Relationship.SELF, workIDs.getExternalIdentifier().get(0).getRelationship());
    assertEquals(workIDs.getExternalIdentifier().get(0).getType(), workIDs2.getExternalIdentifier().get(0).getType());
    assertEquals(workIDs.getExternalIdentifier().get(0).getValue(), workIDs2.getExternalIdentifier().get(0).getValue());
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) Record(org.orcid.jaxb.model.record_v2.Record) Url(org.orcid.jaxb.model.common_v2.Url) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) MarshallingTest(org.orcid.jaxb.model.notification.custom.MarshallingTest) Test(org.junit.Test)

Example 73 with Record

use of nikita.common.model.noark5.v4.Record in project ORCID-Source by ORCID.

the class ValidateV2RC2SamplesTest method testMarshallRecord.

@Test
public void testMarshallRecord() throws JAXBException, SAXException, URISyntaxException {
    Record object = (Record) unmarshallFromPath("/record_2.0_rc2/samples/record-2.0_rc2.xml", Record.class);
    marshall(object, "/record_2.0_rc2/record-2.0_rc2.xsd");
}
Also used : Record(org.orcid.jaxb.model.record_rc2.Record) Test(org.junit.Test)

Example 74 with Record

use of nikita.common.model.noark5.v4.Record in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegatorImpl method viewRecord.

@Override
public Response viewRecord(String orcid) {
    Record record = recordManagerReadOnly.getRecord(orcid);
    orcidSecurityManager.checkAndFilter(orcid, record);
    if (record.getPerson() != null) {
        sourceUtils.setSourceName(record.getPerson());
    }
    if (record.getActivitiesSummary() != null) {
        ActivityUtils.cleanEmptyFields(record.getActivitiesSummary());
        sourceUtils.setSourceName(record.getActivitiesSummary());
    }
    ElementUtils.setPathToRecord(record, orcid);
    Api2_0_LastModifiedDatesHelper.calculateLastModified(record);
    return Response.ok(record).build();
}
Also used : GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) Record(org.orcid.jaxb.model.record_v2.Record)

Example 75 with Record

use of nikita.common.model.noark5.v4.Record in project ORCID-Source by ORCID.

the class RecordTest method testViewRecordFromMemberAPI.

@Test
public void testViewRecordFromMemberAPI() throws InterruptedException, JSONException {
    String accessToken = getAccessToken();
    assertNotNull(accessToken);
    ClientResponse response = memberV2ApiClient.viewRecord(getUser1OrcidId(), accessToken);
    assertNotNull(response);
    assertEquals("invalid " + response, 200, response.getStatus());
    Record record = response.getEntity(Record.class);
    assertNotNull(record);
    assertNotNull(record.getOrcidIdentifier());
    assertEquals(getUser1OrcidId(), record.getOrcidIdentifier().getPath());
    //Check the visibility of every activity that exists
    if (record.getActivitiesSummary() != null) {
        //Educations
        if (record.getActivitiesSummary().getEducations() != null) {
            Educations e = record.getActivitiesSummary().getEducations();
            if (e.getSummaries() != null) {
                for (EducationSummary s : e.getSummaries()) {
                    assertNotNull(s.getSource());
                    assertNotNull(s.getVisibility());
                    Visibility v = s.getVisibility();
                    //If the visibility is PRIVATE the client should be the owner
                    if (Visibility.PRIVATE.equals(v)) {
                        assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        //Employments
        if (record.getActivitiesSummary().getEmployments() != null) {
            Employments e = record.getActivitiesSummary().getEmployments();
            if (e.getSummaries() != null) {
                for (EmploymentSummary s : e.getSummaries()) {
                    assertNotNull(s.getSource());
                    assertNotNull(s.getVisibility());
                    Visibility v = s.getVisibility();
                    //If the visibility is PRIVATE the client should be the owner
                    if (Visibility.PRIVATE.equals(v)) {
                        assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        //Fundings
        if (record.getActivitiesSummary().getFundings() != null) {
            Fundings f = record.getActivitiesSummary().getFundings();
            List<FundingGroup> groups = f.getFundingGroup();
            if (groups != null) {
                for (FundingGroup fGroup : groups) {
                    List<FundingSummary> summaries = fGroup.getFundingSummary();
                    if (summaries != null) {
                        for (FundingSummary s : summaries) {
                            assertNotNull(s.getSource());
                            assertNotNull(s.getVisibility());
                            Visibility v = s.getVisibility();
                            //If the visibility is PRIVATE the client should be the owner
                            if (Visibility.PRIVATE.equals(v)) {
                                assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
                            }
                        }
                    }
                }
            }
        }
        //PeerReviews
        if (record.getActivitiesSummary().getPeerReviews() != null) {
            PeerReviews p = record.getActivitiesSummary().getPeerReviews();
            List<PeerReviewGroup> groups = p.getPeerReviewGroup();
            if (groups != null) {
                for (PeerReviewGroup pGroup : groups) {
                    List<PeerReviewSummary> summaries = pGroup.getPeerReviewSummary();
                    if (summaries != null) {
                        for (PeerReviewSummary s : summaries) {
                            assertNotNull(s.getSource());
                            assertNotNull(s.getVisibility());
                            Visibility v = s.getVisibility();
                            //If the visibility is PRIVATE the client should be the owner
                            if (Visibility.PRIVATE.equals(v)) {
                                assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
                            }
                        }
                    }
                }
            }
        }
        //Works
        if (record.getActivitiesSummary().getWorks() != null) {
            Works w = record.getActivitiesSummary().getWorks();
            List<WorkGroup> groups = w.getWorkGroup();
            if (groups != null) {
                for (WorkGroup wGroup : groups) {
                    List<WorkSummary> summaries = wGroup.getWorkSummary();
                    if (summaries != null) {
                        for (WorkSummary s : summaries) {
                            assertNotNull(s.getSource());
                            assertNotNull(s.getVisibility());
                            Visibility v = s.getVisibility();
                            //If the visibility is PRIVATE the client should be the owner
                            if (Visibility.PRIVATE.equals(v)) {
                                assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
                            }
                        }
                    }
                }
            }
        }
    }
    //Check the visibility of every biography elements that exists
    if (record.getPerson() != null) {
        //Address
        if (record.getPerson().getAddresses() != null) {
            Addresses addresses = record.getPerson().getAddresses();
            List<Address> list = addresses.getAddress();
            if (list != null) {
                for (Address o : list) {
                    assertNotNull(o.getSource());
                    assertNotNull(o.getVisibility());
                    Visibility v = o.getVisibility();
                    //If the visibility is PRIVATE the client should be the owner
                    if (Visibility.PRIVATE.equals(v)) {
                        assertEquals(getClient1ClientId(), o.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        //Biography
        if (record.getPerson().getBiography() != null) {
            Biography b = record.getPerson().getBiography();
            if (b != null) {
                assertNotNull(b.getVisibility());
                if (Visibility.PRIVATE.equals(b.getVisibility())) {
                    fail("Visibility is private");
                }
            }
        }
        //Emails
        if (record.getPerson().getEmails() != null) {
            Emails emails = record.getPerson().getEmails();
            List<Email> list = emails.getEmails();
            if (list != null) {
                for (Email e : list) {
                    assertNotNull(e.getVisibility());
                    if (Visibility.PRIVATE.equals(e.getVisibility())) {
                        fail("Email " + e.getEmail() + " is private");
                    }
                }
            }
        }
        //External identifiers
        if (record.getPerson().getExternalIdentifiers() != null) {
            PersonExternalIdentifiers extIds = record.getPerson().getExternalIdentifiers();
            List<PersonExternalIdentifier> list = extIds.getExternalIdentifiers();
            if (list != null) {
                for (PersonExternalIdentifier e : list) {
                    assertNotNull(e.getVisibility());
                    if (Visibility.PRIVATE.equals(e.getVisibility())) {
                        assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        //Keywords
        if (record.getPerson().getKeywords() != null) {
            Keywords keywords = record.getPerson().getKeywords();
            List<Keyword> list = keywords.getKeywords();
            if (list != null) {
                for (Keyword e : list) {
                    assertNotNull(e.getVisibility());
                    if (Visibility.PRIVATE.equals(e.getVisibility())) {
                        assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        //Name
        if (record.getPerson().getName() != null) {
            Name name = record.getPerson().getName();
            if (Visibility.PRIVATE.equals(name.getVisibility())) {
                fail("Name is private");
            }
        }
        //Other names
        if (record.getPerson().getOtherNames() != null) {
            OtherNames otherNames = record.getPerson().getOtherNames();
            List<OtherName> list = otherNames.getOtherNames();
            if (list != null) {
                for (OtherName e : list) {
                    assertNotNull(e.getVisibility());
                    if (Visibility.PRIVATE.equals(e.getVisibility())) {
                        assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        //Researcher urls
        if (record.getPerson().getResearcherUrls() != null) {
            ResearcherUrls rUrls = record.getPerson().getResearcherUrls();
            List<ResearcherUrl> list = rUrls.getResearcherUrls();
            if (list != null) {
                for (ResearcherUrl e : list) {
                    assertNotNull(e.getVisibility());
                    if (Visibility.PRIVATE.equals(e.getVisibility())) {
                        assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
                    }
                }
            }
        }
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Email(org.orcid.jaxb.model.record_rc3.Email) Keywords(org.orcid.jaxb.model.record_rc3.Keywords) Address(org.orcid.jaxb.model.record_rc3.Address) Fundings(org.orcid.jaxb.model.record.summary_rc3.Fundings) OtherNames(org.orcid.jaxb.model.record_rc3.OtherNames) PeerReviews(org.orcid.jaxb.model.record.summary_rc3.PeerReviews) OtherName(org.orcid.jaxb.model.record_rc3.OtherName) Name(org.orcid.jaxb.model.record_rc3.Name) Addresses(org.orcid.jaxb.model.record_rc3.Addresses) WorkGroup(org.orcid.jaxb.model.record.summary_rc3.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_rc3.WorkSummary) FundingSummary(org.orcid.jaxb.model.record.summary_rc3.FundingSummary) Biography(org.orcid.jaxb.model.record_rc3.Biography) ResearcherUrls(org.orcid.jaxb.model.record_rc3.ResearcherUrls) Record(org.orcid.jaxb.model.record_rc3.Record) ResearcherUrl(org.orcid.jaxb.model.record_rc3.ResearcherUrl) Emails(org.orcid.jaxb.model.record_rc3.Emails) Works(org.orcid.jaxb.model.record.summary_rc3.Works) PeerReviewGroup(org.orcid.jaxb.model.record.summary_rc3.PeerReviewGroup) Keyword(org.orcid.jaxb.model.record_rc3.Keyword) OtherName(org.orcid.jaxb.model.record_rc3.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc3.PersonExternalIdentifier) FundingGroup(org.orcid.jaxb.model.record.summary_rc3.FundingGroup) Employments(org.orcid.jaxb.model.record.summary_rc3.Employments) PersonExternalIdentifiers(org.orcid.jaxb.model.record_rc3.PersonExternalIdentifiers) EducationSummary(org.orcid.jaxb.model.record.summary_rc3.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.record.summary_rc3.PeerReviewSummary) Educations(org.orcid.jaxb.model.record.summary_rc3.Educations) EmploymentSummary(org.orcid.jaxb.model.record.summary_rc3.EmploymentSummary) Visibility(org.orcid.jaxb.model.common_rc3.Visibility) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)60 Record (org.orcid.jaxb.model.record_v2.Record)49 Counted (com.codahale.metrics.annotation.Counted)28 ApiOperation (io.swagger.annotations.ApiOperation)27 ApiResponses (io.swagger.annotations.ApiResponses)27 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)21 Person (org.orcid.jaxb.model.record_v2.Person)20 Record (nikita.model.noark5.v4.Record)19 Email (org.orcid.jaxb.model.record_v2.Email)19 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)18 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)18 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)18 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)18 Address (org.orcid.jaxb.model.record_v2.Address)18 Keyword (org.orcid.jaxb.model.record_v2.Keyword)18 OtherName (org.orcid.jaxb.model.record_v2.OtherName)18 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)18 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)18 Name (org.orcid.jaxb.model.record_v2.Name)17 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)16