1 /*******************************************************************************
\r
2 * Copyright (c) 2012 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.modeling.adapters;
\r
14 import org.simantics.db.Resource;
\r
15 import org.simantics.db.WriteGraph;
\r
16 import org.simantics.db.exception.DatabaseException;
\r
17 import org.simantics.db.layer0.adapter.impl.AbstractRemover;
\r
18 import org.simantics.db.layer0.adapter.impl.EntityRemover;
\r
20 public class RunRemover extends AbstractRemover {
\r
22 public RunRemover(Resource resource) {
\r
27 public void remove(WriteGraph graph) throws DatabaseException {
\r
28 System.out.println("TODO: implement run removal properly");
\r
29 EntityRemover.remove(graph, resource);
\r
30 // File experimentDir = experiment.getExperimentDir();
\r
31 // File resultDir = new File(experimentDir, URIUtil.encodeURI(sessionName));
\r
33 // File resultDir = getResultDir();
\r
35 // if (!resultDir.exists())
\r
36 // throw new DatabaseException("The experiment result doesn't exist. already deleted?");
\r
37 // FileUtils.deleteAll(resultDir);
\r
38 // } catch (IOException e) {
\r
39 // throw new DatabaseException("Cannot delete " + resultDir.getName() + " "+e.getMessage(), e);
\r
43 // public static final Pattern RESULT_DIR_PATTERN = Pattern.compile(".*result(\\d+)/?");
\r
45 // public static String fileHistoryToReadableName(String sourceUrl)
\r
47 // Matcher m = RESULT_DIR_PATTERN.matcher(sourceUrl);
\r
48 // if (!m.matches()) return sourceUrl;
\r
49 // String decoded = m.group(1);
\r
51 // long timestamp = Long.valueOf(decoded);
\r
52 // Date date = new Date(timestamp);
\r
53 // decoded = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(date);
\r
55 // } catch (NumberFormatException e) {
\r
61 // * Convert session name into readable name.
\r
62 // * Time stamp is convereted to Human readable date time.
\r
64 // * @param sessionName e.g. result323123
\r
65 // * @return 12.5.2008 16:00:20 CET
\r
67 // public static String sessionToReadableName(String sessionName)
\r
69 // Matcher m = RESULT_DIR_PATTERN.matcher(sessionName);
\r
70 // if (!m.matches()) return sessionName;
\r
71 // String decoded = m.group(1);
\r
73 // long timestamp = Long.valueOf(decoded);
\r
74 // Date date = new Date(timestamp);
\r
75 // decoded = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(date);
\r
77 // } catch (NumberFormatException e) {
\r
78 // return sessionName;
\r