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=16754153649c8477b00604363a2ff34ce7f25a59;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;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 new file mode 100644 index 000000000..167541536 --- /dev/null +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/adapters/RunRemover.java @@ -0,0 +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; +// } +// } + +}