1 /*******************************************************************************
2 * Copyright (c) 2018 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 * Semantum Oy - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.structural2.queries;
16 import org.simantics.db.ReadGraph;
17 import org.simantics.db.Resource;
18 import org.simantics.db.common.request.ResourceRead;
19 import org.simantics.db.common.uri.UnescapedChildMapOfResource;
20 import org.simantics.db.exception.DatabaseException;
21 import org.simantics.structural.stubs.StructuralResource2;
24 * @author Antti Villberg
27 public class StructuralChildMapOfResource extends ResourceRead<Map<String, Resource>> {
29 public StructuralChildMapOfResource(Resource resource) {
34 public Map<String, Resource> perform(ReadGraph graph) throws DatabaseException {
35 StructuralResource2 STR = StructuralResource2.getInstance(graph);
36 Resource type = graph.getPossibleType(resource, STR.Component);
38 Resource definition = graph.getPossibleObject(type, STR.IsDefinedBy);
39 if (definition != null) {
40 Map<String, Resource> map = graph.syncRequest(new UnescapedChildMapOfResource(definition));
45 return graph.syncRequest(new UnescapedChildMapOfResource(resource));