Révision 2997
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 2997) | ||
---|---|---|
131 | 131 |
*/ |
132 | 132 |
private String parametersNodePath; |
133 | 133 |
|
134 |
|
|
135 | 134 |
/** |
136 | 135 |
* Thread used when calling compute(). |
137 | 136 |
*/ |
tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/adapters/CorpusAdapterFactory.java (revision 2997) | ||
---|---|---|
15 | 15 |
import org.txm.rcp.adapters.TXMResultAdapter; |
16 | 16 |
import org.txm.rcp.adapters.TXMResultAdapterFactory; |
17 | 17 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
18 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
|
18 | 19 |
import org.txm.searchengine.cqp.corpus.Partition; |
19 | 20 |
|
20 | 21 |
|
21 | 22 |
/** |
22 | 23 |
* A factory for creating Adapter objects. |
23 |
*
|
|
24 |
* |
|
24 | 25 |
* @author mdecorde |
25 | 26 |
* @author sjacquot |
26 | 27 |
*/ |
27 | 28 |
public class CorpusAdapterFactory extends TXMResultAdapterFactory { |
28 |
|
|
29 | 29 |
|
30 |
|
|
30 |
|
|
31 |
|
|
31 | 32 |
@Override |
32 | 33 |
public Object getAdapter(Object adaptableObject, Class adapterType) { |
33 |
if(adapterType == IWorkbenchAdapter.class && adaptableObject instanceof CQPCorpus) {
|
|
34 |
if (adapterType == IWorkbenchAdapter.class && adaptableObject instanceof CQPCorpus) {
|
|
34 | 35 |
return new TXMResultAdapter() { |
36 |
|
|
35 | 37 |
@Override |
36 | 38 |
public Object[] getChildren(Object corpus) { |
37 | 39 |
|
38 |
//List<TXMResult> allChildren = ((CQPCorpus) corpus).getChildren(); |
|
40 |
// List<TXMResult> allChildren = ((CQPCorpus) corpus).getChildren();
|
|
39 | 41 |
List<TXMResult> allChildren = ((TXMResult) corpus).getChildren(!TBXPreferences.getInstance().getBoolean(TBXPreferences.SHOW_ALL_RESULT_NODES)); |
40 | 42 |
|
41 | 43 |
|
... | ... | |
46 | 48 |
ArrayList children = new ArrayList(); |
47 | 49 |
|
48 | 50 |
// FIXME: remove Text and SavedQuery from the corpora view |
49 |
// + sort and group the partitions and subcorpus
|
|
51 |
// + sort and group the partitions and subcorpus |
|
50 | 52 |
for (int i = 0; i < allChildren.size(); i++) { |
51 | 53 |
Object element = allChildren.get(i); |
52 | 54 |
// partitions |
53 |
if(element instanceof Partition) {
|
|
55 |
if (element instanceof Partition) {
|
|
54 | 56 |
partitions.add(element); |
55 | 57 |
} |
56 | 58 |
// corpus |
57 |
else if(element instanceof CQPCorpus) {
|
|
59 |
else if (element instanceof CQPCorpus) {
|
|
58 | 60 |
subcorporas.add(element); |
59 | 61 |
} |
60 | 62 |
// results |
61 |
else if (((TXMResult)element).isVisible()) { |
|
63 |
else if (((TXMResult) element).isVisible()) {
|
|
62 | 64 |
resultsChildren.add(element); |
63 | 65 |
} |
64 | 66 |
// hidden results |
65 |
else if(TBXPreferences.getInstance().getBoolean(TBXPreferences.SHOW_ALL_RESULT_NODES)) {
|
|
67 |
else if (TBXPreferences.getInstance().getBoolean(TBXPreferences.SHOW_ALL_RESULT_NODES)) {
|
|
66 | 68 |
hiddentResultsChildren.add(element); |
67 | 69 |
} |
68 |
|
|
70 |
|
|
69 | 71 |
} |
70 | 72 |
|
71 | 73 |
Collections.sort(partitions); |
... | ... | |
78 | 80 |
|
79 | 81 |
return children.toArray(); |
80 | 82 |
} |
81 |
|
|
83 |
|
|
82 | 84 |
@Override |
83 | 85 |
public ImageDescriptor getImageDescriptor(Object object) { |
86 |
// if (object instanceof MainCorpus |
|
87 |
// && !((MainCorpus) object).hasBeenComputed()) { // not working because of actual management of the CorpusManager (all Corpus are loaded and there is not 'not ready state') |
|
88 |
// return AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, IImageKeys.CORPUS_BROKEN); |
|
89 |
// } |
|
90 |
// else { |
|
84 | 91 |
return AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, IImageKeys.CORPUS); |
92 |
// } |
|
85 | 93 |
} |
86 | 94 |
}; |
87 | 95 |
} |
88 | 96 |
return null; |
89 | 97 |
} |
90 |
|
|
91 |
|
|
92 | 98 |
|
93 | 99 |
|
100 |
|
|
101 |
|
|
94 | 102 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/IImageKeys.java (revision 2997) | ||
---|---|---|
106 | 106 |
/** The Constant CORPUS. */ |
107 | 107 |
public static final String CORPUS = "icons/objects/corpus.png"; //$NON-NLS-1$ |
108 | 108 |
|
109 |
/** The Constant of CORPUS_BROKEN. */ |
|
110 |
public static final String CORPUS_BROKEN = "icons/objects/corpus_broken.png"; //$NON-NLS-1$ |
|
111 |
|
|
109 | 112 |
/** The Constant EDITION. */ |
110 | 113 |
public static final String EDITION = "icons/objects/edition.png"; //$NON-NLS-1$ |
111 | 114 |
|
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/imports/ImportModuleCustomization.java (revision 2997) | ||
---|---|---|
62 | 62 |
params.put(QUERIES, true); |
63 | 63 |
params.put(UI, true); |
64 | 64 |
params.put(TEXTUALPLANS, false); |
65 |
params.put(OPTIONS, false);
|
|
65 |
params.put(OPTIONS, true);
|
|
66 | 66 |
allParams.put("discoursLoader.groovy", params); //$NON-NLS-1$ |
67 | 67 |
names.put("discoursLoader.groovy", "CNR + CSV"); //$NON-NLS-1$ //$NON-NLS-2$ |
68 | 68 |
|
... | ... | |
81 | 81 |
params.put(QUERIES, true); |
82 | 82 |
params.put(UI, true); |
83 | 83 |
params.put(TEXTUALPLANS, false); |
84 |
params.put(OPTIONS, false);
|
|
84 |
params.put(OPTIONS, true);
|
|
85 | 85 |
allParams.put("cqpLoader.groovy", params); //$NON-NLS-1$ |
86 | 86 |
names.put("cqpLoader.groovy", "CQP"); //$NON-NLS-1$ //$NON-NLS-2$ |
87 | 87 |
|
... | ... | |
100 | 100 |
params.put(QUERIES, true); |
101 | 101 |
params.put(UI, false); |
102 | 102 |
params.put(TEXTUALPLANS, false); |
103 |
params.put(OPTIONS, false);
|
|
103 |
params.put(OPTIONS, true);
|
|
104 | 104 |
allParams.put("hyperbaseLoader.groovy", params); //$NON-NLS-1$ |
105 | 105 |
names.put("hyperbaseLoader.groovy", "Hyperbase"); //$NON-NLS-1$ //$NON-NLS-2$ |
106 | 106 |
|
... | ... | |
119 | 119 |
params.put(QUERIES, true); |
120 | 120 |
params.put(UI, false); |
121 | 121 |
params.put(TEXTUALPLANS, false); |
122 |
params.put(OPTIONS, false);
|
|
122 |
params.put(OPTIONS, true);
|
|
123 | 123 |
allParams.put("alcesteLoader.groovy", params); //$NON-NLS-1$ |
124 | 124 |
names.put("alcesteLoader.groovy", "Alceste"); //$NON-NLS-1$ //$NON-NLS-2$ |
125 | 125 |
|
... | ... | |
138 | 138 |
params.put(QUERIES, true); |
139 | 139 |
params.put(UI, false); |
140 | 140 |
params.put(TEXTUALPLANS, false); |
141 |
params.put(OPTIONS, false);
|
|
141 |
params.put(OPTIONS, true);
|
|
142 | 142 |
allParams.put("txtLoader.groovy", params); //$NON-NLS-1$ |
143 | 143 |
names.put("txtLoader.groovy", "TXT + CSV"); //$NON-NLS-1$ //$NON-NLS-2$ |
144 | 144 |
|
... | ... | |
176 | 176 |
params.put(QUERIES, true); |
177 | 177 |
params.put(UI, true); |
178 | 178 |
params.put(TEXTUALPLANS, false); |
179 |
params.put(OPTIONS, false);
|
|
179 |
params.put(OPTIONS, true);
|
|
180 | 180 |
allParams.put("tmxLoader.groovy", params); //$NON-NLS-1$ |
181 | 181 |
names.put("tmxLoader.groovy", "XML-TMX"); //$NON-NLS-1$ //$NON-NLS-2$ |
182 | 182 |
|
... | ... | |
195 | 195 |
params.put(QUERIES, true); |
196 | 196 |
params.put(UI, true); |
197 | 197 |
params.put(TEXTUALPLANS, false); |
198 |
params.put(OPTIONS, false);
|
|
198 |
params.put(OPTIONS, true);
|
|
199 | 199 |
allParams.put("xmlLoader.groovy", params); //$NON-NLS-1$ |
200 | 200 |
names.put("xmlLoader.groovy", "XML/w + CSV"); //$NON-NLS-1$ //$NON-NLS-2$ |
201 | 201 |
|
... | ... | |
214 | 214 |
params.put(QUERIES, true); |
215 | 215 |
params.put(UI, true); |
216 | 216 |
params.put(TEXTUALPLANS, false); |
217 |
params.put(OPTIONS, false);
|
|
217 |
params.put(OPTIONS, true);
|
|
218 | 218 |
allParams.put("xmltxmLoader.groovy", params); //$NON-NLS-1$ |
219 | 219 |
names.put("xmltxmLoader.groovy", "XML-TEI TXM"); //$NON-NLS-1$ //$NON-NLS-2$ |
220 | 220 |
|
... | ... | |
233 | 233 |
params.put(QUERIES, true); |
234 | 234 |
params.put(UI, true); |
235 | 235 |
params.put(TEXTUALPLANS, false); |
236 |
params.put(OPTIONS, false);
|
|
236 |
params.put(OPTIONS, true);
|
|
237 | 237 |
allParams.put("factivaLoader.groovy", params); //$NON-NLS-1$ |
238 | 238 |
names.put("factivaLoader.groovy", "XML-PPS"); //$NON-NLS-1$ //$NON-NLS-2$ |
239 | 239 |
|
... | ... | |
252 | 252 |
params.put(QUERIES, true); |
253 | 253 |
params.put(UI, true); |
254 | 254 |
params.put(TEXTUALPLANS, false); |
255 |
params.put(OPTIONS, false);
|
|
255 |
params.put(OPTIONS, true);
|
|
256 | 256 |
allParams.put("factivamailLoader.groovy", params); //$NON-NLS-1$ |
257 | 257 |
names.put("factivamailLoader.groovy", "Factiva TXT"); //$NON-NLS-1$ //$NON-NLS-2$ |
258 | 258 |
|
... | ... | |
271 | 271 |
params.put(QUERIES, true); |
272 | 272 |
params.put(UI, true); |
273 | 273 |
params.put(TEXTUALPLANS, false); |
274 |
params.put(OPTIONS, false);
|
|
274 |
params.put(OPTIONS, true);
|
|
275 | 275 |
allParams.put("bfmLoader.groovy", params); //$NON-NLS-1$ |
276 | 276 |
names.put("bfmLoader.groovy", "XML-TEI BFM"); //$NON-NLS-1$ //$NON-NLS-2$ |
277 | 277 |
|
... | ... | |
290 | 290 |
params.put(QUERIES, true); |
291 | 291 |
params.put(UI, true); |
292 | 292 |
params.put(TEXTUALPLANS, false); |
293 |
params.put(OPTIONS, false);
|
|
293 |
params.put(OPTIONS, true);
|
|
294 | 294 |
allParams.put("frantextLoader.groovy", params); //$NON-NLS-1$ |
295 | 295 |
names.put("frantextLoader.groovy", "XML-TEI Frantext"); //$NON-NLS-1$ //$NON-NLS-2$ |
296 | 296 |
|
... | ... | |
339 | 339 |
params.put(QUERIES, true); |
340 | 340 |
params.put(UI, true); |
341 | 341 |
params.put(TEXTUALPLANS, false); |
342 |
params.put(OPTIONS, false);
|
|
342 |
params.put(OPTIONS, true);
|
|
343 | 343 |
return params; |
344 | 344 |
} |
345 | 345 |
} |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CorpusManager.java (revision 2997) | ||
---|---|---|
60 | 60 |
* @author Jean-Philippe Magué |
61 | 61 |
*/ |
62 | 62 |
public class CorpusManager { |
63 |
|
|
63 |
|
|
64 | 64 |
/** The cqi client. */ |
65 | 65 |
private static AbstractCqiClient cqiClient; |
66 |
|
|
66 |
|
|
67 | 67 |
/** The singleton. */ |
68 | 68 |
private static CorpusManager corpusManager = null; |
69 |
|
|
69 |
|
|
70 | 70 |
/** the corpora. */ |
71 | 71 |
private static HashMap<String, MainCorpus> corpora = null; |
72 |
|
|
72 |
|
|
73 | 73 |
/** |
74 | 74 |
* Instantiates a new corpus manager. |
75 | 75 |
*/ |
76 |
private CorpusManager() {
|
|
77 |
corpora = new HashMap<String, MainCorpus>();
|
|
76 |
private CorpusManager() { |
|
77 |
corpora = new HashMap<>(); |
|
78 | 78 |
} |
79 |
|
|
79 |
|
|
80 | 80 |
/** |
81 | 81 |
* Sets the cqi client. |
82 | 82 |
* |
... | ... | |
86 | 86 |
public static void setCqiClient(AbstractCqiClient cqiClient) { |
87 | 87 |
CorpusManager.cqiClient = cqiClient; |
88 | 88 |
} |
89 |
|
|
89 |
|
|
90 | 90 |
/** |
91 | 91 |
* Gets the corpus manager. |
92 | 92 |
* |
93 | 93 |
* @return the corpus manager |
94 | 94 |
*/ |
95 | 95 |
public static CorpusManager getCorpusManager() { |
96 |
// if (cqiClient == null)
|
|
97 |
// throw new RuntimeException(TXMCoreMessages.cQiClientNotInitialized);
|
|
96 |
// if (cqiClient == null)
|
|
97 |
// throw new RuntimeException(TXMCoreMessages.cQiClientNotInitialized);
|
|
98 | 98 |
if (corpusManager == null) |
99 | 99 |
corpusManager = new CorpusManager(); |
100 | 100 |
return corpusManager; |
101 | 101 |
} |
102 |
|
|
102 |
|
|
103 | 103 |
/** |
104 | 104 |
* Clean. |
105 | 105 |
*/ |
... | ... | |
108 | 108 |
corpora = null; |
109 | 109 |
corpusManager = null; |
110 | 110 |
} |
111 |
|
|
111 |
|
|
112 | 112 |
/** |
113 | 113 |
* Clean corpora : empty the 'corpora' member. |
114 | 114 |
*/ |
115 | 115 |
public static void cleanCorpora() { |
116 |
corpora = new HashMap<String, MainCorpus>();
|
|
116 |
corpora = new HashMap<>(); |
|
117 | 117 |
} |
118 |
|
|
118 |
|
|
119 | 119 |
/** |
120 | 120 |
* Gets a corpus. |
121 | 121 |
* |
... | ... | |
124 | 124 |
* @throws CqiClientException the cqi client exception |
125 | 125 |
* @throws InvalidCqpIdException the invalid cqp id exception |
126 | 126 |
*/ |
127 |
public MainCorpus getCorpus(String corpusName) throws CqiClientException, |
|
128 |
InvalidCqpIdException { |
|
127 |
public MainCorpus getCorpus(String corpusName) throws CqiClientException, InvalidCqpIdException {
|
|
128 |
|
|
129 | 129 |
if (corpora == null) { |
130 | 130 |
// System.out.println("error corpora is null "); |
131 | 131 |
this.getCorpora(); |
132 | 132 |
} |
133 |
|
|
133 |
|
|
134 | 134 |
for (MainCorpus corpus : CorpusManager.corpora.values()) { |
135 | 135 |
if (corpus.getID().equals(corpusName)) { |
136 | 136 |
// System.out.println("found corpus "+corpusName); |
137 | 137 |
return corpus; |
138 | 138 |
} |
139 | 139 |
} |
140 |
//System.out.println("create corpus "+corpusName); |
|
140 |
// System.out.println("create corpus "+corpusName);
|
|
141 | 141 |
for (Project p : Toolbox.workspace.getProjects()) { |
142 | 142 |
CorpusBuild c = p.getCorpusBuild(corpusName); |
143 | 143 |
if (c != null && c instanceof MainCorpus) { |
... | ... | |
146 | 146 |
} |
147 | 147 |
return null; |
148 | 148 |
} |
149 |
|
|
149 |
|
|
150 | 150 |
/** |
151 | 151 |
* Checks for corpus. |
152 | 152 |
* |
... | ... | |
161 | 161 |
return true; |
162 | 162 |
return false; |
163 | 163 |
} |
164 |
|
|
164 |
|
|
165 | 165 |
/** |
166 | 166 |
* Gets a list of the corpora managed by CQP. |
167 | 167 |
* |
... | ... | |
171 | 171 |
* the cqi client exception |
172 | 172 |
*/ |
173 | 173 |
public HashMap<String, MainCorpus> getCorpora() { |
174 |
// //System.out.println("get corpora");
|
|
175 |
// if (corpora != null)
|
|
176 |
// return corpora;
|
|
177 |
// |
|
178 |
// String[] corporaName;
|
|
179 |
// try {
|
|
180 |
// corporaName = cqiClient.listCorpora();
|
|
181 |
// } catch (Exception e) {
|
|
182 |
// throw new CqiClientException(e);
|
|
183 |
// }
|
|
184 |
// |
|
185 |
// corpora = new ArrayList<MainCorpus>(corporaName.length);
|
|
186 |
// for (int i = 0; i < corporaName.length; i++) {
|
|
187 |
// try {
|
|
188 |
// MainCorpus c = this.getCorpus(corporaName[i]);
|
|
189 |
// if (c != null) corpora.add(c);
|
|
190 |
// } catch (InvalidCqpIdException e) {
|
|
191 |
// throw new CqiClientException(TXMCoreMessages.errorColonThisExceptionShouldNotBeThrown, e);
|
|
192 |
// }
|
|
193 |
// }
|
|
194 |
//
|
|
195 |
// for (CQPCorpus corpus : corpora) {
|
|
196 |
// try {
|
|
197 |
// corpus.setCharset(cqiClient.corpusCharset(corpus.getCqpId()));
|
|
198 |
// // TODO : implements cqiClient.corpusLanguage
|
|
199 |
// // corpus.setLanguage(cqiClient.corpusLanguage(corpus.getCqpId()));
|
|
200 |
// } catch (Exception e) {
|
|
201 |
// org.txm.utils.logger.Log.printStackTrace(e);
|
|
202 |
// }
|
|
203 |
// }
|
|
204 |
// // System.out.println("END creating corpora");
|
|
174 |
// //System.out.println("get corpora");
|
|
175 |
// if (corpora != null)
|
|
176 |
// return corpora;
|
|
177 |
//
|
|
178 |
// String[] corporaName;
|
|
179 |
// try {
|
|
180 |
// corporaName = cqiClient.listCorpora();
|
|
181 |
// } catch (Exception e) {
|
|
182 |
// throw new CqiClientException(e);
|
|
183 |
// }
|
|
184 |
//
|
|
185 |
// corpora = new ArrayList<MainCorpus>(corporaName.length);
|
|
186 |
// for (int i = 0; i < corporaName.length; i++) {
|
|
187 |
// try {
|
|
188 |
// MainCorpus c = this.getCorpus(corporaName[i]);
|
|
189 |
// if (c != null) corpora.add(c);
|
|
190 |
// } catch (InvalidCqpIdException e) {
|
|
191 |
// throw new CqiClientException(TXMCoreMessages.errorColonThisExceptionShouldNotBeThrown, e);
|
|
192 |
// }
|
|
193 |
// }
|
|
194 |
//
|
|
195 |
// for (CQPCorpus corpus : corpora) {
|
|
196 |
// try {
|
|
197 |
// corpus.setCharset(cqiClient.corpusCharset(corpus.getCqpId()));
|
|
198 |
// // TODO : implements cqiClient.corpusLanguage
|
|
199 |
// // corpus.setLanguage(cqiClient.corpusLanguage(corpus.getCqpId()));
|
|
200 |
// } catch (Exception e) {
|
|
201 |
// org.txm.utils.logger.Log.printStackTrace(e);
|
|
202 |
// }
|
|
203 |
// }
|
|
204 |
// // System.out.println("END creating corpora");
|
|
205 | 205 |
return corpora; |
206 | 206 |
} |
207 |
|
|
207 |
|
|
208 | 208 |
/** |
209 | 209 |
* Gets the cqi client. |
210 | 210 |
* |
... | ... | |
213 | 213 |
public AbstractCqiClient getCqiClient() { |
214 | 214 |
return cqiClient; |
215 | 215 |
} |
216 |
|
|
216 |
|
|
217 | 217 |
/** |
218 | 218 |
* Delete corpus. |
219 | 219 |
* |
... | ... | |
225 | 225 |
if (CQPSearchEngine.isInitialized()) { |
226 | 226 |
try { |
227 | 227 |
CQPSearchEngine.getCqiClient().dropCorpus(corpus.getID()); |
228 |
} catch (Exception e) { |
|
229 |
Log.warning("Warning while removing corpus: Failed to drop corpus "+corpus); |
|
228 |
} |
|
229 |
catch (Exception e) { |
|
230 |
Log.warning("Warning while removing corpus: Failed to drop corpus " + corpus); |
|
230 | 231 |
Log.printStackTrace(e); |
231 | 232 |
} |
232 | 233 |
} |
233 | 234 |
} |
234 |
|
|
235 |
|
|
235 | 236 |
public boolean hasCorpus(MainCorpus mainCorpus) { |
236 | 237 |
if (corpora != null) { |
237 | 238 |
return corpora.containsKey(mainCorpus.getID()); |
... | ... | |
244 | 245 |
corpora.put(mainCorpus.getID(), mainCorpus); |
245 | 246 |
} |
246 | 247 |
} |
247 |
} |
|
248 |
} |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/MainCorpus.java (revision 2997) | ||
---|---|---|
183 | 183 |
} |
184 | 184 |
|
185 | 185 |
Log.fine(NLS.bind("Call CQI: load_a_system_corpus with {0} and {1}", this.registryFile.getParent(), this.pID)); |
186 |
CQPSearchEngine.getCqiClient().load_a_system_corpus(this.registryFile.getParent(), this.pID); |
|
186 |
if (!CQPSearchEngine.getCqiClient().load_a_system_corpus(this.registryFile.getParent(), this.pID)) { |
|
187 |
Log.warning(TXMCoreMessages.bind("Error: CQI.load_a_system_corpus failed with id={0} and registry={1}", this.getID(), this.registryFile)); |
|
188 |
return false; |
|
189 |
} |
|
187 | 190 |
|
188 | 191 |
List<String> tmp = Arrays.asList(CQPSearchEngine.getCqiClient().listCorpora()); |
189 | 192 |
if (tmp.contains(this.pID)) { |
Formats disponibles : Unified diff