1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package pl.edu.agh.cast.model.mapper.internal;
19
20 import java.io.File;
21
22 import org.eclipse.core.resources.IProject;
23
24 import pl.edu.agh.cast.model.base.IDataSet;
25 import pl.edu.agh.cast.model.mapper.Mappable;
26
27
28
29
30
31
32
33 public class XMLRemover extends AbstractRemover {
34 private IProject project;
35
36
37
38
39
40
41 public XMLRemover(Mappable object, IProject project) {
42 super(object);
43 this.project = project;
44 }
45
46
47
48
49
50 public boolean remove() {
51 try {
52 if (primaryObject instanceof IDataSet) {
53 IDataSet dataSet = (IDataSet)primaryObject;
54
55 String dsFilePath = XMLSaver.fileFor(project, dataSet.getId());
56 File dsFile = new File(dsFilePath);
57 boolean removed = dsFile.delete();
58 if (removed) {
59 removeDataSetFromModel(dataSet);
60 log.info("Removed DataSet: " + dataSet.getId());
61 } else {
62 log.error("Cannot remove DataSet: '" + dataSet.getId()
63 + "' [" + dsFilePath + "]");
64 }
65 return removed;
66 }
67 } catch (Exception ex) {
68 log.error("Cannot remove object: " + primaryObject, ex);
69 }
70 return false;
71 }
72 }