Fixed Termination and Building Workflowitem loading

This commit is contained in:
Frank Schubert
2022-02-17 21:34:53 +01:00
parent b63640e232
commit 08630e9942
6 changed files with 63 additions and 43 deletions
+16 -20
View File
@@ -35,8 +35,9 @@ class Termination extends mfBaseModel {
return $address;
}
public function loadWorkflowItems() {
$item_ids = [];
//$this->log->debug("in loadWorkflowItems() - terminstaiton_id: ".$this->id);
$term_wfitems = mfValuecache::singleton()->get("wfitems-term-active");
if(!$term_wfitems) {
@@ -45,32 +46,28 @@ class Termination extends mfBaseModel {
}
foreach($term_wfitems as $item) {
$item->setObjectId($this->id);
$this->workflowitems[$item->name] = $item;
mfValuecache::singleton()->set("wfTerm-name-".$item->name, $item);
mfValuecache::singleton()->set("wfTerm-id-".$item->id, $item);
$item_ids[] = $item->id;
$item->setObjectId($this->id);
$new_value = new Workflowvalue();
$new_value->item_id = $item->id;
$new_value->object_id = $this->id;
//$this->log->debug("empty value has item_id: ".$new_value->item_id." - object_id: ".$new_value->object_id. ". Goes into cache as wfItemvalue-item-".$item->id."-object-".$this->id." value: ".$new_value->value_string);
mfValuecache::singleton()->set("wfItemvalue-item-".$item->id."-object-".$this->id, $new_value);
$item->setValue($new_value);
$this->workflowitems[$item->name] = $item;
}
foreach($item_ids as $id) {
mfValuecache::singleton()->set("wfItemvalue-item-".$id."-object-".$this->id, new Workflowvalue());
}
// get values
$values = WorkflowvalueModel::search(["object_id" => $this->id]);
//var_dump($values);exit;
foreach($values as $value) {
if(array_key_exists($value->item->name, $this->workflowitems)) {
//var_dump($value);exit;
$this->workflowitems[$value->item->name]->setValue($value);
mfValuecache::singleton()->set("wfItemvalue-item-".$value->item_id."-object-".$this->id, $value);
}
}
/*if($this->id == 42) {
//var_dump(array_keys(mfValuecache::singleton()->getCache()));exit;
var_dump(mfValuecache::singleton()->get("wfItemvalue-item-20-object-42"));exit;
}*/
}
public function getWorkflowvalue($itemname, $type = false) {
@@ -83,6 +80,7 @@ class Termination extends mfBaseModel {
mfValuecache::singleton()->set("wfTerm-name-".$itemname, $item);
mfValuecache::singleton()->set("wfTerm-id-".$item->id, $item);
}
$item->setObjectId($this->id);
switch($item->type) {
case "string":
@@ -116,9 +114,8 @@ class Termination extends mfBaseModel {
$value_type = "string";
}
if(array_key_exists($itemname, $this->getProperty("workflowitems"))) {
//$this->log->debug(__FILE__.": $itemname => ".$this->getProperty("workflowitems")[$itemname]->value->{"value_$value_type"});
return $this->getProperty("workflowitems")[$itemname]->value->{"value_$value_type"};
if(array_key_exists($itemname, $this->workflowitems)) {
return $this->workflowitems[$itemname]->value->{"value_$value_type"};
}
return null;
@@ -142,7 +139,6 @@ class Termination extends mfBaseModel {
$done = true;
foreach($item_names as $name) {
//$this->log->debug(__FILE__.": (Termination ".$this->id.") $name => $type == '".$this->getWorkflowvalue($name)."' (ist: '".$this->getWorkflowvalue("ist_".$name)."')");
if(!strlen($this->getWorkflowvalue($name)) && !strlen($this->getWorkflowvalue("ist_".$name))) {
$done = false;
break;