Search in sources :

Example 6 with Address

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);
}
Also used : Email(org.orcid.jaxb.model.message.Email) Keywords(org.orcid.jaxb.model.message.Keywords) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) Address(org.orcid.jaxb.model.message.Address) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) FamilyName(org.orcid.jaxb.model.message.FamilyName) OtherNames(org.orcid.jaxb.model.message.OtherNames) ArrayList(java.util.ArrayList) Url(org.orcid.jaxb.model.message.Url) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) ExternalIdUrl(org.orcid.jaxb.model.message.ExternalIdUrl) ExternalIdUrl(org.orcid.jaxb.model.message.ExternalIdUrl) ExternalIdCommonName(org.orcid.jaxb.model.message.ExternalIdCommonName) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) GivenNames(org.orcid.jaxb.model.message.GivenNames) Biography(org.orcid.jaxb.model.message.Biography) 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) ExternalIdReference(org.orcid.jaxb.model.message.ExternalIdReference) Keyword(org.orcid.jaxb.model.message.Keyword) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) FundingExternalIdentifier(org.orcid.jaxb.model.message.FundingExternalIdentifier) CreditName(org.orcid.jaxb.model.message.CreditName) OtherName(org.orcid.jaxb.model.message.OtherName) UrlName(org.orcid.jaxb.model.message.UrlName) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) Country(org.orcid.jaxb.model.message.Country) Iso3166Country(org.orcid.jaxb.model.message.Iso3166Country)

Example 7 with Address

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());
}
Also used : Email(org.orcid.jaxb.model.message.Email) Address(org.orcid.jaxb.model.message.Address) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) HashMap(java.util.HashMap)

Example 8 with Address

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;
}
Also used : Email(org.orcid.jaxb.model.message.Email) Keywords(org.orcid.jaxb.model.message.Keywords) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) Address(org.orcid.jaxb.model.message.Address) ExternalIdReference(org.orcid.jaxb.model.message.ExternalIdReference) Keyword(org.orcid.jaxb.model.message.Keyword) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) FamilyName(org.orcid.jaxb.model.message.FamilyName) OtherNames(org.orcid.jaxb.model.message.OtherNames) ArrayList(java.util.ArrayList) 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) ExternalIdCommonName(org.orcid.jaxb.model.message.ExternalIdCommonName) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) GivenNames(org.orcid.pojo.GivenNames) Biography(org.orcid.jaxb.model.message.Biography) Country(org.orcid.jaxb.model.message.Country) Iso3166Country(org.orcid.jaxb.model.message.Iso3166Country) ResearcherUrls(org.orcid.jaxb.model.message.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) ExternalIdentifiers(org.orcid.jaxb.model.message.ExternalIdentifiers)

Example 9 with Address

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;
}
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)

Example 10 with Address

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);
                    }
                }
            }
        }
    }
}
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)

Aggregations

Address (org.orcid.jaxb.model.message.Address)10 Email (org.orcid.jaxb.model.message.Email)7 Country (org.orcid.jaxb.model.message.Country)6 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)6 Iso3166Country (org.orcid.jaxb.model.message.Iso3166Country)5 OtherNames (org.orcid.jaxb.model.message.OtherNames)5 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)4 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)4 ResearcherUrl (org.orcid.jaxb.model.message.ResearcherUrl)4 ResearcherUrls (org.orcid.jaxb.model.message.ResearcherUrls)4 ArrayList (java.util.ArrayList)3 CreditName (org.orcid.jaxb.model.message.CreditName)3 ExternalIdentifier (org.orcid.jaxb.model.message.ExternalIdentifier)3 ExternalIdentifiers (org.orcid.jaxb.model.message.ExternalIdentifiers)3 FamilyName (org.orcid.jaxb.model.message.FamilyName)3 Keyword (org.orcid.jaxb.model.message.Keyword)3 Keywords (org.orcid.jaxb.model.message.Keywords)3 Test (org.junit.Test)2 BaseTest (org.orcid.core.BaseTest)2 Affiliation (org.orcid.jaxb.model.message.Affiliation)2