Merge branch 'master' of bitbucket.org:colosa/processmaker
This commit is contained in:
@@ -195,7 +195,7 @@ Scenario Outline: Delete a pm table of a pmtable
|
||||
|
||||
Scenario Outline: Delete a data of a pmtable
|
||||
Given that I want to delete a resource with the key "pmt_uid" stored in session array as variable "pmt_uid_<pmt_uid_number>"
|
||||
And I request "pmtable/<pmt_uid>/data/CAMPO1/updatevalor2"
|
||||
And I request "pmtable/<pmt_uid>/data/CAMPO1/valor1"
|
||||
And the content type is "application/json"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
|
||||
@@ -76,15 +76,43 @@ Scenario Outline: Create news pmtable
|
||||
Examples:
|
||||
|
||||
| test_description | pmt_uid_number | pmt_tab_name | pmt_tab_dsc | fld_name_1 | fld_label_1 | fld_type_1 | fld_name_2 | fld_label_2 | fld_type_2 | fld_name_3 | fld_label_3 | fld_type_3 |
|
||||
| Create pmtable with type varchar, bigint and boolean | 1 | PMT_Test_QA1 | pmt table 1 created with script | UNO | UNO | VARCHAR | DOS | DOS | BIGINT | TRES | TRES | BOOLEAN |
|
||||
| Create pmtable with type varchar, char and date | 2 | PMT_Test_QA2 | pmt table 2 created with script | UNO | UNO | VARCHAR | DOS | DOS | CHAR | TRES | TRES | DATE |
|
||||
| Create pmtable with type varchar, datetime and decimal | 3 | PMT_Test_QA3 | pmt table 3 created with script | UNO | UNO | VARCHAR | DOS | DOS | DATETIME | TRES | TRES | DECIMAL |
|
||||
| Create pmtable with type varchar, double and float | 4 | PMT_Test_QA4 | pmt table 4 created with script | UNO | UNO | VARCHAR | DOS | DOS | DOUBLE | TRES | TRES | FLOAT |
|
||||
| Create pmtable with type varchar, integer and longvarchar | 5 | PMT_Test_QA5 | pmt table 5 created with script | UNO | UNO | VARCHAR | DOS | DOS | INTEGER | TRES | TRES | LONGVARCHAR |
|
||||
| Create pmtable with type varchar, real and smallint | 6 | PMT_Test_QA6 | pmt table 6 created with script | UNO | UNO | VARCHAR | DOS | DOS | REAL | TRES | TRES | SMALLINT |
|
||||
| Create pmtable with type varchar, time and tinyint | 7 | PMT_Test_QA7 | pmt table 7 created with script | UNO | UNO | VARCHAR | DOS | DOS | TIME | TRES | TRES | TINYINT |
|
||||
| Create pmtable with type varchar, bigint and boolean | 1 | PMT_Test_QA1 | pmt table 1 created with script | UNO | UNO | VARCHAR | DOS | DOS | BIGINT | TRES | TRES | BOOLEAN |
|
||||
| Create pmtable with type varchar, datetime and decimal | 3 | PMT_Test_QA3 | pmt table 3 created with script | UNO | UNO | VARCHAR | DOS | DOS | DATETIME | TRES | TRES | DECIMAL |
|
||||
| Create pmtable with type varchar, double and float | 4 | PMT_Test_QA4 | pmt table 4 created with script | UNO | UNO | VARCHAR | DOS | DOS | DOUBLE | TRES | TRES | FLOAT |
|
||||
| Create pmtable with type varchar, integer and longvarchar | 5 | PMT_Test_QA5 | pmt table 5 created with script | UNO | UNO | VARCHAR | DOS | DOS | INTEGER | TRES | TRES | LONGVARCHAR |
|
||||
| Create pmtable with type varchar, real and smallint | 6 | PMT_Test_QA6 | pmt table 6 created with script | UNO | UNO | VARCHAR | DOS | DOS | REAL | TRES | TRES | SMALLINT |
|
||||
| Create pmtable with type varchar, time and tinyint | 7 | PMT_Test_QA7 | pmt table 7 created with script | UNO | UNO | VARCHAR | DOS | DOS | TIME | TRES | TRES | TINYINT |
|
||||
|
||||
|
||||
Scenario Outline: Create new pmtable with type date and char
|
||||
Given POST this data:
|
||||
"""
|
||||
{
|
||||
"pmt_tab_name" : "PMT_Test_QA2",
|
||||
"pmt_tab_dsc" : "pmt table 2 created with script",
|
||||
"fields" : [
|
||||
{
|
||||
"fld_key" : 1,
|
||||
"fld_name" : "EJEMPLO",
|
||||
"fld_label" : "EJEMPLO",
|
||||
"fld_type" : "DATE"
|
||||
}
|
||||
]
|
||||
}
|
||||
"""
|
||||
And I request "pmtable"
|
||||
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"
|
||||
And store "pmt_uid" in session array as variable "pmt_uid_<pmt_uid_number>"
|
||||
|
||||
Examples:
|
||||
|
||||
| test_description | pmt_uid_number |
|
||||
| Create pmtable with type date | 2 |
|
||||
|
||||
|
||||
Scenario Outline: Create a new Data of pm table.
|
||||
Given POST this data:
|
||||
"""
|
||||
|
||||
@@ -449,7 +449,7 @@ Scenario Outline: Update the Projects and then check if the values had changed
|
||||
|
||||
|
||||
Scenario Outline: Get definition of a project
|
||||
Given that I want to get a resource with the key "new_uid" stored in session array as variable "project_new_uid_<project_new_uid_number>" in postion 0
|
||||
Given that I want to get a resource with the key "new_uid" stored in session array as variable "project_new_uid_<project_new_uid_number>" in position 0
|
||||
And I request "project"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
|
||||
@@ -24,7 +24,7 @@ Scenario: Get definition of a project activity for obtent definition
|
||||
|
||||
|
||||
Scenario Outline: Create new Projects
|
||||
Given POST data from file "<project_template>"
|
||||
Given POST data from file "<project_template>"
|
||||
And I request "projects"
|
||||
Then the response status code should be 201
|
||||
And the response charset is "UTF-8"
|
||||
@@ -45,8 +45,21 @@ Scenario Outline: Create new Projects
|
||||
| Create a new process with parallel by evaluation derivation | 3 | process_template_parallel_por_evaluation.json |
|
||||
| Create a new process with selection derivation | 4 | process_template_selection.json |
|
||||
| Create a new process with sequencial derivation | 5 | process_template_sequencial.json |
|
||||
| Create a new process Complete | 6 | process_template_complete.json |
|
||||
|
||||
|
||||
Scenario Outline: Create new Projects with same name (negative test)
|
||||
Given POST data from file "<project_template>"
|
||||
And I request "projects"
|
||||
Then the response status code should be 400
|
||||
And the response status message should have the following text "<already_exists>"
|
||||
|
||||
Examples:
|
||||
|
||||
| Description | project_template |
|
||||
| Create a new process with same name | process_template_evaluation.json |
|
||||
|
||||
|
||||
Scenario: Get a list of projects
|
||||
Given I request "project"
|
||||
Then the response status code should be 200
|
||||
@@ -706,6 +719,7 @@ Scenario Outline: Delete a Project activity created previously in this script
|
||||
| 3 |
|
||||
| 4 |
|
||||
| 5 |
|
||||
| 6 |
|
||||
|
||||
|
||||
Scenario: Get a list of projects
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
@ProcessMakerMichelangelo @RestAPI
|
||||
Feature: Projects Negative Tests
|
||||
|
||||
Background:
|
||||
Given that I have a valid access_token
|
||||
|
||||
|
||||
Scenario Outline: Create new Projects (Negative Tests)
|
||||
Given POST this data:
|
||||
"""
|
||||
{
|
||||
"prj_name": "<prj_name>",
|
||||
"prj_description": "<prj_description>",
|
||||
"prj_target_namespace": "sample",
|
||||
"prj_expresion_language": null,
|
||||
"prj_type_language": null,
|
||||
"prj_exporter": null,
|
||||
"prj_exporter_version": null,
|
||||
"prj_create_date": "2014-04-28 11:01:54",
|
||||
"prj_update_date": "2014-04-30 08:46:17",
|
||||
"prj_author": "00000000000000000000000000000001",
|
||||
"prj_author_version": null,
|
||||
"prj_original_source": null,
|
||||
"diagrams": [
|
||||
{
|
||||
"dia_uid": "956446767534fece3179b54016939905",
|
||||
"prj_uid": "655001588534fece2d46f86033751389",
|
||||
"dia_name": "Prueba New Project",
|
||||
"dia_is_closable": 0,
|
||||
"pro_uid": "736054291534fece3342096012897456",
|
||||
"activities": [
|
||||
{
|
||||
"act_uid": "569214945534fecfa8f0835033274864",
|
||||
"act_name": "<act_name>",
|
||||
"act_type": "<act_type>",
|
||||
"act_is_for_compensation": "0",
|
||||
"act_start_quantity": "1",
|
||||
"act_completion_quantity": "0",
|
||||
"act_task_type": "EMPTY",
|
||||
"act_implementation": "",
|
||||
"act_instantiate": "0",
|
||||
"act_script_type": "",
|
||||
"act_script": "",
|
||||
"act_loop_type": "NONE",
|
||||
"act_test_before": "0",
|
||||
"act_loop_maximum": "0",
|
||||
"act_loop_condition": "0",
|
||||
"act_loop_cardinality": "0",
|
||||
"act_loop_behavior": "0",
|
||||
"act_is_adhoc": "0",
|
||||
"act_is_collapsed": "0",
|
||||
"act_completion_condition": "0",
|
||||
"act_ordering": "0",
|
||||
"act_cancel_remaining_instances": "0",
|
||||
"act_protocol": "0",
|
||||
"act_method": "0",
|
||||
"act_is_global": "0",
|
||||
"act_referer": "0",
|
||||
"act_default_flow": "0",
|
||||
"act_master_diagram": "0",
|
||||
"bou_x": "486",
|
||||
"bou_y": "101",
|
||||
"bou_width": "161",
|
||||
"bou_height": "42",
|
||||
"bou_container": "bpmnDiagram"
|
||||
}
|
||||
],
|
||||
"events": [
|
||||
{
|
||||
"evn_uid": "259220802534fecfad49854013091940",
|
||||
"evn_name": "<evn_name>",
|
||||
"evn_type": "<evn_type>",
|
||||
"evn_marker": "<evn_marker>",
|
||||
"evn_is_interrupting": "1",
|
||||
"evn_cancel_activity": "0",
|
||||
"evn_activity_ref": null,
|
||||
"evn_wait_for_completion": "0",
|
||||
"evn_error_name": null,
|
||||
"evn_error_code": null,
|
||||
"evn_escalation_name": null,
|
||||
"evn_escalation_code": null,
|
||||
"evn_message": "LEAD",
|
||||
"evn_operation_name": null,
|
||||
"evn_operation_implementation_ref": null,
|
||||
"evn_time_date": null,
|
||||
"evn_time_cycle": null,
|
||||
"evn_time_duration": null,
|
||||
"evn_behavior": "CATCH",
|
||||
"bou_x": "517",
|
||||
"bou_y": "19",
|
||||
"bou_width": "33",
|
||||
"bou_height": "33",
|
||||
"bou_container": "bpmnDiagram"
|
||||
},
|
||||
{
|
||||
"evn_uid": "856003291534fecfae5dff7085708495",
|
||||
"evn_name": "End # 1",
|
||||
"evn_type": "END",
|
||||
"evn_marker": "EMPTY",
|
||||
"evn_is_interrupting": "1",
|
||||
"evn_cancel_activity": "0",
|
||||
"evn_activity_ref": null,
|
||||
"evn_wait_for_completion": "0",
|
||||
"evn_error_name": null,
|
||||
"evn_error_code": null,
|
||||
"evn_escalation_name": null,
|
||||
"evn_escalation_code": null,
|
||||
"evn_message": "",
|
||||
"evn_operation_name": null,
|
||||
"evn_operation_implementation_ref": null,
|
||||
"evn_time_date": null,
|
||||
"evn_time_cycle": null,
|
||||
"evn_time_duration": null,
|
||||
"evn_behavior": "THROW",
|
||||
"bou_x": "549",
|
||||
"bou_y": "181",
|
||||
"bou_width": "33",
|
||||
"bou_height": "33",
|
||||
"bou_container": "bpmnDiagram"
|
||||
}
|
||||
],
|
||||
"gateways": [],
|
||||
"flows": [
|
||||
{
|
||||
"flo_uid": "17092374253551306216a72013534569",
|
||||
"flo_type": "SEQUENCE",
|
||||
"flo_name": null,
|
||||
"flo_element_origin": "569214945534fecfa8f0835033274864",
|
||||
"flo_element_origin_type": "bpmnActivity",
|
||||
"flo_element_dest": "856003291534fecfae5dff7085708495",
|
||||
"flo_element_dest_type": "bpmnEvent",
|
||||
"flo_is_inmediate": "1",
|
||||
"flo_condition": null,
|
||||
"flo_x1": "561",
|
||||
"flo_y1": "193",
|
||||
"flo_x2": "577",
|
||||
"flo_y2": "193",
|
||||
"flo_state": [
|
||||
{
|
||||
"x": 566,
|
||||
"y": 145
|
||||
},
|
||||
{
|
||||
"x": 566,
|
||||
"y": 171
|
||||
},
|
||||
{
|
||||
"x": 602,
|
||||
"y": 171
|
||||
},
|
||||
{
|
||||
"x": 602,
|
||||
"y": 198
|
||||
},
|
||||
{
|
||||
"x": 582,
|
||||
"y": 198
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"flo_uid": "304762728534fecfaf3bf88040991913",
|
||||
"flo_type": "SEQUENCE",
|
||||
"flo_name": null,
|
||||
"flo_element_origin": "259220802534fecfad49854013091940",
|
||||
"flo_element_origin_type": "bpmnEvent",
|
||||
"flo_element_dest": "569214945534fecfa8f0835033274864",
|
||||
"flo_element_dest_type": "bpmnActivity",
|
||||
"flo_is_inmediate": "1",
|
||||
"flo_condition": null,
|
||||
"flo_x1": "529",
|
||||
"flo_y1": "95",
|
||||
"flo_x2": "556",
|
||||
"flo_y2": "95",
|
||||
"flo_state": [
|
||||
{
|
||||
"x": 534,
|
||||
"y": 52
|
||||
},
|
||||
{
|
||||
"x": 534,
|
||||
"y": 76
|
||||
},
|
||||
{
|
||||
"x": 561,
|
||||
"y": 76
|
||||
},
|
||||
{
|
||||
"x": 561,
|
||||
"y": 100
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"artifacts": [],
|
||||
"laneset": [],
|
||||
"lanes": []
|
||||
}
|
||||
]
|
||||
}
|
||||
"""
|
||||
And I request "projects"
|
||||
Then the response status code should be <error_code>
|
||||
And the response status message should have the following text "<error_message>"
|
||||
|
||||
Examples:
|
||||
|
||||
| Description | prj_name | prj_description | act_name | act_type | evn_name | evn_marker | error_code | error_message |
|
||||
| Field required prj_name | | Prueba | Task # 1 | TASK | End # 1 | EMPTY | 400 | prj_name |
|
||||
| Field required prj_description | Test negative project 1 | | Task # 1 | TASK | End # 1 | EMPTY | 400 | prj_description |
|
||||
| Field required act_name | Test negative project 2 | Prueba 1 | | TASK | End # 1 | EMPTY | 400 | act_name |
|
||||
| Field required act_type | Test negative project 3 | Prueba 2 | Task # 1 | | End # 1 | EMPTY | 400 | act_type |
|
||||
| Field required evn_name | Test negative project 4 | Prueba 3 | Task # 1 | TASK | | EMPTY | 400 | evn_name |
|
||||
| Field required evn_marker | Test negative project 5 | Prueba 4 | Task # 1 | TASK | End # 1 | | 400 | evn_marker |
|
||||
@@ -1,71 +0,0 @@
|
||||
@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
|
||||
2104
features/json/process_template_complete.json
Normal file
2104
features/json/process_template_complete.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,15 @@ abstract class Exporter
|
||||
*/
|
||||
protected $bpmnProject;
|
||||
|
||||
protected $projectData;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $projectData = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $metadata = array();
|
||||
|
||||
public function __construct($prjUid)
|
||||
{
|
||||
@@ -29,6 +37,16 @@ abstract class Exporter
|
||||
|
||||
$this->bpmnProject = Project\Bpmn::load($prjUid);
|
||||
$this->projectData = $this->bpmnProject->getProject();
|
||||
|
||||
$this->metadata = array(
|
||||
"vendor_version" => \System::getVersion(),
|
||||
"vendor_version_code" => "Michelangelo",
|
||||
"export_timestamp" => date("U"),
|
||||
"export_datetime" => date("Y-m-d\TH:i:sP"),
|
||||
"export_server_addr" => isset($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"].":".$_SERVER["SERVER_PORT"] : "Unknown",
|
||||
"export_server_os" => PHP_OS ,
|
||||
"export_server_php_version" => PHP_VERSION_ID,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,6 +91,7 @@ abstract class Exporter
|
||||
$data = array();
|
||||
|
||||
$data["metadata"] = $this->getMetadata();
|
||||
$data["metadata"]["workspace"] = defined("SYS_SYS") ? SYS_SYS : "Unknown";
|
||||
$data["metadata"]["name"] = $this->getProjectName();
|
||||
$data["metadata"]["uid"] = $this->getProjectUid();
|
||||
|
||||
@@ -166,22 +185,22 @@ abstract class Exporter
|
||||
return self::VERSION;
|
||||
}
|
||||
|
||||
public function setMetadata($key, $value)
|
||||
{
|
||||
$this->metadata[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all metadata to include on export content
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMetadata()
|
||||
public function getMetadata($key = "", $default = "")
|
||||
{
|
||||
return array(
|
||||
"vendor_version" => \System::getVersion(),
|
||||
"vendor_version_code" => "Michelangelo",
|
||||
"export_timestamp" => date("U"),
|
||||
"export_datetime" => date("Y-m-d\TH:i:sP)"),
|
||||
"export_server_addr" => isset($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"].":".$_SERVER["SERVER_PORT"] : "Unknown",
|
||||
"export_server_os" => PHP_OS ,
|
||||
"export_server_php_version" => PHP_VERSION_ID,
|
||||
"workspace" => defined("SYS_SYS") ? SYS_SYS : "Unknown",
|
||||
);
|
||||
if (! empty($key)) {
|
||||
return isset($this->metadata[$key]) ? $this->metadata[$key] : $default;
|
||||
} else {
|
||||
return $this->metadata;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,8 +44,8 @@ abstract class Importer
|
||||
if ($this->targetExists()) {
|
||||
throw new \Exception(sprintf(
|
||||
"Project already exists, you need set an action to continue. " .
|
||||
"Available actions: [%s|%s|%s].", self::IMPORT_OPTION_CREATE_NEW,
|
||||
self::IMPORT_OPTION_OVERWRITE, self::IMPORT_OPTION_DISABLE_AND_CREATE_NEW
|
||||
"Available actions: [%s|%s|%s|%s].", self::IMPORT_OPTION_CREATE_NEW,
|
||||
self::IMPORT_OPTION_OVERWRITE, self::IMPORT_OPTION_DISABLE_AND_CREATE_NEW, self::IMPORT_OPTION_KEEP_WITHOUT_CHANGING_AND_CREATE_NEW
|
||||
), self::IMPORT_STAT_TARGET_ALREADY_EXISTS);
|
||||
}
|
||||
$generateUid = false;
|
||||
@@ -206,7 +206,7 @@ abstract class Importer
|
||||
|
||||
$data = $_FILES[$varName];
|
||||
|
||||
if ($data["error"] != 0){
|
||||
if ($data["error"] != 0) {
|
||||
throw new \Exception("Error while uploading file. Error code: {$data["error"]}");
|
||||
}
|
||||
|
||||
@@ -263,7 +263,9 @@ abstract class Importer
|
||||
$basePath = "";
|
||||
}
|
||||
|
||||
if (empty($basePath)) continue;
|
||||
if (empty($basePath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
$filename = $basePath . $file["file_path"];
|
||||
@@ -366,6 +368,10 @@ abstract class Importer
|
||||
$result = $workflow->updateTask($arrayTaskData["TAS_UID"], $arrayTaskData);
|
||||
}
|
||||
|
||||
unset($arrayWorkflowTables["process"]["PRO_CREATE_USER"]);
|
||||
unset($arrayWorkflowTables["process"]["PRO_CREATE_DATE"]);
|
||||
unset($arrayWorkflowTables["process"]["PRO_UPDATE_DATE"]);
|
||||
|
||||
$workflow->update($arrayWorkflowTables["process"]);
|
||||
|
||||
//Return
|
||||
@@ -375,21 +381,21 @@ abstract class Importer
|
||||
/**
|
||||
* Imports a Project sent through the POST method ($_FILES)
|
||||
*
|
||||
* @param array $arrayData Data
|
||||
* @param array $arrayFieldName The field's names
|
||||
* @param array $arrayData Data
|
||||
* @param string $option Option ("CREATE", "OVERWRITE", "DISABLE", "KEEP")
|
||||
* @param array $arrayFieldName The field's names
|
||||
*
|
||||
* return array Returns the data sent and the unique id of Project
|
||||
*/
|
||||
public function importPostFile($arrayData, $arrayFieldName = array())
|
||||
public function importPostFile(array $arrayData, $option = "CREATE", array $arrayFieldName = array())
|
||||
{
|
||||
try {
|
||||
//Set data
|
||||
$arrayFieldName["projectFile"] = (isset($arrayFieldName["projectFile"]))? $arrayFieldName["projectFile"] : "PRJ_FILE";
|
||||
$arrayFieldName["projectFile"] = (isset($arrayFieldName["projectFile"]))? $arrayFieldName["projectFile"] : "PROJECT_FILE";
|
||||
$arrayFieldName["option"] = (isset($arrayFieldName["option"]))? $arrayFieldName["option"] : "OPTION";
|
||||
|
||||
$arrayFieldDefinition = array(
|
||||
$arrayFieldName["projectFile"] => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "projectFile"),
|
||||
$arrayFieldName["option"] => array("type" => "int", "required" => false, "empty" => false, "defaultValues" => array("CREATE", "OVERWRITE", "DISABLE", "KEEP"), "fieldNameAux" => "option")
|
||||
$arrayFieldName["projectFile"] => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "projectFile")
|
||||
);
|
||||
|
||||
$arrayFieldNameForException = $arrayFieldName;
|
||||
@@ -405,6 +411,9 @@ abstract class Importer
|
||||
$arrayData[$arrayFieldName["projectFile"]] = $arrayData[$arrayFieldName["projectFile"]]["name"];
|
||||
}
|
||||
|
||||
$optionCaseUpper = (strtoupper($option) == $option)? true : false;
|
||||
$option = strtoupper($option);
|
||||
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$validator = new \ProcessMaker\BusinessModel\Validator();
|
||||
@@ -414,6 +423,16 @@ abstract class Importer
|
||||
|
||||
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $arrayFieldDefinition, $arrayFieldNameForException, true);
|
||||
|
||||
$arrayOptionDefaultValues = array("CREATE", "OVERWRITE", "DISABLE", "KEEP");
|
||||
|
||||
if ($option . "" != "") {
|
||||
if (!in_array($option, $arrayOptionDefaultValues, true)) {
|
||||
$strdv = implode("|", $arrayOptionDefaultValues);
|
||||
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($arrayFieldNameForException["option"], ($optionCaseUpper)? $strdv : strtolower($strdv)), "Invalid value for \"{0}\", it only accepts values: \"{1}\".")));
|
||||
}
|
||||
}
|
||||
|
||||
if ((isset($_FILES["filepmx"]) && pathinfo($_FILES["filepmx"]["name"], PATHINFO_EXTENSION) != "pmx") ||
|
||||
(isset($arrayData[$arrayFieldName["projectFile"]]) && pathinfo($arrayData[$arrayFieldName["projectFile"]], PATHINFO_EXTENSION) != "pmx")
|
||||
) {
|
||||
@@ -421,20 +440,22 @@ abstract class Importer
|
||||
}
|
||||
|
||||
//Set variables
|
||||
$option = self::IMPORT_OPTION_CREATE_NEW;
|
||||
$opt = self::IMPORT_OPTION_CREATE_NEW; //CREATE
|
||||
|
||||
switch ((isset($arrayData[$arrayFieldName["option"]]))? $arrayData[$arrayFieldName["option"]] : "CREATE") {
|
||||
switch ($option) {
|
||||
case "OVERWRITE":
|
||||
$option = self::IMPORT_OPTION_OVERWRITE;
|
||||
$opt = self::IMPORT_OPTION_OVERWRITE;
|
||||
break;
|
||||
case "DISABLE":
|
||||
$option = self::IMPORT_OPTION_DISABLE_AND_CREATE_NEW;
|
||||
$opt = self::IMPORT_OPTION_DISABLE_AND_CREATE_NEW;
|
||||
break;
|
||||
case "KEEP":
|
||||
$option = self::IMPORT_OPTION_KEEP_WITHOUT_CHANGING_AND_CREATE_NEW;
|
||||
$opt = self::IMPORT_OPTION_KEEP_WITHOUT_CHANGING_AND_CREATE_NEW;
|
||||
break;
|
||||
}
|
||||
|
||||
$option = $opt;
|
||||
|
||||
if (isset($_FILES["filepmx"])) {
|
||||
$this->setSaveDir(PATH_DOCUMENT . "input");
|
||||
$this->setSourceFromGlobals("filepmx");
|
||||
@@ -452,7 +473,9 @@ abstract class Importer
|
||||
|
||||
$arrayData = array_merge(array("PRJ_UID" => $projectUid), $arrayData);
|
||||
} catch (\Exception $e) {
|
||||
throw (new \Exception("Project already exists"));
|
||||
$msg = str_replace(array(self::IMPORT_OPTION_CREATE_NEW, self::IMPORT_OPTION_OVERWRITE, self::IMPORT_OPTION_DISABLE_AND_CREATE_NEW, self::IMPORT_OPTION_KEEP_WITHOUT_CHANGING_AND_CREATE_NEW), $arrayOptionDefaultValues, $e->getMessage());
|
||||
|
||||
throw (new \Exception($msg));
|
||||
}
|
||||
|
||||
//Return
|
||||
|
||||
@@ -101,6 +101,7 @@ class Project extends Api
|
||||
$version = \ProcessMaker\Util\Common::getLastVersion($outputDir . $exporter->getProjectName() . "-*.pmx") + 1;
|
||||
$outputFilename = $outputDir . sprintf("%s-%s.%s", $exporter->getProjectName(), $version, "pmx");
|
||||
|
||||
$exporter->setMetadata("export_version", $version);
|
||||
$exporter->saveExport($outputFilename);
|
||||
|
||||
$httpStream = new \ProcessMaker\Util\IO\HttpStream();
|
||||
@@ -118,14 +119,14 @@ class Project extends Api
|
||||
*
|
||||
* @status 201
|
||||
*/
|
||||
public function doPostImport($request_data)
|
||||
public function doPostImport(array $request_data, $option = null)
|
||||
{
|
||||
try {
|
||||
$importer = new \ProcessMaker\Importer\XmlImporter();
|
||||
|
||||
$importer->setData("usr_uid", $this->getUserId());
|
||||
|
||||
$arrayData = $importer->importPostFile($request_data, array("projectFile" => "prj_file", "option" => "option"));
|
||||
$arrayData = $importer->importPostFile($request_data, $option, array("projectFile" => "project_file", "option" => "option"));
|
||||
|
||||
$response = $arrayData;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user