1 /*******************************************************************************
2 * Copyright (c) 2012 Association for Decentralized Information Management in
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.diagram.query;
14 import gnu.trove.map.hash.THashMap;
18 import org.simantics.db.ReadGraph;
19 import org.simantics.db.Resource;
20 import org.simantics.db.common.request.ResourceRead;
21 import org.simantics.db.common.uri.UnescapedChildMapOfResource;
22 import org.simantics.db.exception.DatabaseException;
23 import org.simantics.modeling.template2d.ontology.Template2dResource;
26 * @author Tuukka Lehtonen
28 public class FlagTables extends ResourceRead<Map<String, Resource>> {
30 public FlagTables(Resource drawingTemplate) {
31 super(drawingTemplate);
35 public Map<String, Resource> perform(ReadGraph graph) throws DatabaseException {
36 Map<String, Resource> childMap = graph.syncRequest(new UnescapedChildMapOfResource(resource));
37 if (childMap.isEmpty())
40 Template2dResource TEMPLATE2D = Template2dResource.getInstance(graph);
41 Map<String, Resource> flagTables = new THashMap<String, Resource>(childMap.size());
42 for (Map.Entry<String, Resource> entry : childMap.entrySet()) {
43 if (graph.isInstanceOf(entry.getValue(), TEMPLATE2D.FlagTable)) {
44 flagTables.put(entry.getKey(), entry.getValue());