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.databoard.Bindings;
17 import org.simantics.db.ReadGraph;
18 import org.simantics.db.Resource;
19 import org.simantics.db.common.utils.Logger;
20 import org.simantics.db.exception.DatabaseException;
21 import org.simantics.layer0.Layer0;
23 public class SuperTypeString extends BinaryRead<Resource, String, String> {
25 public SuperTypeString(Resource type) {
29 public SuperTypeString(Resource type, String separator) {
30 super(type, separator);
31 if (separator == null)
32 throw new NullPointerException("null separator");
36 public String perform(ReadGraph graph) throws DatabaseException {
38 Layer0 L0 = Layer0.getInstance(graph);
39 Set<Resource> supers = graph.getSupertypes(parameter);
40 final StringBuilder b = new StringBuilder();
41 String name = graph.getPossibleRelatedValue(parameter, L0.HasName, Bindings.STRING);
43 b.append(TypeString.escapeToken(name));
44 for (Resource r : supers) {
45 name = graph.getPossibleRelatedValue(r, L0.HasName, Bindings.STRING);
48 b.append(TypeString.escapeToken(name));
50 Logger.defaultLogError(new DatabaseException("No name for type " + r));
54 Logger.defaultLogError(new DatabaseException("No name for type " + parameter));