19 require_once(BASE.
"wcmf/application/controller/class.BatchController.php");
20 require_once(BASE.
"wcmf/lib/persistence/class.PersistenceFacade.php");
21 require_once(BASE.
"wcmf/lib/model/class.PersistentIterator.php");
22 require_once(BASE.
"wcmf/lib/model/class.Node.php");
23 require_once(BASE.
"wcmf/lib/model/class.NodeUtil.php");
49 var
$REQUEST =
'BatchDisplayController.request';
61 parent::initialize($request, $response);
64 if ($request->getAction() !=
'continue')
69 if (!$request->hasValue(
'nodes_per_call')) {
70 $request->setValue(
'nodes_per_call', $this->_NODES_PER_CALL);
72 if (!$request->hasValue(
'translateValues')) {
73 $request->setValue(
'translateValues',
true);
77 $session->set($this->REQUEST, $request, array(BASE.
"wcmf/lib/presentation/class.ControllerMessage.php"));
79 $session->set($this->REGISTRY, $reg);
87 if ($this->_request->getAction() !=
'continue')
90 if(strlen($this->_request->getValue(
'oid')) == 0)
97 return parent::validate();
105 return array(
'name' =>
Message::get(
'Loading'),
'size' => 1,
'oids' => array(1),
'callback' =>
'startProcess');
116 return $this->_workPackages[$step-1][
'name'].
" ...";
127 $request = $session->get($this->REQUEST);
128 $nodeOID = $request->getValue(
'oid');
132 $iteratorID = $iterator->save();
133 $session->set($this->ITERATOR_ID, $iteratorID);
136 $this->
loadNode($iterator->getCurrentOID());
138 $iterator->proceed();
141 if (!$iterator->isEnd())
143 $iteratorID = $iterator->save();
144 $session->set($this->ITERATOR_ID, $iteratorID);
146 $name =
Message::get(
'Loading tree: continue with %1%', array($iterator->getCurrentOID()));
164 $request = $session->get($this->REQUEST);
168 $iteratorID = $session->get($this->ITERATOR_ID);
169 if ($iteratorID != null) {
174 if ($iterator == null)
182 while (!$iterator->isEnd() && $counter < $request->getValue(
'nodes_per_call'))
184 $currentOID = $iterator->getCurrentOID();
187 $iterator->proceed();
192 if (!$iterator->isEnd())
195 $iteratorID = $iterator->save();
196 $session->set($this->ITERATOR_ID, $iteratorID);
198 $name =
Message::get(
'Loading tree: continue with %1%', array($iterator->getCurrentOID()));
216 $session->set($this->REQUEST, $tmp);
217 $session->set($this->REGISTRY, $tmp);
218 $session->set($this->ITERATOR_ID, $tmp);
234 $request = $session->get($this->REQUEST);
237 $node = &$persistenceFacade->load($oid, BUIDLDEPTH_SINGLE);
246 $localization->loadTranslation($node, $request->getValue(
'language'),
true,
true);
250 if ($request->getBooleanValue(
'translateValues'))
252 $nodes = array($node);
264 $this->
register($oid);
267 Log::info(
"Loaded: ".$node->getOID(), __CLASS__);
277 function register($oid)
280 $registry = $session->get($this->REGISTRY);
281 array_push($registry, $oid);
282 $session->set($this->REGISTRY, $registry);
292 $registry = $session->get($this->REGISTRY);
294 return in_array($oid, $registry);
302 if (!$this->_response->hasValue(
'objects')) {
304 $this->_response->setValue(
'objects', $objects);
307 $objects = &$this->_response->getValue(
'objects');
308 $objects[
sizeof($objects)] = &$node;
309 $this->_response->setValue(
'objects', $objects);
debug($message, $category)
get($message, $parameters=null, $domain='', $lang='')
BatchDisplayController is a controller that loads a tree of Nodes recursivly and returns the Nodes in...
info($message, $category)
initialize(&$request, &$response)
throwEx($message, $file='', $line='')
addNodeToResponse(&$node)
translateValues(&$nodes, $language=null)
isDebugEnabled($category)
addWorkPackage($name, $size, $oids, $callback, $args=null)
PersistentIterator is used to iterate over a tree/list build of oids using a Depth-First-Algorithm. To persist its state use the PersistentIterator::save() method, to restore its state use the static PersistentIterator::load() method, which returns the loaded instance. States are identified by an unique id, which is provided after saving. PersistentIterator implements the 'Iterator Pattern'.
BatchController allows to define work packages that will be processed in a sequence. It simplifies the usage of LongTaskController functionality for splitting different bigger tasks into many smaller (similar) tasks where the whole number of tasks isn't known at designtime.