Search in sources :

Example 31 with ResearcherUrls

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

the class MemberV3ApiServiceDelegator_ResearcherUrlsTest method testViewResearcherUrls.

@Test
public void testViewResearcherUrls() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED);
    Response response = serviceDelegator.viewResearcherUrls("4444-4444-4444-4443");
    assertNotNull(response);
    ResearcherUrls researcherUrls = (ResearcherUrls) response.getEntity();
    assertNotNull(researcherUrls);
    Utils.verifyLastModified(researcherUrls.getLastModifiedDate());
    assertEquals("/4444-4444-4444-4443/researcher-urls", researcherUrls.getPath());
    assertNotNull(researcherUrls.getResearcherUrls());
    assertEquals(5, researcherUrls.getResearcherUrls().size());
    for (ResearcherUrl rUrl : researcherUrls.getResearcherUrls()) {
        assertThat(rUrl.getPutCode(), anyOf(equalTo(Long.valueOf(2)), equalTo(Long.valueOf(3)), equalTo(Long.valueOf(5)), equalTo(Long.valueOf(7)), equalTo(Long.valueOf(8))));
        Utils.verifyLastModified(researcherUrls.getLastModifiedDate());
        assertNotNull(rUrl.getSource());
        assertFalse(PojoUtil.isEmpty(rUrl.getSource().retrieveSourcePath()));
        assertNotNull(rUrl.getUrl());
        assertNotNull(rUrl.getUrlName());
        assertNotNull(rUrl.getVisibility());
        if (rUrl.getPutCode().equals(Long.valueOf(5)) || rUrl.getPutCode().equals(Long.valueOf(7))) {
            assertEquals("APP-5555555555555555", rUrl.getSource().retrieveSourcePath());
        }
    }
}
Also used : Response(javax.ws.rs.core.Response) ResearcherUrls(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 32 with ResearcherUrls

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

the class MemberV3ApiServiceDelegator_ResearcherUrlsTest method testReadPublicScope_ResearcherUrls.

@Test
public void testReadPublicScope_ResearcherUrls() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    // Public works
    Response r = serviceDelegator.viewResearcherUrls(ORCID);
    assertNotNull(r);
    ResearcherUrls ru = (ResearcherUrls) r.getEntity();
    assertNotNull(ru);
    assertEquals("/0000-0000-0000-0003/researcher-urls", ru.getPath());
    Utils.verifyLastModified(ru.getLastModifiedDate());
    assertEquals(3, ru.getResearcherUrls().size());
    boolean found13 = false, found14 = false, found15 = false;
    for (ResearcherUrl element : ru.getResearcherUrls()) {
        if (element.getPutCode() == 13) {
            found13 = true;
        } else if (element.getPutCode() == 14) {
            found14 = true;
        } else if (element.getPutCode() == 15) {
            found15 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found13);
    assertTrue(found14);
    assertTrue(found15);
    r = serviceDelegator.viewResearcherUrl(ORCID, 13L);
    assertNotNull(r);
    assertEquals(ResearcherUrl.class.getName(), r.getEntity().getClass().getName());
    // Limited am the source of should work
    serviceDelegator.viewResearcherUrl(ORCID, 14L);
    // Limited am not the source of should fail
    try {
        serviceDelegator.viewResearcherUrl(ORCID, 16L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    // Private am the source of should work
    serviceDelegator.viewResearcherUrl(ORCID, 15L);
    // Private am not the source of should fail
    try {
        serviceDelegator.viewResearcherUrl(ORCID, 17L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) ResearcherUrls(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) OrcidVisibilityException(org.orcid.core.exception.OrcidVisibilityException) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 33 with ResearcherUrls

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

the class WebsitesForm method toResearcherUrls.

public ResearcherUrls toResearcherUrls() {
    ResearcherUrls researcherUrls = new ResearcherUrls();
    List<ResearcherUrl> ruList = new ArrayList<ResearcherUrl>();
    for (WebsiteForm website : websites) {
        ruList.add(website.toResearcherUrl());
    }
    researcherUrls.setResearcherUrls(ruList);
    return researcherUrls;
}
Also used : ArrayList(java.util.ArrayList) ResearcherUrls(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)

Example 34 with ResearcherUrls

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

the class Api3_0_Dev1LastModifiedDatesHelper method calculateLastModified.

public static void calculateLastModified(ResearcherUrls researcherUrls) {
    if (researcherUrls != null && researcherUrls.getResearcherUrls() != null && !researcherUrls.getResearcherUrls().isEmpty()) {
        LastModifiedDate latest = null;
        for (ResearcherUrl researcherUrl : researcherUrls.getResearcherUrls()) {
            if (researcherUrl.getLastModifiedDate() != null && researcherUrl.getLastModifiedDate().after(latest)) {
                latest = researcherUrl.getLastModifiedDate();
            }
        }
        researcherUrls.setLastModifiedDate(latest);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)

Example 35 with ResearcherUrls

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

the class JpaJaxbResearcherUrlAdapterTest method testToResearcherUrlEntity.

@Test
public void testToResearcherUrlEntity() throws JAXBException {
    ResearcherUrls rUrls = getResearcherUrls();
    assertNotNull(rUrls);
    assertNotNull(rUrls.getResearcherUrls());
    assertEquals(1, rUrls.getResearcherUrls().size());
    ResearcherUrlEntity entity = jpaJaxbResearcherUrlAdapter.toResearcherUrlEntity(rUrls.getResearcherUrls().get(0));
    assertNotNull(entity);
    // General info
    assertEquals(Long.valueOf(1248), entity.getId());
    assertEquals(Visibility.PUBLIC.value(), entity.getVisibility().value());
    assertEquals("http://site1.com/", entity.getUrl());
    assertEquals("Site # 1", entity.getUrlName());
    // Source
    assertNull(entity.getSourceId());
    assertNull(entity.getClientSourceId());
    assertNull(entity.getElementSourceId());
}
Also used : ResearcherUrlEntity(org.orcid.persistence.jpa.entities.ResearcherUrlEntity) ResearcherUrls(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls) Test(org.junit.Test)

Aggregations

ResearcherUrls (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls)52 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)44 Test (org.junit.Test)38 OtherNames (org.orcid.jaxb.model.v3.dev1.record.OtherNames)34 Addresses (org.orcid.jaxb.model.v3.dev1.record.Addresses)33 Keywords (org.orcid.jaxb.model.v3.dev1.record.Keywords)33 PersonExternalIdentifiers (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers)33 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)32 Address (org.orcid.jaxb.model.v3.dev1.record.Address)31 Emails (org.orcid.jaxb.model.v3.dev1.record.Emails)31 Email (org.orcid.jaxb.model.v3.dev1.record.Email)30 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)30 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)30 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)30 Name (org.orcid.jaxb.model.v3.dev1.record.Name)26 Person (org.orcid.jaxb.model.v3.dev1.record.Person)25 Record (org.orcid.jaxb.model.v3.dev1.record.Record)13 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)13 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)13 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)13