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.browsing.ui.graph.impl;
14 import java.util.Collections;
17 import org.simantics.browsing.ui.BuiltinKeys;
18 import org.simantics.browsing.ui.NodeContext;
19 import org.simantics.browsing.ui.NodeContext.PrimitiveQueryKey;
20 import org.simantics.db.ReadGraph;
21 import org.simantics.db.Resource;
22 import org.simantics.db.common.ResourceArray;
23 import org.simantics.db.exception.DatabaseException;
24 import org.simantics.utils.Container;
26 public class InheritsQueryProcessor extends LazyGraphQueryProcessor<Set<Resource>> {
29 public String toString() {
30 return "InheritsProcessor";
34 public Object getIdentifier() {
35 return CommonKeys.INHERITS;
39 protected Set<Resource> initial() {
40 return Collections.emptySet();
44 protected Set<Resource> compute(ReadGraph graph, NodeContext context, PrimitiveQueryKey<Container<Set<Resource>>> key) throws DatabaseException {
45 Object input = context.getConstant(BuiltinKeys.INPUT);
46 if (input instanceof Resource) {
47 return graph.getSupertypes((Resource) input);
48 } else if (input instanceof ResourceArray) {
49 return graph.getSupertypes(((ResourceArray) input).resources[0]);
51 return Collections.emptySet();