saving Standalone Gateways

This commit is contained in:
girish
2011-02-12 13:04:17 +00:00
parent 4ccf2c140a
commit c06e253974
5 changed files with 133 additions and 53 deletions

View File

@@ -1439,6 +1439,37 @@ class processMap {
} }
} }
/*
* Add a gateway
* @param string $sProcessUID
* @param string $sGatewayUID
* @return boolean
*/
function addGateway($oData) {
try {
$oGateway = new Gateway ( );
$aData = array();
$aData['PRO_UID'] = $oData->pro_uid;
$aData['GAT_X'] = $oData->position->x;
$aData['GAT_Y'] = $oData->position->y;
$aData['GAT_TYPE'] = $oData->gat_type;
$sGat_uid = $oData->gat_uid;
$oGatewayData = GatewayPeer::retrieveByPK($sGat_uid);
if (is_null($oGatewayData)) {
$sGat_uid = $oGateway->create($aData);
}else{
$aData['GAT_UID'] = $sGat_uid;
$oGateway->update($aData);
}
$oEncode->uid = $sGat_uid;
$oJSON = new Services_JSON ( );
return $oJSON->encode($oEncode);
} catch (Exception $oError) {
throw ($oError);
}
}
/* /*
* Add a new guide * Add a new guide
* @param string $sProcessUID * @param string $sProcessUID
@@ -6349,9 +6380,9 @@ function saveExtddEvents($oData)
$oEvent->update($aData); $oEvent->update($aData);
} }
} }
$oNewTask->uid = $sEvn_uid; $oEncode->uid = $sEvn_uid;
$oJSON = new Services_JSON ( ); $oJSON = new Services_JSON ( );
return $oJSON->encode($oNewTask); return $oJSON->encode($oEncode);
} }

View File

@@ -102,6 +102,18 @@
} }
$lanes = $oProcess->createLanesNewPM($oData->lanes); $lanes = $oProcess->createLanesNewPM($oData->lanes);
$fields = $oProcess->createTransitionsPM($oData->tasks,$oData->routes,$arrayEvents,$count,$arrayRoutes,$countRoutes); $fields = $oProcess->createTransitionsPM($oData->tasks,$oData->routes,$arrayEvents,$count,$arrayRoutes,$countRoutes);
//Get all the standalone Gateway
$countGateway = count($fields['GATEWAYS']);
foreach($oData->gateways as $id => $value)
{
if($value['GAT_NEXT_TASK'] == '' && $value['TAS_UID'] == ''){
$fields['GATEWAYS'][$countGateway]['0'] = $value['GAT_UID'];
$fields['GATEWAYS'][$countGateway]['1'] = $value['GAT_TYPE'];
$fields['GATEWAYS'][$countGateway]['2'] = $value['GAT_X'];
$fields['GATEWAYS'][$countGateway]['3'] = $value['GAT_Y'];
}
}
//$subProcess = $oProcess->createSubProcessesPM($oData->subProcess); //$subProcess = $oProcess->createSubProcessesPM($oData->subProcess);
$arrayEvents = $fields['EVENTS']; $arrayEvents = $fields['EVENTS'];
$arrayGateways = $fields['GATEWAYS']; $arrayGateways = $fields['GATEWAYS'];

View File

@@ -77,6 +77,10 @@ if ( isset ($_REQUEST['action']) ) {
$sOutput = $oProcessMap->deleteTask($oData->tas_uid); $sOutput = $oProcessMap->deleteTask($oData->tas_uid);
echo $sOutput; echo $sOutput;
break; break;
case 'addGateway':
$sOutput = $oProcessMap->addGateway($oData);
echo $sOutput;
break;
case 'deleteGateway': case 'deleteGateway':
$sOutput = $oProcessMap->deleteGateway($oData->pro_uid, $oData->gat_uid); $sOutput = $oProcessMap->deleteGateway($oData->pro_uid, $oData->gat_uid);
echo $sOutput; echo $sOutput;

View File

@@ -389,34 +389,27 @@ MyWorkflow.prototype.toggleShapes=function(item)
var x =item.scope.workflow.currentSelection.getX(); //Get x co-ordinate from figure var x =item.scope.workflow.currentSelection.getX(); //Get x co-ordinate from figure
var y =item.scope.workflow.currentSelection.getY(); //Get y co-ordinate from figure var y =item.scope.workflow.currentSelection.getY(); //Get y co-ordinate from figure
if(item.type == 'bpmnEventBoundaryTimerInter') if(item.type == 'bpmnEventBoundaryTimerInter'){
{
workflow.currentSelection.boundaryEvent = true; workflow.currentSelection.boundaryEvent = true;
workflow.taskName = oldWorkflow.taskName; workflow.taskName = oldWorkflow.taskName;
var newShape = workflow.currentSelection; var newShape = workflow.currentSelection;
newShape.setDimension(newShape.getWidth(),newShape.getHeight()); newShape.setDimension(newShape.getWidth(),newShape.getHeight());
} }
else if(item.type == 'bpmnSubProcess') else if(item.type == 'bpmnSubProcess'){
{
workflow.subProcessName = 'Sub Process'; workflow.subProcessName = 'Sub Process';
newShape = eval("new "+item.type+"(this.workflow)"); newShape = eval("new "+item.type+"(this.workflow)");
} }
else else
newShape = eval("new "+item.type+"(this.workflow)"); newShape = eval("new "+item.type+"(this.workflow)");
if(item.type != 'bpmnEventBoundaryTimerInter') if(item.type != 'bpmnEventBoundaryTimerInter'){
{
this.workflow.addFigure(newShape,x,y); //Add New Selected Shape First this.workflow.addFigure(newShape,x,y); //Add New Selected Shape First
//Delete Old Shape //Delete Old Shape
item.scope.workflow.getCommandStack().execute(new CommandDelete(oldWorkflow)); item.scope.workflow.getCommandStack().execute(new CommandDelete(oldWorkflow));
ToolGeneric.prototype.execute.call(item.scope); ToolGeneric.prototype.execute.call(item.scope);
//to create all the new connections again
//to create all the new connections again
var connObj; var connObj;
for(i=0 ; i < countConn ; i++) for(i=0 ; i < countConn ; i++){
{
if(sourcePortId[i] == shapeId) //If shapeId is equal to sourceId the , replace the oldShape object by new shape Object if(sourcePortId[i] == shapeId) //If shapeId is equal to sourceId the , replace the oldShape object by new shape Object
sourceNode[i] = newShape; sourceNode[i] = newShape;
else else
@@ -428,14 +421,12 @@ MyWorkflow.prototype.toggleShapes=function(item)
newShape.workflow.addFigure(connObj); newShape.workflow.addFigure(connObj);
} }
} }
newShape.mode = 'ddEvent'; //Saving Asynchronously deleted shape and new created shape into DB
//Saving Asynchronously deleted shape and new created shape into DB if(item.type.match(/Boundary/)){
if(item.type.match(/Boundary/))
{
newShape.actiontype = 'updateTask'; newShape.actiontype = 'updateTask';
workflow.saveShape(newShape); workflow.saveShape(newShape);
} }
/*if(newShape.type.match(/Event/) && newShape.type.match(/Inter/) && !item.type.match(/Boundary/)) /*if(newShape.type.match(/Event/) && newShape.type.match(/Inter/) && !item.type.match(/Boundary/))
{ {
newShape.actiontype = 'updateEvent'; newShape.actiontype = 'updateEvent';
//Set the Old Id to the Newly created Event //Set the Old Id to the Newly created Event
@@ -443,13 +434,43 @@ MyWorkflow.prototype.toggleShapes=function(item)
newShape.id = oldWorkflow.id; newShape.id = oldWorkflow.id;
newShape.workflow.saveShape(newShape); newShape.workflow.saveShape(newShape);
}*/ }*/
if(newShape.type.match(/Event/) && !item.type.match(/Boundary/)) if(newShape.type.match(/Event/) && !item.type.match(/Boundary/)){
{ newShape.mode = 'ddEvent';
newShape.actiontype = 'addEvent'; newShape.actiontype = 'addEvent';
//Set the Old Id to the Newly created Event //Set the Old Id to the Newly created Event
newShape.html.id = oldWorkflow.id; newShape.html.id = oldWorkflow.id;
newShape.id = oldWorkflow.id; newShape.id = oldWorkflow.id;
newShape.workflow.saveShape(newShape); newShape.workflow.saveShape(newShape);
}
if(newShape.type.match(/Gateway/)){
var ports = newShape.getPorts();
var len =ports.data.length;
var conn = new Array();
for(var i=0; i<=len; i++){
if(typeof ports.data[i] === 'object')
conn[i] = ports.data[i].getConnections();
}
var countConn = 0
//Get ALL the connections for the specified PORT
for(i = 0; i< conn.length ; i++){
if(typeof conn[i] != 'undefined')
for(var j = 0; j < conn[i].data.length ; j++){
if(typeof conn[i].data[j] != 'undefined'){
countConn++;
}
}
}
if(countConn == 0){
newShape.mode = 'ddGateway';
newShape.actiontype = 'addGateway';
//Set the Old Id to the Newly created Gateway
newShape.html.id = oldWorkflow.id;
newShape.id = oldWorkflow.id;
newShape.workflow.saveShape(newShape);
}
else
newShape.mode = 'update';
} }
/* if(newShape.type == 'bpmnEventMessageStart' || newShape.type == 'bpmnEventTimerStart') /* if(newShape.type == 'bpmnEventMessageStart' || newShape.type == 'bpmnEventTimerStart')
{ {
@@ -476,30 +497,27 @@ MyWorkflow.prototype.toggleShapes=function(item)
newShape.workflow.saveShape(newShape); newShape.workflow.saveShape(newShape);
} }
}*/ }*/
else if(newShape.type.match(/Gateway/)) else if(newShape.type.match(/Gateway/)){
{ if(newShape.mode == 'update'){
var shape = new Array(); var shape = new Array();
shape.type = ''; shape.type = '';
newShape.workflow.saveRoute(newShape,shape); newShape.workflow.saveRoute(newShape,shape);
} }
}
//Swapping from Task to subprocess and vice -versa //Swapping from Task to subprocess and vice -versa
if((newShape.type == 'bpmnSubProcess' || newShape.type == 'bpmnTask') && !item.type.match(/Boundary/)) if((newShape.type == 'bpmnSubProcess' || newShape.type == 'bpmnTask') && !item.type.match(/Boundary/)){
{ newShape.actiontype = 'addSubProcess';
newShape.actiontype = 'addSubProcess'; if(newShape.type == 'bpmnTask')
if(newShape.type == 'bpmnTask') newShape.actiontype = 'addTask';
newShape.actiontype = 'addTask'; newShape.workflow.saveShape(newShape);
newShape.workflow.saveShape(newShape);
} }
if((this.type == 'bpmnTask' || this.type == 'bpmnSubProcess') && !item.type.match(/Boundary/) ) if((this.type == 'bpmnTask' || this.type == 'bpmnSubProcess') && !item.type.match(/Boundary/) ){
{ this.actiontype = 'deleteTask';
this.actiontype = 'deleteTask'; this.noAlert = true;
this.noAlert = true; if(this.type == 'bpmnSubProcess')
if(this.type == 'bpmnSubProcess') this.actiontype = 'deleteSubProcess';
this.actiontype = 'deleteSubProcess'; newShape.workflow.deleteSilently(this);
newShape.workflow.deleteSilently(this);
} }
} }
} }
} }
@@ -1084,6 +1102,9 @@ MyWorkflow.prototype.saveShape= function(oNewShape)
case 'saveTextPosition': case 'saveTextPosition':
urlparams = '?action='+actiontype+'&data={"uid":"'+ shapeId +'","position":'+pos+'}'; urlparams = '?action='+actiontype+'&data={"uid":"'+ shapeId +'","position":'+pos+'}';
break; break;
case 'saveGatewayPosition':
urlparams = '?action='+actiontype+'&data={"uid":"'+ shapeId +'","position":'+pos+'}';
break;
case 'saveTaskCordinates': case 'saveTaskCordinates':
urlparams = '?action='+actiontype+'&data={"uid":"'+ shapeId +'","position":'+cordinates+'}'; urlparams = '?action='+actiontype+'&data={"uid":"'+ shapeId +'","position":'+cordinates+'}';
break; break;
@@ -1123,9 +1144,13 @@ MyWorkflow.prototype.saveShape= function(oNewShape)
var evn_type = oNewShape.type; var evn_type = oNewShape.type;
urlparams = '?action='+actiontype+'&data={"evn_uid":"'+evn_uid +'","evn_type":"'+evn_type+'"}'; urlparams = '?action='+actiontype+'&data={"evn_uid":"'+evn_uid +'","evn_type":"'+evn_type+'"}';
break; break;
case 'saveGatewayPosition': case 'addGateway':
urlparams = '?action='+actiontype+'&data={"uid":"'+ shapeId +'","position":'+pos+'}'; var gat_uid = oNewShape.id
var gat_type = oNewShape.type;
var mode = oNewShape.mode;
urlparams = '?action='+actiontype+'&data={"pro_uid":"'+ pro_uid +'","gat_uid":"'+gat_uid +'","gat_type":"'+gat_type+'","position":'+pos+',"mode":"'+mode+'"}';
break; break;
} }
//var urlparams = '?action='+actiontype+'&data={"uid":"'+ pro_uid +'","position":'+pos+'}'; //var urlparams = '?action='+actiontype+'&data={"uid":"'+ pro_uid +'","position":'+pos+'}';

View File

@@ -811,14 +811,22 @@ Ext.onReady ( function() {
if(data.name == 'bpmnAnnotation'){ if(data.name == 'bpmnAnnotation'){
NewShape.actiontype = 'addText'; NewShape.actiontype = 'addText';
workflow.saveShape(NewShape); //Saving task when user drags and drops it workflow.saveShape(NewShape); //Saving task when user drags and drops it
}else if(data.name == 'bpmnTask'){ }
else if(data.name == 'bpmnTask'){
NewShape.actiontype = 'addTask'; NewShape.actiontype = 'addTask';
workflow.saveShape(NewShape); //Saving Annotations when user drags and drops it workflow.saveShape(NewShape); //Saving Annotations when user drags and drops it
}else if(data.name.match(/Event/)){ }
else if(data.name.match(/Event/)){
NewShape.actiontype = 'addEvent'; NewShape.actiontype = 'addEvent';
NewShape.mode = 'ddEvent'; NewShape.mode = 'ddEvent';
workflow.saveShape(NewShape); //Saving Annotations when user drags and drops it workflow.saveShape(NewShape); //Saving Annotations when user drags and drops it
} }
else if(data.name.match(/Gateway/)){
NewShape.actiontype = 'addGateway';
NewShape.mode = 'ddGateway';
workflow.saveShape(NewShape); //Saving Annotations when user drags and drops it
}
var scrollLeft = workflow.getScrollLeft(); var scrollLeft = workflow.getScrollLeft();
var scrollTop = workflow.getScrollTop(); var scrollTop = workflow.getScrollTop();
workflow.addFigure(NewShape,e.xy[0]-xOffset+scrollLeft,e.xy[1]-yOffset+scrollTop); workflow.addFigure(NewShape,e.xy[0]-xOffset+scrollLeft,e.xy[1]-yOffset+scrollTop);