Search in sources :

Example 46 with Biography

use of org.orcid.jaxb.model.v3.dev1.record.Biography in project ORCID-Source by ORCID.

the class BiographyManagerReadOnlyImpl method getBiography.

@Override
public Biography getBiography(String orcid) {
    BiographyEntity biographyEntity = null;
    try {
        biographyEntity = biographyDao.getBiography(orcid, getLastModified(orcid));
    } catch (Exception e) {
        LOGGER.debug("Couldn't find biography for " + orcid);
    }
    if (biographyEntity != null) {
        Biography bio = new Biography();
        bio.setContent(biographyEntity.getBiography());
        bio.setVisibility(Visibility.fromValue(biographyEntity.getVisibility().value()));
        bio.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(biographyEntity.getLastModified())));
        bio.setCreatedDate(new CreatedDate(DateUtils.convertToXMLGregorianCalendar(biographyEntity.getDateCreated())));
        return bio;
    }
    return null;
}
Also used : LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) Biography(org.orcid.jaxb.model.v3.dev1.record.Biography) CreatedDate(org.orcid.jaxb.model.v3.dev1.common.CreatedDate) BiographyEntity(org.orcid.persistence.jpa.entities.BiographyEntity)

Example 47 with Biography

use of org.orcid.jaxb.model.v3.dev1.record.Biography in project ORCID-Source by ORCID.

the class ValidateV3_dev1SamplesTest method testMarshallBiography.

@Test
public void testMarshallBiography() throws JAXBException, SAXException, URISyntaxException {
    Biography object = (Biography) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/biography-3.0_dev1.xml", Biography.class);
    marshall(object, "/record_3.0_dev1/personal-details-3.0_dev1.xsd");
}
Also used : Biography(org.orcid.jaxb.model.v3.dev1.record.Biography) Test(org.junit.Test)

Example 48 with Biography

use of org.orcid.jaxb.model.v3.dev1.record.Biography in project ORCID-Source by ORCID.

the class ValidateV3_dev1SamplesTest method testUnmarshallBiography.

@Test
public void testUnmarshallBiography() throws SAXException, URISyntaxException {
    Biography bio = (Biography) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/biography-3.0_dev1.xml", Biography.class, "/record_3.0_dev1/personal-details-3.0_dev1.xsd");
    assertNotNull(bio);
    assertEquals("biography V3.0_dev1", bio.getContent());
    assertEquals(Visibility.PUBLIC.value(), bio.getVisibility().value());
}
Also used : Biography(org.orcid.jaxb.model.v3.dev1.record.Biography) Test(org.junit.Test)

Example 49 with Biography

use of org.orcid.jaxb.model.v3.dev1.record.Biography in project ORCID-Source by ORCID.

the class ValidateV3_dev1SamplesTest method testUnmarshallPerson.

@Test
public void testUnmarshallPerson() throws SAXException, URISyntaxException {
    Person person = (Person) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/person-3.0_dev1.xml", Person.class, "/record_3.0_dev1/person-3.0_dev1.xsd");
    assertNotNull(person);
    assertNotNull(person.getName());
    assertEquals("give-names", person.getName().getGivenNames().getContent());
    assertEquals("family-name", person.getName().getFamilyName().getContent());
    assertEquals("credit-name", person.getName().getCreditName().getContent());
    assertEquals(Visibility.PUBLIC, person.getName().getVisibility());
    assertNotNull(person.getOtherNames());
    assertNotNull(person.getOtherNames().getOtherNames());
    assertEquals(1, person.getOtherNames().getOtherNames().size());
    OtherName otherName = person.getOtherNames().getOtherNames().get(0);
    assertEquals("other-name-1", otherName.getContent());
    assertNotNull(otherName.getCreatedDate());
    assertNotNull(otherName.getCreatedDate().getValue());
    assertEquals(2001, otherName.getCreatedDate().getValue().getYear());
    assertEquals(12, otherName.getCreatedDate().getValue().getMonth());
    assertEquals(31, otherName.getCreatedDate().getValue().getDay());
    assertNotNull(otherName.getLastModifiedDate().getValue());
    assertEquals(2001, otherName.getLastModifiedDate().getValue().getYear());
    assertEquals(12, otherName.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, otherName.getLastModifiedDate().getValue().getDay());
    assertNotNull(otherName.getSource());
    assertEquals("8888-8888-8888-8880", otherName.getSource().retrieveSourcePath());
    assertNotNull(person.getBiography());
    assertEquals(Visibility.PUBLIC, person.getBiography().getVisibility());
    assertEquals("biography", person.getBiography().getContent());
    assertNotNull(person.getResearcherUrls());
    assertNotNull(person.getResearcherUrls().getResearcherUrls());
    assertEquals(1, person.getResearcherUrls().getResearcherUrls().size());
    ResearcherUrl rUrl = person.getResearcherUrls().getResearcherUrls().get(0);
    assertEquals(Visibility.PUBLIC, rUrl.getVisibility());
    assertEquals(Long.valueOf(1248), rUrl.getPutCode());
    assertEquals("url-name-1", rUrl.getUrlName());
    assertNotNull(rUrl.getUrl());
    assertEquals("http://url.com/", rUrl.getUrl().getValue());
    assertNotNull(rUrl.getCreatedDate());
    assertEquals(2001, rUrl.getCreatedDate().getValue().getYear());
    assertEquals(12, rUrl.getCreatedDate().getValue().getMonth());
    assertEquals(31, rUrl.getCreatedDate().getValue().getDay());
    assertNotNull(rUrl.getLastModifiedDate());
    assertEquals(2001, rUrl.getLastModifiedDate().getValue().getYear());
    assertEquals(12, rUrl.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, rUrl.getLastModifiedDate().getValue().getDay());
    assertNotNull(rUrl.getSource());
    assertEquals("8888-8888-8888-8880", rUrl.getSource().retrieveSourcePath());
    assertNotNull(person.getEmails());
    assertNotNull(person.getEmails().getEmails());
    assertEquals(1, person.getEmails().getEmails().size());
    Email email = person.getEmails().getEmails().get(0);
    assertEquals(Visibility.PUBLIC, email.getVisibility());
    assertEquals("user1@email.com", email.getEmail());
    assertNotNull(email.getCreatedDate());
    assertNotNull(email.getCreatedDate().getValue());
    assertEquals(2001, email.getCreatedDate().getValue().getYear());
    assertEquals(12, email.getCreatedDate().getValue().getMonth());
    assertEquals(31, email.getCreatedDate().getValue().getDay());
    assertNotNull(email.getLastModifiedDate());
    assertNotNull(email.getLastModifiedDate().getValue());
    assertEquals(2001, email.getLastModifiedDate().getValue().getYear());
    assertEquals(12, email.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, email.getLastModifiedDate().getValue().getDay());
    assertNotNull(email.getSource());
    assertEquals("8888-8888-8888-8880", email.retrieveSourcePath());
    assertNotNull(person.getAddresses());
    assertNotNull(person.getAddresses().getAddress());
    assertEquals(1, person.getAddresses().getAddress().size());
    Address address = person.getAddresses().getAddress().get(0);
    assertEquals(Visibility.PUBLIC, address.getVisibility());
    assertEquals(Long.valueOf(1), address.getPutCode());
    assertNotNull(address.getCountry());
    assertEquals(Iso3166Country.US, address.getCountry().getValue());
    assertNotNull(address.getCreatedDate());
    assertNotNull(address.getCreatedDate().getValue());
    assertEquals(2001, address.getCreatedDate().getValue().getYear());
    assertEquals(12, address.getCreatedDate().getValue().getMonth());
    assertEquals(31, address.getCreatedDate().getValue().getDay());
    assertNotNull(address.getLastModifiedDate());
    assertNotNull(address.getLastModifiedDate().getValue());
    assertEquals(2001, address.getLastModifiedDate().getValue().getYear());
    assertEquals(12, address.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, address.getLastModifiedDate().getValue().getDay());
    assertNotNull(address.getSource());
    assertEquals("8888-8888-8888-8880", address.getSource().retrieveSourcePath());
    assertNotNull(person.getKeywords());
    assertNotNull(person.getKeywords().getKeywords());
    assertEquals(1, person.getKeywords().getKeywords().size());
    Keyword keyword = person.getKeywords().getKeywords().get(0);
    assertEquals(Visibility.PUBLIC, keyword.getVisibility());
    assertEquals(Long.valueOf(1), keyword.getPutCode());
    assertEquals("keyword1", keyword.getContent());
    assertNotNull(keyword.getCreatedDate());
    assertNotNull(keyword.getCreatedDate().getValue());
    assertEquals(2001, keyword.getCreatedDate().getValue().getYear());
    assertEquals(12, keyword.getCreatedDate().getValue().getMonth());
    assertEquals(31, keyword.getCreatedDate().getValue().getDay());
    assertNotNull(keyword.getLastModifiedDate());
    assertNotNull(keyword.getLastModifiedDate().getValue());
    assertEquals(2001, keyword.getLastModifiedDate().getValue().getYear());
    assertEquals(12, keyword.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, keyword.getLastModifiedDate().getValue().getDay());
    assertNotNull(keyword.getSource());
    assertEquals("8888-8888-8888-8880", keyword.getSource().retrieveSourcePath());
    assertNotNull(person.getExternalIdentifiers());
    assertNotNull(person.getExternalIdentifiers().getExternalIdentifiers());
    assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
    PersonExternalIdentifier extId = person.getExternalIdentifiers().getExternalIdentifiers().get(0);
    assertEquals(Visibility.PUBLIC, extId.getVisibility());
    assertEquals(Long.valueOf(1), extId.getPutCode());
    assertEquals("type-1", extId.getType());
    assertEquals("value-1", extId.getValue());
    assertNotNull(extId.getUrl());
    assertEquals("http://url.com/1", extId.getUrl().getValue());
    assertNotNull(extId.getCreatedDate());
    assertNotNull(extId.getCreatedDate().getValue());
    assertEquals(2001, extId.getCreatedDate().getValue().getYear());
    assertEquals(12, extId.getCreatedDate().getValue().getMonth());
    assertEquals(31, extId.getCreatedDate().getValue().getDay());
    assertNotNull(extId.getLastModifiedDate());
    assertNotNull(extId.getLastModifiedDate().getValue());
    assertEquals(2001, extId.getLastModifiedDate().getValue().getYear());
    assertEquals(12, extId.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, extId.getLastModifiedDate().getValue().getDay());
    assertNotNull(extId.getSource());
    assertEquals("8888-8888-8888-8880", extId.getSource().retrieveSourcePath());
}
Also used : Email(org.orcid.jaxb.model.v3.dev1.record.Email) Address(org.orcid.jaxb.model.v3.dev1.record.Address) Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) Person(org.orcid.jaxb.model.v3.dev1.record.Person) Test(org.junit.Test)

Example 50 with Biography

use of org.orcid.jaxb.model.v3.dev1.record.Biography in project ORCID-Source by ORCID.

the class ValidateV3_dev1SamplesTest method unmarshallFromPath.

private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
    try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
        Object obj = unmarshall(reader, type, schemaPath);
        Object result = null;
        if (ResearcherUrls.class.equals(type)) {
            result = (ResearcherUrls) obj;
        } else if (ResearcherUrl.class.equals(type)) {
            result = (ResearcherUrl) obj;
        } else if (PersonalDetails.class.equals(type)) {
            result = (PersonalDetails) obj;
        } else if (PersonExternalIdentifier.class.equals(type)) {
            result = (PersonExternalIdentifier) obj;
        } else if (PersonExternalIdentifiers.class.equals(type)) {
            result = (PersonExternalIdentifiers) obj;
        } else if (Biography.class.equals(type)) {
            result = (Biography) obj;
        } else if (Name.class.equals(type)) {
            result = (Name) obj;
        } else if (CreditName.class.equals(type)) {
            result = (CreditName) obj;
        } else if (OtherName.class.equals(type)) {
            result = (OtherName) obj;
        } else if (OtherNames.class.equals(type)) {
            result = (OtherNames) obj;
        } else if (Keywords.class.equals(type)) {
            result = (Keywords) obj;
        } else if (Keyword.class.equals(type)) {
            result = (Keyword) obj;
        } else if (Addresses.class.equals(type)) {
            result = (Addresses) obj;
        } else if (Address.class.equals(type)) {
            result = (Address) obj;
        } else if (Emails.class.equals(type)) {
            result = (Emails) obj;
        } else if (Email.class.equals(type)) {
            result = (Email) obj;
        } else if (Person.class.equals(type)) {
            result = (Person) obj;
        } else if (Deprecated.class.equals(type)) {
            result = (Deprecated) obj;
        } else if (Preferences.class.equals(type)) {
            result = (Preferences) obj;
        } else if (History.class.equals(type)) {
            result = (History) obj;
        } else if (Record.class.equals(type)) {
            result = (Record) obj;
        } else if (ActivitiesSummary.class.equals(type)) {
            result = (ActivitiesSummary) obj;
        } else if (Works.class.equals(type)) {
            result = (Works) obj;
        } else if (Education.class.equals(type)) {
            result = (Education) obj;
        } else if (Educations.class.equals(type)) {
            result = (Educations) obj;
        } else if (Employment.class.equals(type)) {
            result = (Employment) obj;
        } else if (Employments.class.equals(type)) {
            result = (Employments) obj;
        } else if (Distinction.class.equals(type)) {
            result = (Distinction) obj;
        } else if (Distinctions.class.equals(type)) {
            result = (Distinctions) obj;
        } else if (InvitedPosition.class.equals(type)) {
            result = (InvitedPosition) obj;
        } else if (InvitedPositions.class.equals(type)) {
            result = (InvitedPositions) obj;
        } else if (Membership.class.equals(type)) {
            result = (Membership) obj;
        } else if (Memberships.class.equals(type)) {
            result = (Memberships) obj;
        } else if (Qualification.class.equals(type)) {
            result = (Qualification) obj;
        } else if (Qualifications.class.equals(type)) {
            result = (Qualifications) obj;
        } else if (Service.class.equals(type)) {
            result = (Service) obj;
        } else if (Services.class.equals(type)) {
            result = (Services) obj;
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error reading notification from classpath", e);
    }
}
Also used : Email(org.orcid.jaxb.model.v3.dev1.record.Email) InputStreamReader(java.io.InputStreamReader) Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword) Address(org.orcid.jaxb.model.v3.dev1.record.Address) OtherNames(org.orcid.jaxb.model.v3.dev1.record.OtherNames) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) CreditName(org.orcid.jaxb.model.v3.dev1.record.CreditName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) Service(org.orcid.jaxb.model.v3.dev1.record.Service) IOException(java.io.IOException) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) History(org.orcid.jaxb.model.v3.dev1.record.History) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) Qualification(org.orcid.jaxb.model.v3.dev1.record.Qualification) Deprecated(org.orcid.jaxb.model.v3.dev1.record.Deprecated) Education(org.orcid.jaxb.model.v3.dev1.record.Education) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) Biography(org.orcid.jaxb.model.v3.dev1.record.Biography) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction)

Aggregations

Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)76 Test (org.junit.Test)75 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)53 Name (org.orcid.jaxb.model.v3.dev1.record.Name)44 OtherNames (org.orcid.jaxb.model.v3.dev1.record.OtherNames)44 Address (org.orcid.jaxb.model.v3.dev1.record.Address)36 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)36 Email (org.orcid.jaxb.model.v3.dev1.record.Email)35 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)35 Person (org.orcid.jaxb.model.v3.dev1.record.Person)35 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)35 ResearcherUrls (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls)32 Addresses (org.orcid.jaxb.model.v3.dev1.record.Addresses)31 Keywords (org.orcid.jaxb.model.v3.dev1.record.Keywords)31 PersonExternalIdentifiers (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers)31 Emails (org.orcid.jaxb.model.v3.dev1.record.Emails)29 PersonalDetails (org.orcid.jaxb.model.v3.dev1.record.PersonalDetails)22 Record (org.orcid.jaxb.model.v3.dev1.record.Record)18 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)17 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)15