Merged in feature/FBI-2013 (pull request #5912)
FBI-2023 Approved-by: Rodrigo Quelca <rockoinfo@yahoo.com> Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,7 @@
|
||||
namespace ProcessMaker\Services\Api;
|
||||
|
||||
use Luracast\Restler\RestException;
|
||||
use ProcessMaker\Project\Bpmn;
|
||||
use ProcessMaker\Services\Api;
|
||||
use \ProcessMaker\Project\Adapter;
|
||||
use \ProcessMaker\Util;
|
||||
@@ -11,6 +12,8 @@ use \ProcessMaker\BusinessModel\Migrator\GranularExporter;
|
||||
use \ProcessMaker\BusinessModel\Migrator\ExportObjects;
|
||||
use \ProcessMaker\Util\IO\HttpStream;
|
||||
use \ProcessMaker\Util\Common;
|
||||
use ProcessMaker\Project\Adapter\BpmnWorkflow;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class Project
|
||||
@@ -43,7 +46,7 @@ class Project extends Api
|
||||
$projects = Adapter\BpmnWorkflow::getList($start, $limit, $filter, CASE_LOWER);
|
||||
|
||||
return DateTime::convertUtcToIso8601($projects, $this->arrayFieldIso8601);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
@@ -62,7 +65,7 @@ class Project extends Api
|
||||
$property = $userProperty->loadOrCreateIfNotExists($this->getUserId());
|
||||
$project['usr_setting_designer'] = isset($property['USR_SETTING_DESIGNER']) ? \G::json_decode($property['USR_SETTING_DESIGNER']) : null;
|
||||
return DateTime::convertUtcToIso8601($project, $this->arrayFieldIso8601);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
@@ -87,7 +90,7 @@ class Project extends Api
|
||||
}
|
||||
Validator::throwExceptionIfDataNotMetIso8601Format($request_data, $this->arrayFieldIso8601);
|
||||
return Adapter\BpmnWorkflow::createFromStruct(DateTime::convertDataToUtc($request_data, $this->arrayFieldIso8601));
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
@@ -112,7 +115,7 @@ class Project extends Api
|
||||
|
||||
Validator::throwExceptionIfDataNotMetIso8601Format($request_data, $this->arrayFieldIso8601);
|
||||
return Adapter\BpmnWorkflow::updateFromStruct($prj_uid, DateTime::convertDataToUtc($request_data, $this->arrayFieldIso8601));
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
@@ -120,13 +123,39 @@ class Project extends Api
|
||||
/**
|
||||
* @param string $prj_uid {@min 1}{@max 32}
|
||||
* @url DELETE /:prj_uid
|
||||
* @throws Exception
|
||||
*/
|
||||
public function delete($prj_uid)
|
||||
{
|
||||
try {
|
||||
$oBpmnWf = Adapter\BpmnWorkflow::load($prj_uid);
|
||||
$oBpmnWf->remove();
|
||||
} catch (\Exception $e) {
|
||||
if (Bpmn::exists($prj_uid)) {
|
||||
$oBpmnWf = BpmnWorkflow::load($prj_uid);
|
||||
$oBpmnWf->remove();
|
||||
} else {
|
||||
throw new Exception("The project cannot be found or it was already deleted.");
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk actions
|
||||
* @url POST /bulk
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_FACTORY}
|
||||
*
|
||||
* @param array $request_data
|
||||
* @return array $response
|
||||
* @throws Exception
|
||||
*/
|
||||
public function bulk($request_data)
|
||||
{
|
||||
try {
|
||||
$response = Bpmn::doBulk($request_data);
|
||||
return $response;
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
@@ -144,7 +173,7 @@ class Project extends Api
|
||||
$exportProcess= new ExportObjects();
|
||||
$result = $exportProcess->objectList($prj_uid);
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
@@ -224,7 +253,7 @@ class Project extends Api
|
||||
$response = $arrayData;
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -259,7 +288,7 @@ class Project extends Api
|
||||
|
||||
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -279,7 +308,7 @@ class Project extends Api
|
||||
$process->setArrayFieldNameForException(array("processUid" => "prj_uid"));
|
||||
|
||||
$arrayData = $process->update($prj_uid, DateTime::convertDataToUtc($request_data, $this->arrayFieldIso8601));
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -317,7 +346,7 @@ class Project extends Api
|
||||
$response = $arrayData;
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -337,7 +366,7 @@ class Project extends Api
|
||||
$response = $process->getDynaForms($prj_uid);
|
||||
|
||||
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -357,7 +386,7 @@ class Project extends Api
|
||||
$response = $process->getInputDocuments($prj_uid);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -377,7 +406,7 @@ class Project extends Api
|
||||
$response = $process->getVariables("ALL", $prj_uid);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -399,7 +428,7 @@ class Project extends Api
|
||||
$response = ($grid_uid == "")? $process->getVariables("GRID", $prj_uid) : $process->getVariables("GRIDVARS", $prj_uid, $grid_uid);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -419,7 +448,7 @@ class Project extends Api
|
||||
$response = $process->getLibraries($prj_uid);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -435,7 +464,7 @@ class Project extends Api
|
||||
$oRoute = new \Route();
|
||||
$result = $oRoute->updateRouteOrder($request_data);
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
@@ -451,7 +480,7 @@ class Project extends Api
|
||||
$oRoute = new \Route();
|
||||
$result = $oRoute->updateRouteOrderFromProject($prj_uid);
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user