1 /*******************************************************************************
2 * Copyright (c) 2007, 2012 Association for Decentralized Information Management in
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.ui;
14 import org.simantics.browsing.ui.model.tests.Test;
15 import org.simantics.db.ReadGraph;
16 import org.simantics.db.Resource;
17 import org.simantics.db.exception.DatabaseException;
18 import org.simantics.db.layer0.variable.Variable;
19 import org.simantics.issues.ontology.IssueResource;
22 * @author Tuukka Lehtonen
24 public class UserIssueTest implements Test {
27 public boolean isCompatible(Class<?> contentType) {
28 return Resource.class.equals(contentType) || Variable.class.equals(contentType);
32 public boolean test(ReadGraph graph, Object content) throws DatabaseException {
33 IssueResource ISSUE = IssueResource.getInstance(graph);
34 if (content instanceof Resource)
35 return graph.hasStatement((Resource) content, ISSUE.UserIssue);
36 if (content instanceof Variable) {
37 Variable v = (Variable) content;
38 Resource r = v.getPossibleRepresents(graph);
40 return graph.hasStatement(r, ISSUE.UserIssue);