Search in sources :

Example 76 with Url

use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.

the class JpaJaxbFundingAdapterTest method toFundingEntityTest.

@Test
public void toFundingEntityTest() throws JAXBException {
    Funding f = getFunding(true);
    assertNotNull(f);
    ProfileFundingEntity pfe = jpaJaxbFundingAdapter.toProfileFundingEntity(f);
    assertNotNull(pfe);
    // Enums
    assertEquals(Visibility.PRIVATE.value(), pfe.getVisibility().value());
    assertEquals(FundingType.GRANT.value(), pfe.getType().value());
    // General info
    assertEquals(Long.valueOf(0), pfe.getId());
    assertEquals("common:title", pfe.getTitle());
    assertEquals("common:translated-title", pfe.getTranslatedTitle());
    assertEquals("en", pfe.getTranslatedTitleLanguageCode());
    assertEquals("funding:organization-defined-type", pfe.getOrganizationDefinedType());
    assertEquals("funding:short-description", pfe.getDescription());
    assertEquals("1234", pfe.getNumericAmount().toString());
    assertEquals("ADP", pfe.getCurrencyCode());
    assertEquals("http://tempuri.org", pfe.getUrl());
    // Dates
    assertEquals(Integer.valueOf(2), pfe.getStartDate().getDay());
    assertEquals(Integer.valueOf(2), pfe.getStartDate().getMonth());
    assertEquals(Integer.valueOf(1848), pfe.getStartDate().getYear());
    assertEquals(Integer.valueOf(2), pfe.getEndDate().getDay());
    assertEquals(Integer.valueOf(2), pfe.getEndDate().getMonth());
    assertEquals(Integer.valueOf(1848), pfe.getEndDate().getYear());
    // Contributors
    assertEquals("{\"contributor\":[{\"contributorOrcid\":{\"uri\":\"http://orcid.org/8888-8888-8888-8880\",\"path\":\"8888-8888-8888-8880\",\"host\":\"orcid.org\"},\"creditName\":{\"content\":\"funding:credit-name\"},\"contributorEmail\":{\"value\":\"funding@contributor.email\"},\"contributorAttributes\":{\"contributorRole\":\"LEAD\"}}]}", pfe.getContributorsJson());
    // External identifiers
    assertEquals("{\"fundingExternalIdentifier\":[{\"type\":\"GRANT_NUMBER\",\"value\":\"funding:external-identifier-value\",\"url\":{\"value\":\"http://tempuri.org\"},\"relationship\":\"SELF\"},{\"type\":\"GRANT_NUMBER\",\"value\":\"funding:external-identifier-value2\",\"url\":{\"value\":\"http://tempuri.org/2\"},\"relationship\":\"SELF\"}]}", pfe.getExternalIdentifiersJson());
    // Check org is null
    assertNull(pfe.getOrg());
    // Source
    assertNull(pfe.getSourceId());
    assertNull(pfe.getClientSourceId());
    assertNull(pfe.getElementSourceId());
}
Also used : Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) Test(org.junit.Test)

Example 77 with Url

use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.

the class JSONExternalIdentifiersConverterV3Test method testConvertFrom.

@Test
public void testConvertFrom() {
    ExternalIDs externalIDs = converter.convertFrom("{\"externalIdentifier\":[{\"type\":\"GRANT_NUMBER\",\"value\":\"external-identifier-value\",\"url\":{\"value\":\"http://tempuri.org\"},\"relationship\":\"SELF\"},{\"type\":\"GRANT_NUMBER\",\"value\":\"external-identifier-value2\",\"url\":{\"value\":\"http://tempuri.org/2\"},\"relationship\":\"SELF\"}]}", null);
    assertNotNull(externalIDs);
    assertEquals(2, externalIDs.getExternalIdentifier().size());
    ExternalID externalID = externalIDs.getExternalIdentifier().get(0);
    assertEquals("grant_number", externalID.getType());
    assertEquals("external-identifier-value", externalID.getValue());
    assertEquals("http://tempuri.org", externalID.getUrl().getValue());
    externalID = externalIDs.getExternalIdentifier().get(1);
    assertEquals("grant_number", externalID.getType());
    assertEquals("external-identifier-value2", externalID.getValue());
    assertEquals("http://tempuri.org/2", externalID.getUrl().getValue());
}
Also used : ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Test(org.junit.Test)

Example 78 with Url

use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.

the class JSONFundingExternalIdentifiersConverterV3Test method testConvertTo.

@Test
public void testConvertTo() throws JAXBException {
    Funding funding = getFunding();
    assertEquals("{\"fundingExternalIdentifier\":[{\"type\":\"GRANT_NUMBER\",\"value\":\"funding:external-identifier-value\",\"url\":{\"value\":\"http://tempuri.org\"},\"relationship\":\"SELF\"},{\"type\":\"GRANT_NUMBER\",\"value\":\"funding:external-identifier-value2\",\"url\":{\"value\":\"http://tempuri.org/2\"},\"relationship\":\"SELF\"}]}", converter.convertTo(funding.getExternalIdentifiers(), null));
}
Also used : Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) Test(org.junit.Test)

Example 79 with Url

use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.

the class ResearcherUrlManagerImpl method updateResearcherUrl.

@Override
@Transactional
public ResearcherUrl updateResearcherUrl(String orcid, ResearcherUrl researcherUrl, boolean isApiRequest) {
    ResearcherUrlEntity updatedResearcherUrlEntity = researcherUrlDao.getResearcherUrl(orcid, researcherUrl.getPutCode());
    Visibility originalVisibility = Visibility.fromValue(updatedResearcherUrlEntity.getVisibility().value());
    SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
    // Save the original source
    String existingSourceId = updatedResearcherUrlEntity.getSourceId();
    String existingClientSourceId = updatedResearcherUrlEntity.getClientSourceId();
    // Validate the researcher url
    PersonValidator.validateResearcherUrl(researcherUrl, sourceEntity, false, isApiRequest, originalVisibility);
    // Validate it is not duplicated
    List<ResearcherUrlEntity> existingResearcherUrls = researcherUrlDao.getResearcherUrls(orcid, getLastModified(orcid));
    for (ResearcherUrlEntity existing : existingResearcherUrls) {
        if (isDuplicated(existing, researcherUrl, sourceEntity)) {
            Map<String, String> params = new HashMap<String, String>();
            params.put("type", "researcher-url");
            params.put("value", researcherUrl.getUrlName());
            throw new OrcidDuplicatedElementException(params);
        }
    }
    orcidSecurityManager.checkSource(updatedResearcherUrlEntity);
    jpaJaxbResearcherUrlAdapter.toResearcherUrlEntity(researcherUrl, updatedResearcherUrlEntity);
    updatedResearcherUrlEntity.setLastModified(new Date());
    // Be sure it doesn't overwrite the source
    updatedResearcherUrlEntity.setSourceId(existingSourceId);
    updatedResearcherUrlEntity.setClientSourceId(existingClientSourceId);
    researcherUrlDao.merge(updatedResearcherUrlEntity);
    return jpaJaxbResearcherUrlAdapter.toResearcherUrl(updatedResearcherUrlEntity);
}
Also used : HashMap(java.util.HashMap) ResearcherUrlEntity(org.orcid.persistence.jpa.entities.ResearcherUrlEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) OrcidDuplicatedElementException(org.orcid.core.exception.OrcidDuplicatedElementException) Visibility(org.orcid.jaxb.model.v3.dev1.common.Visibility) Date(java.util.Date) Transactional(org.springframework.transaction.annotation.Transactional)

Example 80 with Url

use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.

the class ValidateV3_dev1SamplesTest method testMarshallResearcherUrl.

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

Aggregations

Url (org.orcid.jaxb.model.v3.dev1.common.Url)85 Test (org.junit.Test)76 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)68 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)50 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)42 Response (javax.ws.rs.core.Response)28 DBUnitTest (org.orcid.test.DBUnitTest)28 Title (org.orcid.jaxb.model.v3.dev1.common.Title)23 Work (org.orcid.jaxb.model.v3.dev1.record.Work)23 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)19 List (java.util.List)16 PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)13 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)13 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)12 ClientResponse (com.sun.jersey.api.client.ClientResponse)10 DisambiguatedOrganization (org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization)8 TranslatedTitle (org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle)8 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)8 BaseTest (org.orcid.core.BaseTest)7 Organization (org.orcid.jaxb.model.v3.dev1.common.Organization)6