Révision 526
tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java (revision 526) | ||
---|---|---|
173 | 173 |
* @return |
174 | 174 |
*/ |
175 | 175 |
//FIXME: does not work, need to test furthermore |
176 |
// public static Object get(TXMCommandParameters commandParameters, TXMResult result, String nodeQualifier, String key) {
|
|
176 |
// public static Object get(TXMResultParameters commandParameters, TXMResult result, String nodeQualifier, String key) {
|
|
177 | 177 |
// |
178 | 178 |
// |
179 | 179 |
// if(commandParameters != null && commandParameters.get(key) != null) { |
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 526) | ||
---|---|---|
4 | 4 |
package org.txm.core.results; |
5 | 5 |
|
6 | 6 |
import java.io.File; |
7 |
import java.io.IOException; |
|
7 | 8 |
import java.text.DateFormat; |
8 | 9 |
import java.text.SimpleDateFormat; |
9 | 10 |
import java.util.ArrayList; |
10 | 11 |
import java.util.Date; |
11 | 12 |
import java.util.UUID; |
13 |
import java.util.concurrent.Semaphore; |
|
12 | 14 |
|
15 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
13 | 16 |
import org.osgi.framework.FrameworkUtil; |
14 | 17 |
import org.osgi.service.prefs.BackingStoreException; |
15 | 18 |
import org.txm.core.preferences.TXMPreferences; |
19 |
import org.txm.utils.logger.Log; |
|
16 | 20 |
|
17 | 21 |
/** |
18 | 22 |
* Root class of all TXM results. |
... | ... | |
24 | 28 |
* |
25 | 29 |
*/ |
26 | 30 |
//FIXME: At this moment, an empty list is created for children, to not return null when calling getChildren(), see if that's what we want |
27 |
public abstract class TXMResult implements Cloneable { |
|
31 |
public abstract class TXMResult implements Cloneable, IProgressMonitor {
|
|
28 | 32 |
|
29 | 33 |
/** |
30 | 34 |
* Unique ID of the object built with : class + date + number |
... | ... | |
73 | 77 |
protected String preferencesNodeQualifier; |
74 | 78 |
|
75 | 79 |
/** |
76 |
* Creates a new TXMResult with no parent. |
|
77 |
*/ |
|
78 |
public TXMResult() { |
|
79 |
this(null); |
|
80 |
} |
|
81 |
|
|
82 |
/** |
|
83 | 80 |
* Creates a new TXMResult, child of the specified parent. |
84 | 81 |
* @param parent |
85 | 82 |
*/ |
... | ... | |
118 | 115 |
this.preferencesNodeQualifier = FrameworkUtil.getBundle(getClass()).getSymbolicName(); |
119 | 116 |
this.parameters = parameters; |
120 | 117 |
|
118 |
this.constructorCalled = true; // if not set the compute method will always return false |
|
121 | 119 |
//FIXME: Debug |
122 | 120 |
//System.out.println("TXMResult.TXMResult(): default preferences node qualifier = " + this.preferencesNodeQualifier + ", class = " + getClass()); |
123 | 121 |
} |
... | ... | |
189 | 187 |
return TXMPreferences.getString(key, this.parameters, this, this.preferencesNodeQualifier); |
190 | 188 |
} |
191 | 189 |
|
192 |
public void saveParameters() { |
|
193 |
TXMPreferences.putLocalParameters(this, this.parameters); |
|
190 |
/** |
|
191 |
* Read the parameter stored in the Java class membres : the pXXXXX named members |
|
192 |
* |
|
193 |
* Commands must define this method to persist their parameters |
|
194 |
* |
|
195 |
* just return 'true' if you don't want to bother with this |
|
196 |
* @return |
|
197 |
*/ |
|
198 |
public boolean saveParameters() { |
|
199 |
return true; // true means the compute method will not fail |
|
194 | 200 |
} |
195 | 201 |
|
196 | 202 |
/** |
... | ... | |
601 | 607 |
public String getSimpleDetails() { |
602 | 608 |
return this.getDetails().replace("\n", " "); |
603 | 609 |
} |
610 |
|
|
611 |
/** |
|
612 |
* if set, allows the command to notify its progress |
|
613 |
*/ |
|
614 |
protected IProgressMonitor monitor; |
|
615 |
|
|
616 |
Semaphore progressSemaphore = new Semaphore(1); |
|
617 |
/** |
|
618 |
* This variable ensure the TXMResult class constructor has been called |
|
619 |
*/ |
|
620 |
private boolean constructorCalled; |
|
621 |
|
|
622 |
public void acquireSemaphore() { |
|
623 |
try { |
|
624 |
this.progressSemaphore.acquire(); |
|
625 |
} catch (InterruptedException e) { |
|
626 |
Log.printStackTrace(e); |
|
627 |
} |
|
628 |
} |
|
629 |
|
|
630 |
/** |
|
631 |
* Computes the result according to specified command parameters. |
|
632 |
* |
|
633 |
* @param parameters |
|
634 |
* @return |
|
635 |
*/ |
|
636 |
public boolean compute() throws Exception { |
|
637 |
return this.compute(null); |
|
638 |
} |
|
639 |
|
|
640 |
/** |
|
641 |
* Computes the result according to stored command parameters. |
|
642 |
* |
|
643 |
* @param watcher |
|
644 |
* @return |
|
645 |
* @throws Exception |
|
646 |
* @throws InvalidCqpIdException |
|
647 |
* @throws CqiServerError |
|
648 |
* @throws CqiClientException |
|
649 |
* @throws IOException |
|
650 |
*/ |
|
651 |
public boolean compute(IProgressMonitor monitor) throws Exception { |
|
652 |
return hasBeenConstructorCalled() && setCurrentMonitor(monitor) && validateParameters() && _compute() && saveParameters(); |
|
653 |
} |
|
654 |
|
|
655 |
private boolean hasBeenConstructorCalled() { |
|
656 |
// TODO Auto-generated method stub |
|
657 |
return constructorCalled; |
|
658 |
} |
|
659 |
|
|
660 |
public abstract boolean _compute() throws Exception; |
|
661 |
|
|
662 |
// //removed for now, waiting to see if used |
|
663 |
// /** |
|
664 |
// * Computes the result according to specified command parameters. |
|
665 |
// * @param watcher |
|
666 |
// * @param parameters |
|
667 |
// * @return |
|
668 |
// */ |
|
669 |
// public boolean compute(IProgressMonitor watcher, TXMParameters parameters) throws Exception { |
|
670 |
// this.parameters = parameters; |
|
671 |
// return this.compute(watcher); |
|
672 |
// } |
|
673 |
|
|
674 |
/** |
|
675 |
* |
|
676 |
* @return the array of extensions to show in the FileDialog SWT widget |
|
677 |
*/ |
|
678 |
@Deprecated |
|
679 |
//FIXME: should be moved in an exporter extension |
|
680 |
public String[] getExportTXTExtensions() { |
|
681 |
return new String[]{"*.csv"}; |
|
682 |
} |
|
683 |
|
|
684 |
/** |
|
685 |
* |
|
686 |
* @return true if the monitor has been canceled by the user |
|
687 |
*/ |
|
688 |
public boolean isCanceled() { |
|
689 |
if (monitor != null) { |
|
690 |
return monitor.isCanceled(); |
|
691 |
} |
|
692 |
return false; |
|
693 |
} |
|
694 |
|
|
695 |
/** |
|
696 |
* |
|
697 |
* @return the parent Object that contains this result |
|
698 |
*/ |
|
699 |
@Deprecated |
|
700 |
// FIXME: to remove when TXMResult2 will be fully implemented |
|
701 |
//public abstract HasResults getHasResultsParent(); |
|
702 |
|
|
703 |
public boolean tryAcquireSemaphore() { |
|
704 |
return this.progressSemaphore.tryAcquire(); |
|
705 |
} |
|
706 |
|
|
707 |
public void releaseSemaphore() { |
|
708 |
this.progressSemaphore.release(); |
|
709 |
} |
|
710 |
|
|
711 |
/** |
|
712 |
* You must set the current monitor to be available to manage the process progress |
|
713 |
* @param monitor can be null |
|
714 |
*/ |
|
715 |
public boolean setCurrentMonitor(IProgressMonitor monitor) { |
|
716 |
if (monitor == null) return false; |
|
717 |
if (monitor.isCanceled()) return false; |
|
718 |
this.monitor = monitor; |
|
719 |
return true; |
|
720 |
} |
|
721 |
|
|
722 |
//public abstract boolean toTxt(File file, String encoding) throws Exception; |
|
723 |
@Deprecated |
|
724 |
//FIXME: should be moved in an exporter extension |
|
725 |
public abstract boolean toTxt(File outfile, String encoding, String colseparator, String txtseparator) throws Exception; |
|
726 |
|
|
727 |
/** |
|
728 |
* increment the process |
|
729 |
* @param amount of work |
|
730 |
*/ |
|
731 |
public void worked(int amount) { |
|
732 |
if (monitor != null) { |
|
733 |
//System.out.println("worked "+amount); |
|
734 |
monitor.worked(amount); |
|
735 |
} |
|
736 |
} |
|
737 |
|
|
738 |
/** |
|
739 |
* increment the progress and show a message |
|
740 |
* |
|
741 |
* @param amount |
|
742 |
* @param message |
|
743 |
*/ |
|
744 |
public void worked(int amount, String message) { |
|
745 |
if (monitor != null) { |
|
746 |
monitor.worked(amount); |
|
747 |
monitor.subTask(message); |
|
748 |
} |
|
749 |
} |
|
750 |
|
|
751 |
@Override |
|
752 |
public void beginTask(String name, int totalWork) { |
|
753 |
if (monitor != null) monitor.beginTask(name, totalWork); |
|
754 |
} |
|
755 |
|
|
756 |
@Override |
|
757 |
public void done() { |
|
758 |
if (monitor != null) monitor.done(); |
|
759 |
} |
|
760 |
|
|
761 |
@Override |
|
762 |
public void internalWorked(double work) { |
|
763 |
if (monitor != null) monitor.internalWorked(work); |
|
764 |
} |
|
765 |
|
|
766 |
@Override |
|
767 |
public void setCanceled(boolean value) { |
|
768 |
if (monitor != null) monitor.setCanceled(value); |
|
769 |
} |
|
770 |
|
|
771 |
@Override |
|
772 |
public void setTaskName(String name) { |
|
773 |
if (monitor != null) monitor.setTaskName(name); |
|
774 |
} |
|
775 |
|
|
776 |
@Override |
|
777 |
public void subTask(String name) { |
|
778 |
if (monitor != null) monitor.subTask(name); |
|
779 |
} |
|
604 | 780 |
} |
tmp/org.txm.core/src/java/org/txm/core/results/TXMParameters.java (revision 526) | ||
---|---|---|
27 | 27 |
while (it.hasNext()) { |
28 | 28 |
Object key = it.next(); |
29 | 29 |
Object value = this.get(key); |
30 |
System.out.println("TXMCommandParameters.dump(): key = " + key + " / value = " + value);
|
|
30 |
System.out.println("TXMResultParameters.dump(): key = " + key + " / value = " + value);
|
|
31 | 31 |
} |
32 | 32 |
} |
33 | 33 |
} |
tmp/org.txm.core/src/java/org/txm/objects/Corpus.java (revision 526) | ||
---|---|---|
996 | 996 |
* @param c the c |
997 | 997 |
*/ |
998 | 998 |
public Corpus(Base base, Element c) { |
999 |
if(base != null && c != null)
|
|
1000 |
{ |
|
999 |
super(base);
|
|
1000 |
if(base != null && c != null) {
|
|
1001 | 1001 |
this.base = base; |
1002 | 1002 |
this.setPath(base.getPath() + getName()); |
1003 | 1003 |
setSelfElement(c); |
tmp/org.txm.core/src/java/org/txm/objects/Page.java (revision 526) | ||
---|---|---|
65 | 65 |
* @param page the page |
66 | 66 |
*/ |
67 | 67 |
public Page(Edition edition, Element page) { |
68 |
super(edition); |
|
68 | 69 |
this.setPath(edition.getPath() + getName()); |
69 | 70 |
setSelfElement(page); |
70 | 71 |
this.edition = edition; |
... | ... | |
170 | 171 |
this.getSelfElement().setAttribute("id", name); //$NON-NLS-1$ |
171 | 172 |
} |
172 | 173 |
|
173 |
/* (non-Javadoc) |
|
174 |
* @see org.txm.objects.TxmObject#getChildren() |
|
175 |
*/ |
|
176 |
public List<TxmObject> getChildren() { |
|
177 |
List<TxmObject> rez = new ArrayList<TxmObject>(); |
|
178 |
return rez; |
|
179 |
} |
|
180 | 174 |
|
181 |
/* (non-Javadoc) |
|
182 |
* @see org.txm.objects.TxmObject#removeChildren(org.txm.objects.TxmObject) |
|
183 |
*/ |
|
184 |
public TxmObject removeChildren(TxmObject o) { |
|
185 |
return null; |
|
186 |
} |
|
187 |
|
|
188 |
/* (non-Javadoc) |
|
189 |
* @see org.txm.objects.TxmObject#hasChildren(org.txm.objects.TxmObject) |
|
190 |
*/ |
|
191 |
public boolean hasChildren(TxmObject o) { |
|
192 |
return false; |
|
193 |
} |
|
194 |
|
|
195 |
/* (non-Javadoc) |
|
196 |
* @see org.txm.objects.TxmObject#getParent() |
|
197 |
*/ |
|
198 | 175 |
@Override |
199 |
public TxmObject getParent() { |
|
200 |
return getEdition(); |
|
201 |
} |
|
202 |
|
|
203 |
@Override |
|
204 | 176 |
public boolean save() { |
205 | 177 |
// TODO Auto-generated method stub |
206 | 178 |
return false; |
... | ... | |
213 | 185 |
public String toString() { |
214 | 186 |
return "Page [name="+name+", htmlfile="+htmlfile +", firstWordId="+firstWordId+"]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
215 | 187 |
} |
216 |
|
|
217 |
@Override |
|
218 |
public String getSimpleName() { |
|
219 |
return getName(); |
|
220 |
} |
|
221 |
|
|
222 |
@Override |
|
223 |
public String getDetails() { |
|
224 |
return getName(); |
|
225 |
} |
|
226 |
|
|
227 |
@Override |
|
228 |
public void clean() { |
|
229 |
// TODO Auto-generated method stub |
|
230 |
|
|
231 |
} |
|
232 |
|
|
233 |
@Override |
|
234 |
public boolean validateParameters() { |
|
235 |
return true; |
|
236 |
} |
|
237 | 188 |
} |
tmp/org.txm.core/src/java/org/txm/objects/Alignement.java (revision 526) | ||
---|---|---|
1 | 1 |
package org.txm.objects; |
2 | 2 |
|
3 |
import java.util.List; |
|
4 | 3 |
|
5 |
import org.txm.core.results.TXMParameters; |
|
6 |
|
|
7 | 4 |
/** |
8 | 5 |
* not used ? |
9 | 6 |
* deprecated ? |
... | ... | |
13 | 10 |
*/ |
14 | 11 |
public class Alignement extends TxmObject { |
15 | 12 |
|
13 |
private static final long serialVersionUID = -8729114900304447071L; |
|
14 |
|
|
16 | 15 |
String from, to , struct; |
17 | 16 |
int level; |
18 | 17 |
|
19 |
public Alignement(String from2, String to2, String struct2, int level2) { |
|
18 |
public Alignement(Base base, String from2, String to2, String struct2, int level2) { |
|
19 |
super(base); |
|
20 | 20 |
from = from2; |
21 | 21 |
to = to2; |
22 | 22 |
struct = struct2; |
23 | 23 |
level= level2; |
24 | 24 |
} |
25 | 25 |
|
26 |
public List<? extends TxmObject> getChildren() { |
|
27 |
// TODO Auto-generated method stub |
|
28 |
return null; |
|
29 |
} |
|
30 |
|
|
31 |
public TxmObject removeChildren(TxmObject children) { |
|
32 |
// TODO Auto-generated method stub |
|
33 |
return null; |
|
34 |
} |
|
35 |
|
|
36 |
public boolean hasChildren(TxmObject children) { |
|
37 |
// TODO Auto-generated method stub |
|
38 |
return false; |
|
39 |
} |
|
40 |
|
|
41 | 26 |
@Override |
42 |
public TxmObject getParent() { |
|
43 |
// TODO Auto-generated method stub |
|
44 |
return null; |
|
45 |
} |
|
46 |
|
|
47 |
@Override |
|
48 | 27 |
public boolean load() { |
49 |
// TODO Auto-generated method stub
|
|
28 |
// TODO should read the members from the Element attributes
|
|
50 | 29 |
return false; |
51 | 30 |
} |
52 | 31 |
|
53 | 32 |
@Override |
54 | 33 |
public boolean save() { |
55 |
// TODO Auto-generated method stub
|
|
34 |
// TODO should write the members to the Element attributes
|
|
56 | 35 |
return false; |
57 | 36 |
} |
58 |
|
|
59 |
@Override |
|
60 |
public String getSimpleName() { |
|
61 |
// TODO Auto-generated method stub |
|
62 |
return null; |
|
63 |
} |
|
64 |
|
|
65 |
@Override |
|
66 |
public String getDetails() { |
|
67 |
// TODO Auto-generated method stub |
|
68 |
return null; |
|
69 |
} |
|
70 |
|
|
71 |
@Override |
|
72 |
public void clean() { |
|
73 |
// TODO Auto-generated method stub |
|
74 |
|
|
75 |
} |
|
76 |
|
|
77 |
@Override |
|
78 |
public boolean validateParameters() { |
|
79 |
// TODO Auto-generated method stub |
|
80 |
return false; |
|
81 |
} |
|
82 |
|
|
83 |
@Override |
|
84 |
public boolean setParameters(TXMParameters parameters) { |
|
85 |
return false; |
|
86 |
} |
|
87 | 37 |
} |
tmp/org.txm.core/src/java/org/txm/objects/Text.java (revision 526) | ||
---|---|---|
73 | 73 |
* @param text the text |
74 | 74 |
*/ |
75 | 75 |
public Text(Corpus corpus, Element text) { |
76 |
super(corpus); |
|
76 | 77 |
this.setPath(corpus.getPath() + getName()); |
77 | 78 |
this.corpus = corpus; |
78 | 79 |
setSelfElement(text); |
tmp/org.txm.core/src/java/org/txm/objects/SavedQuery.java (revision 526) | ||
---|---|---|
74 | 74 |
* @param query the query |
75 | 75 |
* @param examples the examples |
76 | 76 |
*/ |
77 |
public SavedQuery(Corpus c, String query, List<String> examples) { |
|
77 |
public SavedQuery(Corpus c, String query, List<String> examples) { |
|
78 |
super(c); |
|
78 | 79 |
this.corpus = c; |
79 | 80 |
this.value = query; |
80 | 81 |
if (examples == null) |
... | ... | |
89 | 90 |
* @param corpus the b |
90 | 91 |
* @param e the e |
91 | 92 |
*/ |
92 |
public SavedQuery(Corpus corpus, Element e) { |
|
93 |
public SavedQuery(Corpus corpus, Element e) { |
|
94 |
super(corpus); |
|
93 | 95 |
this.corpus = corpus; |
94 | 96 |
this.setSelfElement(e); |
95 | 97 |
this.load(); |
tmp/org.txm.core/src/java/org/txm/objects/Edition.java (revision 526) | ||
---|---|---|
30 | 30 |
import java.io.File; |
31 | 31 |
import java.util.ArrayList; |
32 | 32 |
import java.util.Comparator; |
33 |
import java.util.List; |
|
34 | 33 |
import java.util.regex.Matcher; |
35 | 34 |
import java.util.regex.Pattern; |
36 | 35 |
import java.util.regex.PatternSyntaxException; |
... | ... | |
73 | 72 |
* @param edition the edition |
74 | 73 |
*/ |
75 | 74 |
public Edition(Text text, Element edition) { |
75 |
super(text); |
|
76 | 76 |
this.setPath(text.getPath() + getName()); |
77 | 77 |
setSelfElement(edition); |
78 | 78 |
this.text = text; |
... | ... | |
296 | 296 |
return p; |
297 | 297 |
} |
298 | 298 |
|
299 |
/* (non-Javadoc) |
|
300 |
* @see org.txm.objects.TxmObject#getChildren() |
|
301 |
*/ |
|
302 |
public List<TxmObject> getChildren() { |
|
303 |
List<TxmObject> rez = new ArrayList<TxmObject>(); |
|
304 |
rez.addAll(this.getPages()); |
|
305 |
return rez; |
|
306 |
} |
|
307 |
|
|
308 |
/* (non-Javadoc) |
|
309 |
* @see org.txm.objects.TxmObject#removeChildren(org.txm.objects.TxmObject) |
|
310 |
*/ |
|
311 |
public TxmObject removeChildren(TxmObject o) { |
|
312 |
if (o == null) |
|
313 |
return null; |
|
314 |
if (o instanceof Page) { |
|
315 |
getSelfElement().removeChild(o.getSelfElement()); |
|
316 |
if (pages.remove(o)) |
|
317 |
return o; |
|
318 |
else |
|
319 |
return null; |
|
320 |
} |
|
321 |
return null; |
|
322 |
} |
|
323 |
|
|
324 |
/* (non-Javadoc) |
|
325 |
* @see org.txm.objects.TxmObject#hasChildren(org.txm.objects.TxmObject) |
|
326 |
*/ |
|
327 |
public boolean hasChildren(TxmObject o) { |
|
328 |
if (o == null) |
|
329 |
return false; |
|
330 |
if (o instanceof Page) |
|
331 |
return pages.contains(o); |
|
332 |
return false; |
|
333 |
} |
|
334 |
|
|
335 |
/* (non-Javadoc) |
|
336 |
* @see org.txm.objects.TxmObject#getParent() |
|
337 |
*/ |
|
338 |
@Override |
|
339 |
public TxmObject getParent() { |
|
340 |
return getText(); |
|
341 |
} |
|
342 |
|
|
343 | 299 |
public File getHtmlDir() { |
344 | 300 |
if (defaultHtmlDir == null) { |
345 | 301 |
String corpusname = getText().getCorpus().getName(); |
... | ... | |
367 | 323 |
} |
368 | 324 |
} |
369 | 325 |
} |
370 |
|
|
371 |
@Override |
|
372 |
public String getSimpleName() { |
|
373 |
return getName(); |
|
374 |
} |
|
375 |
|
|
376 |
@Override |
|
377 |
public String getDetails() { |
|
378 |
return getName(); |
|
379 |
} |
|
380 |
|
|
381 |
@Override |
|
382 |
public void clean() { |
|
383 |
|
|
384 |
} |
|
385 |
|
|
386 |
@Override |
|
387 |
public boolean validateParameters() { |
|
388 |
return true; |
|
389 |
} |
|
390 | 326 |
} |
tmp/org.txm.core/src/java/org/txm/objects/Workspace.java (revision 526) | ||
---|---|---|
124 | 124 |
* @param xmlproject the xmlproject |
125 | 125 |
*/ |
126 | 126 |
public Workspace(File xmlproject) { |
127 |
super(null); |
|
127 | 128 |
name = xmlproject.getName(); |
128 | 129 |
this.setPath(xmlproject.getAbsolutePath()); |
129 | 130 |
this.xmlfile = xmlproject; |
... | ... | |
365 | 366 |
// TODO Auto-generated method stub |
366 | 367 |
return false; |
367 | 368 |
} |
369 |
|
|
370 |
@Override |
|
371 |
public boolean _compute() throws Exception { |
|
372 |
// TODO Auto-generated method stub |
|
373 |
return false; |
|
374 |
} |
|
375 |
|
|
376 |
@Override |
|
377 |
public boolean toTxt(File arg0, String arg1, String arg2, String arg3) throws Exception { |
|
378 |
// TODO Auto-generated method stub |
|
379 |
return false; |
|
380 |
} |
|
368 | 381 |
} |
tmp/org.txm.core/src/java/org/txm/objects/CorpusParameters.java (revision 526) | ||
---|---|---|
245 | 245 |
String from = split[1].trim(); |
246 | 246 |
String to = split[2].trim(); |
247 | 247 |
|
248 |
Alignement align = new Alignement(from, to, |
|
248 |
Alignement align = new Alignement(this.corpus.getBase(), from, to,
|
|
249 | 249 |
link.getAttribute("alignElement"), Integer.parseInt(link.getAttribute("alignLevel"))); |
250 | 250 |
links.put("#"+from+" #"+to, align); |
251 | 251 |
|
252 |
align = new Alignement(to, from, |
|
252 |
align = new Alignement(this.corpus.getBase(), to, from,
|
|
253 | 253 |
link.getAttribute("alignElement"), Integer.parseInt(link.getAttribute("alignLevel"))); |
254 | 254 |
links.put("#"+to+" #"+from, align); |
255 | 255 |
|
tmp/org.txm.core/src/java/org/txm/objects/TxmObject.java (revision 526) | ||
---|---|---|
27 | 27 |
// |
28 | 28 |
package org.txm.objects; |
29 | 29 |
|
30 |
import java.io.File; |
|
30 | 31 |
import java.io.Serializable; |
31 | 32 |
import java.util.HashMap; |
32 | 33 |
import java.util.Map; |
... | ... | |
57 | 58 |
|
58 | 59 |
/** The object path from the object root to it. */ |
59 | 60 |
private String path; |
60 |
|
|
61 |
/** |
|
62 |
* Creates a new TxmObject with no parent. |
|
63 |
*/ |
|
64 |
public TxmObject() { |
|
65 |
this(null); |
|
66 |
} |
|
67 | 61 |
|
68 | 62 |
/** |
69 | 63 |
* Creates a new TxmObject, child of the specified parent. |
... | ... | |
253 | 247 |
public boolean setParameters(TXMParameters parameters) { |
254 | 248 |
return false; |
255 | 249 |
} |
250 |
|
|
251 |
@Override |
|
252 |
public String getSimpleName() { |
|
253 |
// TODO Auto-generated method stub |
|
254 |
return null; |
|
255 |
} |
|
256 |
|
|
257 |
@Override |
|
258 |
public String getDetails() { |
|
259 |
// TODO Auto-generated method stub |
|
260 |
return null; |
|
261 |
} |
|
262 |
|
|
263 |
@Override |
|
264 |
public void clean() { |
|
265 |
// TODO Auto-generated method stub |
|
266 |
|
|
267 |
} |
|
268 |
|
|
269 |
@Override |
|
270 |
public boolean validateParameters() { |
|
271 |
// TODO Auto-generated method stub |
|
272 |
return false; |
|
273 |
} |
|
274 |
|
|
275 |
@Override |
|
276 |
public boolean _compute() throws Exception { |
|
277 |
// TODO Auto-generated method stub |
|
278 |
return false; |
|
279 |
} |
|
280 |
|
|
281 |
@Override |
|
282 |
public boolean toTxt(File arg0, String arg1, String arg2, String arg3) throws Exception { |
|
283 |
// TODO Auto-generated method stub |
|
284 |
return false; |
|
285 |
} |
|
256 | 286 |
} |
tmp/org.txm.core/src/java/org/txm/objects/Script.java (revision 526) | ||
---|---|---|
74 | 74 |
* @param script the script |
75 | 75 |
*/ |
76 | 76 |
public Script(Base b, Element script) { |
77 |
super(b); |
|
77 | 78 |
this.setPath(b.getPath() + getName()); |
78 | 79 |
setSelfElement(script); |
79 | 80 |
base = b; |
tmp/org.txm.core/src/java/org/txm/objects/Project.java (revision 526) | ||
---|---|---|
74 | 74 |
* @param project the project |
75 | 75 |
*/ |
76 | 76 |
public Project(Workspace workspace, Element project) { |
77 |
super(workspace); |
|
77 | 78 |
this.workspace = workspace; |
78 | 79 |
setSelfElement(project); |
79 | 80 |
load(); |
... | ... | |
146 | 147 |
} |
147 | 148 |
} |
148 | 149 |
|
149 |
//TODO: errrkk why? |
|
150 |
// int iname = 2; |
|
151 |
// String originalName = name; |
|
152 |
// while (loaded.contains(name) && iname < 10) { // building new name if duplicated |
|
153 |
// name = originalName + (iname++); |
|
154 |
// } |
|
155 |
// if (iname > 2) { // name was fixed |
|
156 |
// System.out.println(Messages.bind(Messages.Project_3,name)); |
|
157 |
// if (iname > 10) { // too much duplicates |
|
158 |
// System.out.println(Messages.Project_4+name); |
|
159 |
// basesElem.removeChild(base); |
|
160 |
// } else { |
|
161 |
// base.setAttribute(NAME, name); |
|
162 |
// System.out.println(Messages.Project_16+originalName+" "+name); //$NON-NLS-2$ |
|
163 |
// } |
|
164 |
// } |
|
165 |
|
|
166 | 150 |
if (PARAMS.exists() && PARAMS.canRead()) { |
167 | 151 |
|
168 | 152 |
BaseParameters parameters = new BaseParameters(PARAMS); |
... | ... | |
304 | 288 |
System.out.println("DATAc: "+DATAc+" : "+DATAc.exists()); //$NON-NLS-1$ //$NON-NLS-2$ |
305 | 289 |
continue; |
306 | 290 |
} |
307 |
|
|
308 |
// // patch registry // no more needed, CQP registry path is now a list of registry paths |
|
309 |
// File txmregistry = new File(Toolbox.getParam(Toolbox.CQI_SERVER_PATH_TO_REGISTRY)); |
|
310 |
// if (!txmregistry.exists()) { |
|
311 |
// System.out.println(Messages.Project_25+txmregistry); |
|
312 |
// Log.severe(Messages.Project_25+txmregistry); |
|
313 |
// return null; |
|
314 |
// } |
|
315 |
// the registry path need to be patched, because CQP does NOT manage relative paths (or we don't know how to manage it :)) |
|
316 |
//System.out.println("Updating "+REGISTRYc+" with "+DATAc); |
|
317 |
//PatchCwbRegistry.patch(REGISTRYc, DATAc); |
|
318 | 291 |
} |
319 | 292 |
|
320 | 293 |
return b; |
... | ... | |
392 | 365 |
return bases.values(); |
393 | 366 |
} |
394 | 367 |
|
395 |
/* (non-Javadoc) |
|
396 |
* @see org.txm.objects.TxmObject#getChildren() |
|
397 |
*/ |
|
398 |
public List<TxmObject> getChildren() { |
|
399 |
List<TxmObject> rez = new ArrayList<TxmObject>(); |
|
400 |
rez.addAll(this.getBases()); |
|
401 |
return rez; |
|
402 |
} |
|
403 |
|
|
404 |
/* (non-Javadoc) |
|
405 |
* @see org.txm.objects.TxmObject#removeChildren(org.txm.objects.TxmObject) |
|
406 |
*/ |
|
407 |
public TxmObject removeChildren(TxmObject o) { |
|
408 |
if (o == null) |
|
409 |
return null; |
|
410 |
if (o instanceof Base) { |
|
411 |
removeBase(((Base)o).getName()); |
|
412 |
} |
|
413 |
return null; |
|
414 |
} |
|
415 |
|
|
416 |
/* (non-Javadoc) |
|
417 |
* @see org.txm.objects.TxmObject#hasChildren(org.txm.objects.TxmObject) |
|
418 |
*/ |
|
419 |
public boolean hasChildren(TxmObject o) { |
|
420 |
if (o == null) |
|
421 |
return false; |
|
422 |
if (o instanceof Base) |
|
423 |
return bases.containsKey(((Base) o).getName()); |
|
424 |
return false; |
|
425 |
} |
|
426 |
|
|
427 |
/* (non-Javadoc) |
|
428 |
* @see org.txm.objects.TxmObject#getParent() |
|
429 |
*/ |
|
430 |
@Override |
|
431 |
public TxmObject getParent() { |
|
432 |
return getWorkspace(); |
|
433 |
} |
|
434 |
|
|
435 | 368 |
/** |
436 | 369 |
* Gets the base names. |
437 | 370 |
* |
... | ... | |
440 | 373 |
public List<String> getBaseNames() { |
441 | 374 |
return new ArrayList<String>(this.bases.keySet()); |
442 | 375 |
} |
443 |
|
|
444 |
@Override |
|
445 |
public String getSimpleName() { |
|
446 |
// TODO Auto-generated method stub |
|
447 |
return null; |
|
448 |
} |
|
449 |
|
|
450 |
@Override |
|
451 |
public String getDetails() { |
|
452 |
// TODO Auto-generated method stub |
|
453 |
return null; |
|
454 |
} |
|
455 |
|
|
456 |
@Override |
|
457 |
public void clean() { |
|
458 |
// TODO Auto-generated method stub |
|
459 |
|
|
460 |
} |
|
461 |
|
|
462 |
@Override |
|
463 |
public boolean validateParameters() { |
|
464 |
// TODO Auto-generated method stub |
|
465 |
return false; |
|
466 |
} |
|
467 | 376 |
} |
tmp/org.txm.core/src/java/org/txm/objects/Partition.java (revision 526) | ||
---|---|---|
27 | 27 |
// |
28 | 28 |
package org.txm.objects; |
29 | 29 |
|
30 |
import java.util.List; |
|
31 | 30 |
|
31 |
|
|
32 | 32 |
// TODO: Auto-generated Javadoc |
33 | 33 |
/** |
34 | 34 |
* The Class Partition. |
35 | 35 |
*/ |
36 | 36 |
public class Partition extends TxmObject { |
37 | 37 |
|
38 |
public Partition(Corpus parent) { |
|
39 |
super(parent); |
|
40 |
} |
|
41 |
|
|
38 | 42 |
/** The Constant serialVersionUID. */ |
39 | 43 |
private static final long serialVersionUID = 1921103951325044667L; |
40 | 44 |
|
41 | 45 |
/* (non-Javadoc) |
42 |
* @see org.txm.objects.TxmObject#getChildren() |
|
43 |
*/ |
|
44 |
public List<TxmObject> getChildren() { |
|
45 |
// TODO Auto-generated method stub |
|
46 |
return null; |
|
47 |
} |
|
48 |
|
|
49 |
/* (non-Javadoc) |
|
50 |
* @see org.txm.objects.TxmObject#hasChildren(org.txm.objects.TxmObject) |
|
51 |
*/ |
|
52 |
public boolean hasChildren(TxmObject children) { |
|
53 |
// TODO Auto-generated method stub |
|
54 |
return false; |
|
55 |
} |
|
56 |
|
|
57 |
/* (non-Javadoc) |
|
58 | 46 |
* @see org.txm.objects.TxmObject#load() |
59 | 47 |
*/ |
60 | 48 |
@Override |
... | ... | |
65 | 53 |
} |
66 | 54 |
|
67 | 55 |
/* (non-Javadoc) |
68 |
* @see org.txm.objects.TxmObject#removeChildren(org.txm.objects.TxmObject) |
|
69 |
*/ |
|
70 |
public TxmObject removeChildren(TxmObject children) { |
|
71 |
// TODO Auto-generated method stub |
|
72 |
return null; |
|
73 |
} |
|
74 |
|
|
75 |
/* (non-Javadoc) |
|
76 | 56 |
* @see org.txm.objects.TxmObject#save() |
77 | 57 |
*/ |
78 | 58 |
@Override |
... | ... | |
81 | 61 |
return false; |
82 | 62 |
} |
83 | 63 |
|
84 |
/* (non-Javadoc) |
|
85 |
* @see org.txm.objects.TxmObject#getParent() |
|
86 |
*/ |
|
87 |
@Override |
|
88 |
public TxmObject getParent() { |
|
89 |
// TODO Auto-generated method stub |
|
90 |
return null; |
|
91 |
} |
|
92 |
|
|
93 |
@Override |
|
94 |
public String getSimpleName() { |
|
95 |
return getName(); |
|
96 |
} |
|
97 |
|
|
98 |
@Override |
|
99 |
public String getDetails() { |
|
100 |
return getName(); |
|
101 |
} |
|
102 |
|
|
103 |
@Override |
|
104 |
public void clean() { |
|
105 |
|
|
106 |
} |
|
107 |
|
|
108 |
@Override |
|
109 |
public boolean validateParameters() { |
|
110 |
return true; |
|
111 |
} |
|
112 |
|
|
113 | 64 |
} |
tmp/org.txm.core/src/java/org/txm/objects/Base.java (revision 526) | ||
---|---|---|
78 | 78 |
* @param parameters the b |
79 | 79 |
*/ |
80 | 80 |
public Base(Project project, BaseParameters parameters) { |
81 |
super(project); |
|
81 | 82 |
this.setPath(project.getPath() + getName()); |
82 | 83 |
params = parameters; |
83 | 84 |
setSelfElement(params.root); |
... | ... | |
152 | 153 |
String from = split[1].trim(); |
153 | 154 |
String to = split[2].trim(); |
154 | 155 |
|
155 |
Alignement align = new Alignement(from, to, |
|
156 |
Alignement align = new Alignement(this, from, to,
|
|
156 | 157 |
link.getAttribute("alignElement"), Integer.parseInt(link.getAttribute("alignLevel"))); //$NON-NLS-1$ //$NON-NLS-2$ |
157 | 158 |
links.put("#"+from+" #"+to, align); //$NON-NLS-1$ //$NON-NLS-2$ |
158 | 159 |
|
159 |
align = new Alignement(to, from, |
|
160 |
align = new Alignement(this, to, from,
|
|
160 | 161 |
link.getAttribute("alignElement"), Integer.parseInt(link.getAttribute("alignLevel"))); //$NON-NLS-1$ //$NON-NLS-2$ |
161 | 162 |
links.put("#"+to+" #"+from, align); //$NON-NLS-1$ //$NON-NLS-2$ |
162 | 163 |
} |
... | ... | |
350 | 351 |
public BaseParameters getBaseParameters() { |
351 | 352 |
return params; |
352 | 353 |
} |
353 |
|
|
354 |
@Override |
|
355 |
public String getSimpleName() { |
|
356 |
return getName(); |
|
357 |
} |
|
358 |
|
|
359 |
@Override |
|
360 |
public String getDetails() { |
|
361 |
return getName(); |
|
362 |
} |
|
363 |
|
|
364 |
@Override |
|
365 |
public void clean() { |
|
366 |
|
|
367 |
} |
|
368 |
|
|
369 |
@Override |
|
370 |
public boolean validateParameters() { |
|
371 |
return true; |
|
372 |
} |
|
373 | 354 |
} |
tmp/org.txm.core/src/java/org/txm/functions/TXMCommand.java (revision 526) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate: 2016-09-19 10:31:00 +0200 (Mon, 19 Sep 2016) $ |
|
25 |
// $LastChangedRevision: 3298 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.functions; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
import java.io.IOException; |
|
32 |
import java.util.concurrent.Semaphore; |
|
33 |
|
|
34 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
35 |
import org.txm.core.results.TXMParameters; |
|
36 |
import org.txm.core.results.TXMResult; |
|
37 |
import org.txm.utils.logger.Log; |
|
38 |
|
|
39 |
/** |
|
40 |
* |
|
41 |
* A TXMResult that is able to compute itself using parameters and with or not a monitor |
|
42 |
* |
|
43 |
* if setCurrentMonitor is called, then the IProgressMonitor methods will work. |
|
44 |
* |
|
45 |
* Has methods to interact with a ProcessWatcher: set work amount, set messages, acquire/release interruption semaphore. |
|
46 |
* |
|
47 |
* Call order : |
|
48 |
* MyCommand cmd = new MyCommand(parent) |
|
49 |
* cmd.setParameters(param1, param2, param3) OR cmd.setParameters(parameters) // parameters = new TXMParameters |
|
50 |
* if (cmd.validateParameters()) |
|
51 |
* cmd.compute() OR cmd.compute(monitor) // if any IProgressMonitor available |
|
52 |
* |
|
53 |
* @author mdecorde |
|
54 |
* @author nkredens |
|
55 |
*/ |
|
56 |
public abstract class TXMCommand extends TXMResult implements IProgressMonitor { |
|
57 |
|
|
58 |
/** |
|
59 |
* if set, allows the command to notify its progress |
|
60 |
*/ |
|
61 |
protected IProgressMonitor monitor; |
|
62 |
|
|
63 |
public TXMCommand() { |
|
64 |
super(); |
|
65 |
} |
|
66 |
|
|
67 |
public TXMCommand(TXMResult parent) { |
|
68 |
super(parent); |
|
69 |
} |
|
70 |
|
|
71 |
public TXMCommand(TXMResult parent, TXMParameters parameters) { |
|
72 |
super(parent, parameters); |
|
73 |
} |
|
74 |
|
|
75 |
Semaphore progressSemaphore = new Semaphore(1); |
|
76 |
public void acquireSemaphore() { |
|
77 |
try { |
|
78 |
this.progressSemaphore.acquire(); |
|
79 |
} catch (InterruptedException e) { |
|
80 |
Log.printStackTrace(e); |
|
81 |
} |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* Computes the result according to specified command parameters. |
|
86 |
* |
|
87 |
* @param parameters |
|
88 |
* @return |
|
89 |
*/ |
|
90 |
public boolean compute() throws Exception { |
|
91 |
return this.compute(null); |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* Computes the result according to stored command parameters. |
|
96 |
* |
|
97 |
* @param watcher |
|
98 |
* @return |
|
99 |
* @throws InvalidCqpIdException |
|
100 |
* @throws CqiServerError |
|
101 |
* @throws CqiClientException |
|
102 |
* @throws IOException |
|
103 |
*/ |
|
104 |
public abstract boolean compute(IProgressMonitor watcher) throws Exception; |
|
105 |
|
|
106 |
// //removed for now, waiting to see if used |
|
107 |
// /** |
|
108 |
// * Computes the result according to specified command parameters. |
|
109 |
// * @param watcher |
|
110 |
// * @param parameters |
|
111 |
// * @return |
|
112 |
// */ |
|
113 |
// public boolean compute(IProgressMonitor watcher, TXMParameters parameters) throws Exception { |
|
114 |
// this.parameters = parameters; |
|
115 |
// return this.compute(watcher); |
|
116 |
// } |
|
117 |
|
|
118 |
/** |
|
119 |
* |
|
120 |
* @return the array of extensions to show in the FileDialog SWT widget |
|
121 |
*/ |
|
122 |
@Deprecated |
|
123 |
//FIXME: should be moved in an exporter extension |
|
124 |
public String[] getExportTXTExtensions() { |
|
125 |
return new String[]{"*.csv"}; |
|
126 |
} |
|
127 |
|
|
128 |
/** |
|
129 |
* |
|
130 |
* @return true if the monitor has been canceled by the user |
|
131 |
*/ |
|
132 |
public boolean isCanceled() { |
|
133 |
if (monitor != null) { |
|
134 |
return monitor.isCanceled(); |
|
135 |
} |
|
136 |
return false; |
|
137 |
} |
|
138 |
|
|
139 |
/** |
|
140 |
* |
|
141 |
* @return the parent Object that contains this result |
|
142 |
*/ |
|
143 |
@Deprecated |
|
144 |
// FIXME: to remove when TXMResult2 will be fully implemented |
|
145 |
//public abstract HasResults getHasResultsParent(); |
|
146 |
|
|
147 |
public boolean tryAcquireSemaphore() { |
|
148 |
return this.progressSemaphore.tryAcquire(); |
|
149 |
} |
|
150 |
|
|
151 |
public void releaseSemaphore() { |
|
152 |
this.progressSemaphore.release(); |
|
153 |
} |
|
154 |
|
|
155 |
/** |
|
156 |
* You must set the current monitor to be available to manage the process progress |
|
157 |
* @param monitor can be null |
|
158 |
*/ |
|
159 |
public void setCurrentMonitor(IProgressMonitor monitor) { |
|
160 |
this.monitor = monitor; |
|
161 |
} |
|
162 |
|
|
163 |
//public abstract boolean toTxt(File file, String encoding) throws Exception; |
|
164 |
@Deprecated |
|
165 |
//FIXME: should be moved in an exporter extension |
|
166 |
public abstract boolean toTxt(File outfile, String encoding, String colseparator, String txtseparator) throws Exception; |
|
167 |
|
|
168 |
/** |
|
169 |
* increment the process |
|
170 |
* @param amount of work |
|
171 |
*/ |
|
172 |
public void worked(int amount) { |
|
173 |
if (monitor != null) { |
|
174 |
//System.out.println("worked "+amount); |
|
175 |
monitor.worked(amount); |
|
176 |
} |
|
177 |
} |
|
178 |
|
|
179 |
/** |
|
180 |
* increment the progress and show a message |
|
181 |
* |
|
182 |
* @param amount |
|
183 |
* @param message |
|
184 |
*/ |
|
185 |
public void worked(int amount, String message) { |
|
186 |
if (monitor != null) { |
|
187 |
monitor.worked(amount); |
|
188 |
monitor.subTask(message); |
|
189 |
} |
|
190 |
} |
|
191 |
|
|
192 |
@Override |
|
193 |
public void beginTask(String name, int totalWork) { |
|
194 |
if (monitor != null) monitor.beginTask(name, totalWork); |
|
195 |
} |
|
196 |
|
|
197 |
@Override |
|
198 |
public void done() { |
|
199 |
if (monitor != null) monitor.done(); |
|
200 |
} |
|
201 |
|
|
202 |
@Override |
|
203 |
public void internalWorked(double work) { |
|
204 |
if (monitor != null) monitor.internalWorked(work); |
|
205 |
} |
|
206 |
|
|
207 |
@Override |
|
208 |
public void setCanceled(boolean value) { |
|
209 |
if (monitor != null) monitor.setCanceled(value); |
|
210 |
} |
|
211 |
|
|
212 |
@Override |
|
213 |
public void setTaskName(String name) { |
|
214 |
if (monitor != null) monitor.setTaskName(name); |
|
215 |
} |
|
216 |
|
|
217 |
@Override |
|
218 |
public void subTask(String name) { |
|
219 |
if (monitor != null) monitor.subTask(name); |
|
220 |
} |
|
221 |
} |
tmp/org.txm.core/src/java/org/txm/functions/CommandsAPI.java (revision 526) | ||
---|---|---|
10 | 10 |
/** |
11 | 11 |
* API to all knowned TXM commands. |
12 | 12 |
* |
13 |
* Initialized during Toolbox initialisation using the TXMCommand extension point
|
|
13 |
* Initialized during Toolbox initialisation using the TXMResult extension point
|
|
14 | 14 |
* |
15 | 15 |
* For now a command is : |
16 | 16 |
* - an ID |
... | ... | |
25 | 25 |
|
26 | 26 |
protected static final HashMap<String, Command> cmds = new HashMap<String, Command>(); |
27 | 27 |
|
28 |
public static void install(String cmd, Class<TXMCommand> clazz) {
|
|
28 |
public static void install(String cmd, Class<TXMResult> clazz) {
|
|
29 | 29 |
CommandsAPI.cmds.put(cmd, new Command(cmd,clazz)); |
30 | 30 |
} |
31 | 31 |
|
... | ... | |
50 | 50 |
* @param clazz |
51 | 51 |
* @param mandatory_parameters |
52 | 52 |
*/ |
53 |
public static void install(String cmd, Class<TXMCommand> clazz, HashSet<String> mandatoryParameters) {
|
|
53 |
public static void install(String cmd, Class<TXMResult> clazz, HashSet<String> mandatoryParameters) {
|
|
54 | 54 |
Command command = new Command(cmd,clazz); |
55 | 55 |
command.mandatoryParameters.addAll(mandatoryParameters); |
56 | 56 |
CommandsAPI.cmds.put(cmd, command); |
... | ... | |
64 | 64 |
* @param mandatory_parameters |
65 | 65 |
* @param optional_parameters |
66 | 66 |
*/ |
67 |
public static void install(String cmd, Class<TXMCommand> clazz, HashSet<String> mandatoryParameters, HashSet<String> optionalParameters) {
|
|
67 |
public static void install(String cmd, Class<TXMResult> clazz, HashSet<String> mandatoryParameters, HashSet<String> optionalParameters) {
|
|
68 | 68 |
Command command = new Command(cmd,clazz); |
69 | 69 |
command.mandatoryParameters.addAll(mandatoryParameters); |
70 | 70 |
command.optionalParameters.addAll(optionalParameters); |
... | ... | |
90 | 90 |
} |
91 | 91 |
|
92 | 92 |
// compute directly the command using the parameters |
93 |
TXMCommand result = null;
|
|
93 |
TXMResult result = null;
|
|
94 | 94 |
try { |
95 | 95 |
if (command.mandatoryParameters.containsAll(parameters.keySet())) { |
96 | 96 |
System.out.println("Computing "+command.cmd+"..."); |
tmp/org.txm.core/src/java/org/txm/functions/Command.java (revision 526) | ||
---|---|---|
13 | 13 |
public class Command { |
14 | 14 |
|
15 | 15 |
public final String cmd; |
16 |
public final Class<TXMCommand> clazz;
|
|
16 |
public final Class<TXMResult> clazz;
|
|
17 | 17 |
public final HashSet<String> mandatoryParameters = new HashSet<String>(); |
18 | 18 |
public final HashSet<String> optionalParameters = new HashSet<String>(); |
19 | 19 |
|
20 |
public Command(Class<TXMCommand> clazz) {
|
|
20 |
public Command(Class<TXMResult> clazz) {
|
|
21 | 21 |
this.cmd = clazz.getSimpleName(); |
22 | 22 |
this.clazz = clazz; |
23 | 23 |
} |
24 | 24 |
|
25 |
public Command(String cmd, Class<TXMCommand> clazz) {
|
|
25 |
public Command(String cmd, Class<TXMResult> clazz) {
|
|
26 | 26 |
this.cmd = cmd; |
27 | 27 |
this.clazz = clazz; |
28 | 28 |
} |
tmp/org.txm.internalview.core/src/org/txm/functions/internal/InternalView.java (revision 526) | ||
---|---|---|
9 | 9 |
|
10 | 10 |
import org.eclipse.core.runtime.IProgressMonitor; |
11 | 11 |
import org.txm.core.results.TXMParameters; |
12 |
import org.txm.functions.TXMCommand;
|
|
12 |
import org.txm.core.results.TXMResult;
|
|
13 | 13 |
import org.txm.internalview.core.Messages; |
14 | 14 |
import org.txm.searchengine.cqp.CQPEngine; |
15 | 15 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
... | ... | |
21 | 21 |
import org.txm.searchengine.cqp.corpus.query.Match; |
22 | 22 |
import org.txm.searchengine.cqp.corpus.query.Query; |
23 | 23 |
|
24 |
public class InternalView extends TXMCommand {
|
|
24 |
public class InternalView extends TXMResult {
|
|
25 | 25 |
|
26 | 26 |
Corpus corpus; |
27 | 27 |
List<Property> pProperties; |
... | ... | |
219 | 219 |
} |
220 | 220 |
|
221 | 221 |
@Override |
222 |
public boolean compute(IProgressMonitor watcher) throws Exception {
|
|
222 |
public boolean _compute() throws Exception {
|
|
223 | 223 |
//find struct start-end |
224 | 224 |
Query query = new Query("<"+pStructure.getName()+"> [] expand to "+pStructure); //$NON-NLS-1$ //$NON-NLS-2$ |
225 | 225 |
//System.out.println(query); |
... | ... | |
252 | 252 |
HashMap<Property, List<String>> current = getPage(pCurrentStruct); |
253 | 253 |
return current; |
254 | 254 |
} |
255 |
|
|
256 |
@Override |
|
257 |
public boolean saveParameters() { |
|
258 |
// TODO Auto-generated method stub |
|
259 |
return false; |
|
260 |
} |
|
255 | 261 |
} |
tmp/org.txm.partition.core/src/org/txm/partition/core/functions/PartitionDimensions.java (revision 526) | ||
---|---|---|
3 | 3 |
*/ |
4 | 4 |
package org.txm.partition.core.functions; |
5 | 5 |
|
6 |
import java.io.File; |
|
6 | 7 |
import java.util.ArrayList; |
7 | 8 |
import java.util.Collections; |
8 | 9 |
import java.util.Comparator; |
... | ... | |
136 | 137 |
public boolean setParameters(TXMParameters parameters) { |
137 | 138 |
return false; |
138 | 139 |
} |
140 |
|
|
141 |
|
|
142 |
@Override |
|
143 |
public boolean _compute() throws Exception { |
|
144 |
// TODO move here the code from SWTChartsComponentsProvider that creates the chart to display |
|
145 |
return false; |
|
146 |
} |
|
147 |
|
|
148 |
|
|
149 |
@Override |
|
150 |
public boolean toTxt(File arg0, String arg1, String arg2, String arg3) throws Exception { |
|
151 |
// TODO Auto-generated method stub |
|
152 |
return false; |
|
153 |
} |
|
139 | 154 |
} |
tmp/org.txm.progression.core/src/org/txm/progression/core/functions/Progression.java (revision 526) | ||
---|---|---|
39 | 39 |
|
40 | 40 |
import org.txm.chartsengine.r.core.themes.DefaultTheme; |
41 | 41 |
import org.txm.core.results.TXMParameters; |
42 |
import org.txm.core.results.TXMResult; |
|
42 | 43 |
import org.eclipse.core.runtime.IProgressMonitor; |
43 |
import org.txm.functions.TXMCommand; |
|
44 | 44 |
import org.txm.progression.core.messages.ProgressionCoreMessages; |
45 | 45 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
46 | 46 |
import org.txm.searchengine.cqp.corpus.Corpus; |
... | ... | |
60 | 60 |
* @author mdecorde |
61 | 61 |
* @author sjacquot |
62 | 62 |
*/ |
63 |
public class Progression extends TXMCommand {
|
|
63 |
public class Progression extends TXMResult {
|
|
64 | 64 |
|
65 | 65 |
/** The corpus. */ |
66 | 66 |
Corpus corpus; |
... | ... | |
158 | 158 |
* @throws CqiServerError |
159 | 159 |
* @throws IOException |
160 | 160 |
*/ |
161 |
public boolean compute(IProgressMonitor monitor) throws CqiClientException, IOException, CqiServerError {
|
|
161 |
public boolean _compute() throws Exception {
|
|
162 | 162 |
return stepQueries() && stepStructuralUnits() && stepFinalize(); |
163 | 163 |
} |
164 | 164 |
|
tmp/org.txm.cooccurrence.core/src/org/txm/cooccurrence/core/functions/Cooccurrence.java (revision 526) | ||
---|---|---|
50 | 50 |
import org.txm.cooccurrence.core.preferences.CooccurrencePreferences; |
51 | 51 |
import org.txm.core.results.TXMParameters; |
52 | 52 |
import org.txm.core.results.TXMResult; |
53 |
import org.txm.functions.TXMCommand; |
|
53 |
|
|
54 | 54 |
import org.txm.index.core.functions.Index; |
55 | 55 |
import org.txm.lexicaltable.core.statsengine.r.data.LexicalTableImpl; |
56 | 56 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
... | ... | |
75 | 75 |
* @author mdecorde |
76 | 76 |
* |
77 | 77 |
*/ |
78 |
public class Cooccurrence extends TXMCommand {
|
|
78 |
public class Cooccurrence extends TXMResult {
|
|
79 | 79 |
|
80 | 80 |
/** The a. */ |
81 | 81 |
static double[] a = new double[101]; |
... | ... | |
445 | 445 |
* @param buildLexicalTableWithCooccurrents |
446 | 446 |
* @return |
447 | 447 |
*/ |
448 |
public boolean compute(IProgressMonitor monitor) {
|
|
448 |
public boolean _compute() {
|
|
449 | 449 |
this.monitor = monitor; |
450 | 450 |
//FIXME: debug |
451 | 451 |
//System.out.println("cooc: "+corpus+" "+query+" "+properties+" "+limit+" "+maxLeft+" "+minLeft+" "+minRight+" "+maxRight+" "+minFreq+" "+minCof+" "+minScore+" "+includeXpivot); |
tmp/org.txm.textsbalance.core/src/org/txm/textsbalance/core/functions/TextsBalance.java (revision 526) | ||
---|---|---|
14 | 14 |
import org.txm.core.preferences.TXMPreferences; |
15 | 15 |
import org.txm.core.results.TXMResult; |
16 | 16 |
import org.txm.core.results.TXMParameters; |
17 |
import org.txm.functions.TXMCommand; |
|
17 |
|
|
18 | 18 |
import org.eclipse.core.runtime.IProgressMonitor; |
19 | 19 |
import org.txm.searchengine.cqp.AbstractCqiClient; |
20 | 20 |
import org.txm.searchengine.cqp.CQPEngine; |
... | ... | |
36 | 36 |
* @author sjacquot |
37 | 37 |
* |
38 | 38 |
*/ |
39 |
public class TextsBalance extends TXMCommand {
|
|
39 |
public class TextsBalance extends TXMResult {
|
|
40 | 40 |
|
41 | 41 |
HashMap<Integer, Comparable[]> dataset; |
42 | 42 |
|
... | ... | |
99 | 99 |
* @param groupByTexts |
100 | 100 |
* @throws CqiClientException |
101 | 101 |
*/ |
102 |
public boolean compute(IProgressMonitor watcher) {
|
|
102 |
public boolean _compute() {
|
|
103 | 103 |
|
104 | 104 |
this.name = su.getName() + "@" + suPropertyName + " (group by texts = " + groupByTexts + ")"; |
105 | 105 |
if (suPropertyName == null || suPropertyName.length() == 0) return false; |
... | ... | |
113 | 113 |
this.values = p.getValues(); |
114 | 114 |
Collections.sort(values); |
115 | 115 |
|
116 |
|
|
117 | 116 |
//int method = 2; |
118 | 117 |
//System.out.println("Method: "+method); |
119 | 118 |
//long time = System.currentTimeMillis(); |
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java (revision 526) | ||
---|---|---|
47 | 47 |
import org.txm.concordance.core.messages.ConcordanceMessages; |
48 | 48 |
import org.txm.concordance.core.preferences.ConcordancePreferences; |
49 | 49 |
import org.txm.core.results.TXMParameters; |
50 |
import org.txm.functions.TXMCommand;
|
|
50 |
import org.txm.core.results.TXMResult;
|
|
51 | 51 |
import org.txm.searchengine.cqp.AbstractCqiClient; |
52 | 52 |
import org.txm.searchengine.cqp.MemCqiClient; |
53 | 53 |
import org.txm.searchengine.cqp.Reference; |
... | ... | |
70 | 70 |
* |
71 | 71 |
* @author jmague, mdecorde |
72 | 72 |
*/ |
73 |
public class Concordance extends TXMCommand {
|
|
73 |
public class Concordance extends TXMResult {
|
|
74 | 74 |
|
75 | 75 |
/** The noconc. */ |
76 | 76 |
protected static int noconc = 1;; |
... | ... | |
264 | 264 |
* @throws CqiClientException |
265 | 265 |
*/ |
266 | 266 |
@Override |
267 |
public boolean compute(IProgressMonitor monitor) throws CqiClientException {
|
|
267 |
public boolean _compute() throws Exception {
|
|
268 | 268 |
this.queryResult = this.getCorpus().query(pQuery, pQuery.getQueryString() |
269 | 269 |
.replace(" ", "_") + "_concordance", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
270 | 270 |
|
... | ... | |
1528 | 1528 |
lines = new ArrayList<Line>(Collections.nCopies(nLines, |
Formats disponibles : Unified diff