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

This commit is contained in:
Brayan Osmar Pereyra Suxo
2014-02-06 09:29:20 -04:00
23 changed files with 738 additions and 288 deletions

View File

@@ -0,0 +1,87 @@
@ProcessMakerMichelangelo @RestAPI
Feature: DataBase Connections
Scenario: List all the database connections (result 0 database connections)
Given that I have a valid access_token
And I request "project/74737540052e1641ab88249082085472/database-connections"
Then the response status code should be 200
And the response charset is "UTF-8"
And the response has 0 record
Scenario: Create a new database connection
Given that I have a valid access_token
And POST this data:
"""
{
"dbs_type": "mysql",
"dbs_server": "192.168.11.71",
"dbs_database_name": "rb_cochalo",
"dbs_username": "root",
"dbs_password": "atopml2005",
"dbs_port": 3306,
"dbs_encode": "utf8",
"dbs_description": "conection correcta"
}
"""
And I request "project/74737540052e1641ab88249082085472/database-connection"
Then the response status code should be 201
And store "dbs_uid" in session array
@3: TEST FOR GET DATABASE CONNECTIONS /----------------------------------------------------------------------
Scenario: List all the database connections (result 1 database connection)
Given that I have a valid access_token
And I request "project/74737540052e1641ab88249082085472/database-connections"
Then the response status code should be 200
And the response charset is "UTF-8"
And the response has 1 record
@4: TEST FOR PUT DATABASE CONNECTION /-----------------------------------------------------------------------
Scenario: Update a database connection
Given that I have a valid access_token
And PUT this data:
"""
{
"dbs_type": "mysql",
"dbs_server": "192.168.11.71",
"dbs_database_name": "wf_cochalo",
"dbs_username": "root",
"dbs_password": "atopml2005",
"dbs_port": 3306,
"dbs_encode": "utf8",
"dbs_description": "conection correcta a workflow"
}
"""
And that I want to update a resource with the key "dbs_uid" stored in session array
And I request "project/74737540052e1641ab88249082085472/database-connection"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
Scenario: Get a database connection (with change in "dbs_description" and "dbs_database_name")
Given that I have a valid access_token
And that I want to get a resource with the key "dbs_uid" stored in session array
And I request "project/74737540052e1641ab88249082085472/database-connection"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
And that "dbs_description" is set to "conection correcta a workflow"
And that "dbs_database_name" is set to "wf_cochalo"
Scenario: Delete a database connection
Given that I have a valid access_token
And that I want to delete a resource with the key "dbs_uid" stored in session array
And I request "project/74737540052e1641ab88249082085472/database-connection"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
@7: TEST FOR GET DATABASE CONNECTIONS /----------------------------------------------------------------------
Scenario: List all the database connections (result 0 database connections)
Given that I have a valid access_token
And I request "project/74737540052e1641ab88249082085472/database-connections"
Then the response status code should be 200
And the response charset is "UTF-8"
And the response has 0 record

View File

@@ -15,16 +15,16 @@ Feature: Project User Resources Main Tests
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has 52 records
And the response has 6 records
Scenario: Get a list of starting task of a project when there are exactly 3 tasks
Scenario: Get a list of starting task of a project when there are exactly 2 tasks
Given I request "project/1265557095225ff5c688f46031700471/starting-tasks"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has 3 records
And the response has 2 records
Scenario Outline: Get a list of start task of a specific user
@@ -38,8 +38,8 @@ Feature: Project User Resources Main Tests
| test_description | usr_uid |
| Verify that this user admin tasks | 00000000000000000000000000000001 |
| Verify that this user adam tasks | 44811996752d567110634a1013636964 |
| Verify that this user magda tasks | 36116269152d56733b20e86062657385 |
| Verify that this user adam tasks | 16333273052d567284e6766029512960 |
| Verify that this user magda tasks | 90909671452d56718417612014706933 |
Scenario Outline: Verify if a user can start a task
@@ -61,7 +61,6 @@ Feature: Project User Resources Main Tests
| test_description | act_uid | username | password |
| Properties of user admin - task 1 | 1352844695225ff5fe54de2005407079 | admin | admin |
| Properties of user adam - task 1 | 1352844695225ff5fe54de2005407079 | adam | sample |
| Properties of user admin - task 2 | 1546168275225ff617b6a34046164891 | admin | admin |
| Properties of user erick - task 2 | 1546168275225ff617b6a34046164891 | erick | sample |
| Properties of user admin - task 4 | 46941969352af5be2ab3f39001216717 | admin | admin |
| Properties of user owen - task 1 | 1352844695225ff5fe54de2005407079 | owen | sample |
| Properties of user admin - task 1 | 1352844695225ff5fe54de2005407079 | alyssa | sample |
| Properties of user owen - task 2 | 46941969352af5be2ab3f39001216717 | admin | admin |

View File

@@ -30,7 +30,7 @@ Scenario Outline: Verify if a user can start a task with bad parameters (negativ
| test_description | project | act_uid | username | password | error_code | error_message |
| Invalid act_uid | 1265557095225ff5c688f46031700471 | 00000000009999f5fe54de2005407079 | admin | admin | 400 | act_uid |
| Invalid username | 1265557095225ff5c688f46031700471 | 1546168275225ff617b6a34046164891 | ain | admin | 400 | username |
| Invalid username | 1265557095225ff5c688f46031700471 | 1546168275225ff617b6a34046164891 | ain | admin | 400 | User |
| Invalid password | 1265557095225ff5c688f46031700471 | 1546168275225ff617b6a34046164891 | erick | sle | 400 | password |
| Field requered project | | 46941969352af5be2ab3f39001216717 | admin | admin | 400 | prj_uid |
| Field requered act_uid | 1265557095225ff5c688f46031700471 | | admin | admin | 400 | act_uid |

View File

@@ -1,14 +1,16 @@
@ProcessMakerMichelangelo @RestAPI
Feature: Web Entry
Feature: Web Entry Main Tests
Requirements:
Default user "admin" with password "admin"
a workspace with the process 28733629952e66a362c4f63066393844 ("Sample Project #5 (Web Entry)") already loaded
there are zero web entry in the process
Default user "admin" with password "admin"
Background:
Given that I have a valid access_token
#GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/assignee?filter=john&start=0&limit=50
# List assignees of an activity
Scenario Outline: List assignees of an activity
#ASSIGNEE USER OF AN ACTIVITY
Scenario Outline: List assignees of an activity
Given I request "project/28733629952e66a362c4f63066393844/activity/<tas_uid>/assignee"
And the content type is "application/json"
Then the response status code should be 200
@@ -22,8 +24,7 @@ Feature: Web Entry
| 56118778152e66babcc2103002009439 | Task 2 |
| 18096002352e66bc1643af8048493068 | Task 3 |
#POST /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/assignee
# Assign a user or group to an activity
Scenario Outline: Assign a user or group to an activity
Given POST this data:
"""
@@ -46,9 +47,7 @@ Feature: Web Entry
#WEB ENTRY
#GET /api/1.0/{workspace}/project/{prj_uid}/web-entries
# Get list Web Entries of a Project
Scenario: Get list Web Entries of a Project
Scenario: Get list Web Entries of a Project when there are exactly zero web entries
And I request "project/28733629952e66a362c4f63066393844/web-entries"
And the content type is "application/json"
Then the response status code should be 200
@@ -56,9 +55,7 @@ Feature: Web Entry
And the type is "array"
And the json data is an empty array
#POST /api/1.0/{workspace}/project/{prj_uid}/web-entry
# Create a new Web Entry for a project
# Create a new Web Entry using the method: PHP pages with Web Services
Scenario Outline: Create a new Web Entry using the method: PHP pages with Web Services
Given POST this data:
"""
@@ -78,15 +75,25 @@ Feature: Web Entry
And the type is "object"
And the response has a "url" property
And the "url" property type is "string"
And store "url" in session array as variable "url_<url_number>"
Examples:
| tas_uid | tas_title | dyn_uid | dyn_title |
| 44199549652e66ba533bb06088252754 | Task 1 | 60308801852e66b7181ae21045247174 |DynaForm Demo1 |
| 56118778152e66babcc2103002009439 | Task 2 | 99869771852e66b7dc4b858088901665 |DynaForm Demo2 |
| tas_uid | tas_title | dyn_uid | dyn_title | url_number |
| 44199549652e66ba533bb06088252754 | Task 1 | 60308801852e66b7181ae21045247174 | DynaForm Demo1 | 1 |
| 56118778152e66babcc2103002009439 | Task 2 | 99869771852e66b7dc4b858088901665 | DynaForm Demo2 | 2 |
Scenario Outline: Test webentry URL
Given I request "url" with the key "url" stored in session array as variable "url_<url_number>" and url is "absolute"
And the content type is "text/html"
Then the response status code should be 200
Examples:
| url_number |
| 1 |
| 2 |
#POST /api/1.0/{workspace}/project/{prj_uid}/web-entry
# Create a new Web Entry for a project
# Create a new Web Entry using the method: Single HTML
Scenario Outline: Create a new Web Entry using the method: Single HTML
Given POST this data:
"""
@@ -106,11 +113,10 @@ Feature: Web Entry
And the "html" property type is "string"
Examples:
| tas_uid | tas_title | dyn_uid | dyn_title |
| 18096002352e66bc1643af8048493068 | Task 3 | 37977455352e66b892babe6071295002 |DynaForm Demo3 |
| tas_uid | tas_title | dyn_uid | dyn_title |
| 18096002352e66bc1643af8048493068 | Task 3 | 37977455352e66b892babe6071295002 | DynaForm Demo3 |
#GET /api/1.0/{workspace}/project/{prj_uid}/web-entries
# Get list Web Entries of a Project
Scenario Outline: Get list Web Entries of a Project
And I request "project/28733629952e66a362c4f63066393844/web-entries"
And the content type is "application/json"
@@ -127,8 +133,7 @@ Feature: Web Entry
| 0 | 44199549652e66ba533bb06088252754 | Task 1 | 60308801852e66b7181ae21045247174 |DynaForm Demo1 |
| 1 | 56118778152e66babcc2103002009439 | Task 2 | 99869771852e66b7dc4b858088901665 |DynaForm Demo2 |
#GET GET /api/1.0/{workspace}/project/{prj_uid}/web-entry/{tas_uid}/{dyn_uid}
# Get a single Web Entry of a Project
Scenario Outline: Get a single Web Entry of a Project
Given that I want to get a resource with the key "obj_uid" stored in session array
And I request "project/28733629952e66a362c4f63066393844/web-entry/<tas_uid>/<dyn_uid>"
@@ -146,62 +151,7 @@ Feature: Web Entry
| 44199549652e66ba533bb06088252754 | Task 1 | 60308801852e66b7181ae21045247174 |DynaForm Demo1 |
| 56118778152e66babcc2103002009439 | Task 2 | 99869771852e66b7dc4b858088901665 |DynaForm Demo2 |
#DELETE /api/1.0/{workspace}/project/{prj_uid}/web-entry/{tas_uid}/{dyn_uid}
# Delete a Web Entry of a Project
Scenario Outline: Delete a Web Entry of a Project
Given that I want to delete a resource with the key "obj_uid" stored in session array
And I request "project/28733629952e66a362c4f63066393844/web-entry/<tas_uid>/<dyn_uid>"
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"
Examples:
| tas_uid | tas_title | dyn_uid | dyn_title |
| 44199549652e66ba533bb06088252754 | Task 1 | 60308801852e66b7181ae21045247174 |DynaForm Demo1 |
| 56118778152e66babcc2103002009439 | Task 2 | 99869771852e66b7dc4b858088901665 |DynaForm Demo2 |
#GET /api/1.0/{workspace}/project/{prj_uid}/web-entries
# Get list Web Entries of a Project
Scenario: Get list Web Entries of a Project
And I request "project/28733629952e66a362c4f63066393844/web-entries"
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
#WEB ENTRY - END
#DELETE /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/assignee/{aas_uid}
# Remove an assignee of an activity
Scenario Outline: Remove an assignee of an activity
Given that I want to delete a resource with the key "obj_uid" stored in session array
And I request "project/28733629952e66a362c4f63066393844/activity/<tas_uid>/assignee/<aas_uid>"
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"
Examples:
| tas_uid | tas_title | aas_uid |
| 44199549652e66ba533bb06088252754 | Task 1 | 00000000000000000000000000000001 |
| 56118778152e66babcc2103002009439 | Task 2 | 00000000000000000000000000000001 |
| 18096002352e66bc1643af8048493068 | Task 3 | 00000000000000000000000000000001 |
#GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/assignee?filter=john&start=0&limit=50
# List assignees of an activity
Scenario Outline: List assignees of an activity
Given I request "project/28733629952e66a362c4f63066393844/activity/<tas_uid>/assignee"
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
Examples:
| tas_uid | tas_title |
| 44199549652e66ba533bb06088252754 | Task 1 |
| 56118778152e66babcc2103002009439 | Task 2 |
| 18096002352e66bc1643af8048493068 | Task 3 |

View File

@@ -0,0 +1,59 @@
@ProcessMakerMichelangelo @RestAPI
Feature: Webentry Negative Tests
Background:
Given that I have a valid access_token
Scenario Outline: Create a new Web Entry using the method: PHP pages with Web Services with bad parameters (negative tests)
Given POST this data:
"""
{
"tas_uid": "<tas_uid>",
"dyn_uid": "<dyn_uid>",
"method": "<method>",
"input_document_access": 1,
"usr_username": "<usr_username>",
"usr_password": "<usr_password>"
}
"""
And I request "project/<project>/web-entry"
Then the response status code should be <error_code>
And the response status message should have the following text "<error_message>"
Examples:
| test_description | project | tas_uid | tas_title | dyn_uid | dyn_title | method | usr_username | usr_password | error_code | error_message |
| Invalid method | 28733629952e66a362c4f63066393844 | 44199549652e66ba533bb06088252754 | Task 1 | 60308801852e66b7181ae21045247174 | DynaForm Demo1 | JS | admin | admin | 400 | method |
| Invalid usr_username | 28733629952e66a362c4f63066393844 | 56118778152e66babcc2103002009439 | Task 2 | 99869771852e66b7dc4b858088901665 | DynaForm Demo2 | HTML | aaron | admin | 400 | users |
| Invalid usr_password | 28733629952e66a362c4f63066393844 | 44199549652e66ba533bb06088252754 | Task 1 | 60308801852e66b7181ae21045247174 | DynaForm Demo1 | WS | admin | sample | 400 | password |
| Field required prj_uid | | 56118778152e66babcc2103002009439 | Task 2 | 99869771852e66b7dc4b858088901665 | DynaForm Demo2 | HTML | admin | admin | 400 | prj_uid |
| Field required tas_uid | 28733629952e66a362c4f63066393844 | | Task 1 | 60308801852e66b7181ae21045247174 | DynaForm Demo1 | WS | admin | admin | 400 | tas_uid |
| Field required dyn_uid | 28733629952e66a362c4f63066393844 | 56118778152e66babcc2103002009439 | Task 2 | | DynaForm Demo2 | HTML | admin | admin | 400 | dyn_uid |
| Field required method | 28733629952e66a362c4f63066393844 | 44199549652e66ba533bb06088252754 | Task 1 | 60308801852e66b7181ae21045247174 | DynaForm Demo1 | | admin | admin | 400 | method |
Scenario Outline: Create a new Web Entry using the method: Single HTML
Given POST this data:
"""
{
"tas_uid": "<tas_uid>",
"dyn_uid": "<dyn_uid>",
"method": "<method>",
"input_document_access": 1
}
"""
And I request "project/<project>/web-entry"
Then the response status code should be <error_code>
And the response status message should have the following text "<error_message>"
Examples:
| test_description | project | tas_uid | tas_title | dyn_uid | dyn_title | method | error_code | error_message |
| Invalid method | 28733629952e66a362c4f63066393844 | 18096002352e66bc1643af8048493068 | Task 1 | 37977455352e66b892babe6071295002 | DynaForm Demo1 | JS | 400 | method |
| Invalid usr_username | 28733629952e66a362c4f63066393844 | 18096002352e66bc1643af8048493068 | Task 2 | 37977455352e66b892babe6071295002 | DynaForm Demo2 | HTML | 400 | users |
| Invalid usr_password | 28733629952e66a362c4f63066393844 | 18096002352e66bc1643af8048493068 | Task 1 | 37977455352e66b892babe6071295002 | DynaForm Demo1 | WS | 400 | usr_username |
| Field required prj_uid | | 18096002352e66bc1643af8048493068 | Task 2 | 37977455352e66b892babe6071295002 | DynaForm Demo2 | HTML | 400 | prj_uid |
| Field required tas_uid | 28733629952e66a362c4f63066393844 | | Task 1 | 37977455352e66b892babe6071295002 | DynaForm Demo1 | WS | 400 | tas_uid |
| Field required dyn_uid | 28733629952e66a362c4f63066393844 | 18096002352e66bc1643af8048493068 | Task 2 | | DynaForm Demo2 | HTML | 400 | dyn_uid |
| Field required method | 28733629952e66a362c4f63066393844 | 18096002352e66bc1643af8048493068 | Task 1 | 37977455352e66b892babe6071295002 | DynaForm Demo1 | | 400 | method |

View File

@@ -0,0 +1,71 @@
@ProcessMakerMichelangelo @RestAPI
Feature: Web Entry - Remove Assignee and Web Entries
Background:
Given that I have a valid access_token
Scenario Outline: Remove an assignee of an activity
Given that I want to delete a resource with the key "obj_uid" stored in session array
And I request "project/28733629952e66a362c4f63066393844/activity/<tas_uid>/assignee/<aas_uid>"
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"
Examples:
| tas_uid | tas_title | aas_uid |
| 44199549652e66ba533bb06088252754 | Task 1 | 00000000000000000000000000000001 |
| 56118778152e66babcc2103002009439 | Task 2 | 00000000000000000000000000000001 |
| 18096002352e66bc1643af8048493068 | Task 3 | 00000000000000000000000000000001 |
Scenario Outline: Delete a Web Entry of a Project
Given that I want to delete a resource with the key "obj_uid" stored in session array
And I request "project/28733629952e66a362c4f63066393844/web-entry/<tas_uid>/<dyn_uid>"
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"
Examples:
| tas_uid | tas_title | dyn_uid | dyn_title |
| 44199549652e66ba533bb06088252754 | Task 1 | 60308801852e66b7181ae21045247174 |DynaForm Demo1 |
| 56118778152e66babcc2103002009439 | Task 2 | 99869771852e66b7dc4b858088901665 |DynaForm Demo2 |
Scenario Outline: List assignees of an activity
Given I request "project/28733629952e66a362c4f63066393844/activity/<tas_uid>/assignee"
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
Examples:
| tas_uid | tas_title |
| 44199549652e66ba533bb06088252754 | Task 1 |
| 56118778152e66babcc2103002009439 | Task 2 |
| 18096002352e66bc1643af8048493068 | Task 3 |
Scenario Outline: List assignees of an activity
Given I request "project/28733629952e66a362c4f63066393844/activity/<tas_uid>/assignee"
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
Examples:
| tas_uid | tas_title |
| 44199549652e66ba533bb06088252754 | Task 1 |
| 56118778152e66babcc2103002009439 | Task 2 |
| 18096002352e66bc1643af8048493068 | Task 3 |
Scenario: Get list Web Entries of a Project
And I request "project/28733629952e66a362c4f63066393844/web-entries"
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

View File

@@ -331,7 +331,7 @@ class RestContext extends BehatContext
/**
* @When /^I request "([^"]*)"$/
*/
public function iRequest($pageUrl)
public function iRequest($pageUrl, $urlType="")
{
$this->_startTime = microtime(true);
$baseUrl = $this->getParameter('base_url');
@@ -339,7 +339,12 @@ class RestContext extends BehatContext
$this->_headers['Authorization'] = 'Bearer ' . $this->access_token;
}
$this->_requestUrl = $baseUrl . $pageUrl;
if($urlType=="absolute"){
$this->_requestUrl = $pageUrl;
}else{
$this->_requestUrl = $baseUrl . $pageUrl;
}
$url = false !== strpos($pageUrl, '{')
? array($this->_requestUrl, (array)$this->_restObject)
: $this->_requestUrl;
@@ -1215,8 +1220,9 @@ class RestContext extends BehatContext
/**
* @Given /^I request "([^"]*)" with the key "([^"]*)" stored in session array as variable "([^"]*)"$/
* @Given /^I request "([^"]*)" with the key "([^"]*)" stored in session array as variable "([^"]*)" and url is "([^"]*)"$/
*/
public function iRequestWithTheKeyStoredInSessionArrayAsVariable($pageUrl, $varName, $sessionVarName)
public function iRequestWithTheKeyStoredInSessionArrayAsVariable($pageUrl, $varName, $sessionVarName, $urlType="")
{
if (file_exists("session.data")) {
$sessionData = json_decode(file_get_contents("session.data"));
@@ -1236,7 +1242,7 @@ class RestContext extends BehatContext
$this->printDebug("URL: $pageUrl\n$varName = $varValue\n");
$this->iRequest($pageUrl);
$this->iRequest($pageUrl, $urlType);

View File

@@ -383,6 +383,7 @@ class Bootstrap
self::registerClass("Users", PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Users.php");
self::registerClass("UsersPeer", PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "UsersPeer.php");
self::registerClass("ReportTables", PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.reportTables.php");
self::registerClass("PMPluginRegistry", PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.pluginRegistry.php");
self::registerClass("Xml_Node", PATH_GULLIVER . "class.xmlDocument.php");

View File

@@ -30,6 +30,8 @@
* @package workflow.engine.classes
*/
require_once 'class.plugin.php';
class pluginDetail
{
public $sNamespace;
@@ -129,7 +131,7 @@ class PMPluginRegistry
*
* @return object
*/
public function &getSingleton ()
public static function getSingleton ()
{
if (self::$instance == null) {
self::$instance = new PMPluginRegistry();

View File

@@ -58,7 +58,7 @@ G::LoadClass( 'pmFunctions' );
//call plugin
if (class_exists( 'folderData' )) {
//$folderData = new folderData($sProUid, $proFields['PRO_TITLE'], $sAppUid, $Fields['APP_TITLE'], $sUsrUid);
$oPluginRegistry = &PMPluginRegistry::getSingleton();
$oPluginRegistry = PMPluginRegistry::getSingleton();
$aAvailablePmFunctions = $oPluginRegistry->getPmFunctions();
foreach ($aAvailablePmFunctions as $key => $class) {
$filePlugin = PATH_PLUGINS . $class . PATH_SEP . 'classes' . PATH_SEP . 'class.pmFunctions.php';

View File

@@ -567,7 +567,7 @@ class Process extends BaseProcess
return (is_object( $oPro ) && get_class( $oPro ) == 'Process');
}
public function existsByProTitle ($PRO_TITLE)
public static function existsByProTitle ($PRO_TITLE)
{
$oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn( 'COUNT(*) AS PROCESS' );

View File

@@ -39,64 +39,63 @@ class ProcessProxy extends HttpProxyController
{
$projectType = empty($_GET['type']) ? 'classicProject' : $_GET['type'];
require_once 'classes/model/Task.php';
G::LoadClass( 'processMap' );
$oProcessMap = new ProcessMap();
$httpData->PRO_TITLE = trim( $httpData->PRO_TITLE );
try {
if (! isset( $httpData->PRO_UID )) {
if (Process::existsByProTitle( $httpData->PRO_TITLE )) {
$result = array ('success' => false,'msg' => G::LoadTranslation( 'ID_SAVE_PROCESS_ERROR' ),'errors' => array ('PRO_TITLE' => G::LoadTranslation( 'ID_PROCESSTITLE_ALREADY_EXISTS', SYS_LANG, Array ('PRO_TITLE' => $httpData->PRO_TITLE
) )
)
);
print G::json_encode( $result );
exit( 0 );
}
$processData['USR_UID'] = $_SESSION['USER_LOGGED'];
$processData['PRO_TITLE'] = $httpData->PRO_TITLE;
$processData['PRO_DESCRIPTION'] = $httpData->PRO_DESCRIPTION;
$processData['PRO_CATEGORY'] = $httpData->PRO_CATEGORY;
$sProUid = $oProcessMap->createProcess( $processData );
//call pluginsx
$oData['PRO_UID'] = $sProUid;
$oData['PRO_TEMPLATE'] = isset( $httpData->PRO_TEMPLATE ) && $httpData->PRO_TEMPLATE != '' ? $httpData->PRO_TEMPLATE : '';
$oData['PROCESSMAP'] = $oProcessMap;
$oPluginRegistry = & PMPluginRegistry::getSingleton();
$oPluginRegistry->executeTriggers( PM_NEW_PROCESS_SAVE, $oData );
$data = (array) $httpData;
$data['PRO_CREATE_USER'] = $_SESSION['USER_LOGGED'];
if ($projectType == "classicProject") {
$project = new ProcessMaker\Project\Workflow($data);
} else {
//$oProcessMap->updateProcess($_POST['form']);
$sProUid = $httpData->PRO_UID;
$project = new ProcessMaker\Project\Adapter\WorkflowBpmn($data);
}
//Save Calendar ID for this process
if (isset( $httpData->PRO_CALENDAR )) {
G::LoadClass( "calendar" );
$calendarObj = new Calendar();
$calendarObj->assignCalendarTo( $sProUid, $httpData->PRO_CALENDAR, 'PROCESS' );
}
$sProUid = $project->getUid();
// Creating BPMN Project Layer
if ($projectType == 'bpmnProject') {
$bpmnModel = new ProcessMaker\Adapter\Bpmn\Model();
$replaceUids = false;
$data = array(
'PRJ_UID' => $sProUid,
'PRJ_NAME' => $httpData->PRO_TITLE,
'PRJ_DESCRIPTION' => $httpData->PRO_DESCRIPTION,
'PRJ_CATEGORY' => $httpData->PRO_CATEGORY
);
$result = $bpmnModel->createProject($data, $replaceUids);
}
// require_once 'classes/model/Task.php';
// G::LoadClass( 'processMap' );
// $oProcessMap = new ProcessMap();
//
// $httpData->PRO_TITLE = trim( $httpData->PRO_TITLE );
//
// try {
// if (! isset( $httpData->PRO_UID )) {
// if (Process::existsByProTitle( $httpData->PRO_TITLE )) {
// $result = array ('success' => false,'msg' => G::LoadTranslation( 'ID_SAVE_PROCESS_ERROR' ),'errors' => array ('PRO_TITLE' => G::LoadTranslation( 'ID_PROCESSTITLE_ALREADY_EXISTS', SYS_LANG, Array ('PRO_TITLE' => $httpData->PRO_TITLE
// ) )
// )
// );
// print G::json_encode( $result );
// exit( 0 );
// }
//
// $processData['USR_UID'] = $_SESSION['USER_LOGGED'];
// $processData['PRO_TITLE'] = $httpData->PRO_TITLE;
// $processData['PRO_DESCRIPTION'] = $httpData->PRO_DESCRIPTION;
// $processData['PRO_CATEGORY'] = $httpData->PRO_CATEGORY;
//
// $sProUid = $oProcessMap->createProcess( $processData );
//
// //call pluginsx
// $oData['PRO_UID'] = $sProUid;
// $oData['PRO_TEMPLATE'] = isset( $httpData->PRO_TEMPLATE ) && $httpData->PRO_TEMPLATE != '' ? $httpData->PRO_TEMPLATE : '';
// $oData['PROCESSMAP'] = $oProcessMap;
//
// $oPluginRegistry = & PMPluginRegistry::getSingleton();
// $oPluginRegistry->executeTriggers( PM_NEW_PROCESS_SAVE, $oData );
//
// } else {
// //$oProcessMap->updateProcess($_POST['form']);
// $sProUid = $httpData->PRO_UID;
// }
//
// //Save Calendar ID for this process
// if (isset( $httpData->PRO_CALENDAR )) {
// G::LoadClass( "calendar" );
// $calendarObj = new Calendar();
// $calendarObj->assignCalendarTo( $sProUid, $httpData->PRO_CALENDAR, 'PROCESS' );
// }
//
$this->success = true;
$this->PRO_UID = $sProUid;

View File

@@ -177,14 +177,18 @@ class ProjectUser
\G::LoadClass( 'case' );
$oCase = new \Cases();
$startTasks = $oCase->getStartCases($sUserUID);
foreach ($startTasks as $task) {
if ((isset( $task['pro_uid'] )) && ($task['pro_uid'] == $sProcessUID)) {
$taskValue = explode( '(', $task['value'] );
$tasksLastIndex = count( $taskValue ) - 1;
$taskValue = explode( ')', $taskValue[$tasksLastIndex] );
$aUsers[] = array('act_uid' => $task['uid'],
'act_name' => $taskValue[0]);
if (sizeof($startTasks) > 1){
foreach ($startTasks as $task) {
if ((isset( $task['pro_uid'] )) && ($task['pro_uid'] == $sProcessUID)) {
$taskValue = explode( '(', $task['value'] );
$tasksLastIndex = count( $taskValue ) - 1;
$taskValue = explode( ')', $taskValue[$tasksLastIndex] );
$aUsers[] = array('act_uid' => $task['uid'],
'act_name' => $taskValue[0]);
}
}
} else {
throw (new \Exception( 'This user `usr_uid`: '. $sUserUID .' has no initial activities assigned in this project.'));
}
return $aUsers;
} catch (Exception $e) {

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,20 @@
<?php
namespace ProcessMaker\Exception;
use ProcessMaker\Project;
class ProjectAlreadyExists extends \RuntimeException
{
const EXCEPTION_CODE = 21;
public function __construct(Project\Handler $obj, $name, $message = "", \Exception $previous = null) {
$message = empty($message) ? sprintf("Project \"%s\" with name: %s, already exists.", get_class($obj), $name) : $message;
parent::__construct($message, self::EXCEPTION_CODE, $previous);
}
public function __toString()
{
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace ProcessMaker\Project\Adapter;
use ProcessMaker\Project;
use ProcessMaker\Util\Hash;
class WorkflowBpmn extends Project\Workflow
{
/**
* OVERRIDES
*/
public function create($data)
{
try {
parent::create($data);
} catch (\Exception $e) {
throw new \RuntimeException(sprintf("Can't create Workflow Project." . PHP_EOL . $e->getMessage()));
}
try {
$bpData = array();
$bpData["PRJ_UID"] = $this->getUid();
if (array_key_exists("PRO_TITLE", $data)) {
$bpData["PRJ_NAME"] = $data["PRO_TITLE"];
}
if (array_key_exists("PRO_DESCRIPTION", $data)) {
$bpData["PRJ_DESCRIPTION"] = $data["PRO_DESCRIPTION"];
}
if (array_key_exists("PRO_CREATE_USER", $data)) {
$bpData["PRJ_AUTHOR"] = $data["PRO_CREATE_USER"];
} elseif (array_key_exists("USR_UID", $data)) {
$bpData["PRJ_AUTHOR"] = $data["USR_UID"];
}
$wp = new Project\Bpmn();
$wp->create($bpData);
} catch (\Exception $e) {
$prjUid = $this->getUid();
$this->remove();
throw new \RuntimeException(sprintf(
"Can't create Project with prj_uid: %s, workflow creation fails." . PHP_EOL . $e->getMessage()
, $prjUid
));
}
}
}

View File

@@ -49,15 +49,37 @@ class Workflow extends Handler
public function create($data)
{
try {
// setting defaults
$data['PRO_UID'] = array_key_exists('PRO_UID', $data) ? $data['PRO_UID'] : Hash::generateUID();
$data['USR_UID'] = array_key_exists('PRO_CREATE_USER', $data) ? $data['PRO_CREATE_USER'] : null;
$data['PRO_CATEGORY'] = array_key_exists('PRO_CATEGORY', $data) ? $data['PRO_CATEGORY'] : '';
$data['PRO_TITLE'] = array_key_exists('PRO_TITLE', $data) ? trim($data['PRO_TITLE']) : "";
$data['PRO_CATEGORY'] = array_key_exists('PRO_CATEGORY', $data) ? $data['PRO_CATEGORY'] : "";
//validate if process with specified name already exists
if (Process::existsByProTitle($data["PRO_TITLE"])) {
throw new Exception\ProjectAlreadyExists($this, $data["PRO_TITLE"]);
}
// Create project
$process = new Process();
$this->proUid = $process->create($data, false);
// Call Plugins
$pluginData['PRO_UID'] = $this->proUid;
$pluginData['PRO_TEMPLATE'] = empty($data["PRO_TEMPLATE"]) ? "" : $data["PRO_TEMPLATE"];
$pluginData['PROCESSMAP'] = null;
$pluginRegistry = \PMPluginRegistry::getSingleton();
$pluginRegistry->executeTriggers(PM_NEW_PROCESS_SAVE, $pluginData);
// Save Calendar ID for this process
if (! empty($data["PRO_CALENDAR"])) {
//G::LoadClass( "calendar" );
$calendar = new \Calendar();
$calendar->assignCalendarTo($this->proUid, $data["PRO_CALENDAR"], 'PROCESS');
}
} catch (Exception $e) {
throw new \RuntimeException($e);
}

View File

@@ -67,8 +67,11 @@ class User extends Api
*/
public function doPut($usr_uid, $request_data) {
try {
$userLoggedUid = $this->getUserId();
$user = new \BusinessModel\User();
$arrayData = $user->update($usr_uid, $request_data);
$arrayData = $user->update($usr_uid, $request_data, $userLoggedUid);
$response = $arrayData;
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}

View File

@@ -13,7 +13,7 @@ class BpmnWorkflowTest extends \PHPUnit_Framework_TestCase
function testNew()
{
$data = array(
"PRJ_NAME" => "Test BPMN Project #1",
"PRJ_NAME" => "Test Bpmn/Workflow Project #1",
"PRJ_DESCRIPTION" => "Description for - Test BPMN Project #1",
"PRJ_AUTHOR" => "00000000000000000000000000000001"
);
@@ -43,7 +43,7 @@ class BpmnWorkflowTest extends \PHPUnit_Framework_TestCase
function testCreate()
{
$data = array(
"PRJ_NAME" => "Test BPMN Project #2",
"PRJ_NAME" => "Test Bpmn/Workflow Project #2",
"PRJ_DESCRIPTION" => "Description for - Test BPMN Project #2",
"PRJ_AUTHOR" => "00000000000000000000000000000001"
);

View File

@@ -0,0 +1,72 @@
<?php
namespace Tests\ProcessMaker\Project\Adapter;
use \ProcessMaker\Project;
if (! class_exists("Propel")) {
include_once __DIR__ . "/../../../bootstrap.php";
}
class WorkflowBpmnTest extends \PHPUnit_Framework_TestCase
{
function testNew()
{
$data = array(
"PRO_TITLE" => "Test Workflow/Bpmn Project #1",
"PRO_DESCRIPTION" => "Description for - Test Project #1",
"PRO_CREATE_USER" => "00000000000000000000000000000001"
);
$wbap = new Project\Adapter\WorkflowBpmn($data);
try {
$bp = Project\Bpmn::load($wbap->getUid());
} catch (\Exception $e){die($e->getMessage());}
try {
$wp = Project\Workflow::load($wbap->getUid());
} catch (\Exception $e){}
$this->assertNotNull($bp);
$this->assertNotNull($wp);
$this->assertEquals($bp->getUid(), $wp->getUid());
$project = $bp->getProject();
$process = $wp->getProcess();
$this->assertEquals($project["PRJ_NAME"], $process["PRO_TITLE"]);
$this->assertEquals($project["PRJ_DESCRIPTION"], $process["PRO_DESCRIPTION"]);
$this->assertEquals($project["PRJ_AUTHOR"], $process["PRO_CREATE_USER"]);
}
function testCreate()
{
$data = array(
"PRO_TITLE" => "Test Workflow/Bpmn Project #2",
"PRO_DESCRIPTION" => "Description for - Test Project #2",
"PRO_CREATE_USER" => "00000000000000000000000000000001"
);
$wbap = new Project\Adapter\WorkflowBpmn();
$wbap->create($data);
try {
$bp = Project\Bpmn::load($wbap->getUid());
} catch (\Exception $e){}
try {
$wp = Project\Workflow::load($wbap->getUid());
} catch (\Exception $e){}
$this->assertNotEmpty($bp);
$this->assertNotEmpty($wp);
$this->assertEquals($bp->getUid(), $wp->getUid());
$project = $bp->getProject();
$process = $wp->getProcess();
$this->assertEquals($project["PRJ_NAME"], $process["PRO_TITLE"]);
$this->assertEquals($project["PRJ_DESCRIPTION"], $process["PRO_DESCRIPTION"]);
$this->assertEquals($project["PRJ_AUTHOR"], $process["PRO_CREATE_USER"]);
}
}

View File

@@ -267,7 +267,7 @@ class WorkflowTest extends \PHPUnit_Framework_TestCase
/**
* @depends testCompleteWorkflowProject
* @param $wp \ProcessMaker\Project\WorkflowProject
* @param $wp \ProcessMaker\Project\Workflow
* @expectedException \ProcessMaker\Exception\ProjectNotFound
* @expectedExceptionCode 20
*/