]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.common/src/org/simantics/db/common/uri/UnescapedChildMapOfResource.java
Work in progress
[simantics/platform.git] / bundles / org.simantics.db.common / src / org / simantics / db / common / uri / UnescapedChildMapOfResource.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.db.common.uri;
13
14 import java.util.Map;
15
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.exception.DatabaseException;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22
23 public class UnescapedChildMapOfResource extends ResourceRead<Map<String, Resource>> {
24
25     private static final Logger LOGGER = LoggerFactory.getLogger(UnescapedChildMapOfResource.class);
26
27         public UnescapedChildMapOfResource(Resource resource) {
28             super(resource);
29         }
30         
31         @Override
32         public Map<String, Resource> perform(ReadGraph graph) throws DatabaseException {
33                 return graph.getChildren(resource);
34 //          Layer0 L0 = Layer0.getInstance(graph);
35 //          Collection<Resource> objects = graph.getObjects(resource, L0.ConsistsOf);
36 //          CollectionSupport cs = graph.getService(CollectionSupport.class);
37 //          Map<String,Resource> result = cs.createObjectResourceMap(String.class, objects.size());
38 //          for(Resource r : objects) {
39 //              String name = graph.getPossibleRelatedValue(r, L0.HasName, Bindings.STRING);
40 //              if(name != null) {
41 //                  Resource old = result.put(name, r);
42 //                  if (old != null)
43 //                      LOGGER.error("The database contains siblings with the same name " + name + " (resource=$" + resource.getResourceId() + ", child=$" + r.getResourceId() + ", previous child=$" + old.getResourceId() + ").");
44 //              } else {
45 //                      if(Development.DEVELOPMENT)
46 //                          LOGGER.error("The database contains a child with no unique name (resource=$" + resource.getResourceId() + ", child=$" + r.getResourceId() + ").");
47 //              }
48 //          }
49 //          return result;
50         }       
51         
52 }