ProcessMaker-BE "Web Entry, adapt for save data in database (endpoints)"

- Se han implementado los siguientes Endpoints:
    GET    /api/1.0/{workspace}/project/{prj_uid}/web-entries
    GET    /api/1.0/{workspace}/project/{prj_uid}/web-entry/{we_uid}
    POST   /api/1.0/{workspace}/project/{prj_uid}/web-entry
    PUT    /api/1.0/{workspace}/project/{prj_uid}/web-entry/{we_uid}
    DELETE /api/1.0/{workspace}/project/{prj_uid}/web-entry/{we_uid}
This commit is contained in:
Victor Saisa Lopez
2014-04-22 13:11:32 -04:00
parent 14a17ac244
commit 6feb095227
14 changed files with 2678 additions and 345 deletions

View File

@@ -283,11 +283,11 @@ class Calendar
}
/**
* Create Group
* Create Calendar
*
* @param array $arrayData Data
*
* return array Return data of the new Group created
* return array Return data of the new Calendar created
*/
public function create($arrayData)
{

View File

@@ -1456,39 +1456,6 @@ class Process
}
}
/**
* Get all Web Entries of a Process
*
* @param string $processUid Unique id of Process
*
* return array Return an array with all Web Entries of a Process
*/
public function getWebEntries($processUid)
{
try {
$arrayWebEntry = array();
//Verify data
//Get data
$webEntry = new \ProcessMaker\BusinessModel\WebEntry();
$webEntry->setFormatFieldNameInUppercase($this->formatFieldNameInUppercase);
$webEntry->setArrayFieldNameForException($this->arrayFieldNameForException);
$arrayWebEntryData = $webEntry->getData($processUid);
foreach ($arrayWebEntryData as $index => $value) {
$row = $value;
$arrayWebEntry[] = $webEntry->getWebEntryDataFromRecord($row);
}
//Return
return $arrayWebEntry;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get field names which are primary key in a PM Table
*

File diff suppressed because it is too large Load Diff

View File

@@ -175,26 +175,6 @@ class Project extends Api
}
}
/**
* @url GET /:prj_uid/web-entries
*
* @param string $prj_uid {@min 32}{@max 32}
*/
public function doGetWebEntries($prj_uid)
{
try {
$process = new \ProcessMaker\BusinessModel\Process();
$process->setFormatFieldNameInUppercase(false);
$process->setArrayFieldNameForException(array("processUid" => "prj_uid"));
$response = $process->getWebEntries($prj_uid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url GET /:prj_uid/variables
*

View File

@@ -11,21 +11,51 @@ use \Luracast\Restler\RestException;
*/
class WebEntry extends Api
{
private $webEntry;
/**
* @url GET /:prj_uid/web-entry/:tas_uid/:dyn_uid
* Constructor of the class
*
* @param string $dyn_uid {@min 32}{@max 32}
* @param string $tas_uid {@min 32}{@max 32}
* @param string $prj_uid {@min 32}{@max 32}
* return void
*/
public function doGetWebEntry($dyn_uid, $tas_uid, $prj_uid)
public function __construct()
{
try {
$webEntry = new \ProcessMaker\BusinessModel\WebEntry();
$webEntry->setFormatFieldNameInUppercase(false);
$webEntry->setArrayFieldNameForException(array("processUid" => "prj_uid"));
$this->webEntry = new \ProcessMaker\BusinessModel\WebEntry();
$response = $webEntry->getWebEntry($prj_uid, $tas_uid, $dyn_uid);
$this->webEntry->setFormatFieldNameInUppercase(false);
$this->webEntry->setArrayFieldNameForException(array("processUid" => "prj_uid"));
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url GET /:prj_uid/web-entries
*
* @param string $prj_uid {@min 32}{@max 32}
*/
public function doGetWebEntries($prj_uid)
{
try {
$response = $this->webEntry->getWebEntries($prj_uid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url GET /:prj_uid/web-entry/:we_uid
*
* @param string $prj_uid {@min 32}{@max 32}
* @param string $we_uid {@min 32}{@max 32}
*/
public function doGetWebEntry($prj_uid, $we_uid)
{
try {
$response = $this->webEntry->getWebEntry($we_uid);
return $response;
} catch (\Exception $e) {
@@ -44,11 +74,7 @@ class WebEntry extends Api
public function doPostWebEntry($prj_uid, $request_data)
{
try {
$webEntry = new \ProcessMaker\BusinessModel\WebEntry();
$webEntry->setFormatFieldNameInUppercase(false);
$webEntry->setArrayFieldNameForException(array("processUid" => "prj_uid"));
$arrayData = $webEntry->create($prj_uid, $request_data);
$arrayData = $this->webEntry->create($prj_uid, $this->getUserId(), $request_data);
$response = $arrayData;
@@ -59,20 +85,31 @@ class WebEntry extends Api
}
/**
* @url DELETE /:prj_uid/web-entry/:tas_uid/:dyn_uid
* @url PUT /:prj_uid/web-entry/:we_uid
*
* @param string $dyn_uid {@min 32}{@max 32}
* @param string $tas_uid {@min 32}{@max 32}
* @param string $prj_uid {@min 32}{@max 32}
* @param string $prj_uid {@min 32}{@max 32}
* @param string $we_uid {@min 32}{@max 32}
* @param array $request_data
*/
public function doDeleteWebEntry($dyn_uid, $tas_uid, $prj_uid)
public function doPutWebEntry($prj_uid, $we_uid, $request_data)
{
try {
$webEntry = new \ProcessMaker\BusinessModel\WebEntry();
$webEntry->setFormatFieldNameInUppercase(false);
$webEntry->setArrayFieldNameForException(array("processUid" => "prj_uid"));
$arrayData = $this->webEntry->update($we_uid, $this->getUserId(), $request_data);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
$webEntry->delete($prj_uid, $tas_uid, $dyn_uid);
/**
* @url DELETE /:prj_uid/web-entry/:we_uid
*
* @param string $prj_uid {@min 32}{@max 32}
* @param string $we_uid {@min 32}{@max 32}
*/
public function doDeleteWebEntry($prj_uid, $we_uid)
{
try {
$this->webEntry->delete($we_uid);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}