@@ -145,48 +145,6 @@ public LocalController() throws IOException {
145145 }
146146 }
147147
148- public List <Project > getProjects () throws IOException , JSONException , ParseException {
149- if (projectsManager == null ) {
150- Preferences preferences = Preferences .getInstance ();
151- projectsManager = new ProjectsManager (preferences .getProjectsFolder ());
152- }
153- return projectsManager .getProjects ();
154- }
155-
156- public void createProject (Project project ) throws IOException , SAXException , ParserConfigurationException ,
157- JSONException , ParseException {
158- if (projectsManager == null ) {
159- Preferences preferences = Preferences .getInstance ();
160- projectsManager = new ProjectsManager (preferences .getProjectsFolder ());
161- }
162- projectsManager .add (project );
163- if (memoriesManager == null ) {
164- Preferences preferences = Preferences .getInstance ();
165- memoriesManager = new MemoriesManager (preferences .getMemoriesFolder ());
166- }
167- Language sourceLang = LanguageUtils .getLanguage (project .getSrcLanguage ());
168- Memory memory = new Memory (project .getId (), project .getTitle (), project .getDescription (),
169- new Date (), new Date (), sourceLang );
170- memoriesManager .add (memory );
171- }
172-
173- public void createMemory (Memory memory ) throws IOException , JSONException {
174- if (memoriesManager == null ) {
175- Preferences preferences = Preferences .getInstance ();
176- memoriesManager = new MemoriesManager (preferences .getMemoriesFolder ());
177- }
178- memoriesManager .add (memory );
179- }
180-
181- public List <Memory > getMemories ()
182- throws IOException , JSONException , ParseException , SAXException , ParserConfigurationException {
183- if (memoriesManager == null ) {
184- Preferences preferences = Preferences .getInstance ();
185- memoriesManager = new MemoriesManager (preferences .getMemoriesFolder ());
186- }
187- return memoriesManager .getMemories ();
188- }
189-
190148 public void updateProject (Project project ) throws JSONException , IOException , ParseException {
191149 if (projectsManager == null ) {
192150 Preferences preferences = Preferences .getInstance ();
@@ -1311,53 +1269,6 @@ private Element fixTags(Element src, Element match) {
13111269 return match ;
13121270 }
13131271
1314- public void removeProject (Project project ) throws IOException , JSONException , ParseException {
1315- Preferences preferences = Preferences .getInstance ();
1316- long id = project .getId ();
1317- File projectFolder = new File (preferences .getProjectsFolder (), "" + id );
1318- deltree (projectFolder );
1319- if (projectsManager == null ) {
1320- projectsManager = new ProjectsManager (preferences .getProjectsFolder ());
1321- }
1322- projectsManager .remove (id );
1323- try {
1324- removeMemory (id );
1325- } catch (IOException ioe ) {
1326- // do nothing
1327- }
1328- }
1329-
1330- public void removeMemory (long id ) throws IOException , JSONException , ParseException {
1331- List <Project > projects = getProjects ();
1332- for (int i = 0 ; i < projects .size (); i ++) {
1333- List <Long > memories = projects .get (i ).getMemories ();
1334- for (int j = 0 ; j < memories .size (); j ++) {
1335- if (memories .get (j ) == id ) {
1336- throw new IOException (Messages .getString ("LocalController.34" ));
1337- }
1338- }
1339- }
1340- Preferences preferences = Preferences .getInstance ();
1341- File memoryFolder = new File (preferences .getMemoriesFolder (), "" + id );
1342- deltree (memoryFolder );
1343- if (memoriesManager == null ) {
1344- memoriesManager = new MemoriesManager (preferences .getMemoriesFolder ());
1345- }
1346- memoriesManager .remove (id );
1347- }
1348-
1349- private void deltree (File file ) throws IOException {
1350- if (file .isDirectory ()) {
1351- File [] list = file .listFiles ();
1352- if (list != null ) {
1353- for (int i = 0 ; i < list .length ; i ++) {
1354- deltree (list [i ]);
1355- }
1356- }
1357- }
1358- Files .deleteIfExists (file .toPath ());
1359- }
1360-
13611272 public void exportTMX (Memory memory , String file ) throws IOException , SQLException , JSONException , SAXException ,
13621273 ParserConfigurationException , URISyntaxException {
13631274 ITmEngine database = getTMEngine (memory .getId ());
0 commit comments