Search in sources :

Example 6 with ResearcherUrl

use of org.orcid.jaxb.model.message.ResearcherUrl in project ORCID-Source by ORCID.

the class T2OrcidApiServiceDelegatorTest method testDefaultPrivacyOnBio.

@Test
public void testDefaultPrivacyOnBio() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4499", ScopePathType.ORCID_BIO_UPDATE);
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4499"));
    orcidMessage.setOrcidProfile(orcidProfile);
    OrcidBio orcidBio = new OrcidBio();
    orcidProfile.setOrcidBio(orcidBio);
    PersonalDetails personalDetails = new PersonalDetails();
    orcidBio.setPersonalDetails(personalDetails);
    GivenNames givenNames = new GivenNames("Test given names");
    personalDetails.setGivenNames(givenNames);
    CreditName creditName = new CreditName("Credit Name");
    personalDetails.setCreditName(creditName);
    ExternalIdentifier id = new ExternalIdentifier();
    id.setExternalIdCommonName(new ExternalIdCommonName("cn1"));
    id.setExternalIdReference(new ExternalIdReference("value1"));
    orcidBio.setExternalIdentifiers(new ExternalIdentifiers());
    orcidBio.getExternalIdentifiers().getExternalIdentifier().add(id);
    personalDetails.setOtherNames(new OtherNames());
    personalDetails.getOtherNames().addOtherName("on1", null);
    orcidBio.setKeywords(new Keywords());
    orcidBio.getKeywords().getKeyword().add(new Keyword("kw1", null));
    orcidBio.setResearcherUrls(new ResearcherUrls());
    orcidBio.getResearcherUrls().getResearcherUrl().add(new ResearcherUrl(new Url("http://rurl2.com"), null));
    t2OrcidApiServiceDelegator.updateBioDetails(mockedUriInfo, "4444-4444-4444-4499", orcidMessage);
    OrcidProfile p = orcidProfileManager.retrieveOrcidProfile("4444-4444-4444-4499");
    assertEquals("cn1", p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
    assertEquals(Visibility.PUBLIC, p.getOrcidBio().getExternalIdentifiers().getVisibility());
    assertEquals("on1", p.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().get(0).getContent());
    assertEquals(Visibility.PUBLIC, p.getOrcidBio().getPersonalDetails().getOtherNames().getVisibility());
    assertEquals("kw1", p.getOrcidBio().getKeywords().getKeyword().get(0).getContent());
    assertEquals(Visibility.PUBLIC, p.getOrcidBio().getKeywords().getVisibility());
    assertEquals(new Url("http://rurl2.com"), p.getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).getUrl());
    assertEquals(Visibility.PUBLIC, p.getOrcidBio().getResearcherUrls().getVisibility());
//now test what happens if we add a new one.
}
Also used : Keywords(org.orcid.jaxb.model.message.Keywords) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) ExternalIdReference(org.orcid.jaxb.model.message.ExternalIdReference) Keyword(org.orcid.jaxb.model.message.Keyword) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) FundingExternalIdentifier(org.orcid.jaxb.model.message.FundingExternalIdentifier) OtherNames(org.orcid.jaxb.model.message.OtherNames) CreditName(org.orcid.jaxb.model.message.CreditName) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) ExternalIdUrl(org.orcid.jaxb.model.message.ExternalIdUrl) Url(org.orcid.jaxb.model.message.Url) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ExternalIdCommonName(org.orcid.jaxb.model.message.ExternalIdCommonName) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) GivenNames(org.orcid.jaxb.model.message.GivenNames) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) ResearcherUrls(org.orcid.jaxb.model.message.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) FundingExternalIdentifiers(org.orcid.jaxb.model.message.FundingExternalIdentifiers) ExternalIdentifiers(org.orcid.jaxb.model.message.ExternalIdentifiers) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 7 with ResearcherUrl

use of org.orcid.jaxb.model.message.ResearcherUrl in project ORCID-Source by ORCID.

the class OrcidProfileManagerImpl method addDefaultVisibilityToBioItems.

private void addDefaultVisibilityToBioItems(OrcidProfile orcidProfile, Visibility defaultActivityVis, Boolean isClaimed) {
    if (defaultActivityVis == null) {
        defaultActivityVis = Visibility.PRIVATE;
    }
    if (isClaimed == null) {
        isClaimed = false;
    }
    if (orcidProfile.getOrcidBio() != null) {
        if (orcidProfile.getOrcidBio().getBiography() != null) {
            if (isClaimed) {
                orcidProfile.getOrcidBio().getBiography().setVisibility(defaultActivityVis);
            } else {
                Visibility visibility = orcidProfile.getOrcidBio().getBiography().getVisibility();
                orcidProfile.getOrcidBio().getBiography().setVisibility(visibility != null ? visibility : Visibility.PRIVATE);
            }
        }
        if (orcidProfile.getOrcidBio().getExternalIdentifiers() != null) {
            Visibility listVisibility = orcidProfile.getOrcidBio().getExternalIdentifiers().getVisibility();
            for (ExternalIdentifier x : orcidProfile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier()) {
                if (isClaimed) {
                    x.setVisibility(defaultActivityVis);
                } else {
                    x.setVisibility(listVisibility != null ? listVisibility : Visibility.PRIVATE);
                }
            }
        }
        if (orcidProfile.getOrcidBio().getKeywords() != null) {
            Visibility listVisibility = orcidProfile.getOrcidBio().getKeywords().getVisibility();
            for (Keyword x : orcidProfile.getOrcidBio().getKeywords().getKeyword()) {
                if (isClaimed) {
                    x.setVisibility(defaultActivityVis);
                } else {
                    x.setVisibility(listVisibility != null ? listVisibility : Visibility.PRIVATE);
                }
            }
        }
        if (orcidProfile.getOrcidBio().getResearcherUrls() != null) {
            Visibility listVisibility = orcidProfile.getOrcidBio().getResearcherUrls().getVisibility();
            for (ResearcherUrl x : orcidProfile.getOrcidBio().getResearcherUrls().getResearcherUrl()) {
                if (isClaimed) {
                    x.setVisibility(defaultActivityVis);
                } else {
                    x.setVisibility(listVisibility != null ? listVisibility : Visibility.PRIVATE);
                }
            }
        }
        if (orcidProfile.getOrcidBio().getPersonalDetails() != null && orcidProfile.getOrcidBio().getPersonalDetails().getOtherNames() != null) {
            Visibility listVisibility = orcidProfile.getOrcidBio().getPersonalDetails().getOtherNames().getVisibility();
            for (OtherName x : orcidProfile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName()) {
                if (isClaimed) {
                    x.setVisibility(defaultActivityVis);
                } else {
                    x.setVisibility(listVisibility != null ? listVisibility : Visibility.PRIVATE);
                }
            }
        }
        if (orcidProfile.getOrcidBio().getContactDetails() != null && orcidProfile.getOrcidBio().getContactDetails().getAddress() != null && orcidProfile.getOrcidBio().getContactDetails().getAddress().getCountry() != null) {
            Country country = orcidProfile.getOrcidBio().getContactDetails().getAddress().getCountry();
            if (isClaimed) {
                country.setVisibility(defaultActivityVis);
            } else {
                country.setVisibility(country.getVisibility() != null ? country.getVisibility() : Visibility.PRIVATE);
            }
        }
    }
}
Also used : Keyword(org.orcid.jaxb.model.message.Keyword) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) OtherName(org.orcid.jaxb.model.message.OtherName) Country(org.orcid.jaxb.model.message.Country) Visibility(org.orcid.jaxb.model.message.Visibility) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl)

Example 8 with ResearcherUrl

use of org.orcid.jaxb.model.message.ResearcherUrl in project ORCID-Source by ORCID.

the class OrcidMessageUtil method setSourceName.

public void setSourceName(OrcidProfile orcidProfile) {
    if (orcidProfile != null) {
        if (orcidProfile.getOrcidActivities() != null) {
            OrcidActivities orcidActivities = orcidProfile.getOrcidActivities();
            if (orcidActivities.getAffiliations() != null) {
                Affiliations affs = orcidActivities.getAffiliations();
                List<Affiliation> affList = affs.getAffiliation();
                if (affList != null) {
                    for (Affiliation aff : affList) {
                        setSourceName(aff);
                    }
                }
            }
            if (orcidActivities.getFundings() != null) {
                FundingList fundingList = orcidActivities.getFundings();
                List<Funding> fundings = fundingList.getFundings();
                if (fundings != null) {
                    for (Funding funding : fundings) {
                        setSourceName(funding);
                    }
                }
            }
            if (orcidActivities.getOrcidWorks() != null) {
                OrcidWorks orcidWorks = orcidActivities.getOrcidWorks();
                List<OrcidWork> works = orcidWorks.getOrcidWork();
                if (works != null) {
                    for (OrcidWork work : works) {
                        setSourceName(work);
                    }
                }
            }
        }
        if (orcidProfile.getOrcidBio() != null) {
            OrcidBio orcidBio = orcidProfile.getOrcidBio();
            if (orcidBio.getContactDetails() != null) {
                Address address = orcidBio.getContactDetails().getAddress();
                if (address != null) {
                    setSourceName(address);
                }
            }
            if (orcidBio.getExternalIdentifiers() != null) {
                ExternalIdentifiers extIds = orcidBio.getExternalIdentifiers();
                List<ExternalIdentifier> extIdsList = extIds.getExternalIdentifier();
                if (extIdsList != null) {
                    for (ExternalIdentifier extId : extIdsList) {
                        setSourceName(extId);
                    }
                }
            }
            if (orcidBio.getKeywords() != null) {
                Keywords keywords = orcidBio.getKeywords();
                List<Keyword> keywordList = keywords.getKeyword();
                if (keywordList != null) {
                    for (Keyword keyword : keywordList) {
                        setSourceName(keyword);
                    }
                }
            }
            if (orcidBio.getPersonalDetails() != null) {
                OtherNames otherNames = orcidBio.getPersonalDetails().getOtherNames();
                if (otherNames != null) {
                    List<OtherName> otherNameList = otherNames.getOtherName();
                    if (otherNameList != null) {
                        for (OtherName otherName : otherNameList) {
                            setSourceName(otherName);
                        }
                    }
                }
            }
            if (orcidBio.getResearcherUrls() != null) {
                ResearcherUrls rUrls = orcidBio.getResearcherUrls();
                List<ResearcherUrl> rUrlList = rUrls.getResearcherUrl();
                if (rUrlList != null) {
                    for (ResearcherUrl rUrl : rUrlList) {
                        setSourceName(rUrl);
                    }
                }
            }
        }
    }
}
Also used : Keywords(org.orcid.jaxb.model.message.Keywords) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) Address(org.orcid.jaxb.model.message.Address) Keyword(org.orcid.jaxb.model.message.Keyword) Funding(org.orcid.jaxb.model.message.Funding) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) OtherNames(org.orcid.jaxb.model.message.OtherNames) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) OtherName(org.orcid.jaxb.model.message.OtherName) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) FundingList(org.orcid.jaxb.model.message.FundingList) Affiliations(org.orcid.jaxb.model.message.Affiliations) ResearcherUrls(org.orcid.jaxb.model.message.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) ExternalIdentifiers(org.orcid.jaxb.model.message.ExternalIdentifiers) Affiliation(org.orcid.jaxb.model.message.Affiliation)

Example 9 with ResearcherUrl

use of org.orcid.jaxb.model.message.ResearcherUrl in project ORCID-Source by ORCID.

the class RDFMessageBodyWriter method describeResearcherUrls.

private void describeResearcherUrls(ResearcherUrls researcherUrls, Individual person, OntModel m) {
    if (researcherUrls == null || researcherUrls.getResearcherUrl() == null) {
        return;
    }
    for (ResearcherUrl url : researcherUrls.getResearcherUrl()) {
        Individual page = m.createIndividual(url.getUrl().getValue(), null);
        String urlName = getUrlName(url);
        if (isHomePage(urlName)) {
            person.addProperty(FOAF.homepage, page);
        } else if (isFoaf(urlName)) {
            // TODO: What if we want to link to the URL of the other FOAF
            // *Profile*?
            // Note: We don't dear here to do owl:sameAs or
            // prov:specializationOf as we don't know the extent of the
            // other FOAF profile - we'll
            // suffice to say it's an alternate view of the same person
            person.addProperty(PROV.alternateOf, page);
            page.addRDFType(FOAF.Person);
            page.addRDFType(PROV.Person);
            person.addSeeAlso(page);
        } else if (isWebID(urlName)) {
            person.addSameAs(page);
        } else {
            // It's some other foaf:page which might not be about
            // this person
            person.addProperty(FOAF.page, page);
        }
    }
}
Also used : Individual(org.apache.jena.ontology.Individual) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl)

Example 10 with ResearcherUrl

use of org.orcid.jaxb.model.message.ResearcherUrl in project ORCID-Source by ORCID.

the class RDFWriterTest method fakeBio.

private OrcidMessage fakeBio() throws DatatypeConfigurationException {
    OrcidMessage orcidMessage = new OrcidMessage();
    OrcidProfile orcidProfile1 = new OrcidProfile();
    OrcidIdentifier orcidIdentifier = new OrcidIdentifier();
    orcidProfile1.setOrcidIdentifier(orcidIdentifier);
    orcidIdentifier.setUri("http://orcid.example.com/000-1337");
    orcidIdentifier.setPath("000-1337");
    OrcidBio bio = new OrcidBio();
    orcidProfile1.setOrcidBio(bio);
    OrcidHistory history = new OrcidHistory();
    XMLGregorianCalendar value = dataTypeFactory.newXMLGregorianCalendar(1980, 12, 31, 23, 29, 29, 999, 0);
    history.setCreationMethod(CreationMethod.WEBSITE);
    history.setLastModifiedDate(new LastModifiedDate(value));
    orcidProfile1.setOrcidHistory(history);
    PersonalDetails personal = new PersonalDetails();
    bio.setPersonalDetails(personal);
    personal.setFamilyName(new FamilyName("Doe"));
    personal.setCreditName(new CreditName("John F Doe"));
    personal.setGivenNames(new GivenNames("John"));
    personal.setOtherNames(new OtherNames());
    personal.getOtherNames().addOtherName("Johnny", Visibility.PUBLIC);
    personal.getOtherNames().addOtherName("Mr Doe", Visibility.PUBLIC);
    ResearcherUrls urls = new ResearcherUrls();
    bio.setResearcherUrls(urls);
    ResearcherUrl anonymous = new ResearcherUrl(new Url("http://example.com/anon"), Visibility.PUBLIC);
    urls.getResearcherUrl().add(anonymous);
    // "home page" - with strange casing
    ResearcherUrl homePage = new ResearcherUrl(new Url("http://example.com/myPage"), new UrlName("homePage"), Visibility.PUBLIC);
    urls.getResearcherUrl().add(homePage);
    ResearcherUrl foaf = new ResearcherUrl(new Url("http://example.com/foaf#me"), new UrlName("FOAF"), Visibility.PUBLIC);
    urls.getResearcherUrl().add(foaf);
    ResearcherUrl webId = new ResearcherUrl(new Url("http://example.com/webId"), new UrlName("webID"), Visibility.PUBLIC);
    urls.getResearcherUrl().add(webId);
    ResearcherUrl other = new ResearcherUrl(new Url("http://example.com/other"), new UrlName("other"), Visibility.PUBLIC);
    urls.getResearcherUrl().add(other);
    bio.setContactDetails(new ContactDetails());
    bio.getContactDetails().setEmail(Arrays.asList(new Email("john@example.org"), new Email("doe@example.com")));
    bio.getContactDetails().setAddress(new Address());
    bio.getContactDetails().getAddress().setCountry(new Country(Iso3166Country.GB));
    orcidMessage.setOrcidProfile(orcidProfile1);
    return orcidMessage;
}
Also used : LastModifiedDate(org.orcid.jaxb.model.message.LastModifiedDate) Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) Address(org.orcid.jaxb.model.message.Address) FamilyName(org.orcid.jaxb.model.message.FamilyName) OtherNames(org.orcid.jaxb.model.message.OtherNames) CreditName(org.orcid.jaxb.model.message.CreditName) UrlName(org.orcid.jaxb.model.message.UrlName) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) Url(org.orcid.jaxb.model.message.Url) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) GivenNames(org.orcid.jaxb.model.message.GivenNames) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) ResearcherUrls(org.orcid.jaxb.model.message.ResearcherUrls) Iso3166Country(org.orcid.jaxb.model.message.Iso3166Country) Country(org.orcid.jaxb.model.message.Country) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl)

Aggregations

ResearcherUrl (org.orcid.jaxb.model.message.ResearcherUrl)16 ResearcherUrls (org.orcid.jaxb.model.message.ResearcherUrls)12 Url (org.orcid.jaxb.model.message.Url)12 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)10 Keyword (org.orcid.jaxb.model.message.Keyword)9 ExternalIdentifier (org.orcid.jaxb.model.message.ExternalIdentifier)8 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)8 Keywords (org.orcid.jaxb.model.message.Keywords)7 OtherNames (org.orcid.jaxb.model.message.OtherNames)7 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)7 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)6 Email (org.orcid.jaxb.model.message.Email)6 ExternalIdCommonName (org.orcid.jaxb.model.message.ExternalIdCommonName)6 ExternalIdReference (org.orcid.jaxb.model.message.ExternalIdReference)6 ExternalIdentifiers (org.orcid.jaxb.model.message.ExternalIdentifiers)6 FamilyName (org.orcid.jaxb.model.message.FamilyName)6 GivenNames (org.orcid.jaxb.model.message.GivenNames)6 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)6 Test (org.junit.Test)5 Biography (org.orcid.jaxb.model.message.Biography)5