Révision 1540
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 1540) | ||
---|---|---|
1264 | 1264 |
} |
1265 | 1265 |
|
1266 | 1266 |
/** |
1267 |
* Sets a parameters from its parameter annotation "key".
|
|
1267 |
* Sets a parameter from its parameter annotation "key". |
|
1268 | 1268 |
* @param key |
1269 | 1269 |
* @param value |
1270 | 1270 |
* @return |
... | ... | |
1275 | 1275 |
} |
1276 | 1276 |
|
1277 | 1277 |
/** |
1278 |
* Sets a parameters from its parameter annotation "key".
|
|
1278 |
* Sets a parameter from its parameter annotation "key". |
|
1279 | 1279 |
* @param key |
1280 | 1280 |
* @param value |
1281 |
* @param propagateToParent propagate the key=value to parent if the result has no field=key
|
|
1281 |
* @param propagateToParent propagates the key=value to the parents if the result has no field=key
|
|
1282 | 1282 |
* |
1283 | 1283 |
* @return |
1284 | 1284 |
* @throws Exception |
... | ... | |
1302 | 1302 |
|
1303 | 1303 |
if (targetField != null) { |
1304 | 1304 |
targetField.setAccessible(true); |
1305 |
|
|
1306 |
// FIXME: debug |
|
1307 |
//if(value != null) { |
|
1308 |
// Log.info("TXMResult.setParameter(): setting parameter " + key + " = " + value + " for " + this.getClass() + " (" + value.getClass() + ")"); |
|
1309 |
//} |
|
1310 |
|
|
1311 | 1305 |
targetField.set(this, value); |
1312 | 1306 |
} |
1313 | 1307 |
else if (this.parent != null && propagateToParent) { |
... | ... | |
1375 | 1369 |
* Deletes all non persistent results and saves the results to persist. |
1376 | 1370 |
*/ |
1377 | 1371 |
public static void deleteAllNonPersistentResults() { |
1378 |
// File logs = new File(System.getProperty("user.home"), "logs.txt"); |
|
1379 |
// PrintWriter w = null; |
|
1380 |
try { |
|
1381 |
// w = IOUtils.getWriter(logs); |
|
1382 |
List<TXMResult> todo = Toolbox.workspace.getChildren(); |
|
1383 |
while (todo.size() > 0) { |
|
1384 |
TXMResult r = null; |
|
1385 |
// try { |
|
1386 |
r = todo.remove(0); |
|
1387 |
todo.addAll(0, r.getChildren()); |
|
1388 |
// w.println("Persisting? "+r); |
|
1389 |
if (r.mustBePersisted()) { |
|
1390 |
// w.println(" YES"); |
|
1391 |
TXMPreferences.flush(r); |
|
1392 |
} |
|
1393 |
else { |
|
1394 |
// w.println(" NO"); |
|
1395 |
Log.finest("TXMResult.deleteAllNonPersistentResults(): Deleting result " + r.getSimpleName() + " of type " + r.getClass().getSimpleName() + "."); |
|
1396 |
TXMPreferences.delete(r); |
|
1397 |
} |
|
1398 |
// } catch (Exception e) { |
|
1399 |
// w.println(" Error: "+e+" with "+r); |
|
1400 |
// } |
|
1401 |
// w.println(" OK: "+r); |
|
1402 |
} |
|
1403 |
} finally { |
|
1404 |
// if (w != null) w.close(); |
|
1372 |
List<TXMResult> todo = Toolbox.workspace.getChildren(); |
|
1373 |
while (todo.size() > 0) { |
|
1374 |
TXMResult r = null; |
|
1375 |
r = todo.remove(0); |
|
1376 |
todo.addAll(0, r.getChildren()); |
|
1377 |
if (r.mustBePersisted()) { |
|
1378 |
TXMPreferences.flush(r); |
|
1379 |
} |
|
1380 |
else { |
|
1381 |
Log.finest("TXMResult.deleteAllNonPersistentResults(): Deleting result " + r.getSimpleName() + " of type " + r.getClass().getSimpleName() + "."); |
|
1382 |
TXMPreferences.delete(r); |
|
1383 |
} |
|
1405 | 1384 |
} |
1406 | 1385 |
} |
1407 | 1386 |
|
... | ... | |
1429 | 1408 |
*/ |
1430 | 1409 |
private boolean addChild(TXMResult child) { |
1431 | 1410 |
try { |
1432 |
// do nothing if the parent is already this result |
|
1433 |
// if(child.getParent() == this) { |
|
1434 |
// return true; |
|
1435 |
// } |
|
1436 |
// else { |
|
1437 | 1411 |
// remove from current parent if exists |
1438 | 1412 |
child.removeFromParent(); |
1439 | 1413 |
|
1440 | 1414 |
child.setParent(this); |
1441 | 1415 |
if (!this.children.contains(child)) { |
1442 |
// FIXME: Debug |
|
1443 |
// System.err.println("TXMResult.addResult(); adding child " + |
|
1444 |
// child + " to parent " + this); |
|
1445 | 1416 |
return this.children.add(child); |
1446 | 1417 |
} |
1447 | 1418 |
// } |
... | ... | |
1462 | 1433 |
try { |
1463 | 1434 |
if (!this.children.contains(child)) { |
1464 | 1435 |
child.setParent(this); |
1465 |
// FIXME: Debug |
|
1466 |
// System.err.println("TXMResult.addResult(); adding child " + |
|
1467 |
// child + " to parent " + this); |
|
1468 | 1436 |
this.children.add(index, child); |
1469 | 1437 |
return true; |
1470 | 1438 |
} |
... | ... | |
1756 | 1724 |
return this.getDeepChildren().contains(child); |
1757 | 1725 |
} |
1758 | 1726 |
|
1759 |
|
|
1760 |
// /** |
|
1761 |
// * Gets the first parent of the specified class, eg. this.getFirstParent(Partition.class); |
|
1762 |
// * Returns the object itself if it is of the specified class. |
|
1763 |
// * @param type |
|
1764 |
// * @return null if the TXMResult is not attached to a BinaryCorpus |
|
1765 |
// */ |
|
1766 |
// public Project getCorpusProject() { |
|
1767 |
// Object o = getFirstParent(Project.class); |
|
1768 |
// if (o != null) { |
|
1769 |
// return (Project)o; |
|
1770 |
// } else { |
|
1771 |
// return null; |
|
1772 |
// } |
|
1773 |
// } |
|
1774 |
// |
|
1775 |
// /** |
|
1776 |
// * Gets the first parent of the specified class, eg. this.getFirstParent(Partition.class); |
|
1777 |
// * Returns the object itself if it is of the specified class. |
|
1778 |
// * @param type |
|
1779 |
// * @return null if the TXMResult is not attached to a BinaryCorpus |
|
1780 |
// */ |
|
1781 |
// public CorpusBuild getCorpusBuild() { |
|
1782 |
// Object o = getFirstParent(CorpusBuild.class); |
|
1783 |
// if (o != null) { |
|
1784 |
// return (CorpusBuild)o; |
|
1785 |
// } else { |
|
1786 |
// return null; |
|
1787 |
// } |
|
1788 |
// } |
|
1789 |
|
|
1790 | 1727 |
/** |
1791 | 1728 |
* Gets the sibling nodes of this node result. |
1792 | 1729 |
*/ |
Formats disponibles : Unified diff