diff --git a/workflow/engine/classes/class.derivation.php b/workflow/engine/classes/class.derivation.php index 9c3328886..e39589493 100755 --- a/workflow/engine/classes/class.derivation.php +++ b/workflow/engine/classes/class.derivation.php @@ -142,7 +142,6 @@ class Derivation $arrayNextTask = array(); $arrayNextTaskDefault = array(); - $i = 0; //SELECT * //FROM APP_DELEGATION AS A @@ -211,18 +210,17 @@ class Derivation } if ($flagContinue) { - $arrayNextTask[++$i] = $this->prepareInformationTask($arrayRouteData); + $arrayNextTask[] = $this->prepareInformationTask($arrayRouteData); } } if (count($arrayNextTask) == 0 && count($arrayNextTaskDefault) > 0) { - $arrayNextTask[++$i] = $this->prepareInformationTask($arrayNextTaskDefault); + $arrayNextTask[] = $this->prepareInformationTask($arrayNextTaskDefault); } //Check Task GATEWAYTOGATEWAY $arrayNextTaskBk = $arrayNextTask; $arrayNextTask = array(); - $i = 0; foreach ($arrayNextTaskBk as $value) { $arrayNextTaskData = $value; @@ -231,16 +229,22 @@ class Derivation $arrayAux = $this->prepareInformation($arrayData, $arrayNextTaskData["NEXT_TASK"]["TAS_UID"]); foreach ($arrayAux as $value2) { - $arrayNextTask[++$i] = $value2; + $arrayNextTask[] = $value2; } } else { - $arrayNextTask[++$i] = $arrayNextTaskData; + $arrayNextTask[] = $arrayNextTaskData; } } //1. There is no rule if (count($arrayNextTask) == 0) { - throw new Exception(G::LoadTranslation("ID_NO_DERIVATION_RULE")); + $oProcess = new Process(); + $oProcessFieds = $oProcess->Load( $_SESSION['PROCESS'] ); + if(isset($oProcessFieds['PRO_BPMN']) && $oProcessFieds['PRO_BPMN'] == 1){ + throw new Exception(G::LoadTranslation("ID_NO_DERIVATION_BPMN_RULE")); + }else{ + throw new Exception(G::LoadTranslation("ID_NO_DERIVATION_RULE")); + } } //Return diff --git a/workflow/engine/classes/class.dynaformEditor.php b/workflow/engine/classes/class.dynaformEditor.php index 2499b60f1..f59ae7c9d 100755 --- a/workflow/engine/classes/class.dynaformEditor.php +++ b/workflow/engine/classes/class.dynaformEditor.php @@ -1,950 +1,1012 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ -/** - * Created on 21/12/2007 - * Dynaform - Dynaform class - * - * @copyright 2007 COLOSA - * @author David Callizaya - */ -G::LoadSystem("webResource"); -G::LoadClass('toolBar'); -G::LoadClass('dynaFormField'); -require_once ('classes/model/Process.php'); -require_once ('classes/model/Dynaform.php'); -G::LoadClass('xmlDb'); -G::LoadSystem('dynaformhandler'); - -/** - * - * @package workflow.engine.classes - */ -class dynaformEditor extends WebResource -{ - - private $isOldCopy = false; - public $file = ''; - public $title = 'New Dynaform'; - public $dyn_uid = ''; - public $dyn_type = ''; - public $home = ''; - - /** - * Other Options for Editor: - * left: 'getAbsoluteLeft(document.getElementById("dynaformEditor[0]"))', - * top: 'getAbsoluteTop(document.getElementById("dynaformEditor[0]"))', - * height: '3/4*(document.body.clientWidth-getAbsoluteLeft(document.getElementById("dynaformEditor[0]"))*2)', - * left: 'getAbsoluteLeft(document.getElementById("dynaformEditor[0]"))' - * left: 'getAbsoluteLeft(document.getElementById("dynaformEditor[0]"))' - * - * Other Options for Toolbar: - * left: 'getAbsoluteLeft(document.getElementById("dynaformEditor[0]"))', - * top: 'getAbsoluteTop(document.getElementById("dynaformEditor[0]"))', - */ - public $defaultConfig = array('Editor' => array('left' => '0', 'top' => '0', 'width' => 'document.body.clientWidth-4', 'height' => 'document.body.clientHeight-4'), - 'Toolbar' => array('left' => 'document.body.clientWidth-2-toolbar.clientWidth-24-3+7', 'top' => '52'), - 'FieldsList' => array('left' => '4+toolbar.clientWidth+24', 'top' => 'getAbsoluteTop(document.getElementById("dynaformEditor[0]"))', 'width' => 244, 'height' => 400) - ); - public $panelConf = array('style' => array('title' => array('textAlign' => 'center')), - 'width' => 700, 'height' => 600, 'tabWidth' => 120, 'modal' => true, 'drag' => false, 'resize' => false, 'blinkToFront' => false - ); - - /** - * Constructor of the class dynaformEditor - * - * @param string $get - * @return void - */ - public function dynaformEditor($get) - { - $this->panelConf = array_merge($this->panelConf, $this->defaultConfig['Editor']); - //'title' => G::LoadTranslation('ID_DYNAFORM_EDITOR').' - ['.$this->title.']', - } - - /** - * Create the xml form default - * - * @param string $filename - * @return void - */ - public function _createDefaultXmlForm($fileName) - { - //Create the default Dynaform - $sampleForm = '' . "\n"; - $sampleForm .= '' . "\n"; - switch ($this->dyn_type) { - case "xmlform": - /* $sampleForm.='' . "\n" . - ' <en>Sample form</en>' . "\n" . - ''."\n"; - $sampleForm.='' . "\n" . - ' Submit' . "\n" . - ''."\n"; */ - break; - case "grid": - /* $sampleForm.='' . "\n" . - 'A' . "\n" . - ''."\n"; - $sampleForm.='' . "\n" . - 'B' . "\n" . - ''."\n"; */ - break; - } - $sampleForm .= ''; - G::verifyPath(dirname($fileName), true); - $fp = fopen($fileName, 'w'); - $sampleForm = str_replace('name=""', 'name="' . $this->_getFilename($this->file) . '"', $sampleForm); - fwrite($fp, $sampleForm); - fclose($fp); - } - - /** - * Prints the DynaformEditor - * - * @return void - */ - public function _render() - { - global $G_PUBLISH; - $script = ''; - - /* Start Block: Load (Create if doesn't exist) the xmlform */ - $Parameters = array('SYS_LANG' => SYS_LANG, 'URL' => G::encrypt($this->file, URL_KEY), 'DYN_UID' => $this->dyn_uid, 'PRO_UID' => $this->pro_uid, 'DYNAFORM_NAME' => $this->dyn_title, 'FILE' => $this->file, 'DYN_EDITOR' => $this->dyn_editor - ); - $_SESSION['Current_Dynafom']['Parameters'] = $Parameters; - - $XmlEditor = array('URL' => G::encrypt($this->file, URL_KEY), 'XML' => '' //$openDoc->getXml() - ); - $JSEditor = array('URL' => G::encrypt($this->file, URL_KEY) - ); - - $A = G::encrypt($this->file, URL_KEY); - - try { - $openDoc = new Xml_Document(); - $fileName = $this->home . $this->file . '.xml'; - if (file_exists($fileName)) { - $openDoc->parseXmlFile($fileName); - } else { - $this->_createDefaultXmlForm($fileName); - $openDoc->parseXmlFile($fileName); - } - //$form = new Form( $this->file , $this->home, SYS_LANG, true ); - $Properties = dynaformEditorAjax::get_properties($A, $this->dyn_uid); - /* Start Block: Prepare the XMLDB connection */ - define('DB_XMLDB_HOST', PATH_DYNAFORM . $this->file . '.xml'); - define('DB_XMLDB_USER', ''); - define('DB_XMLDB_PASS', ''); - define('DB_XMLDB_NAME', ''); - define('DB_XMLDB_TYPE', 'myxml'); - /* Start Block: Prepare the dynaformEditor */ - $G_PUBLISH = new Publisher(); - $sName = 'dynaformEditor'; - $G_PUBLISH->publisherId = $sName; - $oHeadPublisher = & headPublisher::getSingleton(); - $oHeadPublisher->setTitle(G::LoadTranslation('ID_DYNAFORM_EDITOR') . ' - ' . $Properties['DYN_TITLE']); - $G_PUBLISH->AddContent('blank'); - $this->panelConf['title'] = ''; - $G_PUBLISH->AddContent('panel-init', 'mainPanel', $this->panelConf); - if ($Properties['DYN_TYPE'] == 'xmlform') { - $G_PUBLISH->AddContent('xmlform', 'toolbar', 'dynaforms/fields_Toolbar', 'display:none', $Parameters, '', ''); - } else { - $G_PUBLISH->AddContent('xmlform', 'toolbar', 'dynaforms/fields_ToolbarGrid', 'display:none', $Parameters, '', ''); - } - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_Editor', 'display:none', $Parameters, '', ''); - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_XmlEditor', 'display:none', $XmlEditor, '', ''); - $G_PUBLISH->AddContent('blank'); - $i = 0; - $aFields = array(); - $aFields[] = array('XMLNODE_NAME' => 'char', 'TYPE' => 'char', 'UP' => 'char', 'DOWN' => 'char' - ); - $oSession = new DBSession(new DBConnection(PATH_DYNAFORM . $this->file . '.xml', '', '', '', 'myxml')); - $oDataset = $oSession->Execute('SELECT * FROM dynaForm WHERE NOT( XMLNODE_NAME = "" ) AND TYPE <> "pmconnection"'); - $iMaximun = $oDataset->count(); - while ($aRow = $oDataset->Read()) { - $aFields[] = array('XMLNODE_NAME' => $aRow['XMLNODE_NAME'], 'TYPE' => $aRow['TYPE'], 'UP' => ($i > 0 ? G::LoadTranslation('ID_UP') : ''), 'DOWN' => ($i < $iMaximun - 1 ? G::LoadTranslation('ID_DOWN') : ''), 'row__' => ($i + 1) - ); - $i++; - break; - } - global $_DBArray; - $_DBArray['fields'] = $aFields; - $_SESSION['_DBArray'] = $_DBArray; - G::LoadClass('ArrayPeer'); - $oCriteria = new Criteria('dbarray'); - $oCriteria->setDBArrayTable('fields'); - /** - * *@Erik-> this is deprecated,. - * (unuseful) $G_PUBLISH->AddContent('propeltable', 'paged-table', 'dynaforms/fields_List', $oCriteria, $Parameters, '', SYS_URI.'dynaforms/dynaforms_PagedTableAjax');** - */ - $G_PUBLISH->AddContent('blank'); - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_JSEditor', 'display:none', $JSEditor, '', ''); - } catch (Exception $e) { - - } - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_Properties', 'display:none', $Properties, '', ''); - //for showHide tab option @Neyek - $G_PUBLISH->AddContent('blank'); - $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_PREVIEW"), $sName . '[3]', 'dynaformEditor.changeToPreview', 'dynaformEditor.saveCurrentView'); - $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_XML"), $sName . '[4]', 'dynaformEditor.changeToXmlCode', 'dynaformEditor.saveCurrentView'); - if ($Properties['DYN_TYPE'] != 'grid') { - $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_HTML"), $sName . '[5]', 'dynaformEditor.changeToHtmlCode', 'dynaformEditor.saveCurrentView'); - } - $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_FIELDS_LIST"), $sName . '[6]', 'dynaformEditor.changeToFieldsList', 'dynaformEditor.saveCurrentView'); - if ($Properties["DYN_TYPE"] != "grid") { - $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_JAVASCRIPTS"), $sName . '[7]', 'dynaformEditor.changeToJavascripts', 'dynaformEditor.saveCurrentView'); - } - $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_PROPERTIES"), $sName . '[8]', 'dynaformEditor.changeToProperties', 'dynaformEditor.saveCurrentView'); - - //for showHide tab option @Neyek - if ($Properties["DYN_TYPE"] != "grid") { - $G_PUBLISH->AddContent("panel-tab", G::LoadTranslation("ID_CONDITIONS_EDITOR"), $sName . "[9]", "dynaformEditor.changeToShowHide", "dynaformEditor.saveShowHide"); - } - - $G_PUBLISH->AddContent('panel-close'); - $oHeadPublisher->addScriptFile("/js/maborak/core/maborak.loader.js",2); - $oHeadPublisher->addScriptFile('/jscore/dynaformEditor/core/dynaformEditor.js'); - //$oHeadPublisher->addScriptFile('/js/dveditor/core/dveditor.js'); - //$oHeadPublisher->addScriptFile('/codepress/codepress.js',1); - - $oHeadPublisher->addScriptFile('/js/codemirrorOld/js/codemirror.js',1); - - $oHeadPublisher->addScriptFile('/js/grid/core/grid.js'); - $oHeadPublisher->addScriptCode(' - var DYNAFORM_URL="' . $Parameters['URL'] . '"; - leimnud.event.add(window,"load",function(){ loadEditor(); }); - '); - $oHeadPublisher->addScriptCode(' var jsMeta;var __usernameLoggedDE__ = "' . (isset($_SESSION['USR_USERNAME']) ? $_SESSION['USR_USERNAME'] : '') . '";var SYS_LANG = "' . SYS_LANG . '";var __DYN_UID__ = "' . $this->dyn_uid . '";'); - - $arrayParameterAux = $Parameters; - $arrayParameterAux["DYNAFORM_NAME"] = base64_encode($arrayParameterAux["DYNAFORM_NAME"]); - $oHeadPublisher->addScriptCode('var dynaformEditorParams = \'' . serialize($arrayParameterAux) . '\';'); - - G::RenderPage("publish", 'blank'); - } - - /** - * Get the filename - * - * @param string $file - * @return string - */ - public function _getFilename($file) - { - return (strcasecmp(substr($file, - 5), '_tmp0') == 0) ? substr($file, 0, strlen($file) - 5) : $file; - } - - /** - * Set the temporal copy - * - * @param string $onOff - * @return void - */ - public function _setUseTemporalCopy($onOff) - { - $file = self::_getFilename($this->file); - if ($onOff) { - $this->file = $file . '_tmp0'; - self::_setTmpData(array('useTmpCopy' => true )); - if (!file_exists(PATH_DYNAFORM . $file . '.xml')) { - $this->_createDefaultXmlForm(PATH_DYNAFORM . $file . '.xml'); - } - //Creates a copy if it doesn't exist, else, use the old copy - if (!file_exists(PATH_DYNAFORM . $this->file . '.xml')) { - self::_copyFile(PATH_DYNAFORM . $file . '.xml', PATH_DYNAFORM . $this->file . '.xml'); - } - if (!file_exists(PATH_DYNAFORM . $this->file . '.html') && file_exists(PATH_DYNAFORM . $file . '.html')) { - self::_copyFile(PATH_DYNAFORM . $file . '.html', PATH_DYNAFORM . $this->file . '.html'); - } - } else { - $this->file = $file; - self::_setTmpData(array()); - } - } - - /** - * Set temporal data - * - * @param $data - * @return void - */ - public function _setTmpData($data) - { - G::verifyPath(PATH_C . 'dynEditor/', true); - $fp = fopen(PATH_C . 'dynEditor/' . session_id() . '.php', 'w'); - fwrite($fp, '$tmpData=unserialize(\'' . addcslashes(serialize($data), '\\\'') . '\');'); - fclose($fp); - } - - /** - * Get temporal data - * - * @param string $filename - * @return array - */ - public function _getTmpData() - { - $tmpData = array(); - $file = PATH_C . 'dynEditor/' . session_id() . '.php'; - if (file_exists($file)) { - eval(implode('', file($file))); - } - return $tmpData; - } - - /** - * Copy files - * - * @param file $from - * @param file $to - * @return void - */ - public function _copyFile($from, $to) - { - $copy = implode('', file($from)); - $fcopy = fopen($to, "w"); - fwrite($fcopy, $copy); - fclose($fcopy); - } -} - -interface iDynaformEditorAjax -{ - //public function render_preview($A); -} - -/** - * DynaformEditorAjax - DynaformEditorAjax class - * - * @package workflow.engine.classes - */ -class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax -{ - - /** - * Constructor of the class dynaformEditorAjax - * - * @param var $post - * @return void - */ - public function dynaformEditorAjax($post) - { - $this->_run($post); - } - - /** - * Function Run - * - * @param var $post - * @return void - */ - public function _run($post) - { - WebResource::WebResource($_SERVER['REQUEST_URI'], $post); - } - - /** - * Prints the DynaformEditorAjax - * - * @param object $A - * @return ob_get_clean - */ - public function render_preview($A) - { - ob_start(); - $file = G::decrypt($A, URL_KEY); - global $G_PUBLISH; - $G_PUBLISH = new Publisher(); - $G_PUBLISH->publisherId = 'preview'; - $form = new Form($file, PATH_DYNAFORM, SYS_LANG, true, $G_PUBLISH->publisherId); - switch (basename($form->template, '.html')) { - case 'grid': - $template = 'grid'; - $aAux = array_keys($form->fields); - if (count($aAux) > 0) { - $aFields = (array_combine($aAux, $aAux)); - } else { - $aFields = $aAux; - } - if (is_array($aFields)) { - foreach ($aFields as $key => $val) { - $aFields[$key] = array(1 => "", 2 => "", 3 => "", 4 => "", 5 => ""); - } - } - break; - default: - $template = 'xmlform_' . $G_PUBLISH->publisherId; - $aFields = array('__DYNAFORM_OPTIONS' => array('PREVIOUS_STEP' => '#', 'NEXT_STEP' => '#', 'NEXT_STEP_LABEL' => G::loadTranslation('ID_NEXT_STEP'), 'PREVIOUS_ACTION' => 'return false;', 'NEXT_ACTION' => 'return false;' - ) - ); - } - $G_PUBLISH->AddContent('dynaform', $template, $file, '', $aFields, ''); - G::RenderPage('publish', 'raw'); - return ob_get_clean(); - } - - /** - * Prints the Dynaform in format HTML - * - * @param object $A - * @return array - */ - public function render_htmledit($A) - { - $script = ''; - $file = G::decrypt($A, URL_KEY); - ob_start(); - global $G_PUBLISH; - $form = new Form($file, PATH_DYNAFORM, SYS_LANG, true); - $G_PUBLISH = new Publisher(); - $G_PUBLISH->publisherId = ''; - $html = $this->get_htmlcode($A); - if (!is_string($html)) { - $error = $html; - $html = ''; - } else { - $error = 0; - } - $HtmlEditor = array('URL' => $A, 'HTML' => $html, 'DYN_UID' => $file ); - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_HtmlEditor', '', $HtmlEditor, '', ''); - G::RenderPage("publish", 'raw'); - return array('error' => $error, 'html' => ob_get_clean() - ); - } - - /** - * Get the html code - * Loads the stored HTML or the default Template if - * it doesn't exist. - * - * @param object $A - * @return code html - */ - public function get_htmlcode($A) - { - try { - $script = null; - $fileTmp = G::decrypt($A, URL_KEY); - $form = new Form($fileTmp, PATH_DYNAFORM, SYS_LANG, true); - - //Navigation Bar - $form->fields = G::array_merges(array("__DYNAFORM_OPTIONS" => new XmlForm_Field_XmlMenu(new Xml_Node("__DYNAFORM_OPTIONS", "complete", "", array("type" => "xmlmenu", "xmlfile" => "gulliver/dynaforms_Options" - )), SYS_LANG, PATH_XMLFORM, $form) - ), $form->fields); - - //Loads the stored HTML or the default Template if - //it doesn't exist. - $filename = substr($form->fileName, 0, - 3) . ($form->type === "xmlform" ? "" : "." . $form->type) . "html"; - - if (!file_exists($filename)) { - $html = $form->printTemplate($form->template, $script); - } else { - $html = implode("", file($filename)); - } - - /* - * It adds the new fields automatically at the bottom of the form. - * TODO: �TOP OR BOTTOM? - * Improving detection algorithm of new fields. - * Current: Do not check the fields that have already been reviewed (saving) - * Already checked the temporary file dynaforms editor. - */ - $tmp = self::_getTmpData(); - if (!isset($tmp['OLD_FIELDS'])) { - $tmp['OLD_FIELDS'] = array(); //var_dump($html);die; - } - $aAux = explode('', $html); - foreach ($form->fields as $field) { - if ((strpos($html, '{$form.' . $field->name . '}') === false) && (strpos($html, '{$' . $field->name . '}') === false)) { - //Aparantly is new (but could be a deleted or non visible like private type fields) - switch (strtolower($field->type)) { - case 'private': - case 'phpvariable': - break; - default: - if (array_search($field->name, $tmp['OLD_FIELDS']) === false) { - //TOP - $aAux[0] .= '
{$' . $field->name . '}' . '{$form.' . $field->name . '}'; - //$html.='
{$'.$field->name.'}'.'{$form.'.$field->name.'}'; - //BOTTOM - //$html='{$'.$field->name.'}'.'{$form.'.$field->name.'}'.$html; - //$tmp['OLD_FIELDS'][]=$field->name; - } - } - } - } - self::_setTmpData($tmp); - //$html=str_replace('{$form_className}','formDefault', $html ); - $html = str_replace('{$form_className}', 'formDefault', $aAux[0] . ''); - - return $html; - } catch (Exception $e) { - return (array) $e; - } - } - - /** - * Restore the html code - * - * @param object $A - * @return code html - */ - public function restore_html($A) - { - $script = null; - $fileTmp = G::decrypt($A, URL_KEY); - $form = new Form($fileTmp, PATH_DYNAFORM, SYS_LANG, true); - - //Navigation Bar - $form->fields = G::array_merges(array("__DYNAFORM_OPTIONS" => new XmlForm_Field_XmlMenu(new Xml_Node("__DYNAFORM_OPTIONS", "complete", "", array("type" => "xmlmenu", "xmlfile" => "gulliver/dynaforms_Options" - )), SYS_LANG, PATH_XMLFORM, $form) - ), $form->fields); - - $form->enableTemplate = false; - $html = $form->printTemplate($form->template, $script); - $html = str_replace('{$form_className}', 'formDefault', $html); - if (file_exists(PATH_DYNAFORM . $fileTmp . '.html')) { - unlink(PATH_DYNAFORM . $fileTmp . '.html'); - } - $fp = fopen(PATH_DYNAFORM . $fileTmp . '.html', 'w'); - fwrite($fp, $html); - fclose($fp); - - return $html; - } - - /** - * Set the html code - * - * @param object $A - * @return array - */ - public function set_htmlcode($A, $htmlcode) - { - try { - $iOcurrences = preg_match_all('/\{\$.*?\}/im', $htmlcode, $matches); - if ($iOcurrences) { - if (isset($matches[0])) { - $tagsHtml = $matches[0]; - foreach ($tagsHtml as $value) { - $aTagVar = strip_tags($value); - if ($value != $aTagVar) { - $htmlcode = str_replace($value, $aTagVar, $htmlcode); - } - } - } - } - $file = G::decrypt($A, URL_KEY); - $form = new Form($file, PATH_DYNAFORM, SYS_LANG, true); - $filename = substr($form->fileName, 0, - 3) . ($form->type === 'xmlform' ? '' : '.' . $form->type) . 'html'; - $fp = fopen($filename, 'w'); - fwrite($fp, $htmlcode); - fclose($fp); - return 0; - } catch (Exception $e) { - return (array) $e; - } - } - - /** - * Get the xml code - * - * @param object $A - * @return array - */ - public function get_xmlcode($A) - { - try { - $file = G::decrypt($A, URL_KEY); - $xmlcode = implode('', file(PATH_DYNAFORM . $file . '.xml')); - return array("xmlcode" => $xmlcode, "error" => 0 - ); - } catch (Exception $e) { - return array("xmlcode" => "", "error" => (array) $e - ); - } - } - - /** - * Set the xml code - * - * @param object $A - * @param array $xmlcode - * @return string - */ - public function set_xmlcode($A, $xmlcode) - { - $xmlcode = urldecode($xmlcode); - $file = G::decrypt($A, URL_KEY); - $xmlcode = str_replace(' ', ' ', trim($xmlcode)); - $fp = fopen(PATH_DYNAFORM . $file . '.xml', 'w'); - fwrite($fp, $xmlcode); - fclose($fp); - return ""; - } - - /** - * Get the javascript code - * - * @param object $A - * @param string $fieldName - * @return array - */ - public function get_javascripts($A, $fieldName) - { - try { - $file = G::decrypt($A, URL_KEY); - $form = new Form($file, PATH_DYNAFORM, SYS_LANG, true); - $aOptions = array(); - $sCode = ''; - foreach ($form->fields as $name => $value) { - if (strcasecmp($value->type, "javascript") == 0) { - $aOptions[] = array('key' => $name, 'value' => $name - ); - if ($name == $fieldName) { - $sCode = $value->code; - } - } - } - return array('aOptions' => $aOptions, 'sCode' => $sCode - ); - } catch (Exception $e) { - return (array) $e; - } - } - - /** - * Set the javascript code - * - * @param object $A - * @param string $fieldName - * @param string $sCode - * @return array - */ - public function set_javascript($A, $fieldName, $sCode, $meta = '') - { - if ($fieldName == '___pm_boot_strap___') { - return 0; - } - - $sCode = urldecode($sCode); - try { - $sCode = rtrim($sCode); - $file = G::decrypt($A, URL_KEY); - /* $dbc2 = new DBConnection( PATH_DYNAFORM . $file . '.xml' ,'','','','myxml' ); - $ses2 = new DBSession($dbc2); - $ses2->execute(G::replaceDataField("UPDATE dynaForm SET XMLNODE_VALUE = @@CODE WHERE XMLNODE_NAME = @@FIELDNAME ", array('FIELDNAME'=>$fieldName,'CODE'=>$sCode), "myxml" )); - */ - - G::LoadSystem('dynaformhandler'); - - $dynaform = new dynaFormHandler(PATH_DYNAFORM . "{$file}.xml"); - $dynaform->replace($fieldName, $fieldName, Array('type' => 'javascript', 'meta' => $meta, '#cdata' => $sCode - )); - - return 0; - } catch (Exception $e) { - return (array) $e; - } - } - - /** - * Get properties of the dynaForm - * - * @param file $A - * @param string $DYN_UID - * @return array - */ - public function get_properties($A, $DYN_UID) - { - $file = G::decrypt($A, URL_KEY); - $tmp = self::_getTmpData(); - if (!(isset($tmp['Properties']) && isset($tmp['useTmpCopy']))) { - $dynaform = new dynaform(); - $dynaform->load($DYN_UID); - $form = new Form($file, PATH_DYNAFORM, SYS_LANG, true); - $Properties = array('A' => $A, 'DYN_UID' => $dynaform->getDynUid(), 'PRO_UID' => $dynaform->getProUid(), 'DYN_TITLE' => $dynaform->getDynTitle(), 'DYN_TYPE' => $dynaform->getDynType(), 'DYN_DESCRIPTION' => $dynaform->getDynDescription(), 'WIDTH' => $form->width, - //'ENABLETEMPLATE'=> $form->enableTemplate, - 'MODE' => $form->mode, 'PRINTDYNAFORM' => $form->printdynaform, 'ADJUSTGRIDSWIDTH' => $form->adjustgridswidth, 'NEXTSTEPSAVE' => $form->nextstepsave - ); - $tmp['Properties'] = $Properties; - self::_setTmpData($tmp); - } else { - $form = new Form($file, PATH_DYNAFORM, SYS_LANG, true); - $Properties = $tmp['Properties']; - if (!isset($Properties['ENABLETEMPLATE'])) { - $Properties['ENABLETEMPLATE'] = "0"; - } - $Properties['WIDTH'] = $form->width; - $Properties['MODE'] = $form->mode; - } - return $Properties; - } - - /** - * Set properties of the dynaForm - * - * @param file $A - * @param string $DYN_UID - * @param array $getFields - * @return array - */ - public function set_properties($A, $DYN_UID, $getFields) - { - try { - $post = array(); - parse_str($getFields, $post); - $Fields = $post['form']; - //if (!isset($Fields['ENABLETEMPLATE'])) $Fields['ENABLETEMPLATE'] ="0"; - $file = G::decrypt($A, URL_KEY); - $tmp = self::_getTmpData(); - if (!isset($tmp['useTmpCopy'])) { - $dynaform = new dynaform(); - $dynaform->update($Fields); - } else { - $tmp['Properties'] = $Fields; - self::_setTmpData($tmp); - } - $dynaform = new dynaFormHandler(PATH_DYNAFORM . "{$file}.xml"); - $dbc2 = new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml'); - $ses2 = new DBSession($dbc2); - //if (!isset($Fields['ENABLETEMPLATE'])) $Fields['ENABLETEMPLATE'] ="0"; - - /* if (isset($Fields['ENABLETEMPLATE'])) { - $ses2->execute(G::replaceDataField("UPDATE . SET ENABLETEMPLATE = @@ENABLETEMPLATE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields)); - } */ - if (isset($Fields['DYN_TYPE'])) { - //$ses2->execute( G::replaceDataField( "UPDATE . SET TYPE = @@DYN_TYPE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) ); - $dynaform->modifyHeaderAttribute('type', $Fields['DYN_TYPE']); - } - if (isset($Fields['WIDTH'])) { - // $ses2->execute( G::replaceDataField( "UPDATE . SET WIDTH = @@WIDTH WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) ); - $dynaform->modifyHeaderAttribute('width', $Fields['WIDTH']); - //g::pr($dynaform->getHeaderAttribute('width')); - } - if (isset($Fields['MODE'])) { - // $ses2->execute( G::replaceDataField( "UPDATE . SET MODE = @@MODE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) ); - $dynaform->modifyHeaderAttribute('mode', $Fields['MODE']); - } - if (isset($Fields['NEXTSTEPSAVE'])) { - //$ses2->execute( G::replaceDataField( "UPDATE . SET NEXTSTEPSAVE = @@NEXTSTEPSAVE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) ); - $dynaform->modifyHeaderAttribute('nextstepsave', $Fields['NEXTSTEPSAVE']); - } - if (isset($Fields['PRINTDYNAFORM'])) { - //$ses2->execute( G::replaceDataField( "UPDATE . SET PRINTDYNAFORM = @@PRINTDYNAFORM WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) ); - $dynaform->modifyHeaderAttribute('printdynaform', $Fields['PRINTDYNAFORM']); - } - if (isset($Fields['ADJUSTGRIDSWIDTH'])) { - //$ses2->execute( G::replaceDataField( "UPDATE . SET ADJUSTGRIDSWIDTH = @@ADJUSTGRIDSWIDTH WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) ); - $dynaform->modifyHeaderAttribute('adjustgridswidth', $Fields['ADJUSTGRIDSWIDTH']); - } - - return 0; - } catch (Exception $e) { - return (array) $e; - } - } - - /** - * Get enable template - * - * @param object $A - * @return string - */ - public function get_enabletemplate($A) - { - $file = G::decrypt($A, URL_KEY); - $form = new Form($file, PATH_DYNAFORM, SYS_LANG, true); - return $form->enableTemplate; - } - - /** - * Set enable template - * - * @param object $A - * @param string $value - * @return string - */ - public function set_enabletemplate($A, $value) - { - $file = G::decrypt($A, URL_KEY); - $value = $value == "1" ? "1" : "0"; - // $dbc2 = new DBConnection( PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml' ); - // $ses2 = new DBSession( $dbc2 ); - // $ses2->execute( "UPDATE . SET ENABLETEMPLATE = '$value'" ); - - $dynaform = new dynaFormHandler(PATH_DYNAFORM . "{$file}.xml"); - $dynaform->modifyHeaderAttribute('enabletemplate', $value); - - return $value; - } - - /** - * Save a dynaForm - * - * @param object $A - * @param string $DYN_UID - * @return array - */ - public function save($A, $DYN_UID) - { - try { - $answer = 0; - $file = G::decrypt($A, URL_KEY); - $tmp = self::_getTmpData(); - if (isset($tmp['useTmpCopy'])) { - /* Save Register */ - $dynaform = new dynaform(); - $dynaform->update($tmp['Properties']); - /* Save file */ - $copy = implode('', file(PATH_DYNAFORM . $file . '.xml')); - /* - * added by krlos carlos/a/colosa.com - * in here we are validation if a xmlform has a submit action - */ - // if (!preg_match("/type=\"submit\"/",$copy) && !preg_match("/type=\"grid\"/",$copy) && !isset($_SESSION['submitAction']) ){ - if (!preg_match("/type=\"submit\"/", $copy) && !preg_match("/type=\"grid\"/", $copy)) { - // $_SESSION['submitAction'] = 1; - $answer = 'noSub'; - } - $copyHtml = false; - if (file_exists(PATH_DYNAFORM . $file . '.html')) { - $copyHtml = implode('', file(PATH_DYNAFORM . $file . '.html')); - } - $file = dynaformEditor::_getFilename($file); - $fcopy = fopen(PATH_DYNAFORM . $file . '.xml', "w"); - fwrite($fcopy, $copy); - fclose($fcopy); - if ($copyHtml) { - $fcopy = fopen(PATH_DYNAFORM . $file . '.html', "w"); - fwrite($fcopy, $copyHtml); - fclose($fcopy); - } - } else { - //throw new Exception("It should not come here unless you have disabled the temporary copy."); - } - return $answer; - } catch (Exception $e) { - return (array) $e; - } - } - - /** - * Close a dynaform - * - * @param object $A - * @return array - */ - public function close($A) - { - try { - /* - * we are unseting this variable. It's our control about to save the xmlfrom - */ - // unset($_SESSION['submitAction']); - $file = G::decrypt($A, URL_KEY); - //return(array('response'=>PATH_DYNAFORM . $file . '.xml')); - /* Delete the temporal copy */ - $tmp = self::_getTmpData(); - $xmlFile = PATH_DYNAFORM . $file . '.xml'; - $htmlFile = PATH_DYNAFORM . $file . '.html'; - //return(array('response'=>$tmp['useTmpCopy'])); - if (isset($tmp['useTmpCopy'])) { - //return(array('response'=>PATH_DYNAFORM . $file . '.xml')); - if ($file !== dynaformEditor::_getFilename($file)) { - // return(array('response'=>PATH_DYNAFORM . $file . '.xml')); - if (file_exists($xmlFile)) { - unlink($xmlFile); - } - if (file_exists($htmlFile)) { - unlink($htmlFile); - } - } - } - return 0; - } catch (Exception $e) { - return (array) $e; - } - } - - /** - * Checks if a dynaform was changed - * - * @param file $A - * @param string $DYN_UID - * @return array - */ - public function is_modified($A, $DYN_UID) - { - $file = G::decrypt($A, URL_KEY); - try { - /* Compare Properties */ - $dynaform = new dynaform(); - $dynaform->load($DYN_UID); - $form = new Form($file, PATH_DYNAFORM, SYS_LANG, true); - $sp = array('A' => $A, 'DYN_UID' => $dynaform->getDynUid(), 'PRO_UID' => $dynaform->getProUid(), 'DYN_TITLE' => $dynaform->getDynTitle(), 'DYN_TYPE' => $dynaform->getDynType(), 'DYN_DESCRIPTION' => $dynaform->getDynDescription(), 'WIDTH' => $form->width, 'ENABLETEMPLATE' => $form->enableTemplate, 'MODE' => $form->mode - ); - $P = self::get_properties($A, $DYN_UID); - if (!isset($P['DYN_TITLE'])) { - $P['DYN_TITLE'] = $sp['DYN_TITLE']; - } - if (!isset($P['DYN_TYPE'])) { - $P['DYN_TYPE'] = $sp['DYN_TYPE']; - } - if (!isset($P['DYN_DESCRIPTION'])) { - $P['DYN_DESCRIPTION'] = $sp['DYN_DESCRIPTION']; - } - if (!isset($P['WIDTH'])) { - $P['WIDTH'] = $sp['WIDTH']; - } - if (!isset($P['ENABLETEMPLATE'])) { - $P['ENABLETEMPLATE'] = $sp['ENABLETEMPLATE']; - } - if (!isset($P['MODE'])) { - $P['MODE'] = $sp['MODE']; - } - $modPro = ($sp['DYN_TITLE'] != $P['DYN_TITLE']) || ($sp['DYN_TYPE'] != $P['DYN_TYPE']) || ($sp['DYN_DESCRIPTION'] != $P['DYN_DESCRIPTION']); - /* || - ($sp['WIDTH']!=$P['WIDTH']) || - ($sp['ENABLETEMPLATE']!=$P['ENABLETEMPLATE']) || - ($sp['MODE']!=$P['MODE']) */ - /* Compare copies */ - $fileOrigen = dynaformEditor::_getFilename($file); - $copy = implode('', file(PATH_DYNAFORM . $file . '.xml')); - $origen = implode('', file(PATH_DYNAFORM . $fileOrigen . '.xml')); - $copyHTML = file_exists(PATH_DYNAFORM . $file . '.html') ? implode('', file(PATH_DYNAFORM . $file . '.html')) : false; - $origenHTML = file_exists(PATH_DYNAFORM . $fileOrigen . '.html') ? implode('', file(PATH_DYNAFORM . $fileOrigen . '.html')) : false; - $modFile = ($copy !== $origen) || ($origenHTML && ($copyHTML !== $origenHTML)); - //Return - //return array("*message"=>sprintf("%s, (%s= %s %s):", $modPro?"1":"0" , $modFile?"1":"0", ($copy!==$origen)?"1":"0" , ($origenHTML && ($copyHTML!==$origenHTML))?"1":"0" )); - //die("c'est fini"); - return $modPro || $modFile; - } catch (Exception $e) { - return (array) $e; - } - } -} +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ +/** + * Created on 21/12/2007 + * Dynaform - Dynaform class + * + * @copyright 2007 COLOSA + * @author David Callizaya + */ +G::LoadSystem("webResource"); +G::LoadClass('toolBar'); +G::LoadClass('dynaFormField'); +require_once ('classes/model/Process.php'); +require_once ('classes/model/Dynaform.php'); +G::LoadClass('xmlDb'); +G::LoadSystem('dynaformhandler'); + +/** + * + * @package workflow.engine.classes + */ +class dynaformEditor extends WebResource +{ + + private $isOldCopy = false; + public $file = ''; + public $title = 'New Dynaform'; + public $dyn_uid = ''; + public $dyn_type = ''; + public $home = ''; + + /** + * Other Options for Editor: + * left: 'getAbsoluteLeft(document.getElementById("dynaformEditor[0]"))', + * top: 'getAbsoluteTop(document.getElementById("dynaformEditor[0]"))', + * height: '3/4*(document.body.clientWidth-getAbsoluteLeft(document.getElementById("dynaformEditor[0]"))*2)', + * left: 'getAbsoluteLeft(document.getElementById("dynaformEditor[0]"))' + * left: 'getAbsoluteLeft(document.getElementById("dynaformEditor[0]"))' + * + * Other Options for Toolbar: + * left: 'getAbsoluteLeft(document.getElementById("dynaformEditor[0]"))', + * top: 'getAbsoluteTop(document.getElementById("dynaformEditor[0]"))', + */ + public $defaultConfig = array('Editor' => array('left' => '0', 'top' => '0', 'width' => 'document.body.clientWidth-4', 'height' => 'document.body.clientHeight-4'), + 'Toolbar' => array('left' => 'document.body.clientWidth-2-toolbar.clientWidth-24-3+7', 'top' => '52'), + 'FieldsList' => array('left' => '4+toolbar.clientWidth+24', 'top' => 'getAbsoluteTop(document.getElementById("dynaformEditor[0]"))', 'width' => 244, 'height' => 400) + ); + public $panelConf = array('style' => array('title' => array('textAlign' => 'center')), + 'width' => 700, 'height' => 600, 'tabWidth' => 120, 'modal' => true, 'drag' => false, 'resize' => false, 'blinkToFront' => false + ); + + /** + * Constructor of the class dynaformEditor + * + * @param string $get + * @return void + */ + public function dynaformEditor($get) + { + $this->panelConf = array_merge($this->panelConf, $this->defaultConfig['Editor']); + //'title' => G::LoadTranslation('ID_DYNAFORM_EDITOR').' - ['.$this->title.']', + } + + /** + * Create the xml form default + * + * @param string $filename + * @return void + */ + public function _createDefaultXmlForm($fileName) + { + //Create the default Dynaform + $sampleForm = '' . "\n"; + $sampleForm .= '' . "\n"; + switch ($this->dyn_type) { + case "xmlform": + /* $sampleForm.='' . "\n" . + ' <en>Sample form</en>' . "\n" . + ''."\n"; + $sampleForm.='' . "\n" . + ' Submit' . "\n" . + ''."\n"; */ + break; + case "grid": + /* $sampleForm.='' . "\n" . + 'A' . "\n" . + ''."\n"; + $sampleForm.='' . "\n" . + 'B' . "\n" . + ''."\n"; */ + break; + } + $sampleForm .= ''; + G::verifyPath(dirname($fileName), true); + $fp = fopen($fileName, 'w'); + $sampleForm = str_replace('name=""', 'name="' . $this->_getFilename($this->file) . '"', $sampleForm); + fwrite($fp, $sampleForm); + fclose($fp); + } + + /** + * Prints the DynaformEditor + * + * @return void + */ + public function _render() + { + global $G_PUBLISH; + $script = ''; + + /* Start Block: Load (Create if doesn't exist) the xmlform */ + $Parameters = array('SYS_LANG' => SYS_LANG, 'URL' => G::encrypt($this->file, URL_KEY), 'DYN_UID' => $this->dyn_uid, 'PRO_UID' => $this->pro_uid, 'DYNAFORM_NAME' => $this->dyn_title, 'FILE' => $this->file, 'DYN_EDITOR' => $this->dyn_editor + ); + $_SESSION['Current_Dynafom']['Parameters'] = $Parameters; + + $XmlEditor = array('URL' => G::encrypt($this->file, URL_KEY), 'XML' => '' //$openDoc->getXml() + ); + $JSEditor = array('URL' => G::encrypt($this->file, URL_KEY) + ); + + $A = G::encrypt($this->file, URL_KEY); + + try { + $openDoc = new Xml_Document(); + $fileName = $this->home . $this->file . '.xml'; + if (file_exists($fileName)) { + $openDoc->parseXmlFile($fileName); + } else { + $this->_createDefaultXmlForm($fileName); + $openDoc->parseXmlFile($fileName); + } + //$form = new Form( $this->file , $this->home, SYS_LANG, true ); + $Properties = dynaformEditorAjax::get_properties($A, $this->dyn_uid); + /* Start Block: Prepare the XMLDB connection */ + define('DB_XMLDB_HOST', PATH_DYNAFORM . $this->file . '.xml'); + define('DB_XMLDB_USER', ''); + define('DB_XMLDB_PASS', ''); + define('DB_XMLDB_NAME', ''); + define('DB_XMLDB_TYPE', 'myxml'); + /* Start Block: Prepare the dynaformEditor */ + $G_PUBLISH = new Publisher(); + $sName = 'dynaformEditor'; + $G_PUBLISH->publisherId = $sName; + $oHeadPublisher = & headPublisher::getSingleton(); + $oHeadPublisher->setTitle(G::LoadTranslation('ID_DYNAFORM_EDITOR') . ' - ' . $Properties['DYN_TITLE']); + $G_PUBLISH->AddContent('blank'); + $this->panelConf['title'] = ''; + $G_PUBLISH->AddContent('panel-init', 'mainPanel', $this->panelConf); + if ($Properties['DYN_TYPE'] == 'xmlform') { + $G_PUBLISH->AddContent('xmlform', 'toolbar', 'dynaforms/fields_Toolbar', 'display:none', $Parameters, '', ''); + } else { + $G_PUBLISH->AddContent('xmlform', 'toolbar', 'dynaforms/fields_ToolbarGrid', 'display:none', $Parameters, '', ''); + } + $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_Editor', 'display:none', $Parameters, '', ''); + $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_XmlEditor', 'display:none', $XmlEditor, '', ''); + $G_PUBLISH->AddContent('blank'); + $i = 0; + $aFields = array(); + $aFields[] = array('XMLNODE_NAME' => 'char', 'TYPE' => 'char', 'UP' => 'char', 'DOWN' => 'char' + ); + $oSession = new DBSession(new DBConnection(PATH_DYNAFORM . $this->file . '.xml', '', '', '', 'myxml')); + $oDataset = $oSession->Execute('SELECT * FROM dynaForm WHERE NOT( XMLNODE_NAME = "" ) AND TYPE <> "pmconnection"'); + $iMaximun = $oDataset->count(); + while ($aRow = $oDataset->Read()) { + $aFields[] = array('XMLNODE_NAME' => $aRow['XMLNODE_NAME'], 'TYPE' => $aRow['TYPE'], 'UP' => ($i > 0 ? G::LoadTranslation('ID_UP') : ''), 'DOWN' => ($i < $iMaximun - 1 ? G::LoadTranslation('ID_DOWN') : ''), 'row__' => ($i + 1) + ); + $i++; + break; + } + global $_DBArray; + $_DBArray['fields'] = $aFields; + $_SESSION['_DBArray'] = $_DBArray; + G::LoadClass('ArrayPeer'); + $oCriteria = new Criteria('dbarray'); + $oCriteria->setDBArrayTable('fields'); + /** + * *@Erik-> this is deprecated,. + * (unuseful) $G_PUBLISH->AddContent('propeltable', 'paged-table', 'dynaforms/fields_List', $oCriteria, $Parameters, '', SYS_URI.'dynaforms/dynaforms_PagedTableAjax');** + */ + $G_PUBLISH->AddContent('blank'); + $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_JSEditor', 'display:none', $JSEditor, '', ''); + } catch (Exception $e) { + + } + $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_Properties', 'display:none', $Properties, '', ''); + //for showHide tab option @Neyek + $G_PUBLISH->AddContent('blank'); + $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_PREVIEW"), $sName . '[3]', 'dynaformEditor.changeToPreview', 'dynaformEditor.saveCurrentView'); + $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_XML"), $sName . '[4]', 'dynaformEditor.changeToXmlCode', 'dynaformEditor.saveCurrentView'); + if ($Properties['DYN_TYPE'] != 'grid') { + $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_HTML"), $sName . '[5]', 'dynaformEditor.changeToHtmlCode', 'dynaformEditor.saveCurrentView'); + } + $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_FIELDS_LIST"), $sName . '[6]', 'dynaformEditor.changeToFieldsList', 'dynaformEditor.saveCurrentView'); + if ($Properties["DYN_TYPE"] != "grid") { + $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_JAVASCRIPTS"), $sName . '[7]', 'dynaformEditor.changeToJavascripts', 'dynaformEditor.saveCurrentView'); + } + $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_PROPERTIES"), $sName . '[8]', 'dynaformEditor.changeToProperties', 'dynaformEditor.saveCurrentView'); + + //for showHide tab option @Neyek + if ($Properties["DYN_TYPE"] != "grid") { + $G_PUBLISH->AddContent("panel-tab", G::LoadTranslation("ID_CONDITIONS_EDITOR"), $sName . "[9]", "dynaformEditor.changeToShowHide", "dynaformEditor.saveShowHide"); + } + + $G_PUBLISH->AddContent('panel-close'); + $oHeadPublisher->addScriptFile("/js/maborak/core/maborak.loader.js",2); + $oHeadPublisher->addScriptFile('/jscore/dynaformEditor/core/dynaformEditor.js'); + //$oHeadPublisher->addScriptFile('/js/dveditor/core/dveditor.js'); + //$oHeadPublisher->addScriptFile('/codepress/codepress.js',1); + + $oHeadPublisher->addScriptFile('/js/codemirrorOld/js/codemirror.js',1); + + $oHeadPublisher->addScriptFile('/js/grid/core/grid.js'); + $oHeadPublisher->addScriptCode(' + var DYNAFORM_URL="' . $Parameters['URL'] . '"; + leimnud.event.add(window,"load",function(){ loadEditor(); }); + '); + $oHeadPublisher->addScriptCode(' var jsMeta;var __usernameLoggedDE__ = "' . (isset($_SESSION['USR_USERNAME']) ? $_SESSION['USR_USERNAME'] : '') . '";var SYS_LANG = "' . SYS_LANG . '";var __DYN_UID__ = "' . $this->dyn_uid . '";'); + + $arrayParameterAux = $Parameters; + $arrayParameterAux["DYNAFORM_NAME"] = base64_encode($arrayParameterAux["DYNAFORM_NAME"]); + $oHeadPublisher->addScriptCode('var dynaformEditorParams = \'' . serialize($arrayParameterAux) . '\';'); + + G::RenderPage("publish", 'blank'); + } + + /** + * Get the filename + * + * @param string $file + * @return string + */ + public function _getFilename($file) + { + return (strcasecmp(substr($file, - 5), '_tmp0') == 0) ? substr($file, 0, strlen($file) - 5) : $file; + } + + /** + * Set the temporal copy + * + * @param string $onOff + * @return void + */ + public function _setUseTemporalCopy($onOff) + { + $file = self::_getFilename($this->file); + if ($onOff) { + $this->file = $file . '_tmp0'; + self::_setTmpData(array('useTmpCopy' => true )); + if (!file_exists(PATH_DYNAFORM . $file . '.xml')) { + $this->_createDefaultXmlForm(PATH_DYNAFORM . $file . '.xml'); + } + //Creates a copy if it doesn't exist, else, use the old copy + if (!file_exists(PATH_DYNAFORM . $this->file . '.xml')) { + self::_copyFile(PATH_DYNAFORM . $file . '.xml', PATH_DYNAFORM . $this->file . '.xml'); + } + if (!file_exists(PATH_DYNAFORM . $this->file . '.html') && file_exists(PATH_DYNAFORM . $file . '.html')) { + self::_copyFile(PATH_DYNAFORM . $file . '.html', PATH_DYNAFORM . $this->file . '.html'); + } + } else { + $this->file = $file; + self::_setTmpData(array()); + } + } + + /** + * Set temporal data + * + * @param $data + * @return void + */ + public function _setTmpData($data) + { + G::verifyPath(PATH_C . 'dynEditor/', true); + $fp = fopen(PATH_C . 'dynEditor/' . session_id() . '.php', 'w'); + fwrite($fp, '$tmpData=unserialize(\'' . addcslashes(serialize($data), '\\\'') . '\');'); + fclose($fp); + } + + /** + * Get temporal data + * + * @param string $filename + * @return array + */ + public function _getTmpData() + { + $tmpData = array(); + $file = PATH_C . 'dynEditor/' . session_id() . '.php'; + if (file_exists($file)) { + eval(implode('', file($file))); + } + return $tmpData; + } + + /** + * Copy files + * + * @param file $from + * @param file $to + * @return void + */ + public function _copyFile($from, $to) + { + $copy = implode('', file($from)); + $fcopy = fopen($to, "w"); + fwrite($fcopy, $copy); + fclose($fcopy); + } +} + +interface iDynaformEditorAjax +{ + //public function render_preview($A); +} + +/** + * DynaformEditorAjax - DynaformEditorAjax class + * + * @package workflow.engine.classes + */ +class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax +{ + + /** + * Constructor of the class dynaformEditorAjax + * + * @param var $post + * @return void + */ + public function dynaformEditorAjax($post) + { + $this->_run($post); + } + + /** + * Function Run + * + * @param var $post + * @return void + */ + public function _run($post) + { + WebResource::WebResource($_SERVER['REQUEST_URI'], $post); + } + + /** + * Prints the DynaformEditorAjax + * + * @param object $A + * @return ob_get_clean + */ + public function render_preview($A) + { + ob_start(); + $file = G::decrypt($A, URL_KEY); + global $G_PUBLISH; + $G_PUBLISH = new Publisher(); + $G_PUBLISH->publisherId = 'preview'; + $form = new Form($file, PATH_DYNAFORM, SYS_LANG, true, $G_PUBLISH->publisherId); + switch (basename($form->template, '.html')) { + case 'grid': + $template = 'grid'; + $aAux = array_keys($form->fields); + if (count($aAux) > 0) { + $aFields = (array_combine($aAux, $aAux)); + } else { + $aFields = $aAux; + } + if (is_array($aFields)) { + foreach ($aFields as $key => $val) { + $aFields[$key] = array(1 => "", 2 => "", 3 => "", 4 => "", 5 => ""); + } + } + break; + default: + $template = 'xmlform_' . $G_PUBLISH->publisherId; + $aFields = array('__DYNAFORM_OPTIONS' => array('PREVIOUS_STEP' => '#', 'NEXT_STEP' => '#', 'NEXT_STEP_LABEL' => G::loadTranslation('ID_NEXT_STEP'), 'PREVIOUS_ACTION' => 'return false;', 'NEXT_ACTION' => 'return false;' + ) + ); + } + $G_PUBLISH->AddContent('dynaform', $template, $file, '', $aFields, ''); + G::RenderPage('publish', 'raw'); + return ob_get_clean(); + } + + /** + * Prints the Dynaform in format HTML + * + * @param object $A + * @return array + */ + public function render_htmledit($A) + { + $script = ''; + $file = G::decrypt($A, URL_KEY); + ob_start(); + global $G_PUBLISH; + $form = new Form($file, PATH_DYNAFORM, SYS_LANG, true); + $G_PUBLISH = new Publisher(); + $G_PUBLISH->publisherId = ''; + $html = $this->get_htmlcode($A); + if (!is_string($html)) { + $error = $html; + $html = ''; + } else { + $error = 0; + } + $HtmlEditor = array('URL' => $A, 'HTML' => $html, 'DYN_UID' => $file ); + $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_HtmlEditor', '', $HtmlEditor, '', ''); + G::RenderPage("publish", 'raw'); + return array('error' => $error, 'html' => ob_get_clean() + ); + } + + /** + * Get the html code + * Loads the stored HTML or the default Template if + * it doesn't exist. + * + * @param object $A + * @return code html + */ + public function get_htmlcode($A) + { + try { + $script = null; + $fileTmp = G::decrypt($A, URL_KEY); + $form = new Form($fileTmp, PATH_DYNAFORM, SYS_LANG, true); + + //Navigation Bar + $form->fields = G::array_merges(array("__DYNAFORM_OPTIONS" => new XmlForm_Field_XmlMenu(new Xml_Node("__DYNAFORM_OPTIONS", "complete", "", array("type" => "xmlmenu", "xmlfile" => "gulliver/dynaforms_Options" + )), SYS_LANG, PATH_XMLFORM, $form) + ), $form->fields); + + //Loads the stored HTML or the default Template if + //it doesn't exist. + $filename = substr($form->fileName, 0, - 3) . ($form->type === "xmlform" ? "" : "." . $form->type) . "html"; + + if (!file_exists($filename)) { + $html = $form->printTemplate($form->template, $script); + } else { + $html = implode("", file($filename)); + } + + /* + * It adds the new fields automatically at the bottom of the form. + * TODO: �TOP OR BOTTOM? + * Improving detection algorithm of new fields. + * Current: Do not check the fields that have already been reviewed (saving) + * Already checked the temporary file dynaforms editor. + */ + $tmp = self::_getTmpData(); + if (!isset($tmp['OLD_FIELDS'])) { + $tmp['OLD_FIELDS'] = array(); //var_dump($html);die; + } + $aAux = explode('', $html); + foreach ($form->fields as $field) { + if ((strpos($html, '{$form.' . $field->name . '}') === false) && (strpos($html, '{$' . $field->name . '}') === false)) { + //Aparantly is new (but could be a deleted or non visible like private type fields) + switch (strtolower($field->type)) { + case 'private': + case 'phpvariable': + break; + default: + if (array_search($field->name, $tmp['OLD_FIELDS']) === false) { + //TOP + $aAux[0] .= '
{$' . $field->name . '}' . '{$form.' . $field->name . '}'; + //$html.='
{$'.$field->name.'}'.'{$form.'.$field->name.'}'; + //BOTTOM + //$html='{$'.$field->name.'}'.'{$form.'.$field->name.'}'.$html; + //$tmp['OLD_FIELDS'][]=$field->name; + } + } + } + } + self::_setTmpData($tmp); + //$html=str_replace('{$form_className}','formDefault', $html ); + $html = str_replace('{$form_className}', 'formDefault', $aAux[0] . ''); + + return $html; + } catch (Exception $e) { + return (array) $e; + } + } + + /** + * Restore the html code + * + * @param object $A + * @return code html + */ + public function restore_html($A) + { + $script = null; + $fileTmp = G::decrypt($A, URL_KEY); + $form = new Form($fileTmp, PATH_DYNAFORM, SYS_LANG, true); + + //Navigation Bar + $form->fields = G::array_merges(array("__DYNAFORM_OPTIONS" => new XmlForm_Field_XmlMenu(new Xml_Node("__DYNAFORM_OPTIONS", "complete", "", array("type" => "xmlmenu", "xmlfile" => "gulliver/dynaforms_Options" + )), SYS_LANG, PATH_XMLFORM, $form) + ), $form->fields); + + $form->enableTemplate = false; + $html = $form->printTemplate($form->template, $script); + $html = str_replace('{$form_className}', 'formDefault', $html); + if (file_exists(PATH_DYNAFORM . $fileTmp . '.html')) { + unlink(PATH_DYNAFORM . $fileTmp . '.html'); + } + $fp = fopen(PATH_DYNAFORM . $fileTmp . '.html', 'w'); + fwrite($fp, $html); + fclose($fp); + + return $html; + } + + /** + * Set the html code + * + * @param object $A + * @return array + */ + public function set_htmlcode($A, $htmlcode) + { + try { + $iOcurrences = preg_match_all('/\{\$.*?\}/im', $htmlcode, $matches); + if ($iOcurrences) { + if (isset($matches[0])) { + $tagsHtml = $matches[0]; + foreach ($tagsHtml as $value) { + $aTagVar = strip_tags($value); + if ($value != $aTagVar) { + $htmlcode = str_replace($value, $aTagVar, $htmlcode); + } + } + } + } + $file = G::decrypt($A, URL_KEY); + $form = new Form($file, PATH_DYNAFORM, SYS_LANG, true); + $filename = substr($form->fileName, 0, - 3) . ($form->type === 'xmlform' ? '' : '.' . $form->type) . 'html'; + $fp = fopen($filename, 'w'); + fwrite($fp, $htmlcode); + fclose($fp); + return 0; + } catch (Exception $e) { + return (array) $e; + } + } + + /** + * Get the xml code + * + * @param object $A + * @return array + */ + public function get_xmlcode($A) + { + try { + $file = G::decrypt($A, URL_KEY); + $xmlcode = implode('', file(PATH_DYNAFORM . $file . '.xml')); + return array("xmlcode" => $xmlcode, "error" => 0 + ); + } catch (Exception $e) { + return array("xmlcode" => "", "error" => (array) $e + ); + } + } + + /** + * Set the xml code + * + * @param object $A + * @param array $xmlcode + * @return string + */ + public function set_xmlcode($A, $xmlcode) + { + $xmlcode = urldecode($xmlcode); + $file = G::decrypt($A, URL_KEY); + $xmlcode = str_replace(' ', ' ', trim($xmlcode)); + $fp = fopen(PATH_DYNAFORM . $file . '.xml', 'w'); + fwrite($fp, $xmlcode); + fclose($fp); + return ""; + } + + /** + * Get the javascript code + * + * @param object $A + * @param string $fieldName + * @return array + */ + public function get_javascripts($A, $fieldName) + { + try { + $file = G::decrypt($A, URL_KEY); + $form = new Form($file, PATH_DYNAFORM, SYS_LANG, true); + $aOptions = array(); + $sCode = ''; + foreach ($form->fields as $name => $value) { + if (strcasecmp($value->type, "javascript") == 0) { + $aOptions[] = array('key' => $name, 'value' => $name + ); + if ($name == $fieldName) { + $sCode = $value->code; + } + } + } + return array('aOptions' => $aOptions, 'sCode' => $sCode + ); + } catch (Exception $e) { + return (array) $e; + } + } + + /** + * Set the javascript code + * + * @param object $A + * @param string $fieldName + * @param string $sCode + * @return array + */ + public function set_javascript($A, $fieldName, $sCode, $meta = '') + { + if ($fieldName == '___pm_boot_strap___') { + return 0; + } + + $sCode = urldecode($sCode); + try { + $sCode = rtrim($sCode); + $file = G::decrypt($A, URL_KEY); + /* $dbc2 = new DBConnection( PATH_DYNAFORM . $file . '.xml' ,'','','','myxml' ); + $ses2 = new DBSession($dbc2); + $ses2->execute(G::replaceDataField("UPDATE dynaForm SET XMLNODE_VALUE = @@CODE WHERE XMLNODE_NAME = @@FIELDNAME ", array('FIELDNAME'=>$fieldName,'CODE'=>$sCode), "myxml" )); + */ + + G::LoadSystem('dynaformhandler'); + + $dynaform = new dynaFormHandler(PATH_DYNAFORM . "{$file}.xml"); + $dynaform->replace($fieldName, $fieldName, Array('type' => 'javascript', 'meta' => $meta, '#cdata' => $sCode + )); + + return 0; + } catch (Exception $e) { + return (array) $e; + } + } + + /** + * Get properties of the dynaForm + * + * @param file $A + * @param string $DYN_UID + * @return array + */ + public function get_properties($A, $DYN_UID) + { + $file = G::decrypt($A, URL_KEY); + $tmp = self::_getTmpData(); + if (!(isset($tmp['Properties']) && isset($tmp['useTmpCopy']))) { + $dynaform = new dynaform(); + $dynaform->load($DYN_UID); + $form = new Form($file, PATH_DYNAFORM, SYS_LANG, true); + $Properties = array('A' => $A, 'DYN_UID' => $dynaform->getDynUid(), 'PRO_UID' => $dynaform->getProUid(), 'DYN_TITLE' => $dynaform->getDynTitle(), 'DYN_TYPE' => $dynaform->getDynType(), 'DYN_DESCRIPTION' => $dynaform->getDynDescription(), 'WIDTH' => $form->width, + //'ENABLETEMPLATE'=> $form->enableTemplate, + 'MODE' => $form->mode, 'PRINTDYNAFORM' => $form->printdynaform, 'ADJUSTGRIDSWIDTH' => $form->adjustgridswidth, 'NEXTSTEPSAVE' => $form->nextstepsave + ); + $tmp['Properties'] = $Properties; + self::_setTmpData($tmp); + } else { + $form = new Form($file, PATH_DYNAFORM, SYS_LANG, true); + $Properties = $tmp['Properties']; + if (!isset($Properties['ENABLETEMPLATE'])) { + $Properties['ENABLETEMPLATE'] = "0"; + } + $Properties['WIDTH'] = $form->width; + $Properties['MODE'] = $form->mode; + } + return $Properties; + } + + /** + * Set properties of the dynaForm + * + * @param file $A + * @param string $DYN_UID + * @param array $getFields + * @return array + */ + public function set_properties($A, $DYN_UID, $getFields) + { + try { + $post = array(); + parse_str($getFields, $post); + $Fields = $post['form']; + //if (!isset($Fields['ENABLETEMPLATE'])) $Fields['ENABLETEMPLATE'] ="0"; + $file = G::decrypt($A, URL_KEY); + $tmp = self::_getTmpData(); + if (!isset($tmp['useTmpCopy'])) { + $dynaform = new dynaform(); + $dynaform->update($Fields); + } else { + $tmp['Properties'] = $Fields; + self::_setTmpData($tmp); + } + $dynaform = new dynaFormHandler(PATH_DYNAFORM . "{$file}.xml"); + $dbc2 = new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml'); + $ses2 = new DBSession($dbc2); + //if (!isset($Fields['ENABLETEMPLATE'])) $Fields['ENABLETEMPLATE'] ="0"; + + /* if (isset($Fields['ENABLETEMPLATE'])) { + $ses2->execute(G::replaceDataField("UPDATE . SET ENABLETEMPLATE = @@ENABLETEMPLATE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields)); + } */ + if (isset($Fields['DYN_TYPE'])) { + //$ses2->execute( G::replaceDataField( "UPDATE . SET TYPE = @@DYN_TYPE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) ); + $dynaform->modifyHeaderAttribute('type', $Fields['DYN_TYPE']); + } + if (isset($Fields['WIDTH'])) { + // $ses2->execute( G::replaceDataField( "UPDATE . SET WIDTH = @@WIDTH WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) ); + $dynaform->modifyHeaderAttribute('width', $Fields['WIDTH']); + //g::pr($dynaform->getHeaderAttribute('width')); + } + if (isset($Fields['MODE'])) { + // $ses2->execute( G::replaceDataField( "UPDATE . SET MODE = @@MODE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) ); + $dynaform->modifyHeaderAttribute('mode', $Fields['MODE']); + } + if (isset($Fields['NEXTSTEPSAVE'])) { + //$ses2->execute( G::replaceDataField( "UPDATE . SET NEXTSTEPSAVE = @@NEXTSTEPSAVE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) ); + $dynaform->modifyHeaderAttribute('nextstepsave', $Fields['NEXTSTEPSAVE']); + } + if (isset($Fields['PRINTDYNAFORM'])) { + //$ses2->execute( G::replaceDataField( "UPDATE . SET PRINTDYNAFORM = @@PRINTDYNAFORM WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) ); + $dynaform->modifyHeaderAttribute('printdynaform', $Fields['PRINTDYNAFORM']); + } + if (isset($Fields['ADJUSTGRIDSWIDTH'])) { + //$ses2->execute( G::replaceDataField( "UPDATE . SET ADJUSTGRIDSWIDTH = @@ADJUSTGRIDSWIDTH WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) ); + $dynaform->modifyHeaderAttribute('adjustgridswidth', $Fields['ADJUSTGRIDSWIDTH']); + } + + return 0; + } catch (Exception $e) { + return (array) $e; + } + } + + /** + * Get enable template + * + * @param object $A + * @return string + */ + public function get_enabletemplate($A) + { + $file = G::decrypt($A, URL_KEY); + $form = new Form($file, PATH_DYNAFORM, SYS_LANG, true); + return $form->enableTemplate; + } + + /** + * Set enable template + * + * @param object $A + * @param string $value + * @return string + */ + public function set_enabletemplate($A, $value) + { + $file = G::decrypt($A, URL_KEY); + $value = $value == "1" ? "1" : "0"; + // $dbc2 = new DBConnection( PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml' ); + // $ses2 = new DBSession( $dbc2 ); + // $ses2->execute( "UPDATE . SET ENABLETEMPLATE = '$value'" ); + + $dynaform = new dynaFormHandler(PATH_DYNAFORM . "{$file}.xml"); + $dynaform->modifyHeaderAttribute('enabletemplate', $value); + + return $value; + } + + /** + * Save a dynaForm + * + * @param object $A + * @param string $DYN_UID + * @return array + */ + public function save($A, $DYN_UID) + { + try { + $answer = 0; + $file = G::decrypt($A, URL_KEY); + $tmp = self::_getTmpData(); + if (isset($tmp['Properties'])){ + $fileFirst = $tmp['Properties']['PRO_UID'].'/'.$tmp['Properties']['DYN_UID']; + } + if (isset($tmp['useTmpCopy'])) { + /* Save Register */ + $dynaform = new dynaform(); + $dynaform->update($tmp['Properties']); + /* Save file */ + $copyFirst = implode('', file(PATH_DYNAFORM . $fileFirst . '.xml')); + $copy = implode('', file(PATH_DYNAFORM . $file . '.xml')); + /*Check differences between XML*/ + $elementFirst = new SimpleXMLElement($copyFirst); + $elementCopy = new SimpleXMLElement($copy); + $desAdd = ''; + $desDel = ''; + //Check the new fields + foreach ($elementCopy as $key1 => $row1){ + $swAll = true; + foreach ($elementFirst as $key2 => $row2){ + if ($key1 == $key2){ + $swAll = false; + break; + } + } + if ($swAll){ + $desAdd .= $key1." "; + } + } + //Check the delete fields + foreach ($elementFirst as $key1 => $row1){ + $swAll = true; + foreach ($elementCopy as $key2 => $row2){ + if ($key1 == $key2){ + $swAll = false; + break; + } + } + if ($swAll){ + $desDel .= $key1." "; + } + } + + $mode = empty($tmp['Properties']['MODE'])? 'Determined by Fields' : $tmp['Properties']['MODE']; + $auditDescription = "Dynaform Title: ".$tmp['Properties']['DYN_TITLE'].", Type: ".$tmp['Properties']['DYN_TYPE'].", Description: ".$tmp['Properties']['DYN_DESCRIPTION'].", Mode: ".$mode; + if($desAdd != ''){ + $auditDescription .= ", Field(s) Add: ".$desAdd; + } + if($desDel != ''){ + $auditDescription .= ", Field(s) Delete: ".$desDel; + } + //Add Audit Log + G::auditLog("UpdateDynaform", $auditDescription); + + + /* + * added by krlos carlos/a/colosa.com + * in here we are validation if a xmlform has a submit action + */ + // if (!preg_match("/type=\"submit\"/",$copy) && !preg_match("/type=\"grid\"/",$copy) && !isset($_SESSION['submitAction']) ){ + if (!preg_match("/type=\"submit\"/", $copy) && !preg_match("/type=\"grid\"/", $copy)) { + // $_SESSION['submitAction'] = 1; + $answer = 'noSub'; + } + $copyHtml = false; + if (file_exists(PATH_DYNAFORM . $file . '.html')) { + $copyHtml = implode('', file(PATH_DYNAFORM . $file . '.html')); + } + $file = dynaformEditor::_getFilename($file); + $fcopy = fopen(PATH_DYNAFORM . $file . '.xml', "w"); + fwrite($fcopy, $copy); + fclose($fcopy); + if ($copyHtml) { + $fcopy = fopen(PATH_DYNAFORM . $file . '.html', "w"); + fwrite($fcopy, $copyHtml); + fclose($fcopy); + } + } else { + //throw new Exception("It should not come here unless you have disabled the temporary copy."); + } + return $answer; + } catch (Exception $e) { + return (array) $e; + } + } + + /** + * Close a dynaform + * + * @param object $A + * @return array + */ + public function close($A) + { + try { + /* + * we are unseting this variable. It's our control about to save the xmlfrom + */ + // unset($_SESSION['submitAction']); + $file = G::decrypt($A, URL_KEY); + //return(array('response'=>PATH_DYNAFORM . $file . '.xml')); + /* Delete the temporal copy */ + $tmp = self::_getTmpData(); + $xmlFile = PATH_DYNAFORM . $file . '.xml'; + $htmlFile = PATH_DYNAFORM . $file . '.html'; + //return(array('response'=>$tmp['useTmpCopy'])); + if (isset($tmp['useTmpCopy'])) { + //return(array('response'=>PATH_DYNAFORM . $file . '.xml')); + if ($file !== dynaformEditor::_getFilename($file)) { + // return(array('response'=>PATH_DYNAFORM . $file . '.xml')); + if (file_exists($xmlFile)) { + unlink($xmlFile); + } + if (file_exists($htmlFile)) { + unlink($htmlFile); + } + } + } + return 0; + } catch (Exception $e) { + return (array) $e; + } + } + + /** + * Checks if a dynaform was changed + * + * @param file $A + * @param string $DYN_UID + * @return array + */ + public function is_modified($A, $DYN_UID) + { + $file = G::decrypt($A, URL_KEY); + try { + /* Compare Properties */ + $dynaform = new dynaform(); + $dynaform->load($DYN_UID); + $form = new Form($file, PATH_DYNAFORM, SYS_LANG, true); + $sp = array('A' => $A, 'DYN_UID' => $dynaform->getDynUid(), 'PRO_UID' => $dynaform->getProUid(), 'DYN_TITLE' => $dynaform->getDynTitle(), 'DYN_TYPE' => $dynaform->getDynType(), 'DYN_DESCRIPTION' => $dynaform->getDynDescription(), 'WIDTH' => $form->width, 'ENABLETEMPLATE' => $form->enableTemplate, 'MODE' => $form->mode + ); + $P = self::get_properties($A, $DYN_UID); + if (!isset($P['DYN_TITLE'])) { + $P['DYN_TITLE'] = $sp['DYN_TITLE']; + } + if (!isset($P['DYN_TYPE'])) { + $P['DYN_TYPE'] = $sp['DYN_TYPE']; + } + if (!isset($P['DYN_DESCRIPTION'])) { + $P['DYN_DESCRIPTION'] = $sp['DYN_DESCRIPTION']; + } + if (!isset($P['WIDTH'])) { + $P['WIDTH'] = $sp['WIDTH']; + } + if (!isset($P['ENABLETEMPLATE'])) { + $P['ENABLETEMPLATE'] = $sp['ENABLETEMPLATE']; + } + if (!isset($P['MODE'])) { + $P['MODE'] = $sp['MODE']; + } + $modPro = ($sp['DYN_TITLE'] != $P['DYN_TITLE']) || ($sp['DYN_TYPE'] != $P['DYN_TYPE']) || ($sp['DYN_DESCRIPTION'] != $P['DYN_DESCRIPTION']); + /* || + ($sp['WIDTH']!=$P['WIDTH']) || + ($sp['ENABLETEMPLATE']!=$P['ENABLETEMPLATE']) || + ($sp['MODE']!=$P['MODE']) */ + /* Compare copies */ + $fileOrigen = dynaformEditor::_getFilename($file); + $copy = implode('', file(PATH_DYNAFORM . $file . '.xml')); + $origen = implode('', file(PATH_DYNAFORM . $fileOrigen . '.xml')); + $copyHTML = file_exists(PATH_DYNAFORM . $file . '.html') ? implode('', file(PATH_DYNAFORM . $file . '.html')) : false; + $origenHTML = file_exists(PATH_DYNAFORM . $fileOrigen . '.html') ? implode('', file(PATH_DYNAFORM . $fileOrigen . '.html')) : false; + $modFile = ($copy !== $origen) || ($origenHTML && ($copyHTML !== $origenHTML)); + //Return + //return array("*message"=>sprintf("%s, (%s= %s %s):", $modPro?"1":"0" , $modFile?"1":"0", ($copy!==$origen)?"1":"0" , ($origenHTML && ($copyHTML!==$origenHTML))?"1":"0" )); + //die("c'est fini"); + return $modPro || $modFile; + } catch (Exception $e) { + return (array) $e; + } + } + /* + Functionality: Funcion que convierte objecto en array + Parameters : Object $object que queremos convertir + Return: Array + */ + public function convertObjectToArray($object){ + if( !is_object( $object ) && !is_array( $object ) ){ + return $object; + } + if( is_object( $object ) ){ + $object = get_object_vars( $object ); + } + return array_map( 'objectToArray', $object ); + } +} diff --git a/workflow/engine/classes/model/BpmnLane.php b/workflow/engine/classes/model/BpmnLane.php old mode 100644 new mode 100755 index 4a4be18bc..41ec73f96 --- a/workflow/engine/classes/model/BpmnLane.php +++ b/workflow/engine/classes/model/BpmnLane.php @@ -78,7 +78,7 @@ class BpmnLane extends BaseBpmnLane { if (! is_null($prjUid)) { $c->add(BpmnLanePeer::PRJ_UID, $prjUid, Criteria::EQUAL); } - + $c->addAscendingOrderByColumn(BpmnBoundPeer::BOU_REL_POSITION); $rs = BpmnLanePeer::doSelectRS($c); $rs->setFetchmode(\ResultSet::FETCHMODE_ASSOC); diff --git a/workflow/engine/classes/model/Dynaform.php b/workflow/engine/classes/model/Dynaform.php index 69eecd8f5..ba413d9f7 100755 --- a/workflow/engine/classes/model/Dynaform.php +++ b/workflow/engine/classes/model/Dynaform.php @@ -150,7 +150,7 @@ class Dynaform extends BaseDynaform * @return void */ - public function create ($aData) + public function create ($aData, $pmTableUid='') { if (! isset( $aData['PRO_UID'] )) { throw (new PropelException( 'The dynaform cannot be created. The PRO_UID is empty.' )); @@ -194,6 +194,17 @@ class Dynaform extends BaseDynaform } $con->commit(); + + //Add Audit Log + $mode = isset($aData['MODE'])? $aData['MODE'] : 'Determined by Fields'; + $description = ""; + if($pmTableUid!=''){ + $pmTable = AdditionalTablesPeer::retrieveByPK( $pmTableUid ); + $addTabName = $pmTable->getAddTabName(); + $description = "Create from a PM Table: ".$addTabName.", "; + } + G::auditLog("CreateDynaform", $description."Dynaform Title: ".$aData['DYN_TITLE'].", Type: ".$aData['DYN_TYPE'].", Description: ".$aData['DYN_DESCRIPTION'].", Mode: ".$mode); + $sXml = '' . "\n"; $sXml .= '' . "\n"; $sXml .= ''; @@ -232,7 +243,7 @@ class Dynaform extends BaseDynaform public function createFromPMTable ($aData, $pmTableUid) { - $this->create( $aData ); + $this->create( $aData , $pmTableUid); $aData['DYN_UID'] = $this->getDynUid(); //krumo(BasePeer::getFieldnames('Content')); $fields = array (); @@ -591,9 +602,17 @@ class Dynaform extends BaseDynaform try { $oPro = DynaformPeer::retrieveByPK( $ProUid ); if (! is_null( $oPro )) { + $title = $oPro->getDynTitle(); + $type = $oPro->getDynType(); + $description = $oPro->getDynDescription(); + Content::removeContent( 'DYN_TITLE', '', $oPro->getDynUid() ); Content::removeContent( 'DYN_DESCRIPTION', '', $oPro->getDynUid() ); $iResult = $oPro->delete(); + + //Add Audit Log + G::auditLog("DeleteDynaform", "Dynaform Title: ".$title.", Type: ".$type.", Description: ".$description); + if (file_exists( PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '.xml' )) { unlink( PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '.xml' ); } diff --git a/workflow/engine/classes/model/MessageApplication.php b/workflow/engine/classes/model/MessageApplication.php new file mode 100644 index 000000000..197b3adf7 --- /dev/null +++ b/workflow/engine/classes/model/MessageApplication.php @@ -0,0 +1,5 @@ +isBpmnProcess($ProUid); return $aFields; } else { @@ -1009,5 +1011,21 @@ class Process extends BaseProcess return 0; } } + /** + * Check is the Process is BPMN. + * + * @param string $ProUid the uid of the Prolication + * @return int 1 if is BPMN process or 0 if a Normal process + */ + public function isBpmnProcess($proUid){ + $c = new Criteria("workflow"); + $c->add(BpmnProcessPeer::PRJ_UID, $proUid); + $res = BpmnProcessPeer::doSelect($c); + if( sizeof($res) == 0 ){ + return 0; + }else{ + return 1; + } + } } diff --git a/workflow/engine/classes/model/map/ListParticipatedLastMapBuilder.php b/workflow/engine/classes/model/map/ListParticipatedLastMapBuilder.php index 10a3e1bf3..78843fad8 100644 --- a/workflow/engine/classes/model/map/ListParticipatedLastMapBuilder.php +++ b/workflow/engine/classes/model/map/ListParticipatedLastMapBuilder.php @@ -81,7 +81,7 @@ class ListParticipatedLastMapBuilder $tMap->addColumn('APP_TAS_TITLE', 'AppTasTitle', 'string', CreoleTypes::VARCHAR, true, 255); - $tMap->addColumn('APP_STATUS', 'AppStatus', 'string', CreoleTypes::VARCHAR, true, 20); + $tMap->addColumn('APP_STATUS', 'AppStatus', 'string', CreoleTypes::VARCHAR, false, 20); $tMap->addColumn('DEL_INDEX', 'DelIndex', 'int', CreoleTypes::INTEGER, true, null); diff --git a/workflow/engine/classes/model/map/MessageApplicationMapBuilder.php b/workflow/engine/classes/model/map/MessageApplicationMapBuilder.php new file mode 100644 index 000000000..7a113f05c --- /dev/null +++ b/workflow/engine/classes/model/map/MessageApplicationMapBuilder.php @@ -0,0 +1,92 @@ +dbMap !== null); + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public function getDatabaseMap() + { + return $this->dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @return void + * @throws PropelException + */ + public function doBuild() + { + $this->dbMap = Propel::getDatabaseMap('workflow'); + + $tMap = $this->dbMap->addTable('MESSAGE_APPLICATION'); + $tMap->setPhpName('MessageApplication'); + + $tMap->setUseIdGenerator(false); + + $tMap->addPrimaryKey('MSGAPP_UID', 'MsgappUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('APP_UID', 'AppUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('PRJ_UID', 'PrjUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('EVN_UID_THROW', 'EvnUidThrow', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('EVN_UID_CATCH', 'EvnUidCatch', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('MSGAPP_VARIABLES', 'MsgappVariables', 'string', CreoleTypes::LONGVARCHAR, true, null); + + $tMap->addColumn('MSGAPP_CORRELATION', 'MsgappCorrelation', 'string', CreoleTypes::VARCHAR, true, 512); + + $tMap->addColumn('MSGAPP_THROW_DATE', 'MsgappThrowDate', 'int', CreoleTypes::TIMESTAMP, true, null); + + $tMap->addColumn('MSGAPP_CATCH_DATE', 'MsgappCatchDate', 'int', CreoleTypes::TIMESTAMP, false, null); + + $tMap->addColumn('MSGAPP_STATUS', 'MsgappStatus', 'string', CreoleTypes::VARCHAR, true, 25); + + $tMap->addValidator('MSGAPP_STATUS', 'validValues', 'propel.validator.ValidValuesValidator', 'READ|UNREAD', 'Please enter a valid value for MSGAPP_STATUS'); + + } // doBuild() + +} // MessageApplicationMapBuilder diff --git a/workflow/engine/classes/model/map/MessageEventDefinitionMapBuilder.php b/workflow/engine/classes/model/map/MessageEventDefinitionMapBuilder.php new file mode 100644 index 000000000..c678de147 --- /dev/null +++ b/workflow/engine/classes/model/map/MessageEventDefinitionMapBuilder.php @@ -0,0 +1,84 @@ +dbMap !== null); + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public function getDatabaseMap() + { + return $this->dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @return void + * @throws PropelException + */ + public function doBuild() + { + $this->dbMap = Propel::getDatabaseMap('workflow'); + + $tMap = $this->dbMap->addTable('MESSAGE_EVENT_DEFINITION'); + $tMap->setPhpName('MessageEventDefinition'); + + $tMap->setUseIdGenerator(false); + + $tMap->addPrimaryKey('MSGED_UID', 'MsgedUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('PRJ_UID', 'PrjUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('EVN_UID', 'EvnUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('MSGT_UID', 'MsgtUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('MSGED_USR_UID', 'MsgedUsrUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('MSGED_VARIABLES', 'MsgedVariables', 'string', CreoleTypes::LONGVARCHAR, true, null); + + $tMap->addColumn('MSGED_CORRELATION', 'MsgedCorrelation', 'string', CreoleTypes::VARCHAR, true, 512); + + } // doBuild() + +} // MessageEventDefinitionMapBuilder diff --git a/workflow/engine/classes/model/map/MessageEventRelationMapBuilder.php b/workflow/engine/classes/model/map/MessageEventRelationMapBuilder.php new file mode 100644 index 000000000..345a6f330 --- /dev/null +++ b/workflow/engine/classes/model/map/MessageEventRelationMapBuilder.php @@ -0,0 +1,78 @@ +dbMap !== null); + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public function getDatabaseMap() + { + return $this->dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @return void + * @throws PropelException + */ + public function doBuild() + { + $this->dbMap = Propel::getDatabaseMap('workflow'); + + $tMap = $this->dbMap->addTable('MESSAGE_EVENT_RELATION'); + $tMap->setPhpName('MessageEventRelation'); + + $tMap->setUseIdGenerator(false); + + $tMap->addPrimaryKey('MSGER_UID', 'MsgerUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('PRJ_UID', 'PrjUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('EVN_UID_THROW', 'EvnUidThrow', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('EVN_UID_CATCH', 'EvnUidCatch', 'string', CreoleTypes::VARCHAR, true, 32); + + } // doBuild() + +} // MessageEventRelationMapBuilder diff --git a/workflow/engine/classes/model/map/MessageEventTaskRelationMapBuilder.php b/workflow/engine/classes/model/map/MessageEventTaskRelationMapBuilder.php new file mode 100644 index 000000000..24efa6433 --- /dev/null +++ b/workflow/engine/classes/model/map/MessageEventTaskRelationMapBuilder.php @@ -0,0 +1,78 @@ +dbMap !== null); + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public function getDatabaseMap() + { + return $this->dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @return void + * @throws PropelException + */ + public function doBuild() + { + $this->dbMap = Propel::getDatabaseMap('workflow'); + + $tMap = $this->dbMap->addTable('MESSAGE_EVENT_TASK_RELATION'); + $tMap->setPhpName('MessageEventTaskRelation'); + + $tMap->setUseIdGenerator(false); + + $tMap->addPrimaryKey('MSGETR_UID', 'MsgetrUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('PRJ_UID', 'PrjUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('EVN_UID', 'EvnUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('TAS_UID', 'TasUid', 'string', CreoleTypes::VARCHAR, true, 32); + + } // doBuild() + +} // MessageEventTaskRelationMapBuilder diff --git a/workflow/engine/classes/model/map/TaskMapBuilder.php b/workflow/engine/classes/model/map/TaskMapBuilder.php index 6d3eeca67..2cc83e175 100755 --- a/workflow/engine/classes/model/map/TaskMapBuilder.php +++ b/workflow/engine/classes/model/map/TaskMapBuilder.php @@ -69,7 +69,7 @@ class TaskMapBuilder $tMap->addPrimaryKey('TAS_UID', 'TasUid', 'string', CreoleTypes::VARCHAR, true, 32); - $tMap->addColumn('TAS_TYPE', 'TasType', 'string', CreoleTypes::VARCHAR, true, 20); + $tMap->addColumn('TAS_TYPE', 'TasType', 'string', CreoleTypes::VARCHAR, true, 50); $tMap->addColumn('TAS_DURATION', 'TasDuration', 'double', CreoleTypes::DOUBLE, true, null); @@ -159,7 +159,7 @@ class TaskMapBuilder $tMap->addColumn('TAS_SELFSERVICE_EXECUTION', 'TasSelfserviceExecution', 'string', CreoleTypes::VARCHAR, false, 15); - $tMap->addValidator('TAS_TYPE', 'validValues', 'propel.validator.ValidValuesValidator', 'NORMAL|ADHOC|SUBPROCESS|HIDDEN|GATEWAYTOGATEWAY|WEBENTRYEVENT', 'Please enter a valid value for TAS_TYPE'); + $tMap->addValidator('TAS_TYPE', 'validValues', 'propel.validator.ValidValuesValidator', 'NORMAL|ADHOC|SUBPROCESS|HIDDEN|GATEWAYTOGATEWAY|WEBENTRYEVENT|START-MESSAGE-EVENT|END-MESSAGE-EVENT|INTERMEDIATE-START-MESSAGE-EVENT|INTERMEDIATE-END-MESSAGE-EVENT', 'Please enter a valid value for TAS_TYPE'); $tMap->addValidator('TAS_TIMEUNIT', 'validValues', 'propel.validator.ValidValuesValidator', 'MINUTES|HOURS|DAYS|WEEKS|MONTHS', 'Please select a valid value for TAS_TIMEUNIT.'); diff --git a/workflow/engine/classes/model/om/BaseBpmnFlow.php b/workflow/engine/classes/model/om/BaseBpmnFlow.php index 15f28a2ad..4badba254 100755 --- a/workflow/engine/classes/model/om/BaseBpmnFlow.php +++ b/workflow/engine/classes/model/om/BaseBpmnFlow.php @@ -141,7 +141,7 @@ abstract class BaseBpmnFlow extends BaseObject implements Persistent */ protected $flo_position = 0; - /** + /** * @var BpmnProject */ protected $aBpmnProject; @@ -365,7 +365,7 @@ abstract class BaseBpmnFlow extends BaseObject implements Persistent /** * Get the [flo_position] column value. - * + * * @return int */ public function getFloPosition() @@ -374,7 +374,7 @@ abstract class BaseBpmnFlow extends BaseObject implements Persistent return $this->flo_position; } - /* + /** * Set the value of [flo_uid] column. * * @param string $v new value @@ -780,7 +780,7 @@ abstract class BaseBpmnFlow extends BaseObject implements Persistent /** * Set the value of [flo_position] column. - * + * * @param int $v new value * @return void */ @@ -794,9 +794,9 @@ abstract class BaseBpmnFlow extends BaseObject implements Persistent } if ($this->flo_position !== $v || $v === 0) { - $this->flo_position = $v; - $this->modifiedColumns[] = BpmnFlowPeer::FLO_POSITION; - } + $this->flo_position = $v; + $this->modifiedColumns[] = BpmnFlowPeer::FLO_POSITION; + } } // setFloPosition() diff --git a/workflow/engine/classes/model/om/BaseMessageApplication.php b/workflow/engine/classes/model/om/BaseMessageApplication.php new file mode 100644 index 000000000..ff81a8d1a --- /dev/null +++ b/workflow/engine/classes/model/om/BaseMessageApplication.php @@ -0,0 +1,1088 @@ +msgapp_uid; + } + + /** + * Get the [app_uid] column value. + * + * @return string + */ + public function getAppUid() + { + + return $this->app_uid; + } + + /** + * Get the [prj_uid] column value. + * + * @return string + */ + public function getPrjUid() + { + + return $this->prj_uid; + } + + /** + * Get the [evn_uid_throw] column value. + * + * @return string + */ + public function getEvnUidThrow() + { + + return $this->evn_uid_throw; + } + + /** + * Get the [evn_uid_catch] column value. + * + * @return string + */ + public function getEvnUidCatch() + { + + return $this->evn_uid_catch; + } + + /** + * Get the [msgapp_variables] column value. + * + * @return string + */ + public function getMsgappVariables() + { + + return $this->msgapp_variables; + } + + /** + * Get the [msgapp_correlation] column value. + * + * @return string + */ + public function getMsgappCorrelation() + { + + return $this->msgapp_correlation; + } + + /** + * Get the [optionally formatted] [msgapp_throw_date] column value. + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the integer unix timestamp will be returned. + * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL). + * @throws PropelException - if unable to convert the date/time to timestamp. + */ + public function getMsgappThrowDate($format = 'Y-m-d H:i:s') + { + + if ($this->msgapp_throw_date === null || $this->msgapp_throw_date === '') { + return null; + } elseif (!is_int($this->msgapp_throw_date)) { + // a non-timestamp value was set externally, so we convert it + $ts = strtotime($this->msgapp_throw_date); + if ($ts === -1 || $ts === false) { + throw new PropelException("Unable to parse value of [msgapp_throw_date] as date/time value: " . + var_export($this->msgapp_throw_date, true)); + } + } else { + $ts = $this->msgapp_throw_date; + } + if ($format === null) { + return $ts; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $ts); + } else { + return date($format, $ts); + } + } + + /** + * Get the [optionally formatted] [msgapp_catch_date] column value. + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the integer unix timestamp will be returned. + * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL). + * @throws PropelException - if unable to convert the date/time to timestamp. + */ + public function getMsgappCatchDate($format = 'Y-m-d H:i:s') + { + + if ($this->msgapp_catch_date === null || $this->msgapp_catch_date === '') { + return null; + } elseif (!is_int($this->msgapp_catch_date)) { + // a non-timestamp value was set externally, so we convert it + $ts = strtotime($this->msgapp_catch_date); + if ($ts === -1 || $ts === false) { + throw new PropelException("Unable to parse value of [msgapp_catch_date] as date/time value: " . + var_export($this->msgapp_catch_date, true)); + } + } else { + $ts = $this->msgapp_catch_date; + } + if ($format === null) { + return $ts; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $ts); + } else { + return date($format, $ts); + } + } + + /** + * Get the [msgapp_status] column value. + * + * @return string + */ + public function getMsgappStatus() + { + + return $this->msgapp_status; + } + + /** + * Set the value of [msgapp_uid] column. + * + * @param string $v new value + * @return void + */ + public function setMsgappUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->msgapp_uid !== $v) { + $this->msgapp_uid = $v; + $this->modifiedColumns[] = MessageApplicationPeer::MSGAPP_UID; + } + + } // setMsgappUid() + + /** + * Set the value of [app_uid] column. + * + * @param string $v new value + * @return void + */ + public function setAppUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->app_uid !== $v) { + $this->app_uid = $v; + $this->modifiedColumns[] = MessageApplicationPeer::APP_UID; + } + + } // setAppUid() + + /** + * Set the value of [prj_uid] column. + * + * @param string $v new value + * @return void + */ + public function setPrjUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->prj_uid !== $v) { + $this->prj_uid = $v; + $this->modifiedColumns[] = MessageApplicationPeer::PRJ_UID; + } + + } // setPrjUid() + + /** + * Set the value of [evn_uid_throw] column. + * + * @param string $v new value + * @return void + */ + public function setEvnUidThrow($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->evn_uid_throw !== $v) { + $this->evn_uid_throw = $v; + $this->modifiedColumns[] = MessageApplicationPeer::EVN_UID_THROW; + } + + } // setEvnUidThrow() + + /** + * Set the value of [evn_uid_catch] column. + * + * @param string $v new value + * @return void + */ + public function setEvnUidCatch($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->evn_uid_catch !== $v) { + $this->evn_uid_catch = $v; + $this->modifiedColumns[] = MessageApplicationPeer::EVN_UID_CATCH; + } + + } // setEvnUidCatch() + + /** + * Set the value of [msgapp_variables] column. + * + * @param string $v new value + * @return void + */ + public function setMsgappVariables($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->msgapp_variables !== $v || $v === '') { + $this->msgapp_variables = $v; + $this->modifiedColumns[] = MessageApplicationPeer::MSGAPP_VARIABLES; + } + + } // setMsgappVariables() + + /** + * Set the value of [msgapp_correlation] column. + * + * @param string $v new value + * @return void + */ + public function setMsgappCorrelation($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->msgapp_correlation !== $v || $v === '') { + $this->msgapp_correlation = $v; + $this->modifiedColumns[] = MessageApplicationPeer::MSGAPP_CORRELATION; + } + + } // setMsgappCorrelation() + + /** + * Set the value of [msgapp_throw_date] column. + * + * @param int $v new value + * @return void + */ + public function setMsgappThrowDate($v) + { + + if ($v !== null && !is_int($v)) { + $ts = strtotime($v); + //Date/time accepts null values + if ($v == '') { + $ts = null; + } + if ($ts === -1 || $ts === false) { + throw new PropelException("Unable to parse date/time value for [msgapp_throw_date] from input: " . + var_export($v, true)); + } + } else { + $ts = $v; + } + if ($this->msgapp_throw_date !== $ts) { + $this->msgapp_throw_date = $ts; + $this->modifiedColumns[] = MessageApplicationPeer::MSGAPP_THROW_DATE; + } + + } // setMsgappThrowDate() + + /** + * Set the value of [msgapp_catch_date] column. + * + * @param int $v new value + * @return void + */ + public function setMsgappCatchDate($v) + { + + if ($v !== null && !is_int($v)) { + $ts = strtotime($v); + //Date/time accepts null values + if ($v == '') { + $ts = null; + } + if ($ts === -1 || $ts === false) { + throw new PropelException("Unable to parse date/time value for [msgapp_catch_date] from input: " . + var_export($v, true)); + } + } else { + $ts = $v; + } + if ($this->msgapp_catch_date !== $ts) { + $this->msgapp_catch_date = $ts; + $this->modifiedColumns[] = MessageApplicationPeer::MSGAPP_CATCH_DATE; + } + + } // setMsgappCatchDate() + + /** + * Set the value of [msgapp_status] column. + * + * @param string $v new value + * @return void + */ + public function setMsgappStatus($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->msgapp_status !== $v || $v === 'UNREAD') { + $this->msgapp_status = $v; + $this->modifiedColumns[] = MessageApplicationPeer::MSGAPP_STATUS; + } + + } // setMsgappStatus() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (1-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos. + * @param int $startcol 1-based offset column which indicates which restultset column to start with. + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->msgapp_uid = $rs->getString($startcol + 0); + + $this->app_uid = $rs->getString($startcol + 1); + + $this->prj_uid = $rs->getString($startcol + 2); + + $this->evn_uid_throw = $rs->getString($startcol + 3); + + $this->evn_uid_catch = $rs->getString($startcol + 4); + + $this->msgapp_variables = $rs->getString($startcol + 5); + + $this->msgapp_correlation = $rs->getString($startcol + 6); + + $this->msgapp_throw_date = $rs->getTimestamp($startcol + 7, null); + + $this->msgapp_catch_date = $rs->getTimestamp($startcol + 8, null); + + $this->msgapp_status = $rs->getString($startcol + 9); + + $this->resetModified(); + + $this->setNew(false); + + // FIXME - using NUM_COLUMNS may be clearer. + return $startcol + 10; // 10 = MessageApplicationPeer::NUM_COLUMNS - MessageApplicationPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating MessageApplication object", $e); + } + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param Connection $con + * @return void + * @throws PropelException + * @see BaseObject::setDeleted() + * @see BaseObject::isDeleted() + */ + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(MessageApplicationPeer::DATABASE_NAME); + } + + try { + $con->begin(); + MessageApplicationPeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * wraps the doSave() worker method in a transaction. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update + * @throws PropelException + * @see doSave() + */ + public function save($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(MessageApplicationPeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update and any referring + * @throws PropelException + * @see save() + */ + protected function doSave($con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $pk = MessageApplicationPeer::doInsert($this, $con); + $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which + // should always be true here (even though technically + // BasePeer::doInsert() can insert multiple rows). + + $this->setNew(false); + } else { + $affectedRows += MessageApplicationPeer::doUpdate($this, $con); + } + $this->resetModified(); // [HL] After being saved an object is no longer 'modified' + } + + $this->alreadyInSave = false; + } + return $affectedRows; + } // doSave() + + /** + * Array of ValidationFailed objects. + * @var array ValidationFailed[] + */ + protected $validationFailures = array(); + + /** + * Gets any ValidationFailed objects that resulted from last call to validate(). + * + * + * @return array ValidationFailed[] + * @see validate() + */ + public function getValidationFailures() + { + return $this->validationFailures; + } + + /** + * Validates the objects modified field values and all objects related to this table. + * + * If $columns is either a column name or an array of column names + * only those columns are validated. + * + * @param mixed $columns Column name or an array of column names. + * @return boolean Whether all columns pass validation. + * @see doValidate() + * @see getValidationFailures() + */ + public function validate($columns = null) + { + $res = $this->doValidate($columns); + if ($res === true) { + $this->validationFailures = array(); + return true; + } else { + $this->validationFailures = $res; + return false; + } + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; + array of ValidationFailed objects otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = MessageApplicationPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = MessageApplicationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getMsgappUid(); + break; + case 1: + return $this->getAppUid(); + break; + case 2: + return $this->getPrjUid(); + break; + case 3: + return $this->getEvnUidThrow(); + break; + case 4: + return $this->getEvnUidCatch(); + break; + case 5: + return $this->getMsgappVariables(); + break; + case 6: + return $this->getMsgappCorrelation(); + break; + case 7: + return $this->getMsgappThrowDate(); + break; + case 8: + return $this->getMsgappCatchDate(); + break; + case 9: + return $this->getMsgappStatus(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = MessageApplicationPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getMsgappUid(), + $keys[1] => $this->getAppUid(), + $keys[2] => $this->getPrjUid(), + $keys[3] => $this->getEvnUidThrow(), + $keys[4] => $this->getEvnUidCatch(), + $keys[5] => $this->getMsgappVariables(), + $keys[6] => $this->getMsgappCorrelation(), + $keys[7] => $this->getMsgappThrowDate(), + $keys[8] => $this->getMsgappCatchDate(), + $keys[9] => $this->getMsgappStatus(), + ); + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name peer name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = MessageApplicationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setMsgappUid($value); + break; + case 1: + $this->setAppUid($value); + break; + case 2: + $this->setPrjUid($value); + break; + case 3: + $this->setEvnUidThrow($value); + break; + case 4: + $this->setEvnUidCatch($value); + break; + case 5: + $this->setMsgappVariables($value); + break; + case 6: + $this->setMsgappCorrelation($value); + break; + case 7: + $this->setMsgappThrowDate($value); + break; + case 8: + $this->setMsgappCatchDate($value); + break; + case 9: + $this->setMsgappStatus($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, + * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = MessageApplicationPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) { + $this->setMsgappUid($arr[$keys[0]]); + } + + if (array_key_exists($keys[1], $arr)) { + $this->setAppUid($arr[$keys[1]]); + } + + if (array_key_exists($keys[2], $arr)) { + $this->setPrjUid($arr[$keys[2]]); + } + + if (array_key_exists($keys[3], $arr)) { + $this->setEvnUidThrow($arr[$keys[3]]); + } + + if (array_key_exists($keys[4], $arr)) { + $this->setEvnUidCatch($arr[$keys[4]]); + } + + if (array_key_exists($keys[5], $arr)) { + $this->setMsgappVariables($arr[$keys[5]]); + } + + if (array_key_exists($keys[6], $arr)) { + $this->setMsgappCorrelation($arr[$keys[6]]); + } + + if (array_key_exists($keys[7], $arr)) { + $this->setMsgappThrowDate($arr[$keys[7]]); + } + + if (array_key_exists($keys[8], $arr)) { + $this->setMsgappCatchDate($arr[$keys[8]]); + } + + if (array_key_exists($keys[9], $arr)) { + $this->setMsgappStatus($arr[$keys[9]]); + } + + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(MessageApplicationPeer::DATABASE_NAME); + + if ($this->isColumnModified(MessageApplicationPeer::MSGAPP_UID)) { + $criteria->add(MessageApplicationPeer::MSGAPP_UID, $this->msgapp_uid); + } + + if ($this->isColumnModified(MessageApplicationPeer::APP_UID)) { + $criteria->add(MessageApplicationPeer::APP_UID, $this->app_uid); + } + + if ($this->isColumnModified(MessageApplicationPeer::PRJ_UID)) { + $criteria->add(MessageApplicationPeer::PRJ_UID, $this->prj_uid); + } + + if ($this->isColumnModified(MessageApplicationPeer::EVN_UID_THROW)) { + $criteria->add(MessageApplicationPeer::EVN_UID_THROW, $this->evn_uid_throw); + } + + if ($this->isColumnModified(MessageApplicationPeer::EVN_UID_CATCH)) { + $criteria->add(MessageApplicationPeer::EVN_UID_CATCH, $this->evn_uid_catch); + } + + if ($this->isColumnModified(MessageApplicationPeer::MSGAPP_VARIABLES)) { + $criteria->add(MessageApplicationPeer::MSGAPP_VARIABLES, $this->msgapp_variables); + } + + if ($this->isColumnModified(MessageApplicationPeer::MSGAPP_CORRELATION)) { + $criteria->add(MessageApplicationPeer::MSGAPP_CORRELATION, $this->msgapp_correlation); + } + + if ($this->isColumnModified(MessageApplicationPeer::MSGAPP_THROW_DATE)) { + $criteria->add(MessageApplicationPeer::MSGAPP_THROW_DATE, $this->msgapp_throw_date); + } + + if ($this->isColumnModified(MessageApplicationPeer::MSGAPP_CATCH_DATE)) { + $criteria->add(MessageApplicationPeer::MSGAPP_CATCH_DATE, $this->msgapp_catch_date); + } + + if ($this->isColumnModified(MessageApplicationPeer::MSGAPP_STATUS)) { + $criteria->add(MessageApplicationPeer::MSGAPP_STATUS, $this->msgapp_status); + } + + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(MessageApplicationPeer::DATABASE_NAME); + + $criteria->add(MessageApplicationPeer::MSGAPP_UID, $this->msgapp_uid); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return string + */ + public function getPrimaryKey() + { + return $this->getMsgappUid(); + } + + /** + * Generic method to set the primary key (msgapp_uid column). + * + * @param string $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setMsgappUid($key); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of MessageApplication (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setAppUid($this->app_uid); + + $copyObj->setPrjUid($this->prj_uid); + + $copyObj->setEvnUidThrow($this->evn_uid_throw); + + $copyObj->setEvnUidCatch($this->evn_uid_catch); + + $copyObj->setMsgappVariables($this->msgapp_variables); + + $copyObj->setMsgappCorrelation($this->msgapp_correlation); + + $copyObj->setMsgappThrowDate($this->msgapp_throw_date); + + $copyObj->setMsgappCatchDate($this->msgapp_catch_date); + + $copyObj->setMsgappStatus($this->msgapp_status); + + + $copyObj->setNew(true); + + $copyObj->setMsgappUid(NULL); // this is a pkey column, so set to default value + + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return MessageApplication Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + /** + * Returns a peer instance associated with this om. + * + * Since Peer classes are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + * + * @return MessageApplicationPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new MessageApplicationPeer(); + } + return self::$peer; + } +} + diff --git a/workflow/engine/classes/model/om/BaseMessageApplicationPeer.php b/workflow/engine/classes/model/om/BaseMessageApplicationPeer.php new file mode 100644 index 000000000..f33bad125 --- /dev/null +++ b/workflow/engine/classes/model/om/BaseMessageApplicationPeer.php @@ -0,0 +1,615 @@ + array ('MsgappUid', 'AppUid', 'PrjUid', 'EvnUidThrow', 'EvnUidCatch', 'MsgappVariables', 'MsgappCorrelation', 'MsgappThrowDate', 'MsgappCatchDate', 'MsgappStatus', ), + BasePeer::TYPE_COLNAME => array (MessageApplicationPeer::MSGAPP_UID, MessageApplicationPeer::APP_UID, MessageApplicationPeer::PRJ_UID, MessageApplicationPeer::EVN_UID_THROW, MessageApplicationPeer::EVN_UID_CATCH, MessageApplicationPeer::MSGAPP_VARIABLES, MessageApplicationPeer::MSGAPP_CORRELATION, MessageApplicationPeer::MSGAPP_THROW_DATE, MessageApplicationPeer::MSGAPP_CATCH_DATE, MessageApplicationPeer::MSGAPP_STATUS, ), + BasePeer::TYPE_FIELDNAME => array ('MSGAPP_UID', 'APP_UID', 'PRJ_UID', 'EVN_UID_THROW', 'EVN_UID_CATCH', 'MSGAPP_VARIABLES', 'MSGAPP_CORRELATION', 'MSGAPP_THROW_DATE', 'MSGAPP_CATCH_DATE', 'MSGAPP_STATUS', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('MsgappUid' => 0, 'AppUid' => 1, 'PrjUid' => 2, 'EvnUidThrow' => 3, 'EvnUidCatch' => 4, 'MsgappVariables' => 5, 'MsgappCorrelation' => 6, 'MsgappThrowDate' => 7, 'MsgappCatchDate' => 8, 'MsgappStatus' => 9, ), + BasePeer::TYPE_COLNAME => array (MessageApplicationPeer::MSGAPP_UID => 0, MessageApplicationPeer::APP_UID => 1, MessageApplicationPeer::PRJ_UID => 2, MessageApplicationPeer::EVN_UID_THROW => 3, MessageApplicationPeer::EVN_UID_CATCH => 4, MessageApplicationPeer::MSGAPP_VARIABLES => 5, MessageApplicationPeer::MSGAPP_CORRELATION => 6, MessageApplicationPeer::MSGAPP_THROW_DATE => 7, MessageApplicationPeer::MSGAPP_CATCH_DATE => 8, MessageApplicationPeer::MSGAPP_STATUS => 9, ), + BasePeer::TYPE_FIELDNAME => array ('MSGAPP_UID' => 0, 'APP_UID' => 1, 'PRJ_UID' => 2, 'EVN_UID_THROW' => 3, 'EVN_UID_CATCH' => 4, 'MSGAPP_VARIABLES' => 5, 'MSGAPP_CORRELATION' => 6, 'MSGAPP_THROW_DATE' => 7, 'MSGAPP_CATCH_DATE' => 8, 'MSGAPP_STATUS' => 9, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + ); + + /** + * @return MapBuilder the map builder for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getMapBuilder() + { + include_once 'classes/model/map/MessageApplicationMapBuilder.php'; + return BasePeer::getMapBuilder('classes.model.map.MessageApplicationMapBuilder'); + } + /** + * Gets a map (hash) of PHP names to DB column names. + * + * @return array The PHP to DB name map for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this. + */ + public static function getPhpNameMap() + { + if (self::$phpNameMap === null) { + $map = MessageApplicationPeer::getTableMap(); + $columns = $map->getColumns(); + $nameMap = array(); + foreach ($columns as $column) { + $nameMap[$column->getPhpName()] = $column->getColumnName(); + } + self::$phpNameMap = $nameMap; + } + return self::$phpNameMap; + } + /** + * Translates a fieldname to another type + * + * @param string $name field name + * @param string $fromType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @param string $toType One of the class type constants + * @return string translated name of the field. + */ + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + /** + * Returns an array of of field names. + * + * @param string $type The type of fieldnames to return: + * One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return array A list of field names + */ + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + /** + * Convenience method which changes table.column to alias.column. + * + * Using this method you can maintain SQL abstraction while using column aliases. + * + * $c->addAlias("alias1", TablePeer::TABLE_NAME); + * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); + * + * @param string $alias The alias for the current table. + * @param string $column The column name for current table. (i.e. MessageApplicationPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(MessageApplicationPeer::TABLE_NAME.'.', $alias.'.', $column); + } + + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param criteria object containing the columns to add. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria) + { + + $criteria->addSelectColumn(MessageApplicationPeer::MSGAPP_UID); + + $criteria->addSelectColumn(MessageApplicationPeer::APP_UID); + + $criteria->addSelectColumn(MessageApplicationPeer::PRJ_UID); + + $criteria->addSelectColumn(MessageApplicationPeer::EVN_UID_THROW); + + $criteria->addSelectColumn(MessageApplicationPeer::EVN_UID_CATCH); + + $criteria->addSelectColumn(MessageApplicationPeer::MSGAPP_VARIABLES); + + $criteria->addSelectColumn(MessageApplicationPeer::MSGAPP_CORRELATION); + + $criteria->addSelectColumn(MessageApplicationPeer::MSGAPP_THROW_DATE); + + $criteria->addSelectColumn(MessageApplicationPeer::MSGAPP_CATCH_DATE); + + $criteria->addSelectColumn(MessageApplicationPeer::MSGAPP_STATUS); + + } + + const COUNT = 'COUNT(MESSAGE_APPLICATION.MSGAPP_UID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT MESSAGE_APPLICATION.MSGAPP_UID)'; + + /** + * Returns the number of rows matching criteria. + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCount(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(MessageApplicationPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(MessageApplicationPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach ($criteria->getGroupByColumns() as $column) { + $criteria->addSelectColumn($column); + } + + $rs = MessageApplicationPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + /** + * Method to select one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param Connection $con + * @return MessageApplication + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectOne(Criteria $criteria, $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = MessageApplicationPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + /** + * Method to do selects. + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con + * @return array Array of selected Objects + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelect(Criteria $criteria, $con = null) + { + return MessageApplicationPeer::populateObjects(MessageApplicationPeer::doSelectRS($criteria, $con)); + } + /** + * Prepares the Criteria object and uses the parent doSelect() + * method to get a ResultSet. + * + * Use this method directly if you want to just get the resultset + * (instead of an array of objects). + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return ResultSet The resultset object with numerically-indexed fields. + * @see BasePeer::doSelect() + */ + public static function doSelectRS(Criteria $criteria, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if (!$criteria->getSelectColumns()) { + $criteria = clone $criteria; + MessageApplicationPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + // BasePeer returns a Creole ResultSet, set to return + // rows indexed numerically. + return BasePeer::doSelect($criteria, $con); + } + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(ResultSet $rs) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = MessageApplicationPeer::getOMClass(); + $cls = Propel::import($cls); + // populate the object(s) + while ($rs->next()) { + + $obj = new $cls(); + $obj->hydrate($rs); + $results[] = $obj; + + } + return $results; + } + /** + * Returns the TableMap related to this peer. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + /** + * The class that the Peer will make instances of. + * + * This uses a dot-path notation which is tranalted into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @return string path.to.ClassName + */ + public static function getOMClass() + { + return MessageApplicationPeer::CLASS_DEFAULT; + } + + /** + * Method perform an INSERT on the database, given a MessageApplication or Criteria object. + * + * @param mixed $values Criteria or MessageApplication object containing data that is used to create the INSERT statement. + * @param Connection $con the connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from MessageApplication object + } + + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->begin(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + + return $pk; + } + + /** + * Method perform an UPDATE on the database, given a MessageApplication or Criteria object. + * + * @param mixed $values Criteria or MessageApplication object containing data create the UPDATE statement. + * @param Connection $con The connection to use (specify Connection exert more control over transactions). + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doUpdate($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(MessageApplicationPeer::MSGAPP_UID); + $selectCriteria->add(MessageApplicationPeer::MSGAPP_UID, $criteria->remove(MessageApplicationPeer::MSGAPP_UID), $comparison); + + } else { + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Method to DELETE all rows from the MESSAGE_APPLICATION table. + * + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + $affectedRows += BasePeer::doDeleteAll(MessageApplicationPeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a MessageApplication or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or MessageApplication object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param Connection $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(MessageApplicationPeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } elseif ($values instanceof MessageApplication) { + + $criteria = $values->buildPkeyCriteria(); + } else { + // it must be the primary key + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(MessageApplicationPeer::MSGAPP_UID, (array) $values, Criteria::IN); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Validates all modified columns of given MessageApplication object. + * If parameter $columns is either a single column name or an array of column names + * than only those columns are validated. + * + * NOTICE: This does not apply to primary or foreign keys for now. + * + * @param MessageApplication $obj The object to validate. + * @param mixed $cols Column name or array of column names. + * + * @return mixed TRUE if all columns are valid or the error message of the first invalid column. + */ + public static function doValidate(MessageApplication $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(MessageApplicationPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(MessageApplicationPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + if ($obj->isNew() || $obj->isColumnModified(MessageApplicationPeer::MSGAPP_STATUS)) + $columns[MessageApplicationPeer::MSGAPP_STATUS] = $obj->getMsgappStatus(); + + } + + return BasePeer::doValidate(MessageApplicationPeer::DATABASE_NAME, MessageApplicationPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param mixed $pk the primary key. + * @param Connection $con the connection to use + * @return MessageApplication + */ + public static function retrieveByPK($pk, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $criteria = new Criteria(MessageApplicationPeer::DATABASE_NAME); + + $criteria->add(MessageApplicationPeer::MSGAPP_UID, $pk); + + + $v = MessageApplicationPeer::doSelect($criteria, $con); + + return !empty($v) > 0 ? $v[0] : null; + } + + /** + * Retrieve multiple objects by pkey. + * + * @param array $pks List of primary keys + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function retrieveByPKs($pks, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(); + $criteria->add(MessageApplicationPeer::MSGAPP_UID, $pks, Criteria::IN); + $objs = MessageApplicationPeer::doSelect($criteria, $con); + } + return $objs; + } +} + + +// static code to register the map builder for this Peer with the main Propel class +if (Propel::isInit()) { + // the MapBuilder classes register themselves with Propel during initialization + // so we need to load them here. + try { + BaseMessageApplicationPeer::getMapBuilder(); + } catch (Exception $e) { + Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); + } +} else { + // even if Propel is not yet initialized, the map builder class can be registered + // now and then it will be loaded when Propel initializes. + require_once 'classes/model/map/MessageApplicationMapBuilder.php'; + Propel::registerMapBuilder('classes.model.map.MessageApplicationMapBuilder'); +} + diff --git a/workflow/engine/classes/model/om/BaseMessageEventDefinition.php b/workflow/engine/classes/model/om/BaseMessageEventDefinition.php new file mode 100644 index 000000000..49002de41 --- /dev/null +++ b/workflow/engine/classes/model/om/BaseMessageEventDefinition.php @@ -0,0 +1,858 @@ +msged_uid; + } + + /** + * Get the [prj_uid] column value. + * + * @return string + */ + public function getPrjUid() + { + + return $this->prj_uid; + } + + /** + * Get the [evn_uid] column value. + * + * @return string + */ + public function getEvnUid() + { + + return $this->evn_uid; + } + + /** + * Get the [msgt_uid] column value. + * + * @return string + */ + public function getMsgtUid() + { + + return $this->msgt_uid; + } + + /** + * Get the [msged_usr_uid] column value. + * + * @return string + */ + public function getMsgedUsrUid() + { + + return $this->msged_usr_uid; + } + + /** + * Get the [msged_variables] column value. + * + * @return string + */ + public function getMsgedVariables() + { + + return $this->msged_variables; + } + + /** + * Get the [msged_correlation] column value. + * + * @return string + */ + public function getMsgedCorrelation() + { + + return $this->msged_correlation; + } + + /** + * Set the value of [msged_uid] column. + * + * @param string $v new value + * @return void + */ + public function setMsgedUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->msged_uid !== $v) { + $this->msged_uid = $v; + $this->modifiedColumns[] = MessageEventDefinitionPeer::MSGED_UID; + } + + } // setMsgedUid() + + /** + * Set the value of [prj_uid] column. + * + * @param string $v new value + * @return void + */ + public function setPrjUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->prj_uid !== $v) { + $this->prj_uid = $v; + $this->modifiedColumns[] = MessageEventDefinitionPeer::PRJ_UID; + } + + } // setPrjUid() + + /** + * Set the value of [evn_uid] column. + * + * @param string $v new value + * @return void + */ + public function setEvnUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->evn_uid !== $v) { + $this->evn_uid = $v; + $this->modifiedColumns[] = MessageEventDefinitionPeer::EVN_UID; + } + + } // setEvnUid() + + /** + * Set the value of [msgt_uid] column. + * + * @param string $v new value + * @return void + */ + public function setMsgtUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->msgt_uid !== $v || $v === '') { + $this->msgt_uid = $v; + $this->modifiedColumns[] = MessageEventDefinitionPeer::MSGT_UID; + } + + } // setMsgtUid() + + /** + * Set the value of [msged_usr_uid] column. + * + * @param string $v new value + * @return void + */ + public function setMsgedUsrUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->msged_usr_uid !== $v || $v === '') { + $this->msged_usr_uid = $v; + $this->modifiedColumns[] = MessageEventDefinitionPeer::MSGED_USR_UID; + } + + } // setMsgedUsrUid() + + /** + * Set the value of [msged_variables] column. + * + * @param string $v new value + * @return void + */ + public function setMsgedVariables($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->msged_variables !== $v || $v === '') { + $this->msged_variables = $v; + $this->modifiedColumns[] = MessageEventDefinitionPeer::MSGED_VARIABLES; + } + + } // setMsgedVariables() + + /** + * Set the value of [msged_correlation] column. + * + * @param string $v new value + * @return void + */ + public function setMsgedCorrelation($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->msged_correlation !== $v || $v === '') { + $this->msged_correlation = $v; + $this->modifiedColumns[] = MessageEventDefinitionPeer::MSGED_CORRELATION; + } + + } // setMsgedCorrelation() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (1-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos. + * @param int $startcol 1-based offset column which indicates which restultset column to start with. + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->msged_uid = $rs->getString($startcol + 0); + + $this->prj_uid = $rs->getString($startcol + 1); + + $this->evn_uid = $rs->getString($startcol + 2); + + $this->msgt_uid = $rs->getString($startcol + 3); + + $this->msged_usr_uid = $rs->getString($startcol + 4); + + $this->msged_variables = $rs->getString($startcol + 5); + + $this->msged_correlation = $rs->getString($startcol + 6); + + $this->resetModified(); + + $this->setNew(false); + + // FIXME - using NUM_COLUMNS may be clearer. + return $startcol + 7; // 7 = MessageEventDefinitionPeer::NUM_COLUMNS - MessageEventDefinitionPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating MessageEventDefinition object", $e); + } + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param Connection $con + * @return void + * @throws PropelException + * @see BaseObject::setDeleted() + * @see BaseObject::isDeleted() + */ + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(MessageEventDefinitionPeer::DATABASE_NAME); + } + + try { + $con->begin(); + MessageEventDefinitionPeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * wraps the doSave() worker method in a transaction. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update + * @throws PropelException + * @see doSave() + */ + public function save($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(MessageEventDefinitionPeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update and any referring + * @throws PropelException + * @see save() + */ + protected function doSave($con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $pk = MessageEventDefinitionPeer::doInsert($this, $con); + $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which + // should always be true here (even though technically + // BasePeer::doInsert() can insert multiple rows). + + $this->setNew(false); + } else { + $affectedRows += MessageEventDefinitionPeer::doUpdate($this, $con); + } + $this->resetModified(); // [HL] After being saved an object is no longer 'modified' + } + + $this->alreadyInSave = false; + } + return $affectedRows; + } // doSave() + + /** + * Array of ValidationFailed objects. + * @var array ValidationFailed[] + */ + protected $validationFailures = array(); + + /** + * Gets any ValidationFailed objects that resulted from last call to validate(). + * + * + * @return array ValidationFailed[] + * @see validate() + */ + public function getValidationFailures() + { + return $this->validationFailures; + } + + /** + * Validates the objects modified field values and all objects related to this table. + * + * If $columns is either a column name or an array of column names + * only those columns are validated. + * + * @param mixed $columns Column name or an array of column names. + * @return boolean Whether all columns pass validation. + * @see doValidate() + * @see getValidationFailures() + */ + public function validate($columns = null) + { + $res = $this->doValidate($columns); + if ($res === true) { + $this->validationFailures = array(); + return true; + } else { + $this->validationFailures = $res; + return false; + } + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; + array of ValidationFailed objects otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = MessageEventDefinitionPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = MessageEventDefinitionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getMsgedUid(); + break; + case 1: + return $this->getPrjUid(); + break; + case 2: + return $this->getEvnUid(); + break; + case 3: + return $this->getMsgtUid(); + break; + case 4: + return $this->getMsgedUsrUid(); + break; + case 5: + return $this->getMsgedVariables(); + break; + case 6: + return $this->getMsgedCorrelation(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = MessageEventDefinitionPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getMsgedUid(), + $keys[1] => $this->getPrjUid(), + $keys[2] => $this->getEvnUid(), + $keys[3] => $this->getMsgtUid(), + $keys[4] => $this->getMsgedUsrUid(), + $keys[5] => $this->getMsgedVariables(), + $keys[6] => $this->getMsgedCorrelation(), + ); + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name peer name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = MessageEventDefinitionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setMsgedUid($value); + break; + case 1: + $this->setPrjUid($value); + break; + case 2: + $this->setEvnUid($value); + break; + case 3: + $this->setMsgtUid($value); + break; + case 4: + $this->setMsgedUsrUid($value); + break; + case 5: + $this->setMsgedVariables($value); + break; + case 6: + $this->setMsgedCorrelation($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, + * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = MessageEventDefinitionPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) { + $this->setMsgedUid($arr[$keys[0]]); + } + + if (array_key_exists($keys[1], $arr)) { + $this->setPrjUid($arr[$keys[1]]); + } + + if (array_key_exists($keys[2], $arr)) { + $this->setEvnUid($arr[$keys[2]]); + } + + if (array_key_exists($keys[3], $arr)) { + $this->setMsgtUid($arr[$keys[3]]); + } + + if (array_key_exists($keys[4], $arr)) { + $this->setMsgedUsrUid($arr[$keys[4]]); + } + + if (array_key_exists($keys[5], $arr)) { + $this->setMsgedVariables($arr[$keys[5]]); + } + + if (array_key_exists($keys[6], $arr)) { + $this->setMsgedCorrelation($arr[$keys[6]]); + } + + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(MessageEventDefinitionPeer::DATABASE_NAME); + + if ($this->isColumnModified(MessageEventDefinitionPeer::MSGED_UID)) { + $criteria->add(MessageEventDefinitionPeer::MSGED_UID, $this->msged_uid); + } + + if ($this->isColumnModified(MessageEventDefinitionPeer::PRJ_UID)) { + $criteria->add(MessageEventDefinitionPeer::PRJ_UID, $this->prj_uid); + } + + if ($this->isColumnModified(MessageEventDefinitionPeer::EVN_UID)) { + $criteria->add(MessageEventDefinitionPeer::EVN_UID, $this->evn_uid); + } + + if ($this->isColumnModified(MessageEventDefinitionPeer::MSGT_UID)) { + $criteria->add(MessageEventDefinitionPeer::MSGT_UID, $this->msgt_uid); + } + + if ($this->isColumnModified(MessageEventDefinitionPeer::MSGED_USR_UID)) { + $criteria->add(MessageEventDefinitionPeer::MSGED_USR_UID, $this->msged_usr_uid); + } + + if ($this->isColumnModified(MessageEventDefinitionPeer::MSGED_VARIABLES)) { + $criteria->add(MessageEventDefinitionPeer::MSGED_VARIABLES, $this->msged_variables); + } + + if ($this->isColumnModified(MessageEventDefinitionPeer::MSGED_CORRELATION)) { + $criteria->add(MessageEventDefinitionPeer::MSGED_CORRELATION, $this->msged_correlation); + } + + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(MessageEventDefinitionPeer::DATABASE_NAME); + + $criteria->add(MessageEventDefinitionPeer::MSGED_UID, $this->msged_uid); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return string + */ + public function getPrimaryKey() + { + return $this->getMsgedUid(); + } + + /** + * Generic method to set the primary key (msged_uid column). + * + * @param string $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setMsgedUid($key); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of MessageEventDefinition (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setPrjUid($this->prj_uid); + + $copyObj->setEvnUid($this->evn_uid); + + $copyObj->setMsgtUid($this->msgt_uid); + + $copyObj->setMsgedUsrUid($this->msged_usr_uid); + + $copyObj->setMsgedVariables($this->msged_variables); + + $copyObj->setMsgedCorrelation($this->msged_correlation); + + + $copyObj->setNew(true); + + $copyObj->setMsgedUid(NULL); // this is a pkey column, so set to default value + + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return MessageEventDefinition Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + /** + * Returns a peer instance associated with this om. + * + * Since Peer classes are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + * + * @return MessageEventDefinitionPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new MessageEventDefinitionPeer(); + } + return self::$peer; + } +} + diff --git a/workflow/engine/classes/model/om/BaseMessageEventDefinitionPeer.php b/workflow/engine/classes/model/om/BaseMessageEventDefinitionPeer.php new file mode 100644 index 000000000..98db053f4 --- /dev/null +++ b/workflow/engine/classes/model/om/BaseMessageEventDefinitionPeer.php @@ -0,0 +1,597 @@ + array ('MsgedUid', 'PrjUid', 'EvnUid', 'MsgtUid', 'MsgedUsrUid', 'MsgedVariables', 'MsgedCorrelation', ), + BasePeer::TYPE_COLNAME => array (MessageEventDefinitionPeer::MSGED_UID, MessageEventDefinitionPeer::PRJ_UID, MessageEventDefinitionPeer::EVN_UID, MessageEventDefinitionPeer::MSGT_UID, MessageEventDefinitionPeer::MSGED_USR_UID, MessageEventDefinitionPeer::MSGED_VARIABLES, MessageEventDefinitionPeer::MSGED_CORRELATION, ), + BasePeer::TYPE_FIELDNAME => array ('MSGED_UID', 'PRJ_UID', 'EVN_UID', 'MSGT_UID', 'MSGED_USR_UID', 'MSGED_VARIABLES', 'MSGED_CORRELATION', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('MsgedUid' => 0, 'PrjUid' => 1, 'EvnUid' => 2, 'MsgtUid' => 3, 'MsgedUsrUid' => 4, 'MsgedVariables' => 5, 'MsgedCorrelation' => 6, ), + BasePeer::TYPE_COLNAME => array (MessageEventDefinitionPeer::MSGED_UID => 0, MessageEventDefinitionPeer::PRJ_UID => 1, MessageEventDefinitionPeer::EVN_UID => 2, MessageEventDefinitionPeer::MSGT_UID => 3, MessageEventDefinitionPeer::MSGED_USR_UID => 4, MessageEventDefinitionPeer::MSGED_VARIABLES => 5, MessageEventDefinitionPeer::MSGED_CORRELATION => 6, ), + BasePeer::TYPE_FIELDNAME => array ('MSGED_UID' => 0, 'PRJ_UID' => 1, 'EVN_UID' => 2, 'MSGT_UID' => 3, 'MSGED_USR_UID' => 4, 'MSGED_VARIABLES' => 5, 'MSGED_CORRELATION' => 6, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * @return MapBuilder the map builder for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getMapBuilder() + { + include_once 'classes/model/map/MessageEventDefinitionMapBuilder.php'; + return BasePeer::getMapBuilder('classes.model.map.MessageEventDefinitionMapBuilder'); + } + /** + * Gets a map (hash) of PHP names to DB column names. + * + * @return array The PHP to DB name map for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this. + */ + public static function getPhpNameMap() + { + if (self::$phpNameMap === null) { + $map = MessageEventDefinitionPeer::getTableMap(); + $columns = $map->getColumns(); + $nameMap = array(); + foreach ($columns as $column) { + $nameMap[$column->getPhpName()] = $column->getColumnName(); + } + self::$phpNameMap = $nameMap; + } + return self::$phpNameMap; + } + /** + * Translates a fieldname to another type + * + * @param string $name field name + * @param string $fromType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @param string $toType One of the class type constants + * @return string translated name of the field. + */ + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + /** + * Returns an array of of field names. + * + * @param string $type The type of fieldnames to return: + * One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return array A list of field names + */ + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + /** + * Convenience method which changes table.column to alias.column. + * + * Using this method you can maintain SQL abstraction while using column aliases. + * + * $c->addAlias("alias1", TablePeer::TABLE_NAME); + * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); + * + * @param string $alias The alias for the current table. + * @param string $column The column name for current table. (i.e. MessageEventDefinitionPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(MessageEventDefinitionPeer::TABLE_NAME.'.', $alias.'.', $column); + } + + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param criteria object containing the columns to add. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria) + { + + $criteria->addSelectColumn(MessageEventDefinitionPeer::MSGED_UID); + + $criteria->addSelectColumn(MessageEventDefinitionPeer::PRJ_UID); + + $criteria->addSelectColumn(MessageEventDefinitionPeer::EVN_UID); + + $criteria->addSelectColumn(MessageEventDefinitionPeer::MSGT_UID); + + $criteria->addSelectColumn(MessageEventDefinitionPeer::MSGED_USR_UID); + + $criteria->addSelectColumn(MessageEventDefinitionPeer::MSGED_VARIABLES); + + $criteria->addSelectColumn(MessageEventDefinitionPeer::MSGED_CORRELATION); + + } + + const COUNT = 'COUNT(MESSAGE_EVENT_DEFINITION.MSGED_UID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT MESSAGE_EVENT_DEFINITION.MSGED_UID)'; + + /** + * Returns the number of rows matching criteria. + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCount(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(MessageEventDefinitionPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(MessageEventDefinitionPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach ($criteria->getGroupByColumns() as $column) { + $criteria->addSelectColumn($column); + } + + $rs = MessageEventDefinitionPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + /** + * Method to select one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param Connection $con + * @return MessageEventDefinition + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectOne(Criteria $criteria, $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = MessageEventDefinitionPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + /** + * Method to do selects. + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con + * @return array Array of selected Objects + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelect(Criteria $criteria, $con = null) + { + return MessageEventDefinitionPeer::populateObjects(MessageEventDefinitionPeer::doSelectRS($criteria, $con)); + } + /** + * Prepares the Criteria object and uses the parent doSelect() + * method to get a ResultSet. + * + * Use this method directly if you want to just get the resultset + * (instead of an array of objects). + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return ResultSet The resultset object with numerically-indexed fields. + * @see BasePeer::doSelect() + */ + public static function doSelectRS(Criteria $criteria, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if (!$criteria->getSelectColumns()) { + $criteria = clone $criteria; + MessageEventDefinitionPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + // BasePeer returns a Creole ResultSet, set to return + // rows indexed numerically. + return BasePeer::doSelect($criteria, $con); + } + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(ResultSet $rs) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = MessageEventDefinitionPeer::getOMClass(); + $cls = Propel::import($cls); + // populate the object(s) + while ($rs->next()) { + + $obj = new $cls(); + $obj->hydrate($rs); + $results[] = $obj; + + } + return $results; + } + /** + * Returns the TableMap related to this peer. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + /** + * The class that the Peer will make instances of. + * + * This uses a dot-path notation which is tranalted into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @return string path.to.ClassName + */ + public static function getOMClass() + { + return MessageEventDefinitionPeer::CLASS_DEFAULT; + } + + /** + * Method perform an INSERT on the database, given a MessageEventDefinition or Criteria object. + * + * @param mixed $values Criteria or MessageEventDefinition object containing data that is used to create the INSERT statement. + * @param Connection $con the connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from MessageEventDefinition object + } + + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->begin(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + + return $pk; + } + + /** + * Method perform an UPDATE on the database, given a MessageEventDefinition or Criteria object. + * + * @param mixed $values Criteria or MessageEventDefinition object containing data create the UPDATE statement. + * @param Connection $con The connection to use (specify Connection exert more control over transactions). + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doUpdate($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(MessageEventDefinitionPeer::MSGED_UID); + $selectCriteria->add(MessageEventDefinitionPeer::MSGED_UID, $criteria->remove(MessageEventDefinitionPeer::MSGED_UID), $comparison); + + } else { + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Method to DELETE all rows from the MESSAGE_EVENT_DEFINITION table. + * + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + $affectedRows += BasePeer::doDeleteAll(MessageEventDefinitionPeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a MessageEventDefinition or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or MessageEventDefinition object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param Connection $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(MessageEventDefinitionPeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } elseif ($values instanceof MessageEventDefinition) { + + $criteria = $values->buildPkeyCriteria(); + } else { + // it must be the primary key + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(MessageEventDefinitionPeer::MSGED_UID, (array) $values, Criteria::IN); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Validates all modified columns of given MessageEventDefinition object. + * If parameter $columns is either a single column name or an array of column names + * than only those columns are validated. + * + * NOTICE: This does not apply to primary or foreign keys for now. + * + * @param MessageEventDefinition $obj The object to validate. + * @param mixed $cols Column name or array of column names. + * + * @return mixed TRUE if all columns are valid or the error message of the first invalid column. + */ + public static function doValidate(MessageEventDefinition $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(MessageEventDefinitionPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(MessageEventDefinitionPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(MessageEventDefinitionPeer::DATABASE_NAME, MessageEventDefinitionPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param mixed $pk the primary key. + * @param Connection $con the connection to use + * @return MessageEventDefinition + */ + public static function retrieveByPK($pk, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $criteria = new Criteria(MessageEventDefinitionPeer::DATABASE_NAME); + + $criteria->add(MessageEventDefinitionPeer::MSGED_UID, $pk); + + + $v = MessageEventDefinitionPeer::doSelect($criteria, $con); + + return !empty($v) > 0 ? $v[0] : null; + } + + /** + * Retrieve multiple objects by pkey. + * + * @param array $pks List of primary keys + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function retrieveByPKs($pks, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(); + $criteria->add(MessageEventDefinitionPeer::MSGED_UID, $pks, Criteria::IN); + $objs = MessageEventDefinitionPeer::doSelect($criteria, $con); + } + return $objs; + } +} + + +// static code to register the map builder for this Peer with the main Propel class +if (Propel::isInit()) { + // the MapBuilder classes register themselves with Propel during initialization + // so we need to load them here. + try { + BaseMessageEventDefinitionPeer::getMapBuilder(); + } catch (Exception $e) { + Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); + } +} else { + // even if Propel is not yet initialized, the map builder class can be registered + // now and then it will be loaded when Propel initializes. + require_once 'classes/model/map/MessageEventDefinitionMapBuilder.php'; + Propel::registerMapBuilder('classes.model.map.MessageEventDefinitionMapBuilder'); +} + diff --git a/workflow/engine/classes/model/om/BaseMessageEventRelation.php b/workflow/engine/classes/model/om/BaseMessageEventRelation.php new file mode 100644 index 000000000..90f850e22 --- /dev/null +++ b/workflow/engine/classes/model/om/BaseMessageEventRelation.php @@ -0,0 +1,684 @@ +msger_uid; + } + + /** + * Get the [prj_uid] column value. + * + * @return string + */ + public function getPrjUid() + { + + return $this->prj_uid; + } + + /** + * Get the [evn_uid_throw] column value. + * + * @return string + */ + public function getEvnUidThrow() + { + + return $this->evn_uid_throw; + } + + /** + * Get the [evn_uid_catch] column value. + * + * @return string + */ + public function getEvnUidCatch() + { + + return $this->evn_uid_catch; + } + + /** + * Set the value of [msger_uid] column. + * + * @param string $v new value + * @return void + */ + public function setMsgerUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->msger_uid !== $v) { + $this->msger_uid = $v; + $this->modifiedColumns[] = MessageEventRelationPeer::MSGER_UID; + } + + } // setMsgerUid() + + /** + * Set the value of [prj_uid] column. + * + * @param string $v new value + * @return void + */ + public function setPrjUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->prj_uid !== $v) { + $this->prj_uid = $v; + $this->modifiedColumns[] = MessageEventRelationPeer::PRJ_UID; + } + + } // setPrjUid() + + /** + * Set the value of [evn_uid_throw] column. + * + * @param string $v new value + * @return void + */ + public function setEvnUidThrow($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->evn_uid_throw !== $v) { + $this->evn_uid_throw = $v; + $this->modifiedColumns[] = MessageEventRelationPeer::EVN_UID_THROW; + } + + } // setEvnUidThrow() + + /** + * Set the value of [evn_uid_catch] column. + * + * @param string $v new value + * @return void + */ + public function setEvnUidCatch($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->evn_uid_catch !== $v) { + $this->evn_uid_catch = $v; + $this->modifiedColumns[] = MessageEventRelationPeer::EVN_UID_CATCH; + } + + } // setEvnUidCatch() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (1-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos. + * @param int $startcol 1-based offset column which indicates which restultset column to start with. + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->msger_uid = $rs->getString($startcol + 0); + + $this->prj_uid = $rs->getString($startcol + 1); + + $this->evn_uid_throw = $rs->getString($startcol + 2); + + $this->evn_uid_catch = $rs->getString($startcol + 3); + + $this->resetModified(); + + $this->setNew(false); + + // FIXME - using NUM_COLUMNS may be clearer. + return $startcol + 4; // 4 = MessageEventRelationPeer::NUM_COLUMNS - MessageEventRelationPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating MessageEventRelation object", $e); + } + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param Connection $con + * @return void + * @throws PropelException + * @see BaseObject::setDeleted() + * @see BaseObject::isDeleted() + */ + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(MessageEventRelationPeer::DATABASE_NAME); + } + + try { + $con->begin(); + MessageEventRelationPeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * wraps the doSave() worker method in a transaction. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update + * @throws PropelException + * @see doSave() + */ + public function save($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(MessageEventRelationPeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update and any referring + * @throws PropelException + * @see save() + */ + protected function doSave($con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $pk = MessageEventRelationPeer::doInsert($this, $con); + $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which + // should always be true here (even though technically + // BasePeer::doInsert() can insert multiple rows). + + $this->setNew(false); + } else { + $affectedRows += MessageEventRelationPeer::doUpdate($this, $con); + } + $this->resetModified(); // [HL] After being saved an object is no longer 'modified' + } + + $this->alreadyInSave = false; + } + return $affectedRows; + } // doSave() + + /** + * Array of ValidationFailed objects. + * @var array ValidationFailed[] + */ + protected $validationFailures = array(); + + /** + * Gets any ValidationFailed objects that resulted from last call to validate(). + * + * + * @return array ValidationFailed[] + * @see validate() + */ + public function getValidationFailures() + { + return $this->validationFailures; + } + + /** + * Validates the objects modified field values and all objects related to this table. + * + * If $columns is either a column name or an array of column names + * only those columns are validated. + * + * @param mixed $columns Column name or an array of column names. + * @return boolean Whether all columns pass validation. + * @see doValidate() + * @see getValidationFailures() + */ + public function validate($columns = null) + { + $res = $this->doValidate($columns); + if ($res === true) { + $this->validationFailures = array(); + return true; + } else { + $this->validationFailures = $res; + return false; + } + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; + array of ValidationFailed objects otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = MessageEventRelationPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = MessageEventRelationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getMsgerUid(); + break; + case 1: + return $this->getPrjUid(); + break; + case 2: + return $this->getEvnUidThrow(); + break; + case 3: + return $this->getEvnUidCatch(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = MessageEventRelationPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getMsgerUid(), + $keys[1] => $this->getPrjUid(), + $keys[2] => $this->getEvnUidThrow(), + $keys[3] => $this->getEvnUidCatch(), + ); + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name peer name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = MessageEventRelationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setMsgerUid($value); + break; + case 1: + $this->setPrjUid($value); + break; + case 2: + $this->setEvnUidThrow($value); + break; + case 3: + $this->setEvnUidCatch($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, + * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = MessageEventRelationPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) { + $this->setMsgerUid($arr[$keys[0]]); + } + + if (array_key_exists($keys[1], $arr)) { + $this->setPrjUid($arr[$keys[1]]); + } + + if (array_key_exists($keys[2], $arr)) { + $this->setEvnUidThrow($arr[$keys[2]]); + } + + if (array_key_exists($keys[3], $arr)) { + $this->setEvnUidCatch($arr[$keys[3]]); + } + + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(MessageEventRelationPeer::DATABASE_NAME); + + if ($this->isColumnModified(MessageEventRelationPeer::MSGER_UID)) { + $criteria->add(MessageEventRelationPeer::MSGER_UID, $this->msger_uid); + } + + if ($this->isColumnModified(MessageEventRelationPeer::PRJ_UID)) { + $criteria->add(MessageEventRelationPeer::PRJ_UID, $this->prj_uid); + } + + if ($this->isColumnModified(MessageEventRelationPeer::EVN_UID_THROW)) { + $criteria->add(MessageEventRelationPeer::EVN_UID_THROW, $this->evn_uid_throw); + } + + if ($this->isColumnModified(MessageEventRelationPeer::EVN_UID_CATCH)) { + $criteria->add(MessageEventRelationPeer::EVN_UID_CATCH, $this->evn_uid_catch); + } + + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(MessageEventRelationPeer::DATABASE_NAME); + + $criteria->add(MessageEventRelationPeer::MSGER_UID, $this->msger_uid); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return string + */ + public function getPrimaryKey() + { + return $this->getMsgerUid(); + } + + /** + * Generic method to set the primary key (msger_uid column). + * + * @param string $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setMsgerUid($key); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of MessageEventRelation (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setPrjUid($this->prj_uid); + + $copyObj->setEvnUidThrow($this->evn_uid_throw); + + $copyObj->setEvnUidCatch($this->evn_uid_catch); + + + $copyObj->setNew(true); + + $copyObj->setMsgerUid(NULL); // this is a pkey column, so set to default value + + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return MessageEventRelation Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + /** + * Returns a peer instance associated with this om. + * + * Since Peer classes are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + * + * @return MessageEventRelationPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new MessageEventRelationPeer(); + } + return self::$peer; + } +} + diff --git a/workflow/engine/classes/model/om/BaseMessageEventRelationPeer.php b/workflow/engine/classes/model/om/BaseMessageEventRelationPeer.php new file mode 100644 index 000000000..379fa84c9 --- /dev/null +++ b/workflow/engine/classes/model/om/BaseMessageEventRelationPeer.php @@ -0,0 +1,582 @@ + array ('MsgerUid', 'PrjUid', 'EvnUidThrow', 'EvnUidCatch', ), + BasePeer::TYPE_COLNAME => array (MessageEventRelationPeer::MSGER_UID, MessageEventRelationPeer::PRJ_UID, MessageEventRelationPeer::EVN_UID_THROW, MessageEventRelationPeer::EVN_UID_CATCH, ), + BasePeer::TYPE_FIELDNAME => array ('MSGER_UID', 'PRJ_UID', 'EVN_UID_THROW', 'EVN_UID_CATCH', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('MsgerUid' => 0, 'PrjUid' => 1, 'EvnUidThrow' => 2, 'EvnUidCatch' => 3, ), + BasePeer::TYPE_COLNAME => array (MessageEventRelationPeer::MSGER_UID => 0, MessageEventRelationPeer::PRJ_UID => 1, MessageEventRelationPeer::EVN_UID_THROW => 2, MessageEventRelationPeer::EVN_UID_CATCH => 3, ), + BasePeer::TYPE_FIELDNAME => array ('MSGER_UID' => 0, 'PRJ_UID' => 1, 'EVN_UID_THROW' => 2, 'EVN_UID_CATCH' => 3, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + ); + + /** + * @return MapBuilder the map builder for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getMapBuilder() + { + include_once 'classes/model/map/MessageEventRelationMapBuilder.php'; + return BasePeer::getMapBuilder('classes.model.map.MessageEventRelationMapBuilder'); + } + /** + * Gets a map (hash) of PHP names to DB column names. + * + * @return array The PHP to DB name map for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this. + */ + public static function getPhpNameMap() + { + if (self::$phpNameMap === null) { + $map = MessageEventRelationPeer::getTableMap(); + $columns = $map->getColumns(); + $nameMap = array(); + foreach ($columns as $column) { + $nameMap[$column->getPhpName()] = $column->getColumnName(); + } + self::$phpNameMap = $nameMap; + } + return self::$phpNameMap; + } + /** + * Translates a fieldname to another type + * + * @param string $name field name + * @param string $fromType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @param string $toType One of the class type constants + * @return string translated name of the field. + */ + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + /** + * Returns an array of of field names. + * + * @param string $type The type of fieldnames to return: + * One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return array A list of field names + */ + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + /** + * Convenience method which changes table.column to alias.column. + * + * Using this method you can maintain SQL abstraction while using column aliases. + * + * $c->addAlias("alias1", TablePeer::TABLE_NAME); + * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); + * + * @param string $alias The alias for the current table. + * @param string $column The column name for current table. (i.e. MessageEventRelationPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(MessageEventRelationPeer::TABLE_NAME.'.', $alias.'.', $column); + } + + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param criteria object containing the columns to add. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria) + { + + $criteria->addSelectColumn(MessageEventRelationPeer::MSGER_UID); + + $criteria->addSelectColumn(MessageEventRelationPeer::PRJ_UID); + + $criteria->addSelectColumn(MessageEventRelationPeer::EVN_UID_THROW); + + $criteria->addSelectColumn(MessageEventRelationPeer::EVN_UID_CATCH); + + } + + const COUNT = 'COUNT(MESSAGE_EVENT_RELATION.MSGER_UID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT MESSAGE_EVENT_RELATION.MSGER_UID)'; + + /** + * Returns the number of rows matching criteria. + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCount(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(MessageEventRelationPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(MessageEventRelationPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach ($criteria->getGroupByColumns() as $column) { + $criteria->addSelectColumn($column); + } + + $rs = MessageEventRelationPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + /** + * Method to select one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param Connection $con + * @return MessageEventRelation + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectOne(Criteria $criteria, $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = MessageEventRelationPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + /** + * Method to do selects. + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con + * @return array Array of selected Objects + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelect(Criteria $criteria, $con = null) + { + return MessageEventRelationPeer::populateObjects(MessageEventRelationPeer::doSelectRS($criteria, $con)); + } + /** + * Prepares the Criteria object and uses the parent doSelect() + * method to get a ResultSet. + * + * Use this method directly if you want to just get the resultset + * (instead of an array of objects). + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return ResultSet The resultset object with numerically-indexed fields. + * @see BasePeer::doSelect() + */ + public static function doSelectRS(Criteria $criteria, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if (!$criteria->getSelectColumns()) { + $criteria = clone $criteria; + MessageEventRelationPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + // BasePeer returns a Creole ResultSet, set to return + // rows indexed numerically. + return BasePeer::doSelect($criteria, $con); + } + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(ResultSet $rs) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = MessageEventRelationPeer::getOMClass(); + $cls = Propel::import($cls); + // populate the object(s) + while ($rs->next()) { + + $obj = new $cls(); + $obj->hydrate($rs); + $results[] = $obj; + + } + return $results; + } + /** + * Returns the TableMap related to this peer. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + /** + * The class that the Peer will make instances of. + * + * This uses a dot-path notation which is tranalted into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @return string path.to.ClassName + */ + public static function getOMClass() + { + return MessageEventRelationPeer::CLASS_DEFAULT; + } + + /** + * Method perform an INSERT on the database, given a MessageEventRelation or Criteria object. + * + * @param mixed $values Criteria or MessageEventRelation object containing data that is used to create the INSERT statement. + * @param Connection $con the connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from MessageEventRelation object + } + + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->begin(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + + return $pk; + } + + /** + * Method perform an UPDATE on the database, given a MessageEventRelation or Criteria object. + * + * @param mixed $values Criteria or MessageEventRelation object containing data create the UPDATE statement. + * @param Connection $con The connection to use (specify Connection exert more control over transactions). + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doUpdate($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(MessageEventRelationPeer::MSGER_UID); + $selectCriteria->add(MessageEventRelationPeer::MSGER_UID, $criteria->remove(MessageEventRelationPeer::MSGER_UID), $comparison); + + } else { + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Method to DELETE all rows from the MESSAGE_EVENT_RELATION table. + * + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + $affectedRows += BasePeer::doDeleteAll(MessageEventRelationPeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a MessageEventRelation or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or MessageEventRelation object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param Connection $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(MessageEventRelationPeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } elseif ($values instanceof MessageEventRelation) { + + $criteria = $values->buildPkeyCriteria(); + } else { + // it must be the primary key + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(MessageEventRelationPeer::MSGER_UID, (array) $values, Criteria::IN); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Validates all modified columns of given MessageEventRelation object. + * If parameter $columns is either a single column name or an array of column names + * than only those columns are validated. + * + * NOTICE: This does not apply to primary or foreign keys for now. + * + * @param MessageEventRelation $obj The object to validate. + * @param mixed $cols Column name or array of column names. + * + * @return mixed TRUE if all columns are valid or the error message of the first invalid column. + */ + public static function doValidate(MessageEventRelation $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(MessageEventRelationPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(MessageEventRelationPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(MessageEventRelationPeer::DATABASE_NAME, MessageEventRelationPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param mixed $pk the primary key. + * @param Connection $con the connection to use + * @return MessageEventRelation + */ + public static function retrieveByPK($pk, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $criteria = new Criteria(MessageEventRelationPeer::DATABASE_NAME); + + $criteria->add(MessageEventRelationPeer::MSGER_UID, $pk); + + + $v = MessageEventRelationPeer::doSelect($criteria, $con); + + return !empty($v) > 0 ? $v[0] : null; + } + + /** + * Retrieve multiple objects by pkey. + * + * @param array $pks List of primary keys + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function retrieveByPKs($pks, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(); + $criteria->add(MessageEventRelationPeer::MSGER_UID, $pks, Criteria::IN); + $objs = MessageEventRelationPeer::doSelect($criteria, $con); + } + return $objs; + } +} + + +// static code to register the map builder for this Peer with the main Propel class +if (Propel::isInit()) { + // the MapBuilder classes register themselves with Propel during initialization + // so we need to load them here. + try { + BaseMessageEventRelationPeer::getMapBuilder(); + } catch (Exception $e) { + Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); + } +} else { + // even if Propel is not yet initialized, the map builder class can be registered + // now and then it will be loaded when Propel initializes. + require_once 'classes/model/map/MessageEventRelationMapBuilder.php'; + Propel::registerMapBuilder('classes.model.map.MessageEventRelationMapBuilder'); +} + diff --git a/workflow/engine/classes/model/om/BaseMessageEventTaskRelation.php b/workflow/engine/classes/model/om/BaseMessageEventTaskRelation.php new file mode 100644 index 000000000..44208e082 --- /dev/null +++ b/workflow/engine/classes/model/om/BaseMessageEventTaskRelation.php @@ -0,0 +1,684 @@ +msgetr_uid; + } + + /** + * Get the [prj_uid] column value. + * + * @return string + */ + public function getPrjUid() + { + + return $this->prj_uid; + } + + /** + * Get the [evn_uid] column value. + * + * @return string + */ + public function getEvnUid() + { + + return $this->evn_uid; + } + + /** + * Get the [tas_uid] column value. + * + * @return string + */ + public function getTasUid() + { + + return $this->tas_uid; + } + + /** + * Set the value of [msgetr_uid] column. + * + * @param string $v new value + * @return void + */ + public function setMsgetrUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->msgetr_uid !== $v) { + $this->msgetr_uid = $v; + $this->modifiedColumns[] = MessageEventTaskRelationPeer::MSGETR_UID; + } + + } // setMsgetrUid() + + /** + * Set the value of [prj_uid] column. + * + * @param string $v new value + * @return void + */ + public function setPrjUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->prj_uid !== $v) { + $this->prj_uid = $v; + $this->modifiedColumns[] = MessageEventTaskRelationPeer::PRJ_UID; + } + + } // setPrjUid() + + /** + * Set the value of [evn_uid] column. + * + * @param string $v new value + * @return void + */ + public function setEvnUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->evn_uid !== $v) { + $this->evn_uid = $v; + $this->modifiedColumns[] = MessageEventTaskRelationPeer::EVN_UID; + } + + } // setEvnUid() + + /** + * Set the value of [tas_uid] column. + * + * @param string $v new value + * @return void + */ + public function setTasUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->tas_uid !== $v) { + $this->tas_uid = $v; + $this->modifiedColumns[] = MessageEventTaskRelationPeer::TAS_UID; + } + + } // setTasUid() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (1-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos. + * @param int $startcol 1-based offset column which indicates which restultset column to start with. + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->msgetr_uid = $rs->getString($startcol + 0); + + $this->prj_uid = $rs->getString($startcol + 1); + + $this->evn_uid = $rs->getString($startcol + 2); + + $this->tas_uid = $rs->getString($startcol + 3); + + $this->resetModified(); + + $this->setNew(false); + + // FIXME - using NUM_COLUMNS may be clearer. + return $startcol + 4; // 4 = MessageEventTaskRelationPeer::NUM_COLUMNS - MessageEventTaskRelationPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating MessageEventTaskRelation object", $e); + } + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param Connection $con + * @return void + * @throws PropelException + * @see BaseObject::setDeleted() + * @see BaseObject::isDeleted() + */ + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(MessageEventTaskRelationPeer::DATABASE_NAME); + } + + try { + $con->begin(); + MessageEventTaskRelationPeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * wraps the doSave() worker method in a transaction. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update + * @throws PropelException + * @see doSave() + */ + public function save($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(MessageEventTaskRelationPeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update and any referring + * @throws PropelException + * @see save() + */ + protected function doSave($con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $pk = MessageEventTaskRelationPeer::doInsert($this, $con); + $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which + // should always be true here (even though technically + // BasePeer::doInsert() can insert multiple rows). + + $this->setNew(false); + } else { + $affectedRows += MessageEventTaskRelationPeer::doUpdate($this, $con); + } + $this->resetModified(); // [HL] After being saved an object is no longer 'modified' + } + + $this->alreadyInSave = false; + } + return $affectedRows; + } // doSave() + + /** + * Array of ValidationFailed objects. + * @var array ValidationFailed[] + */ + protected $validationFailures = array(); + + /** + * Gets any ValidationFailed objects that resulted from last call to validate(). + * + * + * @return array ValidationFailed[] + * @see validate() + */ + public function getValidationFailures() + { + return $this->validationFailures; + } + + /** + * Validates the objects modified field values and all objects related to this table. + * + * If $columns is either a column name or an array of column names + * only those columns are validated. + * + * @param mixed $columns Column name or an array of column names. + * @return boolean Whether all columns pass validation. + * @see doValidate() + * @see getValidationFailures() + */ + public function validate($columns = null) + { + $res = $this->doValidate($columns); + if ($res === true) { + $this->validationFailures = array(); + return true; + } else { + $this->validationFailures = $res; + return false; + } + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; + array of ValidationFailed objects otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = MessageEventTaskRelationPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = MessageEventTaskRelationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getMsgetrUid(); + break; + case 1: + return $this->getPrjUid(); + break; + case 2: + return $this->getEvnUid(); + break; + case 3: + return $this->getTasUid(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = MessageEventTaskRelationPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getMsgetrUid(), + $keys[1] => $this->getPrjUid(), + $keys[2] => $this->getEvnUid(), + $keys[3] => $this->getTasUid(), + ); + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name peer name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = MessageEventTaskRelationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setMsgetrUid($value); + break; + case 1: + $this->setPrjUid($value); + break; + case 2: + $this->setEvnUid($value); + break; + case 3: + $this->setTasUid($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, + * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = MessageEventTaskRelationPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) { + $this->setMsgetrUid($arr[$keys[0]]); + } + + if (array_key_exists($keys[1], $arr)) { + $this->setPrjUid($arr[$keys[1]]); + } + + if (array_key_exists($keys[2], $arr)) { + $this->setEvnUid($arr[$keys[2]]); + } + + if (array_key_exists($keys[3], $arr)) { + $this->setTasUid($arr[$keys[3]]); + } + + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(MessageEventTaskRelationPeer::DATABASE_NAME); + + if ($this->isColumnModified(MessageEventTaskRelationPeer::MSGETR_UID)) { + $criteria->add(MessageEventTaskRelationPeer::MSGETR_UID, $this->msgetr_uid); + } + + if ($this->isColumnModified(MessageEventTaskRelationPeer::PRJ_UID)) { + $criteria->add(MessageEventTaskRelationPeer::PRJ_UID, $this->prj_uid); + } + + if ($this->isColumnModified(MessageEventTaskRelationPeer::EVN_UID)) { + $criteria->add(MessageEventTaskRelationPeer::EVN_UID, $this->evn_uid); + } + + if ($this->isColumnModified(MessageEventTaskRelationPeer::TAS_UID)) { + $criteria->add(MessageEventTaskRelationPeer::TAS_UID, $this->tas_uid); + } + + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(MessageEventTaskRelationPeer::DATABASE_NAME); + + $criteria->add(MessageEventTaskRelationPeer::MSGETR_UID, $this->msgetr_uid); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return string + */ + public function getPrimaryKey() + { + return $this->getMsgetrUid(); + } + + /** + * Generic method to set the primary key (msgetr_uid column). + * + * @param string $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setMsgetrUid($key); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of MessageEventTaskRelation (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setPrjUid($this->prj_uid); + + $copyObj->setEvnUid($this->evn_uid); + + $copyObj->setTasUid($this->tas_uid); + + + $copyObj->setNew(true); + + $copyObj->setMsgetrUid(NULL); // this is a pkey column, so set to default value + + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return MessageEventTaskRelation Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + /** + * Returns a peer instance associated with this om. + * + * Since Peer classes are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + * + * @return MessageEventTaskRelationPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new MessageEventTaskRelationPeer(); + } + return self::$peer; + } +} + diff --git a/workflow/engine/classes/model/om/BaseMessageEventTaskRelationPeer.php b/workflow/engine/classes/model/om/BaseMessageEventTaskRelationPeer.php new file mode 100644 index 000000000..d5a6f62d9 --- /dev/null +++ b/workflow/engine/classes/model/om/BaseMessageEventTaskRelationPeer.php @@ -0,0 +1,582 @@ + array ('MsgetrUid', 'PrjUid', 'EvnUid', 'TasUid', ), + BasePeer::TYPE_COLNAME => array (MessageEventTaskRelationPeer::MSGETR_UID, MessageEventTaskRelationPeer::PRJ_UID, MessageEventTaskRelationPeer::EVN_UID, MessageEventTaskRelationPeer::TAS_UID, ), + BasePeer::TYPE_FIELDNAME => array ('MSGETR_UID', 'PRJ_UID', 'EVN_UID', 'TAS_UID', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('MsgetrUid' => 0, 'PrjUid' => 1, 'EvnUid' => 2, 'TasUid' => 3, ), + BasePeer::TYPE_COLNAME => array (MessageEventTaskRelationPeer::MSGETR_UID => 0, MessageEventTaskRelationPeer::PRJ_UID => 1, MessageEventTaskRelationPeer::EVN_UID => 2, MessageEventTaskRelationPeer::TAS_UID => 3, ), + BasePeer::TYPE_FIELDNAME => array ('MSGETR_UID' => 0, 'PRJ_UID' => 1, 'EVN_UID' => 2, 'TAS_UID' => 3, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + ); + + /** + * @return MapBuilder the map builder for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getMapBuilder() + { + include_once 'classes/model/map/MessageEventTaskRelationMapBuilder.php'; + return BasePeer::getMapBuilder('classes.model.map.MessageEventTaskRelationMapBuilder'); + } + /** + * Gets a map (hash) of PHP names to DB column names. + * + * @return array The PHP to DB name map for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this. + */ + public static function getPhpNameMap() + { + if (self::$phpNameMap === null) { + $map = MessageEventTaskRelationPeer::getTableMap(); + $columns = $map->getColumns(); + $nameMap = array(); + foreach ($columns as $column) { + $nameMap[$column->getPhpName()] = $column->getColumnName(); + } + self::$phpNameMap = $nameMap; + } + return self::$phpNameMap; + } + /** + * Translates a fieldname to another type + * + * @param string $name field name + * @param string $fromType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @param string $toType One of the class type constants + * @return string translated name of the field. + */ + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + /** + * Returns an array of of field names. + * + * @param string $type The type of fieldnames to return: + * One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return array A list of field names + */ + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + /** + * Convenience method which changes table.column to alias.column. + * + * Using this method you can maintain SQL abstraction while using column aliases. + * + * $c->addAlias("alias1", TablePeer::TABLE_NAME); + * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); + * + * @param string $alias The alias for the current table. + * @param string $column The column name for current table. (i.e. MessageEventTaskRelationPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(MessageEventTaskRelationPeer::TABLE_NAME.'.', $alias.'.', $column); + } + + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param criteria object containing the columns to add. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria) + { + + $criteria->addSelectColumn(MessageEventTaskRelationPeer::MSGETR_UID); + + $criteria->addSelectColumn(MessageEventTaskRelationPeer::PRJ_UID); + + $criteria->addSelectColumn(MessageEventTaskRelationPeer::EVN_UID); + + $criteria->addSelectColumn(MessageEventTaskRelationPeer::TAS_UID); + + } + + const COUNT = 'COUNT(MESSAGE_EVENT_TASK_RELATION.MSGETR_UID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT MESSAGE_EVENT_TASK_RELATION.MSGETR_UID)'; + + /** + * Returns the number of rows matching criteria. + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCount(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(MessageEventTaskRelationPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(MessageEventTaskRelationPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach ($criteria->getGroupByColumns() as $column) { + $criteria->addSelectColumn($column); + } + + $rs = MessageEventTaskRelationPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + /** + * Method to select one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param Connection $con + * @return MessageEventTaskRelation + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectOne(Criteria $criteria, $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = MessageEventTaskRelationPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + /** + * Method to do selects. + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con + * @return array Array of selected Objects + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelect(Criteria $criteria, $con = null) + { + return MessageEventTaskRelationPeer::populateObjects(MessageEventTaskRelationPeer::doSelectRS($criteria, $con)); + } + /** + * Prepares the Criteria object and uses the parent doSelect() + * method to get a ResultSet. + * + * Use this method directly if you want to just get the resultset + * (instead of an array of objects). + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return ResultSet The resultset object with numerically-indexed fields. + * @see BasePeer::doSelect() + */ + public static function doSelectRS(Criteria $criteria, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if (!$criteria->getSelectColumns()) { + $criteria = clone $criteria; + MessageEventTaskRelationPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + // BasePeer returns a Creole ResultSet, set to return + // rows indexed numerically. + return BasePeer::doSelect($criteria, $con); + } + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(ResultSet $rs) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = MessageEventTaskRelationPeer::getOMClass(); + $cls = Propel::import($cls); + // populate the object(s) + while ($rs->next()) { + + $obj = new $cls(); + $obj->hydrate($rs); + $results[] = $obj; + + } + return $results; + } + /** + * Returns the TableMap related to this peer. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + /** + * The class that the Peer will make instances of. + * + * This uses a dot-path notation which is tranalted into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @return string path.to.ClassName + */ + public static function getOMClass() + { + return MessageEventTaskRelationPeer::CLASS_DEFAULT; + } + + /** + * Method perform an INSERT on the database, given a MessageEventTaskRelation or Criteria object. + * + * @param mixed $values Criteria or MessageEventTaskRelation object containing data that is used to create the INSERT statement. + * @param Connection $con the connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from MessageEventTaskRelation object + } + + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->begin(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + + return $pk; + } + + /** + * Method perform an UPDATE on the database, given a MessageEventTaskRelation or Criteria object. + * + * @param mixed $values Criteria or MessageEventTaskRelation object containing data create the UPDATE statement. + * @param Connection $con The connection to use (specify Connection exert more control over transactions). + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doUpdate($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(MessageEventTaskRelationPeer::MSGETR_UID); + $selectCriteria->add(MessageEventTaskRelationPeer::MSGETR_UID, $criteria->remove(MessageEventTaskRelationPeer::MSGETR_UID), $comparison); + + } else { + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Method to DELETE all rows from the MESSAGE_EVENT_TASK_RELATION table. + * + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + $affectedRows += BasePeer::doDeleteAll(MessageEventTaskRelationPeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a MessageEventTaskRelation or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or MessageEventTaskRelation object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param Connection $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(MessageEventTaskRelationPeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } elseif ($values instanceof MessageEventTaskRelation) { + + $criteria = $values->buildPkeyCriteria(); + } else { + // it must be the primary key + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(MessageEventTaskRelationPeer::MSGETR_UID, (array) $values, Criteria::IN); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Validates all modified columns of given MessageEventTaskRelation object. + * If parameter $columns is either a single column name or an array of column names + * than only those columns are validated. + * + * NOTICE: This does not apply to primary or foreign keys for now. + * + * @param MessageEventTaskRelation $obj The object to validate. + * @param mixed $cols Column name or array of column names. + * + * @return mixed TRUE if all columns are valid or the error message of the first invalid column. + */ + public static function doValidate(MessageEventTaskRelation $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(MessageEventTaskRelationPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(MessageEventTaskRelationPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(MessageEventTaskRelationPeer::DATABASE_NAME, MessageEventTaskRelationPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param mixed $pk the primary key. + * @param Connection $con the connection to use + * @return MessageEventTaskRelation + */ + public static function retrieveByPK($pk, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $criteria = new Criteria(MessageEventTaskRelationPeer::DATABASE_NAME); + + $criteria->add(MessageEventTaskRelationPeer::MSGETR_UID, $pk); + + + $v = MessageEventTaskRelationPeer::doSelect($criteria, $con); + + return !empty($v) > 0 ? $v[0] : null; + } + + /** + * Retrieve multiple objects by pkey. + * + * @param array $pks List of primary keys + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function retrieveByPKs($pks, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(); + $criteria->add(MessageEventTaskRelationPeer::MSGETR_UID, $pks, Criteria::IN); + $objs = MessageEventTaskRelationPeer::doSelect($criteria, $con); + } + return $objs; + } +} + + +// static code to register the map builder for this Peer with the main Propel class +if (Propel::isInit()) { + // the MapBuilder classes register themselves with Propel during initialization + // so we need to load them here. + try { + BaseMessageEventTaskRelationPeer::getMapBuilder(); + } catch (Exception $e) { + Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); + } +} else { + // even if Propel is not yet initialized, the map builder class can be registered + // now and then it will be loaded when Propel initializes. + require_once 'classes/model/map/MessageEventTaskRelationMapBuilder.php'; + Propel::registerMapBuilder('classes.model.map.MessageEventTaskRelationMapBuilder'); +} + diff --git a/workflow/engine/config/schema.xml b/workflow/engine/config/schema.xml index 411c38c86..4c3a8eba0 100755 --- a/workflow/engine/config/schema.xml +++ b/workflow/engine/config/schema.xml @@ -1201,7 +1201,7 @@ - + @@ -1248,7 +1248,7 @@ - + @@ -4015,7 +4015,7 @@ - + @@ -4368,5 +4368,93 @@ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/workflow/engine/data/mysql/schema.sql b/workflow/engine/data/mysql/schema.sql index e034b44a1..cf4d3ff61 100755 --- a/workflow/engine/data/mysql/schema.sql +++ b/workflow/engine/data/mysql/schema.sql @@ -568,7 +568,7 @@ CREATE TABLE `TASK` ( `PRO_UID` VARCHAR(32) default '' NOT NULL, `TAS_UID` VARCHAR(32) default '' NOT NULL, - `TAS_TYPE` VARCHAR(20) default 'NORMAL' NOT NULL, + `TAS_TYPE` VARCHAR(50) default 'NORMAL' NOT NULL, `TAS_DURATION` DOUBLE default 0 NOT NULL, `TAS_DELAY_TYPE` VARCHAR(30) default '' NOT NULL, `TAS_TEMPORIZER` DOUBLE default 0 NOT NULL, @@ -2263,7 +2263,7 @@ CREATE TABLE `LIST_PARTICIPATED_LAST` `APP_TITLE` VARCHAR(255) default '' NOT NULL, `APP_PRO_TITLE` VARCHAR(255) default '' NOT NULL, `APP_TAS_TITLE` VARCHAR(255) default '' NOT NULL, - `APP_STATUS` VARCHAR(20) default '0' NOT NULL, + `APP_STATUS` VARCHAR(20) default '0', `DEL_INDEX` INTEGER default 0 NOT NULL, `DEL_PREVIOUS_USR_UID` VARCHAR(32) default '', `DEL_PREVIOUS_USR_USERNAME` VARCHAR(100) default '', @@ -2521,3 +2521,77 @@ CREATE TABLE `WEB_ENTRY_EVENT` )ENGINE=InnoDB DEFAULT CHARSET='utf8'; # This restores the fkey checks, after having unset them earlier SET FOREIGN_KEY_CHECKS = 1; + +#----------------------------------------------------------------------------- +#-- MESSAGE_EVENT_DEFINITION +#----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS MESSAGE_EVENT_DEFINITION; + +CREATE TABLE MESSAGE_EVENT_DEFINITION +( + MSGED_UID VARCHAR(32) NOT NULL, + PRJ_UID VARCHAR(32) NOT NULL, + EVN_UID VARCHAR(32) NOT NULL, + MSGT_UID VARCHAR(32) NOT NULL DEFAULT '', + MSGED_USR_UID VARCHAR(32) NOT NULL DEFAULT '', + MSGED_VARIABLES MEDIUMTEXT NOT NULL DEFAULT '', + MSGED_CORRELATION VARCHAR(512) NOT NULL DEFAULT '', + + PRIMARY KEY (MSGED_UID) +) ENGINE=InnoDB DEFAULT CHARSET='utf8'; + +#----------------------------------------------------------------------------- +#-- MESSAGE_EVENT_RELATION +#----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS MESSAGE_EVENT_RELATION; + +CREATE TABLE MESSAGE_EVENT_RELATION +( + MSGER_UID VARCHAR(32) NOT NULL, + PRJ_UID VARCHAR(32) NOT NULL, + EVN_UID_THROW VARCHAR(32) NOT NULL, + EVN_UID_CATCH VARCHAR(32) NOT NULL, + + PRIMARY KEY (MSGER_UID) +) ENGINE=InnoDB DEFAULT CHARSET='utf8'; + +#----------------------------------------------------------------------------- +#-- MESSAGE_EVENT_TASK_RELATION +#----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS MESSAGE_EVENT_TASK_RELATION; + +CREATE TABLE MESSAGE_EVENT_TASK_RELATION +( + MSGETR_UID VARCHAR(32) NOT NULL, + PRJ_UID VARCHAR(32) NOT NULL, + EVN_UID VARCHAR(32) NOT NULL, + TAS_UID VARCHAR(32) NOT NULL, + + PRIMARY KEY (MSGETR_UID) +) ENGINE=InnoDB DEFAULT CHARSET='utf8'; + +#----------------------------------------------------------------------------- +#-- MESSAGE_APPLICATION +#----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS MESSAGE_APPLICATION; + +CREATE TABLE MESSAGE_APPLICATION +( + MSGAPP_UID VARCHAR(32) NOT NULL, + APP_UID VARCHAR(32) NOT NULL, + PRJ_UID VARCHAR(32) NOT NULL, + EVN_UID_THROW VARCHAR(32) NOT NULL, + EVN_UID_CATCH VARCHAR(32) NOT NULL, + MSGAPP_VARIABLES MEDIUMTEXT NOT NULL DEFAULT '', + MSGAPP_CORRELATION VARCHAR(512) NOT NULL DEFAULT '', + MSGAPP_THROW_DATE DATETIME NOT NULL, + MSGAPP_CATCH_DATE DATETIME, + MSGAPP_STATUS VARCHAR(25) NOT NULL DEFAULT 'UNREAD', + + PRIMARY KEY (MSGAPP_UID) +) ENGINE=InnoDB DEFAULT CHARSET='utf8'; + diff --git a/workflow/engine/methods/cases/cases_Step.php b/workflow/engine/methods/cases/cases_Step.php index 872daac9e..68b364007 100755 --- a/workflow/engine/methods/cases/cases_Step.php +++ b/workflow/engine/methods/cases/cases_Step.php @@ -1026,7 +1026,13 @@ try { } //Add content content step - End } catch (Exception $e) { - G::SendTemporalMessage( G::LoadTranslation( 'ID_PROCESS_DEF_PROBLEM' ), 'error', 'string', 3, 100 ); + //Check if the process is BPMN + if(isset($oProcessFieds['PRO_BPMN']) && $oProcessFieds['PRO_BPMN'] == 1){ + G::SendTemporalMessage( G::LoadTranslation( 'ID_BPMN_PROCESS_DEF_PROBLEM' ), 'error', 'string', 3, 100 ); + }else{ + G::SendTemporalMessage( G::LoadTranslation( 'ID_PROCESS_DEF_PROBLEM' ), 'error', 'string', 3, 100 ); + } + $aMessage = array (); $aMessage['MESSAGE'] = $e->getMessage(); $G_PUBLISH = new Publisher(); diff --git a/workflow/engine/methods/dynaforms/conditionalShowHide_Ajax.php b/workflow/engine/methods/dynaforms/conditionalShowHide_Ajax.php index 890d06f7e..f469227db 100755 --- a/workflow/engine/methods/dynaforms/conditionalShowHide_Ajax.php +++ b/workflow/engine/methods/dynaforms/conditionalShowHide_Ajax.php @@ -116,6 +116,14 @@ try { $_POST['FCD_UID'] = ($_POST['FCD_UID'] == '0') ? '' : $_POST['FCD_UID']; $aData = Array ('FCD_UID' => Isset( $_POST['FCD_UID'] ) ? $_POST['FCD_UID'] : '','FCD_FUNCTION' => $_POST['function'],'FCD_FIELDS' => $_POST['fields_selected'],'FCD_CONDITION' => $_POST['condition'],'FCD_EVENTS' => $_POST['events'],'FCD_EVENT_OWNERS' => $_POST['event_owner_selected'],'FCD_STATUS' => $_POST['enabled'],'FCD_DYN_UID' => $aDYN['DYN_UID']); $oFieldCondition->quickSave( $aData ); + //Add Audit Log + if(isset($_POST['enabled']) && $_POST['enabled'] == 1){ + $enable = 'enable'; + }else{ + $enable = 'disable'; + } + G::auditLog("ConditionsEditorDynaform", "Dynaform Title: " .$aDYN['DYNAFORM_NAME']. ", Condition Editor: [Function: ".$_POST['function']. ", Fields: ".$_POST['fields_selected']. ", Conditions: ".$_POST['condition']. ", Events: ".$_POST['events']. ", Event Owner: ".$_POST['event_owner_selected']. ", Status: ".$enable."]"); + break; case 'delete': require_once 'classes/model/FieldCondition.php'; diff --git a/workflow/engine/methods/tracker/tracker_DynaDocs.php b/workflow/engine/methods/tracker/tracker_DynaDocs.php index 5d8280d06..5a7ab49c1 100755 --- a/workflow/engine/methods/tracker/tracker_DynaDocs.php +++ b/workflow/engine/methods/tracker/tracker_DynaDocs.php @@ -30,6 +30,7 @@ */ if (! isset( $_SESSION['PROCESS'] ) || ! isset( $_SESSION['APPLICATION'] )) { G::header( 'location: login' ); + die; } $G_MAIN_MENU = 'caseTracker'; $G_ID_MENU_SELECTED = 'DYNADOC'; diff --git a/workflow/engine/methods/tracker/tracker_History.php b/workflow/engine/methods/tracker/tracker_History.php index b81c5a37f..f608d532d 100755 --- a/workflow/engine/methods/tracker/tracker_History.php +++ b/workflow/engine/methods/tracker/tracker_History.php @@ -30,6 +30,7 @@ */ if (! isset( $_SESSION['PROCESS'] ) || ! isset( $_SESSION['APPLICATION'] ) ) { G::header( 'location: login' ); + die; } $G_MAIN_MENU = 'caseTracker'; diff --git a/workflow/engine/methods/tracker/tracker_Messages.php b/workflow/engine/methods/tracker/tracker_Messages.php index 8c7652d3a..9da5bfbd2 100755 --- a/workflow/engine/methods/tracker/tracker_Messages.php +++ b/workflow/engine/methods/tracker/tracker_Messages.php @@ -30,6 +30,7 @@ */ if (! isset( $_SESSION['PROCESS'] ) || ! isset( $_SESSION['APPLICATION'] )) { G::header( 'location: login' ); + die; } $G_MAIN_MENU = 'caseTracker'; $G_ID_MENU_SELECTED = 'MESSAGES'; diff --git a/workflow/engine/methods/tracker/tracker_ViewMap.php b/workflow/engine/methods/tracker/tracker_ViewMap.php index b3dff829b..013e3c772 100755 --- a/workflow/engine/methods/tracker/tracker_ViewMap.php +++ b/workflow/engine/methods/tracker/tracker_ViewMap.php @@ -31,6 +31,7 @@ require_once 'classes/model/Process.php'; if (! isset( $_SESSION['PROCESS'] ) || ! isset( $_SESSION['APPLICATION'] )) { G::header( 'location: login' ); + die; } $G_MAIN_MENU = 'caseTracker'; $G_ID_MENU_SELECTED = 'MAP'; diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventDefinition.php b/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventDefinition.php new file mode 100644 index 000000000..95543e2b4 --- /dev/null +++ b/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventDefinition.php @@ -0,0 +1,706 @@ + array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "messageEventDefinitionUid"), + + "PRJ_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "projectUid"), + "EVN_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "eventUid"), + "MSGT_UID" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "messageTypeUid"), + "MSGED_USR_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "messageEventDefinitionUserUid"), + "MSGED_VARIABLES" => array("type" => "array", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "messageEventDefinitionVariables"), + "MSGED_CORRELATION" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "messageEventDefinitionCorrelation") + ); + + private $formatFieldNameInUppercase = true; + + private $arrayFieldNameForException = array(); + + /** + * Constructor of the class + * + * return void + */ + public function __construct() + { + try { + foreach ($this->arrayFieldDefinition as $key => $value) { + $this->arrayFieldNameForException[$value["fieldNameAux"]] = $key; + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Set the format of the fields name (uppercase, lowercase) + * + * @param bool $flag Value that set the format + * + * return void + */ + public function setFormatFieldNameInUppercase($flag) + { + try { + $this->formatFieldNameInUppercase = $flag; + + $this->setArrayFieldNameForException($this->arrayFieldNameForException); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Set exception messages for fields + * + * @param array $arrayData Data with the fields + * + * return void + */ + public function setArrayFieldNameForException(array $arrayData) + { + try { + foreach ($arrayData as $key => $value) { + $this->arrayFieldNameForException[$key] = $this->getFieldNameByFormatFieldName($value); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get the name of the field according to the format + * + * @param string $fieldName Field name + * + * return string Return the field name according the format + */ + public function getFieldNameByFormatFieldName($fieldName) + { + try { + return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if exists the Message-Event-Definition + * + * @param string $messageEventDefinitionUid Unique id of Message-Event-Definition + * + * return bool Return true if exists the Message-Event-Definition, false otherwise + */ + public function exists($messageEventDefinitionUid) + { + try { + $obj = \MessageEventDefinitionPeer::retrieveByPK($messageEventDefinitionUid); + + return (!is_null($obj))? true : false; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if exists the Event of a Message-Event-Definition + * + * @param string $projectUid Unique id of Project + * @param string $eventUid Unique id of Event + * @param string $messageEventDefinitionUidToExclude Unique id of Message-Event-Definition to exclude + * + * return bool Return true if exists the Event of a Message-Event-Definition, false otherwise + */ + public function existsEvent($projectUid, $eventUid, $messageEventDefinitionUidToExclude = "") + { + try { + $criteria = new \Criteria("workflow"); + + $criteria->addSelectColumn(\MessageEventDefinitionPeer::MSGED_UID); + $criteria->add(\MessageEventDefinitionPeer::PRJ_UID, $projectUid, \Criteria::EQUAL); + + if ($messageEventDefinitionUidToExclude != "") { + $criteria->add(\MessageEventDefinitionPeer::MSGED_UID, $messageEventDefinitionUidToExclude, \Criteria::NOT_EQUAL); + } + + $criteria->add(\MessageEventDefinitionPeer::EVN_UID, $eventUid, \Criteria::EQUAL); + + $rsCriteria = \MessageEventDefinitionPeer::doSelectRS($criteria); + + return ($rsCriteria->next())? true : false; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if does not exists the Message-Event-Definition + * + * @param string $messageEventDefinitionUid Unique id of Message-Event-Definition + * @param string $fieldNameForException Field name for the exception + * + * return void Throw exception if does not exists the Message-Event-Definition + */ + public function throwExceptionIfNotExistsMessageEventDefinition($messageEventDefinitionUid, $fieldNameForException) + { + try { + if (!$this->exists($messageEventDefinitionUid)) { + throw new \Exception(\G::LoadTranslation("ID_MESSAGE_EVENT_DEFINITION_DOES_NOT_EXIST", array($fieldNameForException, $messageEventDefinitionUid))); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if is registered the Event + * + * @param string $projectUid Unique id of Project + * @param string $eventUid Unique id of Event + * @param string $fieldNameForException Field name for the exception + * @param string $messageEventDefinitionUidToExclude Unique id of Message-Event-Definition to exclude + * + * return void Throw exception if is registered the Event + */ + public function throwExceptionIfEventIsRegistered($projectUid, $eventUid, $fieldNameForException, $messageEventDefinitionUidToExclude = "") + { + try { + if ($this->existsEvent($projectUid, $eventUid, $messageEventDefinitionUidToExclude)) { + throw new \Exception(\G::LoadTranslation("ID_MESSAGE_EVENT_DEFINITION_ALREADY_REGISTERED", array($fieldNameForException, $eventUid))); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Validate the data if they are invalid (INSERT and UPDATE) + * + * @param string $messageEventDefinitionUid Unique id of Message-Event-Definition + * @param string $projectUid Unique id of Project + * @param array $arrayData Data + * + * return void Throw exception if data has an invalid value + */ + public function throwExceptionIfDataIsInvalid($messageEventDefinitionUid, $projectUid, array $arrayData) + { + try { + //Set variables + $arrayMessageEventDefinitionData = ($messageEventDefinitionUid == "")? array() : $this->getMessageEventDefinition($messageEventDefinitionUid, true); + $flagInsert = ($messageEventDefinitionUid == "")? true : false; + + $arrayFinalData = array_merge($arrayMessageEventDefinitionData, $arrayData); + + //Verify data - Field definition + $process = new \ProcessMaker\BusinessModel\Process(); + $messageType = new \ProcessMaker\BusinessModel\MessageType(); + + $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, $flagInsert); + + //Verify data + if (isset($arrayData["EVN_UID"])) { + $this->throwExceptionIfEventIsRegistered($projectUid, $arrayData["EVN_UID"], $this->arrayFieldNameForException["eventUid"], $messageEventDefinitionUid); + } + + if (isset($arrayData["EVN_UID"])) { + $arrayEventType = array("START", "END", "INTERMEDIATE"); + $arrayEventMarker = array("MESSAGETHROW", "MESSAGECATCH"); + + $bpmnEvent = \BpmnEventPeer::retrieveByPK($arrayData["EVN_UID"]); + + if (is_null($bpmnEvent)) { + throw new \Exception(\G::LoadTranslation("ID_EVENT_NOT_EXIST", array($this->arrayFieldNameForException["eventUid"], $arrayData["EVN_UID"]))); + } + + if (!in_array($bpmnEvent->getEvnType(), $arrayEventType) || !in_array($bpmnEvent->getEvnMarker(), $arrayEventMarker)) { + throw new \Exception(\G::LoadTranslation("ID_EVENT_NOT_IS_MESSAGE_EVENT", array($this->arrayFieldNameForException["eventUid"], $arrayData["EVN_UID"]))); + } + } + + if (isset($arrayData["MSGT_UID"]) && $arrayData["MSGT_UID"] . "" != "") { + if (!$messageType->exists($arrayData["MSGT_UID"])) { + throw new \Exception(\G::LoadTranslation("ID_MESSAGE_TYPE_NOT_EXIST", array($this->arrayFieldNameForException["messageTypeUid"], $arrayData["MSGT_UID"]))); + } + } + + $flagCheckData = false; + $flagCheckData = (isset($arrayData["MSGT_UID"]) && $arrayData["MSGT_UID"] . "" != "")? true : $flagCheckData; + $flagCheckData = (isset($arrayData["MSGED_VARIABLES"]))? true : $flagCheckData; + + if ($flagCheckData && $arrayFinalData["MSGT_UID"] . "" != "") { + $arrayMessageTypeVariable = array(); + + $arrayMessageTypeData = $messageType->getMessageType($arrayFinalData["MSGT_UID"], true); + + foreach ($arrayMessageTypeData["MSGT_VARIABLES"] as $value) { + $arrayMessageTypeVariable[$value["MSGTV_NAME"]] = $value["MSGTV_DEFAULT_VALUE"]; + } + + if (count($arrayMessageTypeVariable) != count($arrayFinalData["MSGED_VARIABLES"]) || count(array_diff_key($arrayMessageTypeVariable, $arrayFinalData["MSGED_VARIABLES"])) > 0) { + throw new \Exception(\G::LoadTranslation("ID_MESSAGE_EVENT_DEFINITION_VARIABLES_DO_NOT_MEET_DEFINITION")); + } + } + + if (isset($arrayData["MSGED_USR_UID"])) { + $process->throwExceptionIfNotExistsUser($arrayData["MSGED_USR_UID"], $this->arrayFieldNameForException["messageEventDefinitionUserUid"]); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Create Message-Event-Definition for a Project + * + * @param string $projectUid Unique id of Project + * @param array $arrayData Data + * + * return array Return data of the new Message-Event-Definition created + */ + public function create($projectUid, array $arrayData) + { + try { + //Verify data + $process = new \ProcessMaker\BusinessModel\Process(); + $validator = new \ProcessMaker\BusinessModel\Validator(); + + $validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData"); + $validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData"); + + //Set data + $arrayData = array_change_key_case($arrayData, CASE_UPPER); + + unset($arrayData["MSGED_UID"]); + unset($arrayData["PRJ_UID"]); + + //Verify data + $process->throwExceptionIfNotExistsProcess($projectUid, $this->arrayFieldNameForException["projectUid"]); + + $this->throwExceptionIfDataIsInvalid("", $projectUid, $arrayData); + + //Create + $cnn = \Propel::getConnection("workflow"); + + try { + $messageEventDefinition = new \MessageEventDefinition(); + + if (!isset($arrayData["MSGT_UID"]) || $arrayData["MSGT_UID"] . "" == "") { + $arrayData["MSGT_UID"] = ""; + $arrayData["MSGED_VARIABLES"] = array(); + } + + if (!isset($arrayData["MSGED_VARIABLES"])) { + $arrayData["MSGED_VARIABLES"] = array(); + } + + $messageEventDefinitionUid = \ProcessMaker\Util\Common::generateUID(); + + $messageEventDefinition->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME); + + $messageEventDefinition->setMsgedUid($messageEventDefinitionUid); + $messageEventDefinition->setPrjUid($projectUid); + + if (isset($arrayData["MSGED_VARIABLES"])) { + $messageEventDefinition->setMsgedVariables(serialize($arrayData["MSGED_VARIABLES"])); + } + + if ($messageEventDefinition->validate()) { + $cnn->begin(); + + $result = $messageEventDefinition->save(); + + $cnn->commit(); + + //Task - User + if (isset($arrayData["MSGED_USR_UID"])) { + $bpmnEvent = \BpmnEventPeer::retrieveByPK($arrayData["EVN_UID"]); + + //Event - START-MESSAGE-EVENT + if (is_null($bpmnEvent) && $bpmnEvent->getEvnType() == "START" && $bpmnEvent->getEvnMarker() == "MESSAGECATCH") { + //Message-Event-Task-Relation - Get Task + $messageEventTaskRelation = new \ProcessMaker\BusinessModel\MessageEventTaskRelation(); + + $arrayMessageEventTaskRelationData = $messageEventTaskRelation->getMessageEventTaskRelationWhere( + array( + \MessageEventTaskRelationPeer::PRJ_UID => $projectUid, + \MessageEventTaskRelationPeer::EVN_UID => $bpmnEvent->getEvnUid() + ), + true + ); + + if (!is_null($arrayMessageEventTaskRelationData)) { + //Assign + $task = new \Tasks(); + + $result = $task->assignUser($arrayMessageEventTaskRelationData["TAS_UID"], $arrayData["MSGED_USR_UID"], 1); + } + } + } + + //Return + return $this->getMessageEventDefinition($messageEventDefinitionUid); + } else { + $msg = ""; + + foreach ($messageEventDefinition->getValidationFailures() as $validationFailure) { + $msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage(); + } + + throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : "")); + } + } catch (\Exception $e) { + $cnn->rollback(); + + throw $e; + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Update Message-Event-Definition + * + * @param string $messageEventDefinitionUid Unique id of Message-Event-Definition + * @param array $arrayData Data + * + * return array Return data of the Message-Event-Definition updated + */ + public function update($messageEventDefinitionUid, array $arrayData) + { + try { + //Verify data + $process = new \ProcessMaker\BusinessModel\Process(); + $validator = new \ProcessMaker\BusinessModel\Validator(); + + $validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData"); + $validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData"); + + //Set data + $arrayData = array_change_key_case($arrayData, CASE_UPPER); + $arrayDataBackup = $arrayData; + + unset($arrayData["MSGED_UID"]); + unset($arrayData["PRJ_UID"]); + + //Set variables + $arrayMessageEventDefinitionData = $this->getMessageEventDefinition($messageEventDefinitionUid, true); + + //Verify data + $this->throwExceptionIfNotExistsMessageEventDefinition($messageEventDefinitionUid, $this->arrayFieldNameForException["messageEventDefinitionUid"]); + + $this->throwExceptionIfDataIsInvalid($messageEventDefinitionUid, $arrayMessageEventDefinitionData["PRJ_UID"], $arrayData); + + //Update + $cnn = \Propel::getConnection("workflow"); + + try { + $messageEventDefinition = \MessageEventDefinitionPeer::retrieveByPK($messageEventDefinitionUid); + + if (isset($arrayData["MSGT_UID"]) && $arrayData["MSGT_UID"] . "" == "") { + $arrayData["MSGED_VARIABLES"] = array(); + } + + $messageEventDefinition->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME); + + if (isset($arrayData["MSGED_VARIABLES"])) { + $messageEventDefinition->setMsgedVariables(serialize($arrayData["MSGED_VARIABLES"])); + } + + if ($messageEventDefinition->validate()) { + $cnn->begin(); + + $result = $messageEventDefinition->save(); + + $cnn->commit(); + + //Task - User + if (isset($arrayData["MSGED_USR_UID"]) && $arrayData["MSGED_USR_UID"] != $arrayMessageEventDefinitionData["MSGED_USR_UID"]) { + $bpmnEvent = \BpmnEventPeer::retrieveByPK($arrayMessageEventDefinitionData["EVN_UID"]); + + //Event - START-MESSAGE-EVENT + if (is_null($bpmnEvent) && $bpmnEvent->getEvnType() == "START" && $bpmnEvent->getEvnMarker() == "MESSAGECATCH") { + //Message-Event-Task-Relation - Get Task + $messageEventTaskRelation = new \ProcessMaker\BusinessModel\MessageEventTaskRelation(); + + $arrayMessageEventTaskRelationData = $messageEventTaskRelation->getMessageEventTaskRelationWhere( + array( + \MessageEventTaskRelationPeer::PRJ_UID => $arrayMessageEventDefinitionData["PRJ_UID"], + \MessageEventTaskRelationPeer::EVN_UID => $bpmnEvent->getEvnUid() + ), + true + ); + + if (!is_null($arrayMessageEventTaskRelationData)) { + //Unassign + $taskUser = new \TaskUser(); + + $criteria = new \Criteria("workflow"); + + $criteria->add(\TaskUserPeer::TAS_UID, $arrayMessageEventTaskRelationData["TAS_UID"]); + + $rsCriteria = \TaskUserPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + + while ($rsCriteria->next()) { + $row = $rsCriteria->getRow(); + + $result = $taskUser->remove($row["TAS_UID"], $row["USR_UID"], $row["TU_TYPE"], $row["TU_RELATION"]); + } + + //Assign + $task = new \Tasks(); + + $result = $task->assignUser($arrayMessageEventTaskRelationData["TAS_UID"], $arrayData["MSGED_USR_UID"], 1); + } + } + } + + //Return + $arrayData = $arrayDataBackup; + + if (!$this->formatFieldNameInUppercase) { + $arrayData = array_change_key_case($arrayData, CASE_LOWER); + } + + return $arrayData; + } else { + $msg = ""; + + foreach ($messageEventDefinition->getValidationFailures() as $validationFailure) { + $msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage(); + } + + throw new \Exception(\G::LoadTranslation("ID_REGISTRY_CANNOT_BE_UPDATED") . (($msg != "")? "\n" . $msg : "")); + } + } catch (\Exception $e) { + $cnn->rollback(); + + throw $e; + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Delete Message-Event-Definition + * + * @param string $messageEventDefinitionUid Unique id of Message-Event-Definition + * + * return void + */ + public function delete($messageEventDefinitionUid) + { + try { + //Verify data + $this->throwExceptionIfNotExistsMessageEventDefinition($messageEventDefinitionUid, $this->arrayFieldNameForException["messageEventDefinitionUid"]); + + //Delete + $criteria = new \Criteria("workflow"); + + $criteria->add(\MessageEventDefinitionPeer::MSGED_UID, $messageEventDefinitionUid, \Criteria::EQUAL); + + $result = \MessageEventDefinitionPeer::doDelete($criteria); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Set Message-Event-Definition-Variables by Message-Type for a record + * + * @param array $record Record + * + * return array Return the record + */ + public function setMessageEventDefinitionVariablesForRecordByMessageType(array $record) + { + try { + $record["MSGED_VARIABLES"] = ($record["MSGED_VARIABLES"] . "" != "")? unserialize($record["MSGED_VARIABLES"]) : array(); + + if ($record["MSGT_UID"] . "" != "") { + $arrayMessageTypeVariable = array(); + + $messageType = new \ProcessMaker\BusinessModel\MessageType(); + + if ($messageType->exists($record["MSGT_UID"])) { + $arrayMessageTypeData = $messageType->getMessageType($record["MSGT_UID"], true); + + foreach ($arrayMessageTypeData["MSGT_VARIABLES"] as $value) { + $arrayMessageTypeVariable[$value["MSGTV_NAME"]] = (isset($record["MSGED_VARIABLES"][$value["MSGTV_NAME"]]))? $record["MSGED_VARIABLES"][$value["MSGTV_NAME"]] : $value["MSGTV_DEFAULT_VALUE"]; + } + } + + $record["MSGED_VARIABLES"] = $arrayMessageTypeVariable; + } + + //Return + return $record; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get criteria for Message-Event-Definition + * + * return object + */ + public function getMessageEventDefinitionCriteria() + { + try { + $criteria = new \Criteria("workflow"); + + $criteria->addSelectColumn(\MessageEventDefinitionPeer::MSGED_UID); + $criteria->addSelectColumn(\MessageEventDefinitionPeer::PRJ_UID); + $criteria->addSelectColumn(\MessageEventDefinitionPeer::EVN_UID); + $criteria->addSelectColumn(\MessageEventDefinitionPeer::MSGT_UID); + $criteria->addSelectColumn(\MessageEventDefinitionPeer::MSGED_USR_UID); + $criteria->addSelectColumn(\MessageEventDefinitionPeer::MSGED_VARIABLES); + $criteria->addSelectColumn(\MessageEventDefinitionPeer::MSGED_CORRELATION); + + return $criteria; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get data of a Message-Event-Definition from a record + * + * @param array $record Record + * + * return array Return an array with data Message-Event-Definition + */ + public function getMessageEventDefinitionDataFromRecord(array $record) + { + try { + return array( + $this->getFieldNameByFormatFieldName("MSGED_UID") => $record["MSGED_UID"], + $this->getFieldNameByFormatFieldName("EVN_UID") => $record["EVN_UID"], + $this->getFieldNameByFormatFieldName("MSGT_UID") => $record["MSGT_UID"] . "", + $this->getFieldNameByFormatFieldName("MSGED_USR_UID") => $record["MSGED_USR_UID"] . "", + $this->getFieldNameByFormatFieldName("MSGED_VARIABLES") => $record["MSGED_VARIABLES"], + $this->getFieldNameByFormatFieldName("MSGED_CORRELATION") => $record["MSGED_CORRELATION"] . "" + ); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get all Message-Event-Definitions + * + * @param string $projectUid Unique id of Project + * + * return array Return an array with all Message-Event-Definitions + */ + public function getMessageEventDefinitions($projectUid) + { + try { + $arrayMessageEventDefinition = array(); + + //Verify data + $process = new \ProcessMaker\BusinessModel\Process(); + + $process->throwExceptionIfNotExistsProcess($projectUid, $this->arrayFieldNameForException["projectUid"]); + + //Get data + $criteria = $this->getMessageEventDefinitionCriteria(); + + $criteria->add(\MessageEventDefinitionPeer::PRJ_UID, $projectUid, \Criteria::EQUAL); + + $rsCriteria = \MessageEventDefinitionPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + + while ($rsCriteria->next()) { + $row = $this->setMessageEventDefinitionVariablesForRecordByMessageType($rsCriteria->getRow()); + + $arrayMessageEventDefinition[] = $this->getMessageEventDefinitionDataFromRecord($row); + } + + //Return + return $arrayMessageEventDefinition; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get data of a Message-Event-Definition + * + * @param string $messageEventDefinitionUid Unique id of Message-Event-Definition + * @param bool $flagGetRecord Value that set the getting + * + * return array Return an array with data of a Message-Event-Definition + */ + public function getMessageEventDefinition($messageEventDefinitionUid, $flagGetRecord = false) + { + try { + //Verify data + $this->throwExceptionIfNotExistsMessageEventDefinition($messageEventDefinitionUid, $this->arrayFieldNameForException["messageEventDefinitionUid"]); + + //Get data + $criteria = $this->getMessageEventDefinitionCriteria(); + + $criteria->add(\MessageEventDefinitionPeer::MSGED_UID, $messageEventDefinitionUid, \Criteria::EQUAL); + + $rsCriteria = \MessageEventDefinitionPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + + $rsCriteria->next(); + + $row = $this->setMessageEventDefinitionVariablesForRecordByMessageType($rsCriteria->getRow()); + + //Return + return (!$flagGetRecord)? $this->getMessageEventDefinitionDataFromRecord($row) : $row; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get data of a Message-Event-Definition by unique id of Event + * + * @param string $projectUid Unique id of Project + * @param string $eventUid Unique id of Event + * @param bool $flagGetRecord Value that set the getting + * + * return array Return an array with data of a Message-Event-Definition by unique id of Event + */ + public function getMessageEventDefinitionByEvent($projectUid, $eventUid, $flagGetRecord = false) + { + try { + //Verify data + $process = new \ProcessMaker\BusinessModel\Process(); + + $process->throwExceptionIfNotExistsProcess($projectUid, $this->arrayFieldNameForException["projectUid"]); + + if (!$this->existsEvent($projectUid, $eventUid)) { + throw new \Exception(\G::LoadTranslation("ID_MESSAGE_EVENT_DEFINITION_DOES_NOT_IS_REGISTERED", array($this->arrayFieldNameForException["eventUid"], $eventUid))); + } + + //Get data + $criteria = $this->getMessageEventDefinitionCriteria(); + + $criteria->add(\MessageEventDefinitionPeer::PRJ_UID, $projectUid, \Criteria::EQUAL); + $criteria->add(\MessageEventDefinitionPeer::EVN_UID, $eventUid, \Criteria::EQUAL); + + $rsCriteria = \MessageEventDefinitionPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + + $rsCriteria->next(); + + $row = $this->setMessageEventDefinitionVariablesForRecordByMessageType($rsCriteria->getRow()); + + //Return + return (!$flagGetRecord)? $this->getMessageEventDefinitionDataFromRecord($row) : $row; + } catch (\Exception $e) { + throw $e; + } + } +} + diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventRelation.php b/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventRelation.php new file mode 100644 index 000000000..ac81b1fec --- /dev/null +++ b/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventRelation.php @@ -0,0 +1,408 @@ + array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "messageEventRelationUid"), + + "PRJ_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "projectUid"), + "EVN_UID_THROW" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "eventUidThrow"), + "EVN_UID_CATCH" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "eventUidCatch") + ); + + private $formatFieldNameInUppercase = true; + + private $arrayFieldNameForException = array(); + + /** + * Constructor of the class + * + * return void + */ + public function __construct() + { + try { + foreach ($this->arrayFieldDefinition as $key => $value) { + $this->arrayFieldNameForException[$value["fieldNameAux"]] = $key; + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Set the format of the fields name (uppercase, lowercase) + * + * @param bool $flag Value that set the format + * + * return void + */ + public function setFormatFieldNameInUppercase($flag) + { + try { + $this->formatFieldNameInUppercase = $flag; + + $this->setArrayFieldNameForException($this->arrayFieldNameForException); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Set exception messages for fields + * + * @param array $arrayData Data with the fields + * + * return void + */ + public function setArrayFieldNameForException(array $arrayData) + { + try { + foreach ($arrayData as $key => $value) { + $this->arrayFieldNameForException[$key] = $this->getFieldNameByFormatFieldName($value); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get the name of the field according to the format + * + * @param string $fieldName Field name + * + * return string Return the field name according the format + */ + public function getFieldNameByFormatFieldName($fieldName) + { + try { + return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if exists the Message-Event-Relation + * + * @param string $messageEventRelationUid Unique id of Message-Event-Relation + * + * return bool Return true if exists the Message-Event-Relation, false otherwise + */ + public function exists($messageEventRelationUid) + { + try { + $obj = \MessageEventRelationPeer::retrieveByPK($messageEventRelationUid); + + return (!is_null($obj))? true : false; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if exists the Event-Relation of a Message-Event-Relation + * + * @param string $projectUid Unique id of Project + * @param string $eventUidThrow Unique id of Event (throw) + * @param string $eventUidCatch Unique id of Event (catch) + * @param string $messageEventRelationUidToExclude Unique id of Message-Event-Relation to exclude + * + * return bool Return true if exists the Event-Relation of a Message-Event-Relation, false otherwise + */ + public function existsEventRelation($projectUid, $eventUidThrow, $eventUidCatch, $messageEventRelationUidToExclude = "") + { + try { + $criteria = new \Criteria("workflow"); + + $criteria->addSelectColumn(\MessageEventRelationPeer::MSGER_UID); + $criteria->add(\MessageEventRelationPeer::PRJ_UID, $projectUid, \Criteria::EQUAL); + + if ($messageEventRelationUidToExclude != "") { + $criteria->add(\MessageEventRelationPeer::MSGER_UID, $messageEventRelationUidToExclude, \Criteria::NOT_EQUAL); + } + + $criteria->add(\MessageEventRelationPeer::EVN_UID_THROW, $eventUidThrow, \Criteria::EQUAL); + $criteria->add(\MessageEventRelationPeer::EVN_UID_CATCH, $eventUidCatch, \Criteria::EQUAL); + + $rsCriteria = \MessageEventRelationPeer::doSelectRS($criteria); + + return ($rsCriteria->next())? true : false; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if does not exists the Message-Event-Relation + * + * @param string $messageEventRelationUid Unique id of Message-Event-Relation + * @param string $fieldNameForException Field name for the exception + * + * return void Throw exception if does not exists the Message-Event-Relation + */ + public function throwExceptionIfNotExistsMessageEventRelation($messageEventRelationUid, $fieldNameForException) + { + try { + if (!$this->exists($messageEventRelationUid)) { + throw new \Exception(\G::LoadTranslation("ID_MESSAGE_EVENT_RELATION_DOES_NOT_EXIST", array($fieldNameForException, $messageEventRelationUid))); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if is registered the Event-Relation + * + * @param string $projectUid Unique id of Project + * @param string $eventUidThrow Unique id of Event (throw) + * @param string $eventUidCatch Unique id of Event (catch) + * @param string $messageEventRelationUidToExclude Unique id of Message-Event-Relation to exclude + * + * return void Throw exception if is registered the Event-Relation + */ + public function throwExceptionIfEventRelationIsRegistered($projectUid, $eventUidThrow, $eventUidCatch, $messageEventRelationUidToExclude = "") + { + try { + if ($this->existsEventRelation($projectUid, $eventUidThrow, $eventUidCatch, $messageEventRelationUidToExclude)) { + throw new \Exception(\G::LoadTranslation("ID_MESSAGE_EVENT_RELATION_ALREADY_REGISTERED")); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Validate the data if they are invalid (INSERT and UPDATE) + * + * @param string $messageEventRelationUid Unique id of Message-Event-Relation + * @param string $projectUid Unique id of Project + * @param array $arrayData Data + * + * return void Throw exception if data has an invalid value + */ + public function throwExceptionIfDataIsInvalid($messageEventRelationUid, $projectUid, array $arrayData) + { + try { + //Set variables + $arrayMessageEventRelationData = ($messageEventRelationUid == "")? array() : $this->getMessageEventRelation($messageEventRelationUid, true); + $flagInsert = ($messageEventRelationUid == "")? true : false; + + $arrayFinalData = array_merge($arrayMessageEventRelationData, $arrayData); + + //Verify data - Field definition + $process = new \ProcessMaker\BusinessModel\Process(); + + $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, $flagInsert); + + //Verify data + if (isset($arrayData["EVN_UID_THROW"]) || isset($arrayData["EVN_UID_CATCH"])) { + $this->throwExceptionIfEventRelationIsRegistered($projectUid, $arrayFinalData["EVN_UID_THROW"], $arrayFinalData["EVN_UID_CATCH"], $messageEventRelationUid); + } + + if (isset($arrayData["EVN_UID_THROW"]) || isset($arrayData["EVN_UID_CATCH"])) { + //Flow + $bpmnFlow = \BpmnFlow::findOneBy(array( + \BpmnFlowPeer::FLO_TYPE => "MESSAGE", + \BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $arrayFinalData["EVN_UID_THROW"], + \BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnEvent", + \BpmnFlowPeer::FLO_ELEMENT_DEST => $arrayFinalData["EVN_UID_CATCH"], + \BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE => "bpmnEvent" + )); + + if (is_null($bpmnFlow)) { + throw new \Exception(\G::LoadTranslation( + "ID_MESSAGE_EVENT_RELATION_DOES_NOT_EXIST_MESSAGE_FLOW", + array( + $this->arrayFieldNameForException["eventUidThrow"], $arrayFinalData["EVN_UID_THROW"], + $this->arrayFieldNameForException["eventUidCatch"], $arrayFinalData["EVN_UID_CATCH"] + ) + )); + } + + //Check and validate Message Flow + $bpmn = new \ProcessMaker\Project\Bpmn(); + + $bpmn->throwExceptionFlowIfIsAnInvalidMessageFlow(array( + "FLO_TYPE" => "MESSAGE", + "FLO_ELEMENT_ORIGIN" => $arrayFinalData["EVN_UID_THROW"], + "FLO_ELEMENT_ORIGIN_TYPE" => "bpmnEvent", + "FLO_ELEMENT_DEST" => $arrayFinalData["EVN_UID_CATCH"], + "FLO_ELEMENT_DEST_TYPE" => "bpmnEvent" + )); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Create Message-Event-Relation for a Project + * + * @param string $projectUid Unique id of Project + * @param array $arrayData Data + * + * return array Return data of the new Message-Event-Relation created + */ + public function create($projectUid, array $arrayData) + { + try { + //Verify data + $process = new \ProcessMaker\BusinessModel\Process(); + $validator = new \ProcessMaker\BusinessModel\Validator(); + + $validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData"); + $validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData"); + + //Set data + $arrayData = array_change_key_case($arrayData, CASE_UPPER); + + unset($arrayData["MSGER_UID"]); + unset($arrayData["PRJ_UID"]); + + //Verify data + $process->throwExceptionIfNotExistsProcess($projectUid, $this->arrayFieldNameForException["projectUid"]); + + $this->throwExceptionIfDataIsInvalid("", $projectUid, $arrayData); + + //Create + $cnn = \Propel::getConnection("workflow"); + + try { + $messageEventRelation = new \MessageEventRelation(); + + $messageEventRelationUid = \ProcessMaker\Util\Common::generateUID(); + + $messageEventRelation->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME); + + $messageEventRelation->setMsgerUid($messageEventRelationUid); + $messageEventRelation->setPrjUid($projectUid); + + if ($messageEventRelation->validate()) { + $cnn->begin(); + + $result = $messageEventRelation->save(); + + $cnn->commit(); + + //Return + return $this->getMessageEventRelation($messageEventRelationUid); + } else { + $msg = ""; + + foreach ($messageEventRelation->getValidationFailures() as $validationFailure) { + $msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage(); + } + + throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : "")); + } + } catch (\Exception $e) { + $cnn->rollback(); + + throw $e; + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Delete Message-Event-Relation + * + * @param array $arrayCondition Conditions + * + * return void + */ + public function deleteWhere(array $arrayCondition) + { + try { + //Delete + $criteria = new \Criteria("workflow"); + + foreach ($arrayCondition as $key => $value) { + $criteria->add($key, $value, \Criteria::EQUAL); + } + + $result = \MessageEventRelationPeer::doDelete($criteria); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get criteria for Message-Event-Relation + * + * return object + */ + public function getMessageEventRelationCriteria() + { + try { + $criteria = new \Criteria("workflow"); + + $criteria->addSelectColumn(\MessageEventRelationPeer::MSGER_UID); + $criteria->addSelectColumn(\MessageEventRelationPeer::PRJ_UID); + $criteria->addSelectColumn(\MessageEventRelationPeer::EVN_UID_THROW); + $criteria->addSelectColumn(\MessageEventRelationPeer::EVN_UID_CATCH); + + return $criteria; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get data of a Message-Event-Relation from a record + * + * @param array $record Record + * + * return array Return an array with data Message-Event-Relation + */ + public function getMessageEventRelationDataFromRecord(array $record) + { + try { + return array( + $this->getFieldNameByFormatFieldName("MSGER_UID") => $record["MSGER_UID"], + $this->getFieldNameByFormatFieldName("EVN_UID_THROW") => $record["EVN_UID_THROW"], + $this->getFieldNameByFormatFieldName("EVN_UID_CATCH") => $record["EVN_UID_CATCH"] + ); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get data of a Message-Event-Relation + * + * @param string $messageEventRelationUid Unique id of Message-Event-Relation + * @param bool $flagGetRecord Value that set the getting + * + * return array Return an array with data of a Message-Event-Relation + */ + public function getMessageEventRelation($messageEventRelationUid, $flagGetRecord = false) + { + try { + //Verify data + $this->throwExceptionIfNotExistsMessageEventRelation($messageEventRelationUid, $this->arrayFieldNameForException["messageEventRelationUid"]); + + //Get data + $criteria = $this->getMessageEventRelationCriteria(); + + $criteria->add(\MessageEventRelationPeer::MSGER_UID, $messageEventRelationUid, \Criteria::EQUAL); + + $rsCriteria = \MessageEventRelationPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + + $rsCriteria->next(); + + $row = $rsCriteria->getRow(); + + //Return + return (!$flagGetRecord)? $this->getMessageEventRelationDataFromRecord($row) : $row; + } catch (\Exception $e) { + throw $e; + } + } +} + diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventTaskRelation.php b/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventTaskRelation.php new file mode 100644 index 000000000..dda7620de --- /dev/null +++ b/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventTaskRelation.php @@ -0,0 +1,352 @@ + array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "messageEventTaskRelationUid"), + + "PRJ_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "projectUid"), + "EVN_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "eventUid"), + "TAS_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "taskUid") + ); + + private $formatFieldNameInUppercase = true; + + private $arrayFieldNameForException = array(); + + /** + * Constructor of the class + * + * return void + */ + public function __construct() + { + try { + foreach ($this->arrayFieldDefinition as $key => $value) { + $this->arrayFieldNameForException[$value["fieldNameAux"]] = $key; + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Set the format of the fields name (uppercase, lowercase) + * + * @param bool $flag Value that set the format + * + * return void + */ + public function setFormatFieldNameInUppercase($flag) + { + try { + $this->formatFieldNameInUppercase = $flag; + + $this->setArrayFieldNameForException($this->arrayFieldNameForException); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Set exception messages for fields + * + * @param array $arrayData Data with the fields + * + * return void + */ + public function setArrayFieldNameForException(array $arrayData) + { + try { + foreach ($arrayData as $key => $value) { + $this->arrayFieldNameForException[$key] = $this->getFieldNameByFormatFieldName($value); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get the name of the field according to the format + * + * @param string $fieldName Field name + * + * return string Return the field name according the format + */ + public function getFieldNameByFormatFieldName($fieldName) + { + try { + return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if exists the Message-Event-Task-Relation + * + * @param string $messageEventTaskRelationUid Unique id of Message-Event-Task-Relation + * + * return bool Return true if exists the Message-Event-Task-Relation, false otherwise + */ + public function exists($messageEventTaskRelationUid) + { + try { + $obj = \MessageEventTaskRelationPeer::retrieveByPK($messageEventTaskRelationUid); + + return (!is_null($obj))? true : false; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if does not exists the Message-Event-Task-Relation + * + * @param string $messageEventTaskRelationUid Unique id of Message-Event-Task-Relation + * @param string $fieldNameForException Field name for the exception + * + * return void Throw exception if does not exists the Message-Event-Task-Relation + */ + public function throwExceptionIfNotExistsMessageEventTaskRelation($messageEventTaskRelationUid, $fieldNameForException) + { + try { + if (!$this->exists($messageEventTaskRelationUid)) { + throw new \Exception(\G::LoadTranslation("ID_MESSAGE_EVENT_TASK_RELATION_DOES_NOT_EXIST", array($fieldNameForException, $messageEventTaskRelationUid))); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Validate the data if they are invalid (INSERT and UPDATE) + * + * @param string $messageEventTaskRelationUid Unique id of Message-Event-Task-Relation + * @param string $projectUid Unique id of Project + * @param array $arrayData Data + * + * return void Throw exception if data has an invalid value + */ + public function throwExceptionIfDataIsInvalid($messageEventTaskRelationUid, $projectUid, array $arrayData) + { + try { + //Set variables + $arrayMessageEventTaskRelationData = ($messageEventTaskRelationUid == "")? array() : $this->getMessageEventTaskRelation($messageEventTaskRelationUid, true); + $flagInsert = ($messageEventTaskRelationUid == "")? true : false; + + $arrayFinalData = array_merge($arrayMessageEventTaskRelationData, $arrayData); + + //Verify data - Field definition + $process = new \ProcessMaker\BusinessModel\Process(); + + $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, $flagInsert); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Create Message-Event-Task-Relation for a Project + * + * @param string $projectUid Unique id of Project + * @param array $arrayData Data + * + * return array Return data of the new Message-Event-Task-Relation created + */ + public function create($projectUid, array $arrayData) + { + try { + //Verify data + $process = new \ProcessMaker\BusinessModel\Process(); + $validator = new \ProcessMaker\BusinessModel\Validator(); + + $validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData"); + $validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData"); + + //Set data + $arrayData = array_change_key_case($arrayData, CASE_UPPER); + + unset($arrayData["MSGETR_UID"]); + unset($arrayData["PRJ_UID"]); + + //Verify data + $process->throwExceptionIfNotExistsProcess($projectUid, $this->arrayFieldNameForException["projectUid"]); + + $this->throwExceptionIfDataIsInvalid("", $projectUid, $arrayData); + + //Create + $cnn = \Propel::getConnection("workflow"); + + try { + $messageEventTaskRelation = new \MessageEventTaskRelation(); + + $messageEventTaskRelationUid = \ProcessMaker\Util\Common::generateUID(); + + $messageEventTaskRelation->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME); + + $messageEventTaskRelation->setMsgetrUid($messageEventTaskRelationUid); + $messageEventTaskRelation->setPrjUid($projectUid); + + if ($messageEventTaskRelation->validate()) { + $cnn->begin(); + + $result = $messageEventTaskRelation->save(); + + $cnn->commit(); + + //Return + return $this->getMessageEventTaskRelation($messageEventTaskRelationUid); + } else { + $msg = ""; + + foreach ($messageEventTaskRelation->getValidationFailures() as $validationFailure) { + $msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage(); + } + + throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : "")); + } + } catch (\Exception $e) { + $cnn->rollback(); + + throw $e; + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Delete Message-Event-Task-Relation + * + * @param array $arrayCondition Conditions + * + * return void + */ + public function deleteWhere(array $arrayCondition) + { + try { + //Delete + $criteria = new \Criteria("workflow"); + + foreach ($arrayCondition as $key => $value) { + $criteria->add($key, $value, \Criteria::EQUAL); + } + + $result = \MessageEventTaskRelationPeer::doDelete($criteria); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get criteria for Message-Event-Task-Relation + * + * return object + */ + public function getMessageEventTaskRelationCriteria() + { + try { + $criteria = new \Criteria("workflow"); + + $criteria->addSelectColumn(\MessageEventTaskRelationPeer::MSGETR_UID); + $criteria->addSelectColumn(\MessageEventTaskRelationPeer::PRJ_UID); + $criteria->addSelectColumn(\MessageEventTaskRelationPeer::EVN_UID); + $criteria->addSelectColumn(\MessageEventTaskRelationPeer::TAS_UID); + + return $criteria; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get data of a Message-Event-Task-Relation from a record + * + * @param array $record Record + * + * return array Return an array with data Message-Event-Task-Relation + */ + public function getMessageEventTaskRelationDataFromRecord(array $record) + { + try { + return array( + $this->getFieldNameByFormatFieldName("MSGETR_UID") => $record["MSGETR_UID"], + $this->getFieldNameByFormatFieldName("EVN_UID") => $record["EVN_UID"], + $this->getFieldNameByFormatFieldName("TAS_UID") => $record["TAS_UID"] + ); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get data of a Message-Event-Task-Relation + * + * @param string $messageEventTaskRelationUid Unique id of Message-Event-Task-Relation + * @param bool $flagGetRecord Value that set the getting + * + * return array Return an array with data of a Message-Event-Task-Relation + */ + public function getMessageEventTaskRelation($messageEventTaskRelationUid, $flagGetRecord = false) + { + try { + //Verify data + $this->throwExceptionIfNotExistsMessageEventTaskRelation($messageEventTaskRelationUid, $this->arrayFieldNameForException["messageEventTaskRelationUid"]); + + //Get data + $criteria = $this->getMessageEventTaskRelationCriteria(); + + $criteria->add(\MessageEventTaskRelationPeer::MSGETR_UID, $messageEventTaskRelationUid, \Criteria::EQUAL); + + $rsCriteria = \MessageEventTaskRelationPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + + $rsCriteria->next(); + + $row = $rsCriteria->getRow(); + + //Return + return (!$flagGetRecord)? $this->getMessageEventTaskRelationDataFromRecord($row) : $row; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get data of a Message-Event-Task-Relation + * + * @param array $arrayCondition Conditions + * @param bool $flagGetRecord Value that set the getting + * + * return array Return an array with data of a Message-Event-Task-Relation + */ + public function getMessageEventTaskRelationWhere(array $arrayCondition, $flagGetRecord = false) + { + try { + //Get data + $criteria = $this->getMessageEventTaskRelationCriteria(); + + foreach ($arrayCondition as $key => $value) { + $criteria->add($key, $value, \Criteria::EQUAL); + } + + $rsCriteria = \MessageEventTaskRelationPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + + if ($rsCriteria->next()) { + $row = $rsCriteria->getRow(); + + //Return + return (!$flagGetRecord)? $this->getMessageEventTaskRelationDataFromRecord($row) : $row; + } else { + //Return + return null; + } + } catch (\Exception $e) { + throw $e; + } + } +} + diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/WebEntryEvent.php b/workflow/engine/src/ProcessMaker/BusinessModel/WebEntryEvent.php index ae8557cce..c45cdb087 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/WebEntryEvent.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/WebEntryEvent.php @@ -359,9 +359,11 @@ class WebEntryEvent //Task $task = new \Task(); + $prefix = "wee-"; + $this->webEntryEventWebEntryTaskUid = $task->create( array( - "TAS_UID" => \ProcessMaker\Util\Common::generateUID(), + "TAS_UID" => $prefix . substr(\ProcessMaker\Util\Common::generateUID(), (32 - strlen($prefix)) * -1), "PRO_UID" => $projectUid, "TAS_TYPE" => "WEBENTRYEVENT", "TAS_TITLE" => "WEBENTRYEVENT", @@ -765,6 +767,8 @@ class WebEntryEvent throw new \Exception(\G::LoadTranslation("ID_REGISTRY_CANNOT_BE_UPDATED") . (($msg != "")? "\n" . $msg : "")); } } catch (\Exception $e) { + $cnn->rollback(); + $this->deleteWebEntry($this->webEntryEventWebEntryUid, $this->webEntryEventWebEntryTaskUid); throw $e; diff --git a/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php b/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php index e2bb094a0..996af7a58 100755 --- a/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php +++ b/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php @@ -22,6 +22,15 @@ class BpmnWorkflow extends Project\Bpmn const BPMN_GATEWAY_INCLUSIVE = "INCLUSIVE"; const BPMN_GATEWAY_EXCLUSIVE = "EXCLUSIVE"; + private $arrayTaskAttribute = array( + "gateway-to-gateway" => array("type" => "GATEWAYTOGATEWAY", "prefix" => "gtg-"), + "start-message-event" => array("type" => "START-MESSAGE-EVENT", "prefix" => "sme-"), + "end-message-event" => array("type" => "END-MESSAGE-EVENT", "prefix" => "eme-"), + "intermediate-start-message-event" => array("type" => "INTERMEDIATE-START-MESSAGE-EVENT", "prefix" => "isme-"), + "intermediate-end-message-event" => array("type" => "INTERMEDIATE-END-MESSAGE-EVENT", "prefix" => "ieme-") + ); + + private $arrayMessageEventTaskRelation = array(); /** * OVERRIDES @@ -247,18 +256,19 @@ class BpmnWorkflow extends Project\Bpmn //WebEntry-Event - Update $this->updateWebEntryEventByEvent($data["FLO_ELEMENT_ORIGIN"], array("ACT_UID" => $data["FLO_ELEMENT_DEST"])); break; + case "bpmnEvent": + $messageEventRelationUid = $this->createMessageEventRelationByBpmnFlow(\BpmnFlowPeer::retrieveByPK($floUid)); + break; } break; case "bpmnActivity": switch ($data["FLO_ELEMENT_DEST_TYPE"]) { case "bpmnEvent": - $actUid = $data["FLO_ELEMENT_ORIGIN"]; - $evnUid = $data["FLO_ELEMENT_DEST"]; - $event = \BpmnEventPeer::retrieveByPK($evnUid); + $event = \BpmnEventPeer::retrieveByPK($data["FLO_ELEMENT_DEST"]); // setting as end task - if ($event && $event->getEvnType() == "END") { - $this->wp->setEndTask($actUid); + if (!is_null($event) && $event->getEvnType() == "END" && $event->getEvnMarker() == "EMPTY") { + $this->wp->setEndTask($data["FLO_ELEMENT_ORIGIN"]); } break; } @@ -306,7 +316,7 @@ class BpmnWorkflow extends Project\Bpmn ) { $event = \BpmnEventPeer::retrieveByPK($flowBefore->getFloElementDest()); - if (!is_null($event) && $event->getEvnType() == "END") { + if (!is_null($event) && $event->getEvnType() == "END" && $event->getEvnMarker() == "EMPTY") { //Remove as end task $this->wp->setEndTask($flowBefore->getFloElementOrigin(), false); @@ -322,7 +332,7 @@ class BpmnWorkflow extends Project\Bpmn ) { $event = \BpmnEventPeer::retrieveByPK($flowBefore->getFloElementDest()); - if (!is_null($event) && $event->getEvnType() == "END") { + if (!is_null($event) && $event->getEvnType() == "END" && $event->getEvnMarker() == "EMPTY") { //Remove as end task $this->wp->setEndTask($flowBefore->getFloElementOrigin(), false); } @@ -336,6 +346,27 @@ class BpmnWorkflow extends Project\Bpmn ) { $this->wp->removeRouteFromTo($flowBefore->getFloElementOrigin(), $flowBefore->getFloElementDest()); } + + //Verify case: Event1(message) -> Event2(message) -----Update-to----> Event(message) -> Event(message) + if ($flowBefore->getFloType() == "MESSAGE" && + $flowBefore->getFloElementOriginType() == "bpmnEvent" && $flowBefore->getFloElementDestType() == "bpmnEvent" + ) { + //Delete Message-Event-Relation + $messageEventRelation = new \ProcessMaker\BusinessModel\MessageEventRelation(); + + $messageEventRelation->deleteWhere(array( + \MessageEventRelationPeer::PRJ_UID => $flowBefore->getPrjUid(), + \MessageEventRelationPeer::EVN_UID_THROW => $flowBefore->getFloElementOrigin(), + \MessageEventRelationPeer::EVN_UID_CATCH => $flowBefore->getFloElementDest() + )); + + //Create Message-Event-Relation + if ($flowCurrent->getFloType() == "MESSAGE" && + $flowCurrent->getFloElementOriginType() == "bpmnEvent" && $flowCurrent->getFloElementDestType() == "bpmnEvent" + ) { + $messageEventRelationUid = $this->createMessageEventRelationByBpmnFlow($flowCurrent); + } + } } public function removeFlow($floUid) @@ -379,7 +410,7 @@ class BpmnWorkflow extends Project\Bpmn // => find the corresponding task and unset it as start task $event = \BpmnEventPeer::retrieveByPK($flow->getFloElementDest()); - if (! is_null($event) && $event->getEvnType() == "END") { + if (!is_null($event) && $event->getEvnType() == "END" && $event->getEvnMarker() == "EMPTY") { $activity = \BpmnActivityPeer::retrieveByPK($flow->getFloElementOrigin()); if (! is_null($activity)) { @@ -396,6 +427,23 @@ class BpmnWorkflow extends Project\Bpmn break; } break; + case "bpmnEvent": + switch ($flow->getFloElementDestType()) { + //Event1 -> Event2 + case "bpmnEvent": + if ($flow->getFloType() == "MESSAGE") { + //Delete Message-Event-Relation + $messageEventRelation = new \ProcessMaker\BusinessModel\MessageEventRelation(); + + $messageEventRelation->deleteWhere(array( + \MessageEventRelationPeer::PRJ_UID => $flow->getPrjUid(), + \MessageEventRelationPeer::EVN_UID_THROW => $flow->getFloElementOrigin(), + \MessageEventRelationPeer::EVN_UID_CATCH => $flow->getFloElementDest() + )); + } + break; + } + break; } } @@ -411,12 +459,12 @@ class BpmnWorkflow extends Project\Bpmn $eventUid = parent::addEvent($data); $event = \BpmnEventPeer::retrieveByPK($eventUid); - //Delete case scheduler + // create case scheduler if ($event && $event->getEvnMarker() == "TIMER" && $event->getEvnType() == "START") { $this->wp->addCaseScheduler($eventUid); } - //Delete WebEntry-Event + // create web entry if ($event && $event->getEvnMarker() == "MESSAGE" && $event->getEvnType() == "START") { $this->wp->addWebEntry($eventUid); } @@ -428,19 +476,63 @@ class BpmnWorkflow extends Project\Bpmn { $event = \BpmnEventPeer::retrieveByPK($eventUid); - // delete case scheduler + //Delete case scheduler if ($event && $event->getEvnMarker() == "TIMER" && $event->getEvnType() == "START") { $this->wp->removeCaseScheduler($eventUid); } - // delete web entry - if (!is_null($event) && $event->getEvnType() == "START") { - $webEntryEvent = new \ProcessMaker\BusinessModel\WebEntryEvent(); + if (!is_null($event)) { + //WebEntry-Event - Delete + if ($event->getEvnType() == "START") { + $webEntryEvent = new \ProcessMaker\BusinessModel\WebEntryEvent(); - if ($webEntryEvent->existsEvent($event->getPrjUid(), $eventUid)) { - $arrayWebEntryEventData = $webEntryEvent->getWebEntryEventByEvent($event->getPrjUid(), $eventUid, true); + if ($webEntryEvent->existsEvent($event->getPrjUid(), $eventUid)) { + $arrayWebEntryEventData = $webEntryEvent->getWebEntryEventByEvent($event->getPrjUid(), $eventUid, true); - $webEntryEvent->delete($arrayWebEntryEventData["WEE_UID"]); + $webEntryEvent->delete($arrayWebEntryEventData["WEE_UID"]); + } + } + + //Message-Event-Definition - Delete + $arrayEventType = array("START", "END", "INTERMEDIATE"); + $arrayEventMarker = array("MESSAGETHROW", "MESSAGECATCH"); + + if (!is_null($event) && + in_array($event->getEvnType(), $arrayEventType) && in_array($event->getEvnMarker(), $arrayEventMarker) + ) { + $messageEventDefinition = new \ProcessMaker\BusinessModel\MessageEventDefinition(); + + if ($messageEventDefinition->existsEvent($event->getPrjUid(), $eventUid)) { + $arrayMessageEventDefinitionData = $messageEventDefinition->getMessageEventDefinitionByEvent($event->getPrjUid(), $eventUid, true); + + $messageEventDefinition->delete($arrayMessageEventDefinitionData["MSGED_UID"]); + } + } + + //Message-Event-Task-Relation - Delete + $messageEventTaskRelation = new \ProcessMaker\BusinessModel\MessageEventTaskRelation(); + + $arrayMessageEventTaskRelationData = $messageEventTaskRelation->getMessageEventTaskRelationWhere( + array( + \MessageEventTaskRelationPeer::PRJ_UID => $event->getPrjUid(), + \MessageEventTaskRelationPeer::EVN_UID => $event->getEvnUid() + ), + true + ); + + if (!is_null($arrayMessageEventTaskRelationData)) { + //Task - Delete + $arrayTaskData = $this->wp->getTask($arrayMessageEventTaskRelationData["TAS_UID"]); + + if (!is_null($arrayTaskData)) { + $this->wp->removeTask($arrayMessageEventTaskRelationData["TAS_UID"]); + } + + //Message-Event-Task-Relation - Delete + $messageEventTaskRelation->deleteWhere(array(\MessageEventTaskRelationPeer::MSGETR_UID => $arrayMessageEventTaskRelationData["MSGETR_UID"])); + + //Array - Delete element + unset($this->arrayMessageEventTaskRelation[$eventUid]); } } @@ -462,6 +554,84 @@ class BpmnWorkflow extends Project\Bpmn //} } + public function createTaskByElement($elementUid, $elementType, $key) + { + try { + if (isset($this->arrayMessageEventTaskRelation[$elementUid])) { + $taskUid = $this->arrayMessageEventTaskRelation[$elementUid]; + } else { + $taskPosX = 0; + $taskPosY = 0; + + $flow = \BpmnFlow::findOneBy(array( + \BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $elementUid, + \BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => $elementType + )); + + if (!is_null($flow)) { + $arrayFlowData = $flow->toArray(); + + $taskPosX = (int)($arrayFlowData["FLO_X1"]); + $taskPosY = (int)($arrayFlowData["FLO_Y1"]); + } else { + $flow = \BpmnFlow::findOneBy(array( + \BpmnFlowPeer::FLO_ELEMENT_DEST => $elementUid, + \BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE => $elementType + )); + + if (!is_null($flow)) { + $arrayFlowData = $flow->toArray(); + + $taskPosX = (int)($arrayFlowData["FLO_X2"]); + $taskPosY = (int)($arrayFlowData["FLO_Y2"]); + } + } + + $prefix = $this->arrayTaskAttribute[$key]["prefix"]; + $taskType = $this->arrayTaskAttribute[$key]["type"]; + + $taskUid = $this->wp->addTask(array( + "TAS_UID" => $prefix . substr(Util\Common::generateUID(), (32 - strlen($prefix)) * -1), + "TAS_TYPE" => $taskType, + "TAS_TITLE" => $taskType, + "TAS_POSX" => $taskPosX, + "TAS_POSY" => $taskPosY + )); + + if ($elementType == "bpmnEvent" && + in_array($key, array("start-message-event", "end-message-event", "intermediate-start-message-event")) + ) { + if ($key == "intermediate-start-message-event") { + //Task - User + //Assign to admin + $task = new \Tasks(); + + $result = $task->assignUser($taskUid, "00000000000000000000000000000001", 1); + } + + //Message-Event-Task-Relation - Create + $messageEventTaskRelation = new \ProcessMaker\BusinessModel\MessageEventTaskRelation(); + + $arrayResult = $messageEventTaskRelation->create( + $this->wp->getUid(), + array( + "EVN_UID" => $elementUid, + "TAS_UID" => $taskUid + ) + ); + + //Array - Add element + $this->arrayMessageEventTaskRelation[$elementUid] = $taskUid; + } + } + + //Return + return $taskUid; + } catch (\Exception $e) { + throw $e; + } + } + public function mapBpmnGatewayToWorkflowRoutes($activityUid, $gatewayUid) { try { @@ -509,16 +679,17 @@ class BpmnWorkflow extends Project\Bpmn break; } - $arrayGatewayFlowData = \BpmnFlow::findAllBy(array( - \BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $gatewayUid, + //Flows + $arrayFlow = \BpmnFlow::findAllBy(array( + \BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $gatewayUid, \BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnGateway" )); - if ($arrayGatewayFlowData > 0) { + if ($arrayFlow > 0) { $this->wp->resetTaskRoutes($activityUid); } - foreach ($arrayGatewayFlowData as $value) { + foreach ($arrayFlow as $value) { $arrayFlowData = $value->toArray(); $routeDefault = (array_key_exists("FLO_TYPE", $arrayFlowData) && $arrayFlowData["FLO_TYPE"] == "DEFAULT")? 1 : 0; @@ -526,37 +697,59 @@ class BpmnWorkflow extends Project\Bpmn switch ($arrayFlowData["FLO_ELEMENT_DEST_TYPE"]) { case "bpmnActivity": - case "bpmnEvent": //Gateway ----> Activity - //Gateway ----> Event - if ($arrayFlowData["FLO_ELEMENT_DEST_TYPE"] == "bpmnEvent") { - $event = \BpmnEventPeer::retrieveByPK($arrayFlowData["FLO_ELEMENT_DEST"]); - - if ($event->getEvnType() == "END") { - $result = $this->wp->addRoute($activityUid, -1, $routeType, $routeCondition, $routeDefault); - } - } else { - $result = $this->wp->addRoute($activityUid, $arrayFlowData["FLO_ELEMENT_DEST"], $routeType, $routeCondition, $routeDefault); - } + $result = $this->wp->addRoute($activityUid, $arrayFlowData["FLO_ELEMENT_DEST"], $routeType, $routeCondition, $routeDefault); break; case "bpmnGateway": //Gateway ----> Gateway - $taskUid = $this->wp->addTask(array( - "TAS_TYPE" => "GATEWAYTOGATEWAY", - "TAS_TITLE" => "GATEWAYTOGATEWAY", - "TAS_POSX" => (int)($arrayFlowData["FLO_X1"]), - "TAS_POSY" => (int)($arrayFlowData["FLO_Y1"]) - )); + $taskUid = $this->createTaskByElement( + $gatewayUid, + "bpmnGateway", + "gateway-to-gateway" + ); $result = $this->wp->addRoute($activityUid, $taskUid, $routeType, $routeCondition, $routeDefault); $this->mapBpmnGatewayToWorkflowRoutes($taskUid, $arrayFlowData["FLO_ELEMENT_DEST"]); break; + case "bpmnEvent": + //Gateway ----> Event + $event = \BpmnEventPeer::retrieveByPK($arrayFlowData["FLO_ELEMENT_DEST"]); + + if (!is_null($event)) { + switch ($event->getEvnType()) { + case "START": + throw new \LogicException("Incorrect design" . PHP_EOL . "Given: bpmnGateway -> " . $arrayFlowData["FLO_ELEMENT_DEST_TYPE"]); + break; + case "END": + //$event->getEvnMarker(): EMPTY or MESSAGETHROW + switch ($event->getEvnMarker()) { + case "EMPTY": + $result = $this->wp->addRoute($activityUid, -1, $routeType, $routeCondition, $routeDefault); + break; + case "MESSAGETHROW": + $taskUid = $this->createTaskByElement( + $event->getEvnUid(), + "bpmnEvent", + "end-message-event" + ); + + $result = $this->wp->addRoute($activityUid, $taskUid, $routeType, $routeCondition, $routeDefault); + $result = $this->wp->addRoute($taskUid, -1, "SEQUENTIAL"); + break; + } + break; + case "INTERMEDIATE": + $this->mapBpmnEventToWorkflowRoutes($activityUid, $arrayFlowData["FLO_ELEMENT_DEST"], $routeType, $routeCondition, $routeDefault); + break; + } + } + break; default: - //For processmaker is only allowed flows between: "gateway -> activity", "gateway -> gateway" + //For ProcessMaker is only allowed flows between: "gateway -> activity", "gateway -> gateway", "gateway -> event" //any another flow is considered invalid throw new \LogicException( - "For ProcessMaker is only allowed flows between: \"gateway -> activity\", \"gateway -> gateway\" " . PHP_EOL . + "For ProcessMaker is only allowed flows between: \"gateway -> activity\", \"gateway -> gateway\", \"gateway -> event\"" . PHP_EOL . "Given: bpmnGateway -> " . $arrayFlowData["FLO_ELEMENT_DEST_TYPE"] ); } @@ -566,29 +759,192 @@ class BpmnWorkflow extends Project\Bpmn } } + public function mapBpmnEventToWorkflowRoutes($activityUid, $eventUid, $routeType = "SEQUENTIAL", $routeCondition = "", $routeDefault = 0) + { + try { + $arrayEventData = \BpmnEvent::findOneBy(\BpmnEventPeer::EVN_UID, $eventUid)->toArray(); + + $arrayEventType = array("START", "INTERMEDIATE"); + $arrayEventMarker = array("MESSAGETHROW", "MESSAGECATCH"); + + if (!is_null($arrayEventData) && + in_array($arrayEventData["EVN_TYPE"], $arrayEventType) && in_array($arrayEventData["EVN_MARKER"], $arrayEventMarker) + ) { + //Event - INTERMEDIATE-START-MESSAGE-EVENT + if ($arrayEventData["EVN_TYPE"] == "INTERMEDIATE" && $arrayEventData["EVN_MARKER"] == "MESSAGECATCH") { + $taskUid = $this->createTaskByElement( + $eventUid, + "bpmnEvent", + "intermediate-start-message-event" + ); + + $result = $this->wp->addRoute($activityUid, $taskUid, $routeType, $routeCondition, $routeDefault); + + $activityUid = $taskUid; + } + + //Flows + $arrayFlow = \BpmnFlow::findAllBy(array( + \BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $eventUid, + \BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnEvent" + )); + + foreach ($arrayFlow as $value) { + $arrayFlowData = $value->toArray(); + + switch ($arrayFlowData["FLO_ELEMENT_DEST_TYPE"]) { + case "bpmnActivity": + //Event ----> Activity + $result = $this->wp->addRoute($activityUid, $arrayFlowData["FLO_ELEMENT_DEST"], "SEQUENTIAL"); + break; + case "bpmnGateway": + //Event ----> Gateway + $this->mapBpmnGatewayToWorkflowRoutes($activityUid, $arrayFlowData["FLO_ELEMENT_DEST"]); + break; + case "bpmnEvent": + //Event ----> Event + $event = \BpmnEventPeer::retrieveByPK($arrayFlowData["FLO_ELEMENT_DEST"]); + + if (!is_null($event)) { + switch ($event->getEvnType()) { + case "START": + throw new \LogicException("Incorrect design" . PHP_EOL . "Given: bpmnEvent -> " . $arrayFlowData["FLO_ELEMENT_DEST_TYPE"]); + break; + case "END": + //$event->getEvnMarker(): EMPTY or MESSAGETHROW + switch ($event->getEvnMarker()) { + case "EMPTY": + $result = $this->wp->addRoute($activityUid, -1, "SEQUENTIAL"); + break; + case "MESSAGETHROW": + $taskUid = $this->createTaskByElement( + $event->getEvnUid(), + "bpmnEvent", + "end-message-event" + ); + + $result = $this->wp->addRoute($activityUid, $taskUid, "SEQUENTIAL"); + $result = $this->wp->addRoute($taskUid, -1, "SEQUENTIAL"); + break; + } + break; + case "INTERMEDIATE": + $this->mapBpmnEventToWorkflowRoutes($activityUid, $arrayFlowData["FLO_ELEMENT_DEST"]); + break; + } + } + break; + default: + //For ProcessMaker is only allowed flows between: "event -> activity", "event -> gateway", "event -> event" + //any another flow is considered invalid + throw new \LogicException( + "For ProcessMaker is only allowed flows between: \"event -> activity\", \"event -> gateway\", \"event -> event\"" . PHP_EOL . + "Given: bpmnEvent -> " . $arrayFlowData["FLO_ELEMENT_DEST_TYPE"] + ); + } + } + } + } catch (\Exception $e) { + throw $e; + } + } + public function mapBpmnFlowsToWorkflowRoutes() { - $this->wp->deleteTaskGatewayToGateway($this->wp->getUid()); + //Task - Delete dummies + $this->wp->deleteTaskByArrayType( + $this->wp->getUid(), + array( + $this->arrayTaskAttribute["gateway-to-gateway"]["type"] + ) + ); - $activities = $this->getActivities(); + //Activities + foreach ($this->getActivities() as $value) { + $activity = $value; - foreach ($activities as $activity) { - $flows = \BpmnFlow::findAllBy(array( - \BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $activity["ACT_UID"], + //Flows + $arrayFlow = \BpmnFlow::findAllBy(array( + \BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $activity["ACT_UID"], \BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnActivity" )); - foreach ($flows as $flow) { + foreach ($arrayFlow as $value2) { + $flow = $value2; + switch ($flow->getFloElementDestType()) { case "bpmnActivity": - // (activity -> activity) + //Activity -> Activity $this->wp->addRoute($activity["ACT_UID"], $flow->getFloElementDest(), "SEQUENTIAL"); break; case "bpmnGateway": - // (activity -> gateway) - // we must find the related flows: gateway -> + //Activity -> Gateway + //We must find the related flows: gateway -> $this->mapBpmnGatewayToWorkflowRoutes($activity["ACT_UID"], $flow->getFloElementDest()); break; + case "bpmnEvent": + //Activity -> Event + $event = \BpmnEventPeer::retrieveByPK($flow->getFloElementDest()); + + if (!is_null($event)) { + switch ($event->getEvnType()) { + case "START": + throw new \LogicException("Incorrect design" . PHP_EOL . "Given: bpmnActivity -> " . $flow->getFloElementDestType()); + break; + case "END": + //$event->getEvnMarker(): EMPTY or MESSAGETHROW + switch ($event->getEvnMarker()) { + case "EMPTY": + //This it's already implemented + break; + case "MESSAGETHROW": + $taskUid = $this->createTaskByElement( + $event->getEvnUid(), + "bpmnEvent", + "end-message-event" + ); + + $result = $this->wp->addRoute($activity["ACT_UID"], $taskUid, "SEQUENTIAL"); + $result = $this->wp->addRoute($taskUid, -1, "SEQUENTIAL"); + break; + } + break; + case "INTERMEDIATE": + $this->mapBpmnEventToWorkflowRoutes($activity["ACT_UID"], $flow->getFloElementDest()); + break; + } + } + break; + } + } + } + + //Events - Message-Event + $arrayEventType = array("START", "END", "INTERMEDIATE"); + $arrayEventMarker = array("MESSAGETHROW", "MESSAGECATCH"); + + foreach ($this->getEvents() as $value) { + $event = $value; + + if (!isset($this->arrayMessageEventTaskRelation[$event["EVN_UID"]]) && + in_array($event["EVN_TYPE"], $arrayEventType) && in_array($event["EVN_MARKER"], $arrayEventMarker) + ) { + switch ($event["EVN_TYPE"]) { + case "START": + $taskUid = $this->createTaskByElement( + $event["EVN_UID"], + "bpmnEvent", + "start-message-event" + ); + + $this->wp->setStartTask($taskUid); + + $this->mapBpmnEventToWorkflowRoutes($taskUid, $event["EVN_UID"]); + break; + case "END": + break; + case "INTERMEDIATE": + break; } } } @@ -789,6 +1145,27 @@ class BpmnWorkflow extends Project\Bpmn $bwp->update($projectRecord); + //Array - Set empty + $bwp->arrayMessageEventTaskRelation = array(); + + //Message-Event-Task-Relation - Get all records + $criteria = new \Criteria("workflow"); + + $criteria->addSelectColumn(\MessageEventTaskRelationPeer::EVN_UID); + $criteria->addSelectColumn(\MessageEventTaskRelationPeer::TAS_UID); + + $criteria->add(\MessageEventTaskRelationPeer::PRJ_UID, $bwp->wp->getUid(), \Criteria::EQUAL); + + $rsCriteria = \MessageEventTaskRelationPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + + while ($rsCriteria->next()) { + $row = $rsCriteria->getRow(); + + //Array - Add element + $bwp->arrayMessageEventTaskRelation[$row["EVN_UID"]] = $row["TAS_UID"]; + } + /* * Diagram's Laneset Handling */ @@ -1356,5 +1733,33 @@ class BpmnWorkflow extends Project\Bpmn throw $e; } } + + public function createMessageEventRelationByBpmnFlow(\BpmnFlow $bpmnFlow) + { + try { + $messageEventRelationUid = ""; + + if ($bpmnFlow->getFloType() == "MESSAGE" && + $bpmnFlow->getFloElementOriginType() == "bpmnEvent" && $bpmnFlow->getFloElementDestType() == "bpmnEvent" + ) { + $messageEventRelation = new \ProcessMaker\BusinessModel\MessageEventRelation(); + + $arrayResult = $messageEventRelation->create( + $bpmnFlow->getPrjUid(), + array( + "EVN_UID_THROW" => $bpmnFlow->getFloElementOrigin(), + "EVN_UID_CATCH" => $bpmnFlow->getFloElementDest() + ) + ); + + $messageEventRelationUid = $arrayResult["MSGER_UID"]; + } + + //Return + return $messageEventRelationUid; + } catch (\Exception $e) { + throw $e; + } + } } diff --git a/workflow/engine/src/ProcessMaker/Project/Bpmn.php b/workflow/engine/src/ProcessMaker/Project/Bpmn.php index fb06a0b64..5903db89e 100755 --- a/workflow/engine/src/ProcessMaker/Project/Bpmn.php +++ b/workflow/engine/src/ProcessMaker/Project/Bpmn.php @@ -625,12 +625,53 @@ class Bpmn extends Handler } } + public function throwExceptionFlowIfIsAnInvalidMessageFlow(array $bpmnFlow) + { + try { + if ($bpmnFlow["FLO_TYPE"] == "MESSAGE" && + $bpmnFlow["FLO_ELEMENT_ORIGIN_TYPE"] == "bpmnEvent" && $bpmnFlow["FLO_ELEMENT_DEST_TYPE"] == "bpmnEvent" + ) { + $flagValid = true; + + $arrayEventType = array("START", "END", "INTERMEDIATE"); + + $arrayAux = array( + array("eventUid" => $bpmnFlow["FLO_ELEMENT_ORIGIN"], "eventMarker" => "MESSAGETHROW"), + array("eventUid" => $bpmnFlow["FLO_ELEMENT_DEST"], "eventMarker" => "MESSAGECATCH") + ); + + foreach ($arrayAux as $value) { + $criteria = new \Criteria("workflow"); + + $criteria->addSelectColumn(\BpmnEventPeer::EVN_UID); + $criteria->add(\BpmnEventPeer::EVN_UID, $value["eventUid"], \Criteria::EQUAL); + $criteria->add(\BpmnEventPeer::EVN_TYPE, $arrayEventType, \Criteria::IN); + $criteria->add(\BpmnEventPeer::EVN_MARKER, $value["eventMarker"], \Criteria::EQUAL); + + $rsCriteria = \BpmnEventPeer::doSelectRS($criteria); + + if (!$rsCriteria->next()) { + $flagValid = false; + break; + } + } + + if (!$flagValid) { + throw new \RuntimeException("Invalid Message Flow."); + } + } + } catch (\Exception $e) { + throw $e; + } + } + public function addFlow($data) { self::log("Add Flow with data: ", $data); // setting defaults $data['FLO_UID'] = array_key_exists('FLO_UID', $data) ? $data['FLO_UID'] : Common::generateUID(); + if (array_key_exists('FLO_STATE', $data)) { $data['FLO_STATE'] = is_array($data['FLO_STATE']) ? json_encode($data['FLO_STATE']) : $data['FLO_STATE']; } @@ -680,17 +721,23 @@ class Bpmn extends Handler )); } + //Check and validate Message Flow + $this->throwExceptionFlowIfIsAnInvalidMessageFlow($data); + + //Create $flow = new Flow(); $flow->fromArray($data, BasePeer::TYPE_FIELDNAME); $flow->setPrjUid($this->getUid()); $flow->setDiaUid($this->getDiagram("object")->getDiaUid()); $flow->setFloPosition($this->getFlowNextPosition($data["FLO_UID"], $data["FLO_TYPE"], $data["FLO_ELEMENT_ORIGIN"])); $flow->save(); + self::log("Add Flow Success!"); return $flow->getFloUid(); } catch (\Exception $e) { self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString()); + throw $e; } } @@ -703,7 +750,12 @@ class Bpmn extends Handler if (array_key_exists('FLO_STATE', $data)) { $data['FLO_STATE'] = is_array($data['FLO_STATE']) ? json_encode($data['FLO_STATE']) : $data['FLO_STATE']; } + try { + //Check and validate Message Flow + $this->throwExceptionFlowIfIsAnInvalidMessageFlow($data); + + //Update $flow = FlowPeer::retrieveByPk($floUid); $flow->fromArray($data); $flow->save(); diff --git a/workflow/engine/src/ProcessMaker/Project/Workflow.php b/workflow/engine/src/ProcessMaker/Project/Workflow.php index 322911913..c86a4c369 100755 --- a/workflow/engine/src/ProcessMaker/Project/Workflow.php +++ b/workflow/engine/src/ProcessMaker/Project/Workflow.php @@ -1236,7 +1236,7 @@ class Workflow extends Handler } } - public function deleteTaskGatewayToGateway($processUid) + public function deleteTaskByArrayType($processUid, array $arrayTaskType) { try { $task = new \Tasks(); @@ -1245,7 +1245,7 @@ class Workflow extends Handler $criteria->addSelectColumn(\TaskPeer::TAS_UID); $criteria->add(\TaskPeer::PRO_UID, $processUid, \Criteria::EQUAL); - $criteria->add(\TaskPeer::TAS_TYPE, "GATEWAYTOGATEWAY", \Criteria::EQUAL); + $criteria->add(\TaskPeer::TAS_TYPE, $arrayTaskType, \Criteria::IN); $rsCriteria = \TaskPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Project/MessageEventDefinition.php b/workflow/engine/src/ProcessMaker/Services/Api/Project/MessageEventDefinition.php new file mode 100644 index 000000000..b6ddc236b --- /dev/null +++ b/workflow/engine/src/ProcessMaker/Services/Api/Project/MessageEventDefinition.php @@ -0,0 +1,134 @@ +messageEventDefinition = new \ProcessMaker\BusinessModel\MessageEventDefinition(); + + $this->messageEventDefinition->setFormatFieldNameInUppercase(false); + } catch (\Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + } + + /** + * @url GET /:prj_uid/message-event-definitions + * + * @param string $prj_uid {@min 32}{@max 32} + */ + public function doGetMessageEventDefinitions($prj_uid) + { + try { + $response = $this->messageEventDefinition->getMessageEventDefinitions($prj_uid); + + return $response; + } catch (\Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + } + + /** + * @url GET /:prj_uid/message-event-definition/:msged_uid + * + * @param string $prj_uid {@min 32}{@max 32} + * @param string $msged_uid {@min 32}{@max 32} + */ + public function doGetMessageEventDefinition($prj_uid, $msged_uid) + { + try { + $response = $this->messageEventDefinition->getMessageEventDefinition($msged_uid); + + return $response; + } catch (\Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + } + + /** + * @url GET /:prj_uid/message-event-definition/event/:evn_uid + * + * @param string $prj_uid {@min 32}{@max 32} + * @param string $evn_uid {@min 32}{@max 32} + */ + public function doGetMessageEventDefinitionEvent($prj_uid, $evn_uid) + { + try { + $response = $this->messageEventDefinition->getMessageEventDefinitionByEvent($prj_uid, $evn_uid); + + return $response; + } catch (\Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + } + + /** + * @url POST /:prj_uid/message-event-definition + * + * @param string $prj_uid {@min 32}{@max 32} + * @param array $request_data + * + * @status 201 + */ + public function doPostMessageEventDefinition($prj_uid, array $request_data) + { + try { + $arrayData = $this->messageEventDefinition->create($prj_uid, $request_data); + + $response = $arrayData; + + return $response; + } catch (\Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + } + + /** + * @url PUT /:prj_uid/message-event-definition/:msged_uid + * + * @param string $prj_uid {@min 32}{@max 32} + * @param string $msged_uid {@min 32}{@max 32} + * @param array $request_data + */ + public function doPutMessageEventDefinition($prj_uid, $msged_uid, array $request_data) + { + try { + $arrayData = $this->messageEventDefinition->update($msged_uid, $request_data); + } catch (\Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + } + + /** + * @url DELETE /:prj_uid/message-event-definition/:msged_uid + * + * @param string $prj_uid {@min 32}{@max 32} + * @param string $msged_uid {@min 32}{@max 32} + */ + public function doDeleteMessageEventDefinition($prj_uid, $msged_uid) + { + try { + $this->messageEventDefinition->delete($msged_uid); + } catch (\Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + } +} + diff --git a/workflow/engine/src/ProcessMaker/Services/api.ini b/workflow/engine/src/ProcessMaker/Services/api.ini index bc877b2ec..5b54edbaf 100644 --- a/workflow/engine/src/ProcessMaker/Services/api.ini +++ b/workflow/engine/src/ProcessMaker/Services/api.ini @@ -39,7 +39,8 @@ debug = 1 process-variable = "ProcessMaker\Services\Api\Project\Variable" message-type = "ProcessMaker\Services\Api\Project\MessageType" message-type-variable = "ProcessMaker\Services\Api\Project\MessageType\Variable" - web-entry-event = "ProcessMaker\Services\Api\Project\WebEntryEvent" + web-entry-event = "ProcessMaker\Services\Api\Project\WebEntryEvent" + message-event-definition = "ProcessMaker\Services\Api\Project\MessageEventDefinition" [alias: projects] project = "ProcessMaker\Services\Api\Project" diff --git a/workflow/engine/templates/processes/main.js b/workflow/engine/templates/processes/main.js index 97717d73f..a7876f6ad 100755 --- a/workflow/engine/templates/processes/main.js +++ b/workflow/engine/templates/processes/main.js @@ -476,6 +476,8 @@ Ext.onReady(function(){ function newProcess(params) { + if (winDesigner) + winDesigner.close(); params = typeof params == 'undefined' ? {type:'classicProject'} : params; // TODO this variable have hardcoded labels, it must be changed on the future @@ -587,8 +589,10 @@ function saveProcess() if ( typeof(winDesigner) == "undefined" || winDesigner.closed ){ winDesigner = window.open( "../designer?prj_uid="+resp.result.PRO_UID, - '_blank' + 'winDesigner' ); + Ext.getCmp('newProjectWin').close(); + processesGrid.store.reload(); } else { PMExt.error( _('ID_FAILED'), _('PROCESS_ALREADY_OPENED')); } @@ -648,7 +652,7 @@ editProcess = function(typeParam) if (typeof(winDesigner) == "undefined" || winDesigner.closed){ winDesigner = window.open( url, - '_blank' + 'winDesigner' ); } else { PMExt.error( _('ID_FAILED'), _('PROCESS_ALREADY_OPENED')); @@ -964,7 +968,7 @@ importProcessExistGroup = function() if (typeof(winDesigner) == "undefined" || winDesigner.closed){ winDesigner = window.open( "../designer?prj_uid=" + sNewProUid, - '_blank' + 'winDesigner' ); } else { PMExt.error( _('ID_FAILED'), _('PROCESS_ALREADY_OPENED')); @@ -1110,7 +1114,7 @@ importProcessExistProcess = function() if (typeof(winDesigner) == "undefined" || winDesigner.closed){ winDesigner = window.open( "../designer?prj_uid=" + sNewProUid, - '_blank' + 'winDesigner' ); } else { PMExt.error( _('ID_FAILED'), _('PROCESS_ALREADY_OPENED')); @@ -1163,6 +1167,11 @@ importProcessExistProcess = function() importProcess = function() { + if (winDesigner) { + winDesigner.close(); + if (!winDesigner.closed) + return; + } var processFileType = importProcessGlobal.processFileType; var processFileTypeTitle = (processFileType == "pm") ? "" : " " + processFileType; @@ -1248,7 +1257,7 @@ importProcess = function() if (typeof(winDesigner) == "undefined" || winDesigner.closed){ winDesigner = window.open( "../designer?prj_uid=" + sNewProUid, - '_blank' + 'winDesigner' ); } else { PMExt.error( _('ID_FAILED'), _('PROCESS_ALREADY_OPENED')); @@ -1564,3 +1573,7 @@ function enableDisableDebug() } +Ext.EventManager.on(window, 'beforeunload', function () { + if (winDesigner) + winDesigner.close(); +}); \ No newline at end of file