1009 |
1009 |
// value = new Property(this.getStringParameterValue(key), Corpus.getCorpus(this));
|
1010 |
1010 |
// }
|
1011 |
1011 |
// MD: nope should be done via adapter or extension point "org.txm.searchengine.cqp.core" contributes to
|
|
1012 |
// SJ: or better, when the abstraction of Property, etc. will be done, we could implement some extensions as in ChartCreator model to other engines, eg. SearchEngine, that will return
|
|
1013 |
// the right class here
|
1012 |
1014 |
f.set(this, value);
|
1013 |
1015 |
|
1014 |
1016 |
// FIXME: Debug
|
... | ... | |
1771 |
1773 |
* @return
|
1772 |
1774 |
* @throws Exception
|
1773 |
1775 |
*/
|
1774 |
|
public boolean compute() throws Exception {
|
|
1776 |
public boolean compute() {
|
1775 |
1777 |
return this.compute(null);
|
1776 |
1778 |
}
|
1777 |
1779 |
|
... | ... | |
1782 |
1784 |
* @return
|
1783 |
1785 |
* @throws Exception
|
1784 |
1786 |
*/
|
1785 |
|
public boolean compute(IProgressMonitor monitor) throws Exception {
|
|
1787 |
public boolean compute(IProgressMonitor monitor) {
|
1786 |
1788 |
return this.compute(monitor, true);
|
1787 |
1789 |
}
|
1788 |
1790 |
|
... | ... | |
1802 |
1804 |
* @throws CqiClientExceptio
|
1803 |
1805 |
* @throws IOException
|
1804 |
1806 |
*/
|
1805 |
|
protected boolean compute(IProgressMonitor monitor, boolean deepComputing) throws Exception {
|
|
1807 |
protected boolean compute(IProgressMonitor monitor, boolean deepComputing) {
|
1806 |
1808 |
|
1807 |
|
// FIXME: see if this skipComputing tests is still useful? is it possible to directly return instead?
|
1808 |
|
// en fait voir ChartResult.compute() if(super.compute(monitor, true, false)), je pense que le prob vient du fait que si on retourne false dans TXMResult.compute() alors renderChart() ne sera pas appelé
|
1809 |
|
boolean skipComputing = false;
|
|
1809 |
try {
|
|
1810 |
// FIXME: see if this skipComputing tests is still useful? is it possible to directly return instead?
|
|
1811 |
// en fait voir ChartResult.compute() if(super.compute(monitor, true, false)), je pense que le prob vient du fait que si on retourne false dans TXMResult.compute() alors renderChart() ne sera pas appelé
|
|
1812 |
boolean skipComputing = false;
|
1810 |
1813 |
|
1811 |
|
this.monitor = monitor;
|
|
1814 |
this.monitor = monitor;
|
1812 |
1815 |
|
1813 |
|
// TODO THIS IS FUCKING LAZY LINE CODES OH YEAH YOU MAD BRO
|
1814 |
|
// TODO where do we put this parent compute ? :o
|
1815 |
|
// if (parent != null && !parent.getHasBeenComputedOnce()) { // parent must be computed at least one time
|
1816 |
|
// SJ: other way, test the object itself
|
1817 |
|
if (this.parent != null && !(this.parent instanceof Project)) {
|
1818 |
|
if (!this.parent.compute(monitor, true)) {
|
1819 |
|
Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": failed to compute parent result.");
|
|
1816 |
// TODO THIS IS FUCKING LAZY LINE CODES OH YEAH YOU MAD BRO
|
|
1817 |
// TODO where do we put this parent compute ? :o
|
|
1818 |
// if (parent != null && !parent.getHasBeenComputedOnce()) { // parent must be computed at least one time
|
|
1819 |
// SJ: other way, test the object itself
|
|
1820 |
if (this.parent != null && !(this.parent instanceof Project)) {
|
|
1821 |
if (!this.parent.compute(monitor, true)) {
|
|
1822 |
Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": failed to compute parent result.");
|
1820 |
1823 |
|
1821 |
|
return false;
|
|
1824 |
return false;
|
|
1825 |
}
|
1822 |
1826 |
}
|
1823 |
|
}
|
1824 |
|
|
1825 |
|
boolean d0 = this.isDirty();
|
1826 |
|
boolean d1 = this.needsFullRecomputing;
|
1827 |
|
boolean d2 = this.isDirtyFromHistory();
|
1828 |
|
boolean d3 = this.isDirty();
|
1829 |
|
if (!d1 &&
|
1830 |
|
!d2 && !d3) {
|
1831 |
|
// needsFullRecomputing == true && isDirtyFromHistory == true && isDirty == true
|
1832 |
|
Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": result parameters have not changed since last computing, computing skipped.");
|
1833 |
|
skipComputing = true;
|
1834 |
|
}
|
|
1827 |
|
|
1828 |
boolean d0 = this.isDirty();
|
|
1829 |
boolean d1 = this.needsFullRecomputing;
|
|
1830 |
boolean d2 = this.isDirtyFromHistory();
|
|
1831 |
boolean d3 = this.isDirty();
|
|
1832 |
if (!d1 &&
|
|
1833 |
!d2 && !d3) {
|
|
1834 |
// needsFullRecomputing == true && isDirtyFromHistory == true && isDirty == true
|
|
1835 |
Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": result parameters have not changed since last computing, computing skipped.");
|
|
1836 |
skipComputing = true;
|
|
1837 |
}
|
1835 |
1838 |
|
1836 |
|
if(!skipComputing) {
|
|
1839 |
if(!skipComputing) {
|
1837 |
1840 |
|
1838 |
|
// FIXME: Debug
|
1839 |
|
Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": computing result of type " + this.getClass() + "...");
|
|
1841 |
// FIXME: Debug
|
|
1842 |
Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": computing result of type " + this.getClass() + "...");
|
1840 |
1843 |
|
1841 |
1844 |
|
1842 |
|
// Computing requirements test
|
1843 |
|
if (!this.canCompute()) {
|
1844 |
|
Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": missing or wrong parameters, computing aborted.");
|
1845 |
|
return false;
|
1846 |
|
}
|
|
1845 |
// Computing requirements test
|
|
1846 |
if (!this.canCompute()) {
|
|
1847 |
Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": missing or wrong parameters, computing aborted.");
|
|
1848 |
return false;
|
|
1849 |
}
|
1847 |
1850 |
|
1848 |
|
// Computing
|
1849 |
|
if (!this._compute()) {
|
1850 |
|
Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": computing failed.");
|
1851 |
|
return false;
|
|
1851 |
// Computing
|
|
1852 |
if (!this._compute()) {
|
|
1853 |
Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": computing failed.");
|
|
1854 |
return false;
|
|
1855 |
}
|
1852 |
1856 |
}
|
1853 |
|
}
|
1854 |
1857 |
|
1855 |
|
// clear the lazy name, no more needed since the object has been computed and getSimpleName() can now work
|
1856 |
|
this.lazyName = null;
|
|
1858 |
// clear the lazy name, no more needed since the object has been computed and getSimpleName() can now work
|
|
1859 |
this.lazyName = null;
|
1857 |
1860 |
|
1858 |
1861 |
// // store last used parameters
|
1859 |
1862 |
// if (updateLastParameters) {
|
... | ... | |
1873 |
1876 |
// TXMPreferences.flush(this);
|
1874 |
1877 |
// }
|
1875 |
1878 |
|
1876 |
|
if(!skipComputing) {
|
1877 |
|
|
1878 |
|
// store last used parameters
|
1879 |
|
this.updateLastParameters();
|
|
1879 |
if(!skipComputing) {
|
|
1880 |
|
|
1881 |
// store last used parameters
|
|
1882 |
this.updateLastParameters();
|
1880 |
1883 |
|
1881 |
|
if (!this.autoSaveParametersFromAnnotations()) {
|
1882 |
|
Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": failed to save parameters from annotations for " + this.getName() + ".");
|
1883 |
|
}
|
1884 |
|
if (!this.saveParameters()) {
|
1885 |
|
Log.severe("TXMResult.compute():" + this.getClass().getSimpleName() + ": failed to save parameters for " + this.getName() + ".");
|
1886 |
|
}
|
|
1884 |
if (!this.autoSaveParametersFromAnnotations()) {
|
|
1885 |
Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": failed to save parameters from annotations for " + this.getName() + ".");
|
|
1886 |
}
|
|
1887 |
if (!this.saveParameters()) {
|
|
1888 |
Log.severe("TXMResult.compute():" + this.getClass().getSimpleName() + ": failed to save parameters for " + this.getName() + ".");
|
|
1889 |
}
|
1887 |
1890 |
|
1888 |
|
// file persistence flush
|
1889 |
|
if (this.mustBePersisted()) {
|
1890 |
|
TXMPreferences.flush(this);
|
1891 |
|
}
|
1892 |
|
|
1893 |
|
|
1894 |
|
this.dirty = false; // the computing was successful, the result is no more dirty
|
1895 |
|
this.hasBeenComputedOnce = true;
|
1896 |
|
this.needsFullRecomputing = false;
|
1897 |
|
|
1898 |
|
Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": computing of result type " + this.getClass() + " done.");
|
1899 |
|
|
1900 |
|
// set the children as dirty since the result has changed
|
1901 |
|
for (int i = 0; i < this.children.size(); i++) {
|
1902 |
|
this.children.get(i).setDirty();
|
1903 |
|
}
|
1904 |
|
|
1905 |
|
// Children cascade computing ; if parent == null this is the Workspace
|
1906 |
|
if (deepComputing && parent != null) {
|
1907 |
|
|
1908 |
|
Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": cascade computing of " + this.children.size() + " children.");
|
1909 |
|
|
|
1891 |
// file persistence flush
|
|
1892 |
if (this.mustBePersisted()) {
|
|
1893 |
TXMPreferences.flush(this);
|
|
1894 |
}
|
1910 |
1895 |
|
|
1896 |
|
|
1897 |
this.dirty = false; // the computing was successful, the result is no more dirty
|
|
1898 |
this.hasBeenComputedOnce = true;
|
|
1899 |
this.needsFullRecomputing = false;
|
|
1900 |
|
|
1901 |
Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": computing of result type " + this.getClass() + " done.");
|
|
1902 |
|
|
1903 |
// set the children as dirty since the result has changed
|
1911 |
1904 |
for (int i = 0; i < this.children.size(); i++) {
|
1912 |
|
// FIXME: may be better to add a member needFullRecomputing in TXMResult?
|
1913 |
|
// this.getChild(i).setDirty(); // force recomputing even if some parameters of the result itself have not changed
|
1914 |
|
this.children.get(i).setNeedsFullRecomputing(true); // force recomputing even if some parameters of the result itself have not changed
|
1915 |
|
|
1916 |
|
// recompute only children that has been opened once
|
1917 |
|
//if (child.hasBeenComputedOnce()) {
|
1918 |
|
this.children.get(i).compute(monitor, deepComputing);
|
1919 |
|
//}
|
|
1905 |
this.children.get(i).setDirty();
|
1920 |
1906 |
}
|
1921 |
1907 |
|
1922 |
|
// FIXME: SJ: this code generates concurrent modification excpetions when deep computing
|
1923 |
|
// here for tests purpose
|
|
1908 |
// Children cascade computing ; if parent == null this is the Workspace
|
|
1909 |
if (deepComputing && parent != null) {
|
|
1910 |
|
|
1911 |
Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": cascade computing of " + this.children.size() + " children.");
|
|
1912 |
|
|
1913 |
|
|
1914 |
for (int i = 0; i < this.children.size(); i++) {
|
|
1915 |
// FIXME: may be better to add a member needFullRecomputing in TXMResult?
|
|
1916 |
// this.getChild(i).setDirty(); // force recomputing even if some parameters of the result itself have not changed
|
|
1917 |
this.children.get(i).setNeedsFullRecomputing(true); // force recomputing even if some parameters of the result itself have not changed
|
|
1918 |
|
|
1919 |
// recompute only children that has been opened once
|
|
1920 |
//if (child.hasBeenComputedOnce()) {
|
|
1921 |
this.children.get(i).compute(monitor, deepComputing);
|
|
1922 |
//}
|
|
1923 |
}
|
|
1924 |
|
|
1925 |
// FIXME: SJ: this code generates concurrent modification excpetions when deep computing
|
|
1926 |
// here for tests purpose
|
1924 |
1927 |
// for (TXMResult child : this.getChildren()) {
|
1925 |
1928 |
// child.setNeedsFullRecomputing(true); // force recomputing even if some parameters of the result itself have not changed
|
1926 |
1929 |
// // recompute only children that has been opened once
|
1927 |
1930 |
// child.compute(monitor, deepComputing);
|
1928 |
1931 |
// }
|
1929 |
|
|
|
1932 |
|
|
1933 |
}
|
1930 |
1934 |
}
|
1931 |
1935 |
}
|
1932 |
|
|
|
1936 |
catch (Exception e) {
|
|
1937 |
// TODO Auto-generated catch block
|
|
1938 |
e.printStackTrace();
|
|
1939 |
Log.severe("TXMResult.compute(): Exception occurs during computing.");
|
|
1940 |
return false;
|
|
1941 |
}
|
1933 |
1942 |
|
1934 |
1943 |
return true;
|
1935 |
1944 |
}
|
... | ... | |
2244 |
2253 |
public ArrayList<HashMap<String, Object>> getParametersHistory() {
|
2245 |
2254 |
return parametersHistory;
|
2246 |
2255 |
}
|
2247 |
|
|
2248 |
|
/**
|
2249 |
|
*
|
2250 |
|
* @return the first parent which visible state is true
|
2251 |
|
*/
|
2252 |
|
public TXMResult getFirstVisibleParent() {
|
2253 |
|
if (parent == null) return null;
|
2254 |
|
else if (parent.isVisible()) return parent;
|
2255 |
|
else return parent.getFirstVisibleParent();
|
2256 |
|
}
|
2257 |
2256 |
}
|