use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.
the class Utils method getPersonExternalIdentifier.
public static PersonExternalIdentifier getPersonExternalIdentifier() {
PersonExternalIdentifier newExtId = new PersonExternalIdentifier();
newExtId.setType("new-common-name");
newExtId.setValue("new-reference");
newExtId.setUrl(new Url("http://newUrl.com"));
newExtId.setVisibility(Visibility.LIMITED);
return newExtId;
}
use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.
the class Utils method getFunding.
public static Funding getFunding() {
Funding newFunding = new Funding();
FundingTitle title = new FundingTitle();
title.setTitle(new Title("Public Funding # 2"));
newFunding.setTitle(title);
newFunding.setType(FundingType.AWARD);
ExternalID fExtId = new ExternalID();
fExtId.setRelationship(Relationship.PART_OF);
fExtId.setType(FundingExternalIdentifierType.GRANT_NUMBER.value());
fExtId.setUrl(new Url("http://fundingExtId.com"));
fExtId.setValue("new-funding-ext-id");
ExternalIDs fExtIds = new ExternalIDs();
fExtIds.getExternalIdentifier().add(fExtId);
newFunding.setExternalIdentifiers(fExtIds);
newFunding.setOrganization(getOrganization());
return newFunding;
}
use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.
the class Utils method getWork.
public static Work getWork(String title) {
Work work = new Work();
WorkTitle workTitle = new WorkTitle();
workTitle.setTitle(new Title(title));
work.setWorkTitle(workTitle);
work.setWorkType(WorkType.BOOK);
work.setVisibility(Visibility.PUBLIC);
ExternalIDs extIds = new ExternalIDs();
ExternalID extId = new ExternalID();
extId.setRelationship(Relationship.PART_OF);
extId.setType(WorkExternalIdentifierType.AGR.value());
extId.setValue("ext-id-" + System.currentTimeMillis());
extId.setUrl(new Url("http://thisIsANewUrl.com"));
extIds.getExternalIdentifier().add(extId);
work.setWorkExternalIdentifiers(extIds);
return work;
}
use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.
the class PersonValidatorTest method validateExternalIdentifier_invalidUrl_emptyUrlTest.
@Test(expected = OrcidValidationException.class)
public void validateExternalIdentifier_invalidUrl_emptyUrlTest() {
PersonExternalIdentifier extId = getPersonExternalIdentifier();
extId.setUrl(new Url());
PersonValidator.validateExternalIdentifier(extId, getSourceEntity(), true, true, Visibility.PUBLIC, true);
fail();
}
use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.
the class WorkspaceController method setWebsitesFormJson.
/**
* Retrieve all external identifiers as a json string
*/
@RequestMapping(value = "/my-orcid/websitesForms.json", method = RequestMethod.POST)
@ResponseBody
public WebsitesForm setWebsitesFormJson(HttpServletRequest request, @RequestBody WebsitesForm ws) throws NoSuchRequestHandlingMethodException {
ws.setErrors(new ArrayList<String>());
if (ws != null) {
Set<String> existingUrls = new HashSet<String>();
for (WebsiteForm w : ws.getWebsites()) {
// Clean old errors
w.setErrors(new ArrayList<String>());
// Validate url
validateUrl(w.getUrl());
copyErrors(w.getUrl(), w);
// Validate url name
if (isLongerThan(w.getUrlName(), SiteConstants.URL_NAME_MAX_LENGTH)) {
w.getErrors().add(getMessage("manualWork.length_less_X", SiteConstants.URL_NAME_MAX_LENGTH));
}
// Check there are no duplicates
if (existingUrls.contains(w.getUrl().getValue())) {
w.getErrors().add(getMessage("researcher_url.error.duplicated", w.getUrl()));
} else {
existingUrls.add(w.getUrl().getValue());
}
// Validate visibility is not null
validateVisibility(w);
copyErrors(w, ws);
copyErrors(w.getUrl(), ws);
copyErrors(w.getVisibility(), ws);
}
if (ws.getErrors().size() > 0) {
return ws;
}
ResearcherUrls rUrls = ws.toResearcherUrls();
researcherUrlManager.updateResearcherUrls(getCurrentUserOrcid(), rUrls);
}
return ws;
}
Aggregations