1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.issues.common;
\r
14 import gnu.trove.set.hash.THashSet;
\r
16 import java.util.Set;
\r
18 import org.simantics.db.ReadGraph;
\r
19 import org.simantics.db.Resource;
\r
20 import org.simantics.db.common.request.ObjectsWithType;
\r
21 import org.simantics.db.common.request.TernaryRead;
\r
22 import org.simantics.db.exception.DatabaseException;
\r
23 import org.simantics.issues.Severity;
\r
24 import org.simantics.issues.ontology.IssueResource;
\r
25 import org.simantics.layer0.Layer0;
\r
28 * @author Tuukka Lehtonen
\r
30 public class ModelIssuesWithSeverity extends TernaryRead<Resource, Boolean, Severity, Set<Resource>> {
\r
32 public ModelIssuesWithSeverity(Resource model, boolean onlyUnresolved, Severity minSeverity) {
\r
33 super(model, onlyUnresolved, minSeverity);
\r
37 public Set<Resource> perform(ReadGraph graph) throws DatabaseException {
\r
38 Layer0 L0 = Layer0.getInstance(graph);
\r
39 IssueResource ISSUE = IssueResource.getInstance(graph);
\r
40 Set<Resource> result = new THashSet<Resource>();
\r
41 for (Resource issue : graph.syncRequest(new ObjectsWithType(parameter, L0.ConsistsOf, ISSUE.Issue))) {
\r
42 if (parameter2 && graph.hasStatement(issue, ISSUE.Resolved))
\r
44 Severity s = IssueUtils.toSeverity(ISSUE, graph.getPossibleObject(issue, ISSUE.Issue_HasSeverity));
\r
45 if (s.compareTo(parameter3) <= 0)
\r