Merge branch 'master' of bitbucket.org:colosa/processmaker

This commit is contained in:
Wendy Nestor
2014-01-08 08:59:41 -04:00
6 changed files with 546 additions and 86 deletions

View File

@@ -3,4 +3,4 @@ default:
context:
parameters:
base_url: http://192.168.11.181/api/1.0/michelangelo/
access_token: ff4bdec9e8e2e3b2fa3fb03bc3a7d287fd0dcf26
access_token: cd5cff9b2e3ebabf49e276e47e977fab5988c00e

View File

@@ -1,23 +1,176 @@
@ProcessMakerMichelangelo @RestAPI
Feature: Dynaforms Resources
Feature: DynaForms Resources
#GET /api/1.0/{workspace}/project/{prj_uid}/dynaforms
# Get a List DynaForms of a Project
Scenario: Get a List DynaForms of a Project
Given that I have a valid access_token
And I request "project/14414793652a5d718b65590036026581/dynaforms"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "array"
And the json data is an empty array
Background:
Given that I have a valid access_token
#POST /api/1.0/{workspace}/project/{prj_uid}/dynaform
# Create a new DynaForm for a Project
# Creation normal of a DynaForm
Scenario: Create "My DynaForm1" for a Project (Creation normal of a DynaForm)
Given that I have a valid access_token
And POST this data:
"""
{
"dyn_title": "My DynaForm1",
"dyn_description": "My DynaForm1 DESCRIPTION",
"dyn_type": "xmlform"
}
"""
And I request "project/14414793652a5d718b65590036026581/dynaform"
And the content type is "application/json"
Then the response status code should be 201
And the response charset is "UTF-8"
And the type is "object"
And store "dyn_uid" in session array as variable "dynaForm1"
Scenario: Get a List of dynaforms of a project
Given this scenario is not implemented yet
Scenario: Get a single dynaform of a project
Given this scenario is not implemented yet
Scenario: Create a new dynaform for a project
Given this scenario is not implemented yet
Scenario: Create a copy of a dynaform and import it to another project
Given this scenario is not implemented yet
Scenario: Update a dynaform of a project
Given this scenario is not implemented yet
#POST /api/1.0/{workspace}/project/{prj_uid}/dynaform
# Create a new DynaForm for a Project
# Copy/Import a DynaForm
Scenario: Create "DynaForm Demo" for a Project (Copy/Import a DynaForm)
Given that I have a valid access_token
And POST this data:
"""
{
"dyn_title": "DynaForm Demo",
"dyn_description": "Description",
"dyn_type": "xmlform",
"copy_import":
{
"prj_uid": "48207364252cc27894ca354020290166",
"dyn_uid": "68268455252cc27cb463d76013645722"
}
}
"""
And I request "project/14414793652a5d718b65590036026581/dynaform"
And the content type is "application/json"
Then the response status code should be 201
And the response charset is "UTF-8"
And the type is "object"
And store "dyn_uid" in session array as variable "dynaForm2"
#POST /api/1.0/{workspace}/project/{prj_uid}/dynaform
# Create a new DynaForm for a Project
# Creation of a DynaForm based in a PMTable
Scenario: Create "My DynaForm3" for a Project (Creation of a DynaForm based in a PMTable)
Given that I have a valid access_token
And POST this data:
"""
{
"dyn_title": "My DynaForm3",
"dyn_description": "My DynaForm3 DESCRIPTION",
"dyn_type": "xmlform",
"pmtable":
{
"tab_uid": "65193158852cc1a93a5a535084878044",
"fields": [
{
"fld_name": "DYN_UID",
"pro_variable": "@#APPLICATION"
}
]
}
}
"""
And I request "project/14414793652a5d718b65590036026581/dynaform"
And the content type is "application/json"
Then the response status code should be 201
And the response charset is "UTF-8"
And the type is "object"
And store "dyn_uid" in session array as variable "dynaForm3"
#PUT /api/1.0/{workspace}/project/{prj_uid}/dynaform/{dyn_uid}
# Update a DynaForm for a Project
Scenario: Update a DynaForm for a Project
Given that I have a valid access_token
And PUT this data:
"""
{
"dyn_title": "My DynaForm1 Modified",
"dyn_description": "My DynaForm1 DESCRIPTION Modified",
"dyn_type": "xmlform"
}
"""
And that I want to update a resource with the key "dynaForm1" stored in session array
And I request "project/14414793652a5d718b65590036026581/dynaform"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
And that "dyn_title" is set to "My DynaForm1 Modified"
#GET /api/1.0/{workspace}/project/{prj_uid}/dynaforms
# Get a List DynaForms of a Project
Scenario: Get a List DynaForms of a Project
Given that I have a valid access_token
And I request "project/14414793652a5d718b65590036026581/dynaforms"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "array"
And the "dyn_title" property in row 0 equals "DynaForm Demo"
And the "dyn_description" property in row 0 equals "Description"
And the "dyn_type" property in row 0 equals "xmlform"
#GET /api/1.0/{workspace}/project/{prj_uid}/dynaform/{dyn_uid}
# Get a single DynaForm of a Project
Scenario: Get a single DynaForm of a Project
Given that I have a valid access_token
And that I want to get a resource with the key "dynaForm3" stored in session array
And I request "project/14414793652a5d718b65590036026581/dynaform"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
And that "dyn_title" is set to "My DynaForm3"
And that "dyn_description" is set to "My DynaForm3 DESCRIPTION"
And that "dyn_type" is set to "xmlform"
#DELETE /api/1.0/{workspace}/project/{prj_uid}/dynaform/{dyn_uid}
# Delete a DynaForm of a Project
Scenario: Delete a previously created DynaForms
Given that I have a valid access_token
And that I want to delete a resource with the key "dynaForm1" stored in session array
And I request "project/14414793652a5d718b65590036026581/dynaform"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
#DELETE /api/1.0/{workspace}/project/{prj_uid}/dynaform/{dyn_uid}
# Delete a DynaForm of a Project
Scenario: Delete a previously created DynaForms
Given that I have a valid access_token
And that I want to delete a resource with the key "dynaForm2" stored in session array
And I request "project/14414793652a5d718b65590036026581/dynaform"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
#DELETE /api/1.0/{workspace}/project/{prj_uid}/dynaform/{dyn_uid}
# Delete a DynaForm of a Project
Scenario: Delete a previously created DynaForms
Given that I have a valid access_token
And that I want to delete a resource with the key "dynaForm3" stored in session array
And I request "project/14414793652a5d718b65590036026581/dynaform"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
#GET /api/1.0/{workspace}/project/{prj_uid}/dynaforms
# Get a List DynaForms of a Project
Scenario: Get a List DynaForms of a Project
Given that I have a valid access_token
And I request "project/14414793652a5d718b65590036026581/dynaforms"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "array"
And the json data is an empty array
Scenario: Delete a dynaform of a project
Given this scenario is not implemented yet

View File

@@ -0,0 +1,72 @@
@ProcessMakerMichelangelo @RestAPI
Feature: Testing events
@1: TEST FOR POST EVENT /----------------------------------------------------------------------
Scenario: Create a event
Given that I have a valid access_token
And POST this data:
"""
{
"evn_description": "DE BEHAT",
"evn_status": "ACTIVE",
"evn_action": "SEND_MESSAGE",
"evn_related_to": "SINGLE",
"tas_uid": "97192372152a5c78f04a794095806311",
"evn_tas_uid_from": "97192372152a5c78f04a794095806311",
"evn_tas_estimated_duration": 1,
"evn_time_unit": "DAYS",
"evn_when": 1,
"evn_when_occurs": "AFTER_TIME",
"tri_uid": "95325847552af0c07792c15098680510"
}
"""
And I request "project/251815090529619a99a2bf4013294414/event"
Then the response status code should be 201
And store "evn_uid" in session array
@2: TEST FOR PUT EVENT /-----------------------------------------------------------------------
Scenario: Update a event
Given that I have a valid access_token
And PUT this data:
"""
{
"evn_description": "change description",
"evn_status": "ACTIVE",
"evn_action": "SEND_MESSAGE",
"evn_related_to": "SINGLE",
"tas_uid": "97192372152a5c78f04a794095806311",
"evn_tas_uid_from": "97192372152a5c78f04a794095806311",
"evn_tas_estimated_duration": 1,
"evn_time_unit": "DAYS",
"evn_when": 1,
"evn_when_occurs": "AFTER_TIME",
"tri_uid": "95325847552af0c07792c15098680510"
}
"""
And that I want to update a resource with the key "evn_uid" stored in session array
And I request "project/251815090529619a99a2bf4013294414/event"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
@3: TEST FOR GET EVENT /-----------------------------------------------------------------------
Scenario: Get a event
Given that I have a valid access_token
And that I want to get a resource with the key "evn_uid" stored in session array
And I request "project/251815090529619a99a2bf4013294414/event"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
And that "evn_description" is set to "change description"
@4: TEST FOR DELETE EVENT /-----------------------------------------------------------------------
Scenario: Delete a event
Given that I have a valid access_token
And that I want to delete a resource with the key "evn_uid" stored in session array
And I request "project/251815090529619a99a2bf4013294414/event"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"

View File

@@ -1,21 +1,55 @@
@ProcessMakerMichelangelo @RestAPI
Feature: Triggers Resources
Background:
Given that I have a valid access_token
Scenario: Get a List of triggers of a project
Given this scenario is not implemented yet
Scenario: Get a single trigger of a project
Given this scenario is not implemented yet
Scenario: Create a new trigger for a project
Given this scenario is not implemented yet
Scenario: Update a trigger of a project
Given this scenario is not implemented yet
Feature: Testing triggers
Scenario: Delete a trigger of a project
Given this scenario is not implemented yet
@1: TEST FOR POST TRIGGER /--------------------------------------------------------------------
Scenario: Create a trigger
Given that I have a valid access_token
And POST this data:
"""
{
"tri_title": "nuevo trigger",
"tri_description": "descripcion"
}
"""
And I request "project/251815090529619a99a2bf4013294414/trigger"
Then the response status code should be 201
And store "tri_uid" in session array
@2: TEST FOR PUT TRIGGER /-----------------------------------------------------------------------
Scenario: Update a trigger
Given that I have a valid access_token
And PUT this data:
"""
{
"tri_title": "trigger editado",
"tri_description": "descripcion editada"
}
"""
And that I want to update a resource with the key "tri_uid" stored in session array
And I request "project/251815090529619a99a2bf4013294414/trigger"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
@3: TEST FOR GET TRIGGER /-----------------------------------------------------------------------
Scenario: Get a trigger
Given that I have a valid access_token
And that I want to get a resource with the key "tri_uid" stored in session array
And I request "project/251815090529619a99a2bf4013294414/trigger"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
And that "tri_title" is set to "trigger editado"
And that "tri_description" is set to "descripcion editada"
@4: TEST FOR DELETE TRIGGER /-----------------------------------------------------------------------
Scenario: Get a trigger
Given that I have a valid access_token
And that I want to delete a resource with the key "tri_uid" stored in session array
And I request "project/251815090529619a99a2bf4013294414/trigger"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"

View File

@@ -186,7 +186,7 @@ class ProcessSupervisor
}
/**
* Return output documents of a project
* Return dynaform supervisor
* @param string $sProcessUID
*
* @return array
@@ -228,15 +228,63 @@ class ProcessSupervisor
'step_position' => $aRow['STEP_POSITION'],
'title' => $aRow['DYN_TITLE']);
$oDataset->next();
}
return $aResp;
}
return $aResp;
} catch (Exception $e) {
throw $e;
}
}
/**
* Return output documents of a project
* Return available dynaform supervisor
* @param string $sProcessUID
*
* @return array
*
* @access public
*/
public function getAvailableDynaformSupervisors($sProcessUID = '')
{
try {
$oCriteria = $this->getDynaformSupervisor($sProcessUID);
$aUIDS = array();
foreach ($oCriteria as $oCriteria => $value) {
$aUIDS[] = $value["step_uid_obj"];
}
$sDelimiter = \DBAdapter::getStringDelimiter();
$oCriteria = new \Criteria('workflow');
$oCriteria->addSelectColumn(\DynaformPeer::DYN_UID);
$oCriteria->addSelectColumn(\DynaformPeer::PRO_UID);
$oCriteria->addAsColumn('DYN_TITLE', 'C.CON_VALUE');
$oCriteria->addAlias('C', 'CONTENT');
$aConditions = array();
$aConditions[] = array(\DynaformPeer::DYN_UID, 'C.CON_ID');
$aConditions[] = array('C.CON_CATEGORY', $sDelimiter . 'DYN_TITLE' . $sDelimiter);
$aConditions[] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
$oCriteria->addJoinMC($aConditions, \Criteria::LEFT_JOIN);
$oCriteria->add(\DynaformPeer::PRO_UID, $sProcessUID);
$oCriteria->add(\DynaformPeer::DYN_TYPE, 'xmlform');
$oCriteria->add(\DynaformPeer::DYN_UID, $aUIDS, \Criteria::NOT_IN);
$oDataset = \StepSupervisorPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$oDataset = \StepSupervisorPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
while ($aRow = $oDataset->getRow()) {
$aResp[] = array('pro_uid' => $aRow['PRO_UID'],
'dyn_uid' => $aRow['DYN_UID'],
'title' => $aRow['DYN_TITLE']);
$oDataset->next();
}
return $aResp;
} catch (Exception $e) {
throw $e;
}
}
/**
* Return input documents supervisor
* @param string $sProcessUID
*
* @return array
@@ -286,7 +334,55 @@ class ProcessSupervisor
}
/**
* Remove a supervisor of an activity
* Return available inputdocuments supervisor
* @param string $sProcessUID
*
* @return array
*
* @access public
*/
public function getAvailableInputDocumentSupervisor($sProcessUID = '')
{
try {
$oCriteria = $this->getInputDocumentSupervisor($sProcessUID);
$aUIDS = array();
foreach ($oCriteria as $oCriteria => $value) {
$aUIDS[] = $value["step_uid_obj"];
}
$sDelimiter = \DBAdapter::getStringDelimiter();
$oCriteria = new \Criteria('workflow');
$oCriteria->addSelectColumn(\InputDocumentPeer::INP_DOC_UID);
$oCriteria->addSelectColumn(\InputDocumentPeer::PRO_UID);
$oCriteria->addAsColumn('INP_DOC_TITLE', 'C.CON_VALUE');
$oCriteria->addAlias('C', 'CONTENT');
$aConditions = array();
$aConditions[] = array(\InputDocumentPeer::INP_DOC_UID, 'C.CON_ID');
$aConditions[] = array('C.CON_CATEGORY', $sDelimiter . 'INP_DOC_TITLE' . $sDelimiter);
$aConditions[] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
$oCriteria->addJoinMC($aConditions, \Criteria::LEFT_JOIN);
$oCriteria->add(\InputDocumentPeer::PRO_UID, $sProcessUID);
$oCriteria->add(\InputDocumentPeer::INP_DOC_UID, $aUIDS, \Criteria::NOT_IN);
$oDataset = \StepSupervisorPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$oDataset = \StepSupervisorPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
while ($aRow = $oDataset->getRow()) {
$aResp[] = array('pro_uid' => $aRow['PRO_UID'],
'inp_doc_uid' => $aRow['INP_DOC_UID'],
'title' => $aRow['INP_DOC_TITLE']);
$oDataset->next();
}
return $aResp;
} catch (Exception $e) {
throw $e;
}
}
/**
* Remove a supervisor
*
* @param string $sProcessUID
* @param string $sUserUID
@@ -322,7 +418,7 @@ class ProcessSupervisor
}
/**
* Remove a dynaform supervisor of an activity
* Remove a dynaform supervisor
*
* @param string $sProcessUID
* @param string $sDynaformUID
@@ -358,7 +454,7 @@ class ProcessSupervisor
}
/**
* Remove a dynaform supervisor of an activity
* Remove a input document supervisor
*
* @param string $sProcessUID
* @param string $sInputDocumentUID
@@ -408,29 +504,56 @@ class ProcessSupervisor
if ($sTypeUID == 'Group') {
$puType = 'GROUP_SUPERVISOR';
}
$oTypeAssigneeG = \GroupwfPeer::retrieveByPK( $sUsrUID );
$oTypeAssigneeU = \UsersPeer::retrieveByPK( $sUsrUID );
if (is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) {
throw (new \Exception( 'This id: '. $sUsrUID .' do not correspond to a registered ' .$sTypeUID ));
}
if (is_null( $oTypeAssigneeG ) && ! is_null( $oTypeAssigneeU) ) {
$type = "user";
if ( $type != $assType ) {
throw (new \Exception( 'This id: '. $sUsrUID .' do not correspond to a registered ' .$sTypeUID ));
}
}
if (! is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) {
$type = "group";
if ( $type != $assType ) {
throw (new \Exception( 'This id: '. $sUsrUID .' do not correspond to a registered ' .$sTypeUID ));
}
}
if (is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) {
throw (new \Exception( 'This id: '. $sUsrUID .' do not correspond to a registered ' .$sTypeUID ));
}
if (is_null( $oTypeAssigneeG ) && ! is_null( $oTypeAssigneeU) ) {
$type = "User";
if ( $type != $sTypeUID ) {
throw (new \Exception( 'This id: '. $sUsrUID .' do not correspond to a registered ' .$sTypeUID ));
}
}
if (! is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) {
$type = "Group";
if ( $type != $sTypeUID ) {
throw (new \Exception( 'This id: '. $sUsrUID .' do not correspond to a registered ' .$sTypeUID ));
}
}
$oProcessUser->create(array('PU_UID' => \G::generateUniqueID(), 'PRO_UID' => $sProcessUID, 'USR_UID' => $sUsrUID, 'PU_TYPE' => $puType));
}
/**
* Assign a dynaform supervisor of a process
*
* @param string $sProcessUID
* @param string $sDynUID
* @access public
*/
public function addDynaformSupervisor($sProcessUID, $sDynUID)
{
$oStepSupervisor = new \StepSupervisor();
$oStepSupervisor->create(array('PRO_UID' => $sProcessUID,
'STEP_TYPE_OBJ' => "DYNAFORM",
'STEP_UID_OBJ' => $sDynUID,
'STEP_POSITION' => $oStepSupervisor->getNextPosition($sProcessUID, "DYNAFORM")));
}
/**
* Assign a inputdocument supervisor of a process
*
* @param string $sProcessUID
* @param string $sInputDocumentUID
* @access public
*/
public function addInputDocumentSupervisor($sProcessUID, $sInputDocumentUID)
{
$oStepSupervisor = new \StepSupervisor();
$oStepSupervisor->create(array('PRO_UID' => $sProcessUID,
'STEP_TYPE_OBJ' => "INPUT_DOCUMENT",
'STEP_UID_OBJ' => $sInputDocumentUID,
'STEP_POSITION' => $oStepSupervisor->getNextPosition($sProcessUID, "DYNAFORM")));
}
}

View File

@@ -33,28 +33,6 @@ class ProcessSupervisors extends Api
return $response;
}
/**
* @param string $prjUid {@min 32} {@max 32}
* @param string $filter
* @param int $start
* @param int $limit
*
* @url GET /:prjUid/available-supervisors
*/
public function doGetAvailableSupervisors($prjUid, $filter = '', $start = null, $limit = null)
{
try {
$supervisor = new \BusinessModel\ProcessSupervisor();
$arrayData = $supervisor->getAvailableSupervisors($prjUid, $filter, $start, $limit);
//Response
$response = $arrayData;
} catch (\Exception $e) {
//response
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
return $response;
}
/**
* @param string $prjUid {@min 32} {@max 32}
*
@@ -93,6 +71,68 @@ class ProcessSupervisors extends Api
return $response;
}
/**
* @param string $prjUid {@min 32} {@max 32}
* @param string $filter
* @param int $start
* @param int $limit
*
* @url GET /:prjUid/available-supervisors
*/
public function doGetAvailableSupervisors($prjUid, $filter = '', $start = null, $limit = null)
{
try {
$supervisor = new \BusinessModel\ProcessSupervisor();
$arrayData = $supervisor->getAvailableSupervisors($prjUid, $filter, $start, $limit);
//Response
$response = $arrayData;
} catch (\Exception $e) {
//response
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
return $response;
}
/**
* @param string $prjUid {@min 32} {@max 32}
*
* @url GET /:prjUid/available-dynaform-supervisor
*/
public function doGetAvailableDynaformSupervisor($prjUid)
{
try {
$supervisor = new \BusinessModel\ProcessSupervisor();
$arrayData = $supervisor->getAvailableDynaformSupervisors($prjUid);
//Response
$response = $arrayData;
} catch (\Exception $e) {
//response
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
return $response;
}
/**
* @param string $prjUid {@min 32} {@max 32}
*
* @url GET /:prjUid/available-inputdocument-supervisor
*/
public function doGetAvailableInputDocumentSupervisor($prjUid)
{
try {
$supervisor = new \BusinessModel\ProcessSupervisor();
$arrayData = $supervisor->getAvailableInputDocumentSupervisor($prjUid);
//Response
$response = $arrayData;
} catch (\Exception $e) {
//response
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
return $response;
}
/**
* @url DELETE /:prjUid/supervisor/:supUid
*
@@ -172,6 +212,44 @@ class ProcessSupervisors extends Api
return $response;
}
/**
* @url POST /:prjUid/dynaform-supervisor
*
* @param string $prjUid
* @param string $dyn_uid
*
* @status 201
*/
public function doPostDynaformSupervisors($prjUid, $dyn_uid)
{
try {
$supervisor = new \BusinessModel\ProcessSupervisor();
$arrayData = $supervisor->addDynaformSupervisor($prjUid, $dyn_uid);
} catch (\Exception $e) {
//Response
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
return $response;
}
/**
* @url POST /:prjUid/inputdocument-supervisor
*
* @param string $prjUid
* @param string $inp_doc_uid
*
* @status 201
*/
public function doPostInputDocumentSupervisors($prjUid, $inp_doc_uid)
{
try {
$supervisor = new \BusinessModel\ProcessSupervisor();
$arrayData = $supervisor->addInputDocumentSupervisor($prjUid, $inp_doc_uid);
} catch (\Exception $e) {
//Response
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
return $response;
}
}