List of usage examples for org.apache.commons.collections15.multimap MultiHashMap get
public Collection<V> get(Object key)
From source file:net.sqs2.omr.result.export.spreadsheet.ExcelExportModule.java
private void setExceptionCell(MultiHashMap<PageID, PageTaskException> taskExceptionMultiHashMap, Cell[][] cellArray, int sheetIndex) { String errorMessage = null;/*from w ww . j ava 2 s . co m*/ for (PageID pageID : taskExceptionMultiHashMap.keySet()) { for (PageTaskException pageTaskException : taskExceptionMultiHashMap.get(pageID)) { if (errorMessage == null) { errorMessage = ""; } else { errorMessage += "\n"; } errorMessage += pageTaskException.getExceptionModel().getPageID().getFileResourceID() .getRelativePath() + "=" + pageTaskException.getLocalizedMessage(); } } Cell errorCell = cellArray[3][sheetIndex]; errorCell.setCellValue(createRichTextString(errorMessage)); errorCell.setCellStyle(this.spreadSheetObjectFactory.getErrorCellStyle()); }
From source file:org.nlp2rdf.corpusconversion.Tiger.java
public static void processTree(OneLine currentLine, OliaSyntaxOntologyConnector.SyntaxTree synTree, MultiHashMap mhm, Individual sentence) { //edge label/*from w ww. j a v a2s.co m*/ logger.debug("Syntax current line: " + currentLine); if (currentLine.isWord()) { logger.debug("leaf position: " + currentLine.position); Individual token = getWordAtPosition(sentence, currentLine.position); assert (token != null); OliaSyntaxOntologyConnector.SyntaxTree leaf = synTree.addLeaf(token, currentLine.word, currentLine.position); if (!currentLine.edge.equals("--")) { leaf.setEdgeLabel(currentLine.edge); } } else { logger.debug("adding new syntax node"); List<OneLine> children = (List<OneLine>) mhm.get(currentLine.word.replace("#", "")); /* System.out.println(children); for (Object s : mhm.keySet()) { String words = ""; for (OneLine ol : (List<OneLine>) mhm.get(s)) { words += ol.word+", "; } logger.debug("key:" + s + " " + words); }*/ for (int x = 0; x < children.size(); x++) { OneLine child = children.get(x); logger.debug("child line " + child); if (child.isWord()) { processTree(child, synTree, mhm, sentence); } else { OliaSyntaxOntologyConnector.SyntaxTree astTreeChild = synTree.addNode(child.tag); if (!child.edge.equals("--")) { astTreeChild.setEdgeLabel(child.edge); } processTree(child, astTreeChild, mhm, sentence); } } } }
From source file:org.openanzo.datasource.nodecentric.internal.NodeCentricModelService.java
@Override protected QueryDataset resolveNamedDatasetInternal(IOperationContext context, URI namedDatasetUri) throws AnzoException { long total = System.currentTimeMillis(); DefaultQueryDataset uriSet = new DefaultQueryDataset(new TreeSet<URI>(), new TreeSet<URI>(), new TreeSet<URI>()); NodeCentricOperationContext connectionContext = null; boolean isMine = false; try {// w ww.ja va2 s . c o m if (context instanceof NodeCentricOperationContext) { connectionContext = (NodeCentricOperationContext) context; } else { connectionContext = datasource.getQueryContext(context); isMine = true; } Long id = connectionContext.getNodeLayout().fetchId(namedDatasetUri, connectionContext.getConnection()); if (id == null) { return uriSet; } namedGraphPredicateId = connectionContext.getNodeLayout().store(Dataset.namedGraphProperty, connectionContext.getConnection(), 0); defaultGraphPredicateId = connectionContext.getNodeLayout().store(Dataset.defaultGraphProperty, connectionContext.getConnection(), 0); defaultNamedGraphPredicateId = connectionContext.getNodeLayout() .store(Dataset.defaultNamedGraphProperty, connectionContext.getConnection(), 0); boolean includeMetadataGraphs = false; if (!namedDatasetUri.equals(Constants.GRAPHS.GRAPHS_DATASET) && !namedDatasetUri.equals(Constants.GRAPHS.METADATA_GRAPHS_DATASET)) { Collection<Statement> stmts = find(connectionContext, namedDatasetUri, Dataset.includeMetadataGraphsProperty, null, new URI[] { namedDatasetUri }); if (stmts != null && stmts.size() > 0) { Statement stmt = stmts.iterator().next(); if (stmt.getObject() instanceof TypedLiteral) { Object obj = ((TypedLiteral) stmt.getObject()).getNativeValue(); if (obj instanceof Boolean) { includeMetadataGraphs = ((Boolean) obj).booleanValue(); } } } } HashSet<Long> ids = new HashSet<Long>(); MultiHashMap<Long, Long> sets = new MultiHashMap<Long, Long>(); boolean doNr = true; long start = System.currentTimeMillis(); for (ResolveDatasetResult result : StatementRdbWrapper.resolveDataset( connectionContext.getStatementProvider(), connectionContext.getConnection(), id, id, namedGraphPredicateId.toString(), defaultGraphPredicateId.toString(), defaultNamedGraphPredicateId.toString())) { doNr = false; ids.add(result.getObject()); sets.put(result.getPredicateId(), result.getObject()); } if (log.isInfoEnabled()) { log.info(LogUtils.RDB_MARKER, "[RESOLVE NAMED DATASET] {}:{}", Integer.toString(sets.size()), Long.toString(System.currentTimeMillis() - start)); } if (doNr) { start = System.currentTimeMillis(); for (ResolveDatasetNRResult result : StatementRdbWrapper.resolveDatasetNR( connectionContext.getStatementProvider(), connectionContext.getConnection(), id, id, namedGraphPredicateId.toString(), defaultGraphPredicateId.toString(), defaultNamedGraphPredicateId.toString())) { doNr = false; ids.add(result.getObject()); sets.put(result.getPredicateId(), result.getObject()); } if (log.isInfoEnabled()) { log.info(LogUtils.RDB_MARKER, "[RESOLVE NAMEDNR DATASET] {}:{}", Integer.toString(sets.size()), Long.toString(System.currentTimeMillis() - start)); } } Map<Long, Value> values = connectionContext.getNodeLayout().resolveStoredIds(ids, connectionContext.getConnection()); Collection<Long> ngIds = sets.get(namedGraphPredicateId); if (ngIds != null) { for (Long gid : ngIds) { Value uri = values.get(gid); if (uri != null) { if (uri instanceof URI) { uriSet.namedGraphs.add((URI) uri); if (includeMetadataGraphs && !UriGenerator.isMetadataGraphUri((URI) uri)) { uriSet.namedGraphs.add(UriGenerator.generateMetadataGraphUri((URI) uri)); } } } } } ngIds = sets.get(defaultGraphPredicateId); if (ngIds != null) { for (Long gid : ngIds) { Value uri = values.get(gid); if (uri != null) { if (uri instanceof URI) { uriSet.defaultGraphs.add((URI) uri); if (includeMetadataGraphs && !UriGenerator.isMetadataGraphUri((URI) uri)) { uriSet.defaultGraphs.add(UriGenerator.generateMetadataGraphUri((URI) uri)); } } } } } ngIds = sets.get(defaultNamedGraphPredicateId); if (ngIds != null) { for (Long gid : ngIds) { Value uri = values.get(gid); if (uri != null) { if (uri instanceof URI) { uriSet.namedGraphs.add((URI) uri); uriSet.defaultGraphs.add((URI) uri); if (includeMetadataGraphs && !uri.toString().startsWith(Constants.NAMESPACES.METADATAGRAPH_PREFIX)) { URI muri = UriGenerator.generateMetadataGraphUri((URI) uri); uriSet.defaultGraphs.add(muri); uriSet.namedGraphs.add(muri); } } } } } if (log.isInfoEnabled()) { log.info(LogUtils.RDB_MARKER, "[RESOLVE NAMED DATASET TOTAL] {}/{}:{}", new Object[] { Integer.toString(uriSet.defaultGraphs.size()), Integer.toString(uriSet.namedGraphs.size()), Long.toString(System.currentTimeMillis() - total) }); } return uriSet; } finally { if (connectionContext != null && isMine) { datasource.returnQueryContext(connectionContext); } } }