]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling/src/org/simantics/modeling/adapters/RunRemover.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / adapters / RunRemover.java
1 /*******************************************************************************\r
2  * Copyright (c) 2012 Association for Decentralized Information Management in\r
3  * Industry THTH ry.\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
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.modeling.adapters;\r
13 \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
19 \r
20 public class RunRemover extends AbstractRemover {\r
21 \r
22     public RunRemover(Resource resource) {\r
23         super(resource);\r
24     }\r
25 \r
26     @Override\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
32 //\r
33 //        File resultDir = getResultDir();\r
34 //        try {\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
40 //        }\r
41     }\r
42 \r
43 //    public static final Pattern RESULT_DIR_PATTERN = Pattern.compile(".*result(\\d+)/?");\r
44 //\r
45 //    public static String fileHistoryToReadableName(String sourceUrl)\r
46 //    {\r
47 //        Matcher m = RESULT_DIR_PATTERN.matcher(sourceUrl);\r
48 //        if (!m.matches()) return sourceUrl;\r
49 //        String decoded = m.group(1);\r
50 //        try {\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
54 //            return decoded;\r
55 //        } catch (NumberFormatException e) {\r
56 //            return decoded;\r
57 //        }\r
58 //    }\r
59 //\r
60 //    /**\r
61 //     * Convert session name into readable name.\r
62 //     * Time stamp is convereted to Human readable date time.\r
63 //     *\r
64 //     * @param sessionName e.g. result323123\r
65 //     * @return 12.5.2008 16:00:20 CET\r
66 //     */\r
67 //    public static String sessionToReadableName(String sessionName)\r
68 //    {\r
69 //        Matcher m = RESULT_DIR_PATTERN.matcher(sessionName);\r
70 //        if (!m.matches()) return sessionName;\r
71 //        String decoded = m.group(1);\r
72 //        try {\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
76 //            return decoded;\r
77 //        } catch (NumberFormatException e) {\r
78 //            return sessionName;\r
79 //        }\r
80 //    }\r
81 \r
82 }\r