Révision 1546
tmp/org.txm.core/src/java/org/txm/objects/Workspace.java (revision 1546) | ||
---|---|---|
214 | 214 |
File PROJECT = new File(binCorpusDir, ".project"); //$NON-NLS-1$ |
215 | 215 |
binCorpusDir = new File(this.getLocation(), binCorpusDir.getName()); // this is to ensure the project is in the workspace files |
216 | 216 |
|
217 |
|
|
218 |
|
|
217 | 219 |
if (binCorpusDir.exists() && HTMLs.exists() && DATAs.exists() |
218 | 220 |
&& REGISTRY.exists() && PARAMS.exists() && PROJECT.exists())// && correspfile.exists()) |
219 | 221 |
{// minimal base data |
222 |
|
|
223 |
File[] maincorpusNames = DATAs.listFiles(); |
|
224 |
String maincorpusName = ""; |
|
225 |
if (maincorpusNames.length == 0) { // no CQP corpus |
|
226 |
System.out.println(NLS.bind("Error: no CQP corpus data found in {0} directory.", DATAs)); |
|
227 |
return null; |
|
228 |
} else { |
|
229 |
maincorpusName = maincorpusNames[0].getName(); |
|
230 |
} |
|
220 | 231 |
|
221 | 232 |
Project p = getProject(binCorpusDir.getName()); |
222 | 233 |
if (p != null) { |
223 |
p.delete(); |
|
234 |
p.delete(); // a project with the same name already exists
|
|
224 | 235 |
} |
236 |
p = getProject(maincorpusName); |
|
237 |
if (p != null) { |
|
238 |
p.delete(); // a project with the same name already exists |
|
239 |
} |
|
225 | 240 |
|
226 | 241 |
//System.out.println(parameters.toString()); |
227 | 242 |
|
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorporaDirectory.java (revision 1546) | ||
---|---|---|
51 | 51 |
import org.txm.searchengine.core.SearchEngine; |
52 | 52 |
import org.txm.searchengine.core.SearchEnginesManager; |
53 | 53 |
import org.txm.utils.io.IOUtils; |
54 |
import org.txm.utils.logger.Log; |
|
54 | 55 |
|
55 | 56 |
/** |
56 | 57 |
* Create projects from one binary corpus directory |
... | ... | |
195 | 196 |
|
196 | 197 |
// Project base = LoadBinaryCorpus.loadBinaryCorpusAsDirectory(corpusDirectory); |
197 | 198 |
if (project == null) { |
198 |
System.out.println("Fail to load binary corpus: "+corpusDirectory);
|
|
199 |
Log.warning("Error: fail to load binary corpus: "+corpusDirectory);
|
|
199 | 200 |
} else { |
200 | 201 |
projects.add(project); |
201 | 202 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorpus.java (revision 1546) | ||
---|---|---|
345 | 345 |
// |
346 | 346 |
// Toolbox.workspace.save(); |
347 | 347 |
|
348 |
// test with project name |
|
348 | 349 |
Project p = Toolbox.workspace.getProject(corpusDirectory.getName().toUpperCase().toUpperCase()); |
349 | 350 |
if (p != null) { |
350 |
System.out.println("Aborting loading of "+corpusDirectory+". A corpus with the same name already exists.");
|
|
351 |
System.out.println(NLS.bind("Aborting loading of {0}. A corpus with the same name already exists.", corpusDirectory));
|
|
351 | 352 |
return null; |
352 | 353 |
} |
353 | 354 |
|
355 |
// test with CQP MainCorpus name |
|
356 |
File dataDirectory = new File(corpusDirectory, "data"); |
|
357 |
File[] mainCorpusDirs = dataDirectory.listFiles(); |
|
358 |
if (mainCorpusDirs != null && mainCorpusDirs.length > 0) { |
|
359 |
String mainCorpusName = mainCorpusDirs[0].getName(); |
|
360 |
p = Toolbox.workspace.getProject(mainCorpusName); |
|
361 |
if (p != null) { |
|
362 |
System.out.println(NLS.bind("Aborting loading of {0}. A corpus with the same {1} CQP MainCorpus name already exists.", corpusDirectory, mainCorpusName)); |
|
363 |
return null; |
|
364 |
} |
|
365 |
} |
|
366 |
|
|
354 | 367 |
// seems like a binary corpus directory |
355 | 368 |
// copy files in the new current corpora directory |
356 | 369 |
File destDir = new File(Toolbox.workspace.getLocation(), corpusDirectory.getName().toUpperCase()); |
... | ... | |
364 | 377 |
File dotProjectFile = new File(destDir, ".project"); |
365 | 378 |
if (paramFile.exists() && paramFile.isDirectory() && dotProjectFile.exists() && dotProjectFile.isFile()) { |
366 | 379 |
System.out.println(NLS.bind(TXMUIMessages.loadingTheP0BinaryCorpusAsATXM080Corpus, destDir)); |
380 |
|
|
367 | 381 |
project = Load080BinaryCorpus.loadBinaryCorpusAsDirectory(destDir); |
368 | 382 |
} else if (importXMLFile.exists()) { |
369 | 383 |
System.out.println(NLS.bind(TXMUIMessages.loadingTheP0BinaryCorpusAsATXM079Corpus, destDir)); |
... | ... | |
372 | 386 |
System.out.println(NLS.bind("Error: {0} is not a binary corpus directory.", destDir)); |
373 | 387 |
} |
374 | 388 |
|
389 |
if (!destDir.equals(corpusDirectory) && project == null) { // clean if necessary |
|
390 |
DeleteDir.deleteDirectory(destDir); // the corpus directory was not in the corpora directory |
|
391 |
} |
|
392 |
|
|
375 | 393 |
return project; |
376 | 394 |
} |
377 | 395 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/Load080BinaryCorpus.java (revision 1546) | ||
---|---|---|
34 | 34 |
import org.txm.Toolbox; |
35 | 35 |
import org.txm.objects.Project; |
36 | 36 |
import org.txm.rcp.messages.TXMUIMessages; |
37 |
import org.txm.utils.DeleteDir; |
|
37 | 38 |
import org.txm.utils.logger.Log; |
38 | 39 |
import org.txm.utils.zip.Zip; |
39 | 40 |
|
... | ... | |
44 | 45 |
*/ |
45 | 46 |
public class Load080BinaryCorpus { |
46 | 47 |
|
47 |
|
|
48 |
|
|
48 | 49 |
public static boolean canLoad(File zipFile) { |
49 | 50 |
String basedirname = Zip.getRoot(zipFile); |
50 | 51 |
return Zip.hasEntries(zipFile, basedirname+"/.settings/", basedirname+"/.project", basedirname+"/data/", basedirname+"/txm/", basedirname+"/HTML/", basedirname+"/registry/"); |
... | ... | |
61 | 62 |
//ZIPPED FILE |
62 | 63 |
if (monitor != null) monitor.beginTask(TXMUIMessages.loadingBinaryCorpus, 100); |
63 | 64 |
if (monitor != null) monitor.subTask(TXMUIMessages.extractingBinaryCorpus); |
64 |
|
|
65 |
|
|
65 | 66 |
String basedirname = Zip.getRoot(zipFile); |
66 |
|
|
67 |
|
|
67 | 68 |
Project p = Toolbox.workspace.getProject(basedirname.toUpperCase()); |
68 | 69 |
if (p != null) { |
69 | 70 |
System.out.println("Aborting loading of "+zipFile+". A corpus with the same name already exists."); |
70 | 71 |
return null; |
71 | 72 |
} |
72 |
|
|
73 |
|
|
73 | 74 |
if (!canLoad(zipFile)) { |
74 | 75 |
Log.info(NLS.bind(TXMUIMessages.binaryCorpusIsNotATXM080CorpusNoSettingsNorProjectFile, zipFile.getName())); |
75 | 76 |
return null; |
76 | 77 |
} |
77 |
|
|
78 |
|
|
78 | 79 |
System.out.println(NLS.bind(TXMUIMessages.loadingTheP0BinaryCorpusAsATXM080Corpus, zipFile.getName())); |
79 |
|
|
80 |
|
|
80 | 81 |
try { |
81 | 82 |
//System.out.println(NLS.bind(Messages.AddBase_29, zipFile, corporaDir)); |
82 | 83 |
Zip.decompress(zipFile, Toolbox.workspace.getLocation(), false, monitor); |
... | ... | |
88 | 89 |
if (monitor != null) monitor.worked(50); |
89 | 90 |
|
90 | 91 |
if (monitor != null) monitor.subTask(TXMUIMessages.loadingTheCorpusInThePlatform); |
91 |
Project newProject = loadBinaryCorpusAsDirectory(new File(Toolbox.workspace.getLocation(), basedirname)); |
|
92 |
File corpusDirectory = new File(Toolbox.workspace.getLocation(), basedirname); |
|
93 |
|
|
94 |
// test with CQP MainCorpus name |
|
95 |
File dataDirectory = new File(corpusDirectory, "data"); |
|
96 |
File[] mainCorpusDirs = dataDirectory.listFiles(); |
|
97 |
if (mainCorpusDirs != null && mainCorpusDirs.length > 0) { |
|
98 |
String mainCorpusName = mainCorpusDirs[0].getName(); |
|
99 |
p = Toolbox.workspace.getProject(mainCorpusName); |
|
100 |
if (p != null) { |
|
101 |
System.out.println(NLS.bind("Aborting loading of {0}. A corpus with the same {1} CQP MainCorpus name already exists.", corpusDirectory, mainCorpusName)); |
|
102 |
DeleteDir.deleteDirectory(corpusDirectory); // clean files |
|
103 |
return null; |
|
104 |
} |
|
105 |
} |
|
106 |
|
|
107 |
Project newProject = loadBinaryCorpusAsDirectory(corpusDirectory); |
|
92 | 108 |
if (newProject == null) { |
109 |
DeleteDir.deleteDirectory(corpusDirectory); // clean files |
|
93 | 110 |
System.out.println(TXMUIMessages.failedToLoadBinaryCorpusNullError); |
94 | 111 |
return null; |
95 | 112 |
} |
96 |
|
|
113 |
|
|
97 | 114 |
return newProject; |
98 | 115 |
} |
99 |
|
|
116 |
|
|
100 | 117 |
/** |
101 | 118 |
* load the content of the file if its a directory containing at least the sub folders : |
102 | 119 |
* txm, html, data and registry. |
... | ... | |
114 | 131 |
|
115 | 132 |
File txmcorpora = new File(Toolbox.getTxmHomePath(), "corpora"); //$NON-NLS-1$ |
116 | 133 |
txmcorpora.mkdir(); |
117 |
Project base = Toolbox.workspace.scanDirectory(binCorpusDirectory);
|
|
118 |
if (base == null) {
|
|
134 |
Project project = Toolbox.workspace.scanDirectory(binCorpusDirectory);
|
|
135 |
if (project == null) {
|
|
119 | 136 |
Log.severe(NLS.bind(TXMUIMessages.failedToLoadCorpusFromDirectoryColonP0WeCannotFindTheNecessaryComponents, binCorpusDirectory)); |
120 | 137 |
return null; |
121 | 138 |
} |
122 | 139 |
|
123 | 140 |
Toolbox.workspace.saveParameters(); |
124 |
return base;
|
|
141 |
return project;
|
|
125 | 142 |
} |
126 | 143 |
} |
Formats disponibles : Unified diff