Beispiel #1
0
 public function __construct($prjUid)
 {
     $this->prjUid = $prjUid;
     $this->bpmnProject = Project\Bpmn::load($prjUid);
     $this->projectData = $this->bpmnProject->getProject();
     $this->metadata = array("vendor_version" => \System::getVersion(), "vendor_version_code" => "Michelangelo", "export_timestamp" => date("U"), "export_datetime" => date("Y-m-d\\TH:i:sP"), "export_server_addr" => isset($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] . ":" . $_SERVER["SERVER_PORT"] : "Unknown", "export_server_os" => PHP_OS, "export_server_php_version" => PHP_VERSION_ID);
 }
Beispiel #2
0
    /**
     * Get in base64 the image process (processmap)
     *
     * @url GET /process/:pro_uid/case
     *
     * @param string $prj_uid {@min 32}{@max 32}
     * @param string $app_uid {@min 32}{@max 32}{@from path}
     */
    public function doGetProcessMapImage($pro_uid, $app_uid = null)
    {
        $return = array();
        try {
            $oPMap = new \ProcessMaker\BusinessModel\ProcessMap();
            $schema = Adapter\BpmnWorkflow::getStruct($pro_uid);

            $schemaStatus = array();
            if (!is_null($app_uid)) {
                $case = new \ProcessMaker\BusinessModel\Cases();
                $case->setFormatFieldNameInUppercase(false);
                $schemaStatus = $case->getTasks($app_uid);
            }

            $file = $oPMap->get_image($schema, $schemaStatus);
            ob_start();
            imagepng($file);
            $image  = ob_get_clean();
            $return["map"] = base64_encode($image);

        } catch (\Exception $e) {
            throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
        }
        return $return;
    }
Beispiel #3
0
 /**
  * @param string $prj_uid {@min 1}{@max 32}
  * @url DELETE /:prj_uid
  */
 public function delete($prj_uid)
 {
     try {
         $oBpmnWf = Adapter\BpmnWorkflow::load($prj_uid);
         $oBpmnWf->remove();
     } catch (\Exception $e) {
         throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
     }
 }
Beispiel #4
0
    /**
     * Update project from a struct defined.
     *
     * This function make add, update or delete of elements of a project
     * Actions is based on a diff from project save in Db and the given structure as param, by the following criteria.
     *
     * 1. Elements that are on the struct, but they are not in the Db will be created on Db
     * 2. Elements that are on the struct and they are found in db, will be compared, if they have been modified then will be updated on Db
     * 3. Elements found in Db but they are not present on the struct will be considered deleted, so they will be deleted from Db.
     *
     * Example Struct:
     *  array(
     *    "prj_uid" => "25111170353317e324d6e23073851309",
     *    "prj_name" => "example project",
     *    "prj_description" => "project desc.",
     *    ...
     *    "diagrams" => array(
     *      array(
     *        "dia_uid" => "94208559153317e325f1c24068030751",
     *        "dia_name" => "Example Diagram",
     *        ...
     *        "activities" => array(...),
     *        "events" => array(...),
     *        "gateways" => array(...),
     *        "flows" => array(...),
     *        "artifacts" => array(...),
     *        "laneset" => array(...),
     *        "lanes" => array(...)
     *      )
     *    )
     *  )
     *
     * Notes:
     *   1. All elements keys are in lowercase
     *   2. the "diagrams" element is an array of arrays
     *
     * @param $prjUid
     * @param $projectData
     * @return array
     */
    public static function updateFromStruct($prjUid, $projectData, $generateUid = true, $forceInsert = false)
    {
        $diagram = isset($projectData["diagrams"]) && isset($projectData["diagrams"][0]) ? $projectData["diagrams"][0] : array();
        $diagram["activities"] = isset($diagram["activities"])? $diagram["activities"]: array();
        $diagram["artifacts"]  = isset($diagram["artifacts"])? $diagram["artifacts"]: array();
        $diagram["gateways"] = isset($diagram["gateways"])? $diagram["gateways"]: array();
        $diagram["events"] = isset($diagram["events"])? $diagram["events"]: array();
        $diagram["data"] = isset($diagram["data"])? $diagram["data"]: array();
        $diagram["participants"] = isset($diagram["participants"])? $diagram["participants"]: array();
        $diagram["laneset"] = isset($diagram["laneset"])? $diagram["laneset"]: array();
        $diagram["lanes"] = isset($diagram["lanes"])? $diagram["lanes"]: array();

        $result = array();

        $projectData['prj_uid'] = $prjUid;

        $bwp = BpmnWorkflow::load($prjUid);

        $projectRecord = array_change_key_case($projectData, CASE_UPPER);

        $bwp->update($projectRecord);

        //Array - Set empty
        $bwp->arrayElementTaskRelation = array();

        //Element-Task-Relation - Get all records
        $criteria = new \Criteria("workflow");

        $criteria->addSelectColumn(\ElementTaskRelationPeer::ELEMENT_UID);
        $criteria->addSelectColumn(\ElementTaskRelationPeer::TAS_UID);

        $criteria->add(\ElementTaskRelationPeer::PRJ_UID, $bwp->wp->getUid(), \Criteria::EQUAL);

        $rsCriteria = \ElementTaskRelationPeer::doSelectRS($criteria);
        $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);

        while ($rsCriteria->next()) {
            $row = $rsCriteria->getRow();

            //Array - Add element
            $bwp->arrayElementTaskRelation[$row["ELEMENT_UID"]] = $row["TAS_UID"];
        }

        /*
         * Diagram's Laneset Handling
         */
        $whiteList = array();
        foreach ($diagram["laneset"] as $i => $lanesetData) {
            $lanesetData = array_change_key_case($lanesetData, CASE_UPPER);

            $dataObject = $bwp->getLaneset($lanesetData["LNS_UID"]);

            if ($forceInsert || is_null($dataObject)) {
                if ($generateUid) {
                    //Generate and update UID
                    unset($lanesetData["BOU_UID"]);

                    $uidOld = $lanesetData["LNS_UID"];
                    $lanesetData["LNS_UID"] = Util\Common::generateUID();

                    $result[] = array(
                        "object"  => "laneset",
                        "old_uid" => $uidOld,
                        "new_uid" => $lanesetData["LNS_UID"]
                    );
                }
                $bwp->addLaneset($lanesetData);
            } elseif (! $bwp->isEquals($dataObject, $lanesetData)) {
                $bwp->updateLaneset($lanesetData["LNS_UID"], $lanesetData);
            } else {
                Util\Logger::log("Update Laneset ({$lanesetData["LNS_UID"]}) Skipped - No changes required");
            }

            $diagram["laneset"][$i] = $lanesetData;
            $whiteList[] = $lanesetData["LNS_UID"];
        }

        $dataCollection = $bwp->getLanesets();

        // looking for removed elements
        foreach ($dataCollection as $lanesetData) {
            if (! in_array($lanesetData["LNS_UID"], $whiteList)) {
                // If it is not in the white list, then remove them
                $bwp->removeLaneset($lanesetData["LNS_UID"]);
            }
        }

        /*
         * Diagram's Lane Handling
         */
        $whiteList = array();
        foreach ($diagram["lanes"] as $i => $laneData) {
            $laneData = array_change_key_case($laneData, CASE_UPPER);

            //Update UIDs
            foreach ($result as $value) {
                if ($laneData["LNS_UID"] == $value["old_uid"]) {
                    $laneData["LNS_UID"] = $value["new_uid"];
                }
            }

            $dataObject = $bwp->getLane($laneData["LAN_UID"]);

            if ($forceInsert || is_null($dataObject)) {
                if ($generateUid) {
                    //Generate and update UID
                    unset($laneData["BOU_UID"]);

                    $uidOld = $laneData["LAN_UID"];
                    $laneData["LAN_UID"] = Util\Common::generateUID();

                    $result[] = array(
                        "object"  => "lane",
                        "old_uid" => $uidOld,
                        "new_uid" => $laneData["LAN_UID"]
                    );
                }
                $bwp->addLane($laneData);
            } elseif (! $bwp->isEquals($dataObject, $laneData)) {
                $bwp->updateLane($laneData["LAN_UID"], $laneData);
            } else {
                Util\Logger::log("Update Lane ({$laneData["LAN_UID"]}) Skipped - No changes required");
            }

            $diagram["lanes"][$i] = $laneData;
            $whiteList[] = $laneData["LAN_UID"];
        }

        $dataCollection = $bwp->getLanes();

        // looking for removed elements
        foreach ($dataCollection as $laneData) {
            if (! in_array($laneData["LAN_UID"], $whiteList)) {
                // If it is not in the white list, then remove them
                $bwp->removeLane($laneData["LAN_UID"]);
            }
        }

        /*
         * Diagram's Activities Handling
         */
        $whiteList = array();
        foreach ($diagram["activities"] as $i => $activityData) {
            $activityData = array_change_key_case($activityData, CASE_UPPER);
            unset($activityData["_EXTENDED"], $activityData["BOU_ELEMENT_ID"]);
            $activityData = Util\ArrayUtil::boolToIntValues($activityData);

            $activity = $bwp->getActivity($activityData["ACT_UID"]);

            if ($activity["BOU_CONTAINER"] != $activityData["BOU_CONTAINER"]) {
                $activity = null;
            }

            if ($forceInsert || is_null($activity)) {
                if ($generateUid) {
                    //Generate and update UID
                    $activityData = $bwp->updateBoundByArrayUid($activityData, $result);

                    $uidOld = $activityData["ACT_UID"];
                    $activityData["ACT_UID"] = Util\Common::generateUID();

                    $result[] = array(
                        "object"  => "activity",
                        "old_uid" => $uidOld,
                        "new_uid" => $activityData["ACT_UID"]
                    );
                }

                $bwp->addActivity($activityData);
            } elseif (! $bwp->isEquals($activity, $activityData)) {
                $bwp->updateActivity($activityData["ACT_UID"], $activityData);
            } else {
                Util\Logger::log("Update Activity ({$activityData["ACT_UID"]}) Skipped - No changes required");
            }

            $diagram["activities"][$i] = $activityData;
            $whiteList[] = $activityData["ACT_UID"];

        }

        $activities = $bwp->getActivities();

        // looking for removed elements
        foreach ($activities as $activityData) {
            if (! in_array($activityData["ACT_UID"], $whiteList)) {
                $bwp->removeActivity($activityData["ACT_UID"]);
            }
        }

        /*
         * Diagram's Artifacts Handling
         */
        $whiteList = array();
        foreach ($diagram["artifacts"] as $i => $artifactData) {
            $artifactData = array_change_key_case($artifactData, CASE_UPPER);
            unset($artifactData["_EXTENDED"]);

            $artifact = $bwp->getArtifact($artifactData["ART_UID"]);

            if ($artifact["BOU_CONTAINER"] != $artifactData["BOU_CONTAINER"]) {
                $artifact = null;
            }

            if ($forceInsert || is_null($artifact)) {
                if ($generateUid) {
                    //Generate and update UID
                    $artifactData = $bwp->updateBoundByArrayUid($artifactData, $result);

                    $uidOld = $artifactData["ART_UID"];
                    $artifactData["ART_UID"] = Util\Common::generateUID();

                    $result[] = array(
                        "object"  => "artifact",
                        "old_uid" => $uidOld,
                        "new_uid" => $artifactData["ART_UID"]
                    );
                }

                $bwp->addArtifact($artifactData);
            } elseif (! $bwp->isEquals($artifact, $artifactData)) {
                $bwp->updateArtifact($artifactData["ART_UID"], $artifactData);
            } else {
                Util\Logger::log("Update Artifact ({$artifactData["ART_UID"]}) Skipped - No changes required");
            }

            $diagram["artifacts"][$i] = $artifactData;
            $whiteList[] = $artifactData["ART_UID"];
        }

        $artifacts = $bwp->getArtifacts();
        // looking for removed elements
        foreach ($artifacts as $artifactData) {
            if (! in_array($artifactData["ART_UID"], $whiteList)) {
                $bwp->removeArtifact($artifactData["ART_UID"]);
            }
        }

        /*
         * Diagram's Gateways Handling
         */
        $arrayGatewayUid = array();
        $arrayGatewayParallelUid = array();
        $arrayGatewayUidToCheckConverging = array(); //PARALLEL, INCLUSIVE

        $whiteList = array();

        foreach ($diagram["gateways"] as $i => $gatewayData) {
            $gatewayData = array_change_key_case($gatewayData, CASE_UPPER);
            unset($gatewayData["_EXTENDED"]);

            $flagAddOrUpdate = false;

            $gateway = $bwp->getGateway($gatewayData["GAT_UID"]);

            if ($gateway["BOU_CONTAINER"] != $gatewayData["BOU_CONTAINER"]) {
                $gateway = null;
            }

            if ($forceInsert || is_null($gateway)) {
                if ($generateUid) {
                    //Generate and update UID
                    $gatewayData = $bwp->updateBoundByArrayUid($gatewayData, $result);

                    $uidOld = $gatewayData["GAT_UID"];
                    $gatewayData["GAT_UID"] = Util\Common::generateUID();

                    $result[] = array(
                        "object"  => "gateway",
                        "old_uid" => $uidOld,
                        "new_uid" => $gatewayData["GAT_UID"]
                    );
                }

                $bwp->addGateway($gatewayData);

                $flagAddOrUpdate = true;
            } elseif (! $bwp->isEquals($gateway, $gatewayData)) {
                $bwp->updateGateway($gatewayData["GAT_UID"], $gatewayData);

                $flagAddOrUpdate = true;
            } else {
                Util\Logger::log("Update Gateway ({$gatewayData["GAT_UID"]}) Skipped - No changes required");
            }

            if ($flagAddOrUpdate) {
                $arrayGatewayData = $bwp->getGateway($gatewayData["GAT_UID"]);

                switch ($arrayGatewayData["GAT_TYPE"]) {
                    case self::BPMN_GATEWAY_PARALLEL:
                        $arrayGatewayParallelUid[] = $gatewayData["GAT_UID"];
                        $arrayGatewayUidToCheckConverging[] = $gatewayData["GAT_UID"];
                        break;
                    case self::BPMN_GATEWAY_INCLUSIVE:
                        $arrayGatewayUidToCheckConverging[] = $gatewayData["GAT_UID"];
                        break;
                }
            }

            $arrayGatewayUid[$gatewayData["GAT_UID"]] = 1;

            $diagram["gateways"][$i] = $gatewayData;
            $whiteList[] = $gatewayData["GAT_UID"];
        }

        $gateways = $bwp->getGateways();

        // looking for removed elements
        foreach ($gateways as $gatewayData) {
            if (! in_array($gatewayData["GAT_UID"], $whiteList)) {
                $bwp->removeGateway($gatewayData["GAT_UID"]);
            }
        }

        /*
         * Diagram's Events Handling
         */
        $whiteList = array();
        foreach ($diagram["events"] as $i => $eventData) {
            $eventData = array_change_key_case($eventData, CASE_UPPER);

            unset($eventData["_EXTENDED"]);

            if (array_key_exists("EVN_CANCEL_ACTIVITY", $eventData)) {
                $eventData["EVN_CANCEL_ACTIVITY"] = $eventData["EVN_CANCEL_ACTIVITY"] ? 1 : 0;
            }

            if (array_key_exists("EVN_WAIT_FOR_COMPLETION", $eventData)) {
                $eventData["EVN_WAIT_FOR_COMPLETION"] = $eventData["EVN_WAIT_FOR_COMPLETION"] ? 1 : 0;
            }

            $event = $bwp->getEvent($eventData["EVN_UID"]);

            if ($event["BOU_CONTAINER"] != $eventData["BOU_CONTAINER"]) {
                $event = null;
            }

            if ($forceInsert || is_null($event)) {
                if ($generateUid) {
                    //Generate and update UID
                    $eventData = $bwp->updateBoundByArrayUid($eventData, $result);

                    $uidOld = $eventData["EVN_UID"];
                    $eventData["EVN_UID"] = Util\Common::generateUID();

                    $result[] = array(
                        "object"  => "event",
                        "old_uid" => $uidOld,
                        "new_uid" => $eventData["EVN_UID"]
                    );
                }

                $bwp->addEvent($eventData);
            } elseif (! $bwp->isEquals($event, $eventData)) {
                $bwp->updateEvent($eventData["EVN_UID"], $eventData);
            } else {
                Util\Logger::log("Update Event ({$eventData["EVN_UID"]}) Skipped - No changes required");
            }

            $diagram["events"][$i] = $eventData;
            $whiteList[] = $eventData["EVN_UID"];
        }

        $events = $bwp->getEvents();

        // looking for removed elements
        foreach ($events as $eventData) {
            if (! in_array($eventData["EVN_UID"], $whiteList)) {
                // If it is not in the white list, then remove them
                $bwp->removeEvent($eventData["EVN_UID"]);
            }
        }

        /*
         * Diagram's Data Handling
         */
        $whiteList = array();
        foreach ($diagram["data"] as $i => $dataObjectData) {
            $dataObjectData = array_change_key_case($dataObjectData, CASE_UPPER);
            unset($dataObjectData["_EXTENDED"]);

            $dataObject = $bwp->getData($dataObjectData["DAT_UID"]);

            if ($dataObject["BOU_CONTAINER"] != $dataObjectData["BOU_CONTAINER"]) {
                $dataObject = null;
            }

            if ($forceInsert || is_null($dataObject)) {
                if ($generateUid) {
                    //Generate and update UID
                    $dataObjectData = $bwp->updateBoundByArrayUid($dataObjectData, $result);

                    $uidOld = $dataObjectData["DAT_UID"];
                    $dataObjectData["DAT_UID"] = Util\Common::generateUID();

                    $result[] = array(
                        "object"  => "data",
                        "old_uid" => $uidOld,
                        "new_uid" => $dataObjectData["DAT_UID"]
                    );
                }

                $bwp->addData($dataObjectData);
            } elseif (! $bwp->isEquals($dataObject, $dataObjectData)) {
                $bwp->updateData($dataObjectData["DAT_UID"], $dataObjectData);
            } else {
                Util\Logger::log("Update Data ({$dataObjectData["DAT_UID"]}) Skipped - No changes required");
            }

            $diagram["data"][$i] = $dataObjectData;
            $whiteList[] = $dataObjectData["DAT_UID"];
        }

        $dataCollection = $bwp->getDataCollection();

        // looking for removed elements
        foreach ($dataCollection as $dataObjectData) {
            if (! in_array($dataObjectData["DAT_UID"], $whiteList)) {
                // If it is not in the white list, then remove them
                $bwp->removeData($dataObjectData["DAT_UID"]);
            }
        }

        /*
         * Diagram's Participant Handling
         */
        $whiteList = array();
        foreach ($diagram["participants"] as $i => $participantData) {
            $participantData = array_change_key_case($participantData, CASE_UPPER);
            unset($participantData["_EXTENDED"]);

            $participant = $bwp->getParticipant($participantData["PAR_UID"]);

            if ($participant["BOU_CONTAINER"] != $participantData["BOU_CONTAINER"]) {
                $participant = null;
            }

            if ($forceInsert || is_null($participant)) {
                if ($generateUid) {
                    //Generate and update UID
                    $participantData = $bwp->updateBoundByArrayUid($participantData, $result);

                    $uidOld = $participantData["PAR_UID"];
                    $participantData["PAR_UID"] = Util\Common::generateUID();

                    $result[] = array(
                        "object"  => "participant",
                        "old_uid" => $uidOld,
                        "new_uid" => $participantData["PAR_UID"]
                    );
                }

                $bwp->addParticipant($participantData);
            } elseif (! $bwp->isEquals($participant, $participantData)) {
                $bwp->updateParticipant($participantData["PAR_UID"], $participantData);
            } else {
                Util\Logger::log("Update Participant ({$participantData["PAR_UID"]}) Skipped - No changes required");
            }

            $diagram["participants"][$i] = $participantData;
            $whiteList[] = $participantData["PAR_UID"];
        }

        $dataCollection = $bwp->getParticipants();

        // looking for removed elements
        foreach ($dataCollection as $participantData) {
            if (! in_array($participantData["PAR_UID"], $whiteList)) {
                // If it is not in the white list, then remove them
                $bwp->removeParticipant($participantData["PAR_UID"]);
            }
        }

        /*
         * Diagram's Flows Handling
         */
        $arrayGatewayGatDefaultFlow = array();

        $whiteList = array();

        foreach ($diagram["flows"] as $i => $flowData) {
            $flowData = array_change_key_case($flowData, CASE_UPPER);

            // if it is a new flow record
            if ($forceInsert || ($generateUid && !\BpmnFlow::exists($flowData["FLO_UID"]))) {
                $uidOld = $flowData["FLO_UID"];
                $flowData["FLO_UID"] = Util\Common::generateUID();

                $result[] = array(
                    "object" => "flow",
                    "old_uid" => $uidOld,
                    "new_uid" => $flowData["FLO_UID"]
                );

                $mappedUid = self::mapUid($flowData["FLO_ELEMENT_ORIGIN"], $result);

                if ($mappedUid !== false) {
                    $flowData["FLO_ELEMENT_ORIGIN"] = $mappedUid;
                }

                $mappedUid = self::mapUid($flowData["FLO_ELEMENT_DEST"], $result);

                if ($mappedUid !== false) {
                    $flowData["FLO_ELEMENT_DEST"] = $mappedUid;
                }
            }

            //Update UIDs
            foreach ($result as $value) {
                if ($flowData["FLO_ELEMENT_ORIGIN"] == $value["old_uid"]) {
                    $flowData["FLO_ELEMENT_ORIGIN"] = $value["new_uid"];
                }

                if ($flowData["FLO_ELEMENT_DEST"] == $value["old_uid"]) {
                    $flowData["FLO_ELEMENT_DEST"] = $value["new_uid"];
                }
            }

            //Update condition
            if ($flowData["FLO_ELEMENT_ORIGIN_TYPE"] == "bpmnGateway" && in_array($flowData["FLO_ELEMENT_ORIGIN"], $arrayGatewayParallelUid)) {
                $flowData["FLO_CONDITION"] = "";
            }

            //Add element to array Gateway default flow
            if ($flowData["FLO_TYPE"] == "DEFAULT" && isset($arrayGatewayUid[$flowData["FLO_ELEMENT_ORIGIN"]])) {
                $arrayGatewayGatDefaultFlow[$flowData["FLO_ELEMENT_ORIGIN"]] = $flowData["FLO_UID"];
            }

            $diagram["flows"][$i] = $flowData;
            $whiteList[] = $flowData["FLO_UID"];
        }

        foreach ($diagram["flows"] as $flowData) {
            $flow = $bwp->getFlow($flowData["FLO_UID"]);
            if ($forceInsert || is_null($flow)) {
                $bwp->addFlow($flowData);
            } elseif (! $bwp->isEquals($flow, $flowData)) {
                $bwp->updateFlow($flowData["FLO_UID"], $flowData, $diagram["flows"]);
            } else {
                Util\Logger::log("Update Flow ({$flowData["FLO_UID"]}) Skipped - No changes required");
            }
        }

        $flows = $bwp->getFlows();

        // looking for removed elements
        foreach ($flows as $flowData) {
            if (! in_array($flowData["FLO_UID"], $whiteList)) {
                $bwp->removeFlow($flowData["FLO_UID"]);
            }
        }

        //Update BPMN_GATEWAY.GAT_DIRECTION
        foreach ($arrayGatewayUidToCheckConverging as $value) {
            $arrayGatewayData = $bwp->getGateway($value);

            if (!is_null($arrayGatewayData)) {
                $arrayFlow = \BpmnFlow::findAllBy(array(
                    \BpmnFlowPeer::FLO_TYPE              => array("MESSAGE", \Criteria::NOT_EQUAL),
                    \BpmnFlowPeer::FLO_ELEMENT_DEST      => $arrayGatewayData["GAT_UID"],
                    \BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE => "bpmnGateway"
                ));

                if (count($arrayFlow) > 1) {
                    $bwp->updateGateway($arrayGatewayData["GAT_UID"], array("GAT_DIRECTION" => "CONVERGING"));
                }
            }
        }

        //Update BPMN_GATEWAY.GAT_DEFAULT_FLOW
        foreach ($arrayGatewayGatDefaultFlow as $key => $value) {
            $bwp->updateGateway($key, array("GAT_DEFAULT_FLOW" => $value));
        }

        //Map Bpmn-Flows to Workflow-Routes
        $bwp->mapBpmnFlowsToWorkflowRoutes();

        //Return
        return $result;
    }
Beispiel #5
0
    protected function importBpmnTables(array $tables, $generateUid = false)
    {
        // Build BPMN project struct
        $project = $tables["project"][0];
        $diagram = $tables["diagram"][0];
        $diagram["activities"] = $tables["activity"];
        $diagram["artifacts"] = (isset($tables["artifact"]))? $tables["artifact"] : array();
        $diagram["events"] = $tables["event"];
        $diagram["flows"] = $tables["flow"];
        $diagram["gateways"] = $tables["gateway"];
        $diagram["data"] = (isset($tables["data"]))? $tables["data"] : array();
        $diagram["participants"] = (isset($tables["participant"]))? $tables["participant"] : array();
        $diagram["laneset"] = (isset($tables["laneset"]))? $tables["laneset"] : array();
        $diagram["lanes"] = (isset($tables["lane"]))? $tables["lane"] : array();
        $project["diagrams"] = array($diagram);
        $project["prj_author"] = isset($this->data["usr_uid"])? $this->data["usr_uid"]: "00000000000000000000000000000001";
        $project["process"] = $tables["process"][0];

        return Adapter\BpmnWorkflow::createFromStruct($project, $generateUid);
    }