use of org.orcid.jaxb.model.message.ResearcherUrl in project ORCID-Source by ORCID.
the class OrcidProfileManagerBaseTest method createFullOrcidProfile.
protected OrcidProfile createFullOrcidProfile() {
OrcidProfile profile2 = new OrcidProfile();
profile2.setPassword("password");
profile2.setVerificationCode("1234");
profile2.setOrcidIdentifier(TEST_ORCID);
OrcidBio bio = new OrcidBio();
ContactDetails contactDetails = new ContactDetails();
contactDetails.addOrReplacePrimaryEmail(new Email("will@orcid.org"));
bio.setContactDetails(contactDetails);
profile2.setOrcidBio(bio);
PersonalDetails personalDetails = new PersonalDetails();
personalDetails.setGivenNames(new GivenNames("William"));
personalDetails.setFamilyName(new FamilyName("Simpson"));
personalDetails.setCreditName(new CreditName("W. J. R. Simpson"));
bio.setPersonalDetails(personalDetails);
ResearcherUrls researcherUrls = new ResearcherUrls();
researcherUrls.getResearcherUrl().add(new ResearcherUrl(new Url("http://www.wjrs.co.uk"), null));
bio.setResearcherUrls(researcherUrls);
Keywords keywords = new Keywords();
bio.setKeywords(keywords);
keywords.getKeyword().add(new Keyword("Java", null));
bio.setBiography(new Biography("Will is a software developer at Semantico"));
return profile2;
}
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);
}
}
}
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;
}
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.
}
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);
}
}
}
}
Aggregations