- Added comprehensive AI Assistant system (aiassist/ directory): * Vector search and embedding capabilities * Typebot proxy integration * Elastic search functionality * Message classification and chat history * MCP proxy for external integrations - Implemented Court Status API (GetCourtStatus.php): * Real-time court document status checking * Integration with external court systems * Comprehensive error handling and logging - Enhanced S3 integration: * Improved file backup system with metadata * Batch processing capabilities * Enhanced error logging and recovery * Copy operations with URL fixing - Added Telegram contact creation API - Improved error logging across all modules - Enhanced callback system for AI responses - Extensive backup file storage with timestamps - Updated documentation and README files - File storage improvements: * Thousands of backup files with proper metadata * Fix operations for broken file references * Project-specific backup and recovery systems * Comprehensive file integrity checking Total: 26,461+ files added/modified including AWS SDK, vendor dependencies, and extensive backup system.
169 lines
5.2 KiB
PHP
169 lines
5.2 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: StefanWarnat
|
|
* Date: 26.03.2019
|
|
* Time: 17:18
|
|
*/
|
|
namespace Workflow\BPMN;
|
|
|
|
use Workflow\Main;
|
|
use Workflow\Task;
|
|
use Workflow\VtUtils;
|
|
|
|
class Exporter
|
|
{
|
|
/**
|
|
* @var Main
|
|
*/
|
|
private $workflowObj = null;
|
|
|
|
/**
|
|
* @var Task
|
|
*/
|
|
private $startBlock = null;
|
|
|
|
/**
|
|
* @var Task
|
|
*/
|
|
private $currentBlock = null;
|
|
|
|
private $taskArray = array();
|
|
|
|
/**
|
|
* @var Element
|
|
*/
|
|
private $lastElement = null;
|
|
|
|
/**
|
|
* @var Element[]
|
|
*/
|
|
private $elements = array();
|
|
private $connections = array();
|
|
|
|
/**
|
|
* @var \DOMDocument
|
|
*/
|
|
private $xml = null;
|
|
|
|
public function __construct(Main $workflowObj) {
|
|
$this->workflowObj = $workflowObj;
|
|
|
|
$sql = "SELECT id FROM vtiger_wfp_blocks WHERE workflow_id = " . $this->workflowObj->getId() . " AND type='start' LIMIT 1";
|
|
$row = VtUtils::fetchByAssoc($sql);
|
|
|
|
$this->currentBlock = $this->startBlock = \Workflow\Manager::getTaskHandler("start", $row["id"], $this->workflowObj);
|
|
$this->addBlock($this->currentBlock);
|
|
|
|
echo '<pre>';echo htmlentities($this->getXML());exit();
|
|
}
|
|
|
|
public function addBlock(Task $task, Element $parent = null) {
|
|
if($task->getBlockId() == $this->startBlock->getBlockId()) {
|
|
$type = Element::TYPE_STARTEVENT;
|
|
} else {
|
|
$type = Element::TYPE_TASK;
|
|
}
|
|
|
|
$block = new Element('Block_'.$task->getBlockId(), $task->getTitle(), $type);
|
|
$this->elements['Block_'.$task->getBlockId()] = $block;
|
|
|
|
if($parent !== null) {
|
|
$this->connections[] = array(
|
|
'from' => $parent->getId(),
|
|
'to' => $block->getId(),
|
|
);
|
|
$parent->addChild($block);
|
|
}
|
|
$parent = $block;
|
|
|
|
$sql = 'SELECT output FROM vtiger_wf_types WHERE type = ?';
|
|
$data = VtUtils::fetchByAssoc($sql, array($task->getType()));
|
|
$outputs = VtUtils::json_decode(html_entity_decode($data['output']));
|
|
|
|
$outputCount = array();
|
|
foreach($outputs as $output) {
|
|
$nextBlocks = $task->getNextTasks(array($output[0]));
|
|
|
|
if(!empty($nextBlocks)) {
|
|
$outputCount[$output[0]] = $nextBlocks;
|
|
}
|
|
}
|
|
|
|
if(count($outputCount) > 1) {
|
|
$this->elements['ExclusiveGateway_Block_'.$task->getBlockId()] = new Element('ExclusiveGateway_Block_'.$task->getBlockId(), '', Element::TYPE_EXCLUSIVEGATEWAY);
|
|
|
|
$block->addChild($this->elements['ExclusiveGateway_Block_'.$task->getBlockId()]);
|
|
$parent = $this->elements['ExclusiveGateway_Block_'.$task->getBlockId()];
|
|
|
|
$this->connections[] = array(
|
|
'from' => 'Block_'.$task->getBlockId(),
|
|
'to' => 'ExclusiveGateway_Block_'.$task->getBlockId(),
|
|
'waypoints' => '',
|
|
);
|
|
}
|
|
|
|
foreach($outputCount as $outputKey => $blocks) {
|
|
if($parent !== null) {
|
|
$parent->adjustMaxChild(count($blocks));
|
|
}
|
|
|
|
foreach($blocks as $singleBlock) {
|
|
$this->addBlock($singleBlock, $parent);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public function getXML() {
|
|
$workflowObj = new \Workflow2();
|
|
$this->xml = new \DOMDocument();
|
|
$this->xml->encoding = 'UTF-8';
|
|
// $this->xml->preserveWhiteSpace = false;
|
|
|
|
$definitions = $this->xml->createElement('bpmn:definitions');
|
|
$definitions->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
|
|
$definitions->setAttribute('xmlns:bpmn', 'http://www.omg.org/spec/BPMN/20100524/MODEL');
|
|
$definitions->setAttribute('xmlns:bpmndi', 'http://www.omg.org/spec/BPMN/20100524/DI');
|
|
$definitions->setAttribute('xmlns:dc', 'http://www.omg.org/spec/DD/20100524/DC');
|
|
$definitions->setAttribute('xmlns:di', 'http://www.omg.org/spec/DD/20100524/DI');
|
|
$definitions->setAttribute('id', 'Definitions_'.$this->workflowObj->getId(0).'');
|
|
$definitions->setAttribute('targetNamespace', 'http://bpmn.io/schema/bpmn');
|
|
$definitions->setAttribute('exporter', 'Redoo Networks Workflow Designer');
|
|
$definitions->setAttribute('exporterVersion', $workflowObj->getVersion());
|
|
$this->xml->appendChild($definitions);
|
|
|
|
$this->xml->formatOutput = true;
|
|
|
|
$map = $this->xml->documentElement;
|
|
|
|
$process = $this->xml->createElement('bpmn:process');
|
|
$process->setAttribute('id', 'Workflow_'.$this->workflowObj->getId());
|
|
$process->setAttribute('isExecutable', 'false');
|
|
$map->appendChild($process);
|
|
|
|
|
|
foreach($this->elements as $block) {
|
|
$block->addXML($this->xml);
|
|
}
|
|
|
|
$flows = Flow::getAll();
|
|
foreach($flows as $outgoingId => $childFlows) {
|
|
foreach($childFlows as $incomingId => $id) {
|
|
|
|
$block = $this->xml->createElement('bpmn:sequenceFlow');
|
|
$block->setAttribute('id', $id);
|
|
$block->setAttribute('sourceRef',$outgoingId);
|
|
$block->setAttribute('targetRef',$incomingId);
|
|
|
|
$process->appendChild($block);
|
|
}
|
|
}
|
|
|
|
return $this->xml->saveXML();
|
|
}
|
|
|
|
public function getNextTasks() {
|
|
|
|
}
|
|
} |