List of usage examples for java.util NavigableMap put
V put(K key, V value);
From source file:org.nuclos.server.navigation.ejb3.TreeNodeFacadeBean.java
private void subformSubnodes(final List<TreeNode> result, TreeNode node, Collection<MasterDataVO> mds, Collection<EntityTreeViewVO> etvs) { final Iterator<MasterDataVO> it1 = mds.iterator(); final Iterator<EntityTreeViewVO> it2 = etvs.iterator(); final NavigableMap<Integer, List<? extends TreeNode>> subforms = new TreeMap<Integer, List<? extends TreeNode>>(); // add subnodes defined in the module meta data while (it1.hasNext()) { final MasterDataVO mdvoSub = it1.next(); final EntityTreeViewVO etv = it2.next(); assert etv.getEntity().equals(mdvoSub.getField(EntityTreeViewVO.SUBFORM_ENTITY_FIELD)); assert etv.getField().equals(mdvoSub.getField(EntityTreeViewVO.SUBFORM2ENTITY_REF_FIELD)); // This seems to be all right - except for bmw-fdm. (tp) /*/*from w w w . j a v a2 s .c om*/ assert IdUtils.equals(etv.getOriginentityid(), mdvoSub.getId()) : "org: " + etv.getOriginentityid() + " sub: " + mdvoSub.getIntId(); */ final String entity = etv.getEntity(); final String field = etv.getField(); final String foldername = etv.getFoldername(); final boolean active = etv.isActive(); final Integer sortOrder = etv.getSortOrder() == null ? Integer.valueOf(0) : etv.getSortOrder(); if (node instanceof GenericObjectTreeNode) { final GenericObjectTreeNode gotn = (GenericObjectTreeNode) node; // check whether the user has the right to see the subform data Permission permission = SecurityCache.getInstance().getSubForm(getCurrentUserName(), entity) .get(gotn.getStatusId()); if (permission == null || !permission.includesReading()) { continue; } } if (active) { if (!org.apache.commons.lang.StringUtils.isBlank(foldername)) { if (node instanceof GenericObjectTreeNode || node instanceof MasterDataTreeNode) { // only allow Treenodes of those types. SubFormTreeNode treenode = new SubFormTreeNode<Integer>(null, node, mdvoSub); treenode.getSubNodes(); subforms.put(sortOrder, Collections.singletonList(treenode)); } } else { if (Modules.getInstance().isModuleEntity(entity)) { subforms.put(sortOrder, getModuleSubNodes(node, entity, field)); } else { subforms.put(sortOrder, getMasterDataSubNodes(node, entity, field)); } } } } for (List<? extends TreeNode> l : subforms.values()) { result.addAll(l); } }
From source file:org.openstreetmap.osmosis.hbase.utility.MockHTable.java
/** * {@inheritDoc}/*from ww w. j a v a2s.c o m*/ */ @Override public void put(Put put) throws IOException { this.sleeper(); byte[] row = put.getRow(); NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>> rowData = forceFind(data, row, new TreeMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>>(Bytes.BYTES_COMPARATOR)); for (byte[] family : put.getFamilyMap().keySet()) { if (!columnFamilies.contains(new String(family))) { throw new RuntimeException("Not Exists columnFamily : " + new String(family)); } NavigableMap<byte[], NavigableMap<Long, byte[]>> familyData = forceFind(rowData, family, new TreeMap<byte[], NavigableMap<Long, byte[]>>(Bytes.BYTES_COMPARATOR)); for (KeyValue kv : put.getFamilyMap().get(family)) { kv.updateLatestStamp(Bytes.toBytes(System.currentTimeMillis())); byte[] qualifier = kv.getQualifier(); NavigableMap<Long, byte[]> qualifierData = forceFind(familyData, qualifier, new TreeMap<Long, byte[]>()); qualifierData.put(kv.getTimestamp(), kv.getValue()); } } }
From source file:org.structnetalign.merge.BronKerboschMergeJob.java
@Override public List<NavigableSet<Integer>> call() throws Exception { logger.info("Searching for cliques on job " + index + " containing " + graph.getVertexCount() + " vertices and " + graph.getHomologyCount() + " homology edges"); // find the cliques BronKerboschCliqueFinder<Integer, HomologyEdge> finder = new BronKerboschCliqueFinder<>(); // these cliques are ordered from largest to smallest Collection<Set<Integer>> cliques = finder.transform(graph.getHomology()); // just report the cliques we're using logger.info("Job " + index + ": " + "Found " + cliques.size() + " maximal cliques"); int i = 1;//w w w. j a v a 2 s . c om for (Set<Integer> clique : cliques) { logger.debug("Job " + index + ": " + "Clique " + i + ": " + clique); i++; } // partition the cliques by sets of interactions // we call these (maximal) degenerate sets List<NavigableSet<Integer>> simpleDegenerateSets = new ArrayList<NavigableSet<Integer>>(); for (Set<Integer> clique : cliques) { NavigableMap<String, NavigableSet<Integer>> degenerateSetMap = new TreeMap<>(); for (int v : clique) { Collection<Integer> neighbors = graph.getInteractionNeighbors(v); String hash = hashVertexInteractions(neighbors); NavigableSet<Integer> degenerateSet = degenerateSetMap.get(hash); if (degenerateSet == null) { degenerateSet = new TreeSet<>(); degenerateSetMap.put(hash, degenerateSet); } degenerateSet.add(v); logger.trace("Job " + index + ": " + "Found " + hash + " --> " + degenerateSetMap.get(hash)); } for (NavigableSet<Integer> set : degenerateSetMap.values()) { simpleDegenerateSets.add(set); } } /* * Now sort the degenerate sets from largest to smallest. * Take into account the edge case where the sizes are the same. */ Comparator<NavigableSet<Integer>> comparator = new Comparator<NavigableSet<Integer>>() { @Override public int compare(NavigableSet<Integer> clique1, NavigableSet<Integer> clique2) { if (CollectionUtils.isEqualCollection(clique1, clique2)) return 0; if (clique1.size() < clique2.size()) { return 1; } else if (clique1.size() > clique2.size()) { return -1; } else { Iterator<Integer> iter1 = clique1.iterator(); Iterator<Integer> iter2 = clique2.iterator(); while (iter1.hasNext()) { // we know they're the same size int v1 = iter1.next(); int v2 = iter2.next(); if (v1 < v2) { return 1; } else if (v1 > v2) { return -1; } } } // they're the same throughout, so they're equal return 0; } }; List<NavigableSet<Integer>> sortedDegenerateSets = new ArrayList<>(simpleDegenerateSets.size()); sortedDegenerateSets.addAll(simpleDegenerateSets); Collections.sort(sortedDegenerateSets, comparator); /* * Now we want to return only the maximal maximal degenerate sets. */ TreeSet<String> verticesAlreadyUsed = new TreeSet<String>(); List<NavigableSet<Integer>> finalDegenerateSets = new ArrayList<>(sortedDegenerateSets.size()); int nTrivial = 0; int nWeak = 0; // a degenerate set is weak if it contains a vertex that is added first forcliques: for (NavigableSet<Integer> set : sortedDegenerateSets) { // discard trivial degenerate sets if (set.size() < 2) { nTrivial++; continue; } // verify that we haven't already used any vertex in this degenerate set for (int v : set) { String hash = NetworkUtils.hash(v); // use MD5 for safety if (verticesAlreadyUsed.contains(hash)) { // discard this degenerate set and do NOT say we've used any of these vertices nWeak++; continue forcliques; } } // we haven't used any vertex in this degenerate set // now add all of these vertices // do NOT add before, or we'll add vertices we haven't used yet for (int v : set) { String hash = NetworkUtils.hash(v); verticesAlreadyUsed.add(hash); } finalDegenerateSets.add(set); // keep this degenerate set } logger.info("Job " + index + ": " + "Found " + finalDegenerateSets.size() + " strong nontrivial maximal degenerate sets found (" + nTrivial + " trivial and " + nWeak + " weak)"); return finalDegenerateSets; }
From source file:uk.ac.ebi.atlas.experimentpage.baseline.genedistribution.BarChartTrader.java
public NavigableMap<Double, Integer> getChart(Set<Factor> filterFactors, Set<Factor> selectedQueryFactors) { NavigableMap<Double, Integer> barChartPoints = new TreeMap<>(); for (Double scaledCutoff : factorGroupGeneExpressionIndexes.navigableKeySet()) { barChartPoints.put(scaledCutoff, countGenesAboveCutoff( factorGroupGeneExpressionIndexes.get(scaledCutoff), filterFactors, selectedQueryFactors)); }// w w w .j av a 2 s. c om return barChartPoints; }