1 /*******************************************************************************
2 * Copyright (c) 2017 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 * Semantum Oy - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.browsing.ui.model.tests;
14 import org.simantics.db.ReadGraph;
15 import org.simantics.db.Resource;
16 import org.simantics.db.exception.DatabaseException;
17 import org.simantics.db.layer0.exception.InvalidVariableException;
18 import org.simantics.db.layer0.variable.Variable;
21 * @author Tuukka Lehtonen
24 public enum HasURITest implements Test {
27 public static HasURITest get() {
32 public boolean isCompatible(Class<?> contentType) {
33 return contentType.equals(Resource.class) || contentType.equals(Variable.class);
37 public boolean test(ReadGraph graph, Object content) throws DatabaseException {
38 if (content instanceof Resource) {
39 return graph.getPossibleURI((Resource) content) != null;
40 } else if (content instanceof Variable) {
42 Variable v = (Variable) content;
43 return v.getURI(graph) != null;
44 } catch (InvalidVariableException e) {