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());
}
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());
}
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));
}
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);
}
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");
}
Aggregations