--- /dev/null
+/*******************************************************************************\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