Révision 1652

tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/GroovyScriptedImportEngine.java (revision 1652)
133 133
					
134 134
					project.saveParameters(true);
135 135
					
136
					Log.info(GroovyMessages.restartingToolboxSearchengines);
137
					Toolbox.getEngineManager(EngineType.SEARCH).restartEngines();
138
					Log.info(TXMCoreMessages.common_done);
136
//					Log.info(GroovyMessages.restartingToolboxSearchengines);
137
//					Toolbox.getEngineManager(EngineType.SEARCH).restartEngines();
138
//					Log.info(TXMCoreMessages.common_done);
139 139
					
140 140
				} else {
141 141
					Log.fine(GroovyMessages.errorImportNotCorrectlyEndedSeeConsoleMessages);
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/compiler.groovy (revision 1652)
142 142
		corpus.setID(project.getName());
143 143
		corpus.setName(project.getName());
144 144
		corpus.setDescription("Built with the XML-TRS import module");
145
		if (!corpus.compute(false)) {corpus.delete();
146
			return false;
147
		}
148 145
		
149 146
		cqpFile = new File(binDir,"cqp/"+corpusname+".cqp");
150 147
		new File(binDir,"cqp").mkdirs()
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/txt/compiler.groovy (revision 1652)
192 192
		corpus.setID(project.getName());
193 193
		corpus.setName(project.getName());
194 194
		corpus.setDescription("Built with the TXT+CSV import module");
195
		if (!corpus.compute(false)) {
196
			return false;
197
		}
198 195
		
199 196
		File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp");
200 197
cqpFile.delete()
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/alceste/compiler.groovy (revision 1652)
186 186
		corpus.setID(project.getName());
187 187
		corpus.setName(project.getName());
188 188
		corpus.setDescription("Build the Alceste import module");
189
		if (!corpus.compute(false)) {corpus.delete();
190
			return false;
191
		}
189

  
192 190
		File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp");
193 191
cqpFile.delete()
194 192
		new File(binDir,"cqp").mkdirs()
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/hyperbase/compiler.groovy (revision 1652)
198 198
		corpus.setID(project.getName());
199 199
		corpus.setName(project.getName());
200 200
		corpus.setDescription("Built with the Hyperbase import module");
201
		if (!corpus.compute(false)) {corpus.delete();
202
			return false;
203
		}
204 201
		
205 202
		File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp");
206 203
cqpFile.delete()
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/cqp/compiler.groovy (revision 1652)
99 99
		corpus.setID(project.getName());
100 100
		corpus.setName(project.getName());
101 101
		corpus.setDescription("Built with the CQP import module");
102
		if (!corpus.compute(false)) {corpus.delete();
103
			return false;
104
		}
105 102
		
106 103
		File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp");
107 104
cqpFile.delete()
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZCompiler.groovy (revision 1652)
60 60
		corpus.setID(corpusname);
61 61
		corpus.setName(corpusname);
62 62
		corpus.setDescription("Built with the XTZ import module");
63
		if (!corpus.compute(false)) {
64
			isSuccessFul = false;
65
			return;
66
		}
67 63
		
68 64
		if (module.getProject().getCleanAfterBuild()) {
69 65
			new File(module.getBinaryDirectory(), "cqp").deleteDir()
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xmltxm/compiler.groovy (revision 1652)
362 362
		corpus.setID(project.getName());
363 363
		corpus.setName(project.getName());
364 364
		corpus.setDescription("Built with the XML-TXM import module");
365
		if (!corpus.compute(false)) {corpus.delete();
366
			return false;
367
		}
368 365
		
369 366
		File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp");
370 367
cqpFile.delete()
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/discours/compiler.groovy (revision 1652)
186 186
		corpus.setID(project.getName());
187 187
		corpus.setName(project.getName());
188 188
		corpus.setDescription("Built with the CNR+CSV import module");
189
		if (!corpus.compute(false)) {corpus.delete();
190
			return false;
191
		}
192 189
		
193 190
		File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp");
194 191
cqpFile.delete()
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xml/compiler.groovy (revision 1652)
460 460
		corpus.setID(project.getName());
461 461
		corpus.setName(project.getName());
462 462
		corpus.setDescription("Built with the XML/w import module");
463
		if (!corpus.compute(false)) {corpus.delete();
464
			return false;
465
		}
466 463
		
467 464
		File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp");
468 465
cqpFile.delete()
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/bfm/compiler.groovy (revision 1652)
763 763
		corpus.setID(project.getName());
764 764
		corpus.setName(project.getName());
765 765
		corpus.setDescription("Built with the BFM import module");
766
		if (!corpus.compute(false)) {corpus.delete();
767
			return false;
768
		}
769 766
		
770 767
		File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp");
771 768
cqpFile.delete()
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/tmx/compiler.groovy (revision 1652)
488 488
			corpus.setID(cqpName);
489 489
			corpus.setName(cqpName);
490 490
			corpus.setDescription("Built with the TMX import module");
491
			if (!corpus.compute(false)) {
492
				return false;
493
			}
494 491
			
495 492
			File cqpFile = new File(binDir,"cqp/"+cqpName+".cqp");
496 493
			
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteImportScript.java (revision 1652)
150 150
			return null;
151 151
		}
152 152
		
153
		if (CQPSearchEngine.isInitialized()) {
154
			Toolbox.getEngineManager(EngineType.SEARCH).stopEngines();
155
		}
153
//		if (CQPSearchEngine.isInitialized()) {
154
//			Toolbox.getEngineManager(EngineType.SEARCH).stopEngines();
155
//		}
156 156
		
157 157
		JobHandler jobhandler = new JobHandler(TXMUIMessages.scriptExecution
158 158
				+ project.getImportModuleName()) { //$NON-NLS-1$
......
173 173
					e.printStackTrace();
174 174
				} finally {
175 175
					System.gc();
176
					if (!CQPSearchEngine.isInitialized()) {
177
						try {
178
							SearchEnginesManager.getCQPSearchEngine().start(monitor);
179
						} catch (Exception e) {
180
							// TODO Auto-generated catch block
181
							e.printStackTrace();
182
						}
183
					}
176
//					if (!CQPSearchEngine.isInitialized()) {
177
//						try {
178
//							SearchEnginesManager.getCQPSearchEngine().start(monitor);
179
//						} catch (Exception e) {
180
//							// TODO Auto-generated catch block
181
//							e.printStackTrace();
182
//						}
183
//					}
184 184
					syncExec(new Runnable() {
185 185
						@Override
186 186
						public void run() {
tmp/org.txm.core/src/java/org/txm/objects/Project.java (revision 1652)
303 303
					corpus.deleteChildren(null); // remove all Corpus results
304 304
				}
305 305
			}
306

  
306
			
307 307
			boolean state = engine.build(this, monitor).isOK();
308 308
			if(state == true)	{
309 309
				this.needToBuild = false;
310
				// This step could be done only if the compiler step if done and only if it modifying/deleting the corpus builds
311
				for (CorpusBuild corpus : getCorpusBuilds()) {
312
					if (corpus != null) {
313
						corpus.compute();
314
					}
315
				}
316
				
310 317
			}
311 318
			return state;
312 319

  
......
923 930
				// TODO Auto-generated catch block
924 931
				e.printStackTrace();
925 932
			}
926
			
927
			
928
			
929 933
		}
930 934

  
931 935
		Toolbox.notifyEngines(this, "clean");
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/NetCqiClient.java (revision 1652)
1002 1002
	 * 
1003 1003
	 * @param corpus
1004 1004
	 *            the corpus
1005
	 * @throws IOException 
1005 1006
	 */
1006 1007
	@Override
1007
	public synchronized void dropCorpus(String corpus) {
1008
		throw new UnsupportedOperationException();
1008
	public synchronized void dropCorpus(String corpus) throws IOException {
1009
		this.streamToServer.write(CQI_CORPUS_DROP_CORPUS);
1010
		this.writeString(corpus);
1011
		return;
1009 1012
	}
1010 1013

  
1011 1014
	// CQI_CQP_ERROR_NO_SUCH_CORPUS, CQI_CL_ERROR_NO_SUCH_ATTRIBUTE,
......
1927 1930
		server.stop();
1928 1931
		
1929 1932
	}
1933

  
1934
	@Override
1935
	public boolean load_a_system_corpus(String regfilepath, String entry) throws IOException, UnexpectedAnswerException, CqiServerError {
1936
		this.streamToServer.write(CQI_CQP_LOAD_SYSTEM_CORPUS);
1937
		this.writeString(regfilepath);
1938
		this.writeString(entry);
1939
		return readBoolean();
1940
	}
1930 1941
}
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/ICqiClient.java (revision 1652)
272 272

  
273 273
	/** The Constant CQI_CQP_FDIST_2. */
274 274
	final static public byte[] CQI_CQP_FDIST_2 = { (byte) 0x15, (byte) 0x11 };
275

  
275
	
276 276
	/** The Constant CQI_CQP_QUERY. */
277
	final static public byte[] CQI_CQP_QUERY_EVAL = { (byte) 0x15, (byte) 0x01 };
277
	final static public byte[] CQI_CQP_QUERY_EVAL = { (byte) 0x15, (byte) 0x012 };
278 278
	
279
	/** The Constant CQI_CQP_LOAD_SYSTEM_CORPUS. */
280
	final static public byte[] CQI_CQP_LOAD_SYSTEM_CORPUS = { (byte) 0x15, (byte) 0x13 };
281
	
279 282
	/** The Constant CQI_CONST_FIELD_MATCH. */
280 283
	final public static byte CQI_CONST_FIELD_MATCH = (byte) 0x10;
281 284

  
......
817 820
			byte field1, String attribute1, byte field2, String attribute2) throws IOException, UnexpectedAnswerException, CqiServerError;
818 821

  
819 822
	public boolean reconnect() ;
823
	
824
	/**
825
	 * Runs a CQP query line (ends with ";").
826
	 *
827
	 * @param query the query
828
	 * @throws CqiServerError 
829
	 * @throws UnexpectedAnswerException 
830
	 * @throws IOException 
831
	 */
832
	public void query(String query) throws IOException, UnexpectedAnswerException, CqiServerError;
833

  
834
	/**
835
	 * Load a system corpus
836
	 *
837
	 * @param regfilepath the subcorpus
838
	 * @param entry the corpus ID (uppercase)
839
	 * @return 
840
	 * @throws CqiServerError 
841
	 * @throws UnexpectedAnswerException 
842
	 * @throws IOException 
843
	 */
844
	public boolean load_a_system_corpus(String regfilepath, String entry) throws IOException, UnexpectedAnswerException, CqiServerError;
820 845
}
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/MainCorpus.java (revision 1652)
561 561
			return getName();
562 562
		}
563 563
	}
564
	
565
	
564

  
565

  
566 566
	protected boolean modified = false;
567 567
	public boolean isModified() { return modified; }
568 568
	public void setIsModified(boolean b) { modified = b; }
......
635 635

  
636 636
	@Override
637 637
	protected boolean _compute() throws Exception {
638

  
639
		if (!CQPSearchEngine.isInitialized()) return false;
640

  
638 641
		HashMap<String, MainCorpus> corpora = CorpusManager.getCorpusManager().getCorpora();
639 642
		if (corpora.get(this.pID) != null && corpora.get(this.pID) != this) {
640 643
			Log.severe(NLS.bind("** Error: the \"{0}\" MainCorpus object in the \\\"{1}\\\" project can not be computed: another one with the same CQP identifier has already been computed.", this.pID, this.getProjectDirectory()));
......
642 645
		}
643 646
		corpora.put(this.pID, this);
644 647

  
645
		if (CQPSearchEngine.isInitialized()) {
646
			try {
647
				CQPSearchEngine.getCqiClient().corpusCharset(this.pID);
648
				corpora.put(this.pID, this); // register the corpus
649
			} catch(Exception e) {
650
				if (corpora.get(this.pID) == this) {
651
					corpora.remove(this.pID); // unregister the broken corpus
652
				}
653
				return false;
648
		this.dataDirectory = new File(getProjectDirectory(), "data/"+getID());
649
		this.registryFile = new File(getProjectDirectory(), "registry/"+getID().toLowerCase());
650
		
651
		try {
652
			CQPSearchEngine.getCqiClient().load_a_system_corpus(this.registryFile.getParent(), this.pID);
653
			corpora.put(this.pID, this); // register the corpus
654
		} catch(Exception e) {
655
			Log.severe("MainCorpus not loaded: "+e);
656
			if (corpora.get(this.pID) == this) {
657
				corpora.remove(this.pID); // unregister the broken corpus
654 658
			}
659
			return false;
655 660
		}
661

  
656 662
		
657
		this.dataDirectory = new File(getProjectDirectory(), "data/"+getID());
658
		this.registryFile = new File(getProjectDirectory(), "registry/"+getID().toLowerCase());
659
		
663

  
660 664
		return true;
661 665
	}
662 666

  
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/AbstractCqiClient.java (revision 1652)
615 615
	public abstract int[] alg2Cpos(String attribute, int struc) throws UnexpectedAnswerException, IOException, CqiServerError;
616 616

  
617 617
	/**
618
	 * Runs a CQP query.
618
	 * Runs a CQL query.
619 619
	 *
620 620
	 * @param motherCorpus the mother corpus
621 621
	 * @param subcorpus the subcorpus
......
628 628
	public abstract void cqpQuery(String motherCorpus, String subcorpus, String query) throws IOException, UnexpectedAnswerException, CqiServerError;
629 629

  
630 630
	/**
631
	 * Runs a CQP query line.
632
	 *
633
	 * @param motherCorpus the mother corpus
634
	 * @param subcorpus the subcorpus
635
	 * @param query the query
636
	 * @throws IOException Signals that an I/O exception has occurred.
637
	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
638
	 * @throws CqiServerError the cqi server error
639
	 */
640
	@Override
641
	public abstract void query(String query) throws IOException, UnexpectedAnswerException, CqiServerError;
642

  
643
	/**
644
	 * Runs a CQP query.
645
	 *
646
	 * @param motherCorpus the mother corpus
647
	 * @param subcorpus the subcorpus
648
	 * @param query the query
649
	 * @return 
650
	 * @throws IOException Signals that an I/O exception has occurred.
651
	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
652
	 * @throws CqiServerError the cqi server error
653
	 */
654
	@Override
655
	public abstract boolean load_a_system_corpus(String regfilepath, String entry) throws IOException, UnexpectedAnswerException, CqiServerError;
656

  
657
	/**
631 658
	 * Lists all the subcorpora of a corpus.
632 659
	 *
633 660
	 * @param corpus the corpus
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/MemCqiServer.java (revision 1652)
46 46
import org.txm.utils.ExecTimer;
47 47
import org.txm.utils.logger.Log;
48 48

  
49
// TODO: Auto-generated Javadoc
50 49
/**
51 50
 * Memory implementation of CQP Server usqing the cqi JNI library
52 51
 * 
......
165 164
			LIBRARIES.setAccessible(true);
166 165

  
167 166
			// FIXME: Debug
168
			System.err.println(">>>>>>>>>>>>>>>>>>>> MemCqiServer.start() " + this.getClass().getClassLoader());
167
			//System.err.println(">>>>>>>>>>>>>>>>>>>> MemCqiServer.start() " + this.getClass().getClassLoader());
169 168
			
170 169
			try {
171 170

  
......
311 310
	static Boolean isLoaded = false;
312 311

  
313 312
	public native Boolean start(String[] args);
314

  
313
	
314
	public native Boolean load_a_system_corpus(String regfilepath, String entryname) throws IOException, UnexpectedAnswerException, CqiServerError ;
315
	
315 316
	public native Boolean stop();
316 317

  
317 318
	public native int[] alg2Cpos(String arg0, int arg1) throws UnexpectedAnswerException, IOException, CqiServerError;
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/MemCqiClient.java (revision 1652)
55 55
				(byte)value};
56 56
	}
57 57

  
58
	public byte[] throwExceptionFromCqi(int error) throws CqiServerError, UnexpectedAnswerException, IOException {
59
		return throwExceptionFromCqi("CQi", error);
60
	}
58 61

  
59
	public byte[] throwExceptionFromCqi(int error) throws CqiServerError, UnexpectedAnswerException, IOException {
62
	public byte[] throwExceptionFromCqi(String message, int error) throws CqiServerError, UnexpectedAnswerException, IOException {
60 63
		byte[] ret = intToByteArray(error);
61 64
		
62 65
		byte b = ret[2];
......
133 136
			switch (b2) {
134 137
			case 0x01:// cf cqi.h:39
135 138
				lastError += ": NoSuchAttribute error";
136
				throw new CqiClErrorNoSuchAttribute();
139
				throw new CqiClErrorNoSuchAttribute(message);
137 140
			case 0x02:// cf cqi.h:40
138 141
				lastError += ": WrongAttributeType error";
139
				throw new CqiClErrorWrongAttributeType();
142
				throw new CqiClErrorWrongAttributeType(message);
140 143
			case 0x03:// cf cqi.h:41
141 144
				lastError += ": OutOfRange error";
142
				throw new CqiClErrorOutOfRange();
145
				throw new CqiClErrorOutOfRange(message);
143 146
			case 0x04:// cf cqi.h:42
144 147
				lastError = this.getLastCqiError();
145
				throw new CqiClErrorRegex();
148
				throw new CqiClErrorRegex(message);
146 149
			case 0x05:// cf cqi.h:42
147 150
				lastError += ": CorpusAccess error";
148
				throw new CqiClErrorCorpusAccess();
151
				throw new CqiClErrorCorpusAccess(message);
149 152
			case 0x06:// cf cqi.h:42
150 153
				lastError += ": OutOfMemory error";
151
				throw new CqiClErrorOutOfMemory();
154
				throw new CqiClErrorOutOfMemory(message);
152 155
			case 0x07:// cf cqi.h:42
153 156
				lastError += ": Internal error";
154
				throw new CqiClErrorInternal();
157
				throw new CqiClErrorInternal(message);
155 158
			default:
156 159
				lastError += ": Unknown error";
157 160
				throw new CqiErrorGeneralError(CQPSearchEngineCoreMessages.unknownCQPErrorColonB1+b+CQPSearchEngineCoreMessages.b2+b2);
......
164 167
			switch (b2) {
165 168
			case 0x01:// cf cqi.h:39
166 169
				lastError += ": General error";
167
				throw new CqiCqpErrorErrorGeneral();
170
				throw new CqiCqpErrorErrorGeneral(message);
168 171
			case 0x02:// cf cqi.h:40
169 172
				lastError += ": NoSuchCorpus error";
170
				throw new CqiCqpErrorNoSuchCorpus();
173
				throw new CqiCqpErrorNoSuchCorpus(message);
171 174
			case 0x03:// cf cqi.h:41
172 175
				lastError += ": InvalidField error";
173
				throw new CqiCqpErrorInvalidField();
176
				throw new CqiCqpErrorInvalidField(message);
174 177
			case 0x04:// cf cqi.h:42
175 178
				lastError += ": OutOfRange error";
176
				throw new CqiCqpErrorOutOfRange();
179
				throw new CqiCqpErrorOutOfRange(message);
177 180
			case 0x05:// cf cqi.h:44
178 181
				lastError = getLastCQPError();
179
				throw new CqiCqpErrorSyntax();
182
				throw new CqiCqpErrorSyntax(message);
180 183
			default:
181 184
				throw new CqiErrorGeneralError(CQPSearchEngineCoreMessages.unknownCQPErrorColonB1+b+CQPSearchEngineCoreMessages.b2+b2);
182 185
			}
......
385 388

  
386 389
		Boolean ret = server.dropSubCorpus(arg0);
387 390
		if (ret == null || !ret) {
388
			throwExceptionFromCqi(server.getErrorCode());
391
			throwExceptionFromCqi("Fail to drop subcorpus "+arg0+": ", server.getErrorCode());
389 392
		}
390 393
	}
391 394

  
......
590 593
		}
591 594
		return rez;
592 595
	}
596

  
597
	@Override
598
	public boolean load_a_system_corpus(String regfilepath, String entry) throws IOException, UnexpectedAnswerException, CqiServerError {
599
		return server.load_a_system_corpus(regfilepath, entry);
600
	}
593 601
}
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/ICqiServer.java (revision 1652)
30 30
import java.io.InputStream;
31 31
import java.io.OutputStream;
32 32

  
33
// TODO: Auto-generated Javadoc
34 33
/**
35 34
 * This class aims at handling a CQi server process. It is not a CQi server per
36 35
 * se.

Formats disponibles : Unified diff