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