Adicion de validaciones para campos requeridos en PROJECTS

This commit is contained in:
Brayan Osmar Pereyra Suxo
2014-05-07 15:55:51 -04:00
parent 23b292db04
commit 11251d1123
2 changed files with 35 additions and 1 deletions

View File

@@ -493,6 +493,30 @@ class BpmnWorkflow extends Project\Bpmn
public static function createFromStruct(array $projectData, $generateUid = true)
{
if (\Process::existsByProTitle($projectData["prj_name"])) {
throw new \Exception("Project with name: {$projectData["prj_name"]}, already exists.");
}
$activities = $projectData['diagrams']['0']['activities'];
foreach($activities as $value) {
if (empty($value['act_name'])) {
throw new \Exception("For activity: {$value['act_uid']} `act_name` is required but missing.");
}
if (empty($value['act_type'])) {
throw new \Exception("For activity: {$value['act_uid']} `act_type` is required but missing.");
}
}
$events = $projectData['diagrams']['0']['events'];
foreach($events as $value) {
if (empty($value['evn_name'])) {
throw new \Exception("For event: {$value['evn_uid']} `evn_name` is required but missing.");
}
if (empty($value['evn_type'])) {
throw new \Exception("For event: {$value['evn_uid']} `evn_type` is required but missing.");
}
if (empty($value['evn_marker'])) {
throw new \Exception("For event: {$value['evn_uid']} `evn_marker` is required but missing.");
}
}
$bwp = new self;
$result = array();
$data = array();

View File

@@ -49,9 +49,19 @@ class Project extends Api
}
/**
* Post Project
*
* @param string $prj_name
* @param string $prj_description
* @param array $request_data
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @url POST
* @status 201
*/
public function post($request_data)
public function post($prj_name, $prj_description, $request_data)
{
try {
return Adapter\BpmnWorkflow::createFromStruct($request_data);