Search in sources :

Example 96 with Name

use of org.openmuc.jasn1.compiler.modules.module1.Name in project ORCID-Source by ORCID.

the class RDFWriterTest method fakeBio.

private Record fakeBio() throws DatatypeConfigurationException {
    Record r = new Record();
    r.setOrcidIdentifier(new OrcidIdentifier());
    r.getOrcidIdentifier().setPath("000-1337");
    r.getOrcidIdentifier().setUri("http://orcid.example.com/000-1337");
    r.setHistory(new History());
    r.getHistory().setCreationMethod(CreationMethod.WEBSITE);
    XMLGregorianCalendar value = dataTypeFactory.newXMLGregorianCalendar(1980, 12, 31, 23, 29, 29, 999, 0);
    r.getHistory().setLastModifiedDate(new LastModifiedDate(value));
    r.getHistory().setClaimed(true);
    r.setPerson(new Person());
    r.getPerson().setBiography(new Biography());
    r.getPerson().setName(new Name());
    r.getPerson().getName().setFamilyName(new FamilyName("Doe"));
    r.getPerson().getName().setCreditName(new CreditName("John F Doe"));
    r.getPerson().getName().setGivenNames(new GivenNames("John"));
    r.getPerson().setOtherNames(new OtherNames());
    r.getPerson().getOtherNames().setOtherNames(new ArrayList<OtherName>());
    OtherName n = new OtherName();
    n.setContent("Johnny");
    n.setVisibility(Visibility.PUBLIC);
    OtherName n1 = new OtherName();
    n1.setContent("Mr Doe");
    n1.setVisibility(Visibility.PUBLIC);
    r.getPerson().getOtherNames().getOtherNames().add(n);
    r.getPerson().getOtherNames().getOtherNames().add(n1);
    r.getPerson().setResearcherUrls(new ResearcherUrls());
    r.getPerson().getResearcherUrls().setResearcherUrls(new ArrayList<ResearcherUrl>());
    ResearcherUrl anonymous = new ResearcherUrl();
    anonymous.setUrl(new Url("http://example.com/anon"));
    anonymous.setVisibility(Visibility.PUBLIC);
    r.getPerson().getResearcherUrls().getResearcherUrls().add(anonymous);
    r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/myPage", "homePage"));
    r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/foaf#me", "FOAF"));
    r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/webId", "webID"));
    r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/other", "other"));
    r.getPerson().setAddresses(new Addresses());
    r.getPerson().getAddresses().setAddress(new ArrayList<Address>());
    Address a = new Address();
    a.setCountry(new Country());
    a.getCountry().setValue(Iso3166Country.GB);
    r.getPerson().getAddresses().getAddress().add(a);
    r.getPerson().setEmails(new Emails());
    r.getPerson().getEmails().setEmails(new ArrayList<Email>());
    Email e = new Email();
    e.setEmail("john@example.org");
    e.setCurrent(true);
    Email e1 = new Email();
    e1.setEmail("doe@example.com");
    e1.setCurrent(true);
    r.getPerson().getEmails().getEmails().add(e);
    r.getPerson().getEmails().getEmails().add(e1);
    return r;
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Email(org.orcid.jaxb.model.record_v2.Email) Address(org.orcid.jaxb.model.record_v2.Address) FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) History(org.orcid.jaxb.model.record_v2.History) Url(org.orcid.jaxb.model.common_v2.Url) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) CreditName(org.orcid.jaxb.model.common_v2.CreditName) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Addresses(org.orcid.jaxb.model.record_v2.Addresses) OrcidIdentifier(org.orcid.jaxb.model.common_v2.OrcidIdentifier) GivenNames(org.orcid.jaxb.model.record_v2.GivenNames) Biography(org.orcid.jaxb.model.record_v2.Biography) ResearcherUrls(org.orcid.jaxb.model.record_v2.ResearcherUrls) Record(org.orcid.jaxb.model.record_v2.Record) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Emails(org.orcid.jaxb.model.record_v2.Emails) CreditName(org.orcid.jaxb.model.common_v2.CreditName) OtherName(org.orcid.jaxb.model.record_v2.OtherName) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Country(org.orcid.jaxb.model.common_v2.Country) Iso3166Country(org.orcid.jaxb.model.common_v2.Iso3166Country) Person(org.orcid.jaxb.model.record_v2.Person)

Example 97 with Name

use of org.openmuc.jasn1.compiler.modules.module1.Name 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)

Example 98 with Name

use of org.openmuc.jasn1.compiler.modules.module1.Name 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_rc4.Email) Keywords(org.orcid.jaxb.model.record_rc4.Keywords) Address(org.orcid.jaxb.model.record_rc4.Address) Fundings(org.orcid.jaxb.model.record.summary_rc4.Fundings) OtherNames(org.orcid.jaxb.model.record_rc4.OtherNames) PeerReviews(org.orcid.jaxb.model.record.summary_rc4.PeerReviews) OtherName(org.orcid.jaxb.model.record_rc4.OtherName) Name(org.orcid.jaxb.model.record_rc4.Name) Addresses(org.orcid.jaxb.model.record_rc4.Addresses) WorkGroup(org.orcid.jaxb.model.record.summary_rc4.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_rc4.WorkSummary) FundingSummary(org.orcid.jaxb.model.record.summary_rc4.FundingSummary) Biography(org.orcid.jaxb.model.record_rc4.Biography) ResearcherUrls(org.orcid.jaxb.model.record_rc4.ResearcherUrls) Record(org.orcid.jaxb.model.record_rc4.Record) ResearcherUrl(org.orcid.jaxb.model.record_rc4.ResearcherUrl) Emails(org.orcid.jaxb.model.record_rc4.Emails) Works(org.orcid.jaxb.model.record.summary_rc4.Works) PeerReviewGroup(org.orcid.jaxb.model.record.summary_rc4.PeerReviewGroup) Keyword(org.orcid.jaxb.model.record_rc4.Keyword) OtherName(org.orcid.jaxb.model.record_rc4.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier) FundingGroup(org.orcid.jaxb.model.record.summary_rc4.FundingGroup) Employments(org.orcid.jaxb.model.record.summary_rc4.Employments) PersonExternalIdentifiers(org.orcid.jaxb.model.record_rc4.PersonExternalIdentifiers) EducationSummary(org.orcid.jaxb.model.record.summary_rc4.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.record.summary_rc4.PeerReviewSummary) Educations(org.orcid.jaxb.model.record.summary_rc4.Educations) EmploymentSummary(org.orcid.jaxb.model.record.summary_rc4.EmploymentSummary) Visibility(org.orcid.jaxb.model.common_rc4.Visibility) Test(org.junit.Test)

Example 99 with Name

use of org.openmuc.jasn1.compiler.modules.module1.Name in project ORCID-Source by ORCID.

the class RecordTest method testViewRecordFromPublicAPI.

@Test
public void testViewRecordFromPublicAPI() {
    ClientResponse response = publicV2ApiClient.viewRecordXML(getUser1OrcidId());
    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) {
        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());
                        assertEquals(Visibility.PUBLIC, s.getVisibility());
                    }
                }
            }
            // Employments
            if (record.getActivitiesSummary().getEmployments() != null) {
                Employments e = record.getActivitiesSummary().getEmployments();
                if (e.getSummaries() != null) {
                    for (EmploymentSummary s : e.getSummaries()) {
                        assertNotNull(s.getSource());
                        assertEquals(Visibility.PUBLIC, s.getVisibility());
                    }
                }
            }
            // 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());
                                assertEquals(Visibility.PUBLIC, s.getVisibility());
                            }
                        }
                    }
                }
            }
            // 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());
                                assertEquals(Visibility.PUBLIC, s.getVisibility());
                            }
                        }
                    }
                }
            }
            // 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());
                                assertEquals(Visibility.PUBLIC, s.getVisibility());
                            }
                        }
                    }
                }
            }
        }
    }
    // 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());
                    assertEquals(Visibility.PUBLIC, o.getVisibility());
                }
            }
        }
        // Biography
        if (record.getPerson().getBiography() != null) {
            Biography b = record.getPerson().getBiography();
            if (b != null) {
                assertNotNull(b.getVisibility());
                assertEquals(Visibility.PUBLIC, b.getVisibility());
            }
        }
        // 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());
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
        // External identifiers
        if (record.getPerson().getExternalIdentifiers() != null) {
            PersonExternalIdentifiers extIds = record.getPerson().getExternalIdentifiers();
            List<PersonExternalIdentifier> list = extIds.getExternalIdentifiers();
            if (list != null) {
                for (PersonExternalIdentifier e : list) {
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
        // Keywords
        if (record.getPerson().getKeywords() != null) {
            Keywords keywords = record.getPerson().getKeywords();
            List<Keyword> list = keywords.getKeywords();
            if (list != null) {
                for (Keyword e : list) {
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
        // Name
        if (record.getPerson().getName() != null) {
            Name name = record.getPerson().getName();
            assertEquals(Visibility.PUBLIC, name.getVisibility());
        }
        // Other names
        if (record.getPerson().getOtherNames() != null) {
            OtherNames otherNames = record.getPerson().getOtherNames();
            List<OtherName> list = otherNames.getOtherNames();
            if (list != null) {
                for (OtherName e : list) {
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
        // Researcher urls
        if (record.getPerson().getResearcherUrls() != null) {
            ResearcherUrls rUrls = record.getPerson().getResearcherUrls();
            List<ResearcherUrl> list = rUrls.getResearcherUrls();
            if (list != null) {
                for (ResearcherUrl e : list) {
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Email(org.orcid.jaxb.model.record_v2.Email) Keywords(org.orcid.jaxb.model.record_v2.Keywords) Address(org.orcid.jaxb.model.record_v2.Address) Fundings(org.orcid.jaxb.model.record.summary_v2.Fundings) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) PeerReviews(org.orcid.jaxb.model.record.summary_v2.PeerReviews) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Addresses(org.orcid.jaxb.model.record_v2.Addresses) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) Biography(org.orcid.jaxb.model.record_v2.Biography) ResearcherUrls(org.orcid.jaxb.model.record_v2.ResearcherUrls) Record(org.orcid.jaxb.model.record_v2.Record) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Emails(org.orcid.jaxb.model.record_v2.Emails) Works(org.orcid.jaxb.model.record.summary_v2.Works) PeerReviewGroup(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup) Keyword(org.orcid.jaxb.model.record_v2.Keyword) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) FundingGroup(org.orcid.jaxb.model.record.summary_v2.FundingGroup) Employments(org.orcid.jaxb.model.record.summary_v2.Employments) PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) EducationSummary(org.orcid.jaxb.model.record.summary_v2.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) Educations(org.orcid.jaxb.model.record.summary_v2.Educations) EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary) Test(org.junit.Test)

Example 100 with Name

use of org.openmuc.jasn1.compiler.modules.module1.Name in project CIM-Identities by epri-dev.

the class CIMWebService method submitData.

// Method name:  submitData
// Parameters:  n_nameNew, nt_nameNew, nt_desNew, nta_nameNew, nta_desNew, mRID, action, gen_uuidSel
// Purpose:  Submits data for either insertion, deletion, or modification
public String submitData(String n_nameNew, String nt_nameNew, String nt_desNew, String nta_nameNew, String nta_desNew, String mRID, String action, boolean gen_uuidSel) {
    ch.iec.tc57._2016.cimidentitiesmessage.CIMIdentitiesEventMessageType msg = new ch.iec.tc57._2016.cimidentitiesmessage.CIMIdentitiesEventMessageType();
    ch.iec.tc57._2016.cimidentitiesmessage.CIMIdentitiesResponseMessageType resp = new ch.iec.tc57._2016.cimidentitiesmessage.CIMIdentitiesResponseMessageType();
    CIMIdentitiesPayloadType payload = new CIMIdentitiesPayloadType();
    CIMIdentities cimids = new CIMIdentities();
    CIMIdentity cimid = new CIMIdentity();
    payload.setCIMIdentities(cimids);
    ArrayList<CIMIdentity> cim = (ArrayList<CIMIdentity>) payload.getCIMIdentities().getCIMIdentity();
    IdentifiedObject value = new IdentifiedObject();
    value.setMRID(mRID);
    cimid.setIdentifiedObject(value);
    String error = new String();
    Name name = new Name();
    name.setName(n_nameNew);
    if (action.equals("delete"))
        name.setName("");
    if (name.getName() == null)
        name.setName("");
    cimid.getNames().add(name);
    // set NameType name/description
    NameType nameType = new NameType();
    nameType.setDescription(nt_desNew);
    if (action.equals("delete"))
        nameType.setDescription("");
    if (nameType.getDescription() == null)
        nameType.setDescription("");
    nameType.setName(nt_nameNew);
    if (action.equals("delete"))
        nameType.setName("");
    if (nameType.getName() == null)
        nameType.setName("");
    cimid.getNames().get(0).setNameType(nameType);
    // set NameTypeAuthority name/description
    NameTypeAuthority nameTypeAuth = new NameTypeAuthority();
    nameTypeAuth.setDescription(nta_desNew);
    if (action.equals("delete"))
        nameTypeAuth.setDescription("");
    if (nameTypeAuth.getDescription() == null)
        nameTypeAuth.setDescription("");
    nameTypeAuth.setName(nta_nameNew);
    if (action.equals("delete"))
        nameTypeAuth.setName("");
    if (nameTypeAuth.getName() == null)
        nameTypeAuth.setDescription("");
    cimid.getNames().get(0).getNameType().setNameTypeAuthority(nameTypeAuth);
    cim.add(cimid);
    msg.setPayload(payload);
    /* Insertion handling */
    if (action.equals("insert")) {
        if (gen_uuidSel == true) {
            value.setMRID("");
            payload.getCIMIdentities().getCIMIdentity().get(0).setIdentifiedObject(value);
            msg.setPayload(payload);
        }
        HeaderType header = new HeaderType();
        header.setNoun("CIMIdentities");
        header.setVerb("create");
        msg.setHeader(header);
        try {
            resp = createdCIMIdentitiesRequest(msg);
            String confirmation = "Data inserted:<br>" + "<br><strong>Name:</strong> " + resp.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getName() + "<br><strong>NameType Name:</strong> " + resp.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getName() + "<br><strong>NameType Description:</strong> " + resp.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getDescription() + "<br><strong>NameTypeAuthority Name:</strong> " + resp.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getName() + "<br><strong>NameTypeAuthority Description:</strong> " + resp.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getDescription() + "<br><strong>mRID:</strong>  " + resp.getPayload().getCIMIdentities().getCIMIdentity().get(0).getIdentifiedObject().getMRID();
            return confirmation;
        } catch (FaultMessage ex) {
            resp.getReply().getError().get(0).setDetails(ex.getMessage());
            return resp.getReply().getError().get(0).getDetails();
        }
    } else /* deletion handling */
    if (action.equals("delete") && gen_uuidSel == true) {
        uuidEntered = true;
        HeaderType header = new HeaderType();
        header.setNoun("CIMIdentities");
        header.setVerb("delete");
        msg.setHeader(header);
        /* query the server for the mRID being deleted */
        CIMIdentitiesQueriesRequestType request = new CIMIdentitiesQueriesRequestType();
        CIMIdentitiesQueries var = new CIMIdentitiesQueries();
        EndDeviceGroup edg = new EndDeviceGroup();
        // can be null, '?', or '""' to receive all data, else set mRID
        edg.setMRID(mRID);
        message.setRequest(request);
        message.getRequest().setCIMIdentitiesQueries(var);
        message.getRequest().getCIMIdentitiesQueries().getEndDeviceGroup().add(0, edg);
        message.getRequest().getCIMIdentitiesQueries().getEndDeviceGroup();
        try {
            response = queryCIMIdentities(message);
        } catch (QueryCIMIdentitiesFaultMessage ex) {
            return ex.getMessage();
        }
        /* set outgoing deletion message to contain ALL data about the mRID */
        msg.getPayload().setCIMIdentities(response.getPayload().getCIMIdentities());
        try {
            if (response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getIdentifiedObject().getMRID() == null)
                throw new IndexOutOfBoundsException("mRID doesn't exist");
            deletedCIMIdentitiesRequest(msg);
            String confirmation = "Data deleted:<br>" + "<br><strong>mRID:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getIdentifiedObject().getMRID() + "<br><strong>Name:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getName() + "<br><strong>NameType Name:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getName() + "<br><strong>NameType Description:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getDescription() + "<br><strong>NameTypeAuthority Name:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getName() + "<br><strong>NameTypeAuthority Description:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getDescription();
            return confirmation;
        } catch (FaultMessage ex) {
            error = ex.getMessage();
            return error;
        } catch (IndexOutOfBoundsException err) {
            return "<p style=\"color:red\"><strong>No deletion made.<br>Provided UUID does not currently exist in the database</strong>.<br>Please double check input UUID.<br>";
        }
    } else /* modification handling */
    if (action.equals("modify")) {
        HeaderType header = new HeaderType();
        header.setNoun("CIMIdentities");
        header.setVerb("change");
        msg.setHeader(header);
        /* query the server for the mRID being modified */
        CIMIdentitiesQueriesRequestType request = new CIMIdentitiesQueriesRequestType();
        CIMIdentitiesQueries var = new CIMIdentitiesQueries();
        EndDeviceGroup edg = new EndDeviceGroup();
        // can be null, '?', or '""' to receive all data, else set mRID
        edg.setMRID(mRID);
        message.setRequest(request);
        message.getRequest().setCIMIdentitiesQueries(var);
        message.getRequest().getCIMIdentitiesQueries().getEndDeviceGroup().add(0, edg);
        message.getRequest().getCIMIdentitiesQueries().getEndDeviceGroup();
        try {
            response = queryCIMIdentities(message);
        } catch (QueryCIMIdentitiesFaultMessage ex) {
            return response.getReply().getError().get(0).getDetails();
        }
        try {
            if (response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getIdentifiedObject().getMRID() == null)
                throw new IndexOutOfBoundsException("mRID doesn't exist");
            changedCIMIdentitiesRequest(msg);
            String confirmation = "Data modified:<br>" + "<strong>Previous data:</strong><br>" + "<br><strong>mRID:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getIdentifiedObject().getMRID() + "<br><strong>Name:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getName() + "<br><strong>NameType Name:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getName() + "<br><strong>NameType Description:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getDescription() + "<br><strong>NameTypeAuthority Name:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getName() + "<br><strong>NameTypeAuthority Description:</strong> " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getDescription() + "<br><br><br><strong>New data:</strong><br>" + "<br><strong>Name:</strong> " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getName() + "<br><strong>NameType Name:</strong> " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getName() + "<br><strong>NameType Description:</strong> " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getDescription() + "<br><strong>NameTypeAuthority Name:</strong> " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getName() + "<br><strong>NameTypeAuthority Description:</strong> " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getDescription();
            return confirmation;
        } catch (FaultMessage ex) {
            error = ex.getMessage();
            return error;
        } catch (IndexOutOfBoundsException err) {
            return "<p style=\"color:red\"><strong>Provided UUID does not currently exist in the database</strong>.<br>Please double check input UUID.<br>";
        }
    } else
        return "Error:  Invalid response received.\n";
}
Also used : CIMIdentitiesQueries(ch.iec.tc57._2016.cimidentitiesqueries_.CIMIdentitiesQueries) ArrayList(java.util.ArrayList) NameType(com.epri._2016.cimidentities_.NameType) Name(com.epri._2016.cimidentities_.Name) QueryCIMIdentitiesFaultMessage(ch.iec.tc57._2016.querycimidentities.QueryCIMIdentitiesFaultMessage) CIMIdentitiesQueriesRequestType(ch.iec.tc57._2016.cimidentitiesqueriesmessage.CIMIdentitiesQueriesRequestType) EndDeviceGroup(ch.iec.tc57._2016.cimidentitiesqueries_.EndDeviceGroup) CIMIdentitiesResponseMessageType(ch.iec.tc57._2016.cimidentitiesmessage.CIMIdentitiesResponseMessageType) CIMIdentitiesPayloadType(ch.iec.tc57._2016.cimidentitiesmessage.CIMIdentitiesPayloadType) CIMIdentity(com.epri._2016.cimidentities_.CIMIdentity) CIMIdentitiesResponseMessageType(ch.iec.tc57._2016.cimidentitiesmessage.CIMIdentitiesResponseMessageType) NameTypeAuthority(com.epri._2016.cimidentities_.NameTypeAuthority) FaultMessage(ch.iec.tc57._2016.sendcimidentities.FaultMessage) QueryCIMIdentitiesFaultMessage(ch.iec.tc57._2016.querycimidentities.QueryCIMIdentitiesFaultMessage) HeaderType(ch.iec.tc57._2011.schema.message.HeaderType) IdentifiedObject(com.epri._2016.cimidentities_.IdentifiedObject) CIMIdentities(com.epri._2016.cimidentities_.CIMIdentities)

Aggregations

Test (org.junit.Test)78 Name (org.orcid.jaxb.model.record_v2.Name)74 OtherName (org.orcid.jaxb.model.record_v2.OtherName)62 Biography (org.orcid.jaxb.model.record_v2.Biography)46 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)41 Address (org.orcid.jaxb.model.record_v2.Address)31 Email (org.orcid.jaxb.model.record_v2.Email)30 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)30 Addresses (org.orcid.jaxb.model.record_v2.Addresses)29 Emails (org.orcid.jaxb.model.record_v2.Emails)29 Keyword (org.orcid.jaxb.model.record_v2.Keyword)29 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)29 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)29 Keywords (org.orcid.jaxb.model.record_v2.Keywords)28 Person (org.orcid.jaxb.model.record_v2.Person)28 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)28 Record (org.orcid.jaxb.model.record_v2.Record)19 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)18 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)17 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)17