views:

12

answers:

0

Hi, I still didn't discovered a widely accepted pattern for following situation:

In the database, a three-level deep series of tasks exists.

  1. Main task: gather data for user X; report data;
  2. Sub-task: ensure that all data is fetched and is correct; report success or errors
  3. Minimal task: get a piece of data from network, match it against some template (described by both levels above); report I/O errors or template matching errors.

Currently I am only sure to have a comparator object that checks minimal task's state, and a two state transaction machines, first to check minimal task's and second to implement a state advance over all three levels.

But don't want to write a braindead code that will suffer just because of task state access methods spread between sub-objects/methods, so parent-state->child-state->action-state relations are seem to be bad idea, resulting in a code like if ($level1object->subtasks->subtasks->subtasks_completed) { ... }.

Patternized code should either just look clean and have just getNextMiniTask .. getErrorStateForMainTask methods, or use some other architecture to watch over tasks.

Looking for a good sample of such a job queue, since don't want to invent a square wheel bike. abstract, Java, SQL stored procedures/Hibernate, PHP welcome.

P.S. Suggesting it may result in a some form of n-dimensional tree, where possible decisions are making sub-levels or making the whole branch to stop and throw error. However, still looking for sample code.