--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2012 Association for Decentralized Information Management in\r
+ * 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.modeling.adapters;\r
+\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.impl.AbstractRemover;\r
+import org.simantics.db.layer0.adapter.impl.EntityRemover;\r
+\r
+public class RunRemover extends AbstractRemover {\r
+\r
+ public RunRemover(Resource resource) {\r
+ super(resource);\r
+ }\r
+\r
+ @Override\r
+ public void remove(WriteGraph graph) throws DatabaseException {\r
+ System.out.println("TODO: implement run removal properly");\r
+ EntityRemover.remove(graph, resource);\r
+// File experimentDir = experiment.getExperimentDir();\r
+// File resultDir = new File(experimentDir, URIUtil.encodeURI(sessionName));\r
+//\r
+// File resultDir = getResultDir();\r
+// try {\r
+// if (!resultDir.exists())\r
+// throw new DatabaseException("The experiment result doesn't exist. already deleted?");\r
+// FileUtils.deleteAll(resultDir);\r
+// } catch (IOException e) {\r
+// throw new DatabaseException("Cannot delete " + resultDir.getName() + " "+e.getMessage(), e);\r
+// }\r
+ }\r
+\r
+// public static final Pattern RESULT_DIR_PATTERN = Pattern.compile(".*result(\\d+)/?");\r
+//\r
+// public static String fileHistoryToReadableName(String sourceUrl)\r
+// {\r
+// Matcher m = RESULT_DIR_PATTERN.matcher(sourceUrl);\r
+// if (!m.matches()) return sourceUrl;\r
+// String decoded = m.group(1);\r
+// try {\r
+// long timestamp = Long.valueOf(decoded);\r
+// Date date = new Date(timestamp);\r
+// decoded = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(date);\r
+// return decoded;\r
+// } catch (NumberFormatException e) {\r
+// return decoded;\r
+// }\r
+// }\r
+//\r
+// /**\r
+// * Convert session name into readable name.\r
+// * Time stamp is convereted to Human readable date time.\r
+// *\r
+// * @param sessionName e.g. result323123\r
+// * @return 12.5.2008 16:00:20 CET\r
+// */\r
+// public static String sessionToReadableName(String sessionName)\r
+// {\r
+// Matcher m = RESULT_DIR_PATTERN.matcher(sessionName);\r
+// if (!m.matches()) return sessionName;\r
+// String decoded = m.group(1);\r
+// try {\r
+// long timestamp = Long.valueOf(decoded);\r
+// Date date = new Date(timestamp);\r
+// decoded = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(date);\r
+// return decoded;\r
+// } catch (NumberFormatException e) {\r
+// return sessionName;\r
+// }\r
+// }\r
+\r
+}\r