Adicion de POST y PUT en PROJECT
This commit is contained in:
@@ -808,6 +808,19 @@ class Process extends BaseProcess
|
||||
return $aProcesses;
|
||||
}
|
||||
|
||||
public function getCasesCountForProcess($pro_uid)
|
||||
{
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( 'COUNT(*) AS TOTAL_CASES' );
|
||||
$oCriteria->add( ApplicationPeer::PRO_UID, $pro_uid );
|
||||
$oDataset = ApplicationPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
|
||||
$oDataset->next();
|
||||
$cases = $oDataset->getRow();
|
||||
return (int)$cases['TOTAL_CASES'];
|
||||
}
|
||||
|
||||
public function getAllProcessesByCategory ()
|
||||
{
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
|
||||
@@ -158,6 +158,9 @@ class Bpmn extends Handler
|
||||
foreach ($this->getFlows() as $flow) {
|
||||
$this->removeFlow($flow["FLO_UID"]);
|
||||
}
|
||||
foreach ($this->getArtifacts() as $artifacts) {
|
||||
$this->removeArtifact($artifacts["ART_UID"]);
|
||||
}
|
||||
|
||||
if ($process = $this->getProcess("object")) {
|
||||
$process->delete();
|
||||
@@ -213,9 +216,12 @@ class Bpmn extends Handler
|
||||
|
||||
public function canRemove()
|
||||
{
|
||||
// TODO this must validate if the project can be deleted or not.
|
||||
// TODO the project can be deleted only if it has not any started cases
|
||||
return true;
|
||||
$totalCases = \Process::getCasesCountForProcess($this->prjUid);
|
||||
if ($totalCases == 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -54,11 +54,8 @@ class Project extends Api
|
||||
public function post($request_data)
|
||||
{
|
||||
try {
|
||||
//TODO
|
||||
return Adapter\BpmnWorkflow::createFromStruct($request_data);
|
||||
} catch (\Exception $e) {
|
||||
// TODO in case that $process->createProcess($userUid, $data); fails maybe the BPMN project was created successfully
|
||||
// so, we need remove it or change the creation order.
|
||||
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
@@ -72,10 +69,15 @@ class Project extends Api
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($prjUid)
|
||||
/**
|
||||
* @param string $prj_uid {@min 1}{@max 32}
|
||||
* @url DELETE /:prj_uid
|
||||
*/
|
||||
public function delete($prj_uid)
|
||||
{
|
||||
try {
|
||||
// TODO
|
||||
$oBpmnWf = Adapter\BpmnWorkflow::load($prj_uid);
|
||||
$oBpmnWf->remove();
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user