Example usage for org.apache.commons.collections15.multimap MultiHashMap size

List of usage examples for org.apache.commons.collections15.multimap MultiHashMap size

Introduction

In this page you can find the example usage for org.apache.commons.collections15.multimap MultiHashMap size.

Prototype

public int size() 

Source Link

Usage

From source file:net.sqs2.omr.result.export.spreadsheet.CSVExportModule.java

private void writeSelectSingleAnswer(QuestionEvent questionEvent,
        MultiHashMap<PageID, PageTaskException> taskExceptionMap, Answer answer) {
    this.csvWriter.print(TAB);
    if (answer == null || (taskExceptionMap != null && 0 < taskExceptionMap.size())) {
        return;//from www. j  a  v a  2  s.  com
    }
    String value = MarkAreaAnswerValueUtil.createSelect1MarkAreaAnswerValueString(this.densityThreshold,
            this.doubleMarkSuppressionThreshold, this.noMarkSuppressionThreshold, ((MarkAreaAnswer) answer),
            questionEvent.getFormAreaList(), ',');
    this.csvWriter.print(StringUtil.escapeTSV(value));
}

From source file:net.sqs2.omr.result.export.spreadsheet.CSVExportModule.java

private void writeTextAreaAnswer(MultiHashMap<PageID, PageTaskException> taskExceptionMap, Answer answer) {
    this.csvWriter.print(TAB);
    if (answer == null || (taskExceptionMap != null && 0 < taskExceptionMap.size())) {
        return;/*from   ww w  .  j a v a2s . co m*/
    }
    String value = ((TextAreaAnswer) answer).getValue();
    if (value != null) {
        this.csvWriter.print(StringUtil.escapeTSV(value));
    }
}

From source file:net.sqs2.omr.result.export.spreadsheet.CSVExportModule.java

private void writeSelectMultipleAnswer(QuestionEvent questionEvent,
        MultiHashMap<PageID, PageTaskException> taskExceptionMap, Answer answer) {
    int size = questionEvent.getFormAreaList().size();
    for (int itemIndex = 0; itemIndex < size; itemIndex++) {
        this.csvWriter.print(TAB);
        if (answer == null || (taskExceptionMap != null && 0 < taskExceptionMap.size())) {
            continue;
        }//from w ww  . ja  v  a 2s  .c o  m
        MarkAreaAnswerItem answerItem = ((MarkAreaAnswer) answer).getMarkAreaAnswerItem(itemIndex);

        if (answerItem.isManualMode()) {
            if (answerItem.isManualSelected()) {
                this.csvWriter.print("1");
            } else {
                this.csvWriter.print("0");
            }
        } else {
            if (answerItem.getDensity() < this.densityThreshold) {
                this.csvWriter.print("1");
            } else {
                this.csvWriter.print("0");
            }
        }
    }
}

From source file:net.sqs2.omr.session.output.MarkReadStatusOutputModule.java

@Override
public void endRow(RowEvent rowEvent) {
    this.sourceDirectoryMarkReadStatus.add(this.rowMarkReadStatus);
    this.totalMarkReadStatus.add(this.rowMarkReadStatus);
    MultiHashMap<PageID, PageTaskException> taskExceptionMap = rowEvent.getTaskExceptionMultiHashMap();
    if (taskExceptionMap != null && 0 < taskExceptionMap.size()) {
        this.totalMarkReadStatus.numErrorPages += taskExceptionMap.size();
    }/*from  w w w.  j  a  va2 s. c o  m*/
    int numPages = rowEvent.getRowGroupEvent().getFormMaster().getNumPages();
    this.totalMarkReadStatus.setNumPages(this.totalMarkReadStatus.getNumPages() + numPages);
}

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 {/*from   www  .  j a v a 2 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);
        }
    }
}