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