-/*******************************************************************************\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.document.ui.actions;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.adapter.ActionFactory;\r
-import org.simantics.document.DocumentResource;\r
-import org.simantics.document.ui.graphfile.DocumentVersionUtils;\r
-import org.simantics.document.ui.graphfile.FileDocumentUtil;\r
-\r
-/**\r
- * Abstract base class for adding documents.\r
- * \r
- * If import target is an document, a new version of a document is created.\r
- * \r
- * Document version creation has two modes:\r
- * FLAT: new version is added to the same library as the old document.\r
- * TREE: new version replaces the old document in the library, and old document is moved under the new document.\r
- * \r
- * \r
- * @author Marko Luukkainen <marko.luukkainen@vtt.fi>\r
- *\r
- */\r
-public abstract class AddDocumentAction implements ActionFactory {\r
- \r
-\r
- \r
- \r
- private Resource relation;\r
- \r
- public AddDocumentAction(ReadGraph graph, String relationUri) throws DatabaseException {\r
- relation = graph.getResource(relationUri);\r
- }\r
- \r
-\r
- protected Resource getRelation() {\r
- return relation;\r
- }\r
- \r
- protected void linkDocument(WriteGraph graph, Resource target, Resource newDocument) throws DatabaseException{\r
- DocumentResource doc = DocumentResource.getInstance(graph);\r
- \r
- if (graph.isInstanceOf(target, doc.Document)) {\r
- // adding a new revision\r
- DocumentVersionUtils.createNewVersion(graph, target, newDocument, relation);\r
- \r
- \r
- } else {\r
- graph.claim(target, relation, newDocument);\r
- FileDocumentUtil.createUniqueName(graph, newDocument);\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.document.ui.actions;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.adapter.ActionFactory;
+import org.simantics.document.DocumentResource;
+import org.simantics.document.ui.graphfile.DocumentVersionUtils;
+import org.simantics.document.ui.graphfile.FileDocumentUtil;
+
+/**
+ * Abstract base class for adding documents.
+ *
+ * If import target is an document, a new version of a document is created.
+ *
+ * Document version creation has two modes:
+ * FLAT: new version is added to the same library as the old document.
+ * TREE: new version replaces the old document in the library, and old document is moved under the new document.
+ *
+ *
+ * @author Marko Luukkainen <marko.luukkainen@vtt.fi>
+ *
+ */
+public abstract class AddDocumentAction implements ActionFactory {
+
+
+
+
+ private Resource relation;
+
+ public AddDocumentAction(ReadGraph graph, String relationUri) throws DatabaseException {
+ relation = graph.getResource(relationUri);
+ }
+
+
+ protected Resource getRelation() {
+ return relation;
+ }
+
+ protected void linkDocument(WriteGraph graph, Resource target, Resource newDocument) throws DatabaseException{
+ DocumentResource doc = DocumentResource.getInstance(graph);
+
+ if (graph.isInstanceOf(target, doc.Document)) {
+ // adding a new revision
+ DocumentVersionUtils.createNewVersion(graph, target, newDocument, relation);
+
+
+ } else {
+ graph.claim(target, relation, newDocument);
+ FileDocumentUtil.createUniqueName(graph, newDocument);
+ }
+ }
+
+}