X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fadapters%2FRunRemover.java;fp=bundles%2Forg.simantics.modeling%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fadapters%2FRunRemover.java;h=fcc35b68ee62206aa9ae0cb941ecc7ffaa8ace08;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=16754153649c8477b00604363a2ff34ce7f25a59;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/adapters/RunRemover.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/adapters/RunRemover.java index 167541536..fcc35b68e 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/adapters/RunRemover.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/adapters/RunRemover.java @@ -1,82 +1,82 @@ -/******************************************************************************* - * 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; -// } -// } - -} +/******************************************************************************* + * 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; +// } +// } + +}