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.tests.performance.read;
16 import org.simantics.databoard.Bindings;
17 import org.simantics.db.ReadGraph;
18 import org.simantics.db.Resource;
19 import org.simantics.db.common.request.ResourceRead;
20 import org.simantics.db.exception.DatabaseException;
21 import org.simantics.db.service.CollectionSupport;
22 import org.simantics.layer0.Layer0;
23 import org.simantics.utils.datastructures.Pair;
25 public class TypeSetAndString extends ResourceRead<Pair<Set<Resource>, String>> {
27 public TypeSetAndString(Resource type) {
32 public Pair<Set<Resource>, String> perform(ReadGraph graph) throws DatabaseException {
34 Layer0 L0 = Layer0.getInstance(graph);
35 CollectionSupport cs = graph.getService(CollectionSupport.class);
36 Set<Resource> types = cs.createSet();
39 types.addAll(graph.getSupertypes(resource));
41 final StringBuilder b = new StringBuilder();
43 for (Resource type : types) {
44 String name = graph.getPossibleRelatedValue(type, L0.HasName, Bindings.STRING);
45 if (!first) b.append(" ");
49 return Pair.make(types, b.toString());