|
Lines 57-62
Link Here
|
| 57 |
* @author Mik Kersten |
57 |
* @author Mik Kersten |
| 58 |
* @author Ken Sueda |
58 |
* @author Ken Sueda |
| 59 |
* @author Rob Elves |
59 |
* @author Rob Elves |
|
|
60 |
* @author Jevgeni Holodkov |
| 60 |
* |
61 |
* |
| 61 |
* TODO: move to core? |
62 |
* TODO: move to core? |
| 62 |
*/ |
63 |
*/ |
|
Lines 338-345
Link Here
|
| 338 |
} |
339 |
} |
| 339 |
} |
340 |
} |
| 340 |
|
341 |
|
| 341 |
private void readQuery(TaskList taskList, Node child) { |
342 |
/** |
| 342 |
boolean wasRead = false; |
343 |
* Reads the Query from the specified Node. If taskList is not null, then also adds this query to the TaskList |
|
|
344 |
*/ |
| 345 |
private AbstractRepositoryQuery readQuery(TaskList taskList, Node child) { |
| 346 |
AbstractRepositoryQuery query = null; |
| 343 |
for (AbstractTaskListFactory externalizer : externalizers) { |
347 |
for (AbstractTaskListFactory externalizer : externalizers) { |
| 344 |
Set<String> queryTagNames = externalizer.getQueryElementNames(); |
348 |
Set<String> queryTagNames = externalizer.getQueryElementNames(); |
| 345 |
if (queryTagNames != null && queryTagNames.contains(child.getNodeName())) { |
349 |
if (queryTagNames != null && queryTagNames.contains(child.getNodeName())) { |
|
Lines 355-386
Link Here
|
| 355 |
label = childElement.getAttribute(DelegatingTaskExternalizer.KEY_LABEL); |
359 |
label = childElement.getAttribute(DelegatingTaskExternalizer.KEY_LABEL); |
| 356 |
} |
360 |
} |
| 357 |
|
361 |
|
| 358 |
AbstractRepositoryQuery query = externalizer.createQuery(repositoryUrl, |
362 |
query = externalizer.createQuery(repositoryUrl, queryString, label, childElement); |
| 359 |
queryString, label, childElement); |
|
|
| 360 |
if (query != null) { |
363 |
if (query != null) { |
| 361 |
wasRead = true; |
|
|
| 362 |
if (childElement.getAttribute(DelegatingTaskExternalizer.KEY_LAST_REFRESH) != null |
364 |
if (childElement.getAttribute(DelegatingTaskExternalizer.KEY_LAST_REFRESH) != null |
| 363 |
&& !childElement.getAttribute( |
365 |
&& !childElement.getAttribute( |
| 364 |
DelegatingTaskExternalizer.KEY_LAST_REFRESH).equals("")) { |
366 |
DelegatingTaskExternalizer.KEY_LAST_REFRESH).equals("")) { |
| 365 |
query.setLastSynchronizedStamp(childElement.getAttribute(DelegatingTaskExternalizer.KEY_LAST_REFRESH)); |
367 |
query.setLastSynchronizedStamp(childElement.getAttribute(DelegatingTaskExternalizer.KEY_LAST_REFRESH)); |
| 366 |
} |
368 |
} |
| 367 |
taskList.internalAddQuery(query); |
|
|
| 368 |
} |
369 |
} |
| 369 |
NodeList queryChildren = child.getChildNodes(); |
370 |
|
| 370 |
for (int ii = 0; ii < queryChildren.getLength(); ii++) { |
371 |
// add created Query to the TaskList and read QueryHits (Tasks related to the Query) |
| 371 |
Node queryNode = queryChildren.item(ii); |
372 |
if (taskList != null) { |
| 372 |
try { |
373 |
if (query != null) { |
| 373 |
delagatingExternalizer.readQueryHit((Element) queryNode, taskList, query); |
374 |
taskList.internalAddQuery(query); |
| 374 |
} catch (TaskExternalizationException e) { |
375 |
} |
| 375 |
hasCaughtException = true; |
376 |
|
|
|
377 |
NodeList queryChildren = child.getChildNodes(); |
| 378 |
for (int ii = 0; ii < queryChildren.getLength(); ii++) { |
| 379 |
Node queryNode = queryChildren.item(ii); |
| 380 |
try { |
| 381 |
delagatingExternalizer.readQueryHit((Element) queryNode, taskList, query); |
| 382 |
} catch (TaskExternalizationException e) { |
| 383 |
hasCaughtException = true; |
| 384 |
} |
| 376 |
} |
385 |
} |
| 377 |
} |
386 |
} |
|
|
387 |
|
| 388 |
|
| 378 |
break; |
389 |
break; |
| 379 |
} |
390 |
} |
| 380 |
} |
391 |
} |
| 381 |
if (!wasRead) { |
392 |
if (query == null) { |
| 382 |
orphanedQueryNodes.add(child); |
393 |
orphanedQueryNodes.add(child); |
| 383 |
} |
394 |
} |
|
|
395 |
|
| 396 |
return query; |
| 384 |
} |
397 |
} |
| 385 |
|
398 |
|
| 386 |
/** |
399 |
/** |
|
Lines 507-520
Link Here
|
| 507 |
return; |
520 |
return; |
| 508 |
} |
521 |
} |
| 509 |
|
522 |
|
| 510 |
public void readQueries(TaskList taskList, File inFile) { |
523 |
public List<AbstractRepositoryQuery> readQueries(File inFile) { |
|
|
524 |
List<AbstractRepositoryQuery> queries = new ArrayList<AbstractRepositoryQuery>(); |
| 511 |
try { |
525 |
try { |
| 512 |
if (!inFile.exists()) |
526 |
if (!inFile.exists()) |
| 513 |
return; |
527 |
return queries; |
| 514 |
Document doc = openAsDOM(inFile); |
528 |
Document doc = openAsDOM(inFile); |
| 515 |
if (doc == null) { |
529 |
if (doc == null) { |
| 516 |
handleException(inFile, null, new TaskExternalizationException("TaskList was not well formed XML")); |
530 |
handleException(inFile, null, new TaskExternalizationException("TaskList was not well formed XML")); |
| 517 |
return; |
531 |
return queries; |
| 518 |
} |
532 |
} |
| 519 |
Element root = doc.getDocumentElement(); |
533 |
Element root = doc.getDocumentElement(); |
| 520 |
readVersion = root.getAttribute(ATTRIBUTE_VERSION); |
534 |
readVersion = root.getAttribute(ATTRIBUTE_VERSION); |
|
Lines 527-533
Link Here
|
| 527 |
Node child = list.item(i); |
541 |
Node child = list.item(i); |
| 528 |
try { |
542 |
try { |
| 529 |
if (child.getNodeName().endsWith(AbstractTaskListFactory.KEY_QUERY)) { |
543 |
if (child.getNodeName().endsWith(AbstractTaskListFactory.KEY_QUERY)) { |
| 530 |
readQuery(taskList, child); |
544 |
AbstractRepositoryQuery query = readQuery(null, child); |
|
|
545 |
if (query != null) { |
| 546 |
queries.add(query); |
| 547 |
} |
| 531 |
} |
548 |
} |
| 532 |
} catch (Exception e) { |
549 |
} catch (Exception e) { |
| 533 |
handleException(inFile, child, e); |
550 |
handleException(inFile, child, e); |
|
Lines 540-548
Link Here
|
| 540 |
handleException(inFile, null, e); |
557 |
handleException(inFile, null, e); |
| 541 |
} |
558 |
} |
| 542 |
|
559 |
|
| 543 |
if (!hasCaughtException) { |
560 |
return queries; |
| 544 |
// save new task list only if there were no exception! |
|
|
| 545 |
writeTaskList(taskList, inFile); |
| 546 |
} |
| 547 |
} |
561 |
} |
| 548 |
} |
562 |
} |