Révision 1076
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Partition.java (revision 1076) | ||
---|---|---|
168 | 168 |
pName = "no_name"; |
169 | 169 |
} |
170 | 170 |
|
171 |
|
|
171 | 172 |
if (name == null || name.trim().length() == 0) { |
172 | 173 |
this.name = pName; |
173 | 174 |
} |
174 |
|
|
175 |
// FIXME: test to fix partition creation error |
|
176 |
// this.name = pName; |
|
177 |
|
|
178 |
|
|
175 | 179 |
Log.info(NLS.bind(TXMCoreMessages.info_creatingNewPartition, this.getParent(), this.name)); |
176 | 180 |
long start = System.currentTimeMillis(); |
177 | 181 |
for (int i = 0; i < pQueries.size(); i++) { |
178 | 182 |
String queryS = pQueries.get(i); |
179 |
String partitionName = this.getName(); |
|
180 | 183 |
|
181 | 184 |
String partName = String.valueOf(i); |
182 | 185 |
if(pPartNames != null && i < pPartNames.size()) { |
... | ... | |
186 | 189 |
partName = "-"; //$NON-NLS-1$ |
187 | 190 |
} |
188 | 191 |
|
189 |
Part part = createPart(partitionName, partName, queryS); // lazy
|
|
192 |
Part part = this.createPart(this.getName(), partName, queryS); // lazy
|
|
190 | 193 |
} |
191 | 194 |
long end = System.currentTimeMillis(); |
192 | 195 |
Log.info(NLS.bind(TXMCoreMessages.info_partitionCreatedInXMs, this.name, (end - start))); |
... | ... | |
239 | 242 |
public int compare(String arg0, String arg1) { |
240 | 243 |
int i0 = Integer.parseInt(arg0); |
241 | 244 |
int i1 = Integer.parseInt(arg1); |
242 |
return i0-i1;
|
|
245 |
return i0 - i1;
|
|
243 | 246 |
} |
244 | 247 |
}); |
245 | 248 |
} else if (type.equals("Date")) { //$NON-NLS-1$ |
... | ... | |
301 | 304 |
*/ |
302 | 305 |
@Override |
303 | 306 |
protected boolean _load() { |
304 |
if (this.getUUID().length() > 0) return true; // partition already persisted |
|
307 |
|
|
308 |
// partition already persisted |
|
309 |
if (this.getUUID().length() > 0) { |
|
310 |
return true; |
|
311 |
} |
|
305 | 312 |
|
306 |
if (this.hasBeenComputedOnce) return true; // partition already computed |
|
313 |
// partition already computed |
|
314 |
if (this.hasBeenComputedOnce) { |
|
315 |
return true; |
|
316 |
} |
|
307 | 317 |
|
308 | 318 |
if (this.getSelfElement() != null && this.getParent() != null) { |
309 | 319 |
NodeList partList = getSelfElement().getChildNodes(); |
310 | 320 |
for (int i = 0; i < partList.getLength(); i++) { |
311 | 321 |
if (partList.item(i).getNodeType() == 1) { |
312 | 322 |
Element c = (Element) partList.item(i); |
313 |
if (c.getNodeName().equals("part")) //$NON-NLS-1$ |
|
314 |
{ |
|
323 |
if (c.getNodeName().equals("part")) { //$NON-NLS-1$ |
|
315 | 324 |
String pname = c.getAttribute("name"); //$NON-NLS-1$ |
316 | 325 |
String pshortname = c.getAttribute("shortname"); //$NON-NLS-1$ |
317 | 326 |
String pquery = c.getAttribute("query"); //$NON-NLS-1$ |
318 |
for (Part part : getParts()) |
|
327 |
for (Part part : getParts()) {
|
|
319 | 328 |
if (part.getName().equals(pname)) { |
320 | 329 |
part.setName(pname); |
321 | 330 |
part.setShortName(pshortname); |
322 | 331 |
part.setQuery(pquery); |
323 | 332 |
} |
333 |
} |
|
324 | 334 |
} |
325 | 335 |
} |
326 | 336 |
} |
... | ... | |
374 | 384 |
public Part createPart(String partitionName, String partName, String query) throws CqiClientException { |
375 | 385 |
Part part; |
376 | 386 |
String partCqpId = CqpObject.partNamePrefix + Corpus.getNextSubcorpusCounter(); |
377 |
Log.finest(NLS.bind(TXMCoreMessages.CREATING_PART,partName, query)); |
|
387 |
Log.finest(NLS.bind(TXMCoreMessages.CREATING_PART, partName, query));
|
|
378 | 388 |
long start = System.currentTimeMillis(); |
379 | 389 |
try { |
380 | 390 |
CorpusManager.getCorpusManager().getCqiClient().cqpQuery(this.getParent().getQualifiedCqpId(), partCqpId, query); |
... | ... | |
387 | 397 |
try { |
388 | 398 |
throw new CqiClientException(TXMCoreMessages.Partition_9 + partitionName + "_" + partName + e + " last error: " + CQPSearchEngine.getCqiClient().getLastCQPError()); //$NON-NLS-1$ //$NON-NLS-2$ |
389 | 399 |
} catch (Exception e1) { |
390 |
System.out.println(TXMCoreMessages.Partition_18+e1);
|
|
400 |
Log.severe(TXMCoreMessages.Partition_18 + e1);
|
|
391 | 401 |
org.txm.utils.logger.Log.printStackTrace(e1); |
392 | 402 |
return null; |
393 | 403 |
} |
... | ... | |
733 | 743 |
try { |
734 | 744 |
tmp = this.getStringParameterValue(TBXPreferences.STRUCTURAL_UNIT_PROPERTY); |
735 | 745 |
if (!tmp.isEmpty()) { |
736 |
this.pProperty = StructuralUnitProperty.stringToStructuralUnitProperty(getParent(), tmp); |
|
746 |
this.pProperty = StructuralUnitProperty.stringToStructuralUnitProperty(this.getParent(), tmp);
|
|
737 | 747 |
} |
738 | 748 |
} |
739 | 749 |
catch (CqiClientException e) { |
... | ... | |
748 | 758 |
this.pPartNames = null; |
749 | 759 |
} |
750 | 760 |
|
751 |
tmp = this.getStringParameterValue(CQPPreferences.QUERIES);
|
|
761 |
tmp = this.getStringParameterValue(TXMPreferences.QUERIES);
|
|
752 | 762 |
if (tmp != null) { |
753 | 763 |
this.pQueries = Arrays.asList(tmp.split("\t")); |
754 | 764 |
} else { |
755 | 765 |
this.pQueries = null; |
756 | 766 |
} |
757 | 767 |
|
758 |
tmp = this.getStringParameterValue(CQPPreferences.VALUES);
|
|
768 |
tmp = this.getStringParameterValue(TXMPreferences.VALUES);
|
|
759 | 769 |
if (tmp != null) { |
760 | 770 |
this.pValues = Arrays.asList(tmp.split("\t")); |
761 | 771 |
} else { |
tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/CreatePartition.java (revision 1076) | ||
---|---|---|
46 | 46 |
import org.txm.rcp.views.corpora.CorporaView; |
47 | 47 |
import org.txm.searchengine.cqp.corpus.Corpus; |
48 | 48 |
import org.txm.searchengine.cqp.corpus.Partition; |
49 |
import org.txm.utils.logger.Log; |
|
49 | 50 |
|
50 |
// TODO: Auto-generated Javadoc |
|
51 | 51 |
/** |
52 |
* Command which creates a Partition from a Corpus @ author mdecorde. |
|
52 |
* Command which creates a Partition from a Corpus. |
|
53 |
* |
|
54 |
* @author mdecorde |
|
53 | 55 |
*/ |
54 | 56 |
public class CreatePartition extends AbstractHandler { |
55 | 57 |
|
... | ... | |
71 | 73 |
selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
72 | 74 |
|
73 | 75 |
final Corpus corpus = (Corpus) selection.getFirstElement(); |
74 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event) |
|
75 |
.getShell(); |
|
76 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(); |
|
76 | 77 |
final CreatePartitionDialog d = new CreatePartitionDialog(shell, corpus); |
77 | 78 |
int code = d.open(); |
78 | 79 |
if (code == Window.OK) { |
79 | 80 |
try { |
80 |
JobHandler jobhandler = new JobHandler(NLS.bind( |
|
81 |
TXMUIMessages.CreatePartition_0, corpus.getName())) { |
|
81 |
JobHandler jobhandler = new JobHandler(NLS.bind(TXMUIMessages.CreatePartition_0, corpus.getName())) { |
|
82 | 82 |
@Override |
83 | 83 |
protected IStatus run(IProgressMonitor monitor) { |
84 | 84 |
this.runInit(monitor); |
85 | 85 |
try { |
86 | 86 |
JobsTimer.start(); |
87 |
monitor.beginTask( |
|
88 |
NLS.bind(TXMUIMessages.CreatePartition_0, |
|
89 |
corpus.getName()), 100); |
|
90 |
System.out.println(NLS.bind( |
|
91 |
TXMUIMessages.CreatePartition_0, |
|
92 |
corpus.getName())); |
|
87 |
monitor.beginTask(NLS.bind(TXMUIMessages.CreatePartition_0, corpus.getName()), 100); |
|
88 |
|
|
89 |
Log.info(NLS.bind(TXMUIMessages.CreatePartition_0, corpus.getName())); |
|
90 |
|
|
93 | 91 |
final Partition partition = d.getPartition(); |
94 | 92 |
if (partition == null) { |
95 | 93 |
monitor.done(); |
96 |
System.out.println(TXMUIMessages.CreatePartition_2);
|
|
94 |
Log.severe(TXMUIMessages.CreatePartition_2);
|
|
97 | 95 |
return Status.CANCEL_STATUS; |
98 | 96 |
} |
99 |
System.out.println(NLS.bind( |
|
100 |
TXMUIMessages.CreatePartition_6, |
|
101 |
partition.getNPart())); |
|
102 | 97 |
monitor.worked(95); |
103 | 98 |
|
99 |
Log.info(NLS.bind(TXMUIMessages.CreatePartition_6, partition.getNPart())); |
|
100 |
|
|
101 |
|
|
104 | 102 |
monitor.subTask(TXMUIMessages.RefreshingCorporaView); |
105 | 103 |
syncExec(new Runnable() { |
106 | 104 |
@Override |
... | ... | |
110 | 108 |
} |
111 | 109 |
}); |
112 | 110 |
monitor.worked(100); |
113 |
} catch (ThreadDeath td) { |
|
111 |
} |
|
112 |
catch (ThreadDeath td) { |
|
114 | 113 |
return Status.CANCEL_STATUS; |
115 |
} finally { |
|
114 |
} |
|
115 |
finally { |
|
116 | 116 |
monitor.done(); |
117 | 117 |
JobsTimer.stopAndPrint(); |
118 | 118 |
} |
... | ... | |
122 | 122 |
jobhandler.startJob(); |
123 | 123 |
|
124 | 124 |
} catch (Exception e) { |
125 |
System.err.println(NLS.bind(TXMUIMessages.Error_creating_partition, |
|
126 |
e)); |
|
125 |
Log.severe(NLS.bind(TXMUIMessages.Error_creating_partition, e)); |
|
127 | 126 |
} |
128 | 127 |
} |
129 | 128 |
return null; |
Formats disponibles : Unified diff