]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.common/src/org/simantics/db/common/uri/EscapedChildMapOfResource.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.db.common / src / org / simantics / db / common / uri / EscapedChildMapOfResource.java
index 1d92da9c839a1e86f2d80e12100a08555f0d2d15..295bcc0276f3f61bc245338a2002178015420e70 100644 (file)
@@ -1,84 +1,84 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in 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.db.common.uri;\r
-\r
-import java.util.Map;\r
-import java.util.concurrent.ConcurrentHashMap;\r
-\r
-import org.simantics.databoard.util.URIStringUtils;\r
-import org.simantics.db.AsyncReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.ProcedureBarrier;\r
-import org.simantics.db.common.WriteBindings;\r
-import org.simantics.db.common.procedure.adapter.AsyncMultiProcedureAdapter;\r
-import org.simantics.db.common.request.PropertyMapOfResource;\r
-import org.simantics.db.common.request.ResourceAsyncRead;\r
-import org.simantics.db.procedure.AsyncProcedure;\r
-import org.simantics.layer0.Layer0;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-public class EscapedChildMapOfResource extends ResourceAsyncRead<Map<String, Resource>> {\r
-\r
-    private static final Logger LOGGER = LoggerFactory.getLogger(EscapedChildMapOfResource.class);\r
-\r
-       public EscapedChildMapOfResource(Resource resource) {\r
-           super(resource);\r
-       }\r
-\r
-       @Override\r
-       public void perform(AsyncReadGraph g, final AsyncProcedure<Map<String, Resource>> procedure) {\r
-               \r
-               final Layer0 L0 = g.getService(Layer0.class);\r
-               final ConcurrentHashMap<String, Resource> map = new ConcurrentHashMap<String, Resource>();\r
-               final ProcedureBarrier<Map<String, Resource>> barrier = new ProcedureBarrier<Map<String, Resource>>(1);\r
-               \r
-               g.forEachObject(resource, L0.ConsistsOf, new AsyncMultiProcedureAdapter<Resource>() {\r
-\r
-                       @Override\r
-                       public void execute(AsyncReadGraph g, final Resource child) {\r
-                               barrier.incrementAndGet();\r
-\r
-                               g.forPossibleRelatedValue(child, L0.HasName, WriteBindings.STRING, new AsyncProcedure<Object>() {\r
-\r
-                                       @Override\r
-                                       public void execute(AsyncReadGraph g, Object name) {\r
-                                               if (name != null) {\r
-                                                       String escapedName = URIStringUtils.escape((String)name); \r
-                                                       if (map.put(escapedName, child) != null)\r
-                                                           LOGGER.error("The database contains siblings with the same name " + escapedName + " (resource=" + resource.getResourceId() +").");\r
-                                               }\r
-                                               barrier.dec(g, procedure, map);\r
-                                       }\r
-                                       \r
-                                       @Override\r
-                                       public void exception(AsyncReadGraph graph, Throwable t) {\r
-                                               barrier.dec(graph, procedure, t);\r
-                                       }\r
-                                       \r
-                               });\r
-                       }\r
-                       \r
-                       @Override\r
-                       public void exception(AsyncReadGraph graph, Throwable t) {\r
-                               barrier.dec(graph, procedure, t);\r
-                       }\r
-                       \r
-                       @Override\r
-                       public void finished(AsyncReadGraph g) {\r
-                               barrier.dec(g, procedure, map);\r
-                       }\r
-                       \r
-               });\r
-       }\r
-       \r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.db.common.uri;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.simantics.databoard.util.URIStringUtils;
+import org.simantics.db.AsyncReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.ProcedureBarrier;
+import org.simantics.db.common.WriteBindings;
+import org.simantics.db.common.procedure.adapter.AsyncMultiProcedureAdapter;
+import org.simantics.db.common.request.PropertyMapOfResource;
+import org.simantics.db.common.request.ResourceAsyncRead;
+import org.simantics.db.procedure.AsyncProcedure;
+import org.simantics.layer0.Layer0;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class EscapedChildMapOfResource extends ResourceAsyncRead<Map<String, Resource>> {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(EscapedChildMapOfResource.class);
+
+       public EscapedChildMapOfResource(Resource resource) {
+           super(resource);
+       }
+
+       @Override
+       public void perform(AsyncReadGraph g, final AsyncProcedure<Map<String, Resource>> procedure) {
+               
+               final Layer0 L0 = g.getService(Layer0.class);
+               final ConcurrentHashMap<String, Resource> map = new ConcurrentHashMap<String, Resource>();
+               final ProcedureBarrier<Map<String, Resource>> barrier = new ProcedureBarrier<Map<String, Resource>>(1);
+               
+               g.forEachObject(resource, L0.ConsistsOf, new AsyncMultiProcedureAdapter<Resource>() {
+
+                       @Override
+                       public void execute(AsyncReadGraph g, final Resource child) {
+                               barrier.incrementAndGet();
+
+                               g.forPossibleRelatedValue(child, L0.HasName, WriteBindings.STRING, new AsyncProcedure<Object>() {
+
+                                       @Override
+                                       public void execute(AsyncReadGraph g, Object name) {
+                                               if (name != null) {
+                                                       String escapedName = URIStringUtils.escape((String)name); 
+                                                       if (map.put(escapedName, child) != null)
+                                                           LOGGER.error("The database contains siblings with the same name " + escapedName + " (resource=" + resource.getResourceId() +").");
+                                               }
+                                               barrier.dec(g, procedure, map);
+                                       }
+                                       
+                                       @Override
+                                       public void exception(AsyncReadGraph graph, Throwable t) {
+                                               barrier.dec(graph, procedure, t);
+                                       }
+                                       
+                               });
+                       }
+                       
+                       @Override
+                       public void exception(AsyncReadGraph graph, Throwable t) {
+                               barrier.dec(graph, procedure, t);
+                       }
+                       
+                       @Override
+                       public void finished(AsyncReadGraph g) {
+                               barrier.dec(g, procedure, map);
+                       }
+                       
+               });
+       }
+       
+}