Search in sources :

Example 36 with Email

use of org.orcid.jaxb.model.message.Email 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 37 with Email

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

the class OrcidBatchLoad method assignPersistenceFields.

private void assignPersistenceFields(OrcidProfile profile) {
    // set the transient fields that the encrypters need
    profile.setPassword("password");
    // profile.setOrcidIdentifier();
    profile.setSecurityQuestionAnswer("securityQuestionAnswer");
    profile.setVerificationCode("1111");
    // randomise any fields that are uniquely constrained so that we can
    // re-use the test data
    profile.getOrcidBio().getContactDetails().addOrReplacePrimaryEmail(new Email(RandomStringUtils.randomAlphabetic(150)));
    Keywords keywords = new Keywords();
    keywords.getKeyword().add(new Keyword(RandomStringUtils.randomAlphabetic(255), Visibility.PUBLIC));
    profile.getOrcidBio().setKeywords(keywords);
    profile.retrieveOrcidWorks().getOrcidWork();
}
Also used : Email(org.orcid.jaxb.model.message.Email) Keywords(org.orcid.jaxb.model.message.Keywords) Keyword(org.orcid.jaxb.model.message.Keyword)

Example 38 with Email

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

the class T2OrcidApiServiceVersionedDelegatorTest method testAttemptCreateWithTotallyIncorrectVersion.

@Test(expected = OrcidValidationException.class)
public void testAttemptCreateWithTotallyIncorrectVersion() {
    setUpSecurityContextForClientOnly();
    OrcidMessage orcidMessage = createStubOrcidMessage();
    orcidMessage.setMessageVersion("abc");
    Email email = new Email("madeupemail4@semantico.com");
    orcidMessage.getOrcidProfile().getOrcidBio().getContactDetails().getEmail().add(email);
    t2OrcidApiServiceDelegatorV2_1.createProfile(mockedUriInfo, orcidMessage);
}
Also used : Email(org.orcid.jaxb.model.message.Email) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 39 with Email

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

the class T2OrcidApiServiceDelegatorTest method testReadPrivateEmailsOnBio.

@Test
public void testReadPrivateEmailsOnBio() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4497", ScopePathType.ORCID_BIO_READ_LIMITED, ScopePathType.EMAIL_READ_PRIVATE);
    /*Example A List on 4444-4444-4444-4497:
        Item 1 Private (client is source)
        Item 2 Private (other source)
        Item 3 Limited
        Item 4 Public 
        */
    OrcidProfile p = ((OrcidMessage) t2OrcidApiServiceDelegator.findBioDetails("4444-4444-4444-4497").getEntity()).getOrcidProfile();
    List<Email> emails = p.getOrcidBio().getContactDetails().getEmail();
    assertEquals(3, emails.size());
    boolean privateFound = false;
    boolean publicFound = false;
    boolean limitedFound = false;
    for (Email email : emails) {
        if ("public_4444-4444-4444-4497@test.orcid.org".equals(email.getValue()) && Visibility.PUBLIC.equals(email.getVisibility())) {
            publicFound = true;
        } else if ("limited_4444-4444-4444-4497@test.orcid.org".equals(email.getValue()) && Visibility.LIMITED.equals(email.getVisibility())) {
            limitedFound = true;
        } else if ("private_4444-4444-4444-4497@test.orcid.org".equals(email.getValue()) && Visibility.PRIVATE.equals(email.getVisibility())) {
            privateFound = true;
        }
    }
    assertTrue(publicFound);
    assertTrue(limitedFound);
    assertTrue(privateFound);
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Email(org.orcid.jaxb.model.message.Email) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 40 with Email

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

the class T2OrcidApiServiceVersionedDelegatorTest method testCreateAndReadOwnCreation.

@Test
public void testCreateAndReadOwnCreation() {
    setUpSecurityContextForClientOnly();
    OrcidMessage orcidMessage = createStubOrcidMessage();
    Email email = new Email("madeupemail@semantico.com");
    email.setPrimary(true);
    orcidMessage.getOrcidProfile().getOrcidBio().getContactDetails().getEmail().add(email);
    Response createResponse = t2OrcidApiServiceDelegatorLatest.createProfile(mockedUriInfo, orcidMessage);
    assertNotNull(createResponse);
    assertEquals(HttpStatus.SC_CREATED, createResponse.getStatus());
    String location = ((URI) createResponse.getMetadata().getFirst("Location")).getPath();
    assertNotNull(location);
    String orcid = location.substring(1, 20);
    Response readResponse = t2OrcidApiServiceDelegatorLatest.findFullDetails(orcid);
    assertNotNull(readResponse);
    assertEquals(HttpStatus.SC_OK, readResponse.getStatus());
    OrcidMessage retrievedMessage = (OrcidMessage) readResponse.getEntity();
    assertEquals(orcid, retrievedMessage.getOrcidProfile().getOrcidIdentifier().getPath());
    assertEquals("Test credit name", retrievedMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().getCreditName().getContent());
}
Also used : Response(javax.ws.rs.core.Response) Email(org.orcid.jaxb.model.message.Email) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) URI(java.net.URI) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Email (org.orcid.jaxb.model.message.Email)45 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)22 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)20 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)20 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)18 Test (org.junit.Test)17 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)14 GivenNames (org.orcid.jaxb.model.message.GivenNames)12 FamilyName (org.orcid.jaxb.model.message.FamilyName)11 DBUnitTest (org.orcid.test.DBUnitTest)10 ArrayList (java.util.ArrayList)8 Address (org.orcid.jaxb.model.message.Address)7 Biography (org.orcid.jaxb.model.message.Biography)7 CreditName (org.orcid.jaxb.model.message.CreditName)7 ExternalIdentifiers (org.orcid.jaxb.model.message.ExternalIdentifiers)7 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)7 ExternalIdentifier (org.orcid.jaxb.model.message.ExternalIdentifier)6 Keyword (org.orcid.jaxb.model.message.Keyword)6 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)6 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)6