1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 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.issues.common;
14 import gnu.trove.set.hash.THashSet;
18 import org.simantics.db.ReadGraph;
19 import org.simantics.db.Resource;
20 import org.simantics.db.common.request.ResourceRead2;
21 import org.simantics.db.exception.DatabaseException;
22 import org.simantics.db.layer0.request.Model;
23 import org.simantics.db.layer0.variable.Variable;
26 * @author Antti Villberg
28 public class IssuesWithContext extends ResourceRead2<Set<Variable>> {
30 public IssuesWithContext(ReadGraph graph, Resource context) throws DatabaseException {
31 super(graph.sync(new Model(context)), context);
34 public IssuesWithContext(Resource model, Resource context) {
35 super(model, context);
39 public Set<Variable> perform(ReadGraph graph) throws DatabaseException {
41 Set<Variable> result = new THashSet<Variable>();
42 for(Resource issue : graph.sync(new AllModelIssues(resource))) {
43 Set<Resource> contexts = graph.sync(new IssueResourceContexts(issue));
44 if(contexts.contains(resource2)) result.add(graph.adapt(issue, Variable.class));