Search in sources :

Example 6 with GroupableActivity

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

the class Api2_0_LastModifiedDatesHelper method calculateLastModified.

public static void calculateLastModified(Group group) {
    Collection<? extends GroupableActivity> activities = group.getActivities();
    if (activities != null && !activities.isEmpty()) {
        Iterator<? extends GroupableActivity> activitiesIterator = activities.iterator();
        LastModifiedDate latest = null;
        while (activitiesIterator.hasNext()) {
            GroupableActivity activity = activitiesIterator.next();
            if (activity.getLastModifiedDate() != null && activity.getLastModifiedDate().after(latest)) {
                latest = activity.getLastModifiedDate();
            }
        }
        group.setLastModifiedDate(latest);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) GroupableActivity(org.orcid.jaxb.model.record_v2.GroupableActivity)

Example 7 with GroupableActivity

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

the class ActivitiesGroupGeneratorBaseTest method checkActivitiesBelongsToTheSameGroup.

/**
     * Check that the given activitys belongs to the same group in a list of given groups
     * */
public void checkActivitiesBelongsToTheSameGroup(List<ActivitiesGroup> groups, GroupableActivity... activities) {
    GroupableActivity first = activities[0];
    assertNotNull(first);
    ActivitiesGroup theGroup = getGroupThatContainsActivity(groups, first);
    assertNotNull(theGroup);
    for (GroupableActivity activity : activities) {
        assertTrue(theGroup.belongsToGroup(activity));
    }
}
Also used : GroupableActivity(org.orcid.jaxb.model.record_v2.GroupableActivity)

Example 8 with GroupableActivity

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

the class ActivitiesGroupGeneratorBaseTest method checkActivitiesDontBelongsToTheSameGroup.

/**
     * Check that the given activities belongs to the same group in a list of given groups
     * */
public void checkActivitiesDontBelongsToTheSameGroup(List<ActivitiesGroup> groups, GroupableActivity... activities) {
    for (int i = 0; i < activities.length; i++) {
        GroupableActivity a1 = activities[i];
        ActivitiesGroup theGroup = getGroupThatContainsActivity(groups, a1);
        for (int j = i + 1; j < activities.length; j++) {
            assertFalse("activity[" + i + "] and activity[" + j + "] belongs to the same group", theGroup.belongsToGroup(activities[j]));
        }
    }
}
Also used : GroupableActivity(org.orcid.jaxb.model.record_v2.GroupableActivity)

Example 9 with GroupableActivity

use of org.orcid.jaxb.model.record_rc2.GroupableActivity 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.common_v2.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.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) GroupableActivity(org.orcid.jaxb.model.record_v2.GroupableActivity) ActivitiesGroupGenerator(org.orcid.core.utils.activities.ActivitiesGroupGenerator) Works(org.orcid.jaxb.model.record.summary_v2.Works) ActivitiesGroup(org.orcid.core.utils.activities.ActivitiesGroup) GroupAble(org.orcid.jaxb.model.record_v2.GroupAble)

Example 10 with GroupableActivity

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

the class Api2_0_rc3_LastModifiedDatesHelper method calculateLastModified.

public static void calculateLastModified(Group group) {
    Collection<? extends GroupableActivity> activities = group.getActivities();
    if (activities != null && !activities.isEmpty()) {
        Iterator<? extends GroupableActivity> activitiesIterator = activities.iterator();
        LastModifiedDate latest = null;
        while (activitiesIterator.hasNext()) {
            GroupableActivity activity = activitiesIterator.next();
            if (activity.getLastModifiedDate() != null && activity.getLastModifiedDate().after(latest)) {
                latest = activity.getLastModifiedDate();
            }
        }
        group.setLastModifiedDate(latest);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_rc3.LastModifiedDate) GroupableActivity(org.orcid.jaxb.model.record_rc3.GroupableActivity)

Aggregations

GroupableActivity (org.orcid.jaxb.model.record_v2.GroupableActivity)8 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)4 GroupAble (org.orcid.jaxb.model.record_v2.GroupAble)4 ActivitiesGroup (org.orcid.core.utils.activities.ActivitiesGroup)3 ActivitiesGroupGenerator (org.orcid.core.utils.activities.ActivitiesGroupGenerator)3 GroupableActivityComparator (org.orcid.core.utils.activities.GroupableActivityComparator)2 Date (java.util.Date)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 LastModifiedDate (org.orcid.jaxb.model.common_rc2.LastModifiedDate)1 LastModifiedDate (org.orcid.jaxb.model.common_rc3.LastModifiedDate)1 LastModifiedDate (org.orcid.jaxb.model.common_rc4.LastModifiedDate)1 LastModifiedDate (org.orcid.jaxb.model.common_v2.LastModifiedDate)1 FundingGroup (org.orcid.jaxb.model.record.summary_v2.FundingGroup)1 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)1 Fundings (org.orcid.jaxb.model.record.summary_v2.Fundings)1 PeerReviewGroup (org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup)1 PeerReviewGroupKey (org.orcid.jaxb.model.record.summary_v2.PeerReviewGroupKey)1 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)1 PeerReviews (org.orcid.jaxb.model.record.summary_v2.PeerReviews)1 WorkGroup (org.orcid.jaxb.model.record.summary_v2.WorkGroup)1