1 /*******************************************************************************
2 * Copyright (c) 2017 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.db.layer0.variable;
14 import java.util.Collection;
15 import java.util.HashMap;
18 import org.simantics.db.ReadGraph;
19 import org.simantics.db.Resource;
20 import org.simantics.db.exception.DatabaseException;
23 * Used for defining custom variable spaces in SCL.
24 * See SCL module <code>Simantics/Variables</code> function
25 * <code>createVariableMap :: [Resource] -> VariableMap</code>.
27 * @author Antti Villberg
30 public class ResourceCollectionVariableMap extends VariableMapImpl {
32 final private Collection<Resource> resources;
34 public ResourceCollectionVariableMap(Collection<Resource> resources) {
35 this.resources = resources;
39 public Map<String, Variable> getVariables(ReadGraph graph, Variable context, Map<String, Variable> map)
40 throws DatabaseException {
41 for(Resource resource : resources) {
42 if(map == null) map = new HashMap<>();
43 Variable child = new StandardGraphChildVariable(context, null, resource);
44 map.put(child.getName(graph), child);