Révision 2431

tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Partition.java (revision 2431)
254 254
	@Override
255 255
	protected boolean _compute() throws Exception {
256 256
		
257
		// Parts already created but not computed
258
		// This case happens at TXM start, when Parts have not been yet computed
259
		// FIXME: SJ: problem, this code is executed and THEN Partition.compute() calls again Part.compute() of all its children
260
		// FIXME: SJ: need to remove this code, the compute of children should not be done here
261
		if (this.getParts().size() > 0) {
257
		// create the parts only if they not already exist
258
		if (this.getParts().size() == 0) {
262 259
			
263
			this.beginTask("Building partition parts...", this.getParts().size());
264
			Log.info("Building partition parts...");
265
			
266
			// FIXME: temporary fix, compute all the children parts
267
			List<Part> parts = (List<Part>) getChildren(Part.class);
268
			for (int i = 0; i < parts.size(); i++) {
269
				this.worked(1);
270
				parts.get(i).compute();
271
			}
272
		}
273
		else {
274 260
			Log.finest(NLS.bind(SearchEngineCoreMessages.info_creatingNewPartition, this.getParent(), this.userName));
275 261
			
276 262
			if (this.pProperty != null) {
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 2431)
2255 2255
	 * @throws Exception
2256 2256
	 */
2257 2257
	public boolean compute() {
2258
		return this.compute(new LogMonitor("Computing " + this));
2258
		return this.compute(true);
2259 2259
	}
2260 2260
	
2261 2261
	
......
2410 2410
					|| this.altered // FIXME: SJ: fix for computing LexicalTable children even if the LT is not dirty but only altered, need to define if it's a temporary fix or not
2411 2411
			) {
2412 2412
				
2413
				if (monitor != null && children.size() > 1) monitor.beginTask("Computing children of " + this, children.size());
2413
				if (monitor != null && children.size() > 1) {
2414
					monitor.beginTask("Computing children of " + this, children.size());
2415
				}
2416
				
2414 2417
				// set the children as dirty since the result has changed
2415 2418
				for (int i = 0; i < this.children.size(); i++) {
2416 2419
					this.children.get(i).setDirty();
......
2424 2427
					for (int i = 0; i < this.children.size(); i++) {
2425 2428
						this.children.get(i).compute(monitor, deepComputing);
2426 2429
						
2427
						if (monitor != null && children.size() > 1) monitor.worked(1);
2430
						if (monitor != null && children.size() > 1) {
2431
							monitor.worked(1);
2432
						}
2428 2433
					}
2429 2434
				}
2430 2435
			}
......
2694 2699
	
2695 2700
	/**
2696 2701
	 * Sets the user defined persistable state of the result.
2697
	 * Propagates persistence to parent and non-persistence to the children if needed.
2698 2702
	 * 
2699
	 * @param userPersistable the state to set
2703
	 * If doCheck is equal to true:
2704
	 * - propagates persistence to parent and non-persistence to the children if needed.
2705
	 * - also copies parameters values from Java annotations to result preferences node and flushes the node to file.
2706
	 * 
2707
	 * @param userPersistable
2708
	 * @param doCheck
2700 2709
	 */
2701
	public void setUserPersistable(boolean userPersistable) {
2710
	public void setUserPersistable(boolean userPersistable, boolean doCheck) {
2702 2711
		this.userPersistable = userPersistable;
2712
		
2713
		// force persistable state of the parent if this result is set to persistable
2703 2714
		if (userPersistable && this.parent != null && !this.parent.isInternalPersistable()) {
2704 2715
			this.parent.setUserPersistable(true);
2705 2716
		}
2717
		
2718
		// force non-persistable state of children if this result is set to non-persistable
2706 2719
		if (!userPersistable) {
2707 2720
			for (TXMResult child : getChildren()) {
2708 2721
				child.setUserPersistable(userPersistable);
......
2723 2736
	}
2724 2737
	
2725 2738
	/**
2739
	 * Sets the user defined persistable state of the result.
2740
	 * 
2741
	 * @param userPersistable the state to set
2742
	 */
2743
	public void setUserPersistable(boolean userPersistable) {
2744
		this.setUserPersistable(userPersistable, true);
2745
	}
2746
	
2747
	/**
2726 2748
	 * Swaps the user persistable state.
2727 2749
	 * 
2728 2750
	 * propagate persistence to parent if necessary
tmp/org.txm.core/src/java/org/txm/objects/Project.java (revision 2431)
76 76
 * The Class Project represent a Corpus project with its sources, corpus indexes, texts, editions, pages, etc.
77 77
 */
78 78
public class Project extends TXMResult {
79

  
79
	
80 80
	public static final String TXMCORPUSNATURE = "org.txm.core.CorpusNature";
81

  
82
	//private ArrayList<String> pEditionNames = new ArrayList<String>();
81
	
82
	// private ArrayList<String> pEditionNames = new ArrayList<String>();
83 83
	private IProject rcpProject;
84

  
84
	
85 85
	private ProjectScope preferenceScope;
86

  
86
	
87 87
	/**
88 88
	 * If true, the computing will build the main corpus, editions, texts, etc.
89 89
	 */
90 90
	protected boolean needToBuild;
91

  
92

  
93
	@Parameter(key=TBXPreferences.CLEAN)
91
	
92
	
93
	@Parameter(key = TBXPreferences.CLEAN)
94 94
	private boolean pCleanAfterBuild;
95

  
95
	
96 96
	/**
97 97
	 * Name of import module.
98 98
	 */
99
	@Parameter(key=TBXPreferences.IMPORT_MODULE_NAME)
99
	@Parameter(key = TBXPreferences.IMPORT_MODULE_NAME)
100 100
	String pImportModuleName;
101 101
	
102 102
	/**
103 103
	 * Name of import module.
104 104
	 */
105
	@Parameter(key=TBXPreferences.CORPUS_VERSION)
105
	@Parameter(key = TBXPreferences.CORPUS_VERSION)
106 106
	String pCorpusVersion;
107

  
107
	
108 108
	/**
109 109
	 * 
110 110
	 */
111
	@Parameter(key=TBXPreferences.LINKS)
111
	@Parameter(key = TBXPreferences.LINKS)
112 112
	private HashMap<String, Alignement> links;
113

  
113
	
114 114
	/**
115 115
	 * Default edition.
116 116
	 */
117
	@Parameter(key=TBXPreferences.DEFAULT_EDITION)
117
	@Parameter(key = TBXPreferences.DEFAULT_EDITION)
118 118
	private String pDefaultEditionName;
119

  
119
	
120 120
	/**
121 121
	 * Encoding.
122 122
	 */
123
	@Parameter(key=TBXPreferences.ENCODING)
123
	@Parameter(key = TBXPreferences.ENCODING)
124 124
	private String pEncoding;
125

  
125
	
126 126
	/**
127 127
	 * Language.
128 128
	 */
129
	@Parameter(key=TBXPreferences.LANG)
129
	@Parameter(key = TBXPreferences.LANG)
130 130
	private String pLanguage;
131

  
131
	
132 132
	/**
133 133
	 * Source directory.
134 134
	 */
135
	@Parameter(key=TBXPreferences.SOURCE)
135
	@Parameter(key = TBXPreferences.SOURCE)
136 136
	private File pSrcDirectory;
137

  
138
	//	/** The front xslt path. */
139
	//	@Parameter(key=TBXPreferences.FRONT_XSL)
140
	//	private String pXsl;
141
	//	/** The front xslt path. */
142
	//	@Parameter(key=TBXPreferences.FRONT_XSL_PARAMETERS)
143
	//	private HashMap<String, String> pXsltParameters;
144

  
137
	
138
	// /** The front xslt path. */
139
	// @Parameter(key=TBXPreferences.FRONT_XSL)
140
	// private String pXsl;
141
	// /** The front xslt path. */
142
	// @Parameter(key=TBXPreferences.FRONT_XSL_PARAMETERS)
143
	// private HashMap<String, String> pXsltParameters;
144
	
145 145
	/**
146 146
	 * Author.
147 147
	 */
148
	@Parameter(key=TBXPreferences.AUTHOR)
148
	@Parameter(key = TBXPreferences.AUTHOR)
149 149
	private String pAuthor;
150

  
150
	
151 151
	/**
152 152
	 * Font.
153 153
	 */
154
	@Parameter(key=TBXPreferences.FONT)
154
	@Parameter(key = TBXPreferences.FONT)
155 155
	private String pFont = "Arial";
156

  
156
	
157 157
	/**
158 158
	 * Description.
159 159
	 */
160
	@Parameter(key=TBXPreferences.DESCRIPTION)
160
	@Parameter(key = TBXPreferences.DESCRIPTION)
161 161
	private String pDescription;
162

  
162
	
163 163
	/**
164 164
	 * 
165 165
	 */
166
	@Parameter(key=TBXPreferences.ANNOTATE)
166
	@Parameter(key = TBXPreferences.ANNOTATE)
167 167
	private boolean pAnnotate;
168

  
168
	
169 169
	/**
170 170
	 * Instantiates a new project and define if it needs to build its main corpus, texts, editions, etc..
171 171
	 * 
......
175 175
	 */
176 176
	public Project(Workspace workspace, String name, boolean needToBuild) throws Exception {
177 177
		super("/project/" + name + "/" + createUUID() + "_Project", workspace);
178

  
178
		
179 179
		this.needToBuild = needToBuild;
180 180
		this.internalPersistable = true;
181 181
		this.userName = name;
......
190 190
			TXMPreferences.flush(this);
191 191
		}
192 192
	}
193

  
193
	
194 194
	/**
195 195
	 * Instantiates a new project that needs to build its main corpus, texts, editions, etc..
196
	 * 
196 197
	 * @param workspace
197 198
	 * @param name
198 199
	 * @throws Exception
......
200 201
	public Project(Workspace workspace, String name) throws Exception {
201 202
		this(workspace, name, true);
202 203
	}
203

  
204
	
204 205
	public boolean isOpen() {
205 206
		return rcpProject != null && rcpProject.isOpen();
206 207
	}
......
217 218
				
218 219
				if (monitor != null) monitor.subTask("loading results");
219 220
				this.loadResults(null);
220

  
221
				
221 222
				for (TXMResult cb : getCorpora()) {
222 223
					if (!cb.compute(false)) {
223
						Log.warning("Deleting broken corpus: "+cb+" of "+cb.getProject());
224
						Log.warning("Deleting broken corpus: " + cb + " of " + cb.getProject());
224 225
						cb.delete();
225 226
					}
226 227
				}
227 228
				
228 229
				if (monitor != null) monitor.subTask("");
229
			} catch (CoreException e) {
230
			}
231
			catch (CoreException e) {
230 232
				e.printStackTrace();
231 233
			}
232 234
		}
......
253 255
				
254 256
				this.preferenceScope = null;
255 257
				
256
			} catch (Exception e) {
258
			}
259
			catch (Exception e) {
257 260
				e.printStackTrace();
258 261
			}
259 262
		}
......
275 278
	/**
276 279
	 * Instantiates a new existing project from persistence.
277 280
	 * This project will not be builded, main corpus, texts, editions, etc. will be restored from persistence.
278
	 *  
281
	 * 
279 282
	 * @param nodePath
280 283
	 * @throws CoreException
281 284
	 */
282 285
	public Project(String parametersNodePath) throws CoreException {
283 286
		super(parametersNodePath);
284

  
287
		
285 288
		this.needToBuild = false;
286 289
		this.internalPersistable = true;
287 290
		this.dirty = false;
288 291
		this.hasBeenComputedOnce = true;
289 292
		this.setVisible(false);
290

  
293
		
291 294
		initRCPStuffs();
292

  
293
		//		
294
		//		this.setPath(project.getPath() + getName());
295
		//		params = parameters;
296
		//		setSelfElement(params.root);
297
		//		this.project = project;
298
		//		//load();
299
		//		this.userName = params.name;
300
		//		if (!userName.equals(userName.toUpperCase())) {
301
		//			System.out.println("Warning in Base.init: binary corpus name contains lower case letters: "+this.userName);
302
		//		}
303
		//		
304
		//		this.scope = new BasePreferenceScope(this);
305

  
295
		
296
		//
297
		// this.setPath(project.getPath() + getName());
298
		// params = parameters;
299
		// setSelfElement(params.root);
300
		// this.project = project;
301
		// //load();
302
		// this.userName = params.name;
303
		// if (!userName.equals(userName.toUpperCase())) {
304
		// System.out.println("Warning in Base.init: binary corpus name contains lower case letters: "+this.userName);
305
		// }
306
		//
307
		// this.scope = new BasePreferenceScope(this);
308
		
306 309
		// reloading existing results
307 310
		this.loadResults(null);
308 311
	}
309

  
310

  
312
	
313
	
311 314
	@Override
312 315
	public boolean canCompute() throws Exception {
313
		if(userName == null)	{
316
		if (userName == null) {
314 317
			Log.severe("Project.canCompute(): can not compute with missing name.");
315 318
			return false;
316 319
		}
317

  
318
		if(this.needToBuild == true && (pSrcDirectory == null || pImportModuleName == null))	{
320
		
321
		if (this.needToBuild == true && (pSrcDirectory == null || pImportModuleName == null)) {
319 322
			Log.severe("Project.canCompute(): the project needs to build but source directory or import module name is missing.");
320 323
			return false;
321 324
		}
322 325
		return true;
323 326
	}
324

  
327
	
325 328
	/**
326 329
	 * flag the project to be rebuild with the Import module
327 330
	 */
328 331
	public void setNeedToBuild() {
329 332
		needToBuild = true;
330 333
	}
331

  
332

  
334
	
335
	
333 336
	@Override
334 337
	protected boolean _compute() throws Exception {
335

  
338
		
336 339
		// build the main corpus, texts, editions, etc.
337
		if(this.needToBuild)	{
338

  
339
			//		if (pImportXMLParameters != null) {
340
			//			pImportXMLParameters.load();
341
			//			this._load(pImportXMLParameters.name);
342
			//			// convert to new preferences persistence
343
			//		}
344

  
345
			//FIXME if the corpus name change, the TXMResults node path become wrong
346
			//			if (!rcpProject.getName().equals(userName)) { // project directory and project name must stay in sync
347
			//				IPath destination = new Path(this.getName());
348
			//				if (destination.toFile().exists()) {
349
			//					System.out.println("Error: could not rename project since one already existing with the same new name="+this.getName());
350
			//					return false;
351
			//				}
352
			//				rcpProject.move(destination, true, null);
353
			//			}
354

  
340
		if (this.needToBuild) {
341
			
342
			// if (pImportXMLParameters != null) {
343
			// pImportXMLParameters.load();
344
			// this._load(pImportXMLParameters.name);
345
			// // convert to new preferences persistence
346
			// }
347
			
348
			// FIXME if the corpus name change, the TXMResults node path become wrong
349
			// if (!rcpProject.getName().equals(userName)) { // project directory and project name must stay in sync
350
			// IPath destination = new Path(this.getName());
351
			// if (destination.toFile().exists()) {
352
			// System.out.println("Error: could not rename project since one already existing with the same new name="+this.getName());
353
			// return false;
354
			// }
355
			// rcpProject.move(destination, true, null);
356
			// }
357
			
355 358
			ImportEngines engines = Toolbox.getImportEngines();
356

  
357
			//File scriptfile = new File(Toolbox.getTxmHomePath(), "scripts/groovy/user/org/txm/scripts/importer/"+importName+"/"+importName+"Loader.groovy"); //$NON-NLS-1$
359
			
360
			// File scriptfile = new File(Toolbox.getTxmHomePath(), "scripts/groovy/user/org/txm/scripts/importer/"+importName+"/"+importName+"Loader.groovy"); //$NON-NLS-1$
358 361
			ImportEngine engine = engines.getEngine(getImportModuleName());
359 362
			if (engine == null) {
360
				//			
361
				//			engine = new ScriptedImportEngine(scriptfile) {
362
				//				@Override
363
				//				public boolean build(Project project, IProgressMonitor monitor) {
364
				//					// TODO Auto-generated method stub
365
				//					return false;
366
				//				}
367
				//			};
368
				//Log.severe("Project._compute(): Import engine not found.");
369

  
363
				//
364
				// engine = new ScriptedImportEngine(scriptfile) {
365
				// @Override
366
				// public boolean build(Project project, IProgressMonitor monitor) {
367
				// // TODO Auto-generated method stub
368
				// return false;
369
				// }
370
				// };
371
				// Log.severe("Project._compute(): Import engine not found.");
372
				
370 373
				// no import set
371 374
				return true;
372 375
			}
373

  
376
			
374 377
			if (monitor == null || monitor.isCanceled()) {
375
				monitor = new LogMonitor("computing "+this);
378
				monitor = new LogMonitor("computing " + this);
376 379
			}
377

  
380
			
378 381
			Log.finest("RUNNING IMPORT MODULE WITH NAME = " + getImportModuleName());
379

  
382
			
380 383
			boolean state = engine.build(this, monitor).isOK();
381
			if (state == true)	{
384
			if (state == true) {
382 385
				this.needToBuild = false;
383 386
				// This step could be done only if the compiler step if done and only if it modifying/deleting the corpus builds
384 387
				for (CorpusBuild corpus : getCorpusBuilds()) {
385 388
					if (corpus != null) {
386
					//	corpus.compute(false);
389
						// corpus.compute(false);
387 390
					}
388 391
				}
389
			} else { // import failed
392
			}
393
			else { // import failed
390 394
				for (CorpusBuild corpus : getCorpusBuilds()) { // Cleaning eventual broken corpus
391 395
					if (corpus != null) {
392 396
						corpus.delete();
......
394 398
				}
395 399
			}
396 400
			return state;
397

  
401
			
398 402
		}
399 403
		// Nothing to do if the project does not need to build
400
		else	{
404
		else {
401 405
			return true;
402 406
		}
403 407
	}
......
413 417
			String n = this.getName();
414 418
			this.rcpProject = rcpWorkspace.getRoot().getProject(n);
415 419
		}
416

  
420
		
417 421
		if (!rcpProject.exists()) {
418 422
			createRCPProject();
419 423
		}
420

  
421
//		if (!rcpProject.isOpen()) {
422
//			try {
423
//				rcpProject.open(monitor);
424
//			} catch (Exception e) {
425
//				System.out.println("Warning: restoring corpus project files: "+e);
426
////				rcpProject.delete(true, monitor);
427
////				createRCPProject();
428
//			}
429
//		}
424
		
425
		// if (!rcpProject.isOpen()) {
426
		// try {
427
		// rcpProject.open(monitor);
428
		// } catch (Exception e) {
429
		// System.out.println("Warning: restoring corpus project files: "+e);
430
		//// rcpProject.delete(true, monitor);
431
		//// createRCPProject();
432
		// }
433
		// }
430 434
		if (isOpen()) {
431 435
			this.preferenceScope = new ProjectScope(rcpProject);
432 436
		}
433 437
	}
434

  
438
	
435 439
	private void createRCPProject() throws CoreException {
436 440
		
437 441
		IProjectDescription description = ResourcesPlugin.getWorkspace().newProjectDescription(rcpProject.getName());
438 442
		IFolder folder = Workspace.getInstance().corporaProject.getFolder(rcpProject.getName());
439 443
		
440 444
		description.setLocation(folder.getLocation());
441
		description.setNatureIds(new String[] {TXMCORPUSNATURE});
445
		description.setNatureIds(new String[] { TXMCORPUSNATURE });
442 446
		
443 447
		rcpProject.create(description, monitor);
444 448
		rcpProject.open(monitor);
445
		//TODO might fail if corpus source directory changed
449
		// TODO might fail if corpus source directory changed
446 450
		IFolder srcFolder = rcpProject.getFolder("src");
447 451
		if (pSrcDirectory != null && !pSrcDirectory.getName().isEmpty()) {
448 452
			IPath path = new Path(pSrcDirectory.getAbsolutePath());
......
451 455
			}
452 456
		}
453 457
	}
454

  
458
	
455 459
	/**
456 460
	 * Loads and creates the persisted results from the preferences service.
457 461
	 */
458
	public void loadResults(Class clazz)	{
459

  
462
	public void loadResults(Class clazz) {
463
		
460 464
		Log.finest("*** Project.loadResults(): reloading project persitent results...");
461

  
465
		
462 466
		ArrayList<String> resultNodePaths = TXMPreferences.getAllResultsNodePaths(this.getParametersNodeRootPath());
463

  
467
		
464 468
		Log.fine("Loading " + resultNodePaths.size() + " result(s) from project " + this.getName() + "...");
465

  
466
		//TXMPreferences.dump();
467

  
468
		HashMap<String, TXMResult> loaded = new HashMap<String, TXMResult>();
469
		ArrayList<String> errors = new ArrayList<String>();
469
		
470
		// TXMPreferences.dump();
471
		
472
		HashMap<String, TXMResult> loaded = new HashMap<>();
473
		ArrayList<String> errors = new ArrayList<>();
470 474
		for (String resultNodePath : resultNodePaths) {
471

  
475
			
472 476
			try {
473 477
				Preferences node = TXMPreferences.preferencesRootNode.node(resultNodePath);
474

  
478
				
475 479
				String className = node.get("class", ""); //$NON-NLS-1$ //$NON-NLS-2$
476

  
480
				
477 481
				// Skip Project object
478
				if (Project.class.getName().equals(className))	{ // already loaded in loadProjectFromProjectScope
482
				if (Project.class.getName().equals(className)) { // already loaded in loadProjectFromProjectScope
479 483
					continue;
480 484
				}
481

  
485
				
482 486
				if (className == null || className.length() == 0) {
483 487
					errors.add(NLS.bind("Warning: can not restore object with no class name set with path={0}.", resultNodePath)); //$NON-NLS-1$
484 488
					node.removeNode();
485 489
					continue;
486 490
				}
487

  
491
				
488 492
				if (clazz != null && !clazz.getName().equals(className)) {
489 493
					continue; // only load the result of class=clazz
490 494
				}
491

  
495
				
492 496
				Log.fine("\nProject.loadResults(): loading from result node qualifier " + resultNodePath);
493
				//Log.finest("Toolbox.initialize(): class = " + TXMPreferences.getString("class", nodeQualifier));
494
				//TXMPreferences.dump();
497
				// Log.finest("Toolbox.initialize(): class = " + TXMPreferences.getString("class", nodeQualifier));
498
				// TXMPreferences.dump();
495 499
				
496
//				//TODO see if necessary to prevent errors
497
//				TXMResult result2 = TXMResult.getResult(this, resultNodePath);
498
//				if (result2 != null) { // result already restored
499
//					continue;
500
//				}
500
				// //TODO see if necessary to prevent errors
501
				// TXMResult result2 = TXMResult.getResult(this, resultNodePath);
502
				// if (result2 != null) { // result already restored
503
				// continue;
504
				// }
501 505
				Log.fine("Project.loadResults(): class = " + className); //$NON-NLS-1$
502
				//					Log.finest("Toolbox.initialize(): parent_uuid = " + TXMPreferences.getString(TXMPreferences.PARENT_UUID, nodeQualifier));
506
				// Log.finest("Toolbox.initialize(): parent_uuid = " + TXMPreferences.getString(TXMPreferences.PARENT_UUID, nodeQualifier));
503 507
				Log.fine("Project.loadResults(): parent_uuid = " + node.get(TXMPreferences.PARENT_PARAMETERS_NODE_PATH, "")); //$NON-NLS-1$
504 508
				String bundleId = node.get(TXMPreferences.BUNDLE_ID, ""); //$NON-NLS-1$
505 509
				if (bundleId == null || bundleId.length() == 0) {
......
514 518
					node.removeNode();
515 519
					continue;
516 520
				}
517

  
521
				
518 522
				Class<?> cl = bundle.loadClass(className);
519 523
				
520
//				TXMResult parent = loaded.get(node.get(TXMPreferences.PARENT_PARAMETERS_NODE_PATH, null));
521
//				TXMResult result = null;
522
//				if (parent == null) {
523
					Constructor<?> cons = cl.getConstructor(String.class);
524
					TXMResult result = (TXMResult) cons.newInstance(resultNodePath);
525
//				} else {
526
//					Constructor<?> cons = cl.getConstructor(String.class, TXMResult.class);
527
//					result = (TXMResult) cons.newInstance(resultNodePath, parent);
528
//				}
524
				// TXMResult parent = loaded.get(node.get(TXMPreferences.PARENT_PARAMETERS_NODE_PATH, null));
525
				// TXMResult result = null;
526
				// if (parent == null) {
527
				Constructor<?> cons = cl.getConstructor(String.class);
528
				TXMResult result = (TXMResult) cons.newInstance(resultNodePath);
529
				// } else {
530
				// Constructor<?> cons = cl.getConstructor(String.class, TXMResult.class);
531
				// result = (TXMResult) cons.newInstance(resultNodePath, parent);
532
				// }
529 533
				loaded.put(resultNodePath, result);
534
				
530 535
				// not an internal persistence (eg. corpus or partition)
531
				if (!result.isInternalPersistable())	{
532
					result.setUserPersistable(true);	
536
				if (!result.isInternalPersistable()) {
537
					result.setUserPersistable(true, false);
533 538
				}
534
			} catch (Exception e) {
539
				
540
			}
541
			catch (Exception e) {
535 542
				// TODO Auto-generated catch block
536 543
				e.printStackTrace();
537 544
			}
538 545
		}
539 546
		if (errors.size() > 0) {
540
			for (int i = 0 ; i < 20 && i < errors.size() ; i++) {
547
			for (int i = 0; i < 20 && i < errors.size(); i++) {
541 548
				Log.fine(errors.get(i));
542 549
			}
543 550
			if (errors.size() > 20) {
544
				Log.fine("more: "+(errors.size()-20)+"...");
551
				Log.fine("more: " + (errors.size() - 20) + "...");
545 552
			}
546 553
		}
547

  
548
		//		// load the corpus builds
549
		//		for (CorpusBuild corpus : getCorpusBuilds()) {
550
		//			if (corpus != null) {
551
		//				corpus.compute(false);
552
		//			}
553
		//		}
554
		
555
		// // load the corpus builds
556
		// for (CorpusBuild corpus : getCorpusBuilds()) {
557
		// if (corpus != null) {
558
		// corpus.compute(false);
559
		// }
560
		// }
554 561
	}
555

  
556
	//	public BasePreferenceScope getPreferenceScope() {
557
	//		return scope;
558
	//	}
559

  
560
	//	/* (non-Javadoc)
561
	//	 * @see org.txm.objects.TxmObject#save()
562
	//	 */
563
	//	@Override
564
	//	protected boolean _save() {
565
	//		//System.out.println("SAVE BASE: "+params.root+" "+params.paramFile);
566
	//		try {
567
	//			// Création de la source DOM
568
	//			Source source = new DOMSource(params.root);
562
	
563
	// public BasePreferenceScope getPreferenceScope() {
564
	// return scope;
565
	// }
566
	
567
	// /* (non-Javadoc)
568
	// * @see org.txm.objects.TxmObject#save()
569
	// */
570
	// @Override
571
	// protected boolean _save() {
572
	// //System.out.println("SAVE BASE: "+params.root+" "+params.paramFile);
573
	// try {
574
	// // Création de la source DOM
575
	// Source source = new DOMSource(params.root);
569 576
	//
570
	//			// Création du fichier de sortie
571
	//			Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(params.paramFile), "UTF-8")); //$NON-NLS-1$
572
	//			Result resultat = new StreamResult(writer);
577
	// // Création du fichier de sortie
578
	// Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(params.paramFile), "UTF-8")); //$NON-NLS-1$
579
	// Result resultat = new StreamResult(writer);
573 580
	//
574
	//			// Configuration du transformer
575
	//			TransformerFactory fabrique = new net.sf.saxon.TransformerFactoryImpl();
576
	//			Transformer transformer = fabrique.newTransformer();
577
	//			transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
578
	//			transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
579
	//			
580
	//			// Transformation
581
	//			transformer.transform(source, resultat);
582
	//			writer.close();
583
	//		} catch (Exception e) {
584
	//			e.printStackTrace();
585
	//			Log.severe("Error while saving corpus parameters: "+e.getLocalizedMessage());
586
	//			return false;
587
	//		}
588
	//		return true;
589
	//	}
590

  
581
	// // Configuration du transformer
582
	// TransformerFactory fabrique = new net.sf.saxon.TransformerFactoryImpl();
583
	// Transformer transformer = fabrique.newTransformer();
584
	// transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
585
	// transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
586
	//
587
	// // Transformation
588
	// transformer.transform(source, resultat);
589
	// writer.close();
590
	// } catch (Exception e) {
591
	// e.printStackTrace();
592
	// Log.severe("Error while saving corpus parameters: "+e.getLocalizedMessage());
593
	// return false;
594
	// }
595
	// return true;
596
	// }
597
	
591 598
	/**
592 599
	 * Retro compatibility method for import.xml files.
593 600
	 * 
594 601
	 * @return
595
	 * @throws IOException 
596
	 * @throws SAXException 
597
	 * @throws ParserConfigurationException 
602
	 * @throws IOException
603
	 * @throws SAXException
604
	 * @throws ParserConfigurationException
598 605
	 */
599 606
	public boolean _load(BaseOldParameters params) throws Exception {
600 607
		params.load();
601 608
		userName = params.name;
602

  
609
		
603 610
		// set the improt module name using the Loader script name
604 611
		this.pImportModuleName = params.scriptFile;
605 612
		if (this.pImportModuleName != null) {
......
608 615
				this.pImportModuleName = this.pImportModuleName.substring(0, idx);
609 616
				idx = this.pImportModuleName.lastIndexOf("/");
610 617
				if (idx > 0 && this.pImportModuleName.length() > idx) {
611
					this.pImportModuleName = this.pImportModuleName.substring(idx+1);
618
					this.pImportModuleName = this.pImportModuleName.substring(idx + 1);
612 619
				}
613 620
			}
614
		} else {
621
		}
622
		else {
615 623
			this.pImportModuleName = "xtz";
616 624
		}
617

  
625
		
618 626
		this.pSrcDirectory = params.paramFile.getParentFile();
619 627
		if (pSrcDirectory == null) {
620 628
			pSrcDirectory = new File(getProjectDirectory(), "src");
621 629
		}
622

  
630
		
623 631
		File dir = new File(this.getWorkspace().getLocation(), userName);
624 632
		File paramFile = new File(dir, "import.xml");
625 633
		if (!paramFile.exists()) return false;
626

  
627

  
634
		
635
		
628 636
		// get Alignements
629
		//System.out.println("Load alignement from params: "+params.links);
637
		// System.out.println("Load alignement from params: "+params.links);
630 638
		for (String alignname : params.links.keySet()) {
631 639
			Element link = params.links.get(alignname);
632

  
640
			
633 641
			String target = link.getAttribute("target"); //$NON-NLS-1$
634 642
			String[] split = target.split("#"); //$NON-NLS-1$
635 643
			if (split.length != 3) {
......
638 646
			}
639 647
			String from = split[1].trim();
640 648
			String to = split[2].trim();
641

  
642
			Alignement align = new Alignement(this, from, to, 
649
			
650
			Alignement align = new Alignement(this, from, to,
643 651
					link.getAttribute("alignElement"), Integer.parseInt(link.getAttribute("alignLevel"))); //$NON-NLS-1$ //$NON-NLS-2$
644
			links.put("#"+from+" #"+to, align); //$NON-NLS-1$ //$NON-NLS-2$
645

  
646
			align = new Alignement(this, to, from, 
652
			links.put("#" + from + " #" + to, align); //$NON-NLS-1$ //$NON-NLS-2$
653
			
654
			align = new Alignement(this, to, from,
647 655
					link.getAttribute("alignElement"), Integer.parseInt(link.getAttribute("alignLevel"))); //$NON-NLS-1$ //$NON-NLS-2$
648
			links.put("#"+to+" #"+from, align); //$NON-NLS-1$ //$NON-NLS-2$
656
			links.put("#" + to + " #" + from, align); //$NON-NLS-1$ //$NON-NLS-2$
649 657
		}
650

  
658
		
651 659
		return true;
652 660
	}
653

  
654

  
661
	
662
	
655 663
	/**
656 664
	 * Gets the text.
657 665
	 *
......
666 674
		}
667 675
		return null;
668 676
	}
669

  
677
	
670 678
	/**
671 679
	 * Gets the texts.
672 680
	 *
......
676 684
	public List<Text> getTexts() {
677 685
		return (List<Text>) getChildren(Text.class);
678 686
	}
679

  
687
	
680 688
	/**
681 689
	 * Gets the texts id.
682 690
	 *
......
689 697
		}
690 698
		return ids;
691 699
	}
692

  
700
	
693 701
	/**
694 702
	 * Gets the next text.
695 703
	 *
......
704 712
				return texts.get(idx);
705 713
			}
706 714
		}
707

  
715
		
708 716
		return t;
709 717
	}
710

  
718
	
711 719
	/**
712 720
	 * Gets the previous text.
713 721
	 *
......
717 725
	public Text getPreviousText(Text t) {
718 726
		List<Text> texts = getTexts();
719 727
		if (texts.size() > 0) {
720
			int idx = texts.indexOf(t) -1 ;
728
			int idx = texts.indexOf(t) - 1;
721 729
			if (idx >= 0) {
722 730
				return texts.get(idx);
723 731
			}
724 732
		}
725

  
733
		
726 734
		return t;
727 735
	}
728

  
736
	
729 737
	/**
730 738
	 * Gets the last text.
731 739
	 *
......
734 742
	public Text getLastText() {
735 743
		List<Text> texts = getTexts();
736 744
		if (texts.size() > 0) return texts.get(texts.size() - 1);
737

  
745
		
738 746
		return null;
739 747
	}
740

  
748
	
741 749
	/**
742 750
	 * Gets the first text.
743 751
	 *
......
746 754
	public Text getFirstText() {
747 755
		List<Text> texts = getTexts();
748 756
		if (texts.size() > 0) return texts.get(0);
749

  
757
		
750 758
		return null;
751 759
	}
752

  
753

  
760
	
761
	
754 762
	public boolean hasEditions() {
755 763
		return pDefaultEditionName != null;
756 764
	}
757

  
765
	
758 766
	public String getDefaultEdition() {
759 767
		return pDefaultEditionName;
760 768
	}
761

  
769
	
762 770
	public List<String> getEditionNames() {
763 771
		IEclipsePreferences node = this.getPreferencesScope().getNode(EditionDefinition.class.getSimpleName());
764 772
		try {
765 773
			return Arrays.asList(node.childrenNames());
766
		} catch (BackingStoreException e) {
774
		}
775
		catch (BackingStoreException e) {
767 776
			Log.printStackTrace(e);
768 777
		}
769

  
770
		return new ArrayList<String>();
778
		
779
		return new ArrayList<>();
771 780
	}
772

  
781
	
773 782
	/**
774 783
	 * @return the defaultEditionName
775 784
	 */
776 785
	public String getDefaultEditionName() {
777 786
		return pDefaultEditionName;
778 787
	}
779

  
788
	
780 789
	/**
781 790
	 * @param defaultEditionName the defaultEditionName to set
782 791
	 */
783 792
	public void setDefaultEditionName(String defaultEditionName) {
784 793
		this.pDefaultEditionName = defaultEditionName;
785 794
	}
786

  
795
	
787 796
	public Workspace getWorkspace() {
788 797
		return (Workspace) getParent();
789 798
	}
790

  
799
	
791 800
	public boolean export(File exportzip) {
792 801
		return export(exportzip, null);
793 802
	}
794

  
803
	
795 804
	/**
796 805
	 * Export.
797 806
	 *
......
800 809
	 */
801 810
	public boolean export(File exportzip, IProgressMonitor monitor) {
802 811
		File binarydir = this.getProjectDirectory();
803

  
812
		
804 813
		if (binarydir.exists() && exportzip.getParentFile().exists()) {
805 814
			this.save();
806

  
815
			
807 816
			try {
808 817
				Zip.compress(binarydir, exportzip, monitor);
809
			} catch (IOException e) {
818
			}
819
			catch (IOException e) {
810 820
				org.txm.utils.logger.Log.printStackTrace(e);
811 821
				return false;
812 822
			}
813 823
			return true;
814
		} else {
824
		}
825
		else {
815 826
			System.out.println(NLS.bind(TXMCoreMessages.binaryDirectoryP0NotFound, binarydir));
816 827
			System.out.println(NLS.bind(TXMCoreMessages.parentDirectoryP0NotFound, exportzip.getParentFile()));
817

  
828
			
818 829
		}
819 830
		return false;
820 831
	}
821

  
832
	
822 833
	/**
823 834
	 * Gets the base directory.
824 835
	 *
......
826 837
	 */
827 838
	public File getProjectDirectory() {
828 839
		if (this.rcpProject == null || this.rcpProject.getLocation() == null) {
829
			return new File(Toolbox.workspace.getLocation(), "corpora/"+this.userName);
840
			return new File(Toolbox.workspace.getLocation(), "corpora/" + this.userName);
830 841
		}
831 842
		return this.rcpProject.getLocation().toFile();
832 843
	}
833

  
844
	
834 845
	public HashMap<String, Alignement> getLinks() {
835 846
		return links;
836 847
	}
837

  
848
	
838 849
	public ArrayList<Alignement> getLinksFrom(String from) {
839
		ArrayList<Alignement> rez = new ArrayList<Alignement>();
840
		for(String key : links.keySet())
841
			if(key.startsWith("#"+from+" ")) //$NON-NLS-1$ //$NON-NLS-2$
850
		ArrayList<Alignement> rez = new ArrayList<>();
851
		for (String key : links.keySet())
852
			if (key.startsWith("#" + from + " ")) //$NON-NLS-1$ //$NON-NLS-2$
842 853
				rez.add(links.get(key));
843 854
		return rez;
844 855
	}
845

  
856
	
846 857
	public ArrayList<Alignement> getLinksTo(String to) {
847
		ArrayList<Alignement> rez = new ArrayList<Alignement>();
848
		for(String key : links.keySet())
849
			if(key.endsWith(" #"+to)) //$NON-NLS-1$
858
		ArrayList<Alignement> rez = new ArrayList<>();
859
		for (String key : links.keySet())
860
			if (key.endsWith(" #" + to)) //$NON-NLS-1$
850 861
				rez.add(links.get(key));
851 862
		return rez;
852 863
	}
853

  
864
	
854 865
	public Alignement getLink(String from, String to) {
855
		return links.get("#"+from+" #"+to ); //$NON-NLS-1$ //$NON-NLS-2$
866
		return links.get("#" + from + " #" + to); //$NON-NLS-1$ //$NON-NLS-2$
856 867
	}
857

  
868
	
858 869
	@Override
859 870
	public boolean saveParameters() throws Exception {
860 871
		StringBuilder str = new StringBuilder();
861 872
		if (links != null) {
862 873
			for (String l : links.keySet()) {
863 874
				Alignement a = links.get(l);
864
				str.append("\t"+a.from+"#"+a.to+"#"+a.struct+"#"+a.level);
875
				str.append("\t" + a.from + "#" + a.to + "#" + a.struct + "#" + a.level);
865 876
			}
866 877
			if (str.length() > 0) {
867 878
				this.setParameter(TBXPreferences.LINKS, str.substring(1));
868 879
			}
869 880
		}
870

  
881
		
871 882
		if (this.pSrcDirectory != null) {
872 883
			this.saveParameter(TBXPreferences.SOURCE, pSrcDirectory.getAbsolutePath());
873 884
		}
874

  
885
		
875 886
		return true;
876 887
	}
877

  
888
	
878 889
	@Override
879 890
	public boolean loadParameters() throws Exception {
880

  
891
		
881 892
		String path = this.getStringParameterValue(TBXPreferences.SOURCE);
882 893
		if (path != null && path.length() > 0) {
883 894
			this.pSrcDirectory = new File(path);
884 895
		}
885

  
896
		
886 897
		String linksString = this.getStringParameterValue(TBXPreferences.LINKS);
887 898
		if (linksString != null && !linksString.isEmpty()) {
888 899
			String split[] = linksString.split("\t");
......
891 902
				new Alignement(this, split2[0], split2[1], split2[2], Integer.parseInt(split2[3]));
892 903
			}
893 904
		}
894

  
895
		//		String xsltParamteresString = this.getStringParameterValue(TBXPreferences.FRONT_XSL_PARAMETERS);
896
		//		if (xsltParamteresString != null && !xsltParamteresString.isEmpty()) {
897
		//			String[] split = xsltParamteresString.split("\t");
898
		//			for (String s: split) {
899
		//				String split2 [] = s.split("=", 2);
900
		//				pXsltParameters.put(split2[0], split2[1]);
901
		//			}
902
		//		}
903

  
905
		
906
		// String xsltParamteresString = this.getStringParameterValue(TBXPreferences.FRONT_XSL_PARAMETERS);
907
		// if (xsltParamteresString != null && !xsltParamteresString.isEmpty()) {
908
		// String[] split = xsltParamteresString.split("\t");
909
		// for (String s: split) {
910
		// String split2 [] = s.split("=", 2);
911
		// pXsltParameters.put(split2[0], split2[1]);
912
		// }
913
		// }
914
		
904 915
		return true;
905 916
	}
906

  
917
	
907 918
	@Override
908 919
	public boolean setParameters(TXMParameters parameters) throws Exception {
909 920
		return false;
910 921
	}
911

  
922
	
912 923
	@Override
913 924
	public String getName() {
914 925
		return userName;
915 926
	}
916

  
927
	
917 928
	@Override
918 929
	public String getSimpleName() {
919 930
		return userName;
920 931
	}
921

  
932
	
922 933
	@Override
923 934
	public String getDetails() {
924 935
		return userName;
925 936
	}
926

  
937
	
927 938
	@Override
928 939
	public void clean() {
929 940
		if (rcpProject != null) {
930 941
			try {
931
				//Toolbox.getEngineManager(EngineType.SEARCH).getEngine("CQP").stop(); //$NON-NLS-1$
932

  
933
				rcpProject.delete(true, new LogMonitor("Cleaning "+this));
934

  
935

  
936
				//Toolbox.getEngineManager(EngineType.SEARCH).getEngine("CQP").start(null); //$NON-NLS-1$
937

  
938
			} catch (Exception e) {
942
				// Toolbox.getEngineManager(EngineType.SEARCH).getEngine("CQP").stop(); //$NON-NLS-1$
943
				
944
				rcpProject.delete(true, new LogMonitor("Cleaning " + this));
945
				
946
				
947
				// Toolbox.getEngineManager(EngineType.SEARCH).getEngine("CQP").start(null); //$NON-NLS-1$
948
				
949
			}
950
			catch (Exception e) {
939 951
				// TODO Auto-generated catch block
940 952
				e.printStackTrace();
941 953
			}
942 954
		}
943

  
955
		
944 956
		Toolbox.notifyEngines(this, "clean");
945
		//DeleteDir.deleteDirectory(getProjectDirectory());
957
		// DeleteDir.deleteDirectory(getProjectDirectory());
946 958
	}
947

  
959
	
948 960
	public void setName(String name) {
949 961
		this.userName = name;
950 962
	}
951

  
952

  
953

  
963
	
964
	
965
	
954 966
	@Override
955 967
	public boolean toTxt(File outfile, String encoding, String colseparator, String txtseparator) throws Exception {
956 968
		return false;
957 969
	}
958

  
970
	
959 971
	@Override
960 972
	public String getResultType() {
961 973
		return "Project";
962 974
	}
963

  
975
	
964 976
	public String getImportModuleName() {
965 977
		return pImportModuleName;
966 978
	}
967

  
979
	
968 980
	/**
969 981
	 * Gets the encoding.
970 982
	 *
......
973 985
	public String getEncoding() {
974 986
		return pEncoding;
975 987
	}
976

  
988
	
977 989
	/**
978 990
	 * Gets the lang.
979 991
	 *
......
982 994
	public String getLang() {
983 995
		return pLanguage;
984 996
	}
985

  
997
	
986 998
	/**
987 999
	 * Gets the srcdir.
988 1000
	 *
......
991 1003
	public File getSrcdir() {
992 1004
		return pSrcDirectory;
993 1005
	}
994

  
1006
	
995 1007
	/**
996 1008
	 * Gets the author.
997 1009
	 *
......
1000 1012
	public String getAuthor() {
1001 1013
		return pAuthor;
1002 1014
	}
1003

  
1015
	
1004 1016
	/**
1005 1017
	 * Gets the description.
1006 1018
	 *
......
1009 1021
	public String getDescription() {
1010 1022
		return this.pDescription;
1011 1023
	}
1012

  
1024
	
1013 1025
	/**
1014 1026
	 * Gets the description.
1015 1027
	 *
......
1018 1030
	public void setDescription(String desc) {
1019 1031
		this.pDescription = desc;
1020 1032
	}
1021

  
1033
	
1022 1034
	/**
1023 1035
	 * @return the font
1024 1036
	 */
1025 1037
	public String getFont() {
1026 1038
		return pFont;
1027 1039
	}
1028

  
1040
	
1029 1041
	/**
1030 1042
	 * @param font the font to set
1031 1043
	 */
1032 1044
	public void setFont(String font) {
1033 1045
		this.pFont = font;
1034 1046
	}
1035

  
1047
	
1036 1048
	public void setLang(String lang) {
1037 1049
		this.pLanguage = lang;
1038 1050
	}
1039

  
1051
	
1040 1052
	public void setEncoding(String encoding) {
1041 1053
		this.pEncoding = encoding;
1042 1054
	}
1043

  
1055
	
1044 1056
	public void setSourceDirectory(String sourcePath) {
1045 1057
		this.pSrcDirectory = new File(sourcePath);
1046 1058
	}
1047

  
1059
	
1048 1060
	public void setXsltParameter(String name, String value) {
1049 1061
		this.getPreferencesScope().getNode("xsl").node(TBXPreferences.FRONT_XSL_PARAMETERS).put(name, value);
1050 1062
	}
1051

  
1063
	
1052 1064
	public HashMap<String, String> getXsltParameters() {
1053 1065
		Preferences params = this.getPreferencesScope().getNode("xsl").node(TBXPreferences.FRONT_XSL_PARAMETERS);
1054 1066
		HashMap<String, String> hparams = new HashMap<>();
......
1056 1068
			for (String k : params.childrenNames()) {
1057 1069
				hparams.put(k, params.get(k, null));
1058 1070
			}
1059
		} catch (BackingStoreException e) {
1071
		}
1072
		catch (BackingStoreException e) {
1060 1073
			// TODO Auto-generated catch block
1061 1074
			e.printStackTrace();
1062 1075
		}
1063 1076
		return hparams;
1064 1077
	}
1065

  
1078
	
1066 1079
	public void removeXsltParameter(String name) {
1067 1080
		this.getPreferencesScope().getNode("xsl").node(TBXPreferences.FRONT_XSL_PARAMETERS).remove(name);
1068 1081
	}
1069

  
1082
	
1070 1083
	public String getFrontXSL() {
1071 1084
		return this.getPreferencesScope().getNode("xsl").get(TBXPreferences.FRONT_XSL, null);
1072 1085
	}
1073

  
1086
	
1074 1087
	public void setXslt(String xslpath) {
1075 1088
		this.getPreferencesScope().getNode("xsl").put(TBXPreferences.FRONT_XSL, xslpath);
1076 1089
	}
1077

  
1090
	
1078 1091
	public void setAnnotate(boolean b) {
1079 1092
		this.pAnnotate = b;
1080 1093
	}
1081

  
1094
	
1082 1095
	public Boolean getAnnotate() {
1083 1096
		return pAnnotate;
1084 1097
	}
1085

  
1098
	
1086 1099
	public void setCleanAfterBuild(boolean clean) {
1087 1100
		this.pCleanAfterBuild = clean;
1088 1101
	}
1089

  
1102
	
1090 1103
	public Boolean getCleanAfterBuild() {
1091 1104
		return this.pCleanAfterBuild;
1092 1105
	}
1093

  
1106
	
1094 1107
	public void addTokenizerParameter(String name, String value) {
1095 1108
		IEclipsePreferences params = this.getPreferencesScope().getNode("Tokenizer");
1096 1109
		params.put(name, value);
1097 1110
	}
1098

  
1111
	
1099 1112
	public String getTokenizerParameter(String name, String defaultvalue) {
1100 1113
		IEclipsePreferences params = this.getPreferencesScope().getNode("Tokenizer");
1101 1114
		return params.get(name, defaultvalue);
1102 1115
	}
1103

  
1116
	
1104 1117
	public String[] getTextualPlans() {
1105 1118
		try {
1106 1119
			return this.getPreferencesScope().getNode("TextualPlans").childrenNames();
1107
		} catch (BackingStoreException e) {
1120
		}
1121
		catch (BackingStoreException e) {
1108 1122
			// TODO Auto-generated catch block
1109 1123
			e.printStackTrace();
1110 1124
		}
1111 1125
		return new String[0];
1112 1126
	}
1113

  
1127
	
1114 1128
	public String getTextualPlan(String name) {
1115 1129
		return this.getPreferencesScope().getNode("TextualPlans").get(name, "");
1116 1130
	}
1117

  
1131
	
1118 1132
	public void setTextualPlan(String name, String elements) {
1119 1133
		this.getPreferencesScope().getNode("TextualPlans").put(name, elements);
1120 1134
	}
1121

  
1135
	
1122 1136
	public String getTokenizerWordElement() {
1123 1137
		IEclipsePreferences params = this.getPreferencesScope().getNode("Tokenizer");
1124 1138
		return params.get("word_tags", "w");
1125 1139
	}
1126

  
1140
	
1127 1141
	public boolean getDoTokenizerStep() {
1128 1142
		IEclipsePreferences params = this.getPreferencesScope().getNode("Tokenizer");
1129 1143
		return params.getBoolean("doTokenizeStep", true);
1130 1144
	}
1131

  
1145
	
1132 1146
	public EditionDefinition getEditionDefinition(String name) {
1133 1147
		return new EditionDefinition(this, name);
1134 1148
	}
1135 1149
	
1136 1150
	public ArrayList<EditionDefinition> getEditionDefinitions() {
1137
		ArrayList<EditionDefinition> editions = new ArrayList<EditionDefinition>();
1151
		ArrayList<EditionDefinition> editions = new ArrayList<>();
1138 1152
		IEclipsePreferences editionNode = this.getPreferencesScope().getNode(EditionDefinition.class.getSimpleName());
1139 1153
		try {
1140 1154
			for (String editionName : editionNode.childrenNames()) {
......
1142 1156
					editions.add(getEditionDefinition(editionName));
1143 1157
				}
1144 1158
			}
1145
		} catch (BackingStoreException e) {
1159
		}
1160
		catch (BackingStoreException e) {
1146 1161
			// TODO Auto-generated catch block
1147 1162
			e.printStackTrace();
1148 1163
		}
......
1152 1167
	public CorpusCommandPreferences getCommandPreferences(String name) {
1153 1168
		return new CorpusCommandPreferences(this, name);
1154 1169
	}
1155

  
1170
	
1156 1171
	public ProjectScope getPreferencesScope() {
1157 1172
		return this.preferenceScope;
1158 1173
	}
1159

  
1174
	
1160 1175
	public CorpusBuild getCorpusBuild(String id) {
1161 1176
		return getCorpusBuild(id, null);
1162 1177
	}
......
1168 1183
	 * @return
1169 1184
	 */
1170 1185
	public CorpusBuild getCorpusBuild(String id, Class<? extends CorpusBuild> clazz) {
1171
//		System.out.println("CLASS="+clazz);
1186
		// System.out.println("CLASS="+clazz);
1172 1187
		List<CorpusBuild> builds = getCorpusBuilds();
1173
//		System.out.println("BUILDS="+builds);
1188
		// System.out.println("BUILDS="+builds);
1174 1189
		for (CorpusBuild build : builds) {
1175 1190
			if (id == null) {
1176 1191
				if (clazz == null) {
1177 1192
					return build;
1178
				} else if (build.getClass().equals(clazz) ) {
1193
				}
1194
				else if (build.getClass().equals(clazz)) {
1179 1195
					return build;
1180 1196
				}
1181
			} else if (id.equals(build.getID())) {
1197
			}
1198
			else if (id.equals(build.getID())) {
1182 1199
				if (clazz == null) {
1183 1200
					return build;
1184
				} else if (build.getClass().equals(clazz)) {
1201
				}
1202
				else if (build.getClass().equals(clazz)) {
1185 1203
					return build;
1186 1204
				}
1187 1205
			}
1188 1206
		}
1189 1207
		return null;
1190 1208
	}
1191

  
1209
	
1192 1210
	@SuppressWarnings("unchecked")
1193 1211
	private List<CorpusBuild> getCorpusBuilds() {
1194 1212
		return (List<CorpusBuild>) getChildren(CorpusBuild.class);
1195 1213
	}
1196

  
1214
	
1197 1215
	public void setImportModuleName(String name) {
1198 1216
		this.pImportModuleName = name;
1199 1217
	}
1200

  
1218
	
1201 1219
	/**
1202 1220
	 * Checks if the edition specified by its name exists in the project.
1203 1221
	 * 
......
1208 1226
	public boolean hasEditionDefinition(String name) {
1209 1227
		try {
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff