Search in sources :

Example 1 with ActivityActionsExecutedType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivityActionsExecutedType in project midpoint by Evolveum.

the class ActionsExecutedSummarizer method summarize.

public ActivityActionsExecutedType summarize() {
    // Note: key-related fields in value objects i.e. in ObjectActionsExecutedEntryType instances (objectType, channel, ...)
    // are ignored in the following two maps.
    Map<ActionsExecutedObjectsKey, ObjectActionsExecutedEntryType> allObjectActions = new HashMap<>();
    Map<ActionsExecutedObjectsKey, ObjectActionsExecutedEntryType> resultingObjectActions = new HashMap<>();
    allActions.forEach(action -> addAction(allObjectActions, action));
    for (Map.Entry<String, List<ActionExecuted>> entry : actionsByOid.entrySet()) {
        // Last non-modify operation determines the result
        List<ActionExecuted> actions = entry.getValue();
        assert actions.size() > 0;
        int relevant;
        for (relevant = actions.size() - 1; relevant >= 0; relevant--) {
            if (actions.get(relevant).changeType != ChangeType.MODIFY) {
                break;
            }
        }
        if (relevant < 0) {
            // all are "modify" -> take any (we currently don't care whether successful or not; TODO fix this)
            ActionExecuted actionExecuted = actions.get(actions.size() - 1);
            addAction(resultingObjectActions, actionExecuted);
        } else {
            addAction(resultingObjectActions, actions.get(relevant));
        }
    }
    ActivityActionsExecutedType rv = new ActivityActionsExecutedType();
    mapToBean(allObjectActions, rv.getObjectActionsEntry());
    mapToBean(resultingObjectActions, rv.getResultingObjectActionsEntry());
    return rv;
}
Also used : ActivityActionsExecutedType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivityActionsExecutedType) HashMap(java.util.HashMap) List(java.util.List) ObjectActionsExecutedEntryType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectActionsExecutedEntryType) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

ActivityActionsExecutedType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivityActionsExecutedType)1 ObjectActionsExecutedEntryType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectActionsExecutedEntryType)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1