Adding DELETE /project/{prj_uid}, is working, and more changes for PUT method
This commit is contained in:
@@ -66,7 +66,11 @@ class BpmnActivity extends BaseBpmnActivity
|
||||
public function delete($con = null)
|
||||
{
|
||||
// first, delete the related bound object
|
||||
if (is_object($this->bound) && get_class($this->bound) == 'BpmnBound') {
|
||||
if (! is_object($this->bound)) {
|
||||
$this->bound = BpmnBound::findByElement('Activity', $this->getActUid());
|
||||
}
|
||||
|
||||
if (is_object($this->bound)) {
|
||||
$this->bound->delete($con);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,20 @@ class BpmnEvent extends BaseBpmnEvent
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($con = null)
|
||||
{
|
||||
// first, delete the related bound object
|
||||
if (! is_object($this->bound)) {
|
||||
$this->bound = BpmnBound::findByElement('Event', $this->getActUid());
|
||||
}
|
||||
|
||||
if (is_object($this->bound)) {
|
||||
$this->bound->delete($con);
|
||||
}
|
||||
|
||||
parent::delete($con);
|
||||
}
|
||||
|
||||
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$data = parent::toArray($keyType);
|
||||
|
||||
@@ -53,6 +53,20 @@ class BpmnGateway extends BaseBpmnGateway
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($con = null)
|
||||
{
|
||||
// first, delete the related bound object
|
||||
if (! is_object($this->bound)) {
|
||||
$this->bound = BpmnBound::findByElement('Gateway', $this->getActUid());
|
||||
}
|
||||
|
||||
if (is_object($this->bound)) {
|
||||
$this->bound->delete($con);
|
||||
}
|
||||
|
||||
parent::delete($con);
|
||||
}
|
||||
|
||||
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$data = parent::toArray($keyType);
|
||||
|
||||
@@ -104,6 +104,7 @@ class ProcessProxy extends HttpProxyController
|
||||
} catch (Exception $e) {
|
||||
$this->success = false;
|
||||
$this->msg = $e->getMessage();
|
||||
$this->trace = $e->getTraceAsString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -483,7 +483,8 @@ class Process
|
||||
* return bool Return true, if is succesfully
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
|
||||
DEPRECATED
|
||||
public function deleteProcess($processUid, $checkCases = true)
|
||||
{
|
||||
if ($checkCases) {
|
||||
@@ -508,6 +509,216 @@ class Process
|
||||
|
||||
return $processMap->deleteProcess($processUid);
|
||||
|
||||
}*/
|
||||
|
||||
public function deleteProcess($sProcessUID)
|
||||
{
|
||||
try {
|
||||
G::LoadClass('case');
|
||||
G::LoadClass('reportTables');
|
||||
//Instance all classes necesaries
|
||||
$oProcess = new Process();
|
||||
$oDynaform = new Dynaform();
|
||||
$oInputDocument = new InputDocument();
|
||||
$oOutputDocument = new OutputDocument();
|
||||
$oTrigger = new Triggers();
|
||||
$oRoute = new Route();
|
||||
$oGateway = new Gateway();
|
||||
$oEvent = new Event();
|
||||
$oSwimlaneElement = new SwimlanesElements();
|
||||
$oConfiguration = new Configuration();
|
||||
$oDbSource = new DbSource();
|
||||
$oReportTable = new ReportTables();
|
||||
$oCaseTracker = new CaseTracker();
|
||||
$oCaseTrackerObject = new CaseTrackerObject();
|
||||
//Delete the applications of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(ApplicationPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = ApplicationPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$oCase = new Cases();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oCase->removeCase($aRow['APP_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
//Delete the tasks of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(TaskPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = TaskPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$this->deleteTask($aRow['TAS_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
//Delete the dynaforms of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(DynaformPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = DynaformPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oDynaform->remove($aRow['DYN_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
//Delete the input documents of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(InputDocumentPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = InputDocumentPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oInputDocument->remove($aRow['INP_DOC_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
//Delete the output documents of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(OutputDocumentPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = OutputDocumentPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oOutputDocument->remove($aRow['OUT_DOC_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
|
||||
//Delete the triggers of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(TriggersPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = TriggersPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oTrigger->remove($aRow['TRI_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
|
||||
//Delete the routes of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(RoutePeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = RoutePeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oRoute->remove($aRow['ROU_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
|
||||
//Delete the gateways of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(GatewayPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = GatewayPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oGateway->remove($aRow['GAT_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
|
||||
//Delete the Event of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(EventPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = EventPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oEvent->remove($aRow['EVN_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
|
||||
//Delete the swimlanes elements of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(SwimlanesElementsPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = SwimlanesElementsPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oSwimlaneElement->remove($aRow['SWI_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
//Delete the configurations of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(ConfigurationPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = ConfigurationPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oConfiguration->remove($aRow['CFG_UID'], $aRow['OBJ_UID'], $aRow['PRO_UID'], $aRow['USR_UID'], $aRow['APP_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
//Delete the DB sources of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(DbSourcePeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = DbSourcePeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
|
||||
/**
|
||||
* note added by gustavo cruz gustavo-at-colosa-dot-com 27-01-2010
|
||||
* in order to solve the bug 0004389, we use the validation function Exists
|
||||
* inside the remove function in order to verify if the DbSource record
|
||||
* exists in the Database, however there is a strange behavior within the
|
||||
* propel engine, when the first record is erased somehow the "_deleted"
|
||||
* attribute of the next row is set to true, so when propel tries to erase
|
||||
* it, obviously it can't and trows an error. With the "Exist" function
|
||||
* we ensure that if there is the record in the database, the _delete attribute must be false.
|
||||
*
|
||||
* note added by gustavo cruz gustavo-at-colosa-dot-com 28-01-2010
|
||||
* I have just identified the source of the issue, when is created a $oDbSource DbSource object
|
||||
* it's used whenever a record is erased or removed in the db, however the problem
|
||||
* it's that the same object is used every time, and the delete method invoked
|
||||
* sets the _deleted attribute to true when its called, of course as we use
|
||||
* the same object, the first time works fine but trowns an error with the
|
||||
* next record, cos it's the same object and the delete method checks if the _deleted
|
||||
* attribute it's true or false, the attrib _deleted is setted to true the
|
||||
* first time and later is never changed, the issue seems to be part of
|
||||
* every remove function in the model classes, not only DbSource
|
||||
* i recommend that a more general solution must be achieved to resolve
|
||||
* this issue in every model class, to prevent future problems.
|
||||
*/
|
||||
$oDbSource->remove($aRow['DBS_UID'], $sProcessUID);
|
||||
$oDataset->next();
|
||||
}
|
||||
//Delete the supervisors
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(ProcessUserPeer::PRO_UID, $sProcessUID);
|
||||
ProcessUserPeer::doDelete($oCriteria);
|
||||
//Delete the object permissions
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(ObjectPermissionPeer::PRO_UID, $sProcessUID);
|
||||
ObjectPermissionPeer::doDelete($oCriteria);
|
||||
//Delete the step supervisors
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(StepSupervisorPeer::PRO_UID, $sProcessUID);
|
||||
StepSupervisorPeer::doDelete($oCriteria);
|
||||
//Delete the report tables
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(ReportTablePeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = ReportTablePeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oReportTable->deleteReportTable($aRow['REP_TAB_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
//Delete case tracker configuration
|
||||
$oCaseTracker->remove($sProcessUID);
|
||||
//Delete case tracker objects
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(CaseTrackerObjectPeer::PRO_UID, $sProcessUID);
|
||||
ProcessUserPeer::doDelete($oCriteria);
|
||||
//Delete the process
|
||||
try {
|
||||
$oProcess->remove($sProcessUID);
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,6 +38,15 @@ use Symfony\Component\Yaml\Exception\RuntimeException;
|
||||
*/
|
||||
class Model
|
||||
{
|
||||
private static $diagramElements = array(
|
||||
'act_uid' => 'activities',
|
||||
'evn_uid' => 'events',
|
||||
'flo_uid' => 'flows',
|
||||
'art_uid' => 'artifacts',
|
||||
'lns_uid' => 'laneset',
|
||||
'lan_uid' => 'lanes'
|
||||
);
|
||||
|
||||
public function createProject($data, $replaceUids = false)
|
||||
{
|
||||
$data = array_change_key_case($data, CASE_UPPER);
|
||||
@@ -71,16 +80,15 @@ class Model
|
||||
|
||||
if ($replaceUids) {
|
||||
$uids[] = array('old_uid' => $oldPrjUid, 'new_uid' => $prjUid, 'object' => 'project');
|
||||
$mapId['project'][$oldPrjUid] = $prjUid;
|
||||
}
|
||||
|
||||
if (! isset($diagrams)) {
|
||||
/*if (! isset($diagrams)) {
|
||||
if ($replaceUids) {
|
||||
return $uids;
|
||||
} else {
|
||||
return self::loadProject($prjUid);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
$diagram = new Diagram();
|
||||
|
||||
@@ -101,8 +109,7 @@ class Model
|
||||
$diaUid = $diagram->getDiaUid();
|
||||
|
||||
if ($replaceUids) {
|
||||
$uids[] = array('old_uid' => $oldDiaUid, 'new_uid' => $diaUid, 'object' => 'diagram');
|
||||
$mapId['diagram'][$oldDiaUid] = $diaUid;
|
||||
$uids[] = array('old_uid' => (isset($oldDiaUid) ? $oldDiaUid : ''), 'new_uid' => $diaUid, 'object' => 'diagram');
|
||||
}
|
||||
|
||||
$process = new Process();
|
||||
@@ -125,8 +132,7 @@ class Model
|
||||
$proUid = $process->getProUid();
|
||||
|
||||
if ($replaceUids) {
|
||||
$uids[] = array('old_uid' => $oldProUid, 'new_uid' => $proUid, 'object' => 'project');
|
||||
$mapId['process'][$oldProUid] = $proUid;
|
||||
$uids[] = array('old_uid' => (isset($oldProUid) ? $oldProUid : ''), 'new_uid' => $proUid, 'object' => 'project');
|
||||
}
|
||||
|
||||
|
||||
@@ -369,12 +375,17 @@ class Model
|
||||
*/
|
||||
|
||||
$project = self::getBpmnObjectBy('Project', ProjectPeer::PRJ_UID, $prjUid, true);
|
||||
|
||||
if(empty($project)) {
|
||||
throw new \RuntimeException("Project with id: $prjUid, does not exists. ");
|
||||
}
|
||||
|
||||
$process = self::getBpmnObjectBy('Process', ProcessPeer::PRJ_UID, $prjUid, true);
|
||||
$diagram = self::getBpmnObjectBy('Diagram', DiagramPeer::DIA_UID, $process['dia_uid'], true);
|
||||
|
||||
$project = array_change_key_case($project);
|
||||
|
||||
if (! empty($diagram)) {
|
||||
//if (! empty($diagram)) {
|
||||
$lanesets = self::getBpmnCollectionBy('Laneset', LanesetPeer::PRJ_UID, $prjUid, true);
|
||||
$lanes = self::getBpmnCollectionBy('Lane', LanePeer::PRJ_UID, $prjUid, true);
|
||||
$activities = self::getBpmnCollectionBy('Activity', ActivityPeer::PRJ_UID, $prjUid, true);
|
||||
@@ -412,6 +423,7 @@ class Model
|
||||
|
||||
|
||||
$project['diagrams'] = array($diagram);
|
||||
$project['diagrams'][0]['pro_uid'] = $process['pro_uid'];
|
||||
$project['diagrams'][0]['laneset'] = $lanesets;
|
||||
$project['diagrams'][0]['lanes'] = $lanes;
|
||||
$project['diagrams'][0]['activities'] = $activities;
|
||||
@@ -419,7 +431,7 @@ class Model
|
||||
$project['diagrams'][0]['gateways'] = $gateways;
|
||||
$project['diagrams'][0]['flows'] = $flows;
|
||||
$project['diagrams'][0]['artifacts'] = $artifacts;
|
||||
}
|
||||
//}
|
||||
|
||||
return $project;
|
||||
}
|
||||
@@ -615,6 +627,60 @@ class Model
|
||||
}
|
||||
|
||||
}
|
||||
public function deleteProject($prjUid)
|
||||
{
|
||||
$project = self::loadProject($prjUid);
|
||||
|
||||
// TODO first at all, make validation, the project can only deleted if there are not any started case for it
|
||||
|
||||
// Delete related objects
|
||||
$diagramData = $project['diagrams'][0];
|
||||
|
||||
foreach ($diagramData['flows'] as $data) {
|
||||
$flow = FlowPeer::retrieveByPK($data['flo_uid']);
|
||||
$flow->delete();
|
||||
}
|
||||
foreach ($diagramData['artifacts'] as $data) {
|
||||
$artifact = ArtifactPeer::retrieveByPK($data['art_uid']);
|
||||
$artifact->delete();
|
||||
}
|
||||
foreach ($diagramData['lanes'] as $data) {
|
||||
$lane = LanePeer::retrieveByPK($data['lan_uid']);
|
||||
$lane->delete();
|
||||
}
|
||||
foreach ($diagramData['laneset'] as $data) {
|
||||
$laneset = LanesetPeer::retrieveByPK($data['lns_uid']);
|
||||
$laneset->delete();
|
||||
}
|
||||
foreach ($diagramData['laneset'] as $data) {
|
||||
$laneset = LanesetPeer::retrieveByPK($data['lns_uid']);
|
||||
$laneset->delete();
|
||||
}
|
||||
foreach ($diagramData['activities'] as $data) {
|
||||
$activity = ActivityPeer::retrieveByPK($data['act_uid']);
|
||||
$activity->delete();
|
||||
}
|
||||
foreach ($diagramData['events'] as $data) {
|
||||
$event = EventPeer::retrieveByPK($data['evn_uid']);
|
||||
$event->delete();
|
||||
}
|
||||
foreach ($diagramData['gateways'] as $data) {
|
||||
$gateway = GatewayPeer::retrieveByPK($data['gat_uid']);
|
||||
$gateway->delete();
|
||||
}
|
||||
|
||||
$process = ProcessPeer::retrieveByPK($diagramData['pro_uid']);
|
||||
$process->delete();
|
||||
|
||||
$project = ProjectPeer::retrieveByPK($prjUid);
|
||||
$project->delete();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Others functions
|
||||
*/
|
||||
|
||||
public static function getDiffFromProjects($savedProject, $updatedProject)
|
||||
{
|
||||
|
||||
@@ -162,6 +162,18 @@ class Project extends Api
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($prjUid)
|
||||
{
|
||||
try {
|
||||
$process = new \BusinessModel\Process();
|
||||
$process->deleteProcess($prjUid);
|
||||
|
||||
BpmnModel::deleteProject($prjUid);
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url GET /:projectUid/dynaforms
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user