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.db.common.request;
16 import org.simantics.db.ReadGraph;
17 import org.simantics.db.Resource;
18 import org.simantics.db.common.request.ResourceRead;
19 import org.simantics.db.exception.DatabaseException;
20 import org.simantics.layer0.Layer0;
23 * @author Tuukka Lehtonen
25 public class IsEnumeratedValue extends ResourceRead<Boolean> {
27 public IsEnumeratedValue(Resource resource) {
32 public Boolean perform(ReadGraph graph) throws DatabaseException {
33 return Boolean.valueOf(isEnumeratedValue(graph, resource));
36 public static boolean isEnumeratedValue(ReadGraph graph, Resource resource) throws DatabaseException {
37 Set<Resource> types = graph.getTypes(resource);
38 //if (types.contains(graph.getBuiltins().Boolean))
40 for (Resource type : types)
41 if (isEnumeration(graph, type))
46 public static boolean isEnumeration(ReadGraph graph, Resource type) throws DatabaseException {
47 return graph.hasStatement(type, Layer0.getInstance(graph).Enumeration, type);