Merge remote branch 'upstream/master'

This commit is contained in:
Marco Antonio Nina
2014-04-09 08:27:00 -04:00
31 changed files with 881 additions and 679 deletions

View File

@@ -0,0 +1,72 @@
@ProcessMakerMichelangelo @RestAPI
Feature: Process Category
Requirements:
a workspace with the workspace with one process category
Background:
Given that I have a valid access_token
Scenario: Get list of Categories
Given I request "categories"
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 1 records
Scenario: Get a Category specific
Given I request "category/4177095085330818c324501061677193"
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"
Scenario: Create a new Categories
Given POST this data:
"""
{
"cat_name": "Test new Category"
}
"""
And I request "category"
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 "object"
And store "cat_uid" in session array as variable "cat_uid"
Scenario: Get list of Categories
Given I request "categories"
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 2 records
Scenario: Update the Category created in this script
Given PUT this data:
"""
{
"cat_name": "Name Updated"
}
"""
And that I want to update a resource with the key "cat_uid" stored in session array
And I request "category"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
Scenario: Delete the Category created previously in this script
Given that I want to delete a resource with the key "cat_uid" stored in session array
And I request "category"
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"

View File

@@ -0,0 +1,139 @@
@ProcessMakerMichelangelo @RestAPI
Feature: Process Category Main Test
Requirements:
a workspace with the workspace with one process category
Background:
Given that I have a valid access_token
Scenario: Get list of Categories
Given I request "categories"
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 1 records
Scenario: Get a Category specific
Given I request "category/4177095085330818c324501061677193"
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 "cat_uid" property equals "4177095085330818c324501061677193"
And the "cat_name" property equals "Category Cases Lists"
And the "cat_total_processes" property equals 5
Scenario Outline: Create a new Categories
Given POST this data:
"""
{
"cat_name": "<cat_name>"
}
"""
And I request "category"
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 "object"
And store "cat_uid" in session array as variable "cat_uid_<cat_uid_number>"
Examples:
| test_description | cat_uid_number | cat_name |
| Create new Category with character special | 1 | sample!@#$%^^& |
| Create new Category with only character numeric | 2 | 32425325 |
| Create new Category with only character special | 3 | @$@$#@% |
| Create new Category with normal character | 4 | sample |
Scenario: Get list of Categories
Given I request "categories"
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 5 records
Scenario: Create Category with same name
Given POST this data:
"""
{
"cat_name": "sample"
}
"""
And I request "category"
Then the response status code should be 400
And the response status message should have the following text "Duplicate"
Scenario Outline: Update the Category created in this script
Given PUT this data:
"""
{
"cat_name": "cat_name"
}
"""
And I request "category/cat_uid" with the key "cat_uid" stored in session array as variable "cat_uid_<cat_uid_number>"
And store "cat_uid" in session array as variable "cat_uid_<cat_uid_number>"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
Examples:
| test_description | cat_uid_number | cat_name |
| Update Category | 1 | UPDATE sample!@#$%^^& |
| Update Category | 2 | UPDATE 32425325 |
Scenario Outline: Get a Category specific
Given I request "category/4177095085330818c324501061677193"
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 "cat_name" property equals "UPDATE sample!@#$%^^&"
And the "cat_total_processes" property equals 0
Examples:
| cat_uid_number | cat_name | cat_total_processes |
| 1 | UPDATE sample!@#$%^^& | 0 |
| 2 | UPDATE 32425325 | 0 |
Scenario Outline: Delete the Category created previously in this script
Given that I want to delete a resource with the key "cat_uid" stored in session array as variable "cat_uid_<cat_uid_number>"
And I request "category"
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:
| cat_uid_number |
| 1 |
| 2 |
| 3 |
| 4 |
Scenario: Get a Category specific
Given I request "category/4177095085330818c324501061677193"
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 "cat_uid" property equals "4177095085330818c324501061677193"
And the "cat_name" property equals "Category Cases Lists"
And the "cat_total_processes" property equals 5

View File

@@ -0,0 +1,23 @@
@ProcessMakerMichelangelo @RestAPI
Feature: Process Category Negative Tests
Background:
Given that I have a valid access_token
Scenario Outline: Create a new Categories (Negative Test)
Given POST this data:
"""
{
"cat_name": "<cat_name>"
}
"""
And I request "category"
Then the response status code should be <error_code>
And the response status message should have the following text "<error_message>"
Examples:
| test_description | cat_name | error_code | error_message |
| without name | | 400 | cat_name |

View File

@@ -22,9 +22,9 @@ Scenario Outline: Create a new case (Negative Test)
Examples:
| Description | pro_uid | tas_uid | error_code | error_message |
| Create new case with pro_uid wrong | 99209594750ec1111111927000421575 | 68707275350ec281ada1c95068712556 | 400 | pro_uid |
| Create new case with task_uid wrong | 46279907250ec73b9b25a78031279680 | 99371337811111111111116024620271 | 400 | task_uid |
| Create new case with tas_uid wrong | 46279907250ec73b9b25a78031279680 | 99371337811111111111116024620271 | 400 | tas_uid |
| Create new case without pro_uid | | 52838134750ec7dd0989fc0015625952 | 400 | pro_uid |
| Create new case without tas_uid | 34579467750ec8d55e8b115057818502 | | 400 | task_uid |
| Create new case without tas_uid | 34579467750ec8d55e8b115057818502 | | 400 | tas_uid |
| Create new case whith pro_uid and tas_uid wrong | 8245849601111111181ecc7039804404 | 5690001111111118e4a9243080698854 | 400 | pro_uid |
@@ -34,9 +34,9 @@ Scenario Outline: Create a new case Impersonate (Negative Test)
Given POST this data:
"""
{
"pro_uid": "99209594750ec27ea338927000421575",
"pro_uid": "<pro_uid>",
"usr_uid": "<usr_uid>",
"tas_uid": "68707275350ec281ada1c95068712556",
"tas_uid": "<tas_uid>",
"variables": [{"name": "pruebaQA", "amount":"10400"}]
}
"""
@@ -45,12 +45,12 @@ Scenario Outline: Create a new case Impersonate (Negative Test)
And the response status message should have the following text "<error_message>"
Examples:
| Description | case_number | usr_uid | error_code | error_message |
| Create new case with process "Derivation rules - sequential" - Case Start with chris | 26 | 51049032352d56710347233042615067 | 400 | pro_uid |
| Create new case with process "Derivation rules - evaluation" - Case Start with adam | 27 | 44811996752d567110634a1013636964 | 400 | task_uid |
| Create new case with process "Derivation rules - Parallel" - Case Start with aaron | 28 | 24166330352d56730cdd525035621101 | 400 | pro_uid |
| Create new case with process "Derivation rules - parallel evaluation"- Case Start with jeremiah | 29 | 86677227852d5671f40ba25017213081 | 400 | task_uid |
| Create new case with process "Derivation rules - selection" - Case Start with admin | 30 | 62625000752d5672d6661e6072881167 | 400 | |
| Description | pro_uid | usr_uid | tas_uid | error_code | error_message |
| Create new case with process "Derivation rules - sequential" invalid pro_uid | 99201111111111111138927000421575 | 51049032352d56710347233042615067 | 68707275350ec281ada1c95068712556 | 400 | pro_uid |
| Create new case with process "Derivation rules - evaluation" invalid tas_uid | 99209594750ec27ea338927000421575 | 44811996752d567110634a1013636964 | 68707211111111111111111111712556 | 400 | tas_uid |
| Create new case with process "Derivation rules - Parallel" usr_uid | 99209594750ec27ea338927000421575 | 24166331111111111111115035621101 | 68707275350ec281ada1c95068712556 | 400 | usr_uid |
| Create new case with process "Derivation rules - without pro_uid | | 86677227852d5671f40ba25017213081 | 68707275350ec281ada1c95068712556 | 400 | pro_uid |
| Create new case with process "Derivation rules - selection" tas_uid | 99209594750ec27ea338927000421575 | 62625000752d5672d6661e6072881167 | | 400 | tas_uid |
Scenario Outline: Create a case, derivate and cancel. then try do pause or route
@@ -66,6 +66,7 @@ Scenario Outline: Create a case, derivate and cancel. then try do pause or route
And I request "cases"
Then the response status code should be 200
And store "app_uid" in session array as variable "app_uid_<case_number>"
#Send some variables
And PUT this data:
"""
@@ -116,8 +117,21 @@ Scenario Outline: Create a case, derivate and cancel. then try do pause or route
Then the response status code should be 400
And the response status message should have the following text "<error_message_pause>"
And PUT this data:
"""
{
}
"""
And that I want to delete a resource with the key "app_uid" stored in session array as variable "app_uid_<case_number>"
And I request "cases"
Then the response status code should be 200
And the content type is "application/json"
And the response charset is "UTF-8"
And the type is "object"
Examples:
| Description | case_number | pro_uid | tas_uid | error_message_route | error_message_pause |
| Create new case with process "Derivation rules - sequential" | 1 | 99209594750ec27ea338927000421575 | 68707275350ec281ada1c95068712556 | This case delegation is already closed | This case delegation is already closed |

View File

@@ -9,7 +9,6 @@ Background:
Scenario: List of case notes for this case
Given I request "cases/1185553665335d2e209f723099733152/notes"
the response time should at least be (\d+) milliseconds$/
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "array"
@@ -36,4 +35,11 @@ Scenario: Create a new case note for specified case
And the content type is "application/json"
And the type is "object"
Scenario: List of case notes for this case
Given I request "cases/1185553665335d2e209f723099733152/notes"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "array"
#case 125

View File

@@ -12,18 +12,46 @@ Scenario: List of case notes for this case
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "array"
And the "note_content" property in row 0 equals "tercer case note creado desde script"
Scenario: Create a new case note for specified case
Given POST this data:
"""
{
"note_content": "tercer case note creado desde script",
"send_email": 1
}
"""
And I request "case/1185553665335d2e209f723099733152/case"
Then the response status code should be 201
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "object"
Scenario: Get a List of cases notes of a case with paged
Given I request "cases/1185553665335d2e209f723099733152/notes/paged"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "array"
Scenario Outline: Create a new case note for specified case
Given POST this data:
"""
{
"note_content": "<note_content>",
"send_email": <send_email>
}
"""
And I request "cases/1185553665335d2e209f723099733152/note"
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 "object"
Examples:
| test_description | note_content | send_email |
| Create case note with charater special | Test!@#$ %^&*£ | 1 |
| Create case note with 150 chacarters | Este es una prueba con varios caracteres 112334@#$Este es una prueba con varios caracteres 112334@#$Este es una prueba con varios caracteres 112334@#$ | 1 |
| Create case note with character without space | Estaesunapruebasinespaciosentrepalabraslamismadebeseraceptado | 1 |
| Create case note without send mail | Test sin envio de email | 0 |
| Create case normal with character normal | tercer case note creado desde script | 1 |
Scenario: List of case notes for this case
Given I request "cases/1185553665335d2e209f723099733152/notes"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "array"
And the "note_content" property in row 0 equals "tercer case note creado desde script"
And the "note_content" property in row 1 equals "Test sin envio de email"

View File

@@ -21,7 +21,4 @@ Scenario: create a new case note for specified case (Negative Tests)
And the response status message should have the following text "You do not have permission to cases notes"
#case 124

View File

@@ -13,11 +13,11 @@ Scenario: Returns a list of the uploaded documents for a given case
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "array"
And the response has 5 records
And the response has 9 records
Scenario: Returns an uploaded documents for a given case
Given I request "cases/170220159534214f642abb8058832933/input-document/6075490825331a1c5eebff9015468244"
Given I request "cases/170220159534214f642abb8058832933/input-document/925833635534215b9148a64026212674"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"

View File

@@ -40,19 +40,11 @@ Scenario Outline: Post metadata and then upload documents for a given case
| 4 | /home/wendy/uploadfiles/test.txt | 170220159534214f642abb8058832933 | 68671480353319e5e1dee74089764900 | 19582733053319e304cfa76025663570 | comment 1 |
Scenario Outline: Returns an uploaded documents for a given case
Given I request "cases/<case_uid>/output-document/app_doc_uid" with the key "app_doc_uid" stored in session array as variable "app_doc_uid_<app_doc_uid_number>"
Given I request "cases/<case_uid>/input-document/app_doc_uid" with the key "app_doc_uid" stored in session array as variable "app_doc_uid_<app_doc_uid_number>"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
And the "app_doc_uid" property equals "<app_doc_uid>"
And the "app_doc_filename" property equals "<app_doc_filename>"
And the "doc_uid" property equals "<doc_uid>"
And the "app_doc_version" property equals "<app_doc_version>"
And the "app_doc_create_date" property equals "<app_doc_create_date>"
And the "app_doc_create_user" property equals "<app_doc_create_user>"
And the "app_doc_type" property equals "<app_doc_type>"
And the "app_doc_index" property equals "<app_doc_index>"
And the "app_doc_link" property equals "<app_doc_link>"
Examples:

View File

@@ -9,7 +9,7 @@ Background:
Scenario: Returns a list of the uploaded documents for a given case
Given I request "cases/170220159534214f642abb8058832000/input-documents"
Given I request "cases/170220159534214f642abb8058832900/input-documents"
Then the response status code should be 404
Scenario Outline: Post metadata and then upload documents for a given case

View File

@@ -13,14 +13,14 @@ Scenario: Returns a list of the generated documents for a given cases
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "array"
And the response has 6 records
And the response has 1 records
Scenario: Returns an generated document for a given case
Given I request "cases/33125846153383cecdf64f1079330191/output-document/3000248055333006ab56a01005891659"
Given I request "cases/33125846153383cecdf64f1079330191/output-document/75468909953383d0bc42f96046736849"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "Object"
And the type is "object"
Scenario: Generate or regenerates an output documents for a given case

View File

@@ -1,521 +0,0 @@
<?php
namespace BusinessModel;
use \G;
use \UsersPeer;
use \CasesPeer;
/**
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
class Cases
{
/**
* Get list for Cases
*
* @access public
* @param array $dataList, Data for list
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function getList($dataList = array())
{
Validator::isArray($dataList, '$dataList');
if (!isset($dataList["userId"])) {
throw (new \Exception("The user with userId: '' does not exist."));
} else {
Validator::usrUid($dataList["userId"], "userId");
}
G::LoadClass("applications");
$solrEnabled = false;
$userUid = $dataList["userId"];
$callback = isset( $dataList["callback"] ) ? $dataList["callback"] : "stcCallback1001";
$dir = isset( $dataList["dir"] ) ? $dataList["dir"] : "DESC";
$sort = isset( $dataList["sort"] ) ? $dataList["sort"] : "APP_CACHE_VIEW.APP_NUMBER";
$start = isset( $dataList["start"] ) ? $dataList["start"] : "0";
$limit = isset( $dataList["limit"] ) ? $dataList["limit"] : "25";
$filter = isset( $dataList["filter"] ) ? $dataList["filter"] : "";
$process = isset( $dataList["process"] ) ? $dataList["process"] : "";
$category = isset( $dataList["category"] ) ? $dataList["category"] : "";
$status = isset( $dataList["status"] ) ? strtoupper( $dataList["status"] ) : "";
$user = isset( $dataList["user"] ) ? $dataList["user"] : "";
$search = isset( $dataList["search"] ) ? $dataList["search"] : "";
$action = isset( $dataList["action"] ) ? $dataList["action"] : "todo";
$type = "extjs";
$dateFrom = isset( $dataList["dateFrom"] ) ? substr( $dataList["dateFrom"], 0, 10 ) : "";
$dateTo = isset( $dataList["dateTo"] ) ? substr( $dataList["dateTo"], 0, 10 ) : "";
$first = isset( $dataList["first"] ) ? true :false;
$valuesCorrect = array('todo', 'draft', 'paused', 'sent', 'selfservice', 'unassigned', 'search');
if (!in_array($action, $valuesCorrect)) {
throw (new \Exception('The value for $action is incorrect.'));
}
if ($action == 'search' || $action == 'to_reassign') {
$userUid = ($user == "CURRENT_USER") ? $userUid : $user;
if ($first) {
$result = array();
$result['totalCount'] = 0;
$result['data'] = array();
return $result;
}
}
if ((
$action == "todo" || $action == "draft" || $action == "paused" || $action == "sent" ||
$action == "selfservice" || $action == "unassigned" || $action == "search"
) &&
(($solrConf = \System::solrEnv()) !== false)
) {
G::LoadClass("AppSolr");
$ApplicationSolrIndex = new \AppSolr(
$solrConf["solr_enabled"],
$solrConf["solr_host"],
$solrConf["solr_instance"]
);
if ($ApplicationSolrIndex->isSolrEnabled() && $solrConf['solr_enabled'] == true) {
//Check if there are missing records to reindex and reindex them
$ApplicationSolrIndex->synchronizePendingApplications();
$solrEnabled = true;
}
}
if ($solrEnabled) {
$result = $ApplicationSolrIndex->getAppGridData(
$userUid,
$start,
$limit,
$action,
$filter,
$search,
$process,
$status,
$type,
$dateFrom,
$dateTo,
$callback,
$dir,
$sort,
$category
);
} else {
G::LoadClass("applications");
$apps = new \Applications();
$result = $apps->getAll(
$userUid,
$start,
$limit,
$action,
$filter,
$search,
$process,
$status,
$type,
$dateFrom,
$dateTo,
$callback,
$dir,
(strpos($sort, ".") !== false)? $sort : "APP_CACHE_VIEW." . $sort,
$category
);
}
if (!empty($result['data'])) {
foreach ($result['data'] as &$value) {
$value = array_change_key_case($value, CASE_LOWER);
}
}
return $result;
}
/**
* Get data of a Case
*
* @param string $caseUid Unique id of Case
* @param string $userUid Unique id of User
*
* return array Return an array with data of Case Info
*/
public function getCaseInfo($caseUid, $userUid)
{
try {
$solrEnabled = 0;
if (($solrEnv = \System::solrEnv()) !== false) {
\G::LoadClass("AppSolr");
$appSolr = new \AppSolr(
$solrEnv["solr_enabled"],
$solrEnv["solr_host"],
$solrEnv["solr_instance"]
);
if ($appSolr->isSolrEnabled() && $solrEnv["solr_enabled"] == true) {
//Check if there are missing records to reindex and reindex them
$appSolr->synchronizePendingApplications();
$solrEnabled = 1;
}
}
if ($solrEnabled == 1) {
try {
\G::LoadClass("searchIndex");
$arrayData = array();
$delegationIndexes = array();
$columsToInclude = array("APP_UID");
$solrSearchText = null;
//Todo
$solrSearchText = $solrSearchText . (($solrSearchText != null)? " OR " : null) . "(APP_STATUS:TO_DO AND APP_ASSIGNED_USERS:" . $userUid . ")";
$delegationIndexes[] = "APP_ASSIGNED_USER_DEL_INDEX_" . $userUid . "_txt";
//Draft
$solrSearchText = $solrSearchText . (($solrSearchText != null)? " OR " : null) . "(APP_STATUS:DRAFT AND APP_DRAFT_USER:" . $userUid . ")";
//Index is allways 1
$solrSearchText = "($solrSearchText)";
//Add del_index dynamic fields to list of resulting columns
$columsToIncludeFinal = array_merge($columsToInclude, $delegationIndexes);
$solrRequestData = \Entity_SolrRequestData::createForRequestPagination(
array(
"workspace" => $solrEnv["solr_instance"],
"startAfter" => 0,
"pageSize" => 1000,
"searchText" => $solrSearchText,
"numSortingCols" => 1,
"sortCols" => array("APP_NUMBER"),
"sortDir" => array(strtolower("DESC")),
"includeCols" => $columsToIncludeFinal,
"resultFormat" => "json"
)
);
//Use search index to return list of cases
$searchIndex = new \BpmnEngine_Services_SearchIndex($appSolr->isSolrEnabled(), $solrEnv["solr_host"]);
//Execute query
$solrQueryResult = $searchIndex->getDataTablePaginatedList($solrRequestData);
//Get the missing data from database
$arrayApplicationUid = array();
foreach ($solrQueryResult->aaData as $i => $data) {
$arrayApplicationUid[] = $data["APP_UID"];
}
$aaappsDBData = $appSolr->getListApplicationDelegationData($arrayApplicationUid);
foreach ($solrQueryResult->aaData as $i => $data) {
//Initialize array
$delIndexes = array(); //Store all the delegation indexes
//Complete empty values
$applicationUid = $data["APP_UID"]; //APP_UID
//Get all the indexes returned by Solr as columns
for($i = count($columsToInclude); $i <= count($data) - 1; $i++) {
if (is_array($data[$columsToIncludeFinal[$i]])) {
foreach ($data[$columsToIncludeFinal[$i]] as $delIndex) {
$delIndexes[] = $delIndex;
}
}
}
//Verify if the delindex is an array
//if is not check different types of repositories
//the delegation index must always be defined.
if (count($delIndexes) == 0) {
$delIndexes[] = 1; // the first default index
}
//Remove duplicated
$delIndexes = array_unique($delIndexes);
//Get records
foreach ($delIndexes as $delIndex) {
$aRow = array();
//Copy result values to new row from Solr server
$aRow["APP_UID"] = $data["APP_UID"];
//Get delegation data from DB
//Filter data from db
$indexes = $appSolr->aaSearchRecords($aaappsDBData, array(
"APP_UID" => $applicationUid,
"DEL_INDEX" => $delIndex
));
foreach ($indexes as $index) {
$row = $aaappsDBData[$index];
}
if(!isset($row))
{
continue;
}
$aRow["APP_NUMBER"] = $row["APP_NUMBER"];
$aRow["APP_STATUS"] = $row["APP_STATUS"];
$aRow["PRO_UID"] = $row["PRO_UID"];
$aRow["DEL_INDEX"] = $row["DEL_INDEX"];
$arrayData[] = array(
"guid" => $aRow["APP_UID"],
"name" => $aRow["APP_NUMBER"],
"status" => $aRow["APP_STATUS"],
"delIndex" => $aRow["DEL_INDEX"],
"processId" => $aRow["PRO_UID"]
);
}
}
$case = array();
for ($i = 0; $i<=count($arrayData)-1; $i++) {
if ($arrayData[$i]["guid"] == $caseUid) {
$case = $arrayData[$i];
}
}
return $case;
} catch (\InvalidIndexSearchTextException $e) {
$arrayData = array();
$arrayData[] = array (
"guid" => $e->getMessage(),
"name" => $e->getMessage(),
"status" => $e->getMessage(),
"delIndex" => $e->getMessage(),
"processId" => $e->getMessage()
);
return $arrayData;
}
} else {
$arrayData = array();
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\AppCacheViewPeer::APP_UID);
$criteria->addSelectColumn(\AppCacheViewPeer::DEL_INDEX);
$criteria->addSelectColumn(\AppCacheViewPeer::APP_NUMBER);
$criteria->addSelectColumn(\AppCacheViewPeer::APP_STATUS);
$criteria->addSelectColumn(\AppCacheViewPeer::PRO_UID);
$criteria->add(\AppCacheViewPeer::USR_UID, $userUid);
$criteria->add(\AppCacheViewPeer::APP_UID, $caseUid);
$criteria->add(
//ToDo - getToDo()
$criteria->getNewCriterion(\AppCacheViewPeer::APP_STATUS, "TO_DO", \CRITERIA::EQUAL)->addAnd(
$criteria->getNewCriterion(\AppCacheViewPeer::DEL_FINISH_DATE, null, \Criteria::ISNULL))->addAnd(
$criteria->getNewCriterion(\AppCacheViewPeer::APP_THREAD_STATUS, "OPEN"))->addAnd(
$criteria->getNewCriterion(\AppCacheViewPeer::DEL_THREAD_STATUS, "OPEN"))
)->addOr(
//Draft - getDraft()
$criteria->getNewCriterion(\AppCacheViewPeer::APP_STATUS, "DRAFT", \CRITERIA::EQUAL)->addAnd(
$criteria->getNewCriterion(\AppCacheViewPeer::APP_THREAD_STATUS, "OPEN"))->addAnd(
$criteria->getNewCriterion(\AppCacheViewPeer::DEL_THREAD_STATUS, "OPEN"))
);
$criteria->addDescendingOrderByColumn(\AppCacheViewPeer::APP_NUMBER);
$rsCriteria = \AppCacheViewPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$arrayData[] = array(
"guid" => $row["APP_UID"],
"name" => $row["APP_NUMBER"],
"status" => $row["APP_STATUS"],
"delIndex" => $row["DEL_INDEX"],
"processId" => $row["PRO_UID"]
);
}
return $arrayData;
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get data Task Case
*
* @param string $caseUid Unique id of Case
*
* return array Return an array with Task Case
*/
public function getTaskCase($caseUid)
{
try {
\G::LoadClass('wsBase');
$ws = new \wsBase();
$fields = $ws->taskCase($caseUid);
//Return
return $fields;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Add New Case
*
* @param string $prjUid Unique id of Project
* @param string $actUid Unique id of Activity
* @param string $caseUid Unique id of Case
* @param array $variables
*
* return array Return an array with Task Case
*/
public function addCase($prjUid, $actUid, $userUid, $variables)
{
try {
\G::LoadClass('wsBase');
$ws = new \wsBase();
if ($variables) {
$variables = array_shift($variables);
}
$fields = $ws->newCase($prjUid, $userUid, $actUid, $variables);
//Return
return $fields;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Add New Case Impersonate
*
* @param string $prjUid Unique id of Project
* @param string $usrUid Unique id of User
* @param string $caseUid Unique id of Case
* @param array $variables
*
* return array Return an array with Task Case
*/
public function addCaseImpersonate($prjUid, $usrUid, $caseUid, $variables)
{
try {
\G::LoadClass('wsBase');
$ws = new \wsBase();
$fields = $ws->newCaseImpersonate($prjUid, $usrUid, $variables, '1352844695225ff5fe54de2005407079');
//Return
return $fields;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Reassign Case
*
* @param string $caseUid Unique id of Case
* @param string $userUid Unique id of User
* @param string $delIndex
* @param string $userUidSource Unique id of User Source
* @param string $userUid $userUidTarget id of User Target
*
* return array Return an array with Task Case
*/
public function updateReassignCase($caseUid, $userUid, $delIndex, $userUidSource, $userUidTarget)
{
try {
\G::LoadClass('wsBase');
$ws = new \wsBase();
$fields = $ws->reassignCase($userUid, $caseUid, $delIndex, $userUidSource, $userUidTarget);
//Return
return $fields;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Put cancel case
*
* @access public
* @param string $app_uid, Uid for case
* @param string $usr_uid, Uid for user
* @param string $del_index, Index for case
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function putCancelCase($app_uid, $usr_uid, $del_index = false) {
Validator::appUid($app_uid, '$cas_uid');
Validator::usrUid($usr_uid, '$usr_uid');
if ($del_index === false) {
$del_index = \AppDelegation::getCurrentIndex($app_uid);
}
$case = new \Cases();
$case->cancelCase( $app_uid, $del_index, $usr_uid );
}
/**
* Put pause case
*
* @access public
* @param string $app_uid , Uid for case
* @param string $usr_uid , Uid for user
* @param bool|string $del_index , Index for case
* @param null|string $unpaused_date, Date for unpaused
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function putPauseCase($app_uid, $usr_uid, $del_index = false, $unpaused_date = null) {
Validator::appUid($app_uid, '$cas_uid');
Validator::usrUid($usr_uid, '$usr_uid');
if ($unpaused_date != null) {
Validator::isDate($unpaused_date, 'Y-m-d', '$unpaused_date');
}
if ($del_index === false) {
$del_index = \AppDelegation::getCurrentIndex($app_uid);
}
$case = new \Cases();
$case->pauseCase( $app_uid, $del_index, $usr_uid, $unpaused_date );
}
/**
* Put unpause case
*
* @access public
* @param string $app_uid , Uid for case
* @param string $usr_uid , Uid for user
* @param bool|string $del_index , Index for case
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function putUnpauseCase($app_uid, $usr_uid, $del_index = false) {
Validator::appUid($app_uid, '$cas_uid');
Validator::usrUid($usr_uid, '$usr_uid');
if ($del_index === false) {
$del_index = \AppDelegation::getCurrentIndex($app_uid);
}
$case = new \Cases();
$case->unpauseCase( $app_uid, $del_index, $usr_uid );
}
/**
* Put unpause case
*
* @access public
* @param string $app_uid , Uid for case
* @param string $usr_uid , Uid for user
* @param bool|string $del_index , Index for case
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function putExecuteTriggerCase($app_uid, $tri_uid, $usr_uid, $del_index = false) {
Validator::appUid($app_uid, '$cas_uid');
Validator::triUid($tri_uid, '$tri_uid');
Validator::usrUid($usr_uid, '$usr_uid');
if ($del_index === false) {
$del_index = \AppDelegation::getCurrentIndex($app_uid);
}
$case = new \wsBase();
$case->executeTrigger( $usr_uid, $app_uid, $tri_uid, $del_index );
}
/**
* Delete case
*
* @access public
* @param string $app_uid, Uid for case
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function deleteCase($app_uid) {
Validator::appUid($app_uid, '$cas_uid');
$case = new \Cases();
$case->removeCase( $app_uid );
}
}

View File

@@ -221,7 +221,7 @@ class Calendar
$obj = \CalendarDefinitionPeer::retrieveByPK($calendarUid);
if (!(is_object($obj) && get_class($obj) == "CalendarDefinition")) {
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $calendarUid), "The calendar with {0}: {1} does not exists");
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $calendarUid), "The calendar with {0}: {1} does not exist.");
throw (new \Exception($msg));
}
@@ -262,13 +262,19 @@ class Calendar
public function create($arrayData)
{
try {
//Verify data
$process = new \ProcessMaker\BusinessModel\Process();
$validator = new \ProcessMaker\BusinessModel\Validator();
$validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData");
$validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData");
//Set data
$arrayData = \G::array_change_key_case2($arrayData, CASE_UPPER);
unset($arrayData["CAL_UID"]);
//Verify data
$process = new \ProcessMaker\BusinessModel\Process();
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);
$this->throwExceptionIfExistsName($arrayData["CAL_NAME"], $this->arrayFieldNameForException["calendarName"]);
@@ -295,7 +301,7 @@ class Calendar
if (isset($arrayData["CAL_WORK_HOUR"])) {
foreach ($arrayData["CAL_WORK_HOUR"] as $value) {
if ($value["DAY"] != "ALL" && !in_array($value["DAY"], $arrayData["CAL_WORK_DAYS"])) {
throw (new \Exception(str_replace(array("{0}", "{1}"), array($this->arrayWorkHourFieldNameForException["day"], $this->arrayFieldNameForException["calendarWorkDays"]), "Value specified for \"{0}\" does not exists in \"{1}\"")));
throw (new \Exception(str_replace(array("{0}", "{1}"), array($this->arrayWorkHourFieldNameForException["day"], $this->arrayFieldNameForException["calendarWorkDays"]), "Value specified for \"{0}\" does not exist in \"{1}\".")));
}
$arrayCalendarWorkHour[] = array(
@@ -321,11 +327,7 @@ class Calendar
$arrayDataAux = array();
$arrayDataAux["CALENDAR_UID"] = \G::generateUniqueID();
$arrayDataAux["CALENDAR_NAME"] = $arrayData["CAL_NAME"];
if (isset($arrayData["CAL_DESCRIPTION"])) {
$arrayDataAux["CALENDAR_DESCRIPTION"] = $arrayData["CAL_DESCRIPTION"];
}
$arrayDataAux["CALENDAR_DESCRIPTION"] = (isset($arrayData["CAL_DESCRIPTION"]))? $arrayData["CAL_DESCRIPTION"] : "";
$arrayDataAux["CALENDAR_WORK_DAYS"] = explode("|", $this->workDaysReplaceData(implode("|", $arrayData["CAL_WORK_DAYS"])));
$arrayDataAux["CALENDAR_STATUS"] = $arrayData["CAL_STATUS"];
@@ -361,11 +363,17 @@ class Calendar
public function update($calendarUid, $arrayData)
{
try {
//Verify data
$process = new \ProcessMaker\BusinessModel\Process();
$validator = new \ProcessMaker\BusinessModel\Validator();
$validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData");
$validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData");
//Set data
$arrayData = \G::array_change_key_case2($arrayData, CASE_UPPER);
//Verify data
$process = new \ProcessMaker\BusinessModel\Process();
$this->throwExceptionIfNotExistsCalendar($calendarUid, $this->arrayFieldNameForException["calendarUid"]);
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, false);
@@ -400,7 +408,7 @@ class Calendar
foreach ($arrayAux as $value) {
if (isset($arrayData["CAL_WORK_HOUR"]) && $value["DAY"] != "ALL" && !in_array($value["DAY"], $calendarWorkDays)) {
throw (new \Exception(str_replace(array("{0}", "{1}"), array($this->arrayWorkHourFieldNameForException["day"], $this->arrayFieldNameForException["calendarWorkDays"]), "Value specified for \"{0}\" does not exists in \"{1}\"")));
throw (new \Exception(str_replace(array("{0}", "{1}"), array($this->arrayWorkHourFieldNameForException["day"], $this->arrayFieldNameForException["calendarWorkDays"]), "Value specified for \"{0}\" does not exist in \"{1}\".")));
}
$arrayCalendarWorkHour[] = array(

View File

@@ -74,11 +74,11 @@ class CaseTrackerObject
}
if (!isset($arrayData["CTO_TYPE_OBJ"])) {
throw (new \Exception(str_replace(array("{0}"), array(strtolower("CTO_TYPE_OBJ")), "The \"{0}\" attribute is not defined")));
throw (new \Exception(str_replace(array("{0}"), array(strtolower("CTO_TYPE_OBJ")), "Undefined value for \"{0}\", it is required.")));
}
if (!isset($arrayData["CTO_UID_OBJ"])) {
throw (new \Exception(str_replace(array("{0}"), array(strtolower("CTO_UID_OBJ")), "The \"{0}\" attribute is not defined")));
throw (new \Exception(str_replace(array("{0}"), array(strtolower("CTO_UID_OBJ")), "Undefined value for \"{0}\", it is required.")));
}
$step = new \ProcessMaker\BusinessModel\Step();
@@ -148,11 +148,11 @@ class CaseTrackerObject
}
if (isset($arrayData["CTO_TYPE_OBJ"]) && !isset($arrayData["CTO_UID_OBJ"])) {
throw (new \Exception(str_replace(array("{0}"), array(strtolower("CTO_UID_OBJ")), "The \"{0}\" attribute is not defined")));
throw (new \Exception(str_replace(array("{0}"), array(strtolower("CTO_UID_OBJ")), "Undefined value for \"{0}\", it is required.")));
}
if (!isset($arrayData["CTO_TYPE_OBJ"]) && isset($arrayData["CTO_UID_OBJ"])) {
throw (new \Exception(str_replace(array("{0}"), array(strtolower("CTO_TYPE_OBJ")), "The \"{0}\" attribute is not defined")));
throw (new \Exception(str_replace(array("{0}"), array(strtolower("CTO_TYPE_OBJ")), "Undefined value for \"{0}\", it is required.")));
}
if (isset($arrayData["CTO_TYPE_OBJ"]) && isset($arrayData["CTO_UID_OBJ"])) {
@@ -324,7 +324,8 @@ class CaseTrackerObject
*
* @return void
*/
public function moveCaseTrackerObject($cto_uid, $pro_uid, $cto_pos) {
public function moveCaseTrackerObject($cto_uid, $pro_uid, $cto_pos)
{
$aCaseTrackerObject = CaseTracker::getCaseTrackerObjects($pro_uid);
foreach ($aCaseTrackerObject as $dataCaseTracker) {

View File

@@ -61,7 +61,9 @@ class Cases
if ($start != 0) {
$start--;
}
if ((abs((int)$limit)) == 0) {
$limit = (int)$limit;
$limit = abs($limit);
if ($limit == 0) {
G::LoadClass("configuration");
$conf = new \Configurations();
$generalConfCasesList = $conf->getConfiguration('ENVIRONMENT_SETTINGS', '');
@@ -319,7 +321,7 @@ class Cases
$array['app_name'] = $array['caseName'];
$array['app_status'] = $array['caseStatus'];
$array['app_init_usr_uid'] = $array['caseCreatorUser'];
$array['app_init_usr_username'] = $array['caseCreatorUserName'];
$array['app_init_usr_username'] = trim($array['caseCreatorUserName']);
$array['pro_uid'] = $array['processId'];
$array['pro_name'] = $array['processName'];
$array['app_create_date'] = $array['createDate'];
@@ -410,7 +412,7 @@ class Cases
$array['app_name'] = $array['caseName'];
$array['app_status'] = $array['caseStatus'];
$array['app_init_usr_uid'] = $array['caseCreatorUser'];
$array['app_init_usr_username'] = $array['caseCreatorUserName'];
$array['app_init_usr_username'] = trim($array['caseCreatorUserName']);
$array['pro_uid'] = $array['processId'];
$array['pro_name'] = $array['processName'];
$array['app_create_date'] = $array['createDate'];
@@ -527,6 +529,14 @@ class Cases
if ($variables) {
$variables = array_shift($variables);
}
$oProcesses = new \Processes();
if (! $oProcesses->processExists($processUid)) {
throw (new \Exception( 'Invalid value specified for \'pro_uid\''));
}
$oTask = new \Task();
if (! $oTask->taskExists($taskUid)) {
throw (new \Exception( 'Invalid value specified for \'tas_uid\''));
}
$fields = $ws->newCase($processUid, $userUid, $taskUid, $variables);
$array = json_decode(json_encode($fields), true);
if ($array ["status_code"] != 0) {
@@ -568,6 +578,14 @@ class Cases
} elseif ($variables == null) {
$variables = array(array());
}
$oProcesses = new \Processes();
if (! $oProcesses->processExists($processUid)) {
throw (new \Exception( 'Invalid value specified for \'pro_uid\''));
}
$user = new \Users();
if (! $user->userExists( $userUid )) {
throw (new \Exception( 'Invalid value specified for \'usr_uid\''));
}
$fields = $ws->newCaseImpersonate($processUid, $userUid, $variables, $taskUid);
$array = json_decode(json_encode($fields), true);
if ($array ["status_code"] != 0) {

View File

@@ -14,6 +14,10 @@ class InputDocument
public function getCasesInputDocuments($applicationUid, $userUid)
{
try {
$oApplication = \ApplicationPeer::retrieveByPk($applicationUid);
if (!is_object($oApplication)) {
throw (new \Exception("The Application with app_uid: '$applicationUid' doesn't exist!"));
}
$sApplicationUID = $applicationUid;
$sUserUID = $userUid;
\G::LoadClass('case');
@@ -32,7 +36,7 @@ class InputDocument
$docrow['app_doc_filename'] = $row['APP_DOC_FILENAME'];
$docrow['doc_uid'] = $row['DOC_UID'];
$docrow['app_doc_version'] = $row['DOC_VERSION'];
$docrow['app_doc_create_date'] = $row['CREATE_DATE'];
$docrow['app_doc_create_date'] = $row['CREATE_DATE'];
$docrow['app_doc_create_user'] = $row['CREATED_BY'];
$docrow['app_doc_type'] = $row['TYPE'];
$docrow['app_doc_index'] = $row['APP_DOC_INDEX'];
@@ -60,7 +64,7 @@ class InputDocument
try {
$oAppDocument = \AppDocumentPeer::retrieveByPK( $inputDocumentUid, 1 );
if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') {
throw (new \Exception('This input document with id: '.$inputDocumentUid.' doesn\'t exist!'));
throw (new \Exception('This input document with inp_doc_uid: '.$inputDocumentUid.' doesn\'t exist!'));
}
$sApplicationUID = $applicationUid;
$sUserUID = $userUid;
@@ -109,7 +113,7 @@ class InputDocument
try {
$oAppDocument = \AppDocumentPeer::retrieveByPK( $inputDocumentUid, 1 );
if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') {
throw (new \Exception('This input document with id: '.$inputDocumentUid.' doesn\'t exist!'));
throw (new \Exception('This input document with inp_doc_uid: '.$inputDocumentUid.' doesn\'t exist!'));
}
\G::LoadClass('wsBase');
$ws = new \wsBase();

View File

@@ -56,6 +56,10 @@ class OutputDocument
public function getCasesOutputDocument($applicationUid, $userUid, $applicationDocumentUid)
{
try {
$oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, 1 );
if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') {
throw (new \Exception('This output document with id: '.$applicationDocumentUid.' doesn\'t exist!'));
}
$sApplicationUID = $applicationUid;
$sUserUID = $userUid;
\G::LoadClass('case');

View File

@@ -282,7 +282,7 @@ class DynaForm
$rsCriteria = \DynaformPeer::doSelectRS($criteria);
if (!$rsCriteria->next()) {
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $dynaFormUid), "The DynaForm with {0}: {1}, does not exist");
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $dynaFormUid), "The DynaForm with {0}: {1}, does not exist.");
throw (new \Exception($msg));
}
@@ -512,27 +512,27 @@ class DynaForm
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);
if (!isset($arrayData["COPY_IMPORT"])) {
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName("COPY_IMPORT")), "The \"{0}\" attribute is not defined")));
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName("COPY_IMPORT")), "Undefined value for \"{0}\", it is required.")));
}
if (!isset($arrayData["COPY_IMPORT"]["PRJ_UID"])) {
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName("COPY_IMPORT.PRJ_UID")), "The \"{0}\" attribute is not defined")));
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName("COPY_IMPORT.PRJ_UID")), "Undefined value for \"{0}\", it is required.")));
}
$arrayData["COPY_IMPORT"]["PRJ_UID"] = trim($arrayData["COPY_IMPORT"]["PRJ_UID"]);
if ($arrayData["COPY_IMPORT"]["PRJ_UID"] == "") {
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName("COPY_IMPORT.PRJ_UID")), "The \"{0}\" attribute is empty")));
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName("COPY_IMPORT.PRJ_UID")), "Invalid value for \"{0}\", it can not be empty.")));
}
if (!isset($arrayData["COPY_IMPORT"]["DYN_UID"])) {
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName("COPY_IMPORT.DYN_UID")), "The \"{0}\" attribute is not defined")));
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName("COPY_IMPORT.DYN_UID")), "Undefined value for \"{0}\", it is required.")));
}
$arrayData["COPY_IMPORT"]["DYN_UID"] = trim($arrayData["COPY_IMPORT"]["DYN_UID"]);
if ($arrayData["COPY_IMPORT"]["DYN_UID"] == "") {
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName("COPY_IMPORT.DYN_UID")), "The \"{0}\" attribute is empty")));
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName("COPY_IMPORT.DYN_UID")), "Invalid value for \"{0}\", it can not be empty.")));
}
$this->throwExceptionIfExistsTitle($processUid, $arrayData["DYN_TITLE"], $this->arrayFieldNameForException["dynaFormTitle"]);
@@ -715,29 +715,29 @@ class DynaForm
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);
if ($arrayData["DYN_TYPE"] == "grid") {
throw (new \Exception(str_replace(array("{0}"), array($this->arrayFieldNameForException["dynaFormType"]), "Invalid value specified for \"{0}\"")));
throw (new \Exception(str_replace(array("{0}", "{1}"), array($this->arrayFieldNameForException["dynaFormType"], "xmlform"), "Invalid value for \"{0}\", it only accepts values: \"{1}\".")));
}
if (!isset($arrayData["PMTABLE"])) {
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName("PMTABLE")), "The \"{0}\" attribute is not defined")));
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName("PMTABLE")), "Undefined value for \"{0}\", it is required.")));
}
if (!isset($arrayData["PMTABLE"]["TAB_UID"])) {
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName("PMTABLE.TAB_UID")), "The \"{0}\" attribute is not defined")));
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName("PMTABLE.TAB_UID")), "Undefined value for \"{0}\", it is required.")));
}
$arrayData["PMTABLE"]["TAB_UID"] = trim($arrayData["PMTABLE"]["TAB_UID"]);
if ($arrayData["PMTABLE"]["TAB_UID"] == "") {
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName("PMTABLE.TAB_UID")), "The \"{0}\" attribute is empty")));
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName("PMTABLE.TAB_UID")), "Invalid value for \"{0}\", it can not be empty.")));
}
if (!isset($arrayData["PMTABLE"]["FIELDS"])) {
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName("PMTABLE.FIELDS")), "The \"{0}\" attribute is not defined")));
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName("PMTABLE.FIELDS")), "Undefined value for \"{0}\", it is required.")));
}
if (count($arrayData["PMTABLE"]["FIELDS"]) == 0) {
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName("PMTABLE.FIELDS")), "The \"{0}\" attribute is empty")));
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName("PMTABLE.FIELDS")), "Invalid value for \"{0}\", it can not be empty.")));
}
$this->throwExceptionIfExistsTitle($processUid, $arrayData["DYN_TITLE"], $this->arrayFieldNameForException["dynaFormTitle"]);

View File

@@ -143,7 +143,7 @@ class Group
$group = new \Groupwf();
if (!$group->GroupwfExists($groupUid)) {
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $groupUid), "The group with {0}: {1} does not exist");
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $groupUid), "The group with {0}: {1} does not exist.");
throw (new \Exception($msg));
}

View File

@@ -161,7 +161,7 @@ class InputDocument
$rsCriteria = \InputDocumentPeer::doSelectRS($criteria);
if (!$rsCriteria->next()) {
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $inputDocumentUid), "The Input Document with {0}: {1} does not exist");
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $inputDocumentUid), "The Input Document with {0}: {1} does not exist.");
throw (new \Exception($msg));
}

View File

@@ -176,7 +176,7 @@ class Process
$fieldNameAux = (isset($arrayFieldNameForException[$arrayFieldDefinition[$fieldName]["fieldNameAux"]]))? $arrayFieldNameForException[$arrayFieldDefinition[$fieldName]["fieldNameAux"]] : "";
if ($arrayFieldDefinition[$fieldName]["required"] && !isset($arrayData[$fieldName])) {
throw (new \Exception(str_replace(array("{0}"), array($fieldNameAux), "The \"{0}\" attribute is not defined")));
throw (new \Exception(str_replace(array("{0}"), array($fieldNameAux), "Undefined value for \"{0}\", it is required.")));
}
}
}
@@ -201,12 +201,12 @@ class Process
case 1:
//empty
if (!$arrayFieldDefinition[$fieldName]["empty"] && trim($fieldValue) . "" == "") {
throw (new \Exception(str_replace(array("{0}"), array($fieldNameAux), "The \"{0}\" attribute is empty")));
throw (new \Exception(str_replace(array("{0}"), array($fieldNameAux), "Invalid value for \"{0}\", it can not be empty.")));
}
//defaultValues
if (count($arrayFieldDefinition[$fieldName]["defaultValues"]) > 0 && !in_array($fieldValue, $arrayFieldDefinition[$fieldName]["defaultValues"])) {
throw (new \Exception(str_replace(array("{0}"), array($fieldNameAux), "Invalid value specified for \"{0}\"")));
throw (new \Exception(str_replace(array("{0}", "{1}"), array($fieldNameAux, implode("|", $arrayFieldDefinition[$fieldName]["defaultValues"])), "Invalid value for \"{0}\", it only accepts values: \"{1}\".")));
}
//type
@@ -220,17 +220,17 @@ class Process
switch ($arrayFieldDefinition[$fieldName]["type"]) {
case "date":
if (!preg_match("/^" . $eregDate . "$/", $fieldValue)) {
throw (new \Exception(str_replace(array("{0}"), array($fieldNameAux), "Invalid value specified for \"{0}\"")));
throw (new \Exception(str_replace(array("{0}"), array($fieldNameAux), "Invalid value for \"{0}\".")));
}
break;
case "hour":
if (!preg_match("/^" . $eregHour . "$/", $fieldValue)) {
throw (new \Exception(str_replace(array("{0}"), array($fieldNameAux), "Invalid value specified for \"{0}\"")));
throw (new \Exception(str_replace(array("{0}"), array($fieldNameAux), "Invalid value for \"{0}\".")));
}
break;
case "datetime":
if (!preg_match("/^" . $eregDatetime . "$/", $fieldValue)) {
throw (new \Exception(str_replace(array("{0}"), array($fieldNameAux), "Invalid value specified for \"{0}\"")));
throw (new \Exception(str_replace(array("{0}"), array($fieldNameAux), "Invalid value for \"{0}\".")));
}
break;
}
@@ -242,7 +242,7 @@ class Process
//type
if (!is_array($fieldValue)) {
if ($fieldValue != "" && !preg_match("/^\s*array\s*\(.*\)\s*$/", $fieldValue)) {
throw (new \Exception(str_replace(array("{0}"), array($fieldNameAux), "The \"{0}\" attribute is not array")));
throw (new \Exception(str_replace(array("{0}"), array($fieldNameAux), "Invalid value for \"{0}\", this value must be an array.")));
}
}
@@ -259,7 +259,7 @@ class Process
}
if (count($arrayAux) == 0) {
throw (new \Exception(str_replace(array("{0}"), array($fieldNameAux), "The \"{0}\" attribute is empty")));
throw (new \Exception(str_replace(array("{0}"), array($fieldNameAux), "Invalid value for \"{0}\", it can not be empty.")));
}
}
@@ -277,7 +277,7 @@ class Process
foreach ($arrayAux as $value) {
if (!in_array($value, $arrayFieldDefinition[$fieldName]["defaultValues"])) {
throw (new \Exception(str_replace(array("{0}"), array($fieldNameAux), "Invalid value specified for \"{0}\"")));
throw (new \Exception(str_replace(array("{0}", "{1}"), array($fieldNameAux, implode("|", $arrayFieldDefinition[$fieldName]["defaultValues"])), "Invalid value for \"{0}\", it only accepts values: \"{1}\".")));
}
}
}
@@ -307,7 +307,7 @@ class Process
$nameForException = (isset($arrayFieldNameForException[$key]))? $arrayFieldNameForException[$key] : "";
if (!is_null($value) && ($value . "" == "" || !preg_match("/^(?:\+|\-)?(?:0|[1-9]\d*)$/", $value . "") || (int)($value) < 0)) {
throw (new \Exception(str_replace(array("{0}"), array($nameForException), "Invalid value specified for \"{0}\". Expecting positive integer value")));
throw (new \Exception(str_replace(array("{0}"), array($nameForException), "Invalid value for \"{0}\". Expecting positive integer value.")));
}
}
} catch (\Exception $e) {
@@ -329,7 +329,7 @@ class Process
$process = new \Process();
if (!$process->processExists($processUid)) {
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $processUid), "The project with {0}: {1} does not exist");
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $processUid), "The project with {0}: {1} does not exist.");
throw (new \Exception($msg));
}
@@ -352,7 +352,7 @@ class Process
$user = new \Users();
if (!$user->userExists($userUid)) {
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $userUid), "The user with {0}: {1}, does not exist");
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $userUid), "The user with {0}: {1}, does not exist.");
throw (new \Exception($msg));
}
@@ -397,7 +397,7 @@ class Process
$obj = \ProcessCategoryPeer::retrieveByPK($processCategoryUid);
if (!(is_object($obj) && get_class($obj) == "ProcessCategory")) {
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $processCategoryUid), "The project category with {0}: {1}, does not exist");
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $processCategoryUid), "The project category with {0}: {1}, does not exist.");
throw (new \Exception($msg));
}
@@ -420,7 +420,7 @@ class Process
$obj = \AdditionalTablesPeer::retrieveByPK($additionalTableUid);
if (!(is_object($obj) && get_class($obj) == "AdditionalTables")) {
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $additionalTableUid), "The PM Table with {0}: {1} does not exist");
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $additionalTableUid), "The PM Table with {0}: {1} does not exist.");
throw (new \Exception($msg));
}
@@ -454,7 +454,7 @@ class Process
$rsCriteria = \TaskPeer::doSelectRS($criteria);
if (!$rsCriteria->next()) {
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $taskUid), "The activity with {0}: {1} does not exist");
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $taskUid), "The activity with {0}: {1} does not exist.");
throw (new \Exception($msg));
}
@@ -488,7 +488,7 @@ class Process
}
if ($flag == 0) {
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $fileName), "The routing screen template with {0}: {1} does not exist");
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $fileName), "The routing screen template with {0}: {1} does not exist.");
throw (new \Exception($msg));
}

View File

@@ -282,7 +282,10 @@ class ProcessCategory
public function addCategory($cat_name)
{
try {
require_once 'classes/model/ProcessCategory.php';
require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes". PATH_SEP . "model" . PATH_SEP . "ProcessCategory.php");
if ($cat_name == '') {
throw (new \Exception( 'cat_name. Process Category name can\'t be null'));
}
$catName = trim( $cat_name );
if ($this->existsName( $cat_name )) {
throw (new \Exception( 'cat_name. Duplicate Process Category name'));
@@ -312,7 +315,7 @@ class ProcessCategory
public function updateCategory($cat_uid, $cat_name)
{
try {
require_once 'classes/model/ProcessCategory.php';
require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes". PATH_SEP . "model" . PATH_SEP . "ProcessCategory.php");
$catUID = $cat_uid;
$catName = trim( $cat_name );
if ($this->existsName( $cat_name )) {

View File

@@ -167,9 +167,11 @@ class Step
*/
public function throwExceptionIfHaveInvalidValueInTypeObj($stepTypeObj)
{
if (!in_array($stepTypeObj, array("DYNAFORM", "INPUT_DOCUMENT", "OUTPUT_DOCUMENT", "EXTERNAL"))) {
$arrayDefaultValues = array("DYNAFORM", "INPUT_DOCUMENT", "OUTPUT_DOCUMENT", "EXTERNAL");
if (!in_array($stepTypeObj, $arrayDefaultValues)) {
$field = $this->arrayParamException["stepTypeObj"];
throw (new \Exception(str_replace(array("{0}"), array($field), "Invalid value specified for \"{0}\"")));
throw (new \Exception(str_replace(array("{0}", "{1}"), array($field, implode("|", $arrayDefaultValues)), "Invalid value for \"{0}\", it only accepts values: \"{1}\".")));
}
}
@@ -182,10 +184,12 @@ class Step
*/
public function throwExceptionIfHaveInvalidValueInMode($stepMode)
{
if (!in_array($stepMode, array("EDIT", "VIEW"))) {
$arrayDefaultValues = array("EDIT", "VIEW");
if (!in_array($stepMode, $arrayDefaultValues)) {
$field = $this->arrayParamException["stepMode"];
throw (new \Exception(str_replace(array("{0}"), array($field), "Invalid value specified for \"{0}\"")));
throw (new \Exception(str_replace(array("{0}", "{1}"), array($field, implode("|", $arrayDefaultValues)), "Invalid value for \"{0}\", it only accepts values: \"{1}\".")));
}
}
@@ -201,10 +205,7 @@ class Step
$step = new \Step();
if (!$step->StepExists($stepUid)) {
$field = $this->arrayParamException["stepUid"];
$msg = str_replace(array("{0}"), array($field), "Invalid value specified for \"{0}\"") . " / ";
$msg = $msg . str_replace(array("{0}", "{1}"), array($stepUid, "STEP"), "The UID \"{0}\" does not exist in table {1}");
$msg = str_replace(array("{0}", "{1}"), array($this->arrayParamException["stepUid"], $stepUid), "The step with {0}: {1} does not exist.");
throw (new \Exception($msg));
}
@@ -222,10 +223,7 @@ class Step
$task = new \Task();
if (!$task->taskExists($taskUid)) {
$field = $this->arrayParamException["taskUid"];
$msg = str_replace(array("{0}"), array($field), "Invalid value specified for \"{0}\"") . " / ";
$msg = $msg . str_replace(array("{0}", "{1}"), array($taskUid, "TASK"), "The UID \"{0}\" does not exist in table {1}");
$msg = str_replace(array("{0}", "{1}"), array($this->arrayParamException["taskUid"], $taskUid), "The activity with {0}: {1} does not exist.");
throw (new \Exception($msg));
}
@@ -243,10 +241,7 @@ class Step
$process = new \Process();
if (!$process->exists($processUid)) {
$field = $this->arrayParamException["processUid"];
$msg = str_replace(array("{0}"), array($field), "Invalid value specified for \"{0}\"") . " / ";
$msg = $msg . str_replace(array("{0}", "{1}"), array($processUid, "PROCESS"), "The UID \"{0}\" does not exist in table {1}");
$msg = str_replace(array("{0}", "{1}"), array($this->arrayParamException["processUid"], $processUid), "The project with {0}: {1} does not exist.");
throw (new \Exception($msg));
}
@@ -274,33 +269,33 @@ class Step
$this->throwExceptionIfNotExistsProcess($processUid);
if (!isset($arrayData["STEP_TYPE_OBJ"])) {
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepTypeObj"]), "The \"{0}\" attribute is not defined")));
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepTypeObj"]), "Undefined value for \"{0}\", it is required.")));
}
$arrayData["STEP_TYPE_OBJ"] = trim($arrayData["STEP_TYPE_OBJ"]);
if ($arrayData["STEP_TYPE_OBJ"] == "") {
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepTypeObj"]), "The \"{0}\" attribute is empty")));
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepTypeObj"]), "Invalid value for \"{0}\", it can not be empty.")));
}
if (!isset($arrayData["STEP_UID_OBJ"])) {
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepUidObj"]), "The \"{0}\" attribute is not defined")));
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepUidObj"]), "Undefined value for \"{0}\", it is required.")));
}
$arrayData["STEP_UID_OBJ"] = trim($arrayData["STEP_UID_OBJ"]);
if ($arrayData["STEP_UID_OBJ"] == "") {
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepUidObj"]), "The \"{0}\" attribute is empty")));
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepUidObj"]), "Invalid value for \"{0}\", it can not be empty.")));
}
if (!isset($arrayData["STEP_MODE"])) {
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepMode"]), "The \"{0}\" attribute is not defined")));
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepMode"]), "Undefined value for \"{0}\", it is required.")));
}
$arrayData["STEP_MODE"] = trim($arrayData["STEP_MODE"]);
if ($arrayData["STEP_MODE"] == "") {
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepMode"]), "The \"{0}\" attribute is empty")));
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepMode"]), "Invalid value for \"{0}\", it can not be empty.")));
}
$this->throwExceptionIfHaveInvalidValueInTypeObj($arrayData["STEP_TYPE_OBJ"]);
@@ -372,18 +367,18 @@ class Step
//Verify data
if (isset($arrayData["STEP_TYPE_OBJ"]) && !isset($arrayData["STEP_UID_OBJ"])) {
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepUidObj"]), "The \"{0}\" attribute is not defined")));
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepUidObj"]), "Undefined value for \"{0}\", it is required.")));
}
if (!isset($arrayData["STEP_TYPE_OBJ"]) && isset($arrayData["STEP_UID_OBJ"])) {
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepTypeObj"]), "The \"{0}\" attribute is not defined")));
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepTypeObj"]), "Undefined value for \"{0}\", it is required.")));
}
if (isset($arrayData["STEP_TYPE_OBJ"])) {
$arrayData["STEP_TYPE_OBJ"] = trim($arrayData["STEP_TYPE_OBJ"]);
if ($arrayData["STEP_TYPE_OBJ"] == "") {
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepTypeObj"]), "The \"{0}\" attribute is empty")));
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepTypeObj"]), "Invalid value for \"{0}\", it can not be empty.")));
}
}
@@ -391,7 +386,7 @@ class Step
$arrayData["STEP_UID_OBJ"] = trim($arrayData["STEP_UID_OBJ"]);
if ($arrayData["STEP_UID_OBJ"] == "") {
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepUidObj"]), "The \"{0}\" attribute is empty")));
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepUidObj"]), "Invalid value for \"{0}\", it can not be empty.")));
}
}
@@ -399,7 +394,7 @@ class Step
$arrayData["STEP_MODE"] = trim($arrayData["STEP_MODE"]);
if ($arrayData["STEP_MODE"] == "") {
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepMode"]), "The \"{0}\" attribute is empty")));
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepMode"]), "Invalid value for \"{0}\", it can not be empty.")));
}
}
@@ -859,7 +854,8 @@ class Step
*
* @return void
*/
public function moveSteps($pro_uid, $tas_uid, $step_uid, $step_pos) {
public function moveSteps($pro_uid, $tas_uid, $step_uid, $step_pos)
{
$this->setFormatFieldNameInUppercase(false);
$this->setArrayParamException(array("taskUid" => "act_uid"));
$aSteps = $this->getSteps($tas_uid);

View File

@@ -75,10 +75,7 @@ class Task
$task = new \Task();
if (!$task->taskExists($taskUid)) {
$field = $this->arrayParamException["taskUid"];
$msg = str_replace(array("{0}"), array($field), "Invalid value specified for \"{0}\"") . " / ";
$msg = $msg . str_replace(array("{0}", "{1}"), array($taskUid, "TASK"), "The UID \"{0}\" doesn't exist in table {1}");
$msg = str_replace(array("{0}", "{1}"), array($this->arrayParamException["taskUid"], $taskUid), "The activity with {0}: {1} does not exist.");
throw (new \Exception($msg));
}
@@ -2188,3 +2185,4 @@ class Task
}
}
}

View File

@@ -265,7 +265,7 @@ class Trigger
$rsCriteria = \TriggersPeer::doSelectRS($criteria);
if (!$rsCriteria->next()) {
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $triggerUid), "The trigger with {0}: {1}, does not exist");
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $triggerUid), "The trigger with {0}: {1}, does not exist.");
throw (new \Exception($msg));
}

View File

@@ -111,7 +111,7 @@ class TriggerWizard
$arrayLibrary = $this->library->getRegisteredClasses();
if (!isset($arrayLibrary[$this->libraryGetLibraryName($libraryName)])) {
$msg = str_replace(array("{0}", "{1}"), array($libraryFieldNameForException, $libraryName), "The library with {0}: \"{1}\" does not exist");
$msg = str_replace(array("{0}", "{1}"), array($libraryFieldNameForException, $libraryName), "The library with {0}: \"{1}\" does not exist.");
throw (new \Exception($msg));
}
@@ -138,7 +138,7 @@ class TriggerWizard
$library = $this->library->getLibraryDefinition($this->libraryGetLibraryName($libraryName));
if (!isset($library->methods[$methodName])) {
$msg = str_replace(array("{0}", "{1}"), array($methodFieldNameForException, $methodName), "The function with {0}: \"{1}\" does not exist in the library");
$msg = str_replace(array("{0}", "{1}"), array($methodFieldNameForException, $methodName), "The function with {0}: \"{1}\" does not exist in the library.");
throw (new \Exception($msg));
}
@@ -231,22 +231,22 @@ class TriggerWizard
if ($nInputParam > 0 || $nOutputParam > 0) {
if (!isset($arrayData["TRI_PARAMS"])) {
throw (new \Exception(str_replace(array("{0}"), array($fieldNameForException), "The \"{0}\" attribute is not defined")));
throw (new \Exception(str_replace(array("{0}"), array($fieldNameForException), "Undefined value for \"{0}\", it is required.")));
}
if (!is_array($arrayData["TRI_PARAMS"])) {
throw (new \Exception(str_replace(array("{0}"), array($fieldNameForException), "The \"{0}\" attribute is not array")));
throw (new \Exception(str_replace(array("{0}"), array($fieldNameForException), "Invalid value for \"{0}\", this value must be an array.")));
}
$arrayData["TRI_PARAMS"] = array_change_key_case($arrayData["TRI_PARAMS"], CASE_UPPER);
if ($nInputParam > 0) {
if (!isset($arrayData["TRI_PARAMS"]["INPUT"])) {
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName($fieldNameForException . ".INPUT")), "The \"{0}\" attribute is not defined")));
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName($fieldNameForException . ".INPUT")), "Undefined value for \"{0}\", it is required.")));
}
if (!is_array($arrayData["TRI_PARAMS"]["INPUT"])) {
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName($fieldNameForException . ".INPUT")), "The \"{0}\" attribute is not array")));
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName($fieldNameForException . ".INPUT")), "Invalid value for \"{0}\", this value must be an array.")));
}
$arrayParamData["input"] = $arrayData["TRI_PARAMS"]["INPUT"];
@@ -254,11 +254,11 @@ class TriggerWizard
if ($nOutputParam > 0) {
if (!isset($arrayData["TRI_PARAMS"]["OUTPUT"])) {
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName($fieldNameForException . ".OUTPUT")), "The \"{0}\" attribute is not defined")));
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName($fieldNameForException . ".OUTPUT")), "Undefined value for \"{0}\", it is required.")));
}
if (!is_array($arrayData["TRI_PARAMS"]["OUTPUT"])) {
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName($fieldNameForException . ".OUTPUT")), "The \"{0}\" attribute is not array")));
throw (new \Exception(str_replace(array("{0}"), array($this->getFieldNameByFormatFieldName($fieldNameForException . ".OUTPUT")), "Invalid value for \"{0}\", this value must be an array.")));
}
$arrayParamData["output"] = $arrayData["TRI_PARAMS"]["OUTPUT"];

View File

@@ -9,7 +9,8 @@ namespace ProcessMaker\BusinessModel;
*
* @protected
*/
class Validator{
class Validator
{
/**
* Validate dep_uid
* @var string $dep_uid. Uid for Departament
@@ -330,6 +331,47 @@ class Validator{
throw (new \Exception("The field '$nameField' is empty."));
}
}
/**
* Verify if data is array
*
* @param string $data Data
* @param string $dataNameForException Data name for the exception
*
* return void Throw exception if data is not array
*/
public function throwExceptionIfDataIsNotArray($data, $dataNameForException)
{
try {
if (!is_array($data)) {
$msg = str_replace(array("{0}"), array($dataNameForException), "Invalid value for \"{0}\", this value must be an array.");
throw (new \Exception($msg));
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if data is empty
*
* @param string $data Data
* @param string $dataNameForException Data name for the exception
*
* return void Throw exception if data is empty
*/
public function throwExceptionIfDataIsEmpty($data, $dataNameForException)
{
try {
if (empty($data)) {
$msg = str_replace(array("{0}"), array($dataNameForException), "Invalid value for \"{0}\", it can not be empty.");
throw (new \Exception($msg));
}
} catch (\Exception $e) {
throw $e;
}
}
}

View File

@@ -12,8 +12,8 @@ if (!class_exists("Propel")) {
*/
class CalendarTest extends \PHPUnit_Framework_TestCase
{
private static $calendar;
private static $numCalendar = 2;
protected static $calendar;
protected static $numCalendar = 2;
/**
* Set class for test
@@ -63,6 +63,22 @@ class CalendarTest extends \PHPUnit_Framework_TestCase
$arrayRecord[] = $arrayCalendar;
}
//Create - Japanese characters
$arrayData = array(
"CAL_NAME" => "私の名前PHPUnitの",
"CAL_WORK_DAYS" => array("MON", "TUE", "WED", "THU", "FRI"),
"CAL_STATUS" => "ACTIVE"
);
$arrayCalendar = self::$calendar->create($arrayData);
$this->assertTrue(is_array($arrayCalendar));
$this->assertNotEmpty($arrayCalendar);
$this->assertTrue(isset($arrayCalendar["CAL_UID"]));
$arrayRecord[] = $arrayCalendar;
//Return
return $arrayRecord;
}
@@ -70,10 +86,10 @@ class CalendarTest extends \PHPUnit_Framework_TestCase
/**
* Test update calendars
*
* @covers \ProcessMaker\BusinessModel\Calendar::update
*
* @depends testCreate
* @param array $arrayRecord Data of the calendars
*
* @covers \ProcessMaker\BusinessModel\Calendar::update
*/
public function testUpdate($arrayRecord)
{
@@ -92,10 +108,10 @@ class CalendarTest extends \PHPUnit_Framework_TestCase
/**
* Test get calendars
*
* @covers \ProcessMaker\BusinessModel\Calendar::getCalendars
*
* @depends testCreate
* @param array $arrayRecord Data of the calendars
*
* @covers \ProcessMaker\BusinessModel\Calendar::getCalendars
*/
public function testGetCalendars($arrayRecord)
{
@@ -121,13 +137,14 @@ class CalendarTest extends \PHPUnit_Framework_TestCase
/**
* Test get calendar
*
* @covers \ProcessMaker\BusinessModel\Calendar::getCalendar
*
* @depends testCreate
* @param array $arrayRecord Data of the calendars
*
* @covers \ProcessMaker\BusinessModel\Calendar::getCalendar
*/
public function testGetCalendar($arrayRecord)
{
//Get
$arrayCalendar = self::$calendar->getCalendar($arrayRecord[0]["CAL_UID"]);
$this->assertTrue(is_array($arrayCalendar));
@@ -137,15 +154,249 @@ class CalendarTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($arrayCalendar["CAL_NAME"], $arrayRecord[0]["CAL_NAME"]);
$this->assertEquals($arrayCalendar["CAL_DESCRIPTION"], $arrayRecord[0]["CAL_DESCRIPTION"]);
$this->assertEquals($arrayCalendar["CAL_STATUS"], $arrayRecord[0]["CAL_STATUS"]);
//Get - Japanese characters
$arrayCalendar = self::$calendar->getCalendar($arrayRecord[self::$numCalendar]["CAL_UID"]);
$this->assertTrue(is_array($arrayCalendar));
$this->assertNotEmpty($arrayCalendar);
$this->assertEquals($arrayCalendar["CAL_NAME"], "私の名前PHPUnitの");
$this->assertEquals($arrayCalendar["CAL_WORK_DAYS"], array("MON", "TUE", "WED", "THU", "FRI"));
$this->assertEquals($arrayCalendar["CAL_STATUS"], "ACTIVE");
}
/**
* Test exception when data not is array
*
* @covers \ProcessMaker\BusinessModel\Calendar::create
*
* @expectedException Exception
* @expectedExceptionMessage Invalid value for "$arrayData", this value must be an array.
*/
public function testCreateExceptionNoIsArrayData()
{
$arrayData = 0;
$arrayCalendar = self::$calendar->create($arrayData);
}
/**
* Test exception for empty data
*
* @covers \ProcessMaker\BusinessModel\Calendar::create
*
* @expectedException Exception
* @expectedExceptionMessage Invalid value for "$arrayData", it can not be empty.
*/
public function testCreateExceptionEmptyData()
{
$arrayData = array();
$arrayCalendar = self::$calendar->create($arrayData);
}
/**
* Test exception for required data (CAL_NAME)
*
* @covers \ProcessMaker\BusinessModel\Calendar::create
*
* @expectedException Exception
* @expectedExceptionMessage Undefined value for "CAL_NAME", it is required.
*/
public function testCreateExceptionRequiredDataCalName()
{
$arrayData = array(
//"CAL_NAME" => "PHPUnit Calendar",
"CAL_DESCRIPTION" => "Description",
"CAL_WORK_DAYS" => array("MON", "TUE", "WED", "THU", "FRI"),
"CAL_STATUS" => "ACTIVE"
);
$arrayCalendar = self::$calendar->create($arrayData);
}
/**
* Test exception for invalid data (CAL_NAME)
*
* @covers \ProcessMaker\BusinessModel\Calendar::create
*
* @expectedException Exception
* @expectedExceptionMessage Invalid value for "CAL_NAME", it can not be empty.
*/
public function testCreateExceptionInvalidDataCalName()
{
$arrayData = array(
"CAL_NAME" => "",
"CAL_DESCRIPTION" => "Description",
"CAL_WORK_DAYS" => array("MON", "TUE", "WED", "THU", "FRI"),
"CAL_STATUS" => "ACTIVE"
);
$arrayCalendar = self::$calendar->create($arrayData);
}
/**
* Test exception for invalid data (CAL_WORK_DAYS)
*
* @covers \ProcessMaker\BusinessModel\Calendar::create
*
* @expectedException Exception
* @expectedExceptionMessage Invalid value for "CAL_WORK_DAYS", it only accepts values: "SUN|MON|TUE|WED|THU|FRI|SAT".
*/
public function testCreateExceptionInvalidDataCalWorkDays()
{
$arrayData = array(
"CAL_NAME" => "PHPUnit Calendar",
"CAL_DESCRIPTION" => "Description",
"CAL_WORK_DAYS" => array("MONDAY", "TUE", "WED", "THU", "FRI"),
"CAL_STATUS" => "ACTIVE"
);
$arrayCalendar = self::$calendar->create($arrayData);
}
/**
* Test exception for calendar name existing
*
* @covers \ProcessMaker\BusinessModel\Calendar::create
*
* @expectedException Exception
* @expectedExceptionMessage The calendar name with CAL_NAME: "PHPUnit Calendar0" already exists
*/
public function testCreateExceptionExistsCalName()
{
$arrayData = array(
"CAL_NAME" => "PHPUnit Calendar0",
"CAL_DESCRIPTION" => "Description",
"CAL_WORK_DAYS" => array("MON", "TUE", "WED", "THU", "FRI"),
"CAL_STATUS" => "ACTIVE"
);
$arrayCalendar = self::$calendar->create($arrayData);
}
/**
* Test exception when data not is array
*
* @covers \ProcessMaker\BusinessModel\Calendar::update
*
* @expectedException Exception
* @expectedExceptionMessage Invalid value for "$arrayData", this value must be an array.
*/
public function testUpdateExceptionNoIsArrayData()
{
$arrayData = 0;
$arrayCalendar = self::$calendar->update("", $arrayData);
}
/**
* Test exception for empty data
*
* @covers \ProcessMaker\BusinessModel\Calendar::update
*
* @expectedException Exception
* @expectedExceptionMessage Invalid value for "$arrayData", it can not be empty.
*/
public function testUpdateExceptionEmptyData()
{
$arrayData = array();
$arrayCalendar = self::$calendar->update("", $arrayData);
}
/**
* Test exception for invalid calendar UID
*
* @covers \ProcessMaker\BusinessModel\Calendar::update
*
* @expectedException Exception
* @expectedExceptionMessage The calendar with CAL_UID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx does not exist.
*/
public function testUpdateExceptionInvalidCalUid()
{
$arrayData = array(
"CAL_NAME" => "PHPUnit Calendar",
"CAL_DESCRIPTION" => "Description",
"CAL_WORK_DAYS" => array("MON", "TUE", "WED", "THU", "FRI"),
"CAL_STATUS" => "ACTIVE"
);
$arrayCalendar = self::$calendar->update("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", $arrayData);
}
/**
* Test exception for invalid data (CAL_NAME)
*
* @covers \ProcessMaker\BusinessModel\Calendar::update
*
* @depends testCreate
* @param array $arrayRecord Data of the calendars
*
* @expectedException Exception
* @expectedExceptionMessage Invalid value for "CAL_NAME", it can not be empty.
*/
public function testUpdateExceptionInvalidDataCalName($arrayRecord)
{
$arrayData = array(
"CAL_NAME" => "",
"CAL_DESCRIPTION" => "Description",
"CAL_WORK_DAYS" => array("MON", "TUE", "WED", "THU", "FRI"),
"CAL_STATUS" => "ACTIVE"
);
$arrayCalendar = self::$calendar->update($arrayRecord[0]["CAL_UID"], $arrayData);
}
/**
* Test exception for invalid data (CAL_WORK_DAYS)
*
* @covers \ProcessMaker\BusinessModel\Calendar::update
*
* @depends testCreate
* @param array $arrayRecord Data of the calendars
*
* @expectedException Exception
* @expectedExceptionMessage Invalid value for "CAL_WORK_DAYS", it only accepts values: "SUN|MON|TUE|WED|THU|FRI|SAT".
*/
public function testUpdateExceptionInvalidDataCalWorkDays($arrayRecord)
{
$arrayData = array(
"CAL_NAME" => "PHPUnit Calendar",
"CAL_DESCRIPTION" => "Description",
"CAL_WORK_DAYS" => array("MONDAY", "TUE", "WED", "THU", "FRI"),
"CAL_STATUS" => "ACTIVE"
);
$arrayCalendar = self::$calendar->update($arrayRecord[0]["CAL_UID"], $arrayData);
}
/**
* Test exception for calendar name existing
*
* @covers \ProcessMaker\BusinessModel\Calendar::update
*
* @depends testCreate
* @param array $arrayRecord Data of the calendars
*
* @expectedException Exception
* @expectedExceptionMessage The calendar name with CAL_NAME: "PHPUnit Calendar1" already exists
*/
public function testUpdateExceptionExistsCalName($arrayRecord)
{
$arrayData = $arrayRecord[1];
$arrayCalendar = self::$calendar->update($arrayRecord[0]["CAL_UID"], $arrayData);
}
/**
* Test delete calendars
*
* @covers \ProcessMaker\BusinessModel\Calendar::delete
*
* @depends testCreate
* @param array $arrayRecord Data of the calendars
*
* @covers \ProcessMaker\BusinessModel\Calendar::delete
*/
public function testDelete($arrayRecord)
{

View File

@@ -177,14 +177,12 @@ class InputDocumentsCasesTest extends \PHPUnit_Framework_TestCase
* Test error for incorrect value of input document in array
*
* @covers \ProcessMaker\BusinessModel\Cases\InputDocument::removeInputDocument
* @depends testAddInputDocument
* @param array $aResponse
* @expectedException Exception
* @expectedExceptionMessage This input document with id: 12345678912345678912345678912345678 doesn't exist!
*
* @copyright Colosa - Bolivia
*/
public function testGetCasesInputDocumentErrorIncorrectApplicationValueArray(array $aResponse)
public function testRemoveInputDocumentErrorIncorrectApplicationValueArray()
{
$this->oInputDocument->removeInputDocument('12345678912345678912345678912345678');
}

View File

@@ -101,6 +101,20 @@ class OutputDocumentsCasesTest extends \PHPUnit_Framework_TestCase
return $aResponse;
}
/**
* Test error for incorrect value of application in array
*
* @covers \ProcessMaker\BusinessModel\Cases\OutputDocument::getCasesOutputDocuments
* @expectedException Exception
* @expectedExceptionMessage The Application row '12345678912345678912345678912345678' doesn't exist!
*
* @copyright Colosa - Bolivia
*/
public function testGetCasesOutputDocumentsErrorIncorrectApplicationValueArray()
{
$this->oOutputDocument->getCasesOutputDocuments('12345678912345678912345678912345678', self::$usrUid);
}
/**
* Test get OutputDocuments
*
@@ -116,6 +130,38 @@ class OutputDocumentsCasesTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(is_array($response));
}
/**
* Test error for incorrect value of application in array
*
* @covers \ProcessMaker\BusinessModel\Cases\OutputDocument::getCasesOutputDocument
* @depends testAddCasesOutputDocument
* @param array $aResponse
* @expectedException Exception
* @expectedExceptionMessage The Application row '12345678912345678912345678912345678' doesn't exist!
*
* @copyright Colosa - Bolivia
*/
public function testGetCasesOutputDocumentErrorIncorrectApplicationValueArray(array $aResponse)
{
$this->oOutputDocument->getCasesOutputDocument('12345678912345678912345678912345678', self::$usrUid, $aResponse["app_doc_uid"]);
}
/**
* Test error for incorrect value of output document in array
*
* @covers \ProcessMaker\BusinessModel\Cases\OutputDocument::getCasesOutputDocument
* @depends testAddCasesOutputDocument
* @param array $aResponse
* @expectedException Exception
* @expectedExceptionMessage This output document with id: 12345678912345678912345678912345678 doesn't exist!
*
* @copyright Colosa - Bolivia
*/
public function testGetCasesOutputDocumentErrorIncorrectOutputDocumentValueArray(array $aResponse)
{
$this->oOutputDocument->getCasesOutputDocument($aResponse["idCase"], self::$usrUid, '12345678912345678912345678912345678');
}
/**
* Test get OutputDocument
*
@@ -131,6 +177,20 @@ class OutputDocumentsCasesTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(is_object($response));
}
/**
* Test error for incorrect value of output document in array
*
* @covers \ProcessMaker\BusinessModel\Cases\OutputDocument::removeOutputDocument
* @expectedException Exception
* @expectedExceptionMessage This output document with id: 12345678912345678912345678912345678 doesn't exist!
*
* @copyright Colosa - Bolivia
*/
public function testRemoveOutputDocumentErrorIncorrectOutputDocumentValueArray()
{
$this->oOutputDocument->removeOutputDocument('12345678912345678912345678912345678');
}
/**
* Test remove OutputDocument
*

View File

@@ -40,6 +40,20 @@ class ProcessCategoryTest extends \PHPUnit_Framework_TestCase
}
}
/**
* Test error for incorrect value of category name in array
*
* @covers \BusinessModel\ProcessCategory::addCategory
* @expectedException Exception
* @expectedExceptionMessage cat_name. Process Category name can't be null
*
* @copyright Colosa - Bolivia
*/
public function testAddCategoryErrorIncorrectValue()
{
$this->oCategory->addCategory('');
}
/**
* Test add Category
*
@@ -55,6 +69,34 @@ class ProcessCategoryTest extends \PHPUnit_Framework_TestCase
return $aResponse;
}
/**
* Test error for incorrect value of category name in array
*
* @covers \BusinessModel\ProcessCategory::addCategory
* @expectedException Exception
* @expectedExceptionMessage cat_name. Duplicate Process Category name
*
* @copyright Colosa - Bolivia
*/
public function testAddCategoryErrorDuplicateValue()
{
$this->oCategory->addCategory('New Category Test');
}
/**
* Test error for incorrect value of category name in array
*
* @covers \BusinessModel\ProcessCategory::updateCategory
* @expectedException Exception
* @expectedExceptionMessage cat_name. Duplicate Process Category name
*
* @copyright Colosa - Bolivia
*/
public function testUpdateCategoryErrorDuplicateValue()
{
$this->oCategory->addCategory('New Category Test');
}
/**
* Test put Category
*
@@ -70,6 +112,20 @@ class ProcessCategoryTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(is_object($response));
}
/**
* Test error for incorrect value of category id
*
* @covers \BusinessModel\ProcessCategory::getCategory
* @expectedException Exception
* @expectedExceptionMessage The Category with cat_uid: 12345678912345678912345678912345678 doesn't exist!
*
* @copyright Colosa - Bolivia
*/
public function testGetErrorValue()
{
$this->oCategory->getCategory('12345678912345678912345678912345678');
}
/**
* Test get Category
*
@@ -85,6 +141,19 @@ class ProcessCategoryTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(is_object($response));
}
/**
* Test error for incorrect value of category id
*
* @covers \BusinessModel\ProcessCategory::deleteCategory
* @expectedException Exception
* @expectedExceptionMessage The Category with cat_uid: 12345678912345678912345678912345678 doesn't exist!
*
* @copyright Colosa - Bolivia
*/
public function testDeleteErrorValue()
{
$this->oCategory->deleteCategory('12345678912345678912345678912345678');
}
/**
* Test delete Category