diff --git a/gulliver/js/ext/wz_jsgraphics.js b/gulliver/js/ext/wz_jsgraphics.js index 2d55388d6..cb9fbc2a4 100755 --- a/gulliver/js/ext/wz_jsgraphics.js +++ b/gulliver/js/ext/wz_jsgraphics.js @@ -866,7 +866,6 @@ Allows to specify the size of the text rectangle and to align the text both horizontally (e.g. right) and vertically within that rectangle */ this.drawStringRect = function(txt, x, y, width,height, halign) { - this.ftSz = '11px'; this.htm += '
process; + $coordinateMaximumY = 0; + $coordinateMaximumX = 0; + $lanes = $oData->lanes; + foreach ($lanes as $keyLane => $valLane ) { + if($valLane['SWI_TYPE']=="TEXT"){ + $textLane = $valLane['SWI_TEXT']; + $longText = strlen($textLane); + $height = 0; + $width = 0; + if($longText < 40){ + $height = 20; + $width = ($longText*10)+ 10; + } + if($longText > 40){ + $numberRows = $longText/40; + $height = $numberRows * 20; + $width = 250; + } + $coordinateX = $valLane['SWI_X'] + $width; + $coordinateY = $valLane['SWI_Y'] + $height ; + if($coordinateX > $coordinateMaximumX){ + $coordinateMaximumX = $coordinateX; + } + if($coordinateY > $coordinateMaximumY){ + $coordinateMaximumY = $coordinateY; + } + } + } + foreach ($oData->tasks as $keyLane => $val ) { + $coordinateX = $val['TAS_POSX']+ 160; + $coordinateY = $val['TAS_POSY']+ 38; + if($coordinateX > $coordinateMaximumX){ + $coordinateMaximumX = $coordinateX; + } + if($coordinateY > $coordinateMaximumY){ + $coordinateMaximumY = $coordinateY; + } + } + $data = $this->createPool($process,$coordinateMaximumX + 60,$coordinateMaximumY +60); + fwrite ($xml, ''); + fwrite ($xml, $data); + $artifacts = ''; + $artifacts .= $this->createArtifacts($lanes,'0'); + $dataProcess =' + '; + $dataProcess.= ' + + + + '; + $activitySets = ''; + $subProcess = $oData->subProcess; + $subProcesses = $this-> createSubProcessesXpdl($subProcess,$oData->tasks); + $activitySets.= $subProcesses['ACTIVITIES']; + $activitySets.= ''; + $artifacts .= $subProcesses['ARTIFACTS']; + $artifacts .=' + '; + fwrite ($xml,$artifacts); + fwrite ($xml,$dataProcess); + fwrite ($xml,$activitySets); + // Here are generated activities of a file. XPDL + // for this use the process tasks + $tasks = $oData->tasks; + $events = $oData->event; + $scheduler = $oData->caseScheduler; + $dataTasks = $this-> createActivitiesXpdl($tasks,$events,$scheduler); + fwrite ($xml,$dataTasks['ACTIVITIES']); + $taskHidden = $dataTasks['TASK_HIDDEN']; + $routes = $oData->routes; + $dataRoutes = $this-> createTransitionsXpdl($routes,$tasks,$taskHidden); + fwrite ($xml,$dataRoutes['ACTIVITIES']); + $data = ' + '; + fwrite ($xml, $data); + fwrite ($xml, $dataTasks['TRANSITION']); + fwrite ($xml, $dataRoutes['TRANSITION']); + $data = ' + + + + + +'; + fwrite ($xml, $data); + fclose ($xml); + $filenameLink = 'processes_DownloadFileXpdl?p=' . $proTitle . '&r=' . rand(100,1000); + $result['FILENAMEXPDL'] = $proTitle.'.xpdl'; + $result['FILENAME_LINKXPDL']= $filenameLink; + return $result; + } + + /** + * This function create the pool from the process + * @param array $process + * @param string $coordinateMaximumX + * @param string $coordinateMaximumY + * @return string + */ + function createPool ($process,$coordinateMaximumX,$coordinateMaximumY) + { + $data = ''; + $data .= ' + + + 2.1 + Process Maker + '.$process['PRO_CREATE_DATE'].' + '.$process['PRO_DESCRIPTION'].' + + + + + + CO + + + + + + + + + + + + + + + + + + '; + return $data; + } + + /** + * This function generated the Artifacts of a file. XPDL + * @param array $lanes + * @param string $id + * @return string + */ + function createArtifacts($lanes,$id) + { + $artifacts = ''; + $idTask = ''; + foreach ($lanes as $keyLane => $valLane ) { + if($valLane['SWI_TYPE']=="TEXT"){ + $idLane = $valLane['SWI_UID']; + $textLane = $valLane['SWI_TEXT']; + $coordinateX = $valLane['SWI_X']; + $coordinateY = $valLane['SWI_Y']; + $longText = strlen($textLane); + if($longText < 40){ + $height = 20; + $width = ($longText*10)+ 10; + } + if($longText > 40){ + $numberRows = $longText/40; + $height = $numberRows * 20; + $width = 250; + } + if($id != 0){ + $idTask = ' ActivitySetId="'.$id.'"'; + } + $artifacts .=' + + + + + + + + '; + } + } + return $artifacts; + } + + /** + * This function creates SubProcesses + * @param array $tasks + * @param array $subProcess + * @return array + */ + function createSubProcessesXpdl($subProcess,$tasks) + { + $activitySets = ''; + $dataCreated = ''; + $artifacts = ''; + foreach ($subProcess as $key => $row) { + if($row['SP_UID'] != ''){ + $idTask = $row['TAS_PARENT']; + foreach ($tasks as $id => $value) { + if($value['TAS_UID'] == $idTask){ + $nameTask = htmlentities($value['TAS_TITLE']); + } + } + $activitySets.=' + '; + if($row['PRO_UID'] != ''){ + $dataSubProcess= $this->serializeProcess($row['PRO_UID']); + $data = unserialize ($dataSubProcess); + $tasks = $data->tasks; + $subProcessData= $data->subProcess; + $subProcessTask= $data->tasks; + $lanes = $data->lanes; + $events = $data->event; + $scheduler = $data->caseScheduler; + $artifacts = $this->createArtifacts($lanes,$idTask); + $dataCreated = $this->createSubProcessesXpdl($subProcessData,$subProcessTask); + $dataTasks = $this->createActivitiesXpdl($tasks,$events,$scheduler); + $activitySets .=$dataTasks['ACTIVITIES']; + $taskHidden = $dataTasks['TASK_HIDDEN']; + $routes = $data->routes; + $dataRoutes = $this->createTransitionsXpdl($routes,$tasks,$taskHidden); + $activitySets .=$dataRoutes['ACTIVITIES']; + $activitySets .= ' + '; + $activitySets .=$dataTasks['TRANSITION']; + $activitySets .=$dataRoutes['TRANSITION']; + $activitySets .= ' + '; + } + else{ + $data =' + + '; + } + $activitySets.=''; + $activitySets.=$dataCreated; + } + } + $fields['ACTIVITIES']= $activitySets; + $fields['ARTIFACTS'] = $artifacts; + return $fields; + } + + /** + * This function creates activities from the tasks + * @param array $tasks + * @return array + */ + function createActivitiesXpdl($tasks,$events,$scheduler) + { + $dataTasks = ' + '; + $transitions =' + '; + $start = 0; + $implementation = ''; + $taskHidden = array(); + $description = ''; + foreach ($tasks as $key => $val ) { + $idTask = $val['TAS_UID']; + $nameTask = $val['TAS_TITLE']; + $coordinateX = $val['TAS_POSX']; + $coordinateY = $val['TAS_POSY']; + if($val['TAS_TYPE']== 'NORMAL' or $val['TAS_TYPE']== 'SUBPROCESS'){ + if($val['TAS_TYPE']== 'NORMAL'){ + $implementation = ' + + + '; + } + if($val['TAS_TYPE']== 'SUBPROCESS'){ + $implementation = ' + '; + } + if(isset($val['TAS_DESCRIPTION'])){ + $description = $val['TAS_DESCRIPTION']; + } + else{ + $description = ''; + } + $fillColor = $val['TAS_COLOR']; + if($val['TAS_START']=="TRUE"){ + $start = 1; + } + if($start==1){ + $start=0; + $positionX=$coordinateX+65; + $positionY=$coordinateY-45; + $dataTasks .=' + + '.$description.' + + + + + + + + + + + + '; + $transitions.=' + + + + + + + + + '; + } + $dataTasks .=' + + '.$description.'' + .$implementation.' + + + + + + + + + '; + } + else{ + if($val['TAS_TYPE']== 'HIDDEN'){ + $taskHidden[] = $tasks[$key]; + } + } + } + + $aux = $events; + foreach ($events as $key => $row) { + $aux[$key]= $row['TAS_UID']; + } + if(sizeof($events)> 0){ + array_multisort($aux,SORT_ASC,$events); + unset($aux); + } + $findTask = 0; + $idTasks = array(); + $arrayTasks = array(); + $port = 5; + foreach($events as $key => $val){ + if($val['EVN_ACTION'] == 'SEND_MESSAGE' and $val['EVN_RELATED_TO'] == 'SINGLE'){ + $idEvent = $val['EVN_UID']; + $idTask = $val['TAS_UID']; + foreach($tasks as $id => $value){ + if($value['TAS_UID'] == $idTask){ + $coordinateX = $value['TAS_POSX'] + 19; + $coordinateY = $value['TAS_POSY'] + 38; + $coordinateXM = $coordinateX + 96; + $coordinateYM = $coordinateY + 65; + } + } + foreach($arrayTasks as $id => $value){ + if($idTask == $value['ID']){ + $coordinateX = $value['X'] + 30; + $coordinateY = $value['Y']; + $coordinateXM = $value['XM']+ 30; + $coordinateYM = $value['YM']; + if($coordinateY < 30){ + $coordinateX = $value['FIRSTX'] + 30; + $coordinateY = $value['FIRSTY']; + } + $arrayTasks[$id]['X'] = $coordinateX; + $arrayTasks[$id]['Y'] = $coordinateY; + $arrayTasks[$id]['PORT'] = $port + 1; + $findTask = 1; + $port = $arrayTasks[$id]['PORT']; + } + } + + $description = $val['EVN_DESCRIPTION']; + $arrayTo = $val['EVN_ACTION_PARAMETERS']; + foreach($arrayTo as $idTo => $valueTo){ + $to = $valueTo; + } + $to = explode('|',$to); + $to = $to[0]; + $oConfiguration = new Configuration(); + $emailArray = $oConfiguration->load('Emails','','','',''); + $arrayFrom = unserialize($emailArray['CFG_VALUE']); + $from = $arrayFrom['MESS_ACCOUNT']; + if($to == 'ext'){ + $oUser = new Users(); + $aUser = $oUser->load($_SESSION['USER_LOGGED']); + $to = $aUser['USR_USERNAME']; + } + $dataTasks .=' + + + + + + TimeCycle + + + + + + + + + + + false + + + '.$description.' + + + + + + + + + '.$description.' + + + + + + + false + '; + $transitions.=' + + + + + + + + + '; + if($findTask == 0){ + $idTasks['ID'] = $idTask; + $idTasks['X'] = $coordinateX; + $idTasks['Y'] = $coordinateY; + $idTasks['FIRSTX'] = $coordinateX; + $idTasks['FIRSTY'] = $coordinateY; + $idTasks['XM'] = $coordinateXM; + $idTasks['YM'] = $coordinateYM; + $idTasks['PORT'] = $port; + $arrayTasks[] = $idTasks; + } + /* $dataTasks .=' + + '.$description.' + + + + + + + + + '.$description.' + + + + + + + false + '; + $transitions.=' + + + + + + + + + ';*/ + } + } + $idTasks = array(); + $arrayTasks = array(); + $findTask = 0; + foreach($scheduler as $key => $val){ + if($val['SCH_OPTION'] == 4){ + $idSch = $val['SCH_UID']; + $name = $val['SCH_NAME']; + $idTask = $val['TAS_UID']; + foreach($tasks as $id => $value){ + if($value['TAS_UID'] == $idTask){ + $coordinateX = $value['TAS_POSX'] - 60; + $coordinateY = $value['TAS_POSY'] + 5; + } + } + foreach($arrayTasks as $id => $value){ + if($idTask == $value['ID']){ + $coordinateX = $value['X']; + $coordinateY = $value['Y'] - 40; + if($coordinateY < 30){ + $coordinateX = $value['FIRSTX'] + 50; + $coordinateY = $value['FIRSTY'] - 90; + } + $arrayTasks[$id]['X'] = $coordinateX; + $arrayTasks[$id]['Y'] = $coordinateY; + $findTask = 1; + } + } + $time = $val['SCH_TIME_NEXT_RUN']; + $time = explode(' ',$time); + $time = $time[0]; + $time = str_replace('-','/',$time); + $dataTasks .=' + + + + + + TimeCycle + + + + + + + + + + + false + '; + $transitions.=' + + + + + + + + + '; + if($findTask == 0){ + $idTasks['ID'] = $idTask; + $idTasks['X'] = $coordinateX; + $idTasks['Y'] = $coordinateY; + $idTasks['FIRSTX'] = $coordinateX; + $idTasks['FIRSTY'] = $coordinateY; + $arrayTasks[] = $idTasks; + } + } + if($val['SCH_OPTION'] == 1){ + $idSch = $val['SCH_UID']; + $name = $val['SCH_NAME']; + $idTask = $val['TAS_UID']; + foreach($tasks as $id => $value){ + if($value['TAS_UID'] == $idTask){ + $coordinateX = $value['TAS_POSX'] - 60; + $coordinateY = $value['TAS_POSY'] + 5; + } + } + foreach($arrayTasks as $id => $value){ + if($idTask == $value['ID']){ + $coordinateX = $value['X']; + $coordinateY = $value['Y'] - 40; + if($coordinateY < 30){ + $coordinateX = $value['FIRSTX'] + 50; + $coordinateY = $value['FIRSTY'] - 90; + } + $arrayTasks[$id]['X'] = $coordinateX; + $arrayTasks[$id]['Y'] = $coordinateY; + $findTask = 1; + } + } + $dataTasks .=' + + + + + + TimeCycle + + + + + + + + + + + false + '; + $transitions.=' + + + + + + + + + '; + if($findTask == 0){ + $idTasks['ID'] = $idTask; + $idTasks['X'] = $coordinateX; + $idTasks['Y'] = $coordinateY; + $idTasks['FIRSTX'] = $coordinateX; + $idTasks['FIRSTY'] = $coordinateY; + $arrayTasks[] = $idTasks; + } + } + } + $data = array(); + $data['ACTIVITIES'] = $dataTasks; + $data['TRANSITION'] = $transitions; + $data['TASK_HIDDEN']= $taskHidden; + return $data; + } + + /** + * This function creates transitions + * @param array $routes + * @param array $tasks + * @return array + */ + function createTransitionsXpdl($routes,$tasks,$taskHidden) + { + $cont = 0; + $dataRoutes = ''; + $endEvent = 1; + $taskParallel = ''; + $routeParallel = ''; + $taskSecJoin = ''; + $routeSecJoin = ''; + $taskEvaluate = ''; + $routeEvaluate = ''; + $taskParallelEv = ''; + $routeParallelEv = ''; + $taskSelect = ''; + $routeSelect = ''; + $routeEnd = ''; + $arraySecJoin = array(); + $position = 0; + $fillColor = ''; + $transitions = ''; + $condition = ''; + $nextTask = ''; + $findFrom = 0; + $findTo = 0; + $routesTasks = $routes; + foreach ($routes as $key => $row) { + if($row['ROU_TYPE'] == 'SEC-JOIN'){ + $arraySecJoin[$position] = array(); + $arraySecJoin[$position] = $row; + $position = $position + 1; + unset($routes[$key]); + } + } + $aux = $arraySecJoin ; + foreach ($arraySecJoin as $key => $row) { + $aux[$key]= $row['ROU_NEXT_TASK']; + } + if(sizeof($arraySecJoin)> 0){ + array_multisort($aux,SORT_ASC,$arraySecJoin); + unset($aux); + } + foreach ($routes as $key => $row) { + $uid[$key] = $row['TAS_UID']; + $case[$key] = $row['ROU_CASE']; + } + if(sizeof($routes)> 0){ + array_multisort($uid, SORT_ASC, $case, SORT_ASC, $routes); + } + $routes = array_merge($routes,$arraySecJoin); + $routesTasks = $routes; + foreach ($routes as $key => $val ) { + $end = 0; + $idRoute = $val['ROU_UID']; + $idTask = $val['TAS_UID']; + $nextTask = $val['ROU_NEXT_TASK']; + $condition = htmlentities($val['ROU_CONDITION']); + if($nextTask == "-1"){ + $end = 1; + } + $typeRoute = $val['ROU_TYPE']; + $route = ''; + if ($typeRoute != "SEQUENTIAL" ){ + switch($typeRoute){ + case 'PARALLEL': + $coordinateX = 0; + $coordinateY = 0; + foreach ($tasks as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$idTask){ + $coordinateX=$idVal['TAS_POSX']; + $coordinateY=$idVal['TAS_POSY']; + } + } + foreach ($taskHidden as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$idTask){ + $coordinateX = $idVal['TAS_POSX']; + $coordinateY = $idVal['TAS_POSY']; + $idRoute = $idTask; + } + } + $positionX = $coordinateX + 60; + $positionY = $coordinateY + 40; + if($idTask != $taskParallel){ + $taskParallel = $idTask; + $routeParallel = $idRoute; + $dataRoutes .=' + + + + + + + + + + + false + '; + if($taskParallel != $routeParallel ){ + $transitions.=' + + + + + + + + + '; + } + $transitions.=' + + + + + + + + + '; + } + else{ + $transitions.=' + + + + + + + + + '; + } + break; + case 'SEC-JOIN': + $coordinateX = 0; + $coordinateY = 0; + foreach ($tasks as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$nextTask){ + $coordinateX=$idVal['TAS_POSX']; + $coordinateY=$idVal['TAS_POSY']; + } + } + foreach ($taskHidden as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$idTask){ + $coordinateX = $idVal['TAS_POSX']; + $coordinateY = $idVal['TAS_POSY']; + $idRoute = $idTask; + } + } + $positionX = $coordinateX + 60; + $positionY = $coordinateY - 45; + if($nextTask != $taskSecJoin){ + $taskSecJoin = $nextTask; + $routeSecJoin = $idRoute; + $dataRoutes .=' + + + + + + + + + + + false + '; + if($routeSecJoin != $taskSecJoin ){ + $transitions.=' + + + + + + + + + '; + } + $transitions.=' + + + + + + + + + '; + } + else{ + $transitions.=' + + + + + + + + + '; + } + break; + case 'EVALUATE': + $coordinateX=0; + $coordinateY=0; + foreach ($tasks as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$idTask){ + $coordinateX=$idVal['TAS_POSX']; + $coordinateY=$idVal['TAS_POSY']; + } + } + foreach ($taskHidden as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$idTask){ + $coordinateX = $idVal['TAS_POSX']; + $coordinateY = $idVal['TAS_POSY']; + $idRoute = $idTask; + } + } + $positionX=$coordinateX+60; + $positionY=$coordinateY+40; + if($idTask != $taskEvaluate){ + $taskEvaluate = $idTask; + $routeEvaluate = $idRoute; + if($nextTask != "-1"){ + $dataRoutes .=' + + + + + + + + + + + false + '; + if($taskEvaluate != $routeEvaluate ){ + $transitions.=' + + + + + + + + + '; + } + $transitions.=' + + + '.$condition.' + + + + + + + + '; + } + } + else{ + if($nextTask !="-1"){ + $transitions.=' + + + '.$condition.' + + + + + + + + '; + } + else{ + $routeEnd = $routeEvaluate; + } + } + break; + case 'PARALLEL-BY-EVALUATION': + $coordinateX=0; + $coordinateY=0; + foreach ($tasks as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$idTask){ + $coordinateX=$idVal['TAS_POSX']; + $coordinateY=$idVal['TAS_POSY']; + } + } + foreach ($taskHidden as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$idTask){ + $coordinateX = $idVal['TAS_POSX']; + $coordinateY = $idVal['TAS_POSY']; + $idRoute = $idTask; + } + } + $positionX=$coordinateX+60; + $positionY=$coordinateY+40; + if($idTask != $taskParallelEv){ + $taskParallelEv = $idTask; + $routeParallelEv = $idRoute; + $dataRoutes .=' + + + + + + + + + + + false + '; + if($taskParallelEv != $routeParallelEv ){ + $transitions.=' + + + + + + + + + '; + } + $transitions.=' + + + '.$condition.' + + + + + + + + '; + } + else{ + $transitions.=' + + + '.$condition.' + + + + + + + + '; + } + break; + case 'SELECT': + $coordinateX=0; + $coordinateY=0; + foreach ($tasks as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$idTask){ + $coordinateX=$idVal['TAS_POSX']; + $coordinateY=$idVal['TAS_POSY']; + } + } + foreach ($taskHidden as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$idTask){ + $coordinateX = $idVal['TAS_POSX']; + $coordinateY = $idVal['TAS_POSY']; + $idRoute = $idTask; + } + } + $positionX=$coordinateX+60; + $positionY=$coordinateY+40; + if($idTask != $taskSelect){ + $taskSelect = $idTask; + $routeSelect = $idRoute; + $dataRoutes .=' + + + + + + + + + + + false + '; + if($taskSelect != $routeSelect ){ + $transitions.=' + + + + + + + + + '; + } + $transitions.=' + + + '.$condition.' + + + + + + + + '; + } + else{ + if($nextTask !="-1"){ + $transitions.=' + + + '.$condition.' + + + + + + + + '; + } + else{ + $routeEnd = $routeSelect; + } + } + break; + case 'DISCRIMINATOR': + $coordinateX = 0; + $coordinateY = 0; + $optional = $val['ROU_OPTIONAL']; + foreach ($tasks as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$nextTask){ + $coordinateX=$idVal['TAS_POSX']; + $coordinateY=$idVal['TAS_POSY']; + } + } + foreach ($taskHidden as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$idTask){ + $coordinateX = $idVal['TAS_POSX']; + $coordinateY = $idVal['TAS_POSY']; + $idRoute = $idTask; + } + } + $positionX=$coordinateX+60; + $positionY=$coordinateY-45; + if($nextTask != $taskSecJoin){ + $taskDiscriminator = $nextTask; + $routeDiscriminator = $idRoute; + $dataRoutes .=' + + + + + + + + + + + + + + false + '; + if($routeDiscriminator != $taskDiscriminator ){ + $transitions.=' + + + + + + + + + '; + } + $transitions.=' + + + + + + + + '; + } + else{ + $transitions.=' + + + + + + + + + '; + } + break; + } + } + if($end==1){ + if($typeRoute == "SEQUENTIAL"){ + $coordinateX=0; + $coordinateY=0; + foreach ($tasks as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$idTask){ + $coordinateX=$idVal['TAS_POSX']; + $coordinateY=$idVal['TAS_POSY']; + } + } + $positionX=$coordinateX+65; + $positionY=$coordinateY+40; + $transitions.=' + + + + + + + + + '; + } + else{ + $coordinateX=0; + $coordinateY=0; + foreach ($tasks as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$idTask){ + $coordinateX=$idVal['TAS_POSX']; + $coordinateY=$idVal['TAS_POSY']; + } + } + $positionX = $coordinateX + 120; + $positionY = $coordinateY + 40; + $idTask = $routeEnd; + $transitions.=' + + + + + + + + + '; + } + $dataRoutes .=' + + + + + + + + + + + + + false + '; + $end = 0; + $endEvent = 0; + } + else{ + if ($typeRoute == "SEQUENTIAL"){ + $transitions.=' + + + + + + + + + '; + } + foreach ($tasks as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$idTask){ + $coordinateX=$idVal['TAS_POSX']+190; + $coordinateY=$idVal['TAS_POSY']+5; + if(isset($idVal['TAS_DEF_MESSAGE'])){ + if($idVal['TAS_DEF_MESSAGE'] != '' and $idVal['TAS_DEF_MESSAGE'] != Null){ + $idEvent = G::generateUniqueID(); + $example = new Derivation(); + $fieldUserTo = $example->getAllUsersFromAnyTask($nextTask); + $fieldUserTo = $example->getUsersFullNameFromArray($fieldUserTo); + $fieldUserFrom = $example->getAllUsersFromAnyTask($idTask); + $fieldUserFrom = $example->getUsersFullNameFromArray($fieldUserFrom); + /*$oUser = new Users(); + $aUser = $oUser->load($_SESSION['USER_LOGGED']); + $from = $aUser['USR_USERNAME'];*/ + $description = ''; + $userFrom = ''; + $userTo = ''; + if(isset($fieldUserFrom[0]['USR_USERNAME'])){ + $userFrom = $fieldUserFrom[0]['USR_USERNAME']; + } + if(isset($fieldUserTo[0]['USR_USERNAME'])){ + $userTo = $fieldUserTo[0]['USR_USERNAME']; + } + $dataRoutes .=' + + '.$description.' + + + + + + + + + '.$description.' + + + + + + + false + '; + $transitions.=' + + + + + + + + + '; + } + } + } + } + } + } + $data = array(); + $data['ACTIVITIES'] = $dataRoutes; + $data['TRANSITION'] = $transitions; + return $data; + } + + /** + * Get the process Data from a filename .XPDL + * @param array $pmFilename + * @return void + */ + function getProcessDataXpdl ( $pmFilename ) + { + if (! file_exists($pmFilename) ) + throw ( new Exception ( 'Unable to read uploaded file, please check permissions. ')); + if (! filesize($pmFilename) >= 9 ) + throw ( new Exception ( 'Uploaded file is corrupted, please check the file before continue. ')); + clearstatcache(); + $idProcess = 0; + $nameProcess = ''; + $sw = 0; + $file = new DOMDocument(); + $file->load($pmFilename); + $root = $file->documentElement; + $node = $root->firstChild; + $numberTasks = 0; + $numberLanes = 0; + $endArray = array(); + $posEnd = 0; + $startArray = array(); + $posStart = 0; + $isEnd = 0; + $isStart = 0; + $posRoutes = 0; + $sequencial = 0; + $posT = 0; + $output = ''; + $arrayRoutes = array(); + $arrayLanes = array(); + $routeTransitions = array (); + $start = 0; + $end = 0; + $arrayScheduler = array(); + $arrayMessages = array(); + while ($node) { + if ($node->nodeType == XML_ELEMENT_NODE) { + $name = $node->nodeName; + $content = $node->firstChild; + if($content != array()){ + $output = $content->nodeValue; + } + if(strpos($name,'Pools')!== false){ + while ($content) { + if ($content->nodeType == XML_ELEMENT_NODE) { + $nameChild = $content->nodeName; + $contentChild = $content->firstChild; + if(strpos($nameChild,'Pool')!== false){ + $namePool = $content->getAttribute('Name'); + $idPool = str_replace('-','',$content->getAttribute('Process')); + $process['ID'] = $idPool; + $process['NAME']= $namePool; + $process['DESCRIPTION'] = ''; + $oData->process = $this->createProcess($process); + } + } + $content = $content->nextSibling; + } + } + if(strpos($name,'Artifacts')!== false){ + while ($content) { + if ($content->nodeType == XML_ELEMENT_NODE) { + $nameChild = $content->nodeName; + $contentChild = $content->firstChild; + $idActivity = ''; + if(strpos($nameChild,'Artifact')!== false){ + $artifactType = $content->getAttribute('ArtifactType'); + if($artifactType == 'Annotation'){ + $textAnnotation = $content->getAttribute('TextAnnotation'); + $idAnnotation = str_replace('-','',$content->getAttribute('Id')); + $idActivity = str_replace('-','',$content->getAttribute('ActivitySetId')); + $lanes = $this->findCoordinates($contentChild); + $lanes['TEXT'] = $textAnnotation; + $lanes['ID_PROCESS'] = $idPool; + $lanes['ID_LANE'] = $idAnnotation; + if($idActivity != ''){ + $lanes['ID_PROCESS'] = $idActivity; + } + $arrayLanes[$numberLanes] = $this->createLanes($lanes); + $numberLanes = $numberLanes +1; + } + } + } + $content = $content->nextSibling; + } + } + if(strpos($name,'WorkflowProcesses')!== false){ + while ($content) { + if ($content->nodeType == XML_ELEMENT_NODE) { + $nameChild = $content->nodeName; + $contentChild = $content->firstChild; + if(strpos($nameChild,'WorkflowProcess')!== false){ + $nameWorkflow = $content->getAttribute('Name'); + $idProcess = $content->getAttribute('Id'); + $idProcess = trim(str_replace('-','',$idProcess)); + $subProcesses = array(); + if($nameWorkflow == $namePool and $idProcess == $idPool){ + $idWorkflow = $idProcess; + while ($contentChild) { + if ($contentChild->nodeType == XML_ELEMENT_NODE){ + $nameNode = $contentChild->nodeName; + $contentNode = $contentChild->firstChild; + if(strpos($nameNode,'ActivitySets')!== false){ + $activitySet = $this->createSubProcesses($contentNode,$arrayLanes); + $subProcesses = $activitySet['SUB_PROCESS']; + $arraySubProcesses = $activitySet['SUBPROCESSES']; + } + if(strpos($nameNode,'Activities')!== false){ + $activities = $this->createActivities($contentNode,$idProcess,$subProcesses); + $oData->tasks = $activities['TASKS']; + $startArray = $activities['START']; + $endArray = $activities['END']; + $arrayRoutes = $activities['ROUTES']; + $arrayScheduler = $activities['SCHEDULER']; + $arrayMessages = $activities['MESSAGES']; + } + + if(strpos($nameNode,'Transitions')!== false){ + $transitions = $this->createTransitions($contentNode,$oData->tasks,$arrayRoutes,$endArray,$startArray,$idProcess,$arrayScheduler,$arrayMessages); + $oData->routes = $transitions['ROUTES']; + $oData->tasks = $transitions['TASKS']; + $routeTransitions = $transitions['TRANSITIONS']; + $numberRoutes = $transitions['NUMBER']; + $taskHidden = $transitions['TASKHIDDEN']; + $arrayScheduler = $transitions['SCHEDULER']; + $arrayMessages = $transitions['MESSAGES']; + } + } + $contentChild = $contentChild->nextSibling; + } + } + } + } + $content = $content->nextSibling; + } + } + } + $node = $node->nextSibling; + } + $oData->lanes = array(); + $numberLanes = 0; + foreach($arrayLanes as $key => $value) { + if($value['PRO_UID'] == $idProcess){ + $oData->lanes[$numberLanes] = $value; + $numberLanes = $numberLanes + 1; + } + } + $oData->inputs = array(); + $oData->outputs = array(); + $oData->dynaforms = array(); + $oData->steps = array(); + $oData->taskusers = array(); + $oData->groupwfs = $this->getGroupwfRows( $oData->taskusers ); + $oData->steptriggers = array(); + $oData->dbconnections = array(); + $oData->reportTables = array(); + $oData->reportTablesVars = array(); + $oData->stepSupervisor = array(); + $oData->objectPermissions = array(); + $oData->subProcess = array(); + $numberSubProcess = 0; + $arraySubProcess = $subProcesses; + $numberSubProcess = sizeof($arraySubProcesses); + $numberCount = 0; + foreach($subProcesses as $key => $value) { + foreach($oData->tasks as $keyTask => $valueTask) { + if($value['ID_PROCESS'] == $valueTask['TAS_UID']){ + $fields['TASK_PARENT'] = $valueTask['TAS_UID']; + $idSubProcess = $valueTask['TAS_UID']; + $findTask = 0; + $newTasks = $this->getTaskRows($idSubProcess); + foreach ($newTasks as $keyLane => $val ) { + if($val['TAS_START']==='TRUE' and $findTask == 0){ + $findTask = 1; + $value['TASK_START']=$val['TAS_UID']; + } + } + $fields['PROCESS_PARENT']= $idProcess; + $fields['TAS_UID']= $value['TASK_START']; + $oData->subProcess[$numberSubProcess]= $this->createSubProcess($fields,$arraySubProcess); + $numberSubProcess = $numberSubProcess + 1; + } + } + } + $oData->caseTracker = array(); + $oData->caseTrackerObject = array(); + $oData->stage = array(); + $oData->fieldCondition = array(); + $oData->event = $this->createEventMessages($arrayMessages,$idProcess); + $oData->triggers = array(); + $oData->caseScheduler = $this->createScheduler($arrayScheduler,$idProcess); + $oData->dynaformFiles = array(); + $numberTransitions=sizeof($routeTransitions); + if($numberTransitions > 0){ + $routesArray = $this->createGateways($routeTransitions,$endArray,$oData->routes,$numberRoutes,$idProcess,$taskHidden); + $oData->routes = $routesArray; + } + + //print_r($oData);die; + //print_r($arrayMessages);die; + return $oData; + } + + /** + * This function sort a array + * @param array $fields + * @return array sorted + */ + function sortArray($fields) + { + $aux = $fields ; + foreach ($fields as $key => $row) { + $aux[$key] = $row['FROM']; + } + array_multisort($aux,SORT_ASC,$fields); + return $fields; + } + + /** + * This functions verify the routes and removes the routes that are repeated + * @param array $routeTransitions + * @param array $endArray + * @return array + */ + function verifyRoutes ($routeTransitions,$endArray,$taskHidden) + { $findFirst = 0; + $firstRoute = ''; + $taskTo = ''; + $taskFrom = ''; + $routeArrayT = $routeTransitions; + $findHidden = 0; + foreach ($routeTransitions as $valRoute => $value){ + $findHidden = 0; + if($value['ROUTE'] == $firstRoute){ + if($value['TOORFROM'] == 'TO'){ + $taskFrom = $value['FROM']; + } + if($value['TOORFROM'] == 'FROM'){ + $taskTo = $value['TO']; + } + if($taskFrom != ''){ + foreach ($routeArrayT as $valRoutes => $values){ + $isEventEnd = 0; + foreach ($endArray as $endBase => $valueEnd){ + if($valueEnd==$values['TO']){ + $isEventEnd = 1; + } + } + if($values['ROUTE'] == $value['ROUTE'] and $values['TO'] != $value['ROUTE'] and $isEventEnd == 0 and $findHidden == 0){ + $taskFrom = $values['TO']; + } + else{ + if($values['ROUTE'] == $value['ROUTE'] and $values['TO'] == $value['ROUTE'] and $isEventEnd == 0){ + foreach ($taskHidden as $idHidden => $valueHidden){ + if($valueHidden['ID_TASK'] == $values['TO']){ + $taskFrom = $valueHidden['ID_TASK']; + $findHidden= 1; + } + } + } + } + } + $routeTransitions[$valRoute]['TO']=$taskFrom; + $taskFrom = ''; + } + if($taskTo != ''){ + foreach ($routeArrayT as $valRoutes => $values){ + if($values['ROUTE'] == $value['ROUTE'] and $values['FROM'] != $value['ROUTE'] and $findHidden == 0 ){ + $taskTo = $values['FROM']; + } + } + $routeTransitions[$valRoute]['FROM']=$taskTo; + $taskTo = ''; + } + } + else{ + $firstRoute = $value['ROUTE']; + $taskToE = ''; + $taskFromE = ''; + if($value['TOORFROM'] == 'TO'){ + $taskFromE = $value['FROM']; + } + if($value['TOORFROM'] == 'FROM'){ + $taskToE = $value['TO']; + } + if($taskFromE != ''){ + $findHidden = 0; + foreach ($routeArrayT as $valRoutes => $values){ + $isEventEnd = 0; + foreach ($endArray as $endBase => $valueEnd){ + if($valueEnd==$values['TO']){ + $isEventEnd = 1; + } + } + if($values['ROUTE'] == $value['ROUTE'] and $values['TO'] != $value['ROUTE'] and $isEventEnd == 0 and $findHidden == 0){ + $taskFromE = $values['TO']; + } + else{ + if($values['ROUTE'] == $value['ROUTE'] and $values['TO'] == $value['ROUTE'] and $isEventEnd == 0){ + foreach ($taskHidden as $idHidden => $valueHidden){ + if($valueHidden['ID_TASK'] == $values['TO']){ + $taskFromE = $valueHidden['ID_TASK']; + $findHidden = 1; + } + } + } + } + } + $routeTransitions[$valRoute]['TO']=$taskFromE; + $taskFromE = ''; + } + if($taskToE != ''){ + foreach ($routeArrayT as $valRoutes => $values){ + if($values['ROUTE'] == $value['ROUTE'] and $values['FROM'] != $value['ROUTE'] and $findHidden == 0){ + $taskToE = $values['FROM']; + } + } + $routeTransitions[$valRoute]['FROM']=$taskToE; + $taskToE = ''; + } + } + } + $firstRoute = 0; + $cont = 0; + $routeChange = $routeTransitions; + foreach ($routeTransitions as $valRoutes => $value){ + $route = $value['ROUTE']; + $type = $value['ROU_TYPE']; + $countFrom = 0; + $countTo = 0; + foreach ($routeChange as $valRoutes2 => $values){ + if($value['ROUTE'] == $values['ROUTE'] and $values['TOORFROM'] == 'TO'){ + $countTo = $countTo + 1; + } + if($value['ROUTE'] == $values['ROUTE'] and $values['TOORFROM'] == 'FROM'){ + $countFrom = $countFrom + 1; + } + } + if($type == 'PARALLEL'){ + if($countTo > $countFrom){ + $routeTransitions[$valRoutes]['ROU_TYPE'] = 'SEC-JOIN'; + } + } + } + $routeArrayT2 = $routeTransitions; + $routeArrayT1 = $routeTransitions; + foreach ($routeArrayT1 as $valRoutes => $value){ + if($firstRoute == 0){ + $taskFirst = $value['ROUTE']; + } + if($taskFirst == $value['ROUTE']){ + if($firstRoute == 0){ + foreach ($routeArrayT2 as $valRoutes2 => $values){ + if($values['ROUTE'] == $taskFirst and $values['FROM'] == $value['FROM'] and $values['TO'] == $value['TO'] and $values['ID'] != $value['ID']){ + unset($routeArrayT2[$valRoutes2]); + $firstRoute = 1; + } + } + } + } + else{ + $firstRoute = 0; + } + } + return $routeArrayT2; + } + + /** + * this function creates an array for the process that will be created according to the data given in an array + * @param array $fields + * @return array $process + */ + function createProcess($fields) + { $process = array(); + $process['PRO_UID'] = $fields['ID']; + $process['PRO_PARENT'] = $fields['ID']; + $process['PRO_TIME'] = 1; + $process['PRO_TIMEUNIT'] = 'DAYS'; + $process['PRO_STATUS'] = 'ACTIVE'; + $process['PRO_TYPE_DAY'] = ''; + $process['PRO_TYPE'] = 'NORMAL'; + $process['PRO_ASSIGNMENT'] = 'FALSE'; + $process['PRO_SHOW_MAP'] = 0; + $process['PRO_SHOW_MESSAGE'] = 0; + $process['PRO_SHOW_DELEGATE'] = 0; + $process['PRO_SHOW_DYNAFORM'] = 0; + $process['PRO_CATEGORY'] = ''; + $process['PRO_SUB_CATEGORY'] = ''; + $process['PRO_INDUSTRY'] = 0; + $process['PRO_UPDATE_DATE'] = date("D M j G:i:s T Y"); + $process['PRO_CREATE_DATE'] = date("D M j G:i:s T Y"); + $process['PRO_CREATE_USER'] = 00000000000000000000000000000001; + $process['PRO_HEIGHT'] = 5000; + $process['PRO_WIDTH'] = 10000; + $process['PRO_TITLE_X'] = 0; + $process['PRO_TITLE_Y'] = 0; + $process['PRO_DEBUG'] = 0; + $process['PRO_TITLE'] = $fields['NAME']; + $process['PRO_DESCRIPTION'] = $fields['DESCRIPTION']; + return $process; + } + + /** + * this function creates an array for the subProcess that will be created,according to the data given in an array + * @param array $contentNode + * @param array $arrayLanes + * @return array + */ + function createSubProcesses($contentNode,$arrayLanes) + { $activities = array(); + $numberActivities = 0; + $numberLanes = 0; + $number = 0; + $contentSubNode = $contentNode; + $numberSub = 0; + while ($contentSubNode){ + if ($contentSubNode->nodeType == XML_ELEMENT_NODE){ + $nameActivity = $contentSubNode->nodeName; + $contentActivity = $contentSubNode->firstChild; + if(strpos($nameActivity,'ActivitySet')!== false){ + $idSetActivity = str_replace('-','',$contentSubNode->getAttribute('Id')); + $arrayActivity[$number]['ID_PROCESS']= $idSetActivity; + $number = $number + 1; + } + } + $contentSubNode = $contentSubNode->nextSibling; + } + $number = 0; + $arraySubProcesses = array(); + while ($contentNode){ + if ($contentNode->nodeType == XML_ELEMENT_NODE){ + $isSubProcess = 0; + $nameActivity = $contentNode->nodeName; + $contentActivity = $contentNode->firstChild; + $idSetActivity = 0; + if(strpos($nameActivity,'ActivitySet')!== false){ + $idSetActivity = str_replace('-','',$contentNode->getAttribute('Id')); + if($idSetActivity !== 0){ + $isSubProcess = 1; + } + $nameSetActivity = $contentNode->getAttribute('Name'); + $contentChild = $contentNode->firstChild; + $process['ID'] = $idSetActivity; + $process['NAME'] = $nameSetActivity; + $process['DESCRIPTION'] = ''; + $subProcess->process = $this->createProcess($process); + $activities[$number]['ID_PROCESS']= $idSetActivity ; + while ($contentChild){ + if ($contentChild->nodeType == XML_ELEMENT_NODE){ + + $nameChild = $contentChild->nodeName; + $contentFirst = $contentChild->firstChild; + if(strpos($nameChild,'Activities')!== false){ + $arrayActivities = $this->createActivities($contentFirst,$idSetActivity,$arrayActivity); + $subProcess->tasks = $arrayActivities['TASKS']; + $startArray = $arrayActivities['START']; + $endArray = $arrayActivities['END']; + $arrayRoutes = $arrayActivities['ROUTES']; + $arrayScheduler = $arrayActivities['SCHEDULER']; + $arrayMessages = $arrayActivities['MESSAGES']; + } + + if(strpos($nameChild,'Transitions')!== false){ + $transitions = $this->createTransitions($contentFirst,$subProcess->tasks,$arrayRoutes,$endArray,$startArray,$idSetActivity,$arrayScheduler,$arrayMessages); + $subProcess->routes = $transitions['ROUTES']; + $subProcess->tasks = $transitions['TASKS']; + $routeTransitions = $transitions['TRANSITIONS']; + $numberRoutes = $transitions['NUMBER']; + $arrayMessages = $transitions['MESSAGES']; + } + } + $contentChild = $contentChild->nextSibling; + } + + $values = $subProcess; + if($isSubProcess == 1){ + $arraySubProcesses[$numberSub]['ID_PROCESS']=$idSetActivity ; + $arraySubProcesses[$numberSub]['TASKS'] =$subProcess->tasks; + $numberSub = $numberSub+1; + } + $activities[$number]['TASK_START']= $startArray[0]['ID_TASK']; + $number = $number + 1; + $subProcess->lanes = array(); + $numberLanes = 0; + foreach($arrayLanes as $key => $value) { + if($value['PRO_UID'] ==$idSetActivity){ + $subProcess->lanes[$numberLanes] = $value; + $numberLanes = $numberLanes + 1; + } + } + $subProcess->inputs = array(); + $subProcess->outputs = array(); + $subProcess->dynaforms = array(); + $subProcess->steps = array(); + $subProcess->triggers = array(); + $subProcess->taskusers = array(); + $subProcess->groupwfs = $this->getGroupwfRows($subProcess->taskusers ); + $subProcess->steptriggers = array(); + $subProcess->dbconnections = array(); + $subProcess->reportTables = array(); + $subProcess->reportTablesVars = array(); + $subProcess->stepSupervisor = array(); + $subProcess->objectPermissions = array(); + $subProcess->subProcess = array(); + $subProcess->caseTracker = array(); + $subProcess->caseTrackerObject = array(); + $subProcess->stage = array(); + $subProcess->fieldCondition = array(); + $subProcess->event = array(); + $subProcess->caseScheduler = array(); + $subProcess->dynaformFiles = array(); + $numberTransitions = sizeof($routeTransitions); + if($numberTransitions > 0){ + $routesArray = $this->createGateways($routeTransitions,$endArray,$subProcess->routes,$numberRoutes,$idProcess,''); + $subProcess->routes = $routesArray; + } + $numberSubProcess = 0; + foreach($subProcess->tasks as $key => $value) { + if($value['TAS_TYPE'] === 'SUBPROCESS'){ + $fields['TASK_PARENT'] = $value['TAS_UID']; + $idSubProcess = $value['TAS_UID']; + $newTasks = $this->getTaskRows($idSubProcess); + + $findTask = 0; + foreach ($newTasks as $keyLane => $val ) { + if($val['TAS_START']==='TRUE' and $findTask == 0){ + $findTask = 1; + $value['TASK_START']=$val['TAS_UID']; + } + } + $fields['PROCESS_PARENT'] = $idSetActivity; + $fields['TAS_UID'] = $value['TAS_UID']; + $subProcess->subProcess[$numberSubProcess]= $this->createSubProcess($fields,$arrayActivity); + $numberSubProcess = $numberSubProcess + 1; + } + } + $this->createSubProcessFromDataXpdl($subProcess,$subProcess->tasks); + } + } + $contentNode = $contentNode->nextSibling; + } + $arrayActivities['SUBPROCESSES'] = $arraySubProcesses; + $arrayActivities['SUB_PROCESS'] = $activities; + return $arrayActivities; + } + + /** + * This function creates an array for the task that will be created according to the data given in an array + * @param array $fields + * @return array $task + */ + function createTask($fields) + { + $task = array(); + $task['PRO_UID'] = $fields['ID_PROCESS']; + $task['TAS_UID'] = $fields['ID_TASK']; + $task['TAS_TYPE'] = $fields['TASK_TYPE']; + $task['TAS_DURATION'] = 1; + $task['TAS_DELAY_TYPE'] =''; + $task['TAS_TEMPORIZER'] = 0; + $task['TAS_TYPE_DAY'] ='' ; + $task['TAS_TIMEUNIT'] = 'DAYS'; + $task['TAS_ALERT'] = 'FALSE'; + $task['TAS_PRIORITY_VARIABLE'] = '@@SYS_CASE_PRIORITY'; + $task['TAS_ASSIGN_TYPE'] = 'BALANCED'; + $task['TAS_ASSIGN_VARIABLE'] = '@@SYS_NEXT_USER_TO_BE_ASSIGNED'; + $task['TAS_ASSIGN_LOCATION'] = 'FALSE'; + $task['TAS_ASSIGN_LOCATION_ADHOC']= 'FALSE'; + $task['TAS_TRANSFER_FLY'] = 'FALSE'; + $task['TAS_LAST_ASSIGNED'] = '00000000000000000000000000000001'; + $task['TAS_USER'] = '0'; + $task['TAS_CAN_UPLOAD'] = 'FALSE'; + $task['TAS_VIEW_UPLOAD'] = 'FALSE'; + $task['TAS_VIEW_ADDITIONAL_DOCUMENTATION']= 'FALSE'; + $task['TAS_CAN_CANCEL'] = 'FALSE'; + $task['TAS_OWNER_APP'] = 'FALSE'; + $task['STG_UID'] = ''; + $task['TAS_CAN_PAUSE'] = 'FALSE'; + $task['TAS_CAN_SEND_MESSAGE'] = 'TRUE'; + $task['TAS_CAN_DELETE_DOCS'] = 'FALSE'; + $task['TAS_SELF_SERVICE'] = 'FALSE'; + $task['TAS_START'] = 'FALSE'; + $task['TAS_TO_LAST_USER'] = 'FALSE'; + $task['TAS_SEND_LAST_EMAIL'] = 'FALSE'; + $task['TAS_DERIVATION'] = 'NORMAL'; + $task['TAS_POSX'] = $fields['X']; + $task['TAS_POSY'] = $fields['Y']; + $task['TAS_COLOR'] = ''; + $task['TAS_DEF_MESSAGE'] = ''; + $task['TAS_DEF_PROC_CODE'] = ''; + $task['TAS_DEF_DESCRIPTION'] = ''; + $task['TAS_TITLE'] = $fields['TAS_TITLE']; + $task['TAS_DESCRIPTION'] = $fields['DESCRIPTION']; + $task['TAS_DEF_TITLE'] = ''; + return $task; + } + + function createDataTask($fields) + { + $task = array(); + $task['PRO_UID'] = $fields['ID_PROCESS']; + $task['TAS_UID'] = $fields['ID_TASK']; + $task['TAS_TYPE'] = $fields['TAS_TYPE']; + $task['TAS_DURATION'] = 1; + $task['TAS_DELAY_TYPE'] =''; + $task['TAS_TEMPORIZER'] = 0; + $task['TAS_TYPE_DAY'] ='' ; + $task['TAS_TIMEUNIT'] = 'DAYS'; + $task['TAS_ALERT'] = 'FALSE'; + $task['TAS_PRIORITY_VARIABLE'] = '@@SYS_CASE_PRIORITY'; + $task['TAS_ASSIGN_TYPE'] = 'BALANCED'; + $task['TAS_ASSIGN_VARIABLE'] = '@@SYS_NEXT_USER_TO_BE_ASSIGNED'; + $task['TAS_MI_INSTANCE_VARIABLE'] = '@@SYS_VAR_TOTAL_INSTANCE'; + $task['TAS_MI_COMPLETE_VARIABLE'] = '@@SYS_VAR_TOTAL_INSTANCES_COMPLETE'; + $task['TAS_ASSIGN_LOCATION'] = 'FALSE'; + $task['TAS_ASSIGN_LOCATION_ADHOC']= 'FALSE'; + $task['TAS_TRANSFER_FLY'] = 'FALSE'; + $task['TAS_LAST_ASSIGNED'] = '00000000000000000000000000000001'; + $task['TAS_USER'] = '0'; + $task['TAS_CAN_UPLOAD'] = 'FALSE'; + $task['TAS_VIEW_UPLOAD'] = 'FALSE'; + $task['TAS_VIEW_ADDITIONAL_DOCUMENTATION']= 'FALSE'; + $task['TAS_CAN_CANCEL'] = 'FALSE'; + $task['TAS_OWNER_APP'] = 'FALSE'; + $task['STG_UID'] = ''; + $task['TAS_CAN_PAUSE'] = 'FALSE'; + $task['TAS_CAN_SEND_MESSAGE'] = 'TRUE'; + $task['TAS_CAN_DELETE_DOCS'] = 'FALSE'; + $task['TAS_SELF_SERVICE'] = 'FALSE'; + $task['TAS_START'] = $fields['START']; + $task['TAS_TO_LAST_USER'] = 'FALSE'; + $task['TAS_SEND_LAST_EMAIL'] = 'FALSE'; + $task['TAS_DERIVATION'] = 'NORMAL'; + $task['TAS_POSX'] = $fields['X']; + $task['TAS_POSY'] = $fields['Y']; + $task['TAS_COLOR'] = ''; + $task['TAS_DEF_MESSAGE'] = ''; + $task['TAS_DEF_PROC_CODE'] = ''; + $task['TAS_DEF_DESCRIPTION'] = ''; + $task['TAS_TITLE'] = $fields['TAS_TITLE']; + $task['TAS_DESCRIPTION'] = $fields['DESCRIPTION']; + $task['TAS_DEF_TITLE'] = ''; + return $task; + } +/** + * This function creates an array for the route that will be created according to the data given in an array + * @param array $fields + * @return array $route + */ + function createRoute($fields) + { + $route = array(); + $route['ROU_UID'] = $fields['ROU_UID']; + $route['ROU_PARENT'] = 0; + $route['PRO_UID'] = $fields['ID_PROCESS']; + $route['TAS_UID'] = $fields['FROM']; + $route['ROU_NEXT_TASK'] = $fields['TO']; + $route['ROU_CASE'] = 1; + $route['ROU_TYPE'] = 'SEQUENTIAL'; + $route['ROU_CONDITION'] = '' ; + $route['ROU_TO_LAST_USER'] = 'FALSE'; + $route['ROU_OPTIONAL'] = 'FALSE'; + $route['ROU_SEND_EMAIL'] = 'TRUE'; + $route['ROU_SOURCEANCHOR'] = 1; + $route['ROU_TARGETANCHOR'] = 0; + return $route; + } + + /** + * This function creates an array for the subProcess that will be created according to the data given in an array + * @param array $fields + * @return array $route + */ + function createSubProcess($fields) + { + $subProcess = array(); + $subProcess['SP_UID'] = $fields['TAS_UID']; + $subProcess['PRO_UID'] = $fields['TASK_PARENT']; + $subProcess['TAS_UID'] = $fields['TAS_UID']; + $subProcess['PRO_PARENT'] = $fields['PROCESS_PARENT']; + $subProcess['TAS_PARENT'] = $fields['TASK_PARENT']; + $subProcess['SP_TYPE'] = 'SIMPLE'; + $subProcess['SP_SYNCHRONOUS'] = 0; + $subProcess['SP_SYNCHRONOUS_TYPE'] = 'ALL' ; + $subProcess['SP_SYNCHRONOUS_WAIT'] = 0; + $subProcess['SP_VARIABLES_OUT'] = 'a:1:{s:0:"";s:0:"";}'; + $subProcess['SP_VARIABLES_IN'] = 'a:1:{s:0:"";s:0:"";}'; + $subProcess['SP_GRID_IN'] = ''; + return $subProcess; + } + + /** + * This function creates an array for the routes that are not sequential that will be created according to the data given in an array + * @param array $routeTransitions + * @param array $endArray + * @param array $dataRoutes + * @param array $numberRoutes + * @param string $idProcess + * @return array $dataRoutes + */ + function createGateways($routeTransitions,$endArray,$dataRoutes,$numberRoutes,$idProcess,$taskHidden) + { + $valueCase = ''; + $value = 1; + $valueC = 1; + $aux = $routeTransitions; + foreach ($routeTransitions as $key => $row) { + $aux[$key] = $row['ROUTE']; + } + array_multisort($aux,SORT_ASC,$routeTransitions); + $routeArray = $this->verifyRoutes($routeTransitions,$endArray,$taskHidden); + $routeArray = $this->sortArray($routeArray); + foreach($routeArray as $valRoutes => $value){ + $isEventEnd = 0; + foreach ($endArray as $endBase => $valueEnd){ + if($valueEnd['ID_TASK']==$value['TO']){ + $isEventEnd = 1; + } + } + $dataRoutes[$numberRoutes]= array(); + $dataRoutes[$numberRoutes]['ROU_UID'] = $value['ID']; + $dataRoutes[$numberRoutes]['ROU_PARENT'] = 0; + $dataRoutes[$numberRoutes]['PRO_UID'] = $idProcess; + $dataRoutes[$numberRoutes]['TAS_UID'] = $value['FROM']; + + if($isEventEnd == 0){ + $dataRoutes[$numberRoutes]['ROU_NEXT_TASK'] = $value['TO']; + } + else{ + $dataRoutes[$numberRoutes]['ROU_NEXT_TASK'] = '-1'; + } + if($valueCase == $value['FROM']){ + $valueC = $valueC + 1; + } + else{ + $valueC = 1; + $valueCase = $value['FROM']; + } + if($valueCase == ''){ + $valueC = 1; + $valueCase = $value['FROM']; + } + $dataRoutes[$numberRoutes]['ROU_CASE'] = $valueC; + $dataRoutes[$numberRoutes]['ROU_TYPE'] = $value['ROU_TYPE']; + if($value['ROU_TYPE'] ==='DISCRIMINATOR'){ + $dataRoutes[$numberRoutes]['ROU_CONDITION'] = $value['CONDITION_DIS']; + $dataRoutes[$numberRoutes]['ROU_OPTIONAL'] = $value['TYPE_DIS']; + } + if($value['ROU_TYPE'] !=='DISCRIMINATOR'){ + $dataRoutes[$numberRoutes]['ROU_CONDITION'] = $value['CONDITION']; + $dataRoutes[$numberRoutes]['ROU_OPTIONAL'] = 'FALSE'; + } + $dataRoutes[$numberRoutes]['ROU_TO_LAST_USER'] = 'FALSE'; + $dataRoutes[$numberRoutes]['ROU_SEND_EMAIL'] = 'TRUE'; + $dataRoutes[$numberRoutes]['ROU_SOURCEANCHOR'] = 1; + $dataRoutes[$numberRoutes]['ROU_TARGETANCHOR'] = 0; + $numberRoutes = $numberRoutes + 1; + } + return $dataRoutes; + } + + /** + * This function creates an array for the lane that will be created according to the data given in an array + * @param array $lanes + * @return array $lane + */ + function createLanesPM($array,$idProcess) + { + $arrayLanes = array(); + $field = array(); + foreach ($array as $key=> $value){ + $field['ID_LANE'] = $value['0']; + $field['ID_PROCESS'] = $idProcess; + $field['X'] = $value['2']; + $field['Y'] = $value['3']; + $field['WIDTH'] = $value['4']; + $field['HEIGHT'] = $value['5']; + $field['TEXT'] = $value['6']; + $arrayLanes[]= $this->createLanes($field); + } + return $arrayLanes; + } + +/** + * This function creates an array for the lane that will be created according to the data given in an array + * @param array $lanes + * @return array $lane + */ + function createLanes($lanes) + { + $lane = array(); + $lane['SWI_UID'] = $lanes['ID_LANE']; + $lane['PRO_UID'] = $lanes['ID_PROCESS']; + $lane['SWI_TYPE'] = 'TEXT'; + $lane['SWI_X'] = $lanes['X']; + $lane['SWI_Y'] = $lanes['Y']; + $lane['SWI_TEXT'] = $lanes['TEXT']; + $lane['SWI_WIDTH'] = $lanes['WIDTH']; + $lane['SWI_HEIGHT']= $lanes['HEIGHT']; + return $lane; + } + + /** + * This function creates an array for the lane that will be created according to the data given in an array + * @param array $lanes + * @return array $lane + */ + function createLanesNewPM($array) + { + $arrayLanes = array(); + $field = array(); + foreach ($array as $key=> $value){ + if($value['SWI_TYPE'] == 'TEXT') + { + $field['0'] = $value['SWI_UID']; + $field['1'] = $value['SWI_TEXT']; + $field['2'] = $value['SWI_X']; + $field['3'] = $value['SWI_Y']; + $field['4'] = $value['SWI_WIDTH']; + $field['5'] = $value['SWI_HEIGHT']; + $arrayLanes[]= $field; + } + } + return $arrayLanes; + } + + /** + * This function creates activities according the content of the node + * @param object $contentNode + * @param string $idProcess + * @param string $ActivitySet + * @return array $result + */ + function createActivities($contentNode,$idProcess,$activitySet) + { + $result = array(); + $numberTasks = 0; + $posRoutes = 0; + $posEnd = 0; + $posStart = 0; + $arrayRoutes = array(); + $endArray = array(); + $endArray = array(); + $startArray = array(); + $arrayScheduler = array(); + $scheduler = array(); + $message = array(); + $arrayMessages = array(); + while ($contentNode){ + if ($contentNode->nodeType == XML_ELEMENT_NODE){ + $nameActivity = $contentNode->nodeName; + $contentActivity = $contentNode->firstChild; + if(strpos($nameActivity,'Activity')!== false){ + $idActivity = $contentNode->getAttribute('Id'); + $idActivity = trim(str_replace('-','',$idActivity)); + $name = htmlentities($contentNode->getAttribute('Name')); + $result = $this->createActivity($contentActivity); + $result['ID_PROCESS']= $idProcess; + $result['ID_TASK'] = $idActivity; + $result['TAS_TITLE'] = $name; + $result['TASK_TYPE'] = 'NORMAL'; + foreach ($activitySet as $key => $value) { + if($value['ID_PROCESS'] ==$idActivity){ + $result['TASK_TYPE']= 'SUBPROCESS'; + } + } + if($result['EVENT'] =='' and $result['ROUTE'] ==''){ + $arrayTasks[$numberTasks]= $this->createTask($result); + $numberTasks = $numberTasks +1; + } + else{ + if($result['EVENT'] !='' and $result['TRIGGER']== 'None'){ + if($result['EVENT'] =='END'){ + $endArray[$posEnd] = $result; + $posEnd = $posEnd+1; + } + if($result['EVENT'] =='START'){ + $startArray[$posStart] = $result; + $posStart= $posStart+1; + } + } + else{ + if($result['TRIGGER']== 'Timer'){ + $scheduler['ID'] = $idActivity; + $scheduler['NAME'] = $name; + if($result['TIME'] == '' or $result['TIME'] == Null){ + $scheduler['TIME'] = date("D M j G:i:s T Y"); + } + else{ + $scheduler['TIME'] = $result['TIME']; + } + $scheduler['TYPE_TIME']= $result['TYPE_TIME']; + $arrayScheduler[] = $scheduler; + } + if($result['TRIGGER']== 'Message'){ + $message['ID'] = $idActivity; + $message['NAME'] = $name; + $message['TYPE_MESSAGE'] = $result['MESSAGE']; + $arrayMessages[] = $message; + } + } + if($result['ROUTE'] !=''){ + $position = $this->findCoordinates($contentActivity); + $arrayRoutes[$posRoutes]['ID'] = $idActivity; + $arrayRoutes[$posRoutes]['ROUTE'] = $result['ROUTE']; + $arrayRoutes[$posRoutes]['TYPE_DIS'] = $result['TYPE_DISCRIMINATOR']; + $arrayRoutes[$posRoutes]['CONDITION_DIS'] = $result['CONDITION_DISCRIMINATOR']; + $arrayRoutes[$posRoutes]['X'] = $position['X']; + $arrayRoutes[$posRoutes]['Y'] = $position['Y']; + $posRoutes = $posRoutes + 1; + } + } + } + } + $contentNode = $contentNode->nextSibling; + } + $result['TASKS'] = $arrayTasks; + $result['END'] = $endArray; + $result['START'] = $startArray; + $result['ROUTES'] = $arrayRoutes; + $result['SCHEDULER']= $arrayScheduler; + $result['MESSAGES'] = $arrayMessages; + return $result; + } + + +/** + * This function creates the scheduler + * @param array $fields + * @return array $result + */ + function createEventMessages($fields,$idProcess) + { + $result = array(); + $event = array(); + $example = new Derivation(); + foreach($fields as $key => $value){ + $oEvent = new Event(); + $event['EVN_UID'] = $value['ID']; + $event['PRO_UID'] = $idProcess; + $event['EVN_RELATED_TO'] = 'SINGLE'; + $event['TAS_UID'] = $value['ID_TASK']; + $event['EVN_TAS_ESTIMATED_DURATION'] = '1'; + $event['EVN_WHEN_OCCURS'] = 'AFTER'; + $event['EVN_STATUS'] = 'ACTIVE'; + $event['EVN_WHEN'] = 1; + $event['EVN_MAX_ATTEMPTS'] = 3; + $event['EVN_ACTION'] = 'SEND_MESSAGE'; + $event['EVN_DESCRIPTION'] = $value['NAME']; + $event['EVN_WHEN_OCCURS'] = 'AFTER_TIME'; + $event['EVN_ACTION_PARAMETERS'] = array( + 'SUBJECT' => 'subject', + 'TO' => array('0'=>'usr|-1','1'=>'ext|'), + 'CC' => array(), + 'BCC' => array(), + 'TEMPLATE' => 'alert_message.html' + ); + $result[] = $event; + } + return $result; + } + + /** + * This function creates the scheduler + * @param array $fields + * @return array $result + */ + function createScheduler($fields,$idProcess) + { + $result = array(); + $example = new Derivation(); + foreach($fields as $key => $value){ + if($value['TYPE_TIME'] == 'TimeDate'){ + //there is a scheduler one time only + $value['OPTION']= 4; + $result[]= $this->createArrayScheduler($value,$idProcess); + } + if($value['TYPE_TIME'] == 'TimeCycle'){ + //we calculated if is daily or monthly, etc + $time = $this->calculateTimeScheduler($value['TIME']); + /*$value['OPTION']= $time['OPTION']; + $value['TIME'] = $time['TIME'];*/ + $value['OPTION']= '1'; + } + } + //PRINT_r($result); + return $result; + } + +/** + * This function creates the scheduler + * @param array $fields + * @return array $result + */ + function calculateTimeScheduler($time) + { + $result = array(); + $result = split(' ',$time); + //print_r($result); + return $result; + } + + /** + * This function creates the array scheduler + * @param string $time + * @param string $type (TimeCycle or TimeDate) + * @return array $result + */ + function createArrayScheduler($fields,$idProcess) + { + $result['SCH_UID'] = $fields['ID']; + $result['SCH_DEL_USER_NAME'] = ''; + $result['SCH_DEL_USER_PASS'] = ''; + $result['SCH_DEL_USER_UID'] = ''; + $result['SCH_NAME'] = $fields['NAME']; + $result['PRO_UID'] = $idProcess; + $result['TAS_UID'] = $fields['ID_TASK']; + $result['SCH_TIME_NEXT_RUN'] = $fields['TIME']; + $result['SCH_LAST_RUN_TIME'] = null; + $result['SCH_STATE'] = 'ACTIVE'; + $result['SCH_LAST_STATE'] = 'CREATED'; + $result['USR_UID'] = '00000000000000000000000000000001'; + $result['SCH_OPTION'] = $fields['OPTION']; + $result['SCH_START_TIME'] = $fields['TIME']; + $result['SCH_START_DATE'] = $fields['TIME']; + $result['SCH_DAYS_PERFORM_TASK'] = ''; + $result['SCH_EVERY_DAYS'] = '0'; + $result['SCH_WEEK_DAYS'] = '0|0|0|0|0|0|0'; + $result['SCH_START_DAY'] = ''; + $result['SCH_MONTHS'] = '0|0|0|0|0|0|0|0|0|0|0|0'; + $result['SCH_END_DATE'] = $fields['TIME']; + $result['SCH_REPEAT_EVERY'] = ''; + $result['SCH_REPEAT_UNTIL'] = ''; + $result['SCH_REPEAT_STOP_IF_RUNNING'] = ''; + return $result; + } + + /** + * This function creates transitions according the content of the node + * @param object $contentNode + * @param array $dataTask + * @param array $arrayRoutes + * @param array $endArray + * @param array $startArray + * @param string $idProcess + * @return array $result + */ + + function createTransitions($contentNode,$dataTasks,$arrayRoutes,$endArray,$startArray,$idProcess,$schedulerArray,$messages) + { + $numberRoutes = 0; + $posT = 0; + $output = ''; + $routeTransitions = array(); + $taskHidden = array(); + $countHidden = 1; + $dataRoutes = array(); + $newFrom = 0; + $isScheduler = 0; + $isMessage = 0; + while ($contentNode){ + $isEnd = 0; + $isStart = 0; + $tasks = $dataTasks; + if ($contentNode->nodeType == XML_ELEMENT_NODE){ + $nameTransition = $contentNode->nodeName; + $contentTransition = $contentNode->firstChild; + if(strpos($nameTransition,'Transition')!== false){ + $idTransition = $contentNode->getAttribute('Id'); + $idTransition = trim(str_replace('-','',$idTransition)); + $from = trim(str_replace('-','',$contentNode->getAttribute('From'))); + $to = trim(str_replace('-','',$contentNode->getAttribute('To'))); + $routes['ROU_UID'] = $idTransition; + $routes['ID_PROCESS']= $idProcess; + $routes['FROM'] = $from; + $routes['TO'] = $to; + $isScheduler = 0; + $isMessage = 0; + foreach ($startArray as $startBase => $value){ + if($value['ID_TASK']==$from){ + foreach($tasks as $tasksValue=> $taskId){ + if($to==$taskId['TAS_UID']){ + $taskId['TAS_START']='TRUE'; + $dataTasks[$tasksValue]['TAS_START']='TRUE'; + $isStart = 1; + } + } + } + } + foreach ($schedulerArray as $startBase => $value){ + if($value['ID']==$from){ + $isScheduler = 1; + $schedulerArray[$startBase]['ID_TASK'] = $to; + foreach($tasks as $tasksValue=> $taskId){ + if($to==$taskId['TAS_UID']){ + $taskId['TAS_START']='TRUE'; + $dataTasks[$tasksValue]['TAS_START']='TRUE'; + $isStart = 1; + } + } + } + } + foreach ($messages as $startBase => $value){ + if($value['ID']==$from){ + $isMessage = 1; + $messages[$startBase]['ID_TASK'] = $to; + } + if($value['ID']==$to){ + $isMessage = 1; + $messages[$startBase]['ID_TASK'] = $from; + } + } + $sequencial = 0; + $findRoute = 0; + foreach ($arrayRoutes as $routeBase => $value){ + //change for task hidden + if($value['ID']==$from){ + if($findRoute == 0){ + $typeT = 'FROM'; + $valueRoute = $value['ID']; + $typeRoute = $value['ROUTE']; + $sequencial = 1; + $conditionD = $value['CONDITION_DIS']; + $typeD = $value['TYPE_DIS']; + $findRoute = 1; + } + else{ + $contendHidden = $contentTransition; + $fieldsXY = $this->findCoordinatesTransition($to,$arrayRoutes); + $hidden['ID_TASK'] = G::generateUniqueID(); + $hidden['ID_PROCESS'] = $idProcess; + $hidden['TAS_TITLE'] = ''; + $hidden['TASK_TYPE'] = 'HIDDEN'; + $hidden['DESCRIPTION'] = $countHidden; + $hidden['X'] = $fieldsXY['X']; + $hidden['Y'] = $fieldsXY['Y']; + $taskHidden[] = $hidden; + $dataTasks[] = $this->createTask($hidden); + $countHidden = $countHidden + 1; + $routeTransitions[$posT]['ID'] = G::generateUniqueID(); + $routeTransitions[$posT]['ROUTE'] = $from; + $routeTransitions[$posT]['FROM'] = $from; + $routeTransitions[$posT]['TO'] = $hidden['ID_TASK']; + $routeTransitions[$posT]['TOORFROM'] = 'FROM'; + $routeTransitions[$posT]['ROU_TYPE'] = $value['ROUTE']; + $routeTransitions[$posT]['CONDITION'] = $output; + $routeTransitions[$posT]['CONDITION_DIS'] = $conditionD; + $routeTransitions[$posT]['TYPE_DIS'] = $typeD; + $output = ''; + $posT = $posT + 1; + $from = $hidden['ID_TASK']; + } + } + if($value['ID']==$to){ + if($findRoute == 0){ + $typeT = 'TO'; + $valueRoute = $value['ID']; + $typeRoute = $value['ROUTE']; + $sequencial = 1; + $conditionD = $value['CONDITION_DIS']; + $typeD = $value['TYPE_DIS']; + $findRoute = 1; + } + else{ + + $contendHidden = $contentTransition; + $fieldsXY = $this->findCoordinatesTransition($to,$arrayRoutes); + $hidden['ID_TASK'] = G::generateUniqueID(); + $hidden['ID_PROCESS'] = $idProcess; + $hidden['TAS_TITLE'] = ''; + $hidden['TASK_TYPE'] = 'HIDDEN'; + $hidden['DESCRIPTION'] = $countHidden; + $hidden['X'] = $fieldsXY['X']; + $hidden['Y'] = $fieldsXY['Y']; + $taskHidden[] = $hidden; + $dataTasks[] = $this->createTask($hidden); + $countHidden = $countHidden + 1; + $routeTransitions[$posT]['ID'] = G::generateUniqueID(); + $routeTransitions[$posT]['ROUTE'] = $from; + $routeTransitions[$posT]['FROM'] = $from; + $routeTransitions[$posT]['TO'] = $hidden['ID_TASK']; + $routeTransitions[$posT]['TOORFROM'] = 'TO'; + $routeTransitions[$posT]['ROU_TYPE'] = $typeRoute; + $routeTransitions[$posT]['CONDITION'] = $output; + $routeTransitions[$posT]['CONDITION_DIS'] = $conditionD; + $routeTransitions[$posT]['TYPE_DIS'] = $typeD; + $output = ''; + $posT = $posT + 1; + $from = $hidden['ID_TASK']; + $conditionD = $value['CONDITION_DIS']; + $typeRoute = $value['ROUTE']; + $typeT = 'TO'; + $valueRoute = $value['ID']; + $sequencial = 1; + $conditionD = $value['CONDITION_DIS']; + $typeD = $value['TYPE_DIS']; + } + } + } + if($sequencial == 0){ + foreach ($endArray as $endBase => $value){ + if($value['ID_TASK']==$to){ + foreach($tasks as $tasksValue=> $taskId){ + if($from==$taskId['TAS_UID']){ + $routes['TO'] = '-1'; + $dataRoutes[$numberRoutes]= $this->createRoute($routes); + $numberRoutes = $numberRoutes +1; + $isEnd = 1; + } + } + } + } + } + if($sequencial == 1){ + while ($contentTransition) { + $nameCondition = $contentTransition->nodeName; + $contentCondition = $contentTransition->firstChild; + if(strpos($nameCondition,'Condition')!== false){ + while ($contentCondition) { + $nameExpression = $contentCondition->nodeName; + $contentCondition1 = ''; + if(strpos($nameExpression,'Expression')!== false){ + $contentCondition1 = $contentCondition->firstChild; + if($contentCondition1 != array()){ + $output = $contentCondition1->nodeValue; + } + } + $contentCondition = $contentCondition->nextSibling; + } + } + $contentTransition = $contentTransition->nextSibling; + } + $routeTransitions[$posT]['ID'] = $idTransition; + $routeTransitions[$posT]['ROUTE'] = $valueRoute; + $routeTransitions[$posT]['FROM'] = $from; + $routeTransitions[$posT]['TO'] = $to; + $routeTransitions[$posT]['TOORFROM'] = $typeT; + $routeTransitions[$posT]['ROU_TYPE'] = $typeRoute; + $routeTransitions[$posT]['CONDITION'] = $output; + $routeTransitions[$posT]['CONDITION_DIS'] = $conditionD; + $routeTransitions[$posT]['TYPE_DIS'] = $typeD; + $output = ''; + $posT = $posT + 1; + $sequencial = 1; + } + if($isEnd==0 and $isStart == 0 and $sequencial == 0 and $isScheduler == 0 and $isMessage == 0){ + $dataRoutes[$numberRoutes]= $this->createRoute($routes); + $numberRoutes = $numberRoutes +1; + } + } + } + $contentNode = $contentNode->nextSibling; + } + $routes = $routeTransitions; + foreach($routeTransitions as $key => $id){ + $findTo = 0; + $findFrom = 0; + foreach ($dataTasks as $keyHidden => $value){ + if($id['FROM']== $value['TAS_UID']){ + $findFrom= 1; + } + if($id['TO']== $value['TAS_UID']){ + $findTo = 1; + } + } + if($findTo == 0){ + foreach($routes as $keyR => $idR){ + if($id['TO'] == $idR['ROUTE']){ + $routeTransitions[$key]['ROU_TYPE'] = $idR['ROU_TYPE']; + $routeTransitions[$key]['ROUTE'] = $id['TO']; + $routeTransitions[$key]['TOORFROM'] = 'TO'; + } + } + } + if($findFrom == 0){ + foreach($routes as $keyR => $idR){ + if($id['FROM'] == $idR['ROUTE']){ + $routeTransitions[$key]['ROU_TYPE'] = $idR['ROU_TYPE']; + $routeTransitions[$key]['ROUTE'] = $id['FROM']; + $routeTransitions[$key]['TOORFROM'] = 'FROM'; + } + } + } + } + $result['ROUTES'] = $dataRoutes; + $result['TRANSITIONS']= $routeTransitions; + $result['TASKS'] = $dataTasks; + $result['NUMBER'] = $numberRoutes; + $result['TASKHIDDEN'] = $taskHidden; + $result['SCHEDULER'] = $schedulerArray; + $result['MESSAGES'] = $messages; + return $result; + } +/** + * this function creates a array according to the data given in a node + * @param object $contentNode + * @return array + */ + function createActivity($contentNode) + { + $coordinates = array(); + $event = ''; + $typeRoute = ''; + $markerVisible = ''; + $typePM = ''; + $isRoute = 0; + $description = ''; + $isSubProcess = 0 ; + $trigger = ''; + $time = ''; + $typeTime = ''; + $isMessage = 0; + while ($contentNode) { + if ($contentNode->nodeType == XML_ELEMENT_NODE) { + $nameChild = $contentNode->nodeName; + $contentChild = $contentNode->firstChild; + if(strpos($nameChild,'Description')!== false){ + $description = $contentNode->nodeValue; + } + if(strpos($nameChild,'ExtendedAttributes')!== false){ + $result = $this->createExtended($contentChild); + } + if(strpos($nameChild,'BlockActivity')!== false){ + $isSubProcess = 1; + $idSubProcess = trim(str_replace('-','',$contentNode->getAttribute('ActivitySetId'))); + } + if(strpos($nameChild,'Event')!== false){ + while ($contentChild) { + if ($contentChild->nodeType == XML_ELEMENT_NODE) { + $nameInfo = $contentChild->nodeName; + $contentInfo = $contentChild->firstChild; + if(strpos($nameInfo,'StartEvent')!== false){ + $event = 'START'; + $trigger = $contentChild->getAttribute('Trigger'); + } + if(strpos($nameInfo,'EndEvent')!== false){ + $event = 'END'; + $trigger = $contentChild->getAttribute('Trigger'); + if($trigger == ''){ + $trigger = 'None'; + } + } + if(strpos($nameInfo,'IntermediateEvent')!== false){ + $event = 'INTERMEDIATE'; + $trigger = $contentChild->getAttribute('Trigger'); + } + } + $contentChild = $contentChild->nextSibling; + } + if($trigger != 'None'){ + if($trigger == 'Timer'){ + while ($contentInfo) { + $nameTrigger = $contentInfo->nodeName; + $contentTrigger = $contentInfo->firstChild; + if(strpos($nameTrigger,'TriggerTimer')!== false){ + $time = $contentInfo->getAttribute('TimeCycle'); + $typeTime = 'TimeCycle'; + if($time == ''){ + $time = $contentInfo->getAttribute('TimeDate'); + $typeTime = 'TimeDate'; + } + } + $contentInfo = $contentInfo->nextSibling; + } + } + if($trigger == 'Message'){ + $typeMessage = ''; + $isMessage = 1; + while ($contentInfo) { + $nameTrigger = $contentInfo->nodeName; + $contentTrigger = $contentInfo->firstChild; + if(strpos($nameTrigger,'TriggerResultMessage')!== false){ + $typeMessage = $contentInfo->getAttribute('CatchThrow'); + } + $contentInfo = $contentInfo->nextSibling; + } + } + } + } + + if(strpos($nameChild,'Route')!== false){ + $typePM = ''; + $typeRoute = $contentNode->getAttribute('GatewayType'); + $markerVisible = $contentNode->getAttribute('MarkerVisible'); + if($markerVisible !=''){ + $coordinates['ROUTE'] = $markerVisible; + } + if($typeRoute !=''){ + $coordinates['ROUTE'] = $typeRoute; + } + if($typeRoute =='' and $markerVisible ==''){ + $coordinates['ROUTE'] = 'EVALUATE'; + } + switch($coordinates['ROUTE']){ + case 'AND': + $typePM = 'PARALLEL'; + break; + case 'true': + $typePM = 'EVALUATE'; + break; + case 'EVALUATE': + $typePM = 'EVALUATE'; + break; + case 'OR': + $typePM = 'PARALLEL-BY-EVALUATION'; + break; + case 'Complex': + $typePM = 'DISCRIMINATOR'; + break; + } + $isRoute = 1; + } + if(strpos($nameChild,'NodeGraphicsInfos')!== false){ + $coordinates = $this->findCoordinates($contentNode); + $coordinates['EVENT'] = $event; + $coordinates['TRIGGER'] = $trigger; + $coordinates['TIME'] = $time; + $coordinates['TYPE_TIME'] = $typeTime; + $coordinates['DESCRIPTION'] = $description; + $coordinates['TYPE_DISCRIMINATOR'] = $result['TYPE']; + $coordinates['CONDITION_DISCRIMINATOR'] = $result['CONDITION']; + if($isRoute == 1){ + $coordinates['ROUTE']= $typePM; + } + else{ + $coordinates['ROUTE']=''; + } + if($isMessage == 1){ + $coordinates['MESSAGE']= $typeMessage; + } + else{ + $coordinates['MESSAGE']=''; + } + } + } + $contentNode = $contentNode->nextSibling; + } + return $coordinates; + } + + /** + * This function return the type and the condition of a discriminator + * @param object $contentNode + * @return array + */ + function createExtended($contentNode) + { + $result = array(); + $result['TYPE']= ''; + $result['CONDITION'] = ''; + $contentExtended = $contentNode; + while ($contentExtended) { + if ($contentExtended->nodeType == XML_ELEMENT_NODE) { + $nameChildExtended = $contentExtended->nodeName; + $contentChildExtended = $contentExtended->firstChild; + if(strpos($nameChildExtended,'ExtendedAttribute')!== false){ + $name = $contentExtended->getAttribute('Name'); + if($name == 'option'){ + $result['TYPE'] = $contentExtended->getAttribute('Value'); + } + if($name == 'condition'){ + $result['CONDITION'] = $contentExtended->getAttribute('Value'); + } + } + } + $contentExtended = $contentExtended->nextSibling; + } + return $result; + } + +/** + * This function find the coordinates of a object + * @param object $contentNode + * @return array + */ + function findCoordinates($contentNode) + { + $coordinates = array(); + while ($contentNode) { + if ($contentNode->nodeType == XML_ELEMENT_NODE) { + $nameChild = $contentNode->nodeName; + $contentChild = $contentNode->firstChild; + if(strpos($nameChild,'NodeGraphicsInfos')!== false){ + while ($contentChild) { + if ($contentChild->nodeType == XML_ELEMENT_NODE) { + $nameInfo = $contentChild->nodeName; + $contentInfo = $contentChild->firstChild; + if(strpos($nameInfo,'NodeGraphicsInfo')!== false){ + $coordinates['Height'] = $contentChild->getAttribute('Height'); + $coordinates['Width'] = $contentChild->getAttribute('Width'); + $coordinates['BorderColor'] = $contentChild->getAttribute('BorderColor'); + $coordinates['FillColor'] = $contentChild->getAttribute('FillColor'); + while ($contentInfo) { + $nameCoordinate = $contentInfo->nodeName; + $contentCoordinate = $contentInfo->firstChild; + + if(strpos($nameCoordinate,'Coordinates')!== false){ + $coordinates['X'] = $contentInfo->getAttribute('XCoordinate'); + $coordinates['Y'] = $contentInfo->getAttribute('YCoordinate'); + } + $contentInfo = $contentInfo->nextSibling; + } + + } + } + $contentChild = $contentChild->nextSibling; + } + } + } + $contentNode = $contentNode->nextSibling; + } + return $coordinates; + } + +/** + * This function find the coordinates of a object + * @param string $idRoute + * @param array $aRoutes + * @return array + */ + function findCoordinatesTransition($idRoute,$aRoutes) + { + $coordinates = array(); + $size = sizeof($aRoutes); + $count = 0; + $find = 0; + while($count < $size and $find == 0){ + if($aRoutes[$count]['ID'] == $idRoute){ + $coordinates['X'] = $aRoutes[$count]['X']; + $coordinates['Y'] = $aRoutes[$count]['Y']; + $find = 1; + } + $count = $count + 1; + } + return $coordinates; + } + + /** + * This function create the array Routes + * @param array $dataTasks + * @param array $arrayRoutes + * @param array $aEvents + * @param array $aGateways + * @param string $idProcess + * @return array + */ + function createArrayRoutes($dataTasks,$arrayRoutes,$aEvents,$aGateways,$aEnd,$idProcess) + { + $numberRoutes = 0; + $posT = 0; + $routeTransitions = array(); + $dataRoutes = array(); + $findRoute = 0; + $hidden = array(); + $taskHidden = array(); + $countHidden = 0; + foreach($arrayRoutes as $idRoute => $valueRoute){ + $idTransition = $valueRoute['0']; + $from = $valueRoute['1']; + $to = $valueRoute['2']; + $toPort = $valueRoute['3']; + $fromPort = $valueRoute['4']; + $routes['ROU_UID'] = $idTransition; + $routes['ID_PROCESS']= $idProcess; + $routes['FROM'] = $from; + $routes['TO'] = $to; + $sequencial = 0; + $isEnd = 0; + $typeRoute = ''; + $typePM = ''; + $findRoute = 0; + $isEventIntermediate = 0; + foreach ($aGateways as $routeBase => $value){ + if($value['0']==$from){ + if($findRoute == 0){ + $typeT = 'FROM'; + $valueRoute = $value['0']; + $typeRoute = $value['1']; + $positionX = $value['2']; + $positionY = $value['3']; + $sequencial = 1; + $findRoute = 1; + } + else{ + $hidden['ID_TASK'] = G::generateUniqueID(); + $hidden['ID_PROCESS'] = $idProcess; + $hidden['TAS_TITLE'] = ''; + $hidden['TASK_TYPE'] = 'HIDDEN'; + $hidden['DESCRIPTION'] = $countHidden; + $hidden['X'] = $positionX; + $hidden['Y'] = $positionY; + $taskHidden[] = $hidden; + $dataTasks[] = $this->createTask($hidden); + $countHidden = $countHidden + 1; + $routeTransitions[$posT]['ID'] = G::generateUniqueID(); + $routeTransitions[$posT]['ROUTE'] = $from; + $routeTransitions[$posT]['FROM'] = $from; + $routeTransitions[$posT]['TO'] = $hidden['ID_TASK']; + $routeTransitions[$posT]['TOORFROM'] = 'FROM'; + $routeTransitions[$posT]['ROU_TYPE'] = $value['1']; + $routeTransitions[$posT]['CONDITION'] = ''; + $routeTransitions[$posT]['CONDITION_DIS'] = ''; + $routeTransitions[$posT]['TYPE_DIS'] = ''; + $posT = $posT + 1; + $from = $hidden['ID_TASK']; + } + } + if($value['0']==$to){ + if($findRoute == 0){ + $typeT = 'TO'; + $valueRoute = $value['0']; + $typeRoute = $value['1']; + $positionX = $value['2']; + $positionY = $value['3']; + $sequencial = 1; + $findRoute = 1; + } + else{ + $hidden['ID_TASK'] = G::generateUniqueID(); + $hidden['ID_PROCESS'] = $idProcess; + $hidden['TAS_TITLE'] = ''; + $hidden['TASK_TYPE'] = 'HIDDEN'; + $hidden['DESCRIPTION'] = $countHidden; + $hidden['X'] = $positionX; + $hidden['Y'] = $positionY; + $taskHidden[] = $hidden; + $dataTasks[] = $this->createTask($hidden); + $countHidden = $countHidden + 1; + $routeTransitions[$posT]['ID'] = G::generateUniqueID(); + $routeTransitions[$posT]['ROUTE'] = $from; + $routeTransitions[$posT]['FROM'] = $from; + $routeTransitions[$posT]['TO'] = $hidden['ID_TASK']; + $routeTransitions[$posT]['TOORFROM'] = 'TO'; + $routeTransitions[$posT]['ROU_TYPE'] = $typeRoute; + $routeTransitions[$posT]['CONDITION'] = ''; + $routeTransitions[$posT]['CONDITION_DIS'] = ''; + $routeTransitions[$posT]['TYPE_DIS'] = ''; + $posT = $posT + 1; + $from = $hidden['ID_TASK']; + $typeT = 'TO'; + $valueRoute = $value['0']; + $typeRoute = $value['1']; + $sequencial = 1; + } + } + } + if($sequencial == 0){ + foreach($aEvents as $id => $value){ + if($routes['TO'] == $value['0']){ + if($value['1']==='bpmnEventEndSignal' or $value['1']==='bpmnEventMessageEnd' ){ + $routes['TO'] = '-1'; + $dataRoutes[$numberRoutes]= $this->createRoute($routes); + $numberRoutes = $numberRoutes +1; + $isEnd = 1; + } + else{ + $isEventIntermediate = 1; + } + } + } + } + if($sequencial == 1){ + $routeTransitions[$posT]['ID'] = $idTransition; + $routeTransitions[$posT]['ROUTE'] = $valueRoute; + $routeTransitions[$posT]['FROM'] = $from; + $routeTransitions[$posT]['TO'] = $to; + $routeTransitions[$posT]['TOORFROM'] = $typeT; + $routeTransitions[$posT]['ROU_TYPE'] = $typeRoute; + $routeTransitions[$posT]['CONDITION'] = ''; + $routeTransitions[$posT]['CONDITION_DIS'] = ''; + $routeTransitions[$posT]['TYPE_DIS'] = ''; + $posT = $posT + 1; + $sequencial = 1; + } + if($isEnd == 0 and $sequencial == 0 and $isEventIntermediate == 0){ + $dataRoutes[$numberRoutes]= $this->createRoute($routes); + $numberRoutes = $numberRoutes +1; + } + } + foreach($routeTransitions as $id => $key){ + $typeRoute = $key['ROU_TYPE']; + switch($typeRoute){ + case 'bpmnGatewayExclusiveData': + $typePM = 'EVALUATE'; + break; + case 'bpmnGatewayInclusive': + $typePM = 'PARALLEL-BY-EVALUATION'; + break; + case 'bpmnGatewayExclusiveEvent': + $typePM = 'EVALUATE'; + break; + case 'bpmnGatewayComplex': + $typePM = 'DISCRIMINATOR'; + break; + case 'bpmnGatewayParallel': + $typePM = 'PARALLEL'; + break; + } + $routeTransitions[$id]['ROU_TYPE'] = $typePM; + } + $routes = $routeTransitions; + foreach($routeTransitions as $key => $id){ + $findTo = 0; + $findFrom = 0; + foreach ($dataTasks as $keyHidden => $value){ + if($id['FROM']== $value['TAS_UID']){ + $findFrom= 1; + } + if($id['TO']== $value['TAS_UID']){ + $findTo = 1; + } + } + if($findTo == 0){ + foreach($routes as $keyR => $idR){ + if($id['TO'] == $idR['ROUTE']){ + $routeTransitions[$key]['ROU_TYPE'] = $idR['ROU_TYPE']; + $routeTransitions[$key]['ROUTE'] = $id['TO']; + $routeTransitions[$key]['TOORFROM'] = 'TO'; + } + } + } + if($findFrom == 0){ + foreach($routes as $keyR => $idR){ + if($id['FROM'] == $idR['ROUTE']){ + $routeTransitions[$key]['ROU_TYPE'] = $idR['ROU_TYPE']; + $routeTransitions[$key]['ROUTE'] = $id['FROM']; + $routeTransitions[$key]['TOORFROM'] = 'FROM'; + } + } + } + } + $result['ROUTES'] = $dataRoutes; + $result['TRANSITIONS']= $routeTransitions; + $result['NUMBER'] = $numberRoutes; + $result['TASKS'] = $dataTasks; + $result['HIDDEN'] = $taskHidden; + return $result; + } + + /** + * This function convert the array events in a array with the events end + * @param object $aEvents + * @param string $idProcess + * @return array + */ + function convertArrayEnd($aEvents,$idProcess) + { + $result = array(); + $posEnd = 1; + $endArray = array(); + foreach($aEvents as $id => $value){ + if($value['1']==='bpmnEventEndSignal' or $value['1']==='bpmnEventMessageEnd'){ + $result['ID_PROCESS'] = $idProcess; + $result['ID_TASK'] = $value['0']; + $endArray[$posEnd] = $result; + $posEnd = $posEnd+1; + } + } + return $endArray; + } + + /** + * This function create transitions from the array transitions for the new processmap + * @param array $task + * @param array $routes + * @param array $events + * @param array $countEvents + * @param array $arrayRoutes + * @param array $countRoutes + * @return array + */ + function createTransitionsPM($tasks,$routes,$events,$countEvents,$arrayRoutes,$countRoutes) + { + $cont = 0 ; + $dataRoutes = ''; + $endEvent = 1 ; + $taskParallel = ''; + $routeParallel = ''; + $taskSecJoin = ''; + $routeSecJoin = ''; + $taskDiscriminator = ''; + $taskEvaluate = ''; + $routeEvaluate = ''; + $taskParallelEv = ''; + $routeParallelEv = ''; + $taskSelect = ''; + $routeSelect = ''; + $routeEnd = ''; + $arraySecJoin = array(); + $position = 0; + $fillColor = ''; + $transitions = ''; + $arrayGateways = array(); + $countG = 0; + foreach ($routes as $key => $row) { + if($row['ROU_TYPE'] == 'SEC-JOIN'){ + $arraySecJoin[$position] = array(); + $arraySecJoin[$position] = $row; + $position = $position + 1; + unset($routes[$key]); + } + } + $aux = $arraySecJoin ; + foreach ($arraySecJoin as $key => $row) { + $aux[$key]= $row['ROU_NEXT_TASK']; + } + if(sizeof($arraySecJoin) > 0){ + array_multisort($aux,SORT_ASC,$arraySecJoin); + unset($aux); + } + foreach ($routes as $key => $row) { + $uid[$key] = $row['TAS_UID']; + $case[$key] = $row['ROU_CASE']; + } + if(sizeof($routes) > 0){ + array_multisort($uid, SORT_ASC, $case, SORT_ASC, $routes); + } + $routes = array_merge($routes,$arraySecJoin); + foreach ($routes as $key => $val ) { + $end = 0; + $idRoute = $val['ROU_UID']; + $idTask = $val['TAS_UID']; + $nextTask = $val['ROU_NEXT_TASK']; + $condition = htmlentities($val['ROU_CONDITION']); + $toPort = $val['ROU_TO_PORT']; + $fromPort = $val['ROU_FROM_PORT']; + //If End Event + if($nextTask == "-1"){ + $end=1; + } + $typeRoute = $val['ROU_TYPE']; + $route = ''; + if ($typeRoute != "SEQUENTIAL" ){ + switch($typeRoute){ + case 'PARALLEL': + $coordinateX=0; + $coordinateY=0; + foreach ($tasks as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$idTask){ + $coordinateX=$idVal['TAS_POSX']; + $coordinateY=$idVal['TAS_POSY']; + } + } + $positionX=$coordinateX+35; + $positionY=$coordinateY+85; + if($idTask != $taskParallel){ + $taskParallel = $idTask; + $routeParallel = $idRoute; + $arrayGateways[$countG]['0'] = $routeParallel; + $arrayGateways[$countG]['1'] = 'bpmnGatewayParallel'; + $arrayGateways[$countG]['2'] = $positionX; + $arrayGateways[$countG]['3'] = $positionY; + $countG = $countG + 1; + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $taskParallel; + $arrayRoutes[$countRoutes]['2']= $routeParallel; + $arrayRoutes[$countRoutes]['3']= '1'; + $arrayRoutes[$countRoutes]['4']= '2'; + $countRoutes = $countRoutes + 1; + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $routeParallel; + $arrayRoutes[$countRoutes]['2']= $nextTask; + $arrayRoutes[$countRoutes]['3']= '1'; + $arrayRoutes[$countRoutes]['4']= '2'; + $countRoutes = $countRoutes + 1; + } + else{ + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $routeParallel; + $arrayRoutes[$countRoutes]['2']= $nextTask; + $arrayRoutes[$countRoutes]['3']= '1'; + $arrayRoutes[$countRoutes]['4']= '2'; + $countRoutes = $countRoutes + 1; + } + break; + case 'SEC-JOIN': + $coordinateX=0; + $coordinateY=0; + foreach ($tasks as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$nextTask){ + $coordinateX=$idVal['TAS_POSX']; + $coordinateY=$idVal['TAS_POSY']; + } + } + $positionX=$coordinateX+60; + $positionY=$coordinateY-45; + if($nextTask != $taskSecJoin){ + $taskSecJoin = $nextTask; + $routeSecJoin = $idRoute; + $arrayGateways[$countG]['0'] = $routeSecJoin; + $arrayGateways[$countG]['1'] = 'bpmnGatewayParallel'; + $arrayGateways[$countG]['2'] = $positionX; + $arrayGateways[$countG]['3'] = $positionY; + $countG = $countG + 1; + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $routeSecJoin; + $arrayRoutes[$countRoutes]['2']= $taskSecJoin; + $arrayRoutes[$countRoutes]['3']= '1'; + $arrayRoutes[$countRoutes]['4']= '2'; + $countRoutes = $countRoutes + 1; + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $idTask; + $arrayRoutes[$countRoutes]['2']= $routeSecJoin; + $arrayRoutes[$countRoutes]['3']= '1'; + $arrayRoutes[$countRoutes]['4']= '2'; + $countRoutes = $countRoutes + 1; + } + else{ + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $idTask; + $arrayRoutes[$countRoutes]['2']= $routeSecJoin; + $arrayRoutes[$countRoutes]['3']= '1'; + $arrayRoutes[$countRoutes]['4']= '2'; + $countRoutes = $countRoutes + 1; + } + break; + case 'EVALUATE': + $coordinateX=0; + $coordinateY=0; + foreach ($tasks as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$idTask){ + $coordinateX=$idVal['TAS_POSX']; + $coordinateY=$idVal['TAS_POSY']; + } + } + $positionX=$coordinateX+35; + $positionY=$coordinateY+85; + if($idTask != $taskEvaluate){ + $taskEvaluate = $idTask; + $routeEvaluate = $idRoute; + if($nextTask != "-1"){ + $arrayGateways[$countG]['0'] = $routeEvaluate; + $arrayGateways[$countG]['1'] = 'bpmnGatewayExclusiveData'; + $arrayGateways[$countG]['2'] = $positionX; + $arrayGateways[$countG]['3'] = $positionY; + $countG = $countG + 1; + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $taskEvaluate; + $arrayRoutes[$countRoutes]['2']= $routeEvaluate; + $arrayRoutes[$countRoutes]['3']= '1'; + $arrayRoutes[$countRoutes]['4']= '2'; + $countRoutes = $countRoutes + 1; + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $routeEvaluate; + $arrayRoutes[$countRoutes]['2']= $nextTask; + $arrayRoutes[$countRoutes]['3']= '1'; + $arrayRoutes[$countRoutes]['4']= '2'; + $countRoutes = $countRoutes + 1; + } + } + else{ + if($nextTask !="-1"){ + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $routeEvaluate; + $arrayRoutes[$countRoutes]['2']= $nextTask; + $arrayRoutes[$countRoutes]['3']= '1'; + $arrayRoutes[$countRoutes]['4']= '2'; + $countRoutes = $countRoutes + 1; + } + else{ + $routeEnd = $routeEvaluate; + } + } + break; + case 'PARALLEL-BY-EVALUATION': + $coordinateX=0; + $coordinateY=0; + foreach ($tasks as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$idTask){ + $coordinateX = $idVal['TAS_POSX']; + $coordinateY = $idVal['TAS_POSY']; + } + } + $positionX=$coordinateX+60; + $positionY=$coordinateY+40; + if($idTask != $taskParallelEv){ + $taskParallelEv = $idTask; + $routeParallelEv = $idRoute; + $arrayGateways[$countG]['0'] = $routeParallelEv; + $arrayGateways[$countG]['1'] = 'bpmnGatewayInclusive'; + $arrayGateways[$countG]['2'] = $positionX; + $arrayGateways[$countG]['3'] = $positionY; + $countG = $countG + 1; + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $taskParallelEv; + $arrayRoutes[$countRoutes]['2']= $routeParallelEv; + $arrayRoutes[$countRoutes]['3']= '1'; + $arrayRoutes[$countRoutes]['4']= '2'; + $countRoutes = $countRoutes + 1; + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $routeParallelEv; + $arrayRoutes[$countRoutes]['2']= $nextTask; + $arrayRoutes[$countRoutes]['3']= '1'; + $arrayRoutes[$countRoutes]['4']= '2'; + $countRoutes = $countRoutes + 1; + } + else{ + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $routeParallelEv; + $arrayRoutes[$countRoutes]['2']= $nextTask; + $arrayRoutes[$countRoutes]['3']= '1'; + $arrayRoutes[$countRoutes]['4']= '2'; + $countRoutes = $countRoutes + 1; + } + break; + case 'SELECT': + $coordinateX=0; + $coordinateY=0; + foreach ($tasks as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$idTask){ + $coordinateX=$idVal['TAS_POSX']; + $coordinateY=$idVal['TAS_POSY']; + } + } + $positionX=$coordinateX+60; + $positionY=$coordinateY+40; + if($idTask != $taskSelect){ + $taskSelect = $idTask; + $routeSelect = $idRoute; + $arrayGateways[$countG]['0'] = $routeSelect; + $arrayGateways[$countG]['1'] = 'bpmnGatewayExclusiveData'; + $arrayGateways[$countG]['2'] = $positionX; + $arrayGateways[$countG]['3'] = $positionY; + $countG = $countG + 1; + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $taskSelect; + $arrayRoutes[$countRoutes]['2']= $routeSelect; + $arrayRoutes[$countRoutes]['3']= '1'; + $arrayRoutes[$countRoutes]['4']= '2'; + $countRoutes = $countRoutes + 1; + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $routeSelect; + $arrayRoutes[$countRoutes]['2']= $nextTask; + $arrayRoutes[$countRoutes]['3']= '1'; + $arrayRoutes[$countRoutes]['4']= '2'; + $countRoutes = $countRoutes + 1; + } + else{ + if($nextTask !="-1"){ + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $routeSelect; + $arrayRoutes[$countRoutes]['2']= $nextTask; + $arrayRoutes[$countRoutes]['3']= '1'; + $arrayRoutes[$countRoutes]['4']= '2'; + $countRoutes = $countRoutes + 1; + } + else{ + $routeEnd = $routeSelect; + } + } + break; + case 'DISCRIMINATOR': + $coordinateX = 0; + $coordinateY = 0; + $optional = $val['ROU_OPTIONAL']; + foreach ($tasks as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$nextTask){ + $coordinateX=$idVal['TAS_POSX']; + $coordinateY=$idVal['TAS_POSY']; + } + } + $positionX=$coordinateX+60; + $positionY=$coordinateY-45; + if($nextTask != $taskDiscriminator){ + $taskDiscriminator = $nextTask; + $routeDiscriminator = $idRoute; + $arrayGateways[$countG]['0'] = $routeDiscriminator; + $arrayGateways[$countG]['1'] = 'bpmnGatewayComplex'; + $arrayGateways[$countG]['2'] = $positionX; + $arrayGateways[$countG]['3'] = $positionY; + $countG = $countG + 1; + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $routeDiscriminator; + $arrayRoutes[$countRoutes]['2']= $taskDiscriminator; + $arrayRoutes[$countRoutes]['3']= '1'; + $arrayRoutes[$countRoutes]['4']= '2'; + $countRoutes = $countRoutes + 1; + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $idTask; + $arrayRoutes[$countRoutes]['2']= $routeDiscriminator; + $arrayRoutes[$countRoutes]['3']= '1'; + $arrayRoutes[$countRoutes]['4']= '2'; + $countRoutes = $countRoutes + 1; + } + else{ + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $idTask; + $arrayRoutes[$countRoutes]['2']= $routeDiscriminator; + $arrayRoutes[$countRoutes]['3']= '1'; + $arrayRoutes[$countRoutes]['4']= '2'; + $countRoutes = $countRoutes + 1; + } + break; + } + } + if($end==1){ + if($typeRoute == "SEQUENTIAL"){ + $coordinateX=0; + $coordinateY=0; + foreach ($tasks as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$idTask){ + $coordinateX=$idVal['TAS_POSX']; + $coordinateY=$idVal['TAS_POSY']; + } + } + $positionX = $coordinateX+65; + $positionY = $coordinateY+40; + //$arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['0']= $idRoute; + $arrayRoutes[$countRoutes]['1']= $idTask; + $arrayRoutes[$countRoutes]['2']= $nextTask; + $arrayRoutes[$countRoutes]['3']= $toPort; + $arrayRoutes[$countRoutes]['4']= $fromPort; + $countRoutes = $countRoutes + 1; + } + else{ + $coordinateX=0; + $coordinateY=0; + foreach ($tasks as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$idTask){ + $coordinateX=$idVal['TAS_POSX']; + $coordinateY=$idVal['TAS_POSY']; + } + } + $positionX = $coordinateX + 120; + $positionY = $coordinateY + 40; + $idTask = $routeEnd; + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $idTask; + $arrayRoutes[$countRoutes]['2']= $idRoute; + $arrayRoutes[$countRoutes]['3']= $toPort; + $arrayRoutes[$countRoutes]['4']= $fromPort; + $countRoutes = $countRoutes + 1; + } + $events[$countEvents]['0'] = $idRoute; + $events[$countEvents]['1'] = 'bpmnEventEmptyEnd'; + $events[$countEvents]['2'] = $positionX-25; + $events[$countEvents]['3'] = $positionY+35; + $countEvents = $countEvents + 1; + $end = 0; + $endEvent = 0; + } + else{ + if ($typeRoute == "SEQUENTIAL"){ + //Will Check for Intermediate Timer + $evn_uid = $val['ROU_EVN_UID']; + if($evn_uid != '') + { + $coordinateX=0; + $coordinateY=0; + foreach ($tasks as $taskVal => $idVal ){ + if($idVal['TAS_UID']==$idTask){ + $coordinateX=$idVal['TAS_POSX']; + $coordinateY=$idVal['TAS_POSY']; + } + } + $positionX = $coordinateX + 65; + $positionY = $coordinateY + 40; + + $oEvent = new Event(); + $aEvent = $oEvent->load($evn_uid); + $events[$countEvents]['0'] = $evn_uid; + $events[$countEvents]['1'] = $aEvent['EVN_TYPE']; + $events[$countEvents]['2'] = $positionX-25; + $events[$countEvents]['3'] = $positionY+35; + $countEvents = $countEvents + 1; + + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $idTask; + $arrayRoutes[$countRoutes]['2']= $evn_uid; + $arrayRoutes[$countRoutes]['3']= '1'; + $arrayRoutes[$countRoutes]['4']= '2'; + $countRoutes = $countRoutes + 1; + $arrayRoutes[$countRoutes]['0']= G::generateUniqueID(); + $arrayRoutes[$countRoutes]['1']= $evn_uid; + $arrayRoutes[$countRoutes]['2']= $nextTask; + $arrayRoutes[$countRoutes]['3']= '1'; + $arrayRoutes[$countRoutes]['4']= '2'; + $countRoutes = $countRoutes + 1; + } + else + { + $arrayRoutes[$countRoutes]['0']= $idRoute; + $arrayRoutes[$countRoutes]['1']= $idTask; + $arrayRoutes[$countRoutes]['2']= $nextTask; + $arrayRoutes[$countRoutes]['3']= $toPort; + $arrayRoutes[$countRoutes]['4']= $fromPort; + $countRoutes = $countRoutes + 1; + } + } + } + } + $data = array(); + $data['GATEWAYS'] = $arrayGateways; + $data['TRANSITION'] = $arrayRoutes; + $data['EVENTS'] = $events; + return $data; + } + + /** + * This function Removes duplicate values from an array bi-dimensional + * @param array $array + * @return array + */ + function super_unique($array) + { + $result = array_map("unserialize", array_unique(array_map("serialize", $array))); + foreach ($result as $key => $value){ + if ( is_array($value) ){ + $result[$key] = $this->super_unique($value); + } + } + return $result; + } + + /** + * This function create a array for open the process in the new processmap + * @param array $array + * @return array + */ + function createProcessPM($array) + { + $result = array(); + $result['0'] = $array['PRO_UID']; + $result['1'] = $array['PRO_TITLE']; + $result['2'] = $array['PRO_DESCRIPTION']; + return $result; + } + /** + * This function creates an array for the lane that will be created according to the data given in an array + * @param array $lanes + * @return array $lane + */ + function createSubProcessesPM($array) + { + $arrayLanes = array(); + $field = array(); + foreach ($array as $key=> $value){ + + $field['0'] = $value['SWI_UID']; + $field['1'] = $value['SWI_TEXT']; + $field['2'] = $value['SWI_X']; + $field['3'] = $value['SWI_Y']; + $field['4'] = '';//$value['SWI_WIDTH']; + $field['5'] = '';//$value['SWI_HEIGHT']; + } + return $arrayLanes; + } + + /** + * This function creates an array for the lane that will be created according to the data given in an array + * @param array $lanes + * @return array $lane + */ + function saveWebEntry($array) + { + $file = new DOMDocument(); + foreach($array as $key => $value){ + $link = $value->W_LINK; + $link = split('>',$link); + $link = split('<',$link[2]); + $link = $link['0']; + $uid = $value->W_PRO_UID; + $name = $value->W_FILENAME; + } + } + +} \ No newline at end of file diff --git a/workflow/engine/methods/bpmn/processmap.php b/workflow/engine/methods/bpmn/processmap.php index 4881b2883..4ea3366a3 100755 --- a/workflow/engine/methods/bpmn/processmap.php +++ b/workflow/engine/methods/bpmn/processmap.php @@ -2,8 +2,6 @@ $oHeadPublisher =& headPublisher::getSingleton(); //$oHeadPublisher->setExtSkin( 'xtheme-gray'); - $oHeadPublisher->usingExtJs('ux/RowEditor'); - $oHeadPublisher->addExtJsScript('bpmn/bpmnZoom',true); $oHeadPublisher->addExtJsScript('bpmn/MyWorkflow',true ); //adding a javascript file .js $oHeadPublisher->addExtJsScript('bpmn/pmosExt', true ); //adding a javascript file .js $oHeadPublisher->addExtJsScript('bpmn/TaskContext', true ); //adding a javascript file .js diff --git a/workflow/engine/templates/bpmn/Annotation.js b/workflow/engine/templates/bpmn/Annotation.js index f7ff2cee0..f83e2ca05 100755 --- a/workflow/engine/templates/bpmn/Annotation.js +++ b/workflow/engine/templates/bpmn/Annotation.js @@ -77,17 +77,17 @@ bpmnAnnotation.prototype.paint = function () { */ /* New object is created to implement changing of Text functionality */ - var bpmnText = new jsGraphics(this.id); + this.bpmnText = new jsGraphics(this.id); var padleft = 0.10*this.getWidth(); var padtop = 0.18*this.getHeight(); var rectwidth = this.getWidth() - padleft; var rectheight = this.getHeight() - 2*padtop; - bpmnText.drawStringRect(this.annotationName,0,padtop,rectwidth,rectheight,'center'); + this.bpmnText.setFont('verdana', '11px', Font.PLAIN); + this.bpmnText.drawStringRect(this.annotationName,0,padtop,rectwidth,rectheight,'center'); //bpmnText.drawStringRect(this.taskName,this.getWidth()/2-20,this.getHeight()/2-11,200,'left'); //tempcoord = this.coord_converter(this.getWidth(), this.getHeight(), this.taskName.length); //bpmnText.drawTextString(this.taskName, this.getWidth(), this.getHeight(), tempcoord.temp_x, tempcoord.temp_y); - bpmnText.paint(); - this.bpmnNewText = bpmnText; + this.bpmnText.paint(); if(this.input1!=null){ this.input1.setPosition(0,this.height/2); @@ -161,7 +161,7 @@ bpmnAnnotation.prototype.onDoubleClick = function () { * The string is first cleared and new string is painted.

**/ bpmnAnnotationDialog.prototype.onOk = function () { - this.figure.bpmnNewText.clear(); + this.figure.bpmnText.clear(); len = Math.ceil(this.input.value.length/16); if(this.input.value.length < 19) @@ -175,9 +175,9 @@ bpmnAnnotation.prototype.onDoubleClick = function () { else this.figure.rectWidth = 150; //tempcoord = this.workflow.currentSelection.coord_converter(this.workflow.currentSelection.width, this.workflow.currentSelection.height, this.input.value.length) - this.figure.bpmnNewText.drawStringRect(this.input.value,20,20,this.figure.rectWidth,'left'); + this.figure.bpmnText.drawStringRect(this.input.value,20,20,this.figure.rectWidth,'left'); // this.figure.bpmnNewText.drawTextString(this.input.value, this.workflow.currentSelection.width, this.workflow.currentSelection.height, tempcoord.temp_x, tempcoord.temp_y); - this.figure.bpmnNewText.paint(); + this.figure.bpmnText.paint(); this.figure.annotationName = this.input.value; //Set Updated Text value //Updating Annotation Text Async into the DB diff --git a/workflow/engine/templates/bpmn/bpmnShapes.js b/workflow/engine/templates/bpmn/bpmnShapes.js index 37e49d433..4255620c9 100755 --- a/workflow/engine/templates/bpmn/bpmnShapes.js +++ b/workflow/engine/templates/bpmn/bpmnShapes.js @@ -70,7 +70,7 @@ bpmnTask.prototype.paint = function () { /* Created New Object of jsGraphics to draw String. * New object is created to implement changing of Text functionality */ - bpmnText = new jsGraphics(this.id); + this.bpmnText = new jsGraphics(this.id); /*if(this.taskName.length <= 17) { @@ -101,8 +101,8 @@ bpmnTask.prototype.paint = function () { } var rectheight = this.getHeight() - padtop -7; - - bpmnText.drawStringRect(this.taskName, padleft, padtop, this.rectWidth, rectheight, 'center'); + this.bpmnText.setFont('verdana', '11px', Font.PLAIN); + this.bpmnText.drawStringRect(this.taskName, padleft, padtop, this.rectWidth, rectheight, 'center'); // tempcoord = this.coord_converter(this.getWidth(), this.getHeight(), this.taskName.length); // bpmnText.drawTextString(this.taskName, this.getWidth(), this.getHeight(), tempcoord.temp_x, tempcoord.temp_y); @@ -153,13 +153,13 @@ bpmnTask.prototype.paint = function () { boundaryTimer.drawLine(x[3]-x[3]/1.08+5,y[5]+4,x[3]-x[3]/1.08+8,y[5]+4); //45th min line boundaryTimer.drawLine(x[3]-x[3]/1.08+8,y[5]-4,x[3]-x[3]/1.08+11,y[5]-1); //50th min line boundaryTimer.drawLine(x[3]-x[3]/1.08+15,y[5]-7,x[3]-x[3]/1.08+15,y[5]-4); //60th min line - + if(this.boundaryEvent == true) boundaryTimer.paint(); /**************************** Drawing Timer Boundary event ends here *******************************/ - bpmnText.paint(); - this.bpmnNewText = bpmnText; + this.bpmnText.paint(); + //this.bpmnNewText = this.bpmnText; /*Code Added to Dynamically shift Ports on resizing of shapes **/ @@ -185,7 +185,7 @@ jsGraphics.prototype.drawTextString = function (txt, x, y, dx, dy) { /*Workflow.prototype.onMouseUp=function(x,y){ //Saving Task/Annotations position on Async Ajax call - + this.dragging=false; this.draggingLine=null; };*/ @@ -278,7 +278,7 @@ InputPort.prototype.onDrop = function (port) { newObj.sPortType =port.properties.name; preObj.sPortType =this.properties.name; this.workflow.saveRoute(preObj,newObj); - + var _3f02 = new CommandConnect(this.parentNode.workflow, port, this); if (_3f02.source.type == _3f02.target.type) { return; @@ -302,7 +302,7 @@ OutputPort.prototype.onDrop = function (port) { if (this.parentNode.id == port.parentNode.id || connect == false) { - + } else { var _4070 = new CommandConnect(this.parentNode.workflow, this, port); if (_4070.source.type == _4070.target.type) { @@ -344,7 +344,7 @@ OutputPort.prototype.onDrop = function (port) { } else if(bpmnType.match(/Task/) && port.parentNode.type.match(/Task/)) { - + var preObj = this.workflow.currentSelection; var newObj = port.parentNode; newObj.conn = _4070.connection; @@ -572,8 +572,8 @@ FlowMenu.prototype.onOtherFigureMoved = function (_39fd) { //@params - max X pos(canvas Width) = 918 //@params - max Y pos(canvas Height) = 837 /////////////////////////////////////////// - - + + //Preventing Task from drawing outside canvas Code Ends here if (_39fd.type == 'DecoratedConnection' || _39fd.workflow.contextClicked == true) { this.removechild(this.actionAdd); @@ -732,8 +732,8 @@ bpmnTask.prototype.addShapes = function (_3896) { //Assigning values to newShape Object for Saving Task automatically (Async Ajax Call) newShape.x = xOffset; newShape.y = yOffset; - - + + var conn = new DecoratedConnection(); @@ -917,7 +917,7 @@ bpmnTask.prototype.trim = function (str) { * The string is first cleared and new string is painted.

**/ bpmnTaskDialog.prototype.onOk = function () { - this.figure.bpmnNewText.clear(); + this.figure.bpmnText.clear(); //len = Math.ceil(this.input.value.length/16); var len = this.workflow.currentSelection.width / 18; if (len >= 6) { @@ -952,9 +952,10 @@ bpmnTaskDialog.prototype.onOk = function () { //tempcoord = this.workflow.currentSelection.coord_converter(this.workflow.currentSelection.width, this.workflow.currentSelection.height, this.input.value.length) - this.figure.bpmnNewText.drawStringRect(this.input.value, padleft, padtop, this.figure.rectWidth, rectheight, 'center'); + this.figure.bpmnText.setFont('verdana', '11px', Font.PLAIN); + this.figure.bpmnText.drawStringRect(this.input.value, padleft, padtop, this.figure.rectWidth, rectheight, 'center'); // this.figure.bpmnNewText.drawTextString(this.input.value, this.workflow.currentSelection.width, this.workflow.currentSelection.height, tempcoord.temp_x, tempcoord.temp_y); - this.figure.bpmnNewText.paint(); + this.figure.bpmnText.paint(); this.workflow.currentSelection.taskName = this.input.value; //Set Updated Text value //Saving task name (whenever updated) onAsynch AJAX call this.figure.actiontype = 'updateTaskName'; diff --git a/workflow/engine/templates/bpmn/processmap.js b/workflow/engine/templates/bpmn/processmap.js index b2ab87c89..79bbb7d1e 100755 --- a/workflow/engine/templates/bpmn/processmap.js +++ b/workflow/engine/templates/bpmn/processmap.js @@ -155,7 +155,7 @@ Ext.onReady ( function() { workflow.getCommandStack().redo(); } }, - + { xtype: 'tbsplit', text: 'Process', @@ -167,8 +167,8 @@ Ext.onReady ( function() { } }, {text: 'Input Document'},{text: 'Output Document'},{text: 'Trigger'},{text: 'Report Table'},{text: 'Database Connection'},{text: 'Cases Scheduler'}] - }) - + }) + }, { text:'Zoom In', @@ -178,19 +178,56 @@ Ext.onReady ( function() { var fig = figures.get(f); var width = fig.getWidth(); var height = fig.getHeight(); - fig.setDimension(width+10,height+10); + fig.setDimension(width+20,height+20); + if(fig.type == 'bpmnTask') + { + fig.bpmnText.clear(); + //len = Math.ceil(this.input.value.length/16); + var len = fig.width / 18; + if (len >= 6) { + // len = 1.5; + var padleft = 0.12 * fig.width; + var padtop = 0.32 * fig.height - 3; + fig.rectWidth = fig.width - 2 * padleft; + } + else { + padleft = 0.1 * fig.width; + padtop = 0.09 * fig.height - 3; + fig.rectWidth = fig.width - 2 * padleft; + } + var rectheight = fig.height - 2*padtop; + if(typeof fig.size == 'undefined') + fig.size = fig.bpmnText.ftSz.substr(0,fig.bpmnText.ftSz.length-2); + else + fig.size = parseInt(fig.size) + 4; + eval("fig.bpmnText.setFont('verdana','"+fig.size+"px', Font.PLAIN)"); + fig.bpmnText.drawStringRect(fig.taskName, padleft, padtop, fig.rectWidth, rectheight, 'center'); + fig.bpmnText.paint(); + } + else if(fig.type == 'bpmnAnnotation') + { + fig.bpmnText.clear(); + var text = fig.annotationName; + len = Math.ceil(text.length/16); + if(text.length < 19) + { + len = 1.5; + if(text.length > 9) + fig.rectWidth = text.length*8; + else + fig.rectWidth = 48; + } + else + fig.rectWidth = 150; + if(typeof fig.size == 'undefined') + fig.size = fig.bpmnText.ftSz.substr(0,fig.bpmnText.ftSz.length-2); + else + fig.size = parseInt(fig.size) + 4; + eval("fig.bpmnText.setFont('verdana','"+fig.size+"px', Font.PLAIN)"); + fig.bpmnText.drawStringRect(text,20,20,fig.rectWidth,'left'); + fig.bpmnText.paint(); + } } -// var lines = workflow.getDocument().getLines(); -// for(l = 0;l