Search in sources :

Example 1 with ActivitiesGroupGenerator

use of org.orcid.core.utils.v3.activities.ActivitiesGroupGenerator 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.v3.dev1.common.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.v3.dev1.record.summary.PeerReviewGroupKey) PeerReviewGroup(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup) PeerReviews(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviews) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) GroupableActivity(org.orcid.jaxb.model.v3.dev1.record.GroupableActivity) GroupableActivityComparator(org.orcid.core.utils.v3.activities.GroupableActivityComparator) PeerReviewSummary(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary) ActivitiesGroupGenerator(org.orcid.core.utils.v3.activities.ActivitiesGroupGenerator) ActivitiesGroup(org.orcid.core.utils.v3.activities.ActivitiesGroup) GroupAble(org.orcid.jaxb.model.v3.dev1.record.GroupAble)

Example 2 with ActivitiesGroupGenerator

use of org.orcid.core.utils.v3.activities.ActivitiesGroupGenerator in project ORCID-Source by ORCID.

the class ProfileFundingManagerReadOnlyImpl method groupFundings.

/**
 * Generate a grouped list of funding with the given list of funding
 *
 * @param fundings
 *          The list of fundings to group
 * @param justPublic
 *          Specify if we want to group only the public elements in the given list
 * @return Fundings element with the FundingSummary elements grouped
 */
@Override
public Fundings groupFundings(List<FundingSummary> fundings, boolean justPublic) {
    ActivitiesGroupGenerator groupGenerator = new ActivitiesGroupGenerator();
    Fundings result = new Fundings();
    for (FundingSummary funding : fundings) {
        if (justPublic && !funding.getVisibility().equals(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC)) {
        // If it is just public and the funding is not public, just
        // ignore it
        } else {
            groupGenerator.group(funding);
        }
    }
    List<ActivitiesGroup> groups = groupGenerator.getGroups();
    for (ActivitiesGroup group : groups) {
        Set<GroupAble> externalIdentifiers = group.getGroupKeys();
        Set<GroupableActivity> activities = group.getActivities();
        FundingGroup fundingGroup = new FundingGroup();
        // Fill the funding groups with the external identifiers
        if (externalIdentifiers == null || externalIdentifiers.isEmpty()) {
            // Initialize the ids as an empty list
            fundingGroup.getIdentifiers().getExternalIdentifier();
        } else {
            for (GroupAble extId : externalIdentifiers) {
                ExternalID fundingExtId = (ExternalID) extId;
                fundingGroup.getIdentifiers().getExternalIdentifier().add(fundingExtId.clone());
            }
        }
        // Fill the funding group with the list of activities
        for (GroupableActivity activity : activities) {
            FundingSummary fundingSummary = (FundingSummary) activity;
            fundingGroup.getFundingSummary().add(fundingSummary);
        }
        // Sort the fundings
        Collections.sort(fundingGroup.getFundingSummary(), new GroupableActivityComparator());
        result.getFundingGroup().add(fundingGroup);
    }
    return result;
}
Also used : Fundings(org.orcid.jaxb.model.v3.dev1.record.summary.Fundings) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) FundingSummary(org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary) GroupableActivity(org.orcid.jaxb.model.v3.dev1.record.GroupableActivity) ActivitiesGroupGenerator(org.orcid.core.utils.v3.activities.ActivitiesGroupGenerator) ActivitiesGroup(org.orcid.core.utils.v3.activities.ActivitiesGroup) GroupAble(org.orcid.jaxb.model.v3.dev1.record.GroupAble) FundingGroup(org.orcid.jaxb.model.v3.dev1.record.summary.FundingGroup) GroupableActivityComparator(org.orcid.core.utils.v3.activities.GroupableActivityComparator)

Example 3 with ActivitiesGroupGenerator

use of org.orcid.core.utils.v3.activities.ActivitiesGroupGenerator in project ORCID-Source by ORCID.

the class WorkManagerReadOnlyImpl method groupWorks.

/**
 * Generate a grouped list of works with the given list of works
 *
 * @param works
 *            The list of works to group
 * @param justPublic
 *            Specify if we want to group only the public elements in the
 *            given list
 * @return Works element with the WorkSummary elements grouped
 */
@Override
public Works groupWorks(List<WorkSummary> works, boolean justPublic) {
    ActivitiesGroupGenerator groupGenerator = new ActivitiesGroupGenerator();
    Works result = new Works();
    // Group all works
    for (WorkSummary work : works) {
        if (justPublic && !work.getVisibility().equals(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC)) {
        // If it is just public and the work is not public, just ignore
        // it
        } else {
            groupGenerator.group(work);
        }
    }
    List<ActivitiesGroup> groups = groupGenerator.getGroups();
    for (ActivitiesGroup group : groups) {
        Set<GroupAble> externalIdentifiers = group.getGroupKeys();
        Set<GroupableActivity> activities = group.getActivities();
        WorkGroup workGroup = new WorkGroup();
        // Fill the work groups with the external identifiers
        if (externalIdentifiers == null || externalIdentifiers.isEmpty()) {
            // Initialize the ids as an empty list
            workGroup.getIdentifiers().getExternalIdentifier();
        } else {
            for (GroupAble extId : externalIdentifiers) {
                ExternalID workExtId = (ExternalID) extId;
                workGroup.getIdentifiers().getExternalIdentifier().add(workExtId.clone());
            }
        }
        // Fill the work group with the list of activities
        for (GroupableActivity activity : activities) {
            WorkSummary workSummary = (WorkSummary) activity;
            workGroup.getWorkSummary().add(workSummary);
        }
        // Sort the works
        workGroup.getWorkSummary().sort(WorkComparators.ALL);
        result.getWorkGroup().add(workGroup);
    }
    // Sort the groups!
    result.getWorkGroup().sort(WorkComparators.GROUP);
    return result;
}
Also used : WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) GroupableActivity(org.orcid.jaxb.model.v3.dev1.record.GroupableActivity) ActivitiesGroupGenerator(org.orcid.core.utils.v3.activities.ActivitiesGroupGenerator) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works) ActivitiesGroup(org.orcid.core.utils.v3.activities.ActivitiesGroup) GroupAble(org.orcid.jaxb.model.v3.dev1.record.GroupAble)

Aggregations

ActivitiesGroup (org.orcid.core.utils.v3.activities.ActivitiesGroup)3 ActivitiesGroupGenerator (org.orcid.core.utils.v3.activities.ActivitiesGroupGenerator)3 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)3 GroupAble (org.orcid.jaxb.model.v3.dev1.record.GroupAble)3 GroupableActivity (org.orcid.jaxb.model.v3.dev1.record.GroupableActivity)3 GroupableActivityComparator (org.orcid.core.utils.v3.activities.GroupableActivityComparator)2 FundingGroup (org.orcid.jaxb.model.v3.dev1.record.summary.FundingGroup)1 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)1 Fundings (org.orcid.jaxb.model.v3.dev1.record.summary.Fundings)1 PeerReviewGroup (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup)1 PeerReviewGroupKey (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroupKey)1 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)1 PeerReviews (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviews)1 WorkGroup (org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup)1 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)1 Works (org.orcid.jaxb.model.v3.dev1.record.summary.Works)1