use of org.orcid.jaxb.model.record_rc4.PeerReview in project ORCID-Source by ORCID.
the class Utils method getPeerReview.
public static PeerReview getPeerReview() {
PeerReview peerReview = new PeerReview();
ExternalIDs weis = new ExternalIDs();
ExternalID wei1 = new ExternalID();
wei1.setRelationship(Relationship.PART_OF);
wei1.setUrl(new Url("http://myUrl.com"));
wei1.setValue("work-external-identifier-id");
wei1.setType(WorkExternalIdentifierType.DOI.value());
weis.getExternalIdentifier().add(wei1);
peerReview.setExternalIdentifiers(weis);
peerReview.setGroupId("issn:0000003");
peerReview.setOrganization(getOrganization());
peerReview.setRole(Role.CHAIR);
peerReview.setSubjectContainerName(new Title("subject-container-name"));
peerReview.setSubjectExternalIdentifier(wei1);
WorkTitle workTitle = new WorkTitle();
workTitle.setTitle(new Title("work-title"));
peerReview.setSubjectName(workTitle);
peerReview.setSubjectType(WorkType.DATA_SET);
peerReview.setType(PeerReviewType.EVALUATION);
return peerReview;
}
use of org.orcid.jaxb.model.record_rc4.PeerReview in project ORCID-Source by ORCID.
the class ActivityValidator method validatePeerReview.
public void validatePeerReview(PeerReview peerReview, SourceEntity sourceEntity, boolean createFlag, boolean isApiRequest, Visibility originalVisibility) {
if (peerReview.getExternalIdentifiers() == null || peerReview.getExternalIdentifiers().getExternalIdentifier().isEmpty()) {
throw new ActivityIdentifierValidationException();
}
if (peerReview.getPutCode() != null && createFlag) {
Map<String, String> params = new HashMap<String, String>();
params.put("clientName", sourceEntity.getSourceName());
throw new InvalidPutCodeException(params);
}
if (peerReview.getType() == null) {
Map<String, String> params = new HashMap<String, String>();
String peerReviewTypes = Arrays.stream(PeerReviewType.values()).map(element -> element.value()).collect(Collectors.joining(", "));
params.put("type", "peer review type");
params.put("values", peerReviewTypes);
throw new ActivityTypeValidationException();
}
externalIDValidator.validateWorkOrPeerReview(peerReview.getExternalIdentifiers());
if (peerReview.getSubjectExternalIdentifier() != null) {
externalIDValidator.validateWorkOrPeerReview(peerReview.getSubjectExternalIdentifier());
}
// Check that we are not changing the visibility
if (isApiRequest && !createFlag) {
Visibility updatedVisibility = peerReview.getVisibility();
validateVisibilityDoesntChange(updatedVisibility, originalVisibility);
}
}
use of org.orcid.jaxb.model.record_rc4.PeerReview in project ORCID-Source by ORCID.
the class PeerReviewForm method toPeerReview.
public PeerReview toPeerReview() {
PeerReview peerReview = new PeerReview();
// Put Code
if (!PojoUtil.isEmpty(putCode)) {
peerReview.setPutCode(Long.valueOf(putCode.getValue()));
}
// Visibility
if (visibility != null) {
peerReview.setVisibility(visibility);
}
// Completion date
if (completionDate != null) {
peerReview.setCompletionDate(new FuzzyDate(completionDate.toFuzzyDate()));
}
// External identifiers
if (externalIdentifiers != null && !externalIdentifiers.isEmpty()) {
peerReview.setExternalIdentifiers(new ExternalIDs());
for (WorkExternalIdentifier extId : externalIdentifiers) {
peerReview.getExternalIdentifiers().getExternalIdentifier().add(extId.toRecordWorkExternalIdentifier());
}
}
// Set Organization
Organization organization = new Organization();
OrganizationAddress organizationAddress = new OrganizationAddress();
organization.setAddress(organizationAddress);
if (!PojoUtil.isEmpty(orgName)) {
organization.setName(orgName.getValue());
}
if (!PojoUtil.isEmpty(city)) {
organizationAddress.setCity(city.getValue());
}
if (!PojoUtil.isEmpty(region)) {
organizationAddress.setRegion(region.getValue());
}
if (!PojoUtil.isEmpty(country)) {
organizationAddress.setCountry(Iso3166Country.fromValue(country.getValue()));
}
if (!PojoUtil.isEmpty(disambiguatedOrganizationSourceId)) {
organization.setDisambiguatedOrganization(new DisambiguatedOrganization());
organization.getDisambiguatedOrganization().setDisambiguatedOrganizationIdentifier(disambiguatedOrganizationSourceId.getValue());
organization.getDisambiguatedOrganization().setDisambiguationSource(disambiguationSource.getValue());
}
peerReview.setOrganization(organization);
// Role
if (!PojoUtil.isEmpty(role)) {
peerReview.setRole(Role.fromValue(role.getValue()));
}
// Type
if (!PojoUtil.isEmpty(type)) {
peerReview.setType(PeerReviewType.fromValue(type.getValue()));
}
// Url
if (!PojoUtil.isEmpty(url)) {
peerReview.setUrl(new Url(url.getValue()));
}
// Group id
if (!PojoUtil.isEmpty(groupId)) {
peerReview.setGroupId(groupId.getValue());
}
// Subject external id
if (!PojoUtil.isEmpty(subjectExternalIdentifier)) {
ExternalID subjectExtId = new ExternalID();
if (!PojoUtil.isEmpty(subjectExternalIdentifier.getRelationship())) {
subjectExtId.setRelationship(Relationship.fromValue(subjectExternalIdentifier.getRelationship().getValue()));
}
if (!PojoUtil.isEmpty(subjectExternalIdentifier.getUrl())) {
subjectExtId.setUrl(new Url(subjectExternalIdentifier.getUrl().getValue()));
}
if (!PojoUtil.isEmpty(subjectExternalIdentifier.getWorkExternalIdentifierId())) {
subjectExtId.setValue(subjectExternalIdentifier.getWorkExternalIdentifierId().getValue());
}
if (!PojoUtil.isEmpty(subjectExternalIdentifier.getWorkExternalIdentifierType())) {
subjectExtId.setType(subjectExternalIdentifier.getWorkExternalIdentifierType().getValue());
}
peerReview.setSubjectExternalIdentifier(subjectExtId);
}
// Subject container name
if (!PojoUtil.isEmpty(subjectContainerName)) {
Title containerName = new Title(subjectContainerName.getValue());
peerReview.setSubjectContainerName(containerName);
}
// Subject type
if (!PojoUtil.isEmpty(subjectType)) {
peerReview.setSubjectType(WorkType.fromValue(subjectType.getValue()));
}
// Subject name and subject translated name
if (!PojoUtil.isEmpty(subjectName) || !PojoUtil.isEmpty(translatedSubjectName)) {
WorkTitle workTitle = new WorkTitle();
if (!PojoUtil.isEmpty(subjectName)) {
workTitle.setTitle(new Title(subjectName.getValue()));
}
if (translatedSubjectName != null) {
org.orcid.jaxb.model.common_v2.TranslatedTitle tTitle = new org.orcid.jaxb.model.common_v2.TranslatedTitle();
if (!PojoUtil.isEmpty(translatedSubjectName.getContent())) {
tTitle.setContent(translatedSubjectName.getContent());
}
if (!PojoUtil.isEmpty(translatedSubjectName.getLanguageCode())) {
tTitle.setLanguageCode(translatedSubjectName.getLanguageCode());
}
workTitle.setTranslatedTitle(tTitle);
}
peerReview.setSubjectName(workTitle);
}
//Subject url
if (!PojoUtil.isEmpty(subjectUrl)) {
peerReview.setSubjectUrl(new Url(subjectUrl.getValue()));
}
return peerReview;
}
use of org.orcid.jaxb.model.record_rc4.PeerReview in project ORCID-Source by ORCID.
the class AccessTokenSecurityChecksTest method testTokenIssuedForOneUserFailForOtherUsers_20API.
@Test
public void testTokenIssuedForOneUserFailForOtherUsers_20API() throws JSONException, InterruptedException, URISyntaxException {
String accessToken = getNonCachedAccessTokens(getUser2OrcidId(), getUser2Password(), getScopes(), getClient1ClientId(), getClient1ClientSecret(), getClient1RedirectUri());
String orcid = getUser1OrcidId();
Long putCode = 1L;
Address address = (Address) unmarshallFromPath("/record_2.0/samples/read_samples/address-2.0.xml", Address.class);
evaluateResponse(memberV2ApiClient.createAddress(orcid, address, accessToken));
Education education = (Education) unmarshallFromPath("/record_2.0/samples/read_samples/education-2.0.xml", Education.class);
evaluateResponse(memberV2ApiClient.createEducationJson(orcid, education, accessToken));
evaluateResponse(memberV2ApiClient.createEducationXml(orcid, education, accessToken));
Employment employment = (Employment) unmarshallFromPath("/record_2.0/samples/read_samples/employment-2.0.xml", Employment.class);
evaluateResponse(memberV2ApiClient.createEmploymentJson(orcid, employment, accessToken));
evaluateResponse(memberV2ApiClient.createEmploymentXml(orcid, employment, accessToken));
PersonExternalIdentifier externalIdentifier = (PersonExternalIdentifier) unmarshallFromPath("/record_2.0/samples/read_samples/external-identifier-2.0.xml", PersonExternalIdentifier.class);
evaluateResponse(memberV2ApiClient.createExternalIdentifier(orcid, externalIdentifier, accessToken));
Funding funding = (Funding) unmarshallFromPath("/record_2.0/samples/read_samples/funding-2.0.xml", Funding.class);
evaluateResponse(memberV2ApiClient.createFundingJson(orcid, funding, accessToken));
evaluateResponse(memberV2ApiClient.createFundingXml(orcid, funding, accessToken));
Keyword keyword = (Keyword) unmarshallFromPath("/record_2.0/samples/read_samples/keyword-2.0.xml", Keyword.class);
evaluateResponse(memberV2ApiClient.createKeyword(orcid, keyword, accessToken));
OtherName otherName = (OtherName) unmarshallFromPath("/record_2.0/samples/read_samples/other-name-2.0.xml", OtherName.class);
evaluateResponse(memberV2ApiClient.createOtherName(orcid, otherName, accessToken));
PeerReview peerReview = (PeerReview) unmarshallFromPath("/record_2.0/samples/read_samples/peer-review-2.0.xml", PeerReview.class);
evaluateResponse(memberV2ApiClient.createPeerReviewJson(orcid, peerReview, accessToken));
evaluateResponse(memberV2ApiClient.createPeerReviewXml(orcid, peerReview, accessToken));
ResearcherUrl rUrl = (ResearcherUrl) unmarshallFromPath("/record_2.0/samples/read_samples/researcher-url-2.0.xml", ResearcherUrl.class);
evaluateResponse(memberV2ApiClient.createResearcherUrls(orcid, rUrl, accessToken));
Work work = (Work) unmarshallFromPath("/record_2.0/samples/read_samples/work-2.0.xml", Work.class);
evaluateResponse(memberV2ApiClient.createWorkJson(orcid, work, accessToken));
evaluateResponse(memberV2ApiClient.createWorkXml(orcid, work, accessToken));
evaluateResponse(memberV2ApiClient.deleteAddress(orcid, putCode, accessToken));
evaluateResponse(memberV2ApiClient.deleteEducationXml(orcid, putCode, accessToken));
evaluateResponse(memberV2ApiClient.deleteEmploymentXml(orcid, putCode, accessToken));
evaluateResponse(memberV2ApiClient.deleteExternalIdentifier(orcid, putCode, accessToken));
evaluateResponse(memberV2ApiClient.deleteFundingXml(orcid, putCode, accessToken));
evaluateResponse(memberV2ApiClient.deleteKeyword(orcid, putCode, accessToken));
evaluateResponse(memberV2ApiClient.deleteOtherName(orcid, putCode, accessToken));
evaluateResponse(memberV2ApiClient.deletePeerReviewXml(orcid, putCode, accessToken));
evaluateResponse(memberV2ApiClient.deleteResearcherUrl(orcid, putCode, accessToken));
evaluateResponse(memberV2ApiClient.deleteWorkXml(orcid, putCode, accessToken));
address.setPutCode(putCode);
evaluateResponse(memberV2ApiClient.updateAddress(orcid, address, accessToken));
education.setPutCode(putCode);
evaluateResponse(memberV2ApiClient.updateEducation(orcid, education, accessToken));
employment.setPutCode(putCode);
evaluateResponse(memberV2ApiClient.updateEmployment(orcid, employment, accessToken));
externalIdentifier.setPutCode(putCode);
evaluateResponse(memberV2ApiClient.updateExternalIdentifier(orcid, externalIdentifier, accessToken));
funding.setPutCode(putCode);
evaluateResponse(memberV2ApiClient.updateFunding(orcid, funding, accessToken));
keyword.setPutCode(putCode);
evaluateResponse(memberV2ApiClient.updateKeyword(orcid, keyword, accessToken));
otherName.setPutCode(putCode);
evaluateResponse(memberV2ApiClient.updateOtherName(orcid, otherName, accessToken));
peerReview.setPutCode(putCode);
evaluateResponse(memberV2ApiClient.updatePeerReview(orcid, peerReview, accessToken));
rUrl.setPutCode(putCode);
evaluateResponse(memberV2ApiClient.updateResearcherUrls(orcid, rUrl, accessToken));
work.setPutCode(putCode);
evaluateResponse(memberV2ApiClient.updateWork(orcid, work, accessToken));
evaluateResponse(memberV2ApiClient.getResearcherUrls(orcid, accessToken));
evaluateResponse(memberV2ApiClient.viewAddresses(orcid, accessToken));
evaluateResponse(memberV2ApiClient.viewExternalIdentifiers(orcid, accessToken));
evaluateResponse(memberV2ApiClient.viewKeywords(orcid, accessToken));
evaluateResponse(memberV2ApiClient.viewOtherNames(orcid, accessToken));
evaluateResponse(memberV2ApiClient.viewBiography(orcid, accessToken));
evaluateResponse(memberV2ApiClient.viewPersonalDetailsXML(orcid, accessToken));
evaluateResponse(memberV2ApiClient.viewActivities(orcid, accessToken));
evaluateResponse(memberV2ApiClient.viewPerson(orcid, accessToken));
}
use of org.orcid.jaxb.model.record_rc4.PeerReview in project ORCID-Source by ORCID.
the class BlackBoxBaseRC4 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);
}
}
Aggregations