Search in sources :

Example 91 with ResearcherUrl

use of org.orcid.jaxb.model.record_v2.ResearcherUrl in project ORCID-Source by ORCID.

the class BlackBoxBaseRC3 method unmarshallFromPath.

public Object unmarshallFromPath(String path, Class<?> type) {
    try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
        Object obj = unmarshall(reader, type);
        Object result = null;
        if (Address.class.equals(type)) {
            result = (Address) obj;
        } else if (Education.class.equals(type)) {
            result = (Education) obj;
        } else if (Employment.class.equals(type)) {
            result = (Employment) obj;
        } else if (Funding.class.equals(type)) {
            result = (Funding) obj;
        } else if (Keyword.class.equals(type)) {
            result = (Keyword) obj;
        } else if (Work.class.equals(type)) {
            result = (Work) obj;
        } else if (PeerReview.class.equals(type)) {
            result = (PeerReview) obj;
        } else if (ResearcherUrl.class.equals(type)) {
            result = (ResearcherUrl) obj;
        } else if (PersonalDetails.class.equals(type)) {
            result = (PersonalDetails) obj;
        } else if (OtherName.class.equals(type)) {
            result = (OtherName) obj;
        } else if (PersonExternalIdentifier.class.equals(type)) {
            result = (PersonExternalIdentifier) obj;
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error reading notification from classpath", e);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) Education(org.orcid.jaxb.model.record_rc3.Education) Funding(org.orcid.jaxb.model.record_rc3.Funding) Work(org.orcid.jaxb.model.record_rc3.Work) OtherName(org.orcid.jaxb.model.record_rc3.OtherName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) ResearcherUrl(org.orcid.jaxb.model.record_rc3.ResearcherUrl) IOException(java.io.IOException)

Example 92 with ResearcherUrl

use of org.orcid.jaxb.model.record_v2.ResearcherUrl in project ORCID-Source by ORCID.

the class ValidateV2RC2SamplesTest method testUnmarshallResearcherUrl.

@Test
public void testUnmarshallResearcherUrl() throws SAXException, URISyntaxException {
    ResearcherUrls rUrls = (ResearcherUrls) unmarshallFromPath("/record_2.0_rc2/samples/researcher-urls-2.0_rc2.xml", ResearcherUrls.class, "/record_2.0_rc2/researcher-url-2.0_rc2.xsd");
    assertNotNull(rUrls);
    assertNotNull(rUrls.getResearcherUrls());
    assertEquals(1, rUrls.getResearcherUrls().size());
    assertNotNull(rUrls.getResearcherUrls().get(0).getCreatedDate());
    assertNotNull(rUrls.getResearcherUrls().get(0).getLastModifiedDate());
    assertEquals("Site # 1", rUrls.getResearcherUrls().get(0).getUrlName());
    assertEquals("http://site1.com/", rUrls.getResearcherUrls().get(0).getUrl().getValue());
    assertEquals(Long.valueOf(1248), rUrls.getResearcherUrls().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC.value(), rUrls.getResearcherUrls().get(0).getVisibility().value());
    assertNotNull(rUrls.getResearcherUrls().get(0).getSource());
    assertEquals("http://www.orcid.org/8888-8888-8888-8880", rUrls.getResearcherUrls().get(0).getSource().retriveSourceUri());
    assertEquals("8888-8888-8888-8880", rUrls.getResearcherUrls().get(0).getSource().retrieveSourcePath());
    ResearcherUrl rUrl = (ResearcherUrl) unmarshallFromPath("/record_2.0_rc2/samples/researcher-url-2.0_rc2.xml", ResearcherUrl.class);
    assertNotNull(rUrl);
    assertEquals("Site # 1", rUrl.getUrlName());
    assertNotNull(rUrl.getUrl());
    assertEquals("http://site1.com/", rUrl.getUrl().getValue());
    assertNotNull(rUrl.getCreatedDate());
    assertNotNull(rUrl.getLastModifiedDate());
    assertNotNull(rUrl.getSource());
    assertEquals("8888-8888-8888-8880", rUrl.getSource().retrieveSourcePath());
}
Also used : ResearcherUrls(org.orcid.jaxb.model.record_rc2.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.record_rc2.ResearcherUrl) Test(org.junit.Test)

Example 93 with ResearcherUrl

use of org.orcid.jaxb.model.record_v2.ResearcherUrl in project ORCID-Source by ORCID.

the class ValidateV2_1SamplesTest method testUnmarshallPerson.

@Test
public void testUnmarshallPerson() throws SAXException, URISyntaxException {
    Person person = (Person) unmarshallFromPath("/record_2.1/samples/read_samples/person-2.1.xml", Person.class, "/record_2.1/person-2.1.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());
    validateSourceInHttps(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());
    validateSourceInHttps(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());
    validateSourceInHttps(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());
    validateSourceInHttps(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());
    validateSourceInHttps(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());
    validateSourceInHttps(extId.getSource());
    assertEquals("8888-8888-8888-8880", extId.getSource().retrieveSourcePath());
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) Address(org.orcid.jaxb.model.record_v2.Address) Keyword(org.orcid.jaxb.model.record_v2.Keyword) OtherName(org.orcid.jaxb.model.record_v2.OtherName) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) Person(org.orcid.jaxb.model.record_v2.Person) Test(org.junit.Test)

Example 94 with ResearcherUrl

use of org.orcid.jaxb.model.record_v2.ResearcherUrl in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegatorImpl method updateResearcherUrl.

@Override
public Response updateResearcherUrl(String orcid, Long putCode, ResearcherUrl researcherUrl) {
    orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.ORCID_BIO_UPDATE);
    if (!putCode.equals(researcherUrl.getPutCode())) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("urlPutCode", String.valueOf(putCode));
        params.put("bodyPutCode", String.valueOf(researcherUrl.getPutCode()));
        throw new MismatchedPutCodeException(params);
    }
    clearSource(researcherUrl);
    ResearcherUrl updatedResearcherUrl = researcherUrlManager.updateResearcherUrl(orcid, researcherUrl, true);
    ElementUtils.setPathToResearcherUrl(updatedResearcherUrl, orcid);
    sourceUtils.setSourceName(updatedResearcherUrl);
    return Response.ok(updatedResearcherUrl).build();
}
Also used : HashMap(java.util.HashMap) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) MismatchedPutCodeException(org.orcid.core.exception.MismatchedPutCodeException)

Example 95 with ResearcherUrl

use of org.orcid.jaxb.model.record_v2.ResearcherUrl in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegatorImpl method viewResearcherUrl.

public Response viewResearcherUrl(String orcid, Long putCode) {
    ResearcherUrl researcherUrl = researcherUrlManagerReadOnly.getResearcherUrl(orcid, putCode);
    orcidSecurityManager.checkAndFilter(orcid, researcherUrl, ScopePathType.ORCID_BIO_READ_LIMITED);
    ElementUtils.setPathToResearcherUrl(researcherUrl, orcid);
    sourceUtils.setSourceName(researcherUrl);
    return Response.ok(researcherUrl).build();
}
Also used : ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl)

Aggregations

ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)86 Test (org.junit.Test)76 OtherName (org.orcid.jaxb.model.record_v2.OtherName)46 Address (org.orcid.jaxb.model.record_v2.Address)45 Keyword (org.orcid.jaxb.model.record_v2.Keyword)44 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)44 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)44 Email (org.orcid.jaxb.model.record_v2.Email)41 Biography (org.orcid.jaxb.model.record_v2.Biography)34 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)34 Addresses (org.orcid.jaxb.model.record_v2.Addresses)32 Emails (org.orcid.jaxb.model.record_v2.Emails)32 Keywords (org.orcid.jaxb.model.record_v2.Keywords)32 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)32 Name (org.orcid.jaxb.model.record_v2.Name)30 Person (org.orcid.jaxb.model.record_v2.Person)30 DBUnitTest (org.orcid.test.DBUnitTest)22 Response (javax.ws.rs.core.Response)20 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)18 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)18