1 /*******************************************************************************
2 * Copyright (c) 2007, 2018 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.impl.query;
14 import org.simantics.db.common.exception.DebugException;
15 import org.simantics.db.exception.DatabaseException;
16 import org.simantics.db.impl.graph.ReadGraphImpl;
17 import org.simantics.db.impl.procedure.InternalProcedure;
19 public final class DirectPredicates extends UnaryQueryP<IntSet> {
21 DirectPredicates(final int resource) {
26 public final void removeEntry(QueryProcessor provider) {
27 provider.cache.remove(this);
31 public void compute(ReadGraphImpl graph, InternalProcedure<IntSet> procedure) throws DatabaseException {
32 computeForEach(graph, id, this, procedure);
35 public static Object computeForEach(ReadGraphImpl graph, int id, final DirectPredicates entry, final InternalProcedure<IntSet> procedure_) throws DatabaseException {
37 InternalProcedure<IntSet> procedure = entry != null ? entry : procedure_;
39 graph.processor.querySupport.ensureLoaded(graph, id);
41 final IntSet list = new IntSet(graph.processor.querySupport);
43 graph.processor.querySupport.getPredicates(graph, id, new IntProcedure() {
46 public void execute(ReadGraphImpl graph, int i) {
51 public void finished(ReadGraphImpl graph) {
55 public void exception(ReadGraphImpl graph, Throwable t) {
56 if(DebugException.DEBUG) new DebugException(t).printStackTrace();
61 procedure.execute(graph, list);
63 if(entry != null) entry.performFromCache(graph, procedure_);
70 public String toString() {
71 return "DirectPredicates[" + id + "]";