use of org.orcid.jaxb.model.message.Address in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method setBio.
private void setBio(OrcidProfile profile, Visibility defaultVisibility) {
OrcidBio bio = new OrcidBio();
Biography biography = new Biography("This is my biography");
if (defaultVisibility != null) {
biography.setVisibility(defaultVisibility);
}
bio.setBiography(biography);
ContactDetails contactDetails = new ContactDetails();
Address address = new Address();
address.setCountry(new Country(Iso3166Country.US));
if (defaultVisibility != null) {
address.getCountry().setVisibility(defaultVisibility);
}
contactDetails.setAddress(address);
List<Email> emails = new ArrayList<Email>();
Email email = new Email();
email.setPrimary(true);
email.setValue(System.currentTimeMillis() + "@test.orcid.org");
emails.add(email);
contactDetails.setEmail(emails);
bio.setContactDetails(contactDetails);
ExternalIdentifiers extIds = new ExternalIdentifiers();
ExternalIdentifier extId = new ExternalIdentifier();
extId.setExternalIdCommonName(new ExternalIdCommonName("common-name"));
extId.setExternalIdReference(new ExternalIdReference("ext-id-reference"));
extId.setExternalIdUrl(new ExternalIdUrl("http://orcid.org/ext-id"));
extIds.getExternalIdentifier().add(extId);
if (defaultVisibility != null) {
extIds.setVisibility(defaultVisibility);
}
bio.setExternalIdentifiers(extIds);
Keywords keywords = new Keywords();
Keyword keyword = new Keyword();
keyword.setContent("k1");
keywords.getKeyword().add(keyword);
if (defaultVisibility != null) {
keywords.setVisibility(defaultVisibility);
}
bio.setKeywords(keywords);
PersonalDetails personalDetails = new PersonalDetails();
personalDetails.setCreditName(new CreditName("credit-name"));
personalDetails.setGivenNames(new GivenNames("given-names"));
personalDetails.setFamilyName(new FamilyName("family-name"));
OtherNames otherNames = new OtherNames();
OtherName otherName = new OtherName();
otherName.setContent("o1");
otherNames.getOtherName().add(otherName);
if (defaultVisibility != null) {
otherNames.setVisibility(defaultVisibility);
}
personalDetails.setOtherNames(otherNames);
bio.setPersonalDetails(personalDetails);
ResearcherUrls researcherUrls = new ResearcherUrls();
ResearcherUrl researcherUrl = new ResearcherUrl();
researcherUrl.setUrl(new Url("http://orcid.org/researcher-url-1"));
researcherUrl.setUrlName(new UrlName("url-name-1"));
researcherUrls.getResearcherUrl().add(researcherUrl);
if (defaultVisibility != null) {
researcherUrls.setVisibility(defaultVisibility);
}
bio.setResearcherUrls(researcherUrls);
profile.setOrcidBio(bio);
}
use of org.orcid.jaxb.model.message.Address in project ORCID-Source by ORCID.
the class JpaJaxbEntityAdapterToOrcidProfileTest method checkContactDetails.
private void checkContactDetails(ContactDetails contactDetails) {
assertNotNull(contactDetails);
List<Email> emails = contactDetails.getEmail();
assertEquals(6, emails.size());
Map<String, Email> emailMap = new HashMap<>();
for (Email email : emails) {
emailMap.put(email.getValue(), email);
}
Email primaryEmail = emailMap.get("peter@sellers.com");
assertNotNull(primaryEmail);
assertEquals("PRIVATE", primaryEmail.getVisibility().name());
assertTrue(primaryEmail.isPrimary());
assertTrue(primaryEmail.isCurrent());
assertFalse(primaryEmail.isVerified());
String[] alternativeEmails = new String[] { "teddybass@semantico.com", "teddybass2@semantico.com", "teddybass3public@semantico.com", "teddybass3private@semantico.com" };
for (String alternativeEmail : alternativeEmails) {
Email email = emailMap.get(alternativeEmail);
assertNotNull(email);
switch(email.getValue()) {
case "teddybass@semantico.com":
assertEquals("PRIVATE", email.getVisibility().name());
assertFalse(email.isPrimary());
assertFalse(email.isVerified());
break;
case "teddybass2@semantico.com":
assertEquals("LIMITED", email.getVisibility().name());
assertFalse(email.isPrimary());
assertFalse(email.isVerified());
break;
case "teddybass3public@semantico.com":
assertEquals("PUBLIC", email.getVisibility().name());
assertFalse(email.isPrimary());
assertFalse(email.isVerified());
break;
case "teddybass3private@semantico.com":
assertEquals("PRIVATE", email.getVisibility().name());
assertTrue(email.isPrimary());
assertTrue(email.isVerified());
break;
}
assertTrue(email.isCurrent());
}
Address contactDetailsAddress = contactDetails.getAddress();
assertNotNull(contactDetailsAddress);
assertEquals(Visibility.LIMITED, contactDetailsAddress.getCountry().getVisibility());
}
use of org.orcid.jaxb.model.message.Address in project ORCID-Source by ORCID.
the class OrcidJaxbCopyManagerTest method getBio.
private OrcidBio getBio(String sufix, Visibility visibility, int max) {
OrcidBio orcidBio = new OrcidBio();
Biography bio = new Biography(sufix + "My Biography", visibility);
orcidBio.setBiography(bio);
ContactDetails contactDetails = new ContactDetails();
Address address = new Address();
Country country = new Country(visibility.equals(Visibility.PRIVATE) ? Iso3166Country.US : Iso3166Country.CR);
country.setVisibility(visibility);
address.setCountry(country);
contactDetails.setAddress(address);
List<Email> emails = new ArrayList<Email>();
for (int i = 0; i < max; i++) {
Email email = new Email();
email.setValue(sufix + "Email" + i);
if (i == 0) {
email.setPrimary(true);
}
email.setVisibility(visibility);
emails.add(email);
}
contactDetails.setEmail(emails);
orcidBio.setContactDetails(contactDetails);
ExternalIdentifiers extIds = new ExternalIdentifiers();
extIds.setVisibility(visibility);
for (int i = 0; i < max; i++) {
ExternalIdentifier extId = new ExternalIdentifier();
extId.setExternalIdCommonName(new ExternalIdCommonName(sufix + "CommonName" + i));
extId.setExternalIdReference(new ExternalIdReference(sufix + "Reference" + i));
extIds.getExternalIdentifier().add(extId);
}
orcidBio.setExternalIdentifiers(extIds);
Keywords keywords = new Keywords();
keywords.setVisibility(visibility);
for (int i = 0; i < max; i++) {
Keyword k = new Keyword();
k.setContent(sufix + "Keyword" + i);
keywords.getKeyword().add(k);
}
orcidBio.setKeywords(keywords);
PersonalDetails personalDetails = new PersonalDetails();
CreditName creditName = new CreditName(sufix + "Credit name");
creditName.setVisibility(visibility);
personalDetails.setCreditName(creditName);
FamilyName familyName = new FamilyName(sufix + "Family");
personalDetails.setFamilyName(familyName);
GivenNames givenNames = new GivenNames();
givenNames.setContent(sufix + "Given");
personalDetails.setGivenNames(givenNames);
OtherNames other = new OtherNames();
other.setVisibility(visibility);
for (int i = 0; i < max; i++) {
other.addOtherName(sufix + "Other" + i, null);
}
personalDetails.setOtherNames(other);
orcidBio.setPersonalDetails(personalDetails);
ResearcherUrls researcherUrls = new ResearcherUrls();
researcherUrls.setVisibility(visibility);
for (int i = 0; i < max; i++) {
ResearcherUrl rUrl = new ResearcherUrl();
rUrl.setUrl(new Url("http://www.rurl.com/" + sufix + "/" + i));
rUrl.setUrlName(new UrlName(sufix + "Url" + i));
researcherUrls.getResearcherUrl().add(rUrl);
}
orcidBio.setResearcherUrls(researcherUrls);
return orcidBio;
}
use of org.orcid.jaxb.model.message.Address 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.Address 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);
}
}
}
}
}
}
Aggregations