-/*******************************************************************************\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.layer0.adapter.impl;\r
-\r
-import java.util.Map;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.layer0.adapter.InstanceFactory;\r
-import org.simantics.db.layer0.request.DefaultInstanceFactoryRequest;\r
-import org.simantics.db.request.WriteResult;\r
-\r
-public class DefaultInstanceFactory implements InstanceFactory {\r
-\r
- final Resource resource;\r
- \r
- public DefaultInstanceFactory(Resource resource) {\r
- this.resource = resource;\r
- }\r
- \r
- public WriteResult<Map<String, Object>> create(ReadGraph graph, Map<String, Object> attachment, Resource ... templates) {\r
- return new DefaultInstanceFactoryRequest(resource, attachment, templates);\r
- }\r
- \r
-// @Override\r
-// public Resource create(WriteGraph graph) throws DatabaseException {\r
-// \r
-// Builtins b = graph.getBuiltins();\r
-// SpreadsheetResource sr = SpreadsheetResource.getInstance(graph);\r
-//\r
-// InstanceFactory sheetElementFactory = graph.adapt(sr.SpreadsheetElement, InstanceFactory.class);\r
-// Map<String, Object> sheetElement = graph.syncRequest(sheetElementFactory.create(ArrayMap.keys("").values(""), sr.ForCompositeTemplate));\r
-//\r
-//// InstanceFactory sheetFactory = w.adapt(ssr.Spreadsheet, InstanceFactory.class);\r
-//// w.syncRequest(sheetFactory.create(ArrayMap.keys("composite").values(model), ssr.ForCompositeTemplate));\r
-// \r
-// Resource result = OrderedSetUtils.create(graph, sr.Spreadsheet, (Resource)sheetElement.get("resource"));\r
-//\r
-// graph.claim((Resource)sheetElement.get("resource"), sr.HasSheet, result);\r
-//\r
-// Resource rowResource0 = graph.newResource();\r
-// graph.claim(rowResource0, b.InstanceOf, null, sr.Row);\r
-// Resource rowResource1 = graph.newResource();\r
-// graph.claim(rowResource1, b.InstanceOf, null, sr.Row);\r
-// Resource columnResource0 = graph.newResource();\r
-// graph.claim(columnResource0, b.InstanceOf, null, sr.Column);\r
-// Resource columnResource1 = graph.newResource();\r
-// graph.claim(columnResource1, b.InstanceOf, null, sr.Column);\r
-// Resource columnResource2 = graph.newResource();\r
-// graph.claim(columnResource2, b.InstanceOf, null, sr.Column);\r
-// Resource columnResource3 = graph.newResource();\r
-// graph.claim(columnResource3, b.InstanceOf, null, sr.Column);\r
-// \r
-// graph.claim(result, sr.HasRows, OrderedSetUtils.create(graph, sr.Rows, rowResource0, rowResource1));\r
-// graph.claim(result, sr.HasColumns, OrderedSetUtils.create(graph, sr.Columns, columnResource0, columnResource1, columnResource2, columnResource3));\r
-//\r
-//// RowsColumnsIndex rowIndex = graph.syncRequest(new Rows(result));\r
-//// RowsColumnsIndex columnIndex = graph.syncRequest(new Columns(result));\r
-//// Resource rowResource0 = rowIndex.ensureIndex(graph, 0);\r
-//// Resource rowResource1 = rowIndex.ensureIndex(graph, 1);\r
-//// Resource columnResource0 = columnIndex.ensureIndex(graph, 0);\r
-//// Resource columnResource1 = columnIndex.ensureIndex(graph, 1);\r
-//// Resource columnResource2 = columnIndex.ensureIndex(graph, 2);\r
-//// Resource columnResource3 = columnIndex.ensureIndex(graph, 3);\r
-//// \r
-// {\r
-// Resource newCell = graph.newResource();\r
-// graph.claim(newCell, b.InstanceOf, null, sr.TextCell);\r
-// String label = "Pipe name";\r
-// graph.claim(newCell, sr.HasRow, sr.RowOf, rowResource0);\r
-// graph.claim(newCell, sr.HasColumn, sr.ColumnOf, columnResource0);\r
-// graph.addValue(newCell, sr.HasLabel, sr.LabelOf, b.String, label, StringJavaBinding.INSTANCE);\r
-// graph.claim(result, b.ConsistsOf, b.PartOf, newCell);\r
-// }\r
-//\r
-// {\r
-// Resource newCell = graph.newResource();\r
-// graph.claim(newCell, b.InstanceOf, null, sr.TextCell);\r
-// String label = "Pipe length";\r
-// graph.claim(newCell, sr.HasRow, sr.RowOf, rowResource0);\r
-// graph.claim(newCell, sr.HasColumn, sr.ColumnOf, columnResource1);\r
-// graph.addValue(newCell, sr.HasLabel, sr.LabelOf, b.String, label, StringJavaBinding.INSTANCE);\r
-// graph.claim(result, b.ConsistsOf, b.PartOf, newCell);\r
-// }\r
-//\r
-// {\r
-// Resource newCell = graph.newResource();\r
-// graph.claim(newCell, b.InstanceOf, null, sr.TextCell);\r
-// String label = "Flow area";\r
-// graph.claim(newCell, sr.HasRow, sr.RowOf, rowResource0);\r
-// graph.claim(newCell, sr.HasColumn, sr.ColumnOf, columnResource2);\r
-// graph.addValue(newCell, sr.HasLabel, sr.LabelOf, b.String, label, StringJavaBinding.INSTANCE);\r
-// graph.claim(result, b.ConsistsOf, b.PartOf, newCell);\r
-// }\r
-//\r
-// {\r
-// Resource newCell = graph.newResource();\r
-// graph.claim(newCell, b.InstanceOf, null, sr.TextCell);\r
-// String label = "In simulation";\r
-// graph.claim(newCell, sr.HasRow, sr.RowOf, rowResource0);\r
-// graph.claim(newCell, sr.HasColumn, sr.ColumnOf, columnResource3);\r
-// graph.addValue(newCell, sr.HasLabel, sr.LabelOf, b.String, label, StringJavaBinding.INSTANCE);\r
-// graph.claim(result, b.ConsistsOf, b.PartOf, newCell);\r
-// }\r
-//\r
-// {\r
-// Resource newCell = graph.newResource();\r
-// graph.claim(newCell, b.InstanceOf, null, sr.ExpressionCell);\r
-// String label = "Attributes(Components('Pipe*'), 'Name', 'Pi12 Length', 'Pi12 Area', 'Included In Simulation')";\r
-// graph.claim(newCell, sr.HasRow, sr.RowOf, rowResource1);\r
-// graph.claim(newCell, sr.HasColumn, sr.ColumnOf, columnResource0);\r
-// graph.addValue(newCell, sr.HasExpression, sr.ExpressionOf, b.String, label, StringJavaBinding.INSTANCE);\r
-// graph.claim(result, b.ConsistsOf, b.PartOf, newCell);\r
-// }\r
-//\r
-// return result;\r
-// \r
-// }\r
-\r
-// @Override\r
-// public Resource create(WriteGraph graph, Resource container, Resource relation) throws DatabaseException {\r
-//\r
-// Builtins b = graph.getBuiltins();\r
-// Resource sheet = create(graph);\r
-// String name = GraphUtils.findFreshName(graph, "Sheet", container, relation);\r
-// graph.addValue(sheet, b.HasName, b.NameOf, b.String, name, StringJavaBinding.INSTANCE);\r
-// graph.claim(container, relation, sheet);\r
-// return sheet;\r
-// \r
-// }\r
-//\r
-// @Override\r
-// public Resource create(WriteGraph graph, Map<String, Resource> attachment,\r
-// Collection<Resource> templates) throws DatabaseException {\r
-// throw new Error("Not implemented");\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.layer0.adapter.impl;
+
+import java.util.Map;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.layer0.adapter.InstanceFactory;
+import org.simantics.db.layer0.request.DefaultInstanceFactoryRequest;
+import org.simantics.db.request.WriteResult;
+
+public class DefaultInstanceFactory implements InstanceFactory {
+
+ final Resource resource;
+
+ public DefaultInstanceFactory(Resource resource) {
+ this.resource = resource;
+ }
+
+ public WriteResult<Map<String, Object>> create(ReadGraph graph, Map<String, Object> attachment, Resource ... templates) {
+ return new DefaultInstanceFactoryRequest(resource, attachment, templates);
+ }
+
+// @Override
+// public Resource create(WriteGraph graph) throws DatabaseException {
+//
+// Builtins b = graph.getBuiltins();
+// SpreadsheetResource sr = SpreadsheetResource.getInstance(graph);
+//
+// InstanceFactory sheetElementFactory = graph.adapt(sr.SpreadsheetElement, InstanceFactory.class);
+// Map<String, Object> sheetElement = graph.syncRequest(sheetElementFactory.create(ArrayMap.keys("").values(""), sr.ForCompositeTemplate));
+//
+//// InstanceFactory sheetFactory = w.adapt(ssr.Spreadsheet, InstanceFactory.class);
+//// w.syncRequest(sheetFactory.create(ArrayMap.keys("composite").values(model), ssr.ForCompositeTemplate));
+//
+// Resource result = OrderedSetUtils.create(graph, sr.Spreadsheet, (Resource)sheetElement.get("resource"));
+//
+// graph.claim((Resource)sheetElement.get("resource"), sr.HasSheet, result);
+//
+// Resource rowResource0 = graph.newResource();
+// graph.claim(rowResource0, b.InstanceOf, null, sr.Row);
+// Resource rowResource1 = graph.newResource();
+// graph.claim(rowResource1, b.InstanceOf, null, sr.Row);
+// Resource columnResource0 = graph.newResource();
+// graph.claim(columnResource0, b.InstanceOf, null, sr.Column);
+// Resource columnResource1 = graph.newResource();
+// graph.claim(columnResource1, b.InstanceOf, null, sr.Column);
+// Resource columnResource2 = graph.newResource();
+// graph.claim(columnResource2, b.InstanceOf, null, sr.Column);
+// Resource columnResource3 = graph.newResource();
+// graph.claim(columnResource3, b.InstanceOf, null, sr.Column);
+//
+// graph.claim(result, sr.HasRows, OrderedSetUtils.create(graph, sr.Rows, rowResource0, rowResource1));
+// graph.claim(result, sr.HasColumns, OrderedSetUtils.create(graph, sr.Columns, columnResource0, columnResource1, columnResource2, columnResource3));
+//
+//// RowsColumnsIndex rowIndex = graph.syncRequest(new Rows(result));
+//// RowsColumnsIndex columnIndex = graph.syncRequest(new Columns(result));
+//// Resource rowResource0 = rowIndex.ensureIndex(graph, 0);
+//// Resource rowResource1 = rowIndex.ensureIndex(graph, 1);
+//// Resource columnResource0 = columnIndex.ensureIndex(graph, 0);
+//// Resource columnResource1 = columnIndex.ensureIndex(graph, 1);
+//// Resource columnResource2 = columnIndex.ensureIndex(graph, 2);
+//// Resource columnResource3 = columnIndex.ensureIndex(graph, 3);
+////
+// {
+// Resource newCell = graph.newResource();
+// graph.claim(newCell, b.InstanceOf, null, sr.TextCell);
+// String label = "Pipe name";
+// graph.claim(newCell, sr.HasRow, sr.RowOf, rowResource0);
+// graph.claim(newCell, sr.HasColumn, sr.ColumnOf, columnResource0);
+// graph.addValue(newCell, sr.HasLabel, sr.LabelOf, b.String, label, StringJavaBinding.INSTANCE);
+// graph.claim(result, b.ConsistsOf, b.PartOf, newCell);
+// }
+//
+// {
+// Resource newCell = graph.newResource();
+// graph.claim(newCell, b.InstanceOf, null, sr.TextCell);
+// String label = "Pipe length";
+// graph.claim(newCell, sr.HasRow, sr.RowOf, rowResource0);
+// graph.claim(newCell, sr.HasColumn, sr.ColumnOf, columnResource1);
+// graph.addValue(newCell, sr.HasLabel, sr.LabelOf, b.String, label, StringJavaBinding.INSTANCE);
+// graph.claim(result, b.ConsistsOf, b.PartOf, newCell);
+// }
+//
+// {
+// Resource newCell = graph.newResource();
+// graph.claim(newCell, b.InstanceOf, null, sr.TextCell);
+// String label = "Flow area";
+// graph.claim(newCell, sr.HasRow, sr.RowOf, rowResource0);
+// graph.claim(newCell, sr.HasColumn, sr.ColumnOf, columnResource2);
+// graph.addValue(newCell, sr.HasLabel, sr.LabelOf, b.String, label, StringJavaBinding.INSTANCE);
+// graph.claim(result, b.ConsistsOf, b.PartOf, newCell);
+// }
+//
+// {
+// Resource newCell = graph.newResource();
+// graph.claim(newCell, b.InstanceOf, null, sr.TextCell);
+// String label = "In simulation";
+// graph.claim(newCell, sr.HasRow, sr.RowOf, rowResource0);
+// graph.claim(newCell, sr.HasColumn, sr.ColumnOf, columnResource3);
+// graph.addValue(newCell, sr.HasLabel, sr.LabelOf, b.String, label, StringJavaBinding.INSTANCE);
+// graph.claim(result, b.ConsistsOf, b.PartOf, newCell);
+// }
+//
+// {
+// Resource newCell = graph.newResource();
+// graph.claim(newCell, b.InstanceOf, null, sr.ExpressionCell);
+// String label = "Attributes(Components('Pipe*'), 'Name', 'Pi12 Length', 'Pi12 Area', 'Included In Simulation')";
+// graph.claim(newCell, sr.HasRow, sr.RowOf, rowResource1);
+// graph.claim(newCell, sr.HasColumn, sr.ColumnOf, columnResource0);
+// graph.addValue(newCell, sr.HasExpression, sr.ExpressionOf, b.String, label, StringJavaBinding.INSTANCE);
+// graph.claim(result, b.ConsistsOf, b.PartOf, newCell);
+// }
+//
+// return result;
+//
+// }
+
+// @Override
+// public Resource create(WriteGraph graph, Resource container, Resource relation) throws DatabaseException {
+//
+// Builtins b = graph.getBuiltins();
+// Resource sheet = create(graph);
+// String name = GraphUtils.findFreshName(graph, "Sheet", container, relation);
+// graph.addValue(sheet, b.HasName, b.NameOf, b.String, name, StringJavaBinding.INSTANCE);
+// graph.claim(container, relation, sheet);
+// return sheet;
+//
+// }
+//
+// @Override
+// public Resource create(WriteGraph graph, Map<String, Resource> attachment,
+// Collection<Resource> templates) throws DatabaseException {
+// throw new Error("Not implemented");
+// }
+
+
+}