CODE STYLE Formating worflow/engine/classes/model/AppFolder.php

CODE STYLE Formating worflow/engine/classes/model/Step.php

Change format files in worflow/engine/classes/model/AppFolder.php
Change format files in worflow/engine/classes/model/Step.php
This commit is contained in:
norahmollo
2012-10-19 13:13:05 +00:00
parent a09707f72f
commit 2906790fe3
2 changed files with 1105 additions and 1119 deletions

View File

@@ -1,6 +1,7 @@
<?php <?php
/** /**
* AppFolder.php * AppFolder.php
*
* @package workflow.engine.classes.model * @package workflow.engine.classes.model
*/ */
@@ -15,21 +16,29 @@ require_once 'classes/model/Application.php';
* You should add additional methods to this class to meet the * You should add additional methods to this class to meet the
* application requirements. This class will only be generated as * application requirements. This class will only be generated as
* long as it does not already exist in the output directory. * long as it does not already exist in the output directory.
*
*/ */
/** /**
*
* @author hugo loza * @author hugo loza
* @package workflow.engine.classes.model * @package workflow.engine.classes.model
*/ */
class AppFolder extends BaseAppFolder { class AppFolder extends BaseAppFolder
{
/** /**
*
* @param string $folderName * @param string $folderName
* @param strin(32) $folderParent * @param strin(32) $folderParent
* @return Ambigous <>|number * @return Ambigous <>|number
*/ */
function createFolder($folderName, $folderParent = "/", $action="createifnotexists") { function createFolder ($folderName, $folderParent = "/", $action = "createifnotexists")
$validActions=array("createifnotexists","create","update"); {
if(!in_array($action,$validActions)) $action="createifnotexists"; $validActions = array ("createifnotexists","create","update"
);
if (! in_array( $action, $validActions )) {
$action = "createifnotexists";
}
//Clean Folder and Parent names (delete spaces...) //Clean Folder and Parent names (delete spaces...)
$folderName = trim( $folderName ); $folderName = trim( $folderName );
$folderParent = trim( $folderParent ); $folderParent = trim( $folderParent );
@@ -40,13 +49,15 @@ class AppFolder extends BaseAppFolder {
$oDataset = AppFolderPeer::doSelectRS( $oCriteria ); $oDataset = AppFolderPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next(); $oDataset->next();
if ($aRow = $oDataset->getRow ()) {//Folder exist, then return the ID if ($aRow = $oDataset->getRow()) {
//Folder exist, then return the ID
$response['success'] = false; $response['success'] = false;
$response['message'] = $response['error'] = "Can't create folder <br /> A folder with same name already exist. <br /> $folderName"; $response['message'] = $response['error'] = "Can't create folder <br /> A folder with same name already exist. <br /> $folderName";
$response['folderUID'] = $aRow['FOLDER_UID']; $response['folderUID'] = $aRow['FOLDER_UID'];
//return ($aRow ['FOLDER_UID']); //return ($aRow ['FOLDER_UID']);
return ($response); return ($response);
} else {//Folder doesn't exist. Create and return the ID } else {
//Folder doesn't exist. Create and return the ID
$folderUID = G::GenerateUniqueID(); $folderUID = G::GenerateUniqueID();
$tr = new AppFolder(); $tr = new AppFolder();
$tr->setFolderUid( $folderUID ); $tr->setFolderUid( $folderUID );
@@ -70,30 +81,30 @@ class AppFolder extends BaseAppFolder {
$msg .= $objValidationFailure->getMessage() . "<br/>"; $msg .= $objValidationFailure->getMessage() . "<br/>";
} }
$response['success'] = false; $response['success'] = false;
$response['message'] = $response['error'] = "Can't create folder \n A \n " . $msg; $response['message'] = $response['error'] = "Can't create folder \n A \n " . $msg;
return ($response); return ($response);
} }
} }
} }
/** /**
*
* @param string $folderPath * @param string $folderPath
* @param strin(32) $sessionID * @param strin(32) $sessionID
* @return string Last Folder ID generated * @return string Last Folder ID generated
*/ */
function createFromPath($folderPath, $sessionID = "") { function createFromPath ($folderPath, $sessionID = "")
if ($sessionID == "") {
if ($sessionID == "") {
$sessionID = $_SESSION['APPLICATION']; $sessionID = $_SESSION['APPLICATION'];
//Get current Application Fields //Get current Application Fields
}
$oApplication = new Application(); $oApplication = new Application();
$appFields = $oApplication->Load( $sessionID ); $appFields = $oApplication->Load( $sessionID );
$folderPathParsed = G::replaceDataField( $folderPath, $appFields ); $folderPathParsed = G::replaceDataField( $folderPath, $appFields );
$folderPathParsed = G::replaceDataField( $folderPath, unserialize( $appFields['APP_DATA'] ) ); $folderPathParsed = G::replaceDataField( $folderPath, unserialize( $appFields['APP_DATA'] ) );
$folderPathParsedArray = explode( "/", $folderPathParsed ); $folderPathParsedArray = explode( "/", $folderPathParsed );
$folderRoot = "/"; //Always starting from Root $folderRoot = "/"; //Always starting from Root
foreach ($folderPathParsedArray as $folderName) { foreach ($folderPathParsedArray as $folderName) {
if (trim( $folderName ) != "") { if (trim( $folderName ) != "") {
@@ -105,50 +116,51 @@ class AppFolder extends BaseAppFolder {
} }
/** /**
*
* @param string $fileTags * @param string $fileTags
* @param string(32) $sessionID Application ID * @param string(32) $sessionID Application ID
* @return string * @return string
*/ */
function parseTags($fileTags, $sessionID = "") { function parseTags ($fileTags, $sessionID = "")
{
if ($sessionID == "") if ($sessionID == "") {
$sessionID = $_SESSION['APPLICATION']; $sessionID = $_SESSION['APPLICATION'];
//Get current Application Fields //Get current Application Fields
}
$oApplication = new Application(); $oApplication = new Application();
$appFields = $oApplication->Load( $sessionID ); $appFields = $oApplication->Load( $sessionID );
$fileTagsParsed = G::replaceDataField( $fileTags, $appFields ); $fileTagsParsed = G::replaceDataField( $fileTags, $appFields );
$fileTagsParsed = G::replaceDataField( $fileTags, unserialize( $appFields['APP_DATA'] ) ); $fileTagsParsed = G::replaceDataField( $fileTags, unserialize( $appFields['APP_DATA'] ) );
return $fileTagsParsed; return $fileTagsParsed;
} }
/** /**
*
* @param string(32) $folderID * @param string(32) $folderID
* @return multitype: * @return multitype:
*/ */
function getFolderList($folderID, $limit=0, $start=0) { function getFolderList ($folderID, $limit = 0, $start = 0)
{
$Criteria = new Criteria( 'workflow' ); $Criteria = new Criteria( 'workflow' );
$Criteria->clearSelectColumns()->clearOrderByColumns(); $Criteria->clearSelectColumns()->clearOrderByColumns();
$Criteria->addSelectColumn( AppFolderPeer::FOLDER_UID ); $Criteria->addSelectColumn( AppFolderPeer::FOLDER_UID );
$Criteria->addSelectColumn( AppFolderPeer::FOLDER_PARENT_UID ); $Criteria->addSelectColumn( AppFolderPeer::FOLDER_PARENT_UID );
$Criteria->addSelectColumn( AppFolderPeer::FOLDER_NAME ); $Criteria->addSelectColumn( AppFolderPeer::FOLDER_NAME );
$Criteria->addSelectColumn( AppFolderPeer::FOLDER_CREATE_DATE ); $Criteria->addSelectColumn( AppFolderPeer::FOLDER_CREATE_DATE );
$Criteria->addSelectColumn( AppFolderPeer::FOLDER_UPDATE_DATE ); $Criteria->addSelectColumn( AppFolderPeer::FOLDER_UPDATE_DATE );
$Criteria->add( appFolderPeer::FOLDER_PARENT_UID, $folderID, CRITERIA::EQUAL ); $Criteria->add( appFolderPeer::FOLDER_PARENT_UID, $folderID, CRITERIA::EQUAL );
$Criteria->addAscendingOrderByColumn( AppFolderPeer::FOLDER_NAME ); $Criteria->addAscendingOrderByColumn( AppFolderPeer::FOLDER_NAME );
$response['totalFoldersCount'] = AppFolderPeer::doCount( $Criteria ); $response['totalFoldersCount'] = AppFolderPeer::doCount( $Criteria );
$response['folders'] = array (); $response['folders'] = array ();
if ($limit != 0) { if ($limit != 0) {
$Criteria->setLimit( $limit ); $Criteria->setLimit( $limit );
$Criteria->setOffset( $start ); $Criteria->setOffset( $start );
} }
$rs = appFolderPeer::doSelectRS( $Criteria ); $rs = appFolderPeer::doSelectRS( $Criteria );
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$rs->next(); $rs->next();
@@ -159,11 +171,14 @@ if($limit != 0){
} }
return ($response); return ($response);
} }
/** /**
*
* @param string(32) $folderUid * @param string(32) $folderUid
* @return array <multitype:, mixed> * @return array <multitype:, mixed>
*/ */
function load($folderUid) { function load ($folderUid)
{
$tr = AppFolderPeer::retrieveByPK( $folderUid ); $tr = AppFolderPeer::retrieveByPK( $folderUid );
if ((is_object( $tr ) && get_class( $tr ) == 'AppFolder')) { if ((is_object( $tr ) && get_class( $tr ) == 'AppFolder')) {
$fields['FOLDER_UID'] = $tr->getFolderUid(); $fields['FOLDER_UID'] = $tr->getFolderUid();
@@ -187,10 +202,12 @@ if($limit != 0){
} }
return $fields; return $fields;
} }
function getFolderStructure($folderId) {
function getFolderStructure ($folderId)
{
$folderObj = $this->load( $folderId ); $folderObj = $this->load( $folderId );
$folderArray [$folderObj ['FOLDER_UID']] = array ("NAME" => $folderObj ['FOLDER_NAME'], "PARENT" => $folderObj ['FOLDER_PARENT_UID'] ); $folderArray[$folderObj['FOLDER_UID']] = array ("NAME" => $folderObj['FOLDER_NAME'],"PARENT" => $folderObj['FOLDER_PARENT_UID']
);
$folderArray['PATH_ARRAY'][] = $folderObj['FOLDER_NAME']; $folderArray['PATH_ARRAY'][] = $folderObj['FOLDER_NAME'];
while ($folderObj['FOLDER_PARENT_UID'] != "") { while ($folderObj['FOLDER_PARENT_UID'] != "") {
@@ -203,7 +220,8 @@ if($limit != 0){
return $folderArray; return $folderArray;
} }
function getFolderContent($folderID, $docIdFilter = array(), $keyword = NULL, $searchType = NULL, $limit=0, $start=0, $user='', $onlyActive=false) { function getFolderContent ($folderID, $docIdFilter = array(), $keyword = null, $searchType = null, $limit = 0, $start = 0, $user = '', $onlyActive = false)
{
require_once ("classes/model/AppDocument.php"); require_once ("classes/model/AppDocument.php");
require_once ("classes/model/InputDocument.php"); require_once ("classes/model/InputDocument.php");
require_once ("classes/model/OutputDocument.php"); require_once ("classes/model/OutputDocument.php");
@@ -217,11 +235,12 @@ if($limit != 0){
$oAppDocument = new AppDocument(); $oAppDocument = new AppDocument();
$oCriteria = new Criteria(); $oCriteria = new Criteria();
if ((is_array ( $docIdFilter )) && (count ( $docIdFilter ) > 0)) { //Search by App Doc UID no matter what Folder it is if ((is_array( $docIdFilter )) && (count( $docIdFilter ) > 0)) {
//Search by App Doc UID no matter what Folder it is
$oCriteria->add( AppDocumentPeer::APP_DOC_UID, $docIdFilter, CRITERIA::IN ); $oCriteria->add( AppDocumentPeer::APP_DOC_UID, $docIdFilter, CRITERIA::IN );
} elseif ($folderID != NULL) { } elseif ($folderID != null) {
if ($folderID == "/") { if ($folderID == "/") {
$oCriteria->add ( AppDocumentPeer::FOLDER_UID, array('root','',NULL), CRITERIA::IN ); $oCriteria->add( AppDocumentPeer::FOLDER_UID, array ('root','',null), CRITERIA::IN );
} else { } else {
$oCriteria->add( AppDocumentPeer::FOLDER_UID, $folderID ); $oCriteria->add( AppDocumentPeer::FOLDER_UID, $folderID );
} }
@@ -259,20 +278,15 @@ if($limit != 0){
$oCase->verifyTable(); $oCase->verifyTable();
$oCriteria->addAscendingOrderByColumn( AppDocumentPeer::APP_DOC_INDEX ); $oCriteria->addAscendingOrderByColumn( AppDocumentPeer::APP_DOC_INDEX );
$oCriteria->addDescendingOrderByColumn( AppDocumentPeer::DOC_VERSION ); $oCriteria->addDescendingOrderByColumn( AppDocumentPeer::DOC_VERSION );
$response['totalDocumentsCount'] = AppDocumentPeer::doCount( $oCriteria ); $response['totalDocumentsCount'] = AppDocumentPeer::doCount( $oCriteria );
$response['documents'] = array (); $response['documents'] = array ();
$oCriteria->setLimit( $limit ); $oCriteria->setLimit( $limit );
$oCriteria->setOffset( $start ); $oCriteria->setOffset( $start );
$rs = AppDocumentPeer::doSelectRS( $oCriteria ); $rs = AppDocumentPeer::doSelectRS( $oCriteria );
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$rs->next(); $rs->next();
@@ -281,10 +295,8 @@ if($limit != 0){
//**** start get Doc Info //**** start get Doc Info
$oApp = new Application(); $oApp = new Application();
if (($oApp->exists( $row['APP_UID'] )) || ($row['APP_UID'] == "00000000000000000000000000000000")) { if (($oApp->exists( $row['APP_UID'] )) || ($row['APP_UID'] == "00000000000000000000000000000000")) {
//$completeInfo = array("APP_DOC_FILENAME" => $row ["APP_DOC_UID"],"APP_DOC_UID"=>$row ['APP_UID']); //$completeInfo = array("APP_DOC_FILENAME" => $row ["APP_DOC_UID"],"APP_DOC_UID"=>$row ['APP_UID']);
$completeInfo = $this->getCompleteDocumentInfo( $row['APP_UID'], $row['APP_DOC_UID'], $row['DOC_VERSION'], $row['DOC_UID'], $row['USR_UID'] ); $completeInfo = $this->getCompleteDocumentInfo( $row['APP_UID'], $row['APP_DOC_UID'], $row['DOC_VERSION'], $row['DOC_UID'], $row['USR_UID'] );
$oAppDocument = new AppDocument(); $oAppDocument = new AppDocument();
$lastVersion = $oAppDocument->getLastAppDocVersion( $row['APP_DOC_UID'], $row['APP_UID'] ); $lastVersion = $oAppDocument->getLastAppDocVersion( $row['APP_DOC_UID'], $row['APP_UID'] );
//$filesResult [] = $completeInfo; //$filesResult [] = $completeInfo;
@@ -294,16 +306,17 @@ if($limit != 0){
if (in_array( $row['APP_DOC_UID'], $docIdFilter )) { if (in_array( $row['APP_DOC_UID'], $docIdFilter )) {
$response['documents'][] = $completeInfo; $response['documents'][] = $completeInfo;
} }
} elseif ($lastVersion == $row ['DOC_VERSION']) { //Only Last Document version } elseif ($lastVersion == $row['DOC_VERSION']) {
//Only Last Document version
if ($searchType == "ALL") { // If search in name of docs is active then filter if ($searchType == "ALL") { // If search in name of docs is active then filter
if ((stripos( $completeInfo['APP_DOC_FILENAME'], $keyword ) !== false) || (stripos( $completeInfo['APP_DOC_TAGS'], $keyword ) !== false)) { if ((stripos( $completeInfo['APP_DOC_FILENAME'], $keyword ) !== false) || (stripos( $completeInfo['APP_DOC_TAGS'], $keyword ) !== false)) {
$response['documents'][] = $completeInfo; $response['documents'][] = $completeInfo;
} }
} else {//No search filter active } else {
//No search filter active
$response['documents'][] = $completeInfo; $response['documents'][] = $completeInfo;
} }
} }
} }
} }
} }
@@ -311,7 +324,9 @@ if($limit != 0){
} }
return ($response); return ($response);
} }
function getCompleteDocumentInfo($appUid, $appDocUid, $docVersion, $docUid, $usrId) {
function getCompleteDocumentInfo ($appUid, $appDocUid, $docVersion, $docUid, $usrId)
{
require_once ("classes/model/AppDocument.php"); require_once ("classes/model/AppDocument.php");
require_once ("classes/model/InputDocument.php"); require_once ("classes/model/InputDocument.php");
require_once ("classes/model/OutputDocument.php"); require_once ("classes/model/OutputDocument.php");
@@ -388,7 +403,6 @@ if($limit != 0){
/////// ///////
if (! empty( $row1["APP_DOC_PLUGIN"] )) { if (! empty( $row1["APP_DOC_PLUGIN"] )) {
$pluginRegistry = &PMPluginRegistry::getSingleton(); $pluginRegistry = &PMPluginRegistry::getSingleton();
$pluginName = $row1["APP_DOC_PLUGIN"]; $pluginName = $row1["APP_DOC_PLUGIN"];
$fieldValue = ""; $fieldValue = "";
@@ -398,23 +412,18 @@ if($limit != 0){
if ($pluginDetail) { if ($pluginDetail) {
if ($pluginDetail->enabled) { if ($pluginDetail->enabled) {
require_once (PATH_PLUGINS . $pluginName . ".php"); require_once (PATH_PLUGINS . $pluginName . ".php");
$pluginNameClass = $pluginName . "Plugin"; $pluginNameClass = $pluginName . "Plugin";
$objPluginClass = new $pluginNameClass( $pluginName ); $objPluginClass = new $pluginNameClass( $pluginName );
if (isset( $objPluginClass->sMethodGetUrlDownload ) && ! empty( $objPluginClass->sMethodGetUrlDownload )) { if (isset( $objPluginClass->sMethodGetUrlDownload ) && ! empty( $objPluginClass->sMethodGetUrlDownload )) {
if (file_exists( PATH_PLUGINS . $pluginName . PATH_SEP . "class." . $pluginName . ".php" )) { if (file_exists( PATH_PLUGINS . $pluginName . PATH_SEP . "class." . $pluginName . ".php" )) {
require_once (PATH_PLUGINS . $pluginName . PATH_SEP . "class." . $pluginName . ".php"); require_once (PATH_PLUGINS . $pluginName . PATH_SEP . "class." . $pluginName . ".php");
$pluginNameClass = $pluginName . "Class"; $pluginNameClass = $pluginName . "Class";
$objClass = new $pluginNameClass(); $objClass = new $pluginNameClass();
if (method_exists( $objClass, $objPluginClass->sMethodGetUrlDownload )) { if (method_exists( $objClass, $objPluginClass->sMethodGetUrlDownload )) {
eval( "\$url = \$objClass->" . $objPluginClass->sMethodGetUrlDownload . "(\"" . $row1["APP_DOC_UID"] . "\");" ); eval( "\$url = \$objClass->" . $objPluginClass->sMethodGetUrlDownload . "(\"" . $row1["APP_DOC_UID"] . "\");" );
$downloadLink = $url; $downloadLink = $url;
$fieldValue = $row1["APP_DOC_PLUGIN"]; $fieldValue = $row1["APP_DOC_PLUGIN"];
} }
} }
@@ -422,7 +431,6 @@ if($limit != 0){
} }
} }
} }
$row1["APP_DOC_PLUGIN"] = $fieldValue; $row1["APP_DOC_PLUGIN"] = $fieldValue;
} }
break; break;
@@ -435,7 +443,6 @@ if($limit != 0){
$downloadLabel = G::LoadTranslation( 'ID_DOWNLOAD' ); $downloadLabel = G::LoadTranslation( 'ID_DOWNLOAD' );
$downloadLabel1 = ""; $downloadLabel1 = "";
break; break;
} }
$oUser = new Users(); $oUser = new Users();
if (($usrId != "-1") && ($oUser->userExists( $usrId ))) { if (($usrId != "-1") && ($oUser->userExists( $usrId ))) {
@@ -460,12 +467,11 @@ if($limit != 0){
} }
$row6['APP_DOC_UID_VERSION'] = $appDocUid . "_" . $docVersion; $row6['APP_DOC_UID_VERSION'] = $appDocUid . "_" . $docVersion;
if ($appUid == "00000000000000000000000000000000") { //External Files if ($appUid == "00000000000000000000000000000000") {
//External Files
$row1['APP_DOC_TYPE'] = G::LoadTranslation( 'ID_EXTERNAL_FILE' ); $row1['APP_DOC_TYPE'] = G::LoadTranslation( 'ID_EXTERNAL_FILE' );
} }
//**** End get docinfo //**** End get docinfo
$infoMerged = array_merge( $row1, $row2, $row3, $row4, $row5, $row6 ); $infoMerged = array_merge( $row1, $row2, $row3, $row4, $row5, $row6 );
//krumo($infoMerged); //krumo($infoMerged);
//**************************************************************************************************** //****************************************************************************************************
@@ -476,7 +482,10 @@ if($limit != 0){
} }
if (! is_array( $aObjectPermissions )) { if (! is_array( $aObjectPermissions )) {
$aObjectPermissions = array ('DYNAFORMS' => array (- 1 ), 'INPUT_DOCUMENTS' => array (- 1 ), 'OUTPUT_DOCUMENTS' => array (- 1 ) ); $aObjectPermissions = array ('DYNAFORMS' => array (- 1),
'INPUT_DOCUMENTS' => array (- 1),
'OUTPUT_DOCUMENTS' => array (- 1)
);
} }
if (! isset( $aObjectPermissions['DYNAFORMS'] )) { if (! isset( $aObjectPermissions['DYNAFORMS'] )) {
$aObjectPermissions['DYNAFORMS'] = array (- 1); $aObjectPermissions['DYNAFORMS'] = array (- 1);
@@ -500,12 +509,12 @@ if($limit != 0){
} }
} }
//**************************************************************************************************** //****************************************************************************************************
return array_merge( $infoMerged, $aObjectPermissions ); return array_merge( $infoMerged, $aObjectPermissions );
} }
} }
function getFolderChilds($folderID, $folderArray) {
function getFolderChilds ($folderID, $folderArray)
{
$folderList = $this->getFolderList( $folderID ); $folderList = $this->getFolderList( $folderID );
$foldersList = array (); $foldersList = array ();
foreach ($folderList as $key => $folderObj) { foreach ($folderList as $key => $folderObj) {
@@ -515,7 +524,8 @@ if($limit != 0){
return (array_merge( $folderArray, $foldersList )); return (array_merge( $folderArray, $foldersList ));
} }
function getFolderTags($rootFolder) { function getFolderTags ($rootFolder)
{
$folderArray[$rootFolder] = $rootFolder; $folderArray[$rootFolder] = $rootFolder;
$foldersToProcess = $this->getFolderChilds( $rootFolder, $folderArray ); $foldersToProcess = $this->getFolderChilds( $rootFolder, $folderArray );
$tagsInfo = array (); $tagsInfo = array ();
@@ -535,9 +545,13 @@ if($limit != 0){
return $tagsInfo; return $tagsInfo;
} }
function remove ($FolderUid, $rootfolder ) {
function remove ($FolderUid, $rootfolder)
{
$oCriteria = new Criteria( 'workflow' ); $oCriteria = new Criteria( 'workflow' );
$oCriteria->add( AppFolderPeer::FOLDER_UID, $FolderUid ); $oCriteria->add( AppFolderPeer::FOLDER_UID, $FolderUid );
AppFolderPeer::doDelete( $oCriteria ); AppFolderPeer::doDelete( $oCriteria );
} }
} // AppFolder }
// AppFolder

View File

@@ -1,6 +1,7 @@
<?php <?php
/** /**
* Step.php * Step.php
*
* @package workflow.engine.classes.model * @package workflow.engine.classes.model
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
@@ -26,7 +27,6 @@
require_once 'classes/model/om/BaseStep.php'; require_once 'classes/model/om/BaseStep.php';
/** /**
* Skeleton subclass for representing a row from the 'STEP' table. * Skeleton subclass for representing a row from the 'STEP' table.
* *
@@ -38,63 +38,67 @@ require_once 'classes/model/om/BaseStep.php';
* *
* @package workflow.engine.classes.model * @package workflow.engine.classes.model
*/ */
class Step extends BaseStep { class Step extends BaseStep
function create($aData) {
public function create ($aData)
{ {
$con = Propel::getConnection( StepPeer::DATABASE_NAME ); $con = Propel::getConnection( StepPeer::DATABASE_NAME );
try try {
{ if (isset( $aData['STEP_UID'] ) && $aData['STEP_UID'] == '') {
if ( isset ( $aData['STEP_UID'] ) && $aData['STEP_UID']== '' )
unset( $aData['STEP_UID'] ); unset( $aData['STEP_UID'] );
if ( isset ( $aData['STEP_UID'] ) ) }
if (isset( $aData['STEP_UID'] )) {
$sStepUID = $aData['STEP_UID']; $sStepUID = $aData['STEP_UID'];
else } else {
$sStepUID = G::generateUniqueID(); $sStepUID = G::generateUniqueID();
}
$con->begin(); $con->begin();
$this->setStepUid( $sStepUID ); $this->setStepUid( $sStepUID );
$this->setProUid( $aData['PRO_UID'] ); $this->setProUid( $aData['PRO_UID'] );
$this->setTasUid( $aData['TAS_UID'] ); $this->setTasUid( $aData['TAS_UID'] );
if (isset ( $aData['STEP_TYPE_OBJ'] )) if (isset( $aData['STEP_TYPE_OBJ'] )) {
$this->setStepTypeObj( $aData['STEP_TYPE_OBJ'] ); $this->setStepTypeObj( $aData['STEP_TYPE_OBJ'] );
else } else {
$this->setStepTypeObj( "DYNAFORM" ); $this->setStepTypeObj( "DYNAFORM" );
}
if (isset ( $aData['STEP_UID_OBJ'] )) if (isset( $aData['STEP_UID_OBJ'] )) {
$this->setStepUidObj( $aData['STEP_UID_OBJ'] ); $this->setStepUidObj( $aData['STEP_UID_OBJ'] );
else } else {
$this->setStepUidObj( "" ); $this->setStepUidObj( "" );
}
if (isset ( $aData['STEP_CONDITION'] )) if (isset( $aData['STEP_CONDITION'] )) {
$this->setStepCondition( $aData['STEP_CONDITION'] ); $this->setStepCondition( $aData['STEP_CONDITION'] );
else } else {
$this->setStepCondition( "" ); $this->setStepCondition( "" );
}
if (isset ( $aData['STEP_POSITION'] )) if (isset( $aData['STEP_POSITION'] )) {
$this->setStepPosition( $aData['STEP_POSITION'] ); $this->setStepPosition( $aData['STEP_POSITION'] );
else } else {
$this->setStepPosition( "" ); $this->setStepPosition( "" );
}
if (isset ( $aData['STEP_MODE'] )) if (isset( $aData['STEP_MODE'] )) {
$this->setStepMode( $aData['STEP_MODE'] ); $this->setStepMode( $aData['STEP_MODE'] );
else } else {
$this->setStepMode( "" ); $this->setStepMode( "" );
}
if($this->validate()) if ($this->validate()) {
{
$result = $this->save(); $result = $this->save();
$con->commit(); $con->commit();
return $sStepUID; return $sStepUID;
} } else {
else
{
$con->rollback(); $con->rollback();
throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." )); throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." ));
} }
}
catch(Exception $e) } catch (Exception $e) {
{
$con->rollback(); $con->rollback();
throw ($e); throw ($e);
} }
@@ -104,18 +108,15 @@ class Step extends BaseStep {
{ {
try { try {
$oRow = StepPeer::retrieveByPK( $StepUid ); $oRow = StepPeer::retrieveByPK( $StepUid );
if (!is_null($oRow)) if (! is_null( $oRow )) {
{
$aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME ); $aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME ); $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
$this->setNew( false ); $this->setNew( false );
return $aFields; return $aFields;
} } else {
else {
throw (new Exception( "The row '$StepUid' in table StepUid doesn't exist!" )); throw (new Exception( "The row '$StepUid' in table StepUid doesn't exist!" ));
} }
} } catch (Exception $oError) {
catch (Exception $oError) {
throw ($oError); throw ($oError);
} }
} }
@@ -130,13 +131,11 @@ class Step extends BaseStep {
if (StepPeer::doCount( $c ) > 0) { if (StepPeer::doCount( $c ) > 0) {
$rs = StepPeer::doSelect( $c ); $rs = StepPeer::doSelect( $c );
return $rs[0]; return $rs[0];
} } else {
else {
return null; return null;
} }
} } catch (Exception $oError) {
catch (Exception $oError) {
throw ($oError); throw ($oError);
} }
} }
@@ -156,15 +155,12 @@ class Step extends BaseStep {
$c->add( StepPeer::STEP_TYPE_OBJ, $sType ); $c->add( StepPeer::STEP_TYPE_OBJ, $sType );
$c->add( StepPeer::STEP_UID_OBJ, $sUid ); $c->add( StepPeer::STEP_UID_OBJ, $sUid );
$rs = StepPeer::doSelect( $c ); $rs = StepPeer::doSelect( $c );
if (!is_null($rs) && !is_null($rs[0])) if (! is_null( $rs ) && ! is_null( $rs[0] )) {
{
return $rs[0]; return $rs[0];
} } else {
else {
throw (new Exception( "You tried to call to loadByType method without send the Task UID or Type or Object UID !" )); throw (new Exception( "You tried to call to loadByType method without send the Task UID or Type or Object UID !" ));
} }
} } catch (Exception $oError) {
catch (Exception $oError) {
throw ($oError); throw ($oError);
} }
} }
@@ -174,33 +170,28 @@ class Step extends BaseStep {
* @param array $fields * @param array $fields
* @return variant * @return variant
*/ */
function update($fields) public function update ($fields)
{ {
$con = Propel::getConnection( StepPeer::DATABASE_NAME ); $con = Propel::getConnection( StepPeer::DATABASE_NAME );
try try {
{
$con->begin(); $con->begin();
$this->load( $fields['STEP_UID'] ); $this->load( $fields['STEP_UID'] );
$this->fromArray( $fields, BasePeer::TYPE_FIELDNAME ); $this->fromArray( $fields, BasePeer::TYPE_FIELDNAME );
if($this->validate()) if ($this->validate()) {
{
$result = $this->save(); $result = $this->save();
$con->commit(); $con->commit();
return $result; return $result;
} } else {
else
{
$con->rollback(); $con->rollback();
throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." )); throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." ));
} }
} } catch (Exception $e) {
catch(Exception $e)
{
$con->rollback(); $con->rollback();
throw ($e); throw ($e);
} }
} }
function remove($sStepUID)
public function remove ($sStepUID)
{ {
require_once ('classes/model/StepTrigger.php'); require_once ('classes/model/StepTrigger.php');
$oStepTriggers = new StepTrigger(); $oStepTriggers = new StepTrigger();
@@ -230,24 +221,22 @@ class Step extends BaseStep {
$oConnection = Propel::getConnection( StepPeer::DATABASE_NAME ); $oConnection = Propel::getConnection( StepPeer::DATABASE_NAME );
try { try {
$oStep = StepPeer::retrieveByPK( $sStepUID ); $oStep = StepPeer::retrieveByPK( $sStepUID );
if (!is_null($oStep)) if (! is_null( $oStep )) {
{
$oConnection->begin(); $oConnection->begin();
$iResult = $oStep->delete(); $iResult = $oStep->delete();
$oConnection->commit(); $oConnection->commit();
return $iResult; return $iResult;
} } else {
else {
throw (new Exception( 'This row doesn\'t exist!' )); throw (new Exception( 'This row doesn\'t exist!' ));
} }
} } catch (Exception $oError) {
catch (Exception $oError) {
$oConnection->rollback(); $oConnection->rollback();
throw ($oError); throw ($oError);
} }
} }
function getNextPosition($sTaskUID) { public function getNextPosition ($sTaskUID)
{
try { try {
$oCriteria = new Criteria( 'workflow' ); $oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn( '(COUNT(*) + 1) AS POSITION' ); $oCriteria->addSelectColumn( '(COUNT(*) + 1) AS POSITION' );
@@ -257,13 +246,13 @@ class Step extends BaseStep {
$oDataset->next(); $oDataset->next();
$aRow = $oDataset->getRow(); $aRow = $oDataset->getRow();
return (int) $aRow['POSITION']; return (int) $aRow['POSITION'];
} } catch (Exception $oException) {
catch (Exception $oException) {
throw $Exception; throw $Exception;
} }
} }
function reOrder($sStepUID, $iPosition) { public function reOrder ($sStepUID, $iPosition)
{
try { try {
/*$oCriteria1 = new Criteria('workflow'); /*$oCriteria1 = new Criteria('workflow');
$oCriteria1->add(StepPeer::STEP_POSITION, StepPeer::STEP_POSITION); $oCriteria1->add(StepPeer::STEP_POSITION, StepPeer::STEP_POSITION);
@@ -285,13 +274,13 @@ class Step extends BaseStep {
$oStep->save(); $oStep->save();
$oDataset->next(); $oDataset->next();
} }
} } catch (Exception $oException) {
catch (Exception $oException) {
throw $oException; throw $oException;
} }
} }
function up($sStepUID = '', $sTaskUID = '', $iPosition = 0) { public function up ($sStepUID = '', $sTaskUID = '', $iPosition = 0)
{
try { try {
if ($iPosition > 1) { if ($iPosition > 1) {
$oCriteria1 = new Criteria( 'workflow' ); $oCriteria1 = new Criteria( 'workflow' );
@@ -306,13 +295,13 @@ class Step extends BaseStep {
$oCriteria2->add( StepPeer::STEP_UID, $sStepUID ); $oCriteria2->add( StepPeer::STEP_UID, $sStepUID );
BasePeer::doUpdate( $oCriteria2, $oCriteria1, Propel::getConnection( 'workflow' ) ); BasePeer::doUpdate( $oCriteria2, $oCriteria1, Propel::getConnection( 'workflow' ) );
} }
} } catch (Exception $oException) {
catch (Exception $oException) {
throw $oException; throw $oException;
} }
} }
function down($sStepUID = '', $sTaskUID = '', $iPosition = 0) { public function down ($sStepUID = '', $sTaskUID = '', $iPosition = 0)
{
try { try {
$oCriteria = new Criteria( 'workflow' ); $oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn( 'COUNT(*) AS MAX_POSITION' ); $oCriteria->addSelectColumn( 'COUNT(*) AS MAX_POSITION' );
@@ -334,13 +323,13 @@ class Step extends BaseStep {
$oCriteria2->add( StepPeer::STEP_UID, $sStepUID ); $oCriteria2->add( StepPeer::STEP_UID, $sStepUID );
BasePeer::doUpdate( $oCriteria2, $oCriteria1, Propel::getConnection( 'workflow' ) ); BasePeer::doUpdate( $oCriteria2, $oCriteria1, Propel::getConnection( 'workflow' ) );
} }
} } catch (Exception $oException) {
catch (Exception $oException) {
throw $oException; throw $oException;
} }
} }
function removeStep($sType = '', $sObjUID = '') { public function removeStep ($sType = '', $sObjUID = '')
{
try { try {
$oCriteria = new Criteria( 'workflow' ); $oCriteria = new Criteria( 'workflow' );
$oCriteria->add( StepPeer::STEP_TYPE_OBJ, $sType ); $oCriteria->add( StepPeer::STEP_TYPE_OBJ, $sType );
@@ -353,8 +342,7 @@ class Step extends BaseStep {
$this->remove( $aRow['STEP_UID'] ); $this->remove( $aRow['STEP_UID'] );
$oDataset->next(); $oDataset->next();
} }
} } catch (Exception $oException) {
catch (Exception $oException) {
throw $oException; throw $oException;
} }
} }
@@ -365,18 +353,17 @@ class Step extends BaseStep {
* @param string $sUid the uid of the * @param string $sUid the uid of the
*/ */
function StepExists ( $sUid ) { public function StepExists ($sUid)
{
$con = Propel::getConnection( StepPeer::DATABASE_NAME ); $con = Propel::getConnection( StepPeer::DATABASE_NAME );
try { try {
$oObj = StepPeer::retrieveByPk( $sUid ); $oObj = StepPeer::retrieveByPk( $sUid );
if (is_object( $oObj ) && get_class( $oObj ) == 'Step') { if (is_object( $oObj ) && get_class( $oObj ) == 'Step') {
return true; return true;
} } else {
else {
return false; return false;
} }
} } catch (Exception $oError) {
catch (Exception $oError) {
throw ($oError); throw ($oError);
} }
} }
@@ -387,7 +374,8 @@ class Step extends BaseStep {
* @param string $sproUid the uid of the process * @param string $sproUid the uid of the process
* @param string $sObjUID the uid of the dynaform * @param string $sObjUID the uid of the dynaform
*/ */
function loadInfoAssigDynaform($sproUid,$sObjUID){ public function loadInfoAssigDynaform ($sproUid, $sObjUID)
{
require_once ("classes/model/DynaformPeer.php"); require_once ("classes/model/DynaformPeer.php");
G::LoadSystem( 'dynaformhandler' ); G::LoadSystem( 'dynaformhandler' );
@@ -400,7 +388,6 @@ class Step extends BaseStep {
$oDataset->next(); $oDataset->next();
$aRow = $oDataset->getRow(); $aRow = $oDataset->getRow();
if ($aRow['DYN_TYPE'] != 'xmlform') { if ($aRow['DYN_TYPE'] != 'xmlform') {
$oC1 = new Criteria( 'workflow' ); $oC1 = new Criteria( 'workflow' );
@@ -439,15 +426,14 @@ class Step extends BaseStep {
$aRow = $oDataset->getRow(); $aRow = $oDataset->getRow();
return ($aRow); return ($aRow);
} }
die; die();
} }
function getAttribute($node, $attName){ public function getAttribute ($node, $attName)
{
foreach ( $node->attributes as $attribute ) foreach ($node->attributes as $attribute) {
{ if ($attribute->name == $attName) {
if ( $attribute->name == $attName )
{
return $attribute->value; return $attribute->value;
} }
@@ -460,8 +446,8 @@ class Step extends BaseStep {
* @param string $sproUid the uid of the process * @param string $sproUid the uid of the process
* @param string $sdbsUid the uid of the db connection * @param string $sdbsUid the uid of the db connection
*/ */
function loadInfoAssigConnecctionDB($sproUid,$sdbsUid){ public function loadInfoAssigConnecctionDB ($sproUid, $sdbsUid)
{
require_once ("classes/model/DynaformPeer.php"); require_once ("classes/model/DynaformPeer.php");
G::LoadSystem( 'dynaformhandler' ); G::LoadSystem( 'dynaformhandler' );
$swDynaform = true; $swDynaform = true;
@@ -499,6 +485,7 @@ class Step extends BaseStep {
$swDynaform = false; $swDynaform = false;
} //end foreach } //end foreach
} //end if } //end if
$oDataset->next(); $oDataset->next();
} //end while } //end while
@@ -510,7 +497,7 @@ class Step extends BaseStep {
//there is a db connection, you can not delete this connection //there is a db connection, you can not delete this connection
return false; return false;
} }
die; die();
} }
/** /**
@@ -518,7 +505,7 @@ class Step extends BaseStep {
* *
* @author Erik A. O. <erik@colosa.com> * @author Erik A. O. <erik@colosa.com>
*/ */
function getAllCaseSteps($PRO_UID, $TAS_UID, $APP_UID) public function getAllCaseSteps ($PRO_UID, $TAS_UID, $APP_UID)
{ {
$c = new Criteria(); $c = new Criteria();
@@ -537,7 +524,8 @@ class Step extends BaseStep {
* @param string $sdbsUid the uid of the db connection * @param string $sdbsUid the uid of the db connection
* @author krlos <carlos@colosa.com> * @author krlos <carlos@colosa.com>
*/ */
function lookingforUidGrids($sproUid,$sObjUID) { public function lookingforUidGrids ($sproUid, $sObjUID)
{
require_once ("classes/model/DynaformPeer.php"); require_once ("classes/model/DynaformPeer.php");
G::LoadSystem( 'dynaformhandler' ); G::LoadSystem( 'dynaformhandler' );
@@ -551,7 +539,6 @@ class Step extends BaseStep {
$aRow = $oDataset->getRow(); $aRow = $oDataset->getRow();
if ($aRow['DYN_TYPE'] == 'xmlform') { if ($aRow['DYN_TYPE'] == 'xmlform') {
$oC1 = new Criteria( 'workflow' ); $oC1 = new Criteria( 'workflow' );
$oC1->add( DynaformPeer::PRO_UID, $sproUid ); $oC1->add( DynaformPeer::PRO_UID, $sproUid );
$oC1->add( DynaformPeer::DYN_TYPE, "xmlform" ); $oC1->add( DynaformPeer::DYN_TYPE, "xmlform" );
@@ -581,21 +568,6 @@ class Step extends BaseStep {
} }
} }
}
} // Step // Step