Search in sources :

Example 6 with PeerReview

use of org.orcid.jaxb.model.record_v2.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;
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) Title(org.orcid.jaxb.model.common_v2.Title) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Url(org.orcid.jaxb.model.common_v2.Url) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl)

Example 7 with PeerReview

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

the class PeerReviewManagerReadOnlyImpl method groupPeerReviews.

/**
     * Generate a grouped list of peer reviews with the given list of peer reviews
     * 
     * @param peerReviews
     *          The list of peer reviews to group
     * @param justPublic
     *          Specify if we want to group only the public elements in the given list
     * @return PeerReviews element with the PeerReviewSummary elements grouped                  
     * */
@Override
public PeerReviews groupPeerReviews(List<PeerReviewSummary> peerReviews, boolean justPublic) {
    ActivitiesGroupGenerator groupGenerator = new ActivitiesGroupGenerator();
    PeerReviews result = new PeerReviews();
    for (PeerReviewSummary peerReview : peerReviews) {
        if (justPublic && !peerReview.getVisibility().equals(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC)) {
        // If it is just public and the funding is not public, just
        // ignore it
        } else {
            groupGenerator.group(peerReview);
        }
    }
    List<ActivitiesGroup> groups = groupGenerator.getGroups();
    for (ActivitiesGroup group : groups) {
        Set<GroupAble> groupKeys = group.getGroupKeys();
        Set<GroupableActivity> activities = group.getActivities();
        PeerReviewGroup peerReviewGroup = new PeerReviewGroup();
        // Fill the peer review groups with the external identifiers
        if (groupKeys == null || groupKeys.isEmpty()) {
            // Initialize the ids as an empty list
            peerReviewGroup.getIdentifiers().getExternalIdentifier();
        } else {
            for (GroupAble groupKey : groupKeys) {
                PeerReviewGroupKey key = (PeerReviewGroupKey) groupKey;
                ExternalID id = new ExternalID();
                //TODO: this is not nice
                id.setType(PeerReviewGroupKey.KEY_NAME);
                id.setValue(key.getGroupId());
                peerReviewGroup.getIdentifiers().getExternalIdentifier().add(id);
            }
        }
        // Fill the peer review group with the list of activities
        for (GroupableActivity activity : activities) {
            PeerReviewSummary peerReviewSummary = (PeerReviewSummary) activity;
            peerReviewGroup.getPeerReviewSummary().add(peerReviewSummary);
        }
        // Sort the peer reviews
        Collections.sort(peerReviewGroup.getPeerReviewSummary(), new GroupableActivityComparator());
        result.getPeerReviewGroup().add(peerReviewGroup);
    }
    return result;
}
Also used : PeerReviewGroupKey(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroupKey) PeerReviewGroup(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup) PeerReviews(org.orcid.jaxb.model.record.summary_v2.PeerReviews) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) GroupableActivity(org.orcid.jaxb.model.record_v2.GroupableActivity) GroupableActivityComparator(org.orcid.core.utils.activities.GroupableActivityComparator) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) ActivitiesGroupGenerator(org.orcid.core.utils.activities.ActivitiesGroupGenerator) ActivitiesGroup(org.orcid.core.utils.activities.ActivitiesGroup) GroupAble(org.orcid.jaxb.model.record_v2.GroupAble)

Example 8 with PeerReview

use of org.orcid.jaxb.model.record_v2.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);
    }
}
Also used : FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) Arrays(java.util.Arrays) Year(org.orcid.jaxb.model.common_v2.Year) InvalidPutCodeException(org.orcid.core.exception.InvalidPutCodeException) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) OrcidStringUtils(org.orcid.utils.OrcidStringUtils) ActivityTitleValidationException(org.orcid.core.exception.ActivityTitleValidationException) OrcidDuplicatedActivityException(org.orcid.core.exception.OrcidDuplicatedActivityException) Contributor(org.orcid.jaxb.model.common_v2.Contributor) ContributorOrcid(org.orcid.jaxb.model.common_v2.ContributorOrcid) Amount(org.orcid.jaxb.model.common_v2.Amount) PojoUtil(org.orcid.pojo.ajaxForm.PojoUtil) HashMap(java.util.HashMap) GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) StringUtils(org.apache.commons.lang3.StringUtils) OrcidValidationException(org.orcid.core.exception.OrcidValidationException) Day(org.orcid.jaxb.model.common_v2.Day) Matcher(java.util.regex.Matcher) ActivityTypeValidationException(org.orcid.core.exception.ActivityTypeValidationException) Source(org.orcid.jaxb.model.common_v2.Source) Map(java.util.Map) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) CitationType(org.orcid.jaxb.model.record_v2.CitationType) Employment(org.orcid.jaxb.model.record_v2.Employment) Funding(org.orcid.jaxb.model.record_v2.Funding) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) PublicationDate(org.orcid.jaxb.model.common_v2.PublicationDate) Resource(javax.annotation.Resource) Month(org.orcid.jaxb.model.common_v2.Month) Collectors(java.util.stream.Collectors) WorkContributors(org.orcid.jaxb.model.record_v2.WorkContributors) ActivityIdentifierValidationException(org.orcid.core.exception.ActivityIdentifierValidationException) WorkType(org.orcid.jaxb.model.record_v2.WorkType) Iso3166Country(org.orcid.jaxb.model.common_v2.Iso3166Country) Visibility(org.orcid.jaxb.model.common_v2.Visibility) Relationship(org.orcid.jaxb.model.record_v2.Relationship) Work(org.orcid.jaxb.model.record_v2.Work) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Pattern(java.util.regex.Pattern) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) SiteConstants(org.orcid.persistence.constants.SiteConstants) Education(org.orcid.jaxb.model.record_v2.Education) ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) PeerReviewType(org.orcid.jaxb.model.record_v2.PeerReviewType) HashMap(java.util.HashMap) InvalidPutCodeException(org.orcid.core.exception.InvalidPutCodeException) ActivityTypeValidationException(org.orcid.core.exception.ActivityTypeValidationException) Visibility(org.orcid.jaxb.model.common_v2.Visibility) ActivityIdentifierValidationException(org.orcid.core.exception.ActivityIdentifierValidationException)

Example 9 with PeerReview

use of org.orcid.jaxb.model.record_v2.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(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.record_v2.ExternalID)

Example 10 with PeerReview

use of org.orcid.jaxb.model.record_v2.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;
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) DisambiguatedOrganization(org.orcid.jaxb.model.common_v2.DisambiguatedOrganization) Organization(org.orcid.jaxb.model.common_v2.Organization) OrganizationAddress(org.orcid.jaxb.model.common_v2.OrganizationAddress) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) FuzzyDate(org.orcid.jaxb.model.common_v2.FuzzyDate) Title(org.orcid.jaxb.model.common_v2.Title) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) Url(org.orcid.jaxb.model.common_v2.Url) DisambiguatedOrganization(org.orcid.jaxb.model.common_v2.DisambiguatedOrganization) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview)

Aggregations

Test (org.junit.Test)72 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)68 ClientResponse (com.sun.jersey.api.client.ClientResponse)35 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)19 Response (javax.ws.rs.core.Response)18 DBUnitTest (org.orcid.test.DBUnitTest)18 Url (org.orcid.jaxb.model.common_v2.Url)11 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)11 Funding (org.orcid.jaxb.model.record_v2.Funding)10 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)10 ArrayList (java.util.ArrayList)9 PeerReview (org.orcid.jaxb.model.record_rc1.PeerReview)9 Education (org.orcid.jaxb.model.record_v2.Education)9 Work (org.orcid.jaxb.model.record_v2.Work)9 PeerReviewEntity (org.orcid.persistence.jpa.entities.PeerReviewEntity)9 OtherName (org.orcid.jaxb.model.record_v2.OtherName)8 BaseTest (org.orcid.core.BaseTest)6 Title (org.orcid.jaxb.model.common_v2.Title)6 WorkExternalIdentifier (org.orcid.jaxb.model.record_rc1.WorkExternalIdentifier)6 WorkExternalIdentifierId (org.orcid.jaxb.model.record_rc1.WorkExternalIdentifierId)6