1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.db.common.request;
\r
14 import java.util.Set;
\r
16 import org.simantics.databoard.Bindings;
\r
17 import org.simantics.db.ReadGraph;
\r
18 import org.simantics.db.Resource;
\r
19 import org.simantics.db.common.utils.Logger;
\r
20 import org.simantics.db.exception.DatabaseException;
\r
21 import org.simantics.layer0.Layer0;
\r
23 public class SuperTypeString extends BinaryRead<Resource, String, String> {
\r
25 public SuperTypeString(Resource type) {
\r
29 public SuperTypeString(Resource type, String separator) {
\r
30 super(type, separator);
\r
31 if (separator == null)
\r
32 throw new NullPointerException("null separator");
\r
36 public String perform(ReadGraph graph) throws DatabaseException {
\r
38 Layer0 L0 = Layer0.getInstance(graph);
\r
39 Set<Resource> supers = graph.getSupertypes(parameter);
\r
40 final StringBuilder b = new StringBuilder();
\r
41 String name = graph.getPossibleRelatedValue(parameter, L0.HasName, Bindings.STRING);
\r
44 for (Resource r : supers) {
\r
45 name = graph.getPossibleRelatedValue(r, L0.HasName, Bindings.STRING);
\r
47 b.append(parameter2);
\r
50 Logger.defaultLogError(new DatabaseException("No name for type " + r));
\r
54 Logger.defaultLogError(new DatabaseException("No name for type " + parameter));
\r
57 return b.toString();
\r