Example usage for org.apache.commons.collections ListUtils isEqualList

List of usage examples for org.apache.commons.collections ListUtils isEqualList

Introduction

In this page you can find the example usage for org.apache.commons.collections ListUtils isEqualList.

Prototype

public static boolean isEqualList(final Collection list1, final Collection list2) 

Source Link

Document

Tests two lists for value-equality as per the equality contract in java.util.List#equals(java.lang.Object) .

Usage

From source file:hydrograph.ui.dataviewer.filter.FilterHelper.java

/**
 * Validate user group selection./*from w w  w . j a v  a2 s.  c o  m*/
 * 
 * @param groupSelectionMap
 *            the group selection map
 * @param selectionList
 *            the selection list
 * @return true, if successful
 */
public boolean validateUserGroupSelection(Map<Integer, List<List<Integer>>> groupSelectionMap,
        List<Integer> selectionList) {
    boolean retValue = true;
    for (int key : groupSelectionMap.keySet()) {
        List<List<Integer>> groups = groupSelectionMap.get(key);
        for (List<Integer> grp : groups) {
            if (selectionList.size() == grp.size()) {
                if (!ListUtils.isEqualList(selectionList, grp)
                        && ListUtils.intersection(selectionList, grp).size() == 0) {
                    retValue = true;
                } else if (ListUtils.isEqualList(selectionList, grp)) {
                    if (createErrorDialog(Messages.GROUP_CLAUSE_ALREADY_EXISTS).open() == SWT.OK) {
                        retValue = false;
                        break;
                    }
                } else if (ListUtils.intersection(selectionList, grp).size() > 0) {
                    if (createErrorDialog(Messages.CANNOT_CREATE_GROUP_CLAUSE).open() == SWT.OK) {
                        retValue = false;
                        break;
                    }
                }
            } else {
                if (ListUtils.isEqualList(ListUtils.intersection(selectionList, grp), grp)) {
                    retValue = true;
                } else if (ListUtils.isEqualList(ListUtils.intersection(grp, selectionList), selectionList)) {
                    retValue = true;
                } else if (ListUtils.intersection(selectionList, grp).size() == 0) {
                    retValue = true;
                } else {
                    if (createErrorDialog(Messages.CANNOT_CREATE_GROUP_CLAUSE).open() == SWT.OK) {
                        retValue = false;
                        break;
                    }
                }
            }
        }
        if (!retValue) {
            break;
        }
    }
    return retValue;
}

From source file:hydrograph.ui.dataviewer.filter.FilterHelper.java

/**
 * Rearrange groups after delete row.//w  w  w .  j a v a  2s  . co  m
 * 
 * @param groupSelectionMap
 *            the group selection map
 * @param selectionList
 *            the selection list
 * @return true, if successful
 */
public boolean rearrangeGroupsAfterDeleteRow(TreeMap<Integer, List<List<Integer>>> groupSelectionMap,
        List<Integer> selectionList) {
    boolean retValue = false;
    int lastKey = groupSelectionMap.lastKey();
    int count = 0;
    for (int i = lastKey; i >= 0; i--) {
        List<List<Integer>> groups = groupSelectionMap.get(i);
        for (int j = 0; j <= groups.size() - 1; j++) {
            if (selectionList.size() == groups.get(j).size()
                    && ListUtils.isEqualList(selectionList, groups.get(j))) {
                count++;
                if (count >= 2) {
                    retValue = true;
                }
            }
        }
    }
    return retValue;
}

From source file:opennlp.tools.textsimilarity.ParseTreeChunk.java

public boolean equals(ParseTreeChunk ch) {
    List<String> lems = ch.getLemmas();
    List<String> poss = ch.POSs;
    return ListUtils.isEqualList(ch.getLemmas(), this.lemmas) && ListUtils.isEqualList(ch.getPOSs(), this.POSs);
}

From source file:org.apache.cocoon.forms.binding.EnhancedRepeaterJXPathBinding.java

public void doSave(Widget frmModel, JXPathContext jxpc) throws BindingException {
    Repeater repeater = (Repeater) selectWidget(frmModel, super.getId());
    if (!(repeater instanceof EnhancedRepeater)) {
        super.doSave(frmModel, jxpc);
        return;//from w  ww.  j a  v a2  s .c  o  m
    }

    EnhancedRepeater rep = (EnhancedRepeater) repeater;
    rep.doPageSave();
    Pointer ptr = jxpc.getPointer(super.getRepeaterPath());
    JXPathContext repeaterContext = jxpc.getRelativeContext(ptr);
    RepeaterJXPathCollection collection = rep.getCollection();
    // iterate updated rows. note: we don't iterate over the whole context
    for (Iterator iter = collection.getUpdatedRows().iterator(); iter.hasNext();) {
        RepeaterItem item = (RepeaterItem) iter.next();
        Repeater.RepeaterRow thisRow = item.getRow();
        // Get the identity
        List identity = getIdentity(thisRow);
        if (hasNonNullElements(identity)) {
            // iterate nodes to find match
            Iterator rowPointers = repeaterContext.iteratePointers(getRowPath());
            while (rowPointers.hasNext()) {
                Pointer jxp = (Pointer) rowPointers.next();
                JXPathContext rowContext = repeaterContext.getRelativeContext(jxp);
                List contextIdentity = getIdentity(rowContext);
                if (ListUtils.isEqualList(identity, contextIdentity)) {
                    getRowBinding().saveFormToModel(thisRow, rowContext);
                    break;
                }
            }
        } else {
            getRowBinding().saveFormToModel(thisRow, item.getContext().getContextPointer());
        }
    }

    for (Iterator iter = collection.getDeletedRows().iterator(); iter.hasNext();) {
        RepeaterItem item = (RepeaterItem) iter.next();
        jxpc.removePath(item.getContext().createPath(".").asPath());
    }

    // insert rows
    int indexCount = collection.getOriginalCollectionSize() - collection.getDeletedRows().size();
    for (Iterator iter = collection.getInsertedRows().iterator(); iter.hasNext();) {
        indexCount++;
        RepeaterItem item = (RepeaterItem) iter.next();

        // Perform the insert row binding.
        if (getInsertRowBinding() != null) {
            getInsertRowBinding().saveFormToModel(item.getRow(), repeaterContext);
        }
        // -->  create the path to let the context be created
        Pointer newRowContextPointer = repeaterContext
                .createPath(super.getInsertRowPath() + "[" + indexCount + "]");
        JXPathContext newRowContext = repeaterContext.getRelativeContext(newRowContextPointer);
        //    + rebind to children for update
        super.getRowBinding().saveFormToModel(item.getRow(), newRowContext);
    }
}

From source file:org.apache.cocoon.forms.binding.RepeaterJXPathBinding.java

/**
 * Uses the mapped identity of each row to detect if rows have been
 * updated, inserted or removed.  Depending on what happened the appropriate
 * child-bindings are allowed to visit the narrowed contexts.
 *//*from  ww  w .  j  a  v  a2  s.c  o m*/
public void doSave(Widget frmModel, JXPathContext jxpc) throws BindingException {
    // Find the repeater
    Repeater repeater = (Repeater) selectWidget(frmModel, this.repeaterId);
    // and his context, creating the path if needed
    JXPathContext repeaterContext = jxpc.getRelativeContext(jxpc.createPath(this.repeaterPath));

    // create set of updatedRowIds
    Set updatedRows = new HashSet();
    //create list of rows to insert at end
    List rowsToInsert = new ArrayList();

    // iterate rows in the form model...
    int formRowCount = repeater.getSize();
    for (int i = 0; i < formRowCount; i++) {
        Repeater.RepeaterRow thisRow = repeater.getRow(i);

        // Get the identity
        List identity = getIdentity(thisRow);

        if (hasNonNullElements(identity)) {
            // iterate nodes to find match
            Iterator rowPointers = repeaterContext.iteratePointers(this.rowPath);
            boolean found = false;
            while (rowPointers.hasNext()) {
                Pointer jxp = (Pointer) rowPointers.next();
                JXPathContext rowContext = repeaterContext.getRelativeContext(jxp);
                List contextIdentity = getIdentity(rowContext);
                if (ListUtils.isEqualList(identity, contextIdentity)) {
                    // match! --> bind to children
                    this.rowBinding.saveFormToModel(thisRow, rowContext);
                    //        --> store rowIdValue in list of updatedRowIds
                    updatedRows.add(identity);
                    found = true;
                    break;
                }
            }
            if (!found) {
                // this is a new row
                rowsToInsert.add(thisRow);
                // also add it to the updated row id's so that this row doesn't get deleted
                updatedRows.add(identity);
            }
        } else {
            // if there is no value to determine the identity --> this is a new row
            rowsToInsert.add(thisRow);
        }
    }
    // Iterate again nodes for deletion
    Iterator rowPointers = repeaterContext.iteratePointers(this.rowPath);
    List rowsToDelete = new ArrayList();
    while (rowPointers.hasNext()) {
        Pointer jxp = (Pointer) rowPointers.next();
        JXPathContext rowContext = repeaterContext.getRelativeContext((Pointer) jxp.clone());
        List contextIdentity = getIdentity(rowContext);
        // check if the identity of the rowContext is in the updated rows
        //     if not --> bind for delete
        if (!isIdentityInUpdatedRows(updatedRows, contextIdentity)) {
            rowsToDelete.add(rowContext);
        }
    }
    if (rowsToDelete.size() > 0) {
        // run backwards through the list, so that we don't get into
        // trouble by shifting indexes
        for (int i = rowsToDelete.size() - 1; i >= 0; i--) {
            if (this.deleteRowBinding != null) {
                this.deleteRowBinding.saveFormToModel(frmModel, rowsToDelete.get(i));
            } else {
                // Simply remove the corresponding path
                ((JXPathContext) rowsToDelete.get(i)).removePath(".");
            }
        }
    }
    // count how many we have now
    int indexCount = 1;
    rowPointers = repeaterContext.iteratePointers(this.rowPathForInsert);
    while (rowPointers.hasNext()) {
        rowPointers.next();
        indexCount++;
    }
    // end with rows to insert (to make sure they don't get deleted!)
    if (rowsToInsert.size() > 0) {
        Iterator rowIterator = rowsToInsert.iterator();
        //register the factory!
        while (rowIterator.hasNext()) {
            Repeater.RepeaterRow thisRow = (Repeater.RepeaterRow) rowIterator.next();
            // Perform the insert row binding.
            if (this.insertRowBinding != null) {
                this.insertRowBinding.saveFormToModel(repeater, repeaterContext);
            }
            // -->  create the path to let the context be created
            Pointer newRowContextPointer = repeaterContext
                    .createPath(this.rowPathForInsert + "[" + indexCount + "]");
            JXPathContext newRowContext = repeaterContext.getRelativeContext(newRowContextPointer);
            if (getLogger().isDebugEnabled()) {
                getLogger().debug("inserted row at " + newRowContextPointer.asPath());
            }
            //    + rebind to children for update
            this.rowBinding.saveFormToModel(thisRow, newRowContext);
            getLogger().debug("bound new row");
            indexCount++;
        }
        //            } else {
        //                if (getLogger().isWarnEnabled()) {
        //                    getLogger().warn("RepeaterBinding has detected rows to insert, but misses "
        //                            + "the <on-insert-row> binding to do it.");
        //                }
        //            }
    }
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("done saving rows " + toString());
    }
}

From source file:org.apache.cocoon.forms.binding.RepeaterJXPathBinding.java

/**
 * Tests if an identity is already contained in a Set of identities.
 * @param identitySet the Set of identities.
 * @param identity the identity that is tested if it is already in the Set.
 * @return true if the Set contains the identity, false otherwise.
 *//*w w  w .ja v  a 2 s.  c o m*/
private boolean isIdentityInUpdatedRows(Set identitySet, List identity) {
    Iterator iter = identitySet.iterator();
    while (iter.hasNext()) {
        List identityFromSet = (List) iter.next();
        if (ListUtils.isEqualList(identityFromSet, identity)) {
            return true;
        }
    }
    return false;
}

From source file:org.apache.cocoon.woody.binding.RepeaterJXPathBinding.java

/**
 * Uses the mapped unique-id of each row to detect if rows have been
 * updated, inserted or removed.  Depending on what happened the appropriate
 * child-bindings are alowed to visit the narrowed contexts.
 *//*  ww w  . j a  va  2s  .  co m*/
public void doSave(Widget frmModel, JXPathContext jxpc) throws BindingException {
    // Find the repeater
    Repeater repeater = (Repeater) frmModel.getWidget(this.repeaterId);
    // and his context
    JXPathContext repeaterContext = jxpc.getRelativeContext(jxpc.getPointer(this.repeaterPath));

    // create set of updatedRowIds
    Set updatedRowIds = new HashSet();
    //create list of rows to insert at end
    List rowsToInsert = new ArrayList();

    // iterate rows in the form model...
    int formRowCount = repeater.getSize();
    for (int i = 0; i < formRowCount; i++) {
        Repeater.RepeaterRow thisRow = repeater.getRow(i);

        // Get the key values
        List rowIdValues = getUniqueRowValues(thisRow);

        if (isAnyListElementNotNull(rowIdValues)) {
            // iterate nodes to find match
            Iterator rowPointers = repeaterContext.iteratePointers(this.rowPath);
            boolean found = false;
            while (rowPointers.hasNext()) {
                Pointer jxp = (Pointer) rowPointers.next();
                JXPathContext rowContext = repeaterContext.getRelativeContext(jxp);
                List matchIds = getMatchIds(rowContext);
                if (ListUtils.isEqualList(rowIdValues, matchIds)) {
                    // match! --> bind to children
                    this.rowBinding.saveFormToModel(thisRow, rowContext);
                    //        --> store rowIdValue in list of updatedRowIds
                    updatedRowIds.add(rowIdValues);
                    found = true;
                    break;
                }
            }
            if (!found) {
                // this is a new row
                rowsToInsert.add(thisRow);
                // also add it to the updated row id's so that this row doesn't get deleted
                updatedRowIds.add(rowIdValues);
            }
        } else {
            // if all rowIdValues == null --> this is a new row
            rowsToInsert.add(thisRow);
        }
    }
    // Iterate again nodes for deletion
    Iterator rowPointers = repeaterContext.iteratePointers(this.rowPath);
    List rowsToDelete = new ArrayList();
    while (rowPointers.hasNext()) {
        Pointer jxp = (Pointer) rowPointers.next();
        JXPathContext rowContext = repeaterContext.getRelativeContext((Pointer) jxp.clone());
        List matchIds = getMatchIds(rowContext);
        // check if matchPath was in list of updates, if not --> bind for delete
        if (!isListInSet(updatedRowIds, matchIds)) {
            rowsToDelete.add(rowContext);
        }
    }
    if (rowsToDelete.size() > 0) {
        if (this.deleteRowBinding != null) {
            // run backwards through the list, so that we don't get into
            // trouble by shifting indexes
            for (int i = rowsToDelete.size() - 1; i >= 0; i--) {
                this.deleteRowBinding.saveFormToModel(frmModel, rowsToDelete.get(i));
            }
        } else {
            if (getLogger().isWarnEnabled()) {
                getLogger().warn("RepeaterBinding has detected rows to delete, "
                        + "but misses the <on-delete-row> binding to do it.");
            }
        }
    }
    // count how many we have now
    int indexCount = 1;
    rowPointers = repeaterContext.iteratePointers(this.rowPathForInsert);
    while (rowPointers.hasNext()) {
        rowPointers.next();
        indexCount++;
    }
    // end with rows to insert (to make sure they don't get deleted!)
    if (rowsToInsert.size() > 0) {
        if (this.insertRowBinding != null) {
            Iterator rowIterator = rowsToInsert.iterator();
            //register the factory!
            while (rowIterator.hasNext()) {
                Repeater.RepeaterRow thisRow = (Repeater.RepeaterRow) rowIterator.next();
                // Perform the insert row binding.
                this.insertRowBinding.saveFormToModel(repeater, repeaterContext);
                // -->  create the path to let the context be created
                Pointer newRowContextPointer = repeaterContext
                        .createPath(this.rowPathForInsert + "[" + indexCount + "]");
                JXPathContext newRowContext = repeaterContext.getRelativeContext(newRowContextPointer);
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("inserted row at " + newRowContextPointer.asPath());
                }
                //    + rebind to children for update
                this.rowBinding.saveFormToModel(thisRow, newRowContext);
                getLogger().debug("bound new row");
                indexCount++;
            }
        } else {
            if (getLogger().isWarnEnabled()) {
                getLogger().warn("RepeaterBinding has detected rows to insert, but misses "
                        + "the <on-insert-row> binding to do it.");
            }
        }
    }
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("done saving rows " + toString());
    }
}

From source file:org.apache.cocoon.woody.binding.RepeaterJXPathBinding.java

/**
 * Tests if a List is already contained in a Set of Lists.
 * @param set the Set of Lists.//  w  w w  . ja v a2  s.  com
 * @param list the list that is tested if it is already in the Set.
 * @return true if the Set contains the List, false otherwise.
 */
private boolean isListInSet(Set set, List list) {
    Iterator iter = set.iterator();
    while (iter.hasNext()) {
        List listFromSet = (List) iter.next();
        if (ListUtils.isEqualList(listFromSet, list)) {
            return true;
        }
    }
    return false;
}

From source file:org.apache.eagle.alert.engine.coordinator.AlertDeduplication.java

@Override
public boolean equals(Object that) {
    if (that == this) {
        return true;
    }//from   ww w. j  a v a2s . c o  m
    if (!(that instanceof AlertDeduplication)) {
        return false;
    }
    AlertDeduplication another = (AlertDeduplication) that;
    if (ListUtils.isEqualList(another.dedupFields, this.dedupFields)
            && Objects.equals(another.dedupIntervalMin, this.dedupIntervalMin)
            && Objects.equals(another.outputStreamId, this.outputStreamId)) {
        return true;
    }
    return false;
}

From source file:org.apache.eagle.alert.engine.interpreter.PolicyExecutionPlannerImpl.java

private PolicyExecutionPlan doParse() throws Exception {
    PolicyExecutionPlan policyExecutionPlan = new PolicyExecutionPlan();
    try {//from   w w  w  .jav a 2  s .  c  o  m
        ExecutionPlan executionPlan = SiddhiCompiler.parse(this.executionPlan);

        policyExecutionPlan.setExecutionPlanDesc(executionPlan.toString());

        // Set current execution plan as valid
        policyExecutionPlan.setExecutionPlanSource(this.executionPlan);
        policyExecutionPlan.setInternalExecutionPlan(executionPlan);

        // Go through execution element
        for (ExecutionElement executionElement : executionPlan.getExecutionElementList()) {
            // -------------
            // Explain Query
            // -------------
            if (executionElement instanceof Query) {
                // -----------------------
                // Query Level Variables
                // -----------------------
                InputStream inputStream = ((Query) executionElement).getInputStream();
                Selector selector = ((Query) executionElement).getSelector();
                Map<String, SingleInputStream> queryLevelAliasToStreamMapping = new HashMap<>();

                // Inputs stream definitions
                for (String streamId : inputStream.getUniqueStreamIds()) {
                    if (!effectiveInputStreams.containsKey(streamId)) {
                        org.wso2.siddhi.query.api.definition.StreamDefinition streamDefinition = executionPlan
                                .getStreamDefinitionMap().get(streamId);
                        if (streamDefinition != null) {
                            effectiveInputStreams.put(streamId, SiddhiDefinitionAdapter
                                    .convertFromSiddiDefinition(streamDefinition).getColumns());
                        } else {
                            effectiveInputStreams.put(streamId, null);
                        }
                    }
                }

                // Window Spec and Partition
                if (inputStream instanceof SingleInputStream) {
                    retrieveAliasForQuery((SingleInputStream) inputStream, queryLevelAliasToStreamMapping);
                    retrievePartition(findStreamPartition((SingleInputStream) inputStream, selector));
                } else {
                    if (inputStream instanceof JoinInputStream) {
                        // Only Support JOIN/INNER_JOIN Now
                        if (((JoinInputStream) inputStream).getType().equals(JoinInputStream.Type.INNER_JOIN)
                                || ((JoinInputStream) inputStream).getType()
                                        .equals(JoinInputStream.Type.JOIN)) {
                            SingleInputStream leftInputStream = (SingleInputStream) ((JoinInputStream) inputStream)
                                    .getLeftInputStream();
                            SingleInputStream rightInputStream = (SingleInputStream) ((JoinInputStream) inputStream)
                                    .getRightInputStream();

                            retrievePartition(findStreamPartition(leftInputStream, selector));
                            retrievePartition(findStreamPartition(rightInputStream, selector));
                            retrieveAliasForQuery(leftInputStream, queryLevelAliasToStreamMapping);
                            retrieveAliasForQuery(rightInputStream, queryLevelAliasToStreamMapping);

                        } else {
                            throw new ExecutionPlanValidationException(
                                    "Not support " + ((JoinInputStream) inputStream).getType()
                                            + " yet, currently support: INNER JOIN");
                        }

                        Expression joinCondition = ((JoinInputStream) inputStream).getOnCompare();

                        if (joinCondition != null) {
                            if (joinCondition instanceof Compare) {
                                if (((Compare) joinCondition).getOperator().equals(Compare.Operator.EQUAL)) {
                                    Variable leftExpression = (Variable) ((Compare) joinCondition)
                                            .getLeftExpression();
                                    Preconditions.checkNotNull(leftExpression.getStreamId());
                                    Preconditions.checkNotNull(leftExpression.getAttributeName());

                                    StreamPartition leftPartition = new StreamPartition();
                                    leftPartition.setType(StreamPartition.Type.GROUPBY);
                                    leftPartition.setColumns(
                                            Collections.singletonList(leftExpression.getAttributeName()));
                                    leftPartition.setStreamId(retrieveStreamId(leftExpression,
                                            effectiveInputStreams, queryLevelAliasToStreamMapping));
                                    retrievePartition(leftPartition);

                                    Variable rightExpression = (Variable) ((Compare) joinCondition)
                                            .getRightExpression();
                                    Preconditions.checkNotNull(rightExpression.getStreamId());
                                    Preconditions.checkNotNull(rightExpression.getAttributeName());
                                    StreamPartition rightPartition = new StreamPartition();
                                    rightPartition.setType(StreamPartition.Type.GROUPBY);
                                    rightPartition.setColumns(
                                            Collections.singletonList(rightExpression.getAttributeName()));
                                    rightPartition.setStreamId(retrieveStreamId(rightExpression,
                                            effectiveInputStreams, queryLevelAliasToStreamMapping));
                                    retrievePartition(leftPartition);
                                } else {
                                    throw new ExecutionPlanValidationException(
                                            "Only support \"EQUAL\" condition in INNER JOIN" + joinCondition);
                                }
                            } else {
                                throw new ExecutionPlanValidationException(
                                        "Only support \"Compare\" on INNER JOIN condition in INNER JOIN: "
                                                + joinCondition);
                            }
                        }
                    } else if (inputStream instanceof StateInputStream) {
                        // Group By Spec
                        List<Variable> groupBy = selector.getGroupByList();
                        if (groupBy.size() >= 0) {
                            Map<String, List<Variable>> streamGroupBy = new HashMap<>();
                            for (String streamId : inputStream.getUniqueStreamIds()) {
                                streamGroupBy.put(streamId, new ArrayList<>());
                            }

                            collectStreamReferenceIdMapping(((StateInputStream) inputStream).getStateElement());

                            for (Variable variable : groupBy) {
                                // Not stream not set, then should be all streams' same field
                                if (variable.getStreamId() == null) {
                                    for (String streamId : inputStream.getUniqueStreamIds()) {
                                        streamGroupBy.get(streamId).add(variable);
                                    }
                                } else {
                                    String streamId = variable.getStreamId();
                                    if (!this.effectiveInputStreamsAlias.containsKey(streamId)) {
                                        streamId = retrieveStreamId(variable, effectiveInputStreams,
                                                queryLevelAliasToStreamMapping);
                                    } else {
                                        streamId = this.effectiveInputStreamsAlias.get(streamId);
                                    }
                                    if (streamGroupBy.containsKey(streamId)) {
                                        streamGroupBy.get(streamId).add(variable);
                                    } else {
                                        throw new DefinitionNotExistException(streamId);
                                    }
                                }
                            }
                            for (Map.Entry<String, List<Variable>> entry : streamGroupBy.entrySet()) {
                                if (entry.getValue().size() > 0) {
                                    StreamPartition partition = generatePartition(entry.getKey(), null,
                                            Arrays.asList(entry.getValue()
                                                    .toArray(new Variable[entry.getValue().size()])));
                                    if (((StateInputStream) inputStream).getStateType()
                                            .equals(StateInputStream.Type.PATTERN)) {
                                        if (effectivePartitions.containsKey(partition.getStreamId())) {
                                            StreamPartition existingPartition = effectivePartitions
                                                    .get(partition.getStreamId());
                                            if (!existingPartition.equals(partition)
                                                    && existingPartition.getType().equals(partition.getType())
                                                    && ListUtils.isEqualList(existingPartition.getColumns(),
                                                            partition.getColumns())) {
                                                partition.setSortSpec(existingPartition.getSortSpec());
                                            }
                                        }
                                    }
                                    retrievePartition(partition);
                                }
                            }
                        }
                    }
                }

                // Output streams
                OutputStream outputStream = ((Query) executionElement).getOutputStream();
                effectiveOutputStreams.put(outputStream.getId(),
                        convertOutputStreamColumns(selector.getSelectionList()));
            } else {
                LOG.warn("Unhandled execution element: {}", executionElement.toString());
            }
        }
        // Set effective input streams
        policyExecutionPlan.setInputStreams(effectiveInputStreams);

        // Set effective output streams
        policyExecutionPlan.setOutputStreams(effectiveOutputStreams);

        // Set Partitions
        for (String streamId : effectiveInputStreams.keySet()) {
            // Use shuffle partition by default
            if (!effectivePartitions.containsKey(streamId)) {
                StreamPartition shufflePartition = new StreamPartition();
                shufflePartition.setStreamId(streamId);
                shufflePartition.setType(StreamPartition.Type.SHUFFLE);
                effectivePartitions.put(streamId, shufflePartition);
            }
        }
        policyExecutionPlan.setStreamPartitions(new ArrayList<>(effectivePartitions.values()));
    } catch (Exception ex) {
        LOG.error("Got error to parse policy execution plan: \n{}", this.executionPlan, ex);
        throw ex;
    }
    return policyExecutionPlan;
}