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

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

Introduction

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

Prototype

public static List subtract(final List list1, final List list2) 

Source Link

Document

Subtracts all elements in the second list from the first list, placing the results in a new list.

Usage

From source file:de.escidoc.core.test.oum.OumTestBase.java

/**
 * Checks if the given arrays contain the same elements regardless of their order.
 *
 * @param array1 The 1st array./*  w ww.  j av a2s  .c o  m*/
 * @param array2 The 2nd array.
 * @return true if the check was successful.
 */
protected boolean compareContent(final String[] array1, final String[] array2) {
    boolean result = true;

    if ((array1 == null) || (array2 == null) || (array1.length != array2.length)) {
        result = false;
    } else {
        result = ListUtils.subtract(Arrays.asList(array1), Arrays.asList(array2)).size() == 0;
    }
    return result;

}

From source file:br.gov.frameworkdemoiselle.component.audit.dashboard.view.UsersDashboardMB.java

@SuppressWarnings("unchecked")
public void onLazyLoad(TimelineLazyLoadEvent e) {

    Date dateBegin = e.getStartDateFirst();
    Date dateFinal = e.getEndDateFirst();

    TimelineUpdater timelineUpdater = TimelineUpdater.getCurrentInstance(":formTabs:tabs:timelineUser");

    trails = ListUtils.subtract(trailBC.findByNamedQueryWithBetween("Trail.findByUserName", "userName",
            user.getUserName(), dateBegin, dateFinal), trails);

    for (Trail trail : trails) {
        this.users.add(new TimelineEvent(trail, trail.getWhen(), false), timelineUpdater);
    }/*from ww w  . j a  va  2 s  .co  m*/

}

From source file:br.gov.frameworkdemoiselle.component.audit.dashboard.view.FeaturesDashboardMB.java

@SuppressWarnings("unchecked")
public void onLazyLoad(TimelineLazyLoadEvent e) {

    Date dataInicio = e.getStartDateFirst();
    Date dataFinal = e.getEndDateFirst();

    TimelineUpdater timelineUpdater = TimelineUpdater.getCurrentInstance(":formTabs:tabs:timelineFeature");

    trails = ListUtils.subtract(trailBC.findByNamedQueryWithBetween("Trail.findByWhat", "what",
            feature.getWhat(), dataInicio, dataFinal), trails);

    for (Trail trail : trails) {
        this.features.add(new TimelineEvent(trail, trail.getWhen(), false), timelineUpdater);
    }//from  w w w .  ja  v a2  s. co  m

}

From source file:com.hs.mail.imap.dao.MySqlSearchDao.java

private List<Long> query(UidToMsnMapper map, long mailboxID, NotKey key) {
    SearchKey k = key.getSearchKey();//from   www .j  ava 2  s  .  c  o m
    if (k.isComposite()) {
        return ListUtils.subtract(map.getUIDList(), query(map, mailboxID, k));
    } else {
        return ListUtils.subtract(map.getUIDList(), query(map, mailboxID, new CompositeKey(k)));
    }
}

From source file:hydrograph.ui.propertywindow.widgets.dialog.hiveInput.HiveFieldDialogHelper.java

/**
 * //  w ww . java  2s.co m
 * @param keyValues
 * @param keyList
 * @param incomingList2 
 */
private void checkAndAdjustRowsColumns(List<HivePartitionFields> keyValues, List<String> keyList,
        List<InputHivePartitionColumn> incomingList) {
    Set<String> colNames = new HashSet<>();
    for (int i = 0; i < incomingList.size(); i++) {

        colNames = extractColumnNamesFromObject(incomingList.get(i), colNames);

        List<String> notAvailableFields = ListUtils.subtract(keyList, new ArrayList<>(colNames));

        if (null != notAvailableFields && notAvailableFields.size() > 0) {
            for (String fieldName : notAvailableFields) {

                keyValues.get(i).getRowFields().add(keyList.indexOf(fieldName), "");
            }
        }
        colNames.clear();
    }

}

From source file:hydrograph.ui.propertywindow.widgets.dialog.hiveInput.HiveFieldDialogHelper.java

/**
 * /*from   w w w  .  j av  a 2 s .  co m*/
 * @param columnNames
 * @param keyList
 * @return
 */
private List<String> checkIfNewColumnAddedOrDeleted(List<String> columnNames, List<String> keyList) {

    if (null != columnNames && !columnNames.isEmpty() && !keyList.isEmpty()) {

        return ListUtils.subtract(keyList, columnNames);

    }

    return new ArrayList<String>();

}

From source file:de.uni_potsdam.hpi.bpt.promnicat.processEvolution.analyses.metricAnalyses.AdditionsDeletionsAnalysis.java

/**
 * find number of additions and deletions for a revision
 * by comparing the IDs of the elements from the previous revision with
 * the new IDs.//  ww w . j a va 2 s  .  c om
 * 
 * @param classToAnalyze the element class to analyze (events, activities, etc.)
 * @param oldElements the elements to compare the new elements to
 * @param revision the actual revision to get the new elements from
 * @param includeSubprocesses flag to decide whether to include subprocesses in the analysis
 * @return the number of additions and deletions for the given element class
 */
@SuppressWarnings("unchecked")
private static Map<AnalysisConstants, Integer> analyzeAddsAndDeletesFor(AnalysisConstants classToAnalyze,
        Map<String, List<String>> oldElements, ProcessEvolutionModelRevision revision,
        boolean includeSubprocesses) {
    List<String> newIDs = new ArrayList<String>();
    List<String> deletions;
    List<String> additions;
    ProcessModel actualModel = revision.getProcessModel();
    switch (classToAnalyze) {
    case EVENTS:
        newIDs = getIDsFor(Event.class, actualModel, includeSubprocesses);
        break;

    case ACTIVITIES:
        newIDs = getIDsFor(Activity.class, actualModel, includeSubprocesses);
        break;

    case EDGES:
        newIDs = getEdgesIDs(actualModel, includeSubprocesses);
        break;

    case ROLES:
        newIDs = getIDsFor(Resource.class, actualModel, includeSubprocesses);
        break;

    case GATEWAYS:
        newIDs = getIDsFor(Gateway.class, actualModel, includeSubprocesses);
        break;

    case DOCUMENTS:
        newIDs = getIDsFor(Document.class, actualModel, includeSubprocesses);
        break;

    default:
        break;
    }
    List<String> oldIDs = oldElements.get(classToAnalyze.getDescription());
    oldIDs = oldIDs == null ? new ArrayList<String>() : oldIDs;
    deletions = ListUtils.subtract(oldIDs, newIDs);
    additions = ListUtils.subtract(newIDs, oldIDs);
    Map<AnalysisConstants, Integer> results = new HashMap<AnalysisConstants, Integer>();
    oldElements.put(classToAnalyze.getDescription(), newIDs);
    results.put(AnalysisConstants.ADDITIONS, additions.size());
    results.put(AnalysisConstants.DELETIONS, deletions.size());
    return results;
}

From source file:com.ebay.cloud.cms.entmgr.entity.impl.EntityFieldDeltaMerger.java

private List<?> mergeDeltaContent(List<?> giveValues, List<?> foundValues) {
    return ListUtils.subtract(giveValues, foundValues);
}

From source file:com.ebay.cloud.cms.dal.persistence.flatten.impl.IndexBuildCommand.java

private Set<String> getUpdateIndex(Map<String, DBObject> exsitingIndexMap, MetaClass meta) {
    Collection<IndexInfo> collection = meta.getIndexes();
    Set<String> updateIndexes = new HashSet<String>();
    for (IndexInfo info : collection) {
        if (exsitingIndexMap.containsKey(info.getIndexName())) {
            boolean diff = false;
            DBObject dbo = exsitingIndexMap.get(info.getIndexName());
            // key check : cast as BasicDBObject, so that we could go through the insert order
            // FIXME :: don't support compare key order. If we support key order specify, then we need to add this comparison 
            BasicDBObject keyObjs = (BasicDBObject) dbo.get("key");
            DBObject keyObject = buildIndexKeyObject(meta, info, onMainBranch);
            diff = !ListUtils.isEqualList(keyObjs.keySet(), keyObject.keySet());

            if (!diff) {
                // option check when keys check passed
                List<IndexOptionEnum> exsitingOption = new ArrayList<IndexInfo.IndexOptionEnum>();
                for (IndexOptionEnum ioe : IndexOptionEnum.values()) {
                    if (dbo.containsField(ioe.name().toLowerCase())
                            && Boolean.parseBoolean(dbo.get(ioe.name().toLowerCase()).toString())) {
                        exsitingOption.add(ioe);
                    }/*from w w w  .  jav a2 s .c o m*/
                }
                if (!ListUtils.subtract(exsitingOption, info.getIndexOptions()).isEmpty()
                        || !ListUtils.subtract(info.getIndexOptions(), exsitingOption).isEmpty()) {
                    diff = true;
                }
            }
            if (diff) {
                updateIndexes.add(info.getIndexName());
            }
        }
    }
    return updateIndexes;
}

From source file:com.hs.mail.imap.dao.MySqlSearchDao.java

private List<Long> query(UidToMsnMapper map, long mailboxID, KeywordKey key) {
    String sql = SearchQuery.toQuery(mailboxID, key);
    if (key.getTestSet()) {
        return getJdbcTemplate().queryForList(sql, Long.class);
    } else {/*from  w w w .  ja v a2s  .c o  m*/
        return ListUtils.subtract(map.getUIDList(), getJdbcTemplate().queryForList(sql, Long.class));
    }
}