Search in sources :

Example 46 with PeerReview

use of org.orcid.jaxb.model.record_rc2.PeerReview in project ORCID-Source by ORCID.

the class ValidateV2IdentifiersTest method testPeerReview.

/**
 * Test both types of identifier here
 *
 * @throws SAXException
 * @throws IOException
 * @throws JAXBException
 * @throws ParserConfigurationException
 */
@Test
public void testPeerReview() throws SAXException, IOException, JAXBException, ParserConfigurationException {
    PeerReview peerReview = unmarshallFromPath("/record_2.0/samples/read_samples/peer-review-2.0.xml", PeerReview.class);
    ExternalID id = peerReview.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertEquals("source-work-id", id.getType());
    assertEquals("work:external-identifier-id", id.getValue());
    assertEquals(new Url("http://orcid.org"), id.getUrl());
    assertEquals(Relationship.SELF, id.getRelationship());
    ExternalID subjectid = peerReview.getSubjectExternalIdentifier();
    assertEquals("doi", subjectid.getType());
    assertEquals("peer-review:subject-external-identifier-id", subjectid.getValue());
    assertEquals(new Url("http://orcid.org"), subjectid.getUrl());
    assertEquals(Relationship.SELF, subjectid.getRelationship());
    Validator validator = getValidator("peer-review");
    validator.validate(marshall(PeerReview.class, peerReview));
    validator.validate(marshallToDOM(PeerReview.class, peerReview));
    // do the full record too
    peerReview = unmarshallFromPath("/record_2.0/samples/read_samples/peer-review-full-2.0.xml", PeerReview.class);
    id = peerReview.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertEquals("source-work-id", id.getType());
    assertEquals("work:external-identifier-id", id.getValue());
    assertEquals(new Url("http://orcid.org"), id.getUrl());
    assertEquals(Relationship.SELF, id.getRelationship());
    subjectid = peerReview.getSubjectExternalIdentifier();
    assertEquals("doi", subjectid.getType());
    assertEquals("peer-review:subject-external-identifier-id", subjectid.getValue());
    assertEquals(new Url("http://orcid.org"), subjectid.getUrl());
    assertEquals(Relationship.SELF, subjectid.getRelationship());
}
Also used : ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Url(org.orcid.jaxb.model.common_v2.Url) Validator(javax.xml.validation.Validator) MarshallingTest(org.orcid.jaxb.model.notification.custom.MarshallingTest) Test(org.junit.Test)

Example 47 with PeerReview

use of org.orcid.jaxb.model.record_rc2.PeerReview in project ORCID-Source by ORCID.

the class ValidateV2RC3Identifiers method testPeerReview.

/**
 * Test both types of identifier here
 *
 * @throws SAXException
 * @throws IOException
 * @throws JAXBException
 * @throws ParserConfigurationException
 */
@Test
public void testPeerReview() throws SAXException, IOException, JAXBException, ParserConfigurationException {
    PeerReview peerReview = unmarshallFromPath("/record_2.0_rc3/samples/peer-review-2.0_rc3.xml", PeerReview.class);
    ExternalID id = peerReview.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertEquals("source-work-id", id.getType());
    assertEquals("work:external-identifier-id", id.getValue());
    assertEquals(new Url("http://orcid.org"), id.getUrl());
    assertEquals(Relationship.SELF, id.getRelationship());
    ExternalID subjectid = peerReview.getSubjectExternalIdentifier();
    assertEquals("doi", subjectid.getType());
    assertEquals("peer-review:subject-external-identifier-id", subjectid.getValue());
    assertEquals(new Url("http://orcid.org"), subjectid.getUrl());
    assertEquals(Relationship.SELF, subjectid.getRelationship());
    Validator validator = getValidator("peer-review");
    validator.validate(marshall(PeerReview.class, peerReview));
    validator.validate(marshallToDOM(PeerReview.class, peerReview));
    // do the full record too
    peerReview = unmarshallFromPath("/record_2.0_rc3/samples/peer-review-full-2.0_rc3.xml", PeerReview.class);
    id = peerReview.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertEquals("source-work-id", id.getType());
    assertEquals("work:external-identifier-id", id.getValue());
    assertEquals(new Url("http://orcid.org"), id.getUrl());
    assertEquals(Relationship.SELF, id.getRelationship());
    subjectid = peerReview.getSubjectExternalIdentifier();
    assertEquals("doi", subjectid.getType());
    assertEquals("peer-review:subject-external-identifier-id", subjectid.getValue());
    assertEquals(new Url("http://orcid.org"), subjectid.getUrl());
    assertEquals(Relationship.SELF, subjectid.getRelationship());
}
Also used : ExternalID(org.orcid.jaxb.model.record_rc3.ExternalID) PeerReview(org.orcid.jaxb.model.record_rc3.PeerReview) Url(org.orcid.jaxb.model.common_rc3.Url) Validator(javax.xml.validation.Validator) MarshallingTest(org.orcid.jaxb.model.notification.custom.MarshallingTest) Test(org.junit.Test)

Example 48 with PeerReview

use of org.orcid.jaxb.model.record_rc2.PeerReview in project ORCID-Source by ORCID.

the class ValidateV2RC4Identifiers method testPeerReview.

/**
 * Test both types of identifier here
 *
 * @throws SAXException
 * @throws IOException
 * @throws JAXBException
 * @throws ParserConfigurationException
 */
@Test
public void testPeerReview() throws SAXException, IOException, JAXBException, ParserConfigurationException {
    PeerReview peerReview = unmarshallFromPath("/record_2.0_rc4/samples/peer-review-2.0_rc4.xml", PeerReview.class);
    ExternalID id = peerReview.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertEquals("source-work-id", id.getType());
    assertEquals("work:external-identifier-id", id.getValue());
    assertEquals(new Url("http://orcid.org"), id.getUrl());
    assertEquals(Relationship.SELF, id.getRelationship());
    ExternalID subjectid = peerReview.getSubjectExternalIdentifier();
    assertEquals("doi", subjectid.getType());
    assertEquals("peer-review:subject-external-identifier-id", subjectid.getValue());
    assertEquals(new Url("http://orcid.org"), subjectid.getUrl());
    assertEquals(Relationship.SELF, subjectid.getRelationship());
    Validator validator = getValidator("peer-review");
    validator.validate(marshall(PeerReview.class, peerReview));
    validator.validate(marshallToDOM(PeerReview.class, peerReview));
    // do the full record too
    peerReview = unmarshallFromPath("/record_2.0_rc4/samples/peer-review-full-2.0_rc4.xml", PeerReview.class);
    id = peerReview.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertEquals("source-work-id", id.getType());
    assertEquals("work:external-identifier-id", id.getValue());
    assertEquals(new Url("http://orcid.org"), id.getUrl());
    assertEquals(Relationship.SELF, id.getRelationship());
    subjectid = peerReview.getSubjectExternalIdentifier();
    assertEquals("doi", subjectid.getType());
    assertEquals("peer-review:subject-external-identifier-id", subjectid.getValue());
    assertEquals(new Url("http://orcid.org"), subjectid.getUrl());
    assertEquals(Relationship.SELF, subjectid.getRelationship());
}
Also used : ExternalID(org.orcid.jaxb.model.record_rc4.ExternalID) PeerReview(org.orcid.jaxb.model.record_rc4.PeerReview) Url(org.orcid.jaxb.model.common_rc4.Url) Validator(javax.xml.validation.Validator) MarshallingTest(org.orcid.jaxb.model.notification.custom.MarshallingTest) Test(org.junit.Test)

Example 49 with PeerReview

use of org.orcid.jaxb.model.record_rc2.PeerReview in project ORCID-Source by ORCID.

the class ValidateV2_1IdentifiersTest method testPeerReview.

/**
 * Test both types of identifier here
 *
 * @throws SAXException
 * @throws IOException
 * @throws JAXBException
 * @throws ParserConfigurationException
 */
@Test
public void testPeerReview() throws SAXException, IOException, JAXBException, ParserConfigurationException {
    PeerReview peerReview = unmarshallFromPath("/record_2.1/samples/read_samples/peer-review-2.1.xml", PeerReview.class);
    ExternalID id = peerReview.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertEquals("source-work-id", id.getType());
    assertEquals("work:external-identifier-id", id.getValue());
    assertEquals(new Url("http://orcid.org"), id.getUrl());
    assertEquals(Relationship.SELF, id.getRelationship());
    ExternalID subjectid = peerReview.getSubjectExternalIdentifier();
    assertEquals("doi", subjectid.getType());
    assertEquals("peer-review:subject-external-identifier-id", subjectid.getValue());
    assertEquals(new Url("http://orcid.org"), subjectid.getUrl());
    assertEquals(Relationship.SELF, subjectid.getRelationship());
    Validator validator = getValidator("peer-review");
    validator.validate(marshall(PeerReview.class, peerReview));
    validator.validate(marshallToDOM(PeerReview.class, peerReview));
    // do the full record too
    peerReview = unmarshallFromPath("/record_2.1/samples/read_samples/peer-review-full-2.1.xml", PeerReview.class);
    id = peerReview.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertEquals("source-work-id", id.getType());
    assertEquals("work:external-identifier-id", id.getValue());
    assertEquals(new Url("http://orcid.org"), id.getUrl());
    assertEquals(Relationship.SELF, id.getRelationship());
    subjectid = peerReview.getSubjectExternalIdentifier();
    assertEquals("doi", subjectid.getType());
    assertEquals("peer-review:subject-external-identifier-id", subjectid.getValue());
    assertEquals(new Url("http://orcid.org"), subjectid.getUrl());
    assertEquals(Relationship.SELF, subjectid.getRelationship());
}
Also used : ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Url(org.orcid.jaxb.model.common_v2.Url) Validator(javax.xml.validation.Validator) MarshallingTest(org.orcid.jaxb.model.notification.custom.MarshallingTest) Test(org.junit.Test)

Example 50 with PeerReview

use of org.orcid.jaxb.model.record_rc2.PeerReview in project ORCID-Source by ORCID.

the class PeerReviewManagerImpl method createPeerReview.

@Override
public PeerReview createPeerReview(String orcid, PeerReview peerReview, boolean isApiRequest) {
    SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
    // If request comes from the API, perform the validations
    if (isApiRequest) {
        // Validate it have at least one ext id
        activityValidator.validatePeerReview(peerReview, sourceEntity, true, isApiRequest, null);
        List<PeerReviewEntity> peerReviews = peerReviewDao.getByUser(orcid, getLastModified(orcid));
        // duplicates
        if (!sourceEntity.getSourceId().equals(orcid)) {
            if (peerReviews != null) {
                for (PeerReviewEntity entity : peerReviews) {
                    PeerReview existing = jpaJaxbPeerReviewAdapter.toPeerReview(entity);
                    activityValidator.checkExternalIdentifiersForDuplicates(peerReview.getExternalIdentifiers(), existing.getExternalIdentifiers(), existing.getSource(), sourceEntity);
                }
            }
        } else {
            // check vocab of external identifiers
            externalIDValidator.validateWorkOrPeerReview(peerReview.getExternalIdentifiers());
            externalIDValidator.validateWorkOrPeerReview(peerReview.getSubjectExternalIdentifier());
        }
        validateGroupId(peerReview);
    }
    PeerReviewEntity entity = jpaJaxbPeerReviewAdapter.toPeerReviewEntity(peerReview);
    // Updates the give organization with the latest organization from
    // database
    OrgEntity updatedOrganization = orgManager.getOrgEntity(peerReview);
    entity.setOrg(updatedOrganization);
    // Set the source
    if (sourceEntity.getSourceProfile() != null) {
        entity.setSourceId(sourceEntity.getSourceProfile().getId());
    }
    if (sourceEntity.getSourceClient() != null) {
        entity.setClientSourceId(sourceEntity.getSourceClient().getId());
    }
    ProfileEntity profile = profileEntityCacheManager.retrieve(orcid);
    entity.setProfile(profile);
    setIncomingPrivacy(entity, profile);
    DisplayIndexCalculatorHelper.setDisplayIndexOnNewEntity(entity, isApiRequest);
    peerReviewDao.persist(entity);
    peerReviewDao.flush();
    notificationManager.sendAmendEmail(orcid, AmendedSection.PEER_REVIEW, createItemList(entity));
    return jpaJaxbPeerReviewAdapter.toPeerReview(entity);
}
Also used : SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) PeerReviewEntity(org.orcid.persistence.jpa.entities.PeerReviewEntity) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity)

Aggregations

Test (org.junit.Test)72 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)66 ClientResponse (com.sun.jersey.api.client.ClientResponse)35 Response (javax.ws.rs.core.Response)17 DBUnitTest (org.orcid.test.DBUnitTest)17 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)16 Url (org.orcid.jaxb.model.common_v2.Url)10 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)10 PeerReview (org.orcid.jaxb.model.record_rc1.PeerReview)9 PeerReviewEntity (org.orcid.persistence.jpa.entities.PeerReviewEntity)8 ArrayList (java.util.ArrayList)7 BaseTest (org.orcid.core.BaseTest)6 WorkExternalIdentifier (org.orcid.jaxb.model.record_rc1.WorkExternalIdentifier)6 WorkExternalIdentifierId (org.orcid.jaxb.model.record_rc1.WorkExternalIdentifierId)6 PeerReview (org.orcid.jaxb.model.record_rc3.PeerReview)6 PeerReview (org.orcid.jaxb.model.record_rc4.PeerReview)6 Funding (org.orcid.jaxb.model.record_v2.Funding)6 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)6 Title (org.orcid.jaxb.model.common_v2.Title)5 Education (org.orcid.jaxb.model.record_v2.Education)5