--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2012 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.diagram.query;\r
+\r
+import gnu.trove.map.hash.THashMap;\r
+\r
+import java.util.Collection;\r
+import java.util.Map;\r
+\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ResourceRead;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class AnnotationTypeProperties extends ResourceRead<Map<String, Resource>> {\r
+\r
+ public AnnotationTypeProperties(Resource annotationType) {\r
+ super(annotationType);\r
+ }\r
+\r
+ @Override\r
+ public Map<String, Resource> perform(ReadGraph graph) throws DatabaseException {\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ Collection<Resource> children = graph.getObjects(resource, L0.ConsistsOf);\r
+ Map<String, Resource> properties = new THashMap<String, Resource>(children.size());\r
+ for (Resource child : children) {\r
+ if (graph.isSubrelationOf(child, L0.HasProperty)) {\r
+ String name = graph.getPossibleRelatedValue2(child, L0.HasName, Bindings.STRING);\r
+ if (name != null)\r
+ properties.put(name, child);\r
+ }\r
+ }\r
+ return properties;\r
+ }\r
+\r
+}\r