Example usage for org.apache.commons.collections15 MultiMap values

List of usage examples for org.apache.commons.collections15 MultiMap values

Introduction

In this page you can find the example usage for org.apache.commons.collections15 MultiMap values.

Prototype

Collection<V> values();

Source Link

Document

Gets a collection containing all the values in the map.

Usage

From source file:modalLogic.tableau.World.java

/**
 * Update clashes for an incoming literal.
 *
 * @param literal the literal//  w  w w.j a va  2 s. c o  m
 * @param literals the other literals
 */
private void addClashes(LabelledFormula<P> literal, MultiMap<P, LabelledFormula<P>> literals,
        MultiMap<Constant, LabelledFormula<P>> constants) {
    Collection<LabelledFormula<P>> clashing = literals.get(literal.getFormula().getProposition());
    if (clashing == null) {
        clashing = new ArrayList<LabelledFormula<P>>();
    }
    clashing.addAll(constants.values());

    if (!clashing.isEmpty()) {
        for (LabelledFormula<P> c : clashing) {
            clashes.add(literal, c);
        }
    }
}

From source file:org.openanzo.datasource.nodecentric.internal.NodeCentricResetService.java

private void resetGraph(MultiMap<URI, Statement> statements, NodeCentricOperationContext context, URI serverURI)
        throws AnzoException {
    Collection<Statement> graphTemplates = new ArrayList<Statement>();
    // If a graph doesn't have a corresponding metadata graph in the statements, then add a default metadata graph for it.
    graphTemplates.add(new Statement(GRAPHS.DEFAULT_GRAPH_TEMPLATE, RDF.TYPE, NamedGraph.TYPE));
    graphTemplates.add(new Statement(GRAPHS.DEFAULT_GRAPH_TEMPLATE, NamedGraph.revisionedProperty,
            MemTypedLiteral.create(true)));
    graphTemplates.add(new Statement(GRAPHS.DEFAULT_GRAPH_TEMPLATE, NamedGraph.persistedProperty,
            MemTypedLiteral.create(true)));

    graphTemplates.add(new Statement(GRAPHS.DEFAULT_GRAPH_TEMPLATE, NamedGraph.canBeReadByProperty,
            Constants.EVERYONE_ROLE));//from   www .  j  ava2 s  .  c  o m
    graphTemplates.add(new Statement(GRAPHS.DEFAULT_GRAPH_TEMPLATE, NamedGraph.canBeAddedToByProperty,
            Constants.EVERYONE_ROLE));
    graphTemplates.add(new Statement(GRAPHS.DEFAULT_GRAPH_TEMPLATE, NamedGraph.canBeRemovedFromByProperty,
            Constants.EVERYONE_ROLE));

    graphTemplates.add(new Statement(GRAPHS.DEFAULT_METADATA_GRAPH_TEMPLATE, NamedGraph.canBeReadByProperty,
            Constants.EVERYONE_ROLE));
    graphTemplates.add(new Statement(GRAPHS.DEFAULT_METADATA_GRAPH_TEMPLATE, NamedGraph.canBeAddedToByProperty,
            Constants.EVERYONE_ROLE));
    graphTemplates.add(new Statement(GRAPHS.DEFAULT_METADATA_GRAPH_TEMPLATE,
            NamedGraph.canBeRemovedFromByProperty, Constants.EVERYONE_ROLE));

    context.setAttribute("resetting", Boolean.valueOf(true));
    statements.put(GRAPHS.DEFAULT_SYSTEMGRAPH, Constants.valueFactory.createStatement(
            GRAPHS.DEFAULT_SYSTEMGRAPH, AnzoServer.serverIdProperty, serverURI, GRAPHS.DEFAULT_SYSTEMGRAPH));
    datasource.getUpdateService().importStatements(context, statements.values(), graphTemplates);

}

From source file:org.openanzo.datasource.services.BaseUpdateService.java

public IUpdates importStatements(IOperationContext context, Collection<Statement> statements,
        Collection<Statement> graphTemplate) throws AnzoException {
    long start = 0;
    if (stats.isEnabled()) {
        start = System.currentTimeMillis();
    }/*from  ww  w.j  a  va  2  s  . co m*/
    throwExceptionIfAnonymousUser(context);
    if (getLockProvider() != null)
        getLockProvider().readLock().lock();
    logEntry();
    try {
        MultiMap<URI, Statement> map = new AnzoMultiMap<URI, Statement>();
        for (Statement stmt : statements) {
            URI ngUri = stmt.getNamedGraphUri();
            if (ngUri == null) {
                throw new AnzoException(ExceptionConstants.DATASOURCE.STATEMENT_NO_GRAPH);
            }
            map.put(ngUri, stmt);
        }
        if (graphTemplate == null) {
            graphTemplate = Collections.<Statement>emptySet();
        }
        IUpdates updateResults = importStatementsInternal(context, map, graphTemplate);
        for (IUpdateResultListener listener : datasourceUpdateResultListeners) {
            try {
                listener.updateComplete(context, updateResults);
            } catch (AnzoException ae) {
                log.error(LogUtils.DATASOURCE_MARKER, "Error in listener:" + listener.getClass().getName());
            }
        }
        Boolean fireGlobal = (Boolean) context.getAttribute(FIRE_GLOBAL_UDPATE_EVENTS);
        if (fireGlobal == null || fireGlobal.booleanValue()) {
            for (IUpdateResultListener listener : globalUpdateResultListeners) {
                try {
                    listener.updateComplete(context, updateResults);
                } catch (AnzoException ae) {
                    log.error(LogUtils.DATASOURCE_MARKER, "Error in listener:" + listener.getClass().getName());
                }
            }
        }
        if (log.isDebugEnabled()) {
            log.debug(LogUtils.TIMING_MARKER, "Base Import,{},{}", (System.currentTimeMillis() - start),
                    map.values().size());
        }
        return updateResults;
    } finally {
        if (stats.isEnabled()) {
            stats.use("importStatements", (System.currentTimeMillis() - start));
        }
        if (getLockProvider() != null)
            getLockProvider().readLock().unlock();
        logExit();
    }
}

From source file:org.openanzo.datasource.services.BaseUpdateService.java

public void importStatements(IOperationContext context, String reader, String readerFormat,
        Collection<Statement> graphTemplate, Writer output, String resultFormat) throws AnzoException {
    long start = 0;
    if (stats.isEnabled()) {
        start = System.currentTimeMillis();
    }/*from   ww w .  jav a2  s .  c  o m*/
    throwExceptionIfAnonymousUser(context);
    if (getLockProvider() != null)
        getLockProvider().readLock().lock();
    logEntry();
    try {
        MultiMap<URI, Statement> statements = ReadWriteUtils.readStatementSets(reader, readerFormat);
        if (statements.containsKey(null)) {
            throw new AnzoException(ExceptionConstants.DATASOURCE.STATEMENT_NO_GRAPH);
        }
        if (graphTemplate == null) {
            graphTemplate = Collections.<Statement>emptySet();
        }
        IUpdates updateResults = importStatementsInternal(context, statements, graphTemplate);
        for (IUpdateResultListener listener : datasourceUpdateResultListeners) {
            try {
                listener.updateComplete(context, updateResults);
            } catch (AnzoException ae) {
                log.error(LogUtils.DATASOURCE_MARKER, "Error in listener:" + listener.getClass().getName());
            }
        }
        Boolean fireGlobal = (Boolean) context.getAttribute(FIRE_GLOBAL_UDPATE_EVENTS);
        if (fireGlobal == null || fireGlobal.booleanValue()) {
            for (IUpdateResultListener listener : globalUpdateResultListeners) {
                try {
                    listener.updateComplete(context, updateResults);
                } catch (AnzoException ae) {
                    log.error(LogUtils.DATASOURCE_MARKER, "Error in listener:" + listener.getClass().getName());
                }
            }
        }
        CommonSerializationUtils.writeUpdates(false, updateResults, output, resultFormat);
        if (log.isDebugEnabled()) {
            log.debug(LogUtils.TIMING_MARKER, "Base Import,{},{}", (System.currentTimeMillis() - start),
                    statements.values().size());
        }
    } finally {
        if (stats.isEnabled()) {
            stats.use("importStatements", (System.currentTimeMillis() - start));
        }
        if (getLockProvider() != null)
            getLockProvider().readLock().unlock();
        logExit();
    }
}