List of usage examples for java.util LinkedHashMap keySet
public Set<K> keySet()
From source file:net.sf.maltcms.chromaui.project.spi.DBProjectFactory.java
private static void addTreatmentGroups(LinkedHashMap<String, Set<File>> groupToFile, LinkedHashMap<File, IChromatogramDescriptor> fileToDescriptor, IChromAUIProject icui) { for (String group : groupToFile.keySet()) { ITreatmentGroupDescriptor treatmentGroupDescriptor = new TreatmentGroupDescriptor(); treatmentGroupDescriptor.setName(group); treatmentGroupDescriptor.setDisplayName(group); TreatmentGroupContainer tgc = new TreatmentGroupContainer(); tgc.setTreatmentGroup(treatmentGroupDescriptor); ISampleGroupDescriptor sgd = new SampleGroupDescriptor(); sgd.setName(group);/* w ww . j a v a 2s . c o m*/ sgd.setDisplayName(group); Set<File> files = groupToFile.get(group); for (File f : files) { IChromatogramDescriptor descr = fileToDescriptor.get(f); descr.setTreatmentGroup(treatmentGroupDescriptor); tgc.addMembers(descr); } tgc.setName(group); tgc.setDisplayName(group); icui.addContainer(tgc); } }
From source file:net.sf.maltcms.chromaui.project.spi.DBProjectFactory.java
private static void addSampleGroups(LinkedHashMap<String, Set<File>> sampleGroupToFile, LinkedHashMap<File, IChromatogramDescriptor> fileToDescriptor, IChromAUIProject icui) { for (String group : sampleGroupToFile.keySet()) { ISampleGroupDescriptor sampleGroupDescriptor = new SampleGroupDescriptor(); sampleGroupDescriptor.setName(group); sampleGroupDescriptor.setDisplayName(group); SampleGroupContainer tgc = new SampleGroupContainer(); tgc.setSampleGroup(sampleGroupDescriptor); ISampleGroupDescriptor sgd = new SampleGroupDescriptor(); sgd.setName(group);// w w w . j av a 2 s. c o m sgd.setDisplayName(group); Set<File> files = sampleGroupToFile.get(group); for (File f : files) { IChromatogramDescriptor descr = fileToDescriptor.get(f); descr.setSampleGroup(sampleGroupDescriptor); tgc.addMembers(descr); } tgc.setName(group); tgc.setDisplayName(group); icui.addContainer(tgc); } }
From source file:org.mule.util.JarUtils.java
public static void createJarFileEntries(File jarFile, LinkedHashMap entries) throws Exception { JarOutputStream jarStream = null; FileOutputStream fileStream = null; if (jarFile != null) { logger.debug("Creating jar file " + jarFile.getAbsolutePath()); try {/* www. java2 s. c om*/ fileStream = new FileOutputStream(jarFile); jarStream = new JarOutputStream(fileStream); if (entries != null && !entries.isEmpty()) { Iterator iter = entries.keySet().iterator(); while (iter.hasNext()) { String jarFilePath = (String) iter.next(); Object content = entries.get(jarFilePath); JarEntry entry = new JarEntry(jarFilePath); jarStream.putNextEntry(entry); logger.debug("Adding jar entry " + jarFilePath + " to " + jarFile.getAbsolutePath()); if (content instanceof String) { writeJarEntry(jarStream, ((String) content).getBytes()); } else if (content instanceof byte[]) { writeJarEntry(jarStream, (byte[]) content); } else if (content instanceof File) { writeJarEntry(jarStream, (File) content); } } } jarStream.flush(); fileStream.getFD().sync(); } finally { if (jarStream != null) { try { jarStream.close(); } catch (Exception jarNotClosed) { logger.debug(jarNotClosed); } } if (fileStream != null) { try { fileStream.close(); } catch (Exception fileNotClosed) { logger.debug(fileNotClosed); } } } } }
From source file:org.apache.flex.compiler.internal.projects.SourcePathManager.java
private static boolean arePathsEqual(File[] newPaths, LinkedHashMap<DirectoryID, HashSet<QNameFile>> oldPaths) { if (newPaths.length != oldPaths.size()) return false; int i = 0;//from ww w . ja v a 2 s .c om for (DirectoryID oldPath : oldPaths.keySet()) { if (!newPaths[i].isDirectory()) return false; // all the old paths are directories. If this isn't then it must not be equal DirectoryID newDir = new DirectoryID(newPaths[i]); if (!(newDir.equals(oldPath))) return false; i++; } return true; }
From source file:com.evolveum.midpoint.wf.impl.processors.primary.policy.ProcessSpecifications.java
static ProcessSpecifications createFromRules(List<EvaluatedPolicyRule> rules, PrismContext prismContext) throws ObjectNotFoundException { // Step 1: plain list of approval actions -> map: process-spec -> list of related actions/rules ("collected") LinkedHashMap<WfProcessSpecificationType, List<Pair<ApprovalPolicyActionType, EvaluatedPolicyRule>>> collectedSpecifications = new LinkedHashMap<>(); for (EvaluatedPolicyRule rule : rules) { for (ApprovalPolicyActionType approvalAction : rule.getEnabledActions(ApprovalPolicyActionType.class)) { WfProcessSpecificationType spec = approvalAction.getProcessSpecification(); collectedSpecifications.computeIfAbsent(spec, s -> new ArrayList<>()) .add(new ImmutablePair<>(approvalAction, rule)); }//from www . j a v a 2s. com } // Step 2: resolve references for (WfProcessSpecificationType spec : new HashSet<>(collectedSpecifications.keySet())) { // cloned to avoid concurrent modification exception if (spec != null && spec.getRef() != null) { List<Map.Entry<WfProcessSpecificationType, List<Pair<ApprovalPolicyActionType, EvaluatedPolicyRule>>>> matching = collectedSpecifications .entrySet().stream() .filter(e -> e.getKey() != null && spec.getRef().equals(e.getKey().getName())) .collect(Collectors.toList()); if (matching.isEmpty()) { throw new IllegalStateException("Process specification named '" + spec.getRef() + "' referenced from an approval action couldn't be found"); } else if (matching.size() > 1) { throw new IllegalStateException("More than one process specification named '" + spec.getRef() + "' referenced from an approval action: " + matching); } else { // move all actions/rules to the referenced process specification List<Pair<ApprovalPolicyActionType, EvaluatedPolicyRule>> referencedSpecActions = matching .get(0).getValue(); referencedSpecActions.addAll(collectedSpecifications.get(spec)); collectedSpecifications.remove(spec); } } } Map<String, Pair<ApprovalPolicyActionType, EvaluatedPolicyRule>> actionsMap = null; // Step 3: include other actions for (Map.Entry<WfProcessSpecificationType, List<Pair<ApprovalPolicyActionType, EvaluatedPolicyRule>>> processSpecificationEntry : collectedSpecifications .entrySet()) { WfProcessSpecificationType spec = processSpecificationEntry.getKey(); if (spec == null || spec.getIncludeAction().isEmpty() && spec.getIncludeActionIfPresent().isEmpty()) { continue; } if (actionsMap == null) { actionsMap = createActionsMap(collectedSpecifications.values()); } for (String actionToInclude : spec.getIncludeAction()) { processActionToInclude(actionToInclude, actionsMap, processSpecificationEntry, true); } for (String actionToInclude : spec.getIncludeActionIfPresent()) { processActionToInclude(actionToInclude, actionsMap, processSpecificationEntry, false); } } // Step 4: sorts process specifications and wraps into ProcessSpecification objects ProcessSpecifications rv = new ProcessSpecifications(prismContext); collectedSpecifications.entrySet().stream().sorted((ps1, ps2) -> { WfProcessSpecificationType key1 = ps1.getKey(); WfProcessSpecificationType key2 = ps2.getKey(); if (key1 == null) { return key2 == null ? 0 : 1; // non-empty (key2) records first } else if (key2 == null) { return -1; // non-empty (key1) record first } int order1 = defaultIfNull(key1.getOrder(), Integer.MAX_VALUE); int order2 = defaultIfNull(key2.getOrder(), Integer.MAX_VALUE); return Integer.compare(order1, order2); }).forEach(e -> rv.specifications.add(rv.new ProcessSpecification(e))); return rv; }
From source file:org.neo4j.nlp.impl.util.VectorUtil.java
public static Map<String, List<LinkedHashMap<String, Object>>> similarDocumentMapForVector( GraphDatabaseService db, GraphManager graphManager, String input, DecisionTree<Long> decisionTree) { Map<String, List<LinkedHashMap<String, Object>>> documents; Map<String, List<LinkedHashMap<String, Object>>> results = new HashMap<>(); List<Integer> featureIndexList; VsmCacheModel vsmCacheModel = new VsmCacheModel(db).invoke(); featureIndexList = vsmCacheModel.getFeatureIndexList(); documents = vsmCacheModel.getDocuments(); List<Double> features = getFeatureVector(db, graphManager, input, featureIndexList, decisionTree); List<LinkedHashMap<String, Object>> resultList = new ArrayList<>(); LinkedHashMap<String, Double> classMap = new LinkedHashMap<>(); documents.keySet().stream().forEach(otherKey -> { List<Double> v2 = getWeightVectorForClass(documents, otherKey, featureIndexList, db); classMap.put(otherKey, cosineSimilarity(features, v2)); });//ww w . java 2s. c om classMap.keySet().stream().forEach(ks -> { if (classMap.get(ks) > 0.0) { LinkedHashMap<String, Object> localMap = new LinkedHashMap<>(); localMap.put("class", ks); localMap.put("similarity", classMap.get(ks)); resultList.add(localMap); } }); try { resultList.sort((a, b) -> { Double diff = (((double) a.get("similarity")) - ((double) b.get("similarity"))); return diff > 0 ? -1 : diff.equals(0.0) ? 0 : 1; }); } catch (NullPointerException ex) { // resultList is empty or null } results.put("classes", resultList); return results; }
From source file:odoo.controls.OSelectionField.java
public static List<ODataRow> getRecordItems(OModel model, OColumn column, Bundle formData) { List<ODataRow> items = new ArrayList<>(); OModel rel_model = model.createInstance(column.getType()); StringBuilder whr = new StringBuilder(); List<Object> args_list = new ArrayList<>(); LinkedHashMap<String, OColumn.ColumnDomain> domains = new LinkedHashMap<>(); domains.putAll(column.getDomains()); if (column.hasDomainFilterColumn()) { domains.putAll(column.getDomainFilterParser(model).getDomain(formData)); }//from w w w . j a va 2s . c o m for (String key : domains.keySet()) { OColumn.ColumnDomain domain = domains.get(key); if (domain.getConditionalOperator() != null) { whr.append(domain.getConditionalOperator()); } else { whr.append(" "); whr.append(domain.getColumn()); whr.append(" "); whr.append(domain.getOperator()); whr.append(" ? "); args_list.add(domain.getValue() + ""); } } String where = null; String[] args = null; if (args_list.size() > 0) { where = whr.toString(); args = args_list.toArray(new String[args_list.size()]); } List<ODataRow> rows = rel_model.select(new String[] { rel_model.getDefaultNameColumn() }, where, args, rel_model.getDefaultNameColumn()); ODataRow row = new ODataRow(); row.put(OColumn.ROW_ID, -1); row.put(rel_model.getDefaultNameColumn(), "No " + column.getLabel() + " selected"); items.add(row); items.addAll(rows); return items; }
From source file:com.cburch.logisim.gui.main.SelectionAttributes.java
private static LinkedHashMap<Attribute<Object>, Object> computeAttributes(Collection<Component> newSel) { LinkedHashMap<Attribute<Object>, Object> attrMap; attrMap = new LinkedHashMap<Attribute<Object>, Object>(); Iterator<Component> sit = newSel.iterator(); if (sit.hasNext()) { AttributeSet first = sit.next().getAttributeSet(); for (Attribute<?> attr : first.getAttributes()) { @SuppressWarnings("unchecked") Attribute<Object> attrObj = (Attribute<Object>) attr; attrMap.put(attrObj, first.getValue(attr)); }/*ww w . ja v a2 s . c om*/ while (sit.hasNext()) { AttributeSet next = sit.next().getAttributeSet(); Iterator<Attribute<Object>> ait = attrMap.keySet().iterator(); while (ait.hasNext()) { Attribute<Object> attr = ait.next(); if (next.containsAttribute(attr)) { Object v = attrMap.get(attr); if (v != null && !v.equals(next.getValue(attr))) { attrMap.put(attr, null); } } else { ait.remove(); } } } } return attrMap; }
From source file:com.google.gwt.emultest.java.util.LinkedHashMapTest.java
/** * Check the state of a newly constructed, empty LinkedHashMap. * * @param hashMap/* w w w. ja v a2 s . c o m*/ */ private static void checkEmptyLinkedHashMapAssumptions(LinkedHashMap<?, ?> hashMap) { assertNotNull(hashMap); assertTrue(hashMap.isEmpty()); assertNotNull(hashMap.values()); assertTrue(hashMap.values().isEmpty()); assertTrue(hashMap.values().size() == 0); assertNotNull(hashMap.keySet()); assertTrue(hashMap.keySet().isEmpty()); assertTrue(hashMap.keySet().size() == 0); assertNotNull(hashMap.entrySet()); assertTrue(hashMap.entrySet().isEmpty()); assertTrue(hashMap.entrySet().size() == 0); assertNotNull(hashMap.entrySet().iterator()); assertFalse(hashMap.entrySet().iterator().hasNext()); }
From source file:org.neo4j.nlp.impl.util.VectorUtil.java
public static Map<String, List<LinkedHashMap<String, Object>>> similarDocumentMapForClass( GraphDatabaseService db, String className) { Map<String, List<LinkedHashMap<String, Object>>> documents; Map<String, List<LinkedHashMap<String, Object>>> results = new HashMap<>(); List<Integer> featureIndexList; VsmCacheModel vsmCacheModel = new VsmCacheModel(db).invoke(); featureIndexList = vsmCacheModel.getFeatureIndexList(); documents = vsmCacheModel.getDocuments(); final String key = className; List<LinkedHashMap<String, Object>> resultList = new ArrayList<>(); LinkedHashMap<String, Double> classMap = new LinkedHashMap<>(); List<Double> v1 = getFeatureVectorForDocumentClass(documents, featureIndexList, key); documents.keySet().stream().filter(otherKey -> !key.equals(otherKey)).forEach(otherKey -> { List<Double> v2 = getBinaryFeatureVectorForDocumentClass(documents, featureIndexList, otherKey); classMap.put(otherKey, cosineSimilarity(v1, v2)); });//from ww w . ja v a 2s . c om classMap.keySet().forEach(ks -> { if (!ks.equals(key) && classMap.get(ks) > 0.0) { LinkedHashMap<String, Object> localMap = new LinkedHashMap<>(); localMap.put("class", ks); localMap.put("similarity", classMap.get(ks)); resultList.add(localMap); } }); resultList.sort((a, b) -> { Double diff = (((double) a.get("similarity")) - ((double) b.get("similarity"))); return diff > 0 ? -1 : diff.equals(0.0) ? 0 : 1; }); results.put("classes", resultList); return results; }