Search in sources :

Example 16 with PeerReview

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

the class MemberV3Dev1Test method testPeerReviewMustHaveAtLeastOneExtId.

@Test
public void testPeerReviewMustHaveAtLeastOneExtId() throws JSONException, InterruptedException, URISyntaxException {
    PeerReview peerReview = (PeerReview) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/peer-review-3.0_dev1.xml", PeerReview.class);
    peerReview.setPutCode(null);
    peerReview.setGroupId(groupRecords.get(0).getGroupId());
    peerReview.getExternalIdentifiers().getExternalIdentifier().clear();
    String accessToken = getAccessToken();
    ClientResponse postResponse = memberV3Dev1ApiClientImpl.createPeerReviewXml(this.getUser1OrcidId(), peerReview, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), postResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) Test(org.junit.Test)

Example 17 with PeerReview

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

the class JSONPeerReviewWorkExternalIdentifierConverterV3Test method testConvertTo.

@Test
public void testConvertTo() throws JAXBException {
    PeerReview peerReview = getPeerReview();
    assertEquals("{\"relationship\":\"SELF\",\"url\":{\"value\":\"http://orcid.org\"},\"workExternalIdentifierType\":\"DOI\",\"workExternalIdentifierId\":{\"content\":\"peer-review:subject-external-identifier-id\"}}", converter.convertTo(peerReview.getSubjectExternalIdentifier(), null));
}
Also used : PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) Test(org.junit.Test)

Example 18 with PeerReview

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

the class PeerReviewForm method valueOf.

public static PeerReviewForm valueOf(PeerReview peerReview) {
    PeerReviewForm form = new PeerReviewForm();
    // Put code
    if (peerReview.getPutCode() != null) {
        form.setPutCode(Text.valueOf(peerReview.getPutCode()));
    }
    // Visibility
    if (peerReview.getVisibility() != null) {
        form.setVisibility(Visibility.valueOf(peerReview.getVisibility()));
    }
    // Completion date
    if (!PojoUtil.isEmpty(peerReview.getCompletionDate())) {
        form.setCompletionDate(Date.valueOf(peerReview.getCompletionDate()));
    }
    // Role
    if (peerReview.getRole() != null) {
        form.setRole(Text.valueOf(peerReview.getRole().value()));
    }
    // Type
    if (peerReview.getType() != null) {
        form.setType(Text.valueOf(peerReview.getType().value()));
    }
    // Url
    if (!PojoUtil.isEmpty(peerReview.getUrl())) {
        form.setUrl(Text.valueOf(peerReview.getUrl().getValue()));
    }
    // Org info
    if (peerReview.getOrganization() != null) {
        if (!PojoUtil.isEmpty(peerReview.getOrganization().getName())) {
            form.setOrgName(Text.valueOf(peerReview.getOrganization().getName()));
        }
        if (peerReview.getOrganization().getAddress() != null) {
            if (!PojoUtil.isEmpty(peerReview.getOrganization().getAddress().getCity())) {
                form.setCity(Text.valueOf(peerReview.getOrganization().getAddress().getCity()));
            }
            if (peerReview.getOrganization().getAddress().getCountry() != null) {
                form.setCountry(Text.valueOf(peerReview.getOrganization().getAddress().getCountry().value()));
            }
            if (!PojoUtil.isEmpty(peerReview.getOrganization().getAddress().getRegion())) {
                form.setRegion(Text.valueOf(peerReview.getOrganization().getAddress().getRegion()));
            }
        }
        if (peerReview.getOrganization().getDisambiguatedOrganization() != null) {
            if (!PojoUtil.isEmpty(peerReview.getOrganization().getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier())) {
                form.setDisambiguatedOrganizationSourceId(Text.valueOf(peerReview.getOrganization().getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier()));
            }
            if (!PojoUtil.isEmpty(peerReview.getOrganization().getDisambiguatedOrganization().getDisambiguationSource())) {
                form.setDisambiguationSource(Text.valueOf(peerReview.getOrganization().getDisambiguatedOrganization().getDisambiguationSource()));
            }
        }
    }
    // External ids
    if (peerReview.getExternalIdentifiers() != null) {
        List<ExternalID> externalIdentifiers = peerReview.getExternalIdentifiers().getExternalIdentifier();
        form.setExternalIdentifiers(new ArrayList<WorkExternalIdentifier>());
        for (ExternalID extId : externalIdentifiers) {
            form.getExternalIdentifiers().add(WorkExternalIdentifier.valueOf(extId));
        }
    }
    // Group Id
    if (!PojoUtil.isEmpty(peerReview.getGroupId())) {
        form.setGroupId(Text.valueOf(peerReview.getGroupId()));
    }
    // Subject ext Id
    if (peerReview.getSubjectExternalIdentifier() != null) {
        WorkExternalIdentifier wExtId = new WorkExternalIdentifier();
        if (peerReview.getSubjectExternalIdentifier().getRelationship() != null) {
            wExtId.setRelationship(Text.valueOf(peerReview.getSubjectExternalIdentifier().getRelationship().value()));
        }
        if (peerReview.getSubjectExternalIdentifier().getUrl() != null) {
            wExtId.setUrl(Text.valueOf(peerReview.getSubjectExternalIdentifier().getUrl().getValue()));
        }
        if (peerReview.getSubjectExternalIdentifier().getValue() != null) {
            wExtId.setWorkExternalIdentifierId(Text.valueOf(peerReview.getSubjectExternalIdentifier().getValue()));
        }
        if (peerReview.getSubjectExternalIdentifier().getType() != null) {
            wExtId.setWorkExternalIdentifierType(Text.valueOf(peerReview.getSubjectExternalIdentifier().getType()));
        }
        form.setSubjectExternalIdentifier(wExtId);
    }
    // Subject Container name
    if (peerReview.getSubjectContainerName() != null) {
        form.setSubjectContainerName(Text.valueOf(peerReview.getSubjectContainerName().getContent()));
    }
    // Subject type
    if (peerReview.getSubjectType() != null) {
        form.setSubjectType(Text.valueOf(peerReview.getSubjectType().value()));
    }
    // Subject name
    if (peerReview.getSubjectName() != null) {
        if (peerReview.getSubjectName().getTitle() != null) {
            form.setSubjectName(Text.valueOf(peerReview.getSubjectName().getTitle().getContent()));
        }
        TranslatedTitleForm tTitle = new TranslatedTitleForm();
        if (peerReview.getSubjectName().getTranslatedTitle() != null) {
            tTitle.setContent(peerReview.getSubjectName().getTranslatedTitle().getContent());
            tTitle.setLanguageCode(peerReview.getSubjectName().getTranslatedTitle().getLanguageCode());
        }
        form.setTranslatedSubjectName(tTitle);
    }
    // Subject url
    if (peerReview.getSubjectUrl() != null) {
        form.setSubjectUrl(Text.valueOf(peerReview.getSubjectUrl().getValue()));
    }
    // Source
    if (peerReview.getSource() != null) {
        form.setSource(peerReview.getSource().retrieveSourcePath());
        if (peerReview.getSource().getSourceName() != null)
            form.setSourceName(peerReview.getSource().getSourceName().getContent());
    }
    // Created Date
    if (peerReview.getCreatedDate() != null) {
        form.setCreatedDate(Date.valueOf(peerReview.getCreatedDate()));
    }
    // Last modified
    if (peerReview.getLastModifiedDate() != null) {
        form.setLastModified(Date.valueOf(peerReview.getLastModifiedDate()));
    }
    return form;
}
Also used : ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID)

Example 19 with PeerReview

use of org.orcid.jaxb.model.v3.dev1.record.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 && visibility.getVisibility() != null) {
        peerReview.setVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.fromValue(visibility.getVisibility().value()));
    }
    // 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.v3.dev1.common.TranslatedTitle tTitle = new org.orcid.jaxb.model.v3.dev1.common.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;
}
Also used : ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) Organization(org.orcid.jaxb.model.v3.dev1.common.Organization) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) OrganizationAddress(org.orcid.jaxb.model.v3.dev1.common.OrganizationAddress) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) FuzzyDate(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate) Title(org.orcid.jaxb.model.v3.dev1.common.Title) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Url(org.orcid.jaxb.model.v3.dev1.common.Url) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview)

Example 20 with PeerReview

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

the class ActivityValidatorTest method validatePeerReview_emptyExternalIdentifierValueTest.

@Test(expected = ActivityIdentifierValidationException.class)
public void validatePeerReview_emptyExternalIdentifierValueTest() {
    PeerReview pr = getPeerReview();
    pr.getExternalIdentifiers().getExternalIdentifier().get(0).setValue("");
    activityValidator.validatePeerReview(pr, null, true, true, Visibility.PUBLIC);
}
Also used : PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) Test(org.junit.Test)

Aggregations

PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)66 Test (org.junit.Test)49 Response (javax.ws.rs.core.Response)20 DBUnitTest (org.orcid.test.DBUnitTest)20 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)12 PeerReviewEntity (org.orcid.persistence.jpa.entities.PeerReviewEntity)9 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)9 Url (org.orcid.jaxb.model.v3.dev1.common.Url)8 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)8 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)8 Work (org.orcid.jaxb.model.v3.dev1.record.Work)7 BaseTest (org.orcid.core.BaseTest)6 Title (org.orcid.jaxb.model.v3.dev1.common.Title)6 Education (org.orcid.jaxb.model.v3.dev1.record.Education)6 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)6 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)6 ArrayList (java.util.ArrayList)5 Day (org.orcid.jaxb.model.v3.dev1.common.Day)5 Month (org.orcid.jaxb.model.v3.dev1.common.Month)5 Year (org.orcid.jaxb.model.v3.dev1.common.Year)5