Example usage for org.apache.commons.collections.map MultiKeyMap values

List of usage examples for org.apache.commons.collections.map MultiKeyMap values

Introduction

In this page you can find the example usage for org.apache.commons.collections.map MultiKeyMap values.

Prototype

public Collection values() 

Source Link

Usage

From source file:com.navercorp.pinpoint.collector.dao.hbase.stat.HbaseDataSourceListDao.java

private List<DataSourceListBo> reorderDataSourceListBos(List<DataSourceListBo> dataSourceListBos) {
    // reorder dataSourceBo using id and timeSlot
    MultiKeyMap dataSourceListBoMap = new MultiKeyMap();

    for (DataSourceListBo dataSourceListBo : dataSourceListBos) {
        for (DataSourceBo dataSourceBo : dataSourceListBo.getList()) {
            int id = dataSourceBo.getId();
            long timestamp = dataSourceBo.getTimestamp();
            long timeSlot = AgentStatUtils.getBaseTimestamp(timestamp);

            DataSourceListBo mappedDataSourceListBo = (DataSourceListBo) dataSourceListBoMap.get(id, timeSlot);
            if (mappedDataSourceListBo == null) {
                mappedDataSourceListBo = new DataSourceListBo();
                mappedDataSourceListBo.setAgentId(dataSourceBo.getAgentId());
                mappedDataSourceListBo.setStartTimestamp(dataSourceBo.getStartTimestamp());
                mappedDataSourceListBo.setTimestamp(dataSourceBo.getTimestamp());

                dataSourceListBoMap.put(id, timeSlot, mappedDataSourceListBo);
            }//from   w  ww. ja v a  2  s.co m

            // set fastest timestamp
            if (mappedDataSourceListBo.getTimestamp() > dataSourceBo.getTimestamp()) {
                mappedDataSourceListBo.setTimestamp(dataSourceBo.getTimestamp());
            }

            mappedDataSourceListBo.add(dataSourceBo);
        }
    }

    Collection values = dataSourceListBoMap.values();
    return new ArrayList<DataSourceListBo>(values);
}

From source file:com.gs.obevo.db.apps.reveng.DbFileMerger.java

public void generateDiffs(DbPlatform dialect, MutableCollection<DbMergeInfo> dbNameLocationPairs,
        File outputDir) {//  ww  w . j a v a 2  s. c o  m
    System.out.println("Generating diffs for " + dbNameLocationPairs);
    MultiKeyMap objectMap = new MultiKeyMap();
    for (DbMergeInfo dbNameLocationPair : dbNameLocationPairs) {
        FileObject mainDir = FileRetrievalMode.FILE_SYSTEM
                .resolveSingleFileObject(dbNameLocationPair.getInputDir().getAbsolutePath());
        for (FileObject schemaDir : mainDir.getChildren()) {
            if (schemaDir.getType() != FileType.FOLDER) {
                continue;
            }
            for (ChangeType changeType : dialect.getChangeTypes()) {
                FileObject changeTypeDir = schemaDir.getChild(changeType.getDirectoryName());
                if (changeTypeDir != null && changeTypeDir.isReadable()
                        && changeTypeDir.getType() == FileType.FOLDER) {
                    FileObject[] childFiles = changeTypeDir.getChildren();
                    for (FileObject objectFile : childFiles) {
                        if (objectFile.getType() == FileType.FILE) {
                            FileComparison fileComparison = (FileComparison) objectMap.get(changeType,
                                    objectFile.getName().getBaseName());
                            if (fileComparison == null) {
                                fileComparison = new FileComparison(schemaDir.getName().getBaseName(),
                                        changeType, objectFile.getName().getBaseName());
                                objectMap.put(changeType, objectFile.getName().getBaseName(), fileComparison);
                            }

                            fileComparison.addFilePair(Tuples.pair(dbNameLocationPair.getName(), objectFile));
                            String fileContent = objectFile.getStringContent();
                            String normalizedContent = DAStringUtil
                                    .normalizeWhiteSpaceFromStringOld(fileContent);
                            // modify the content here if needed
                            fileComparison.addContentValues(fileContent);
                            fileComparison.addDistinctValue(normalizedContent);
                            fileComparison.incrementCount();
                        }
                    }
                }
            }
        }
    }

    for (FileComparison fileComparison : (Collection<FileComparison>) objectMap.values()) {
        File fileComparisonFileRoot = new File(new File(outputDir, fileComparison.getSchemaName()),
                fileComparison.getChangeType().getDirectoryName());
        if (fileComparison.getDistinctValues().size() == 1) {
            File outputFile;
            if (fileComparison.getCount() == dbNameLocationPairs.size()) {
                outputFile = new File(fileComparisonFileRoot, fileComparison.getName());
            } else {
                MutableList<String> dbNames = fileComparison.getFilePairs()
                        .collect(Functions.<String>firstOfPair());
                String dbNameString = "only-" + dbNames.sortThis().makeString("-");
                File dbDir = new File(fileComparisonFileRoot, dbNameString);
                outputFile = new File(dbDir, fileComparison.getName());

                File packageInfoFile = new File(dbDir, "package-info.txt");
                FileUtilsCobra.writeStringToFile(packageInfoFile, "//// METADATA includeEnvs=\""
                        + dbNames.sortThis().collect(StringFunctions.append("*")).makeString(",") + "\"");
            }
            FileUtilsCobra.writeStringToFile(outputFile, fileComparison.getContentValues().getFirst());
        } else {
            for (Pair<String, FileObject> dbNameFileObjectPair : fileComparison.getFilePairs()) {
                String dbName = dbNameFileObjectPair.getOne();
                File outputFile = new File(new File(fileComparisonFileRoot, dbName), fileComparison.getName());
                File packageInfoFile = new File(new File(fileComparisonFileRoot, dbName), "package-info.txt");

                String fileContent = dbNameFileObjectPair.getTwo().getStringContent();
                FileUtilsCobra.writeStringToFile(outputFile, fileContent);
                FileUtilsCobra.writeStringToFile(packageInfoFile,
                        "//// METADATA includeEnvs=\"" + StringFunctions.append("*").valueOf(dbName) + "\"");
            }
        }
    }
}

From source file:org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobJavaScriptsManager.java

@SuppressWarnings("rawtypes")
protected Set<ModuleNeeded> getModuleNeededs(MultiKeyMap map) {
    Set<ModuleNeeded> modulesSet = new HashSet<ModuleNeeded>(100);
    Collection allModules = map.values();
    for (Object obj : allModules) {
        if (obj instanceof ModuleNeeded) {
            modulesSet.add((ModuleNeeded) obj);
        } else if (obj instanceof Set) {
            Set set = (Set) obj;
            if (!set.isEmpty()) {
                modulesSet.addAll(set);//  w  w  w  .  j a  va2s.  c  om
            }
        }
    }
    return modulesSet;
}