From 41516719abb34e8126ed385f7cf955b513478f03 Mon Sep 17 00:00:00 2001 From: Wendy Nestor Date: Tue, 1 Apr 2014 08:52:37 -0400 Subject: [PATCH 1/6] Avance de los features case note, case variables, input document case, output document case --- .../basic_sequence_cases_actions.feature} | 0 .../main_tests_cases_actions.feature} | 123 +++++++- .../negative_tests_cases_actions.feature} | 0 ...basic_sequence_cases_actions_13_17.feature | 85 ------ ...negative_tests_cases_actions_13_17.feature | 0 .../negative_tests_cases_actions_7_12.feature | 0 .../basic_sequence_case_note.feature | 58 +--- .../case_note/main_tests_case_note.feature | 30 ++ .../negative_tests_case_note.feature | 27 ++ .../basic_sequence_case_variables.feature | 75 ++++- .../main_tests_case_variables.feature | 274 ++++++++++++++++++ .../negative_tests_case_variables.feature | 95 ++++++ ...basic_sequence_input_document_case.feature | 12 +- .../main_tests_input_document_case.feature | 42 ++- ...asic_sequence_output_document_case.feature | 13 +- ...main_sequence_output_document_case.feature | 8 +- .../basic_sequence_permissions.feature | 2 +- features/bootstrap/RestContext.php | 44 +-- workflow/public_html/testInput.php | 19 ++ 19 files changed, 707 insertions(+), 200 deletions(-) rename features/backend/application_cases/{case_actions_7-12/basic_sequence_cases_actions_7_12.feature => case_actions/basic_sequence_cases_actions.feature} (100%) rename features/backend/application_cases/{case_actions_7-12/main_tests_cases_actions_7_12.feature => case_actions/main_tests_cases_actions.feature} (65%) rename features/backend/application_cases/{case_actions_13-17/main_tests_cases_actions_13_17.feature => case_actions/negative_tests_cases_actions.feature} (100%) delete mode 100644 features/backend/application_cases/case_actions_13-17/basic_sequence_cases_actions_13_17.feature delete mode 100644 features/backend/application_cases/case_actions_13-17/negative_tests_cases_actions_13_17.feature delete mode 100644 features/backend/application_cases/case_actions_7-12/negative_tests_cases_actions_7_12.feature create mode 100644 workflow/public_html/testInput.php diff --git a/features/backend/application_cases/case_actions_7-12/basic_sequence_cases_actions_7_12.feature b/features/backend/application_cases/case_actions/basic_sequence_cases_actions.feature similarity index 100% rename from features/backend/application_cases/case_actions_7-12/basic_sequence_cases_actions_7_12.feature rename to features/backend/application_cases/case_actions/basic_sequence_cases_actions.feature diff --git a/features/backend/application_cases/case_actions_7-12/main_tests_cases_actions_7_12.feature b/features/backend/application_cases/case_actions/main_tests_cases_actions.feature similarity index 65% rename from features/backend/application_cases/case_actions_7-12/main_tests_cases_actions_7_12.feature rename to features/backend/application_cases/case_actions/main_tests_cases_actions.feature index 932b782ec..8b74321b6 100644 --- a/features/backend/application_cases/case_actions_7-12/main_tests_cases_actions_7_12.feature +++ b/features/backend/application_cases/case_actions/main_tests_cases_actions.feature @@ -105,7 +105,7 @@ Scenario Outline: Reassigns a case to a different user } """ And that I want to update a resource with the key "app_uid_" stored in session array - And I request "case/app_uid/reassign-case" with the key "app_uid" stored in session array as variable "app_uid_" + And I request "cases/app_uid/reassign-case" with the key "app_uid" stored in session array as variable "app_uid_" Then the response status code should be 200 And the content type is "application/json" And the response charset is "UTF-8" @@ -116,14 +116,98 @@ Scenario Outline: Reassigns a case to a different user | Description | app_uid_number | usr_uid_source | usr_uid_target | | Reassign the user adam | 1 | 00000000000000000000000000000001 | 44811996752d567110634a1013636964 | | Reassign the user aaron | 2 | 00000000000000000000000000000001 | 51049032352d56710347233042615067 | - | Reassign the user jeremiah | 3 | 00000000000000000000000000000001 | 86677227852d5671f40ba25017213081 | - | Reassign the user chris | 4 | 00000000000000000000000000000001 | 24166330352d56730cdd525035621101 | - | Reassign the user zachary | 5 | 00000000000000000000000000000001 | 62625000752d5672d6661e6072881167 | | Reassign the user admin | 6 | 24166330352d56730cdd525035621101 | 00000000000000000000000000000001 | | Reassign the user admin | 7 | 44811996752d567110634a1013636964 | 00000000000000000000000000000001 | - | Reassign the user admin | 8 | 51049032352d56710347233042615067 | 00000000000000000000000000000001 | - | Reassign the user admin | 9 | 86677227852d5671f40ba25017213081 | 00000000000000000000000000000001 | - | Reassign the user admin | 10 | 62625000752d5672d6661e6072881167 | 00000000000000000000000000000001 | + + +Scenario Outline: Cancel a case + Given PUT this data: + """ + { + + } + """ + And that I want to update a resource with the key "app_uid_" stored in session array + And I request "cases/app_uid/cancel" with the key "app_uid" stored in session array as variable "app_uid_" + 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 | app_uid_number | + | Cancel of the process "Derivation rules - Parallel" | 3 | + | Cancel of the process "Derivation rules - parallel evaluation" | 5 | + | Cancel of the process "Derivation rules - selection" | 10 | + + +Scenario Outline: Pause a case + Given PUT this data: + """ + { + + } + """ + And that I want to update a resource with the key "app_uid_" stored in session array + And I request "cases/app_uid/pause" with the key "app_uid" stored in session array as variable "app_uid_" + 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 | app_uid_number | + | Pause of the process "Derivation rules - parallel evaluation" | 4 | + | Pause of the process "Derivation rules - Parallel" | 8 | + | Pause of the process "Derivation rules - parallel evaluation" | 9 | + + +Scenario Outline: Unpause a case + Given PUT this data: + """ + { + + } + """ + And that I want to update a resource with the key "app_uid_" stored in session array + And I request "cases/app_uid/unpause" with the key "app_uid" stored in session array as variable "app_uid_" + 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 | app_uid_number | + | Unpause of the process "Derivation rules - parallel evaluation" | 4 | + | Unpause of the process "Derivation rules - Parallel" | 8 | + | Unpause of the process "Derivation rules - parallel evaluation" | 9 | + + +Scenario Outline: Trigger a case + Given PUT this data: + """ + { + + } + """ + And that I want to update a resource with the key "app_uid_" stored in session array + And I request "cases/app_uid/execute-trigger/{tri_uid}" with the key "app_uid" stored in session array as variable "app_uid_" + 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 | app_uid_number | + | | | + | | | + | | | + + Scenario Outline: Route a case to the next task in the process @@ -153,3 +237,28 @@ Scenario Outline: Route a case to the next task in the process | Route next activity "Derivation rules - Parallel" | 8 | | Route next activity "Derivation rules - parallel evaluation" | 9 | | Route next activity "Derivation rules - selection" | 10 | + + + +Scenario Outline: Delete of the cases created in this script. + Given that I want to delete a resource with the key "app_doc_uid" stored in session array as variable "app_doc_uid_" + And I request "cases/551390121533343ee886813057396196/output-document" + And 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: + + | app_doc_uid_number | + | 1 | + | 2 | + | 3 | + | 4 | + | 5 | + | 6 | + | 7 | + | 8 | + | 9 | + | 10 | + diff --git a/features/backend/application_cases/case_actions_13-17/main_tests_cases_actions_13_17.feature b/features/backend/application_cases/case_actions/negative_tests_cases_actions.feature similarity index 100% rename from features/backend/application_cases/case_actions_13-17/main_tests_cases_actions_13_17.feature rename to features/backend/application_cases/case_actions/negative_tests_cases_actions.feature diff --git a/features/backend/application_cases/case_actions_13-17/basic_sequence_cases_actions_13_17.feature b/features/backend/application_cases/case_actions_13-17/basic_sequence_cases_actions_13_17.feature deleted file mode 100644 index 69f573cc4..000000000 --- a/features/backend/application_cases/case_actions_13-17/basic_sequence_cases_actions_13_17.feature +++ /dev/null @@ -1,85 +0,0 @@ -@ProcessMakerMichelangelo @RestAPI -Feature: Cases Actions - the features in this script are (cancelCase, pauseCase, unpaseCase, executeCase, executeCase, executeTrigger and Delete Case) -Requirements: - a workspace with five cases of the process "Test micheangelo" and "Test Users-Step-Properties End Point" - -Background: - Given that I have a valid access_token - - -Scenario: Cancel Case - Given PUT this data: - """ - { - - - - } - """ - And that I want to update a resource with the key "" stored in session array - And I request "case/{uid}/cancel-case" - 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" - - -Scenario: Pause Case - Given PUT this data: - """ - { - - - - } - """ - And that I want to update a resource with the key "" stored in session array - And I request "case/{uid}/pause-case" - 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" - - -Scenario: Unpause Case - Given PUT this data: - """ - { - - - - } - """ - And that I want to update a resource with the key "" stored in session array - And I request "case/{uid}/unpause-case" - 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" - - - -Scenario: Executes a ProcessMaker trigger for a case - Given POST this data: - """ - { - - - - } - """ - And I request "case{uid}/execute-trigger" - 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 "" in session array - - -Scenario: Delete case of workspace - Given that I want to delete a resource with the key "" stored in session array - And I request "case/{uid}/unpause-case" - 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" diff --git a/features/backend/application_cases/case_actions_13-17/negative_tests_cases_actions_13_17.feature b/features/backend/application_cases/case_actions_13-17/negative_tests_cases_actions_13_17.feature deleted file mode 100644 index e69de29bb..000000000 diff --git a/features/backend/application_cases/case_actions_7-12/negative_tests_cases_actions_7_12.feature b/features/backend/application_cases/case_actions_7-12/negative_tests_cases_actions_7_12.feature deleted file mode 100644 index e69de29bb..000000000 diff --git a/features/backend/application_cases/case_note/basic_sequence_case_note.feature b/features/backend/application_cases/case_note/basic_sequence_case_note.feature index 0ac95ecdd..6fe680f48 100644 --- a/features/backend/application_cases/case_note/basic_sequence_case_note.feature +++ b/features/backend/application_cases/case_note/basic_sequence_case_note.feature @@ -1,68 +1,38 @@ @ProcessMakerMichelangelo @RestAPI Feature: Cases Notes Requirements: - a workspace with three cases of the process "Test Users-Step-Properties End Point" + a workspace with one case of the process "Test Case Note" Background: Given that I have a valid access_token Scenario: List of case notes for this case - Given I request "case/{uid}/notes" + 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" + + +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: create a new case note for specified case +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/{uid}/case" + And I request "cases/1185553665335d2e209f723099733152/note" 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 "" in session array - -Scenario: Get a specified case note for this case - Given that I want to get a resource with the key "" stored in session array - Given I request "case/{uid}/note/{uid}" - Then the response status code should be 200 - And the response charset is "UTF-8" - And the " property equals "" - And the "" property equals "" - - - -Scenario: Modify a case note for specified case - Given PUT this data: - """ - { - - - - } - """ - And that I want to update a resource with the key "" stored in session array - And I request "case/{uid}/case/{uid}" - 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" - - -Scenario: Delete a case note for specified case - Given that I want to delete a resource with the key "" stored in session array - And I request "case/{uid}/case/{uid}" - 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" +#case 125 \ No newline at end of file diff --git a/features/backend/application_cases/case_note/main_tests_case_note.feature b/features/backend/application_cases/case_note/main_tests_case_note.feature index e69de29bb..cee9e5aa9 100644 --- a/features/backend/application_cases/case_note/main_tests_case_note.feature +++ b/features/backend/application_cases/case_note/main_tests_case_note.feature @@ -0,0 +1,30 @@ +@ProcessMakerMichelangelo @RestAPI +Feature: Cases Notes +Requirements: + a workspace with one case of the process "Test Case Note" + +Background: + Given that I have a valid access_token + + +Scenario: List of case notes for this case + Given I request "cases/{uid}/notes" + 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": "tercer case note creado desde script", + "send_email": 1 + } + """ + And I request "case/{uid}/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" + \ No newline at end of file diff --git a/features/backend/application_cases/case_note/negative_tests_case_note.feature b/features/backend/application_cases/case_note/negative_tests_case_note.feature index e69de29bb..aa92b5d44 100644 --- a/features/backend/application_cases/case_note/negative_tests_case_note.feature +++ b/features/backend/application_cases/case_note/negative_tests_case_note.feature @@ -0,0 +1,27 @@ +ProcessMakerMichelangelo @RestAPI +Feature: Case Note Negative Tests +Requirements: + a workspace with three cases of the process "Test Users-Step-Properties End Point" + + +Background: + Given that I have a valid access_token + + +Scenario: create a new case note for specified case (Negative Tests) + Given POST this data: + """ + { + "note_content": "prueba de creacion de un case note, sn permisos para poder enviar", + "send_email": 1 + } + """ + And I request "cases/6441974235335ced24785c4035070430/note" + Then the response status code should be 400 + And the response status message should have the following text "You do not have permission to cases notes" + + + + + +#case 124 \ No newline at end of file diff --git a/features/backend/application_cases/case_variables/basic_sequence_case_variables.feature b/features/backend/application_cases/case_variables/basic_sequence_case_variables.feature index 7c651c85e..be2bc010c 100644 --- a/features/backend/application_cases/case_variables/basic_sequence_case_variables.feature +++ b/features/backend/application_cases/case_variables/basic_sequence_case_variables.feature @@ -1,31 +1,88 @@ @ProcessMakerMichelangelo @RestAPI Feature: Cases Variables Requirements: - a workspace with five cases of the process "Test micheangelo" and "Test Users-Step-Properties End Point" + a workspace with five cases of the process "Test Case Variables" and with one case in workspace Background: Given that I have a valid access_token Scenario: Returns the variables can be system variables and/or case variables. - Given I request "case/{uid}/get-variables" + Given I request "cases/95124734553388becc0e332080057699/variables" Then the response status code should be 200 And the response charset is "UTF-8" - And the type is "array" + And the type is "object" Scenario: Sends variables to a case Given PUT this data: """ { - - - + "nameany": "sample-put", + "namealphabetic": "juanput", + "namealphanumeric": "sample123put", + "nameinteger": "1313200000", + "namerealnumber": "4324325000put", + "nameemail": "qa@colosaput.com", + "namelogin": "sampleput", + "valorreal": "32,142,424.00", + "valorinteger": "4,242,424", + "porcentagereal": "424.00 %", + "porcentageinteger": "424 %", + "observaciones": "ningunaput", + "grid": { + "1": { + "sample": "unoput", + "currency1": "133,000.00", + "percentage1": "424.00 %" + } + } } """ - And that I want to update a resource with the key "" stored in session array - And I request "case/{uid}/send-variables" + And I request "cases/95124734553388becc0e332080057699/variable" 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" \ No newline at end of file + And the type is "object" + + +Scenario: Return variables to a case + Given PUT this data: + """ + { + "nameany": "sample", + "namealphabetic": "juan", + "namealphanumeric": "sample123", + "nameinteger": "12345", + "namerealnumber": "12344.56", + "nameemail": "qa@colosa.com", + "namelogin": "sample", + "valorreal": "12,344,556,778.00", + "valorinteger": "1,223,445", + "porcentagereal": "122.44 %", + "porcentageinteger": "123 %", + "observaciones": "Observaciones", + "grid": { + "1": { + "sample": "jose", + "currency1": "12,334,444.00", + "percentage1": "333.00 %" + } + } + } + """ + And I request "cases/95124734553388becc0e332080057699/variable" + 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" + + +Scenario: Returns the variables can be system variables and/or case variables. + Given I request "cases/95124734553388becc0e332080057699/variables" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "object" + + +#guardar el caso 128-->volver a ejecutar otro caso \ No newline at end of file diff --git a/features/backend/application_cases/case_variables/main_tests_case_variables.feature b/features/backend/application_cases/case_variables/main_tests_case_variables.feature index e69de29bb..4fcfa9613 100644 --- a/features/backend/application_cases/case_variables/main_tests_case_variables.feature +++ b/features/backend/application_cases/case_variables/main_tests_case_variables.feature @@ -0,0 +1,274 @@ +@ProcessMakerMichelangelo @RestAPI +Feature: Cases Variables +Requirements: + a workspace with five cases of the process "Test Case Variables" and with one case in workspace + +Background: + Given that I have a valid access_token + +#case 128 +Scenario: Returns the variables can be system variables and/or case variables. + Given I request "cases/95124734553388becc0e332080057699/variables" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "object" + And the "nameany" property equals "sample" + And the "namealphabetic" property equals "juan" + And the "namealphanumeric" property equals "sample123" + And the "nameinteger" property equals "12345" + And the "namerealnumber" property equals "12344.56" + And the "nameemail" property equals "qa@colosa.com" + And the "namelogin" property equals "sample" + And the "valorreal" property equals "12,344,556,778.00" + And the "valorinteger" property equals "1,223,445" + And the "porcentagereal" property equals "122.44 %" + And the "porcentageinteger" property equals "123 %" + And the "observaciones" property equals "Observaciones" + And the "areascolosa" property equals "desarrollo" + And the "areascolosa_label" property equals "Desarrollo" + And the "COUNTRY" property equals "BO" + And the "COUNTRY_label" property equals "Bolivia" + And the "STATE" property equals "H" + And the "STATE_label" property equals "Chuquisaca" + And the "LOCATION" property equals "SRE" + And the "LOCATION_label" property equals "Sucre" + And the "aprobado" property equals "1" + And the "aprobadohint" property equals "0" + And the "checkbox1" property equals "On" + And the "checkbox2" property equals "Off" + And the "checkbox3" property equals "Off" + And the "radiogroup1" property equals "primero" + And the "radiogroup1_label" property equals "Primero" + And the "radiogroup2" property equals "quinto" + And the "radiogroup2_label" property equals "Quinto" + And the "date1" property equals "2013-11-07" + And the "date2" property equals "2013-11-08" + And the "date3" property equals "2014-03-03" + And the "date4" property equals "2014-03-01" + And the "suggest2" property equals "51049032352d56710347233042615067" + And the "suggest2_label" property equals "aaron" + + + + And the "sample" property in row 1 of property "grid" equals "jose" + And the "currency1" property equals "12,334,444.00" + And the "percentage1" property equals "333.00 %" + And the "suggest1_label" property equals "gavin" + And the "suggest1" property equals "33140476452d5671b0abda5073786635" + And the "textarea1" property equals "ninguno" + And the "dropdown1" property equals "dos" + And the "dropdown1_label" property equals "dos" + And the "yesno1" property equals "1" + And the "checkbox1" property equals "On" + And the "date1" property equals "2014-03-13" + And the "link1" property equals "http://www.google.com/" + And the "link1_label" property equals "link1" + And the "sample" property equals "maria" + And the "currency1" property equals "132,424.00" + And the "percentage1" property equals "344.00 %" + And the "suggest1_label" property equals "emily" + And the "suggest1" property equals "34289569752d5673d310e82094574281" + And the "textarea1" property equals "sample" + And the "dropdown1" property equals "uno" + And the "dropdown1_label" property equals "uno" + And the "yesno1" property equals "0" + And the "checkbox1" property equals "Off" + And the "date1" property equals "2014-03-29" + And the "link1" property equals "http://www.google.com/" + And the "link1_label" property equals "link1" + + +Scenario: Sends variables to a case + Given PUT this data: + """ + { + "nameany": "sample-put", + "namealphabetic": "juanput", + "namealphanumeric": "sample123567", + "nameinteger": "1313200000", + "namerealnumber": "4324325000567.12", + "nameemail": "qa@colosaput.com", + "namelogin": "sampleput", + "valorreal": "32,142,424.00", + "porcentagereal": "424.00 %", + "observaciones": "ningunaput", + "grid": { + "1": { + "sample": "unoput", + "currency1": "133,000.00", + "percentage1": "424.00 %" + } + } + } + """ + And I request "cases/95124734553388becc0e332080057699/variable" + 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" + + +Scenario: Returns the variables can be system variables and/or case variables. + Given I request "cases/95124734553388becc0e332080057699/variables" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "object" + And the "nameany" property equals "sample-put" + And the "namealphabetic" property equals "juan-put" + And the "namealphanumeric" property equals "sample123567" + And the "nameinteger" property equals "1313200000" + And the "namerealnumber" property equals "4324325000567.12" + And the "nameemail" property equals "qa@colosaput.com" + And the "namelogin" property equals "sampleput" + And the "valorreal" property equals "32,142,424.00" + And the "valorinteger" property equals "1,223,445" + And the "porcentagereal" property equals "424.00 %" + And the "porcentageinteger" property equals "123 %" + And the "observaciones" property equals "ningunaput" + And the "areascolosa" property equals "desarrollo" + And the "areascolosa_label" property equals "Desarrollo" + And the "COUNTRY" property equals "BO" + And the "COUNTRY_label" property equals "Bolivia" + And the "STATE" property equals "H" + And the "STATE_label" property equals "Chuquisaca" + And the "LOCATION" property equals "SRE" + And the "LOCATION_label" property equals "Sucre" + And the "aprobado" property equals "1" + And the "aprobadohint" property equals "0" + And the "checkbox1" property equals "On" + And the "checkbox2" property equals "Off" + And the "checkbox3" property equals "Off" + And the "radiogroup1" property equals "primero" + And the "radiogroup1_label" property equals "Primero" + And the "radiogroup2" property equals "quinto" + And the "radiogroup2_label" property equals "Quinto" + And the "date1" property equals "2013-11-07" + And the "date2" property equals "2013-11-08" + And the "date3" property equals "2014-03-03" + And the "date4" property equals "2014-03-01" + And the "suggest2" property equals "51049032352d56710347233042615067" + And the "suggest2_label" property equals "aaron" + And the "sample" property equals "unoput" + And the "currency1" property equals "133,000.00" + And the "percentage1" property equals "424.00 %" + And the "suggest1_label" property equals "gavin" + And the "suggest1" property equals "33140476452d5671b0abda5073786635" + And the "textarea1" property equals "ninguno" + And the "dropdown1" property equals "dos" + And the "dropdown1_label" property equals "dos" + And the "yesno1" property equals "1" + And the "checkbox1" property equals "On" + And the "date1" property equals "2014-03-13" + And the "link1" property equals "http://www.google.com/" + And the "link1_label" property equals "link1" + And the "sample" property equals "maria" + And the "currency1" property equals "132,424.00" + And the "percentage1" property equals "344.00 %" + And the "suggest1_label" property equals "emily" + And the "suggest1" property equals "34289569752d5673d310e82094574281" + And the "textarea1" property equals "sample" + And the "dropdown1" property equals "uno" + And the "dropdown1_label" property equals "uno" + And the "yesno1" property equals "0" + And the "checkbox1" property equals "Off" + And the "date1" property equals "2014-03-29" + And the "link1" property equals "http://www.google.com/" + And the "link1_label" property equals "link1" + + +Scenario: Return variables to a case + Given PUT this data: + """ + { + "nameany": "sample", + "namealphabetic": "juan", + "namealphanumeric": "sample123", + "nameinteger": "12345", + "namerealnumber": "12344.56", + "nameemail": "qa@colosa.com", + "namelogin": "sample", + "valorreal": "12,344,556,778.00", + "porcentagereal": "122.44 %", + "observaciones": "Observaciones", + "grid": { + "1": { + "sample": "jose", + "currency1": "12,334,444.00", + "percentage1": "333.00 %" + } + } + } + """ + And I request "cases/95124734553388becc0e332080057699/variable" + 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" + + +Scenario: Returns the variables can be system variables and/or case variables. + Given I request "cases/95124734553388becc0e332080057699/variables" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "object" + And the "nameany" property equals "sample" + And the "namealphabetic" property equals "juan" + And the "namealphanumeric" property equals "sample123" + And the "nameinteger" property equals "12345" + And the "namerealnumber" property equals "12344.56" + And the "nameemail" property equals "qa@colosa.com" + And the "namelogin" property equals "sample" + And the "valorreal" property equals "12,344,556,778.00" + And the "valorinteger" property equals "1,223,445" + And the "porcentagereal" property equals "122.44 %" + And the "porcentageinteger" property equals "123 %" + And the "observaciones" property equals "Observaciones" + And the "areascolosa" property equals "desarrollo" + And the "areascolosa_label" property equals "Desarrollo" + And the "COUNTRY" property equals "BO" + And the "COUNTRY_label" property equals "Bolivia" + And the "STATE" property equals "H" + And the "STATE_label" property equals "Chuquisaca" + And the "LOCATION" property equals "SRE" + And the "LOCATION_label" property equals "Sucre" + And the "aprobado" property equals "1" + And the "aprobadohint" property equals "0" + And the "checkbox1" property equals "On" + And the "checkbox2" property equals "Off" + And the "checkbox3" property equals "Off" + And the "radiogroup1" property equals "primero" + And the "radiogroup1_label" property equals "Primero" + And the "radiogroup2" property equals "quinto" + And the "radiogroup2_label" property equals "Quinto" + And the "date1" property equals "2013-11-07" + And the "date2" property equals "2013-11-08" + And the "date3" property equals "2014-03-03" + And the "date4" property equals "2014-03-01" + And the "suggest2" property equals "51049032352d56710347233042615067" + And the "suggest2_label" property equals "aaron" + And the "sample" property equals "jose" + And the "currency1" property equals "12,334,444.00" + And the "percentage1" property equals "333.00 %" + And the "suggest1_label" property equals "gavin" + And the "suggest1" property equals "33140476452d5671b0abda5073786635" + And the "textarea1" property equals "ninguno" + And the "dropdown1" property equals "dos" + And the "dropdown1_label" property equals "dos" + And the "yesno1" property equals "1" + And the "checkbox1" property equals "On" + And the "date1" property equals "2014-03-13" + And the "link1" property equals "http://www.google.com/" + And the "link1_label" property equals "link1" + And the "sample" property equals "maria" + And the "currency1" property equals "132,424.00" + And the "percentage1" property equals "344.00 %" + And the "suggest1_label" property equals "emily" + And the "suggest1" property equals "34289569752d5673d310e82094574281" + And the "textarea1" property equals "sample" + And the "dropdown1" property equals "uno" + And the "dropdown1_label" property equals "uno" + And the "yesno1" property equals "0" + And the "checkbox1" property equals "Off" + And the "date1" property equals "2014-03-29" + And the "link1" property equals "http://www.google.com/" + And the "link1_label" property equals "link1" \ No newline at end of file diff --git a/features/backend/application_cases/case_variables/negative_tests_case_variables.feature b/features/backend/application_cases/case_variables/negative_tests_case_variables.feature index e69de29bb..3dfdc81ca 100644 --- a/features/backend/application_cases/case_variables/negative_tests_case_variables.feature +++ b/features/backend/application_cases/case_variables/negative_tests_case_variables.feature @@ -0,0 +1,95 @@ +@ProcessMakerMichelangelo @RestAPI +Feature: Cases Variables Negative Tests + +Background: + Given that I have a valid access_token + + +Scenario: Returns the variables can be system variables and/or case variables (negative tests). + Given I request "cases/95124734553388becc0e332080057699/variable" + Then the response status code should be 400 + And the response status message should have the following text "Not Found" + + +Scenario: Sends variables to a case (negative tests) + Given PUT this data: + """ + { + "nameany": "sample-put", + "namealphabetic": "juanput", + "namealphanumeric": "sample123put", + "nameinteger": "1313200000", + "namerealnumber": "4324325000put", + "nameemail": "qa@colosaput.com", + "namelogin": "sampleput", + "valorreal": "32,142,424.00", + "valorinteger": "4,242,424", + "porcentagereal": "424.00 %", + "porcentageinteger": "424 %", + "observaciones": "ningunaput", + "grid": { + "1": { + "sample": "unoput", + "currency1": "133,000.00", + "percentage1": "424.00 %", + } + """ + And I request "cases/95124734553388becc0e332080057699/variable" + 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" + + + + 18130826553359171798e40060879912 + + "nameany": "wendy344%", + "namealphabetic": "nestor123", + "namealphanumeric": "rad1233$%", + "nameinteger": "342432,7", + "namerealnumber": "35353", + "nameemail": "wendycolosacom", + "namelogin": "sample", + "valorreal": "242343253,253.00", + "valorinteger": "346436363", + "porcentagereal": "64600", + "porcentageinteger": "464", + "observaciones": "ninguna", + "areascolosa": "sample", + "areascolosa_label": "sample", + "COUNTRY": "BOA", + "COUNTRY_label": "Bolivia", + "STATE": "aH", + "STATE_label": "Chuquisaca", + "LOCATION": "SRE", + "LOCATION_label": "Sucre", + "aprobado": "20", + "aprobadohint": "0", + "checkbox1": "sample", + "checkbox2": "oki", + "checkbox3": "Off", + "radiogroup1": "hola", + "radiogroup1_label": "Primero", + "date1": "hola", + "date2": "2013-11-08", + "date3": "2014-03-09", + "date4": "2014-03-02", + "suggest2": "51049032352d56710347233042615067", + "suggest2_label": "sample", + "grid": { + "1": { + "sample": "hugo", + "currency1": "2,424,234.00", + "percentage1": "354.00 %", + "suggest1_label": "dorothy", + "suggest1": "81205219852d56719a97fc3086456770", + "textarea1": "ninguno", + "dropdown1": "uno", + "yesno1": "0", + "checkbox1": "On", + "date1": "2014-03-20", + "link1": "http://www.google.com/", + "link1_label": "link1", + "file1": "Tuesday.docx", + "dropdown1_label": "uno" \ No newline at end of file diff --git a/features/backend/application_cases/input_documents_case/basic_sequence_input_document_case.feature b/features/backend/application_cases/input_documents_case/basic_sequence_input_document_case.feature index b9cb57ee8..9eff00135 100644 --- a/features/backend/application_cases/input_documents_case/basic_sequence_input_document_case.feature +++ b/features/backend/application_cases/input_documents_case/basic_sequence_input_document_case.feature @@ -9,7 +9,7 @@ Background: Scenario: Returns a list of the uploaded documents for a given case - Given I request "cases/3980158475331a1a0288fd3009853776/input-documents" + Given I request "cases/64654381053382b8bb4c415067063003/input-documents" Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" @@ -17,19 +17,19 @@ Scenario: Returns a list of the uploaded documents for a given case Scenario: Returns an uploaded documents for a given case - Given I request "cases/3980158475331a1a0288fd3009853776/input-document/6075490825331a1c5eebff9015468244" + Given I request "cases/64654381053382b8bb4c415067063003/input-document/6075490825331a1c5eebff9015468244" Then the response status code should be 200 And the response charset is "UTF-8" And the type is "object" Scenario: Post metadata and then upload documents for a given case - Given POST upload an input document "/home/wendy/uploadfiles/test1.html" to "cases/3980158475331a1a0288fd3009853776/input-document" + Given POST upload an input document "/home/wendy/uploadfiles/test1.html" to "cases/64654381053382b8bb4c415067063003/input-document" """ { - "inp_doc_uid": "inp_doc_uid", - "tas_uid": "tas_uid", + "inp_doc_uid": "68671480353319e5e1dee74089764900", + "tas_uid": "19582733053319e304cfa76025663570", "app_doc_comment": "app_doc_comment" @@ -44,7 +44,7 @@ Scenario: Post metadata and then upload documents for a given case Scenario: Delete an uploaded or generated document from a case. Given that I want to delete a resource with the key "" stored in session array - And I request "cases/3980158475331a1a0288fd3009853776/input-document/{app_doc_uid}" + And I request "cases/64654381053382b8bb4c415067063003/input-document/{app_doc_uid}" Then the response status code should be 200 And the content type is "application/json" And the response charset is "UTF-8" diff --git a/features/backend/application_cases/input_documents_case/main_tests_input_document_case.feature b/features/backend/application_cases/input_documents_case/main_tests_input_document_case.feature index a8759f067..c9db84a3f 100644 --- a/features/backend/application_cases/input_documents_case/main_tests_input_document_case.feature +++ b/features/backend/application_cases/input_documents_case/main_tests_input_document_case.feature @@ -9,7 +9,7 @@ Background: Scenario: Returns a list of the uploaded documents for a given case - Given I request "cases/3980158475331a1a0288fd3009853776/input-documents" + Given I request "cases/64654381053382b8bb4c415067063003/input-documents" Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" @@ -17,7 +17,7 @@ Scenario: Returns a list of the uploaded documents for a given case Scenario Outline: Returns an uploaded documents for a given case - Given I request "cases/3980158475331a1a0288fd3009853776/input-document/" + Given I request "cases/64654381053382b8bb4c415067063003/input-document/" Then the response status code should be 200 And the response charset is "UTF-8" And the type is "object" @@ -38,4 +38,40 @@ Scenario Outline: Returns an uploaded documents for a given case | Get Input "Screenshot Case Archive.docx" | 3770386635331a1f49c78e8070071944 | 3770386635331a1f49c78e8070071944 | Screenshot Case Archive.docx | 68671480353319e5e1dee74089764900 | 1 | 2014-03-25 11:34:12 | , Administrator (admin) | INPUT | 2 | cases/cases_ShowDocument?a=3770386635331a1f49c78e8070071944&v=1 | | Get Input "alert_message.html" | 6382509235331a235b27a82003894796 | 6382509235331a235b27a82003894796 | alert_message.htm | 68588088053319e68d88f67081331478 | 1 | 2014-03-25 11:35:17 | , Administrator (admin) | INPUT | 4 | cases/cases_ShowDocument?a=6382509235331a235b27a82003894796&v=1 | | Get Input "actionsByEmail-2.5.0.28.tar" | 3548449385331a24a34d273018695729 | 3548449385331a24a34d273018695729 | actionsByEmail-2.5.0.28.tar | 68588088053319e68d88f67081331478 | 1 | 2014-03-25 11:35:38 | , Administrator (admin) | INPUT | 5 | cases/cases_ShowDocument?a=3548449385331a24a34d273018695729&v=1 | - | Get Input "Step_ordenamiento (5).pm" | 3814366275331a21b80d603018480738 | 3814366275331a21b80d603018480738 | Step_ordenamiento (5).pm | 68588088053319e68d88f67081331478 | 2 | 2014-03-25 11:36:11 | , Administrator (admin) | INPUT | 6 | cases/cases_ShowDocument?a=3814366275331a21b80d603018480738&v=2 | \ No newline at end of file + | Get Input "Step_ordenamiento (5).pm" | 3814366275331a21b80d603018480738 | 3814366275331a21b80d603018480738 | Step_ordenamiento (5).pm | 68588088053319e68d88f67081331478 | 2 | 2014-03-25 11:36:11 | , Administrator (admin) | INPUT | 6 | cases/cases_ShowDocument?a=3814366275331a21b80d603018480738&v=2 | + + + Scenario Outline: Post metadata and then upload documents for a given case + Given POST upload an input document "" to "cases//input-document" + """ + { + + "inp_doc_uid": "", + "tas_uid": "", + "app_doc_comment": "" + + + } + """ + 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 "app_doc_uid" in session array as variable "app_doc_uid_" + + Examples: + | app_doc_uid_number | document_file | case_uid | inp_doc_uid | tas_uid | app_doc_comment | + | 1 | /home/wendy/uploadfiles/test1.html | 64654381053382b8bb4c415067063003 | 68671480353319e5e1dee74089764900 | 19582733053319e304cfa76025663570 | comment 1 | + + +Scenario Outline: Delete an uploaded or generated document from a case. + Given that I want to delete a resource with the key "app_doc_uid_" stored in session array + And I request "cases/64654381053382b8bb4c415067063003/input-document/" + 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: + | app_doc_uid_number | + | 1 | \ No newline at end of file diff --git a/features/backend/application_cases/output_document_case/basic_sequence_output_document_case.feature b/features/backend/application_cases/output_document_case/basic_sequence_output_document_case.feature index aacca954c..74db0a059 100644 --- a/features/backend/application_cases/output_document_case/basic_sequence_output_document_case.feature +++ b/features/backend/application_cases/output_document_case/basic_sequence_output_document_case.feature @@ -9,7 +9,7 @@ Background: Scenario: Returns a list of the generated documents for a given cases - Given I request "cases/24438110553330068247694030259829/output-documents" + Given I request "cases/33125846153383cecdf64f1079330191/output-documents" Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" @@ -17,7 +17,7 @@ Scenario: Returns a list of the generated documents for a given cases Scenario: Returns an generated document for a given case - Given I request "cases/24438110553330068247694030259829/output-document/3000248055333006ab56a01005891659" + Given I request "cases/33125846153383cecdf64f1079330191/output-document/3000248055333006ab56a01005891659" Then the response status code should be 200 And the response charset is "UTF-8" And the type is "Object" @@ -30,17 +30,18 @@ Scenario: Generate or regenerates an output documents for a given case "out_doc_uid": "2087233055331ef4127d238097105696" } """ - And I request "case/24438110553330068247694030259829/output-document" - Then the response status code should be 201 + And I request "cases/33125846153383cecdf64f1079330191/output-document" + 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 store "app_doc_uid" in session array as variable "app_doc_uid_0" Scenario: Delete an uploaded or generated document from a case. - Given that I want to delete a resource with the key "" stored in session array - And I request "output-document/{uid}" + And that I want to delete a resource with the key "app_doc_uid_0" stored in session array + Gie I request "output-document" Then the response status code should be 200 And the content type is "application/json" And the response charset is "UTF-8" diff --git a/features/backend/application_cases/output_document_case/main_sequence_output_document_case.feature b/features/backend/application_cases/output_document_case/main_sequence_output_document_case.feature index f75a6bf64..71be22783 100644 --- a/features/backend/application_cases/output_document_case/main_sequence_output_document_case.feature +++ b/features/backend/application_cases/output_document_case/main_sequence_output_document_case.feature @@ -15,7 +15,7 @@ Scenario Outline: Generate or regenerates an output documents for a given case "out_doc_uid": "" } """ - And I request "cases/551390121533343ee886813057396196/output-document" + And I request "cases/33125846153383cecdf64f1079330191/output-document" Then the response status code should be 200 And the response charset is "UTF-8" And the content type is "application/json" @@ -33,7 +33,7 @@ Scenario Outline: Generate or regenerates an output documents for a given case Scenario: Returns a list of the generated documents for a given cases - Given I request "cases/551390121533343ee886813057396196/output-documents" + Given I request "cases/33125846153383cecdf64f1079330191/output-documents" Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" @@ -47,7 +47,7 @@ Scenario: Returns a list of the generated documents for a given cases Scenario Outline: Returns an generated document for a given case - Given I request "cases/551390121533343ee886813057396196/output-document/app_doc_uid" with the key "app_doc_uid" stored in session array as variable "app_doc_uid_" + Given I request "cases/33125846153383cecdf64f1079330191/output-document/app_doc_uid" with the key "app_doc_uid" stored in session array as variable "app_doc_uid_" Then the response status code should be 200 And the response charset is "UTF-8" And the type is "Object" @@ -76,7 +76,7 @@ Scenario Outline: Returns an generated document for a given case Scenario Outline: Delete an uploaded or generated document from a case. Given that I want to delete a resource with the key "app_doc_uid" stored in session array as variable "app_doc_uid_" - And I request "cases/551390121533343ee886813057396196/output-document" + And I request "cases/33125846153383cecdf64f1079330191/output-document" And the response status code should be 200 And the content type is "application/json" And the response charset is "UTF-8" diff --git a/features/backend/projects/process_permissions/basic_sequence_permissions.feature b/features/backend/projects/process_permissions/basic_sequence_permissions.feature index 448910dcf..9d772d2ac 100644 --- a/features/backend/projects/process_permissions/basic_sequence_permissions.feature +++ b/features/backend/projects/process_permissions/basic_sequence_permissions.feature @@ -1,4 +1,4 @@ -@ProcessMakerMichelangelo @RestAPI +miche@ProcessMakerMichelangelo @RestAPI Feature: ProcessPermissions Resources @1: TEST FOR GET PROCESS PERMISSIONS /---------------------------------------------------------------------- diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index bec47be6e..83b64d848 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -1,4 +1,4 @@ -FA_headers['Authorization'] = 'Bearer ' . $this->access_token; } + + if($urlType=="absolute"){ $this->_requestUrl = $pageUrl; @@ -367,7 +369,7 @@ class RestContext extends BehatContext case 'POST': $postFields = is_object($this->_restObject) ? (array)$this->_restObject - : $this->_restObject; + : $this->_restObject; $this->_request = $this->_client ->post($url, $this->_headers, (empty($this->_requestBody) ? $postFields : @@ -1481,43 +1483,15 @@ class RestContext extends BehatContext */ public function postUploadAnInputDocumentTo($file, $url, PyStringNode $string) { - $baseUrl = $this->getParameter('base_url'); - $url = $baseUrl.$url; - $accesstoken = $this->getParameter('access_token'); - $headr = array(); - $headr[] = 'Authorization: Bearer '.$accesstoken; - $postFields = json_decode($string); $postFields->form ='@'.$file; - //print_r($postFields); - - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL,$url); - curl_setopt($ch, CURLOPT_HTTPHEADER,$headr); - curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields); - curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - $postResult = curl_exec($ch); - print_r($postResult); - curl_close($ch); - - //Save result as usual - $this->_type = 'json'; - //$this->_response = json_decode($postResult); - $this->_data = json_decode($postResult); - - - - // $postResult = (array)json_decode($postResult); - - - - + + $this->_restObjectMethod = 'post'; + $this->_restObject = $postFields; + $this->iRequest($url); + } - - - } diff --git a/workflow/public_html/testInput.php b/workflow/public_html/testInput.php new file mode 100644 index 000000000..43e8cea97 --- /dev/null +++ b/workflow/public_html/testInput.php @@ -0,0 +1,19 @@ +'@'.$file, 'inp_doc_uid'=>$inp_doc_uid, 'tas_uid' =>$tas_uid, 'app_doc_comment' =>$app_doc_comment); +curl_setopt($ch, CURLOPT_URL,$url); +curl_setopt($ch, CURLOPT_HTTPHEADER,$headr); +curl_setopt($ch, CURLOPT_POSTFIELDS, $a); +curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); +$postResult = curl_exec($ch); +curl_close($ch); +print_r($postResult); \ No newline at end of file From e2250cc6b04276228c028bae3ad2c9513712a70a Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Tue, 1 Apr 2014 11:46:06 -0400 Subject: [PATCH 2/6] Se agrega funcion para upgrade de Files Manager --- workflow/engine/bin/tasks/cliUpgrade.php | 88 +++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/workflow/engine/bin/tasks/cliUpgrade.php b/workflow/engine/bin/tasks/cliUpgrade.php index 1f85cd1d2..1ad0a35c1 100755 --- a/workflow/engine/bin/tasks/cliUpgrade.php +++ b/workflow/engine/bin/tasks/cliUpgrade.php @@ -39,7 +39,6 @@ EOT CLI::taskOpt("buildACV", "If the option is enabled, performs the Build Cache View.", "ACV", "buildACV"); CLI::taskRun("run_upgrade"); - /** * A version of rm_dir which does not exits on error. * @@ -150,6 +149,7 @@ function run_upgrade($command, $args) G::browserCacheFilesSetUid(); + upgradeFilesManager($command); //Status if ($errors) { CLI::logging("Upgrade finished but there were errors upgrading workspaces.\n"); @@ -162,3 +162,89 @@ function run_upgrade($command, $args) $flag = G::isPMUnderUpdating(0); } +/** + * Function upgradeFilesManager + * access public + */ + +function upgradeFilesManager($command = "") { + CLI::logging("> Updating Files Manager...\n\n"); + $workspaces = get_workspaces_from_args($command); + foreach ($workspaces as $workspace) { + $name = $workspace->name; + require_once( PATH_DB . $name . '/db.php' ); + require_once( PATH_THIRDPARTY . 'propel/Propel.php'); + PROPEL::Init ( PATH_METHODS.'dbConnections/rootDbConnections.php' ); + $con = Propel::getConnection("root"); + $stmt = $con->createStatement(); + $sDirectory = PATH_DATA . "sites/" . $name . "/" . "mailTemplates/"; + $sDirectoryPublic = PATH_DATA . "sites/" . $name . "/" . "public/"; + if ($dh = opendir($sDirectory)) { + $files = Array(); + while ($file = readdir($dh)) { + if ($file != "." && $file != ".." && $file[0] != '.') { + if (is_dir($sDirectory . "/" . $file)) { + $inner_files = listFiles($sDirectory . $file); + if (is_array($inner_files)) $files = array_merge($files, $inner_files); + } else { + array_push($files, $sDirectory . $file); + } + } + } + closedir($dh); + } + if ($dh = opendir($sDirectoryPublic)) { + while ($file = readdir($dh)) { + if ($file != "." && $file != ".." && $file[0] != '.') { + if (is_dir($sDirectoryPublic . "/" . $file)) { + $inner_files = listFiles($sDirectoryPublic . $file); + if (is_array($inner_files)) $files = array_merge($files, $inner_files); + } else { + array_push($files, $sDirectoryPublic . $file); + } + } + } + closedir($dh); + } + foreach ($files as $aFile) { + if (strpos($aFile, $sDirectory) !== false){ + $processUid = current(explode("/", str_replace($sDirectory,'',$aFile))); + } else { + $processUid = current(explode("/", str_replace($sDirectoryPublic,'',$aFile))); + } + $sql = "SELECT PROCESS_FILES.PRF_PATH FROM PROCESS_FILES WHERE PROCESS_FILES.PRF_PATH='" . $aFile ."'"; + $appRows = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC); + $fileUid = ''; + foreach ($appRows as $row) { + $fileUid = $row["PRF_PATH"]; + } + if ($fileUid !== $aFile) { + $sPkProcessFiles = G::generateUniqueID(); + $sDate = date('Y-m-d H:i:s'); + $sql = "INSERT INTO PROCESS_FILES (PRF_UID, PRO_UID, USR_UID, PRF_UPDATE_USR_UID, + PRF_PATH, PRF_TYPE, PRF_EDITABLE, PRF_CREATE_DATE, PRF_UPDATE_DATE) + VALUES ('".$sPkProcessFiles."', '".$processUid."', '00000000000000000000000000000001', '', + '".$aFile."', 'file', 'true', '".$sDate."', NULL)"; + $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC); + } + } + } +} + +function listFiles($dir) { + if($dh = opendir($dir)) { + $files = Array(); + while ($file = readdir($dh)) { + if ($file != "." && $file != ".." && $file[0] != '.') { + if (is_dir($dir . "/" . $file)) { + $inner_files = listFiles($dir . "/" . $file); + if (is_array($inner_files)) $files = array_merge($files, $inner_files); + } else { + array_push($files, $dir . "/" . $file); + } + } + } + closedir($dh); + return $files; + } +} \ No newline at end of file From a7b961671562bb326493563a26d28548cdd4557a Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Tue, 1 Apr 2014 14:58:55 -0400 Subject: [PATCH 3/6] Se agrega endpoint en ASSIGNESS y ADHOC ASSIGNESS para obtener todos los usuarios asignados, incluyendo los de los grupos --- workflow/engine/src/BusinessModel/Task.php | 251 +++++++++++++++++- .../Project/Activity/Assignee.php | 52 ++++ 2 files changed, 302 insertions(+), 1 deletion(-) diff --git a/workflow/engine/src/BusinessModel/Task.php b/workflow/engine/src/BusinessModel/Task.php index f50694b72..8ef75c134 100644 --- a/workflow/engine/src/BusinessModel/Task.php +++ b/workflow/engine/src/BusinessModel/Task.php @@ -1937,5 +1937,254 @@ class Task unset($array[$variable]); } } -} + /** + * Return a list of assignees of an activity + * + * @param string $sProcessUID {@min 32} {@max 32} + * @param string $sTaskUID {@min 32} {@max 32} + * @param string $filter + * @param int $start + * @param int $limit + * @param string $type + * + * return array + * + * @access public + */ + public function getTaskAssigneesAll($sProcessUID, $sTaskUID, $filter, $start, $limit, $type) + { + try { + $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); + if (is_null($oProcess)) { + throw (new \Exception( 'This id for `prj_uid`: '. $sProcessUID .' does not correspond to a registered process')); + } + $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); + if (is_null($oActivity)) { + throw (new \Exception( 'This id for `act_uid`: '. $sTaskUID .' does not correspond to a registered activity')); + } + $aUsers = array(); + $oTasks = new \Tasks(); + $aAux = $oTasks->getGroupsOfTask($sTaskUID, 1); + $aGroupUids = array(); + foreach ($aAux as $aGroup) { + $aGroupUids[] = $aGroup['GRP_UID']; + } + foreach ($aGroupUids as $results) { + $oCriteria = new \Criteria('workflow'); + $oCriteria->addSelectColumn('USR_UID'); + $oCriteria->add(\GroupUserPeer::GRP_UID, $results); + $oGroupDataset = \GroupUserPeer::doSelectRS($oCriteria); + $oGroupDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + while ($oGroupDataset->next()) { + $aGroupRow = $oGroupDataset->getRow(); + $oGroupCriteria = new \Criteria('workflow'); + $oGroupCriteria->addSelectColumn(\UsersPeer::USR_UID); + $oGroupCriteria->addSelectColumn(\UsersPeer::USR_FIRSTNAME); + $oGroupCriteria->addSelectColumn(\UsersPeer::USR_LASTNAME); + $oGroupCriteria->addSelectColumn(\UsersPeer::USR_USERNAME); + if ($filter != '') { + $oGroupCriteria->add($oGroupCriteria->getNewCriterion(\UsersPeer::USR_USERNAME, "%$filter%", + \Criteria::LIKE)->addOr($oGroupCriteria->getNewCriterion(\UsersPeer::USR_FIRSTNAME, + "%$filter%", \Criteria::LIKE))->addOr($oGroupCriteria->getNewCriterion(\UsersPeer::USR_LASTNAME, + "%$filter%", \Criteria::LIKE))); + } + $oGroupCriteria->add(\UsersPeer::USR_UID, $aGroupRow["USR_UID"]); + $oUserDataset = \UsersPeer::doSelectRS($oGroupCriteria); + $oUserDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oUserDataset->next(); + while ($aUserRow = $oUserDataset->getRow()) { + $aUsers[] = array('aas_uid' => $aUserRow['USR_UID'], + 'aas_name' => $aUserRow['USR_FIRSTNAME'], + 'aas_lastname' => $aUserRow['USR_LASTNAME'], + 'aas_username' => $aUserRow['USR_USERNAME'], + 'aas_type' => "user" ); + $oUserDataset->next(); + } + } + } + $oCriteria = new \Criteria('workflow'); + $oCriteria->addSelectColumn(\UsersPeer::USR_UID); + $oCriteria->addSelectColumn(\UsersPeer::USR_FIRSTNAME); + $oCriteria->addSelectColumn(\UsersPeer::USR_LASTNAME); + $oCriteria->addSelectColumn(\UsersPeer::USR_USERNAME); + if ($filter != '') { + $oCriteria->add($oCriteria->getNewCriterion(\UsersPeer::USR_USERNAME, "%$filter%", \Criteria::LIKE) + ->addOr($oCriteria->getNewCriterion(\UsersPeer::USR_FIRSTNAME, "%$filter%", \Criteria::LIKE)) + ->addOr($oCriteria->getNewCriterion(\UsersPeer::USR_LASTNAME, "%$filter%", \Criteria::LIKE ))); + } + $oCriteria->addJoin(\TaskUserPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN); + $oCriteria->add(\TaskUserPeer::TAS_UID, $sTaskUID); + $oCriteria->add(\TaskUserPeer::TU_TYPE, 1); + $oCriteria->add(\TaskUserPeer::TU_RELATION, 1); + $oDataset = \TaskUserPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + if ($type == '' || $type == 'user') { + $aUsers[] = array('aas_uid' => $aRow['USR_UID'], + 'aas_name' => $aRow['USR_FIRSTNAME'], + 'aas_lastname' => $aRow['USR_LASTNAME'], + 'aas_username' => $aRow['USR_USERNAME'], + 'aas_type' => "user" ); + } + $oDataset->next(); + } + $aUsersGroups = array(); + $exclude = array(""); + for ($i = 0; $i<=count($aUsers)-1; $i++) { + if (!in_array(trim($aUsers[$i]["aas_uid"]) ,$exclude)) { + $aUsersGroups[] = $aUsers[$i]; + $exclude[] = trim($aUsers[$i]["aas_uid"]); + } + } + if ($start) { + if ($start < 0) { + throw (new \Exception( 'Invalid value specified for `start`.')); + } + } else { + $start = 0; + } + if (isset($limit)) { + if ($limit < 0) { + throw (new \Exception( 'Invalid value specified for `limit`.')); + } else { + if ($limit == 0) { + return array(); + } + } + } else { + $limit = 1000; + } + $aUsersGroups = $this->arrayPagination($aUsersGroups, $start, $limit); + return $aUsersGroups; + } catch (Exception $e) { + throw $e; + } + } + + /** + * Return a list of adhoc assignees of an activity + * + * @param string $sProcessUID {@min 32} {@max 32} + * @param string $sTaskUID {@min 32} {@max 32} + * @param string $filter + * @param int $start + * @param int $limit + * @param string $type + * + * return array + * + * @access public + */ + public function getTaskAdhocAssigneesAll($sProcessUID, $sTaskUID, $filter, $start, $limit, $type) + { + try { + $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); + if (is_null($oProcess)) { + throw (new \Exception( 'This id for `prj_uid`: '. $sProcessUID .' does not correspond to a registered process')); + } + $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); + if (is_null($oActivity)) { + throw (new \Exception( 'This id for `act_uid`: '. $sTaskUID .' does not correspond to a registered activity')); + } + $aUsers = array(); + $oTasks = new \Tasks(); + $aAux = $oTasks->getGroupsOfTask($sTaskUID, 2); + $aGroupUids = array(); + foreach ($aAux as $aGroup) { + $aGroupUids[] = $aGroup['GRP_UID']; + } + foreach ($aGroupUids as $results) { + $oCriteria = new \Criteria('workflow'); + $oCriteria->addSelectColumn('USR_UID'); + $oCriteria->add(\GroupUserPeer::GRP_UID, $results); + $oGroupDataset = \GroupUserPeer::doSelectRS($oCriteria); + $oGroupDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + while ($oGroupDataset->next()) { + $aGroupRow = $oGroupDataset->getRow(); + $oGroupCriteria = new \Criteria('workflow'); + $oGroupCriteria->addSelectColumn(\UsersPeer::USR_UID); + $oGroupCriteria->addSelectColumn(\UsersPeer::USR_FIRSTNAME); + $oGroupCriteria->addSelectColumn(\UsersPeer::USR_LASTNAME); + $oGroupCriteria->addSelectColumn(\UsersPeer::USR_USERNAME); + if ($filter != '') { + $oGroupCriteria->add($oGroupCriteria->getNewCriterion(\UsersPeer::USR_USERNAME, "%$filter%", + \Criteria::LIKE)->addOr($oGroupCriteria->getNewCriterion(\UsersPeer::USR_FIRSTNAME, + "%$filter%", \Criteria::LIKE))->addOr($oGroupCriteria->getNewCriterion(\UsersPeer::USR_LASTNAME, + "%$filter%", \Criteria::LIKE))); + } + $oGroupCriteria->add(\UsersPeer::USR_UID, $aGroupRow["USR_UID"]); + $oUserDataset = \UsersPeer::doSelectRS($oGroupCriteria); + $oUserDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oUserDataset->next(); + while ($aUserRow = $oUserDataset->getRow()) { + $aUsers[] = array('aas_uid' => $aUserRow['USR_UID'], + 'aas_name' => $aUserRow['USR_FIRSTNAME'], + 'aas_lastname' => $aUserRow['USR_LASTNAME'], + 'aas_username' => $aUserRow['USR_USERNAME'], + 'aas_type' => "user" ); + $oUserDataset->next(); + } + } + } + $oCriteria = new \Criteria('workflow'); + $oCriteria->addSelectColumn(\UsersPeer::USR_UID); + $oCriteria->addSelectColumn(\UsersPeer::USR_FIRSTNAME); + $oCriteria->addSelectColumn(\UsersPeer::USR_LASTNAME); + $oCriteria->addSelectColumn(\UsersPeer::USR_USERNAME); + if ($filter != '') { + $oCriteria->add($oCriteria->getNewCriterion(\UsersPeer::USR_USERNAME, "%$filter%", \Criteria::LIKE) + ->addOr($oCriteria->getNewCriterion(\UsersPeer::USR_FIRSTNAME, "%$filter%", \Criteria::LIKE)) + ->addOr($oCriteria->getNewCriterion(\UsersPeer::USR_LASTNAME, "%$filter%", \Criteria::LIKE ))); + } + $oCriteria->addJoin(\TaskUserPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN); + $oCriteria->add(\TaskUserPeer::TAS_UID, $sTaskUID); + $oCriteria->add(\TaskUserPeer::TU_TYPE, 2); + $oCriteria->add(\TaskUserPeer::TU_RELATION, 1); + $oDataset = \TaskUserPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + if ($type == '' || $type == 'user') { + $aUsers[] = array('aas_uid' => $aRow['USR_UID'], + 'aas_name' => $aRow['USR_FIRSTNAME'], + 'aas_lastname' => $aRow['USR_LASTNAME'], + 'aas_username' => $aRow['USR_USERNAME'], + 'aas_type' => "user" ); + } + $oDataset->next(); + } + $aUsersGroups = array(); + $exclude = array(""); + for ($i = 0; $i<=count($aUsers)-1; $i++) { + if (!in_array(trim($aUsers[$i]["aas_uid"]) ,$exclude)) { + $aUsersGroups[] = $aUsers[$i]; + $exclude[] = trim($aUsers[$i]["aas_uid"]); + } + } + if ($start) { + if ($start < 0) { + throw (new \Exception( 'Invalid value specified for `start`.')); + } + } else { + $start = 0; + } + if (isset($limit)) { + if ($limit < 0) { + throw (new \Exception( 'Invalid value specified for `limit`.')); + } else { + if ($limit == 0) { + return array(); + } + } + } else { + $limit = 1000; + } + $aUsersGroups = $this->arrayPagination($aUsersGroups, $start, $limit); + return $aUsersGroups; + } catch (Exception $e) { + throw $e; + } + } +} \ No newline at end of file diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Project/Activity/Assignee.php b/workflow/engine/src/Services/Api/ProcessMaker/Project/Activity/Assignee.php index 3b083339e..4ea804e05 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Project/Activity/Assignee.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Project/Activity/Assignee.php @@ -240,5 +240,57 @@ class Assignee extends Api throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } + + /** + * @url GET /:prjUid/activity/:actUid/assignee/all + * + * @param string $prjUid {@min 32} {@max 32} + * @param string $actUid {@min 32} {@max 32} + * @param string $filter + * @param int $start + * @param int $limit + * @param string $type + * + */ + public function doGetActivityAssigneesAll($prjUid, $actUid, $filter = '', $start = null, $limit = null, $type = '') + { + $response = array(); + try { + $task = new \BusinessModel\Task(); + $arrayData = $task->getTaskAssigneesAll($prjUid, $actUid, $filter, $start, $limit, $type); + //Response + $response = $arrayData; + } catch (\Exception $e) { + //Response + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + return $response; + } + + /** + * @url GET /:prjUid/activity/:actUid/adhoc-assignee/all + * + * @param string $prjUid {@min 32} {@max 32} + * @param string $actUid {@min 32} {@max 32} + * @param string $filter + * @param int $start + * @param int $limit + * @param string $type + * + */ + public function doGetActivityAdhocAssigneesAll($prjUid, $actUid, $filter = '', $start = null, $limit = null, $type = '') + { + $response = array(); + try { + $task = new \BusinessModel\Task(); + $arrayData = $task->getTaskAdhocAssigneesAll($prjUid, $actUid, $filter, $start, $limit, $type); + //Response + $response = $arrayData; + } catch (\Exception $e) { + //Response + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + return $response; + } } From 1e7154902fc92fa9f25f17bd654f8e9a3e50a576 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Tue, 1 Apr 2014 15:30:58 -0400 Subject: [PATCH 4/6] Se modifica BEHAT basico para ASSIGNEE y ADHOC ASSIGNEE --- .../adhoc_assignee/main_tests_adhoc_assignee.feature | 10 ++++++++-- .../projects/assignee/activity_assignee.feature | 7 +++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/features/backend/projects/adhoc_assignee/main_tests_adhoc_assignee.feature b/features/backend/projects/adhoc_assignee/main_tests_adhoc_assignee.feature index af3d9b027..a11080cc4 100644 --- a/features/backend/projects/adhoc_assignee/main_tests_adhoc_assignee.feature +++ b/features/backend/projects/adhoc_assignee/main_tests_adhoc_assignee.feature @@ -123,7 +123,13 @@ Requirements: And the content type is "application/json" And the type is "array" And the response has 1 records - - + + Scenario: List assignees of an activity + Given I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/adhoc-assignee/all" + 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" + \ No newline at end of file diff --git a/features/backend/projects/assignee/activity_assignee.feature b/features/backend/projects/assignee/activity_assignee.feature index 5a2c75b42..5e6f62ceb 100644 --- a/features/backend/projects/assignee/activity_assignee.feature +++ b/features/backend/projects/assignee/activity_assignee.feature @@ -129,3 +129,10 @@ Scenario Outline: List assignees of an activity using a filter And the type is "array" And the response has 4 records + + Scenario: List assignees of an activity including users that are within groups + Given I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/assignee/all" + 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" From adbf4e40211bf1dc24d7b75dd6cf96bf7338feaa Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Tue, 1 Apr 2014 16:24:45 -0400 Subject: [PATCH 5/6] Se modifica respuesta en POST de OUTPUTDOCUMENTS --- workflow/engine/src/BusinessModel/Cases/OutputDocument.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/workflow/engine/src/BusinessModel/Cases/OutputDocument.php b/workflow/engine/src/BusinessModel/Cases/OutputDocument.php index 8683d1e36..0e3d578c6 100644 --- a/workflow/engine/src/BusinessModel/Cases/OutputDocument.php +++ b/workflow/engine/src/BusinessModel/Cases/OutputDocument.php @@ -265,7 +265,8 @@ class OutputDocument } } $g->sessionVarRestore(); - return $this->getCasesOutputDocument($applicationUid, $userUid, $sDocUID); + $response = $this->getCasesOutputDocument($applicationUid, $userUid, $sDocUID); + return $response; } catch (\Exception $e) { throw $e; } From 539aa22fc5499d34fd3ec6640dd25ae64645be08 Mon Sep 17 00:00:00 2001 From: Victor Saisa Lopez Date: Tue, 1 Apr 2014 17:30:02 -0400 Subject: [PATCH 6/6] ProcessMaker "Calendar (endpoints)" - Se han implementado los siguientes Endpoints: GET /api/1.0/{workspace}/calendar/{cal_uid} POST /api/1.0/{workspace}/calendar --- .../engine/src/BusinessModel/Calendar.php | 353 +++++++++++++++++- .../engine/src/BusinessModel/DynaForm.php | 8 +- workflow/engine/src/BusinessModel/Group.php | 14 +- .../engine/src/BusinessModel/Group/User.php | 8 +- .../src/BusinessModel/InputDocument.php | 2 +- workflow/engine/src/BusinessModel/Process.php | 89 +++-- workflow/engine/src/BusinessModel/Step.php | 26 +- workflow/engine/src/BusinessModel/Task.php | 6 +- .../src/BusinessModel/TriggerWizard.php | 2 +- .../engine/src/BusinessModel/WebEntry.php | 4 +- .../Services/Api/ProcessMaker/Calendar.php | 42 +++ 11 files changed, 469 insertions(+), 85 deletions(-) diff --git a/workflow/engine/src/BusinessModel/Calendar.php b/workflow/engine/src/BusinessModel/Calendar.php index 8c437f375..8dd46ee1b 100644 --- a/workflow/engine/src/BusinessModel/Calendar.php +++ b/workflow/engine/src/BusinessModel/Calendar.php @@ -4,14 +4,29 @@ namespace BusinessModel; class Calendar { private $arrayFieldDefinition = array( - "CAL_UID" => array("fieldName" => "CALENDAR_UID", "type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "calendarUid"), + "CAL_UID" => array("fieldName" => "CALENDAR_UID", "type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "calendarUid"), - "CAL_NAME" => array("fieldName" => "CALENDAR_NAME", "type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "calendarName"), - "CAL_DESCRIPTION" => array("fieldName" => "CALENDAR_DESCRIPTION", "type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "calendarDescription"), - "CAL_CREATE_DATE" => array("fieldName" => "CALENDAR_CREATE_DATE", "type" => "datetime", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "calendarCreateDate"), - "CAL_UPDATE_DATE" => array("fieldName" => "CALENDAR_UPDATE_DATE", "type" => "datetime", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "calendarUpdateDate"), - "CAL_WORK_DAYS" => array("fieldName" => "CALENDAR_WORK_DAYS", "type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "calendarWorkDays"), - "CAL_STATUS" => array("fieldName" => "CALENDAR_STATUS", "type" => "string", "required" => true, "empty" => false, "defaultValues" => array("ACTIVE", "INACTIVE"), "fieldNameAux" => "calendarStatus") + "CAL_NAME" => array("fieldName" => "CALENDAR_NAME", "type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "calendarName"), + "CAL_DESCRIPTION" => array("fieldName" => "CALENDAR_DESCRIPTION", "type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "calendarDescription"), + "CAL_WORK_DAYS" => array("fieldName" => "CALENDAR_WORK_DAYS", "type" => "array", "required" => true, "empty" => false, "defaultValues" => array("SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"), "fieldNameAux" => "calendarWorkDays"), + "CAL_STATUS" => array("fieldName" => "CALENDAR_STATUS", "type" => "string", "required" => true, "empty" => false, "defaultValues" => array("ACTIVE", "INACTIVE"), "fieldNameAux" => "calendarStatus"), + "CAL_WORK_HOUR" => array("fieldName" => "CALENDAR_WORK_HOUR", "type" => "array", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "calendarWorkHour"), + "CAL_HOLIDAY" => array("fieldName" => "CALENDAR_HOLIDAY", "type" => "array", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "calendarHoliday"), + + "CAL_CREATE_DATE" => array("fieldName" => "CALENDAR_CREATE_DATE", "type" => "datetime", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "calendarCreateDate"), + "CAL_UPDATE_DATE" => array("fieldName" => "CALENDAR_UPDATE_DATE", "type" => "datetime", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "calendarUpdateDate") + ); + + private $arrayWorkHourFieldDefinition = array( + "DAY" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "ALL"), "fieldNameAux" => "day"), + "HOUR_START" => array("type" => "hour", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "hourStart"), + "HOUR_END" => array("type" => "hour", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "hourEnd") + ); + + private $arrayHolidayFieldDefinition = array( + "NAME" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "name"), + "DATE_START" => array("type" => "date", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "dateStart"), + "DATE_END" => array("type" => "date", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "dateEnd") ); private $formatFieldNameInUppercase = true; @@ -21,6 +36,8 @@ class Calendar "start" => "START", "limit" => "LIMIT" ); + private $arrayWorkHourFieldNameForException = array(); + private $arrayHolidayFieldNameForException = array(); /** * Constructor of the class @@ -33,6 +50,14 @@ class Calendar foreach ($this->arrayFieldDefinition as $key => $value) { $this->arrayFieldNameForException[$value["fieldNameAux"]] = $key; } + + foreach ($this->arrayWorkHourFieldDefinition as $key => $value) { + $this->arrayWorkHourFieldNameForException[$value["fieldNameAux"]] = $key; + } + + foreach ($this->arrayHolidayFieldDefinition as $key => $value) { + $this->arrayHolidayFieldNameForException[$value["fieldNameAux"]] = $key; + } } catch (\Exception $e) { throw $e; } @@ -51,6 +76,8 @@ class Calendar $this->formatFieldNameInUppercase = $flag; $this->setArrayFieldNameForException($this->arrayFieldNameForException); + $this->setArrayWorkHourFieldNameForException($this->arrayWorkHourFieldNameForException); + $this->setArrayHolidayFieldNameForException($this->arrayHolidayFieldNameForException); } catch (\Exception $e) { throw $e; } @@ -74,6 +101,42 @@ class Calendar } } + /** + * Set exception messages for fields + * + * @param array $arrayData Data with the fields + * + * return void + */ + public function setArrayWorkHourFieldNameForException($arrayData) + { + try { + foreach ($arrayData as $key => $value) { + $this->arrayWorkHourFieldNameForException[$key] = $this->getFieldNameByFormatFieldName($value); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Set exception messages for fields + * + * @param array $arrayData Data with the fields + * + * return void + */ + public function setArrayHolidayFieldNameForException($arrayData) + { + try { + foreach ($arrayData as $key => $value) { + $this->arrayHolidayFieldNameForException[$key] = $this->getFieldNameByFormatFieldName($value); + } + } catch (\Exception $e) { + throw $e; + } + } + /** * Get the name of the field according to the format * @@ -90,6 +153,199 @@ class Calendar } } + /** + * Verify if exists the name of a Calendar + * + * @param string $calendarName Name + * @param string $calendarUidExclude Unique id of Calendar to exclude + * + * return bool Return true if exists the name of a Calendar, false otherwise + */ + public function existsName($calendarName, $calendarUidExclude = "") + { + try { + $criteria = new \Criteria("workflow"); + + $criteria->addSelectColumn(\CalendarDefinitionPeer::CALENDAR_UID); + $criteria->add(\CalendarDefinitionPeer::CALENDAR_STATUS, "DELETED", \Criteria::NOT_EQUAL); + + if ($calendarUidExclude != "") { + $criteria->add(\CalendarDefinitionPeer::CALENDAR_UID, $calendarUidExclude, \Criteria::NOT_EQUAL); + } + + $criteria->add(\CalendarDefinitionPeer::CALENDAR_NAME, $calendarName, \Criteria::EQUAL); + + $rsCriteria = \CalendarDefinitionPeer::doSelectRS($criteria); + + if ($rsCriteria->next()) { + return true; + } else { + return false; + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Replace and Get Work Days + * + * @param string $workDays Work days + * @param bool $toNumber If is true replace to numbers, replace to string otherwise + * + * return string Return Work days + */ + public function workDaysReplaceData($workDays, $toNumber = true) + { + try { + $arrayDayString = array("SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "ALL"); + $arrayDayNumber = array(0, 1, 2, 3, 4, 5, 6, 7); + + return ($toNumber)? str_replace($arrayDayString, $arrayDayNumber, $workDays) : str_replace($arrayDayNumber, $arrayDayString, $workDays); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if doesn't exists the Calendar in table CALENDAR_DEFINITION + * + * @param string $calendarUid Unique id of Calendar + * @param string $fieldNameForException Field name for the exception + * + * return void Throw exception if doesn't exists the Calendar in table CALENDAR_DEFINITION + */ + public function throwExceptionIfNotExistsCalendar($calendarUid, $fieldNameForException) + { + try { + $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"); + + throw (new \Exception($msg)); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if exists the name of a Calendar + * + * @param string $calendarName Name + * @param string $fieldNameForException Field name for the exception + * @param string $calendarUidExclude Unique id of Calendar to exclude + * + * return void Throw exception if exists the name of a Calendar + */ + public function throwExceptionIfExistsName($calendarName, $fieldNameForException, $calendarUidExclude = "") + { + try { + if ($this->existsName($calendarName, $calendarUidExclude)) { + $msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $calendarName), "The calendar name with {0}: \"{1}\" already exists"); + + throw (new \Exception($msg)); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Create Group + * + * @param array $arrayData Data + * + * return array Return data of the new Group created + */ + public function create($arrayData) + { + try { + $arrayData = \G::array_change_key_case2($arrayData, CASE_UPPER); + + unset($arrayData["CAL_UID"]); + + //Verify data + $process = new \BusinessModel\Process(); + + $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true); + + $this->throwExceptionIfExistsName($arrayData["CAL_NAME"], $this->arrayFieldNameForException["calendarName"]); + + if (!(count($arrayData["CAL_WORK_DAYS"]) >= 3)) { + throw (new \Exception(\G::LoadTranslation("ID_MOST_AT_LEAST_3_DAY"))); + } + + if (isset($arrayData["CAL_WORK_HOUR"])) { + foreach ($arrayData["CAL_WORK_HOUR"] as $value) { + $process->throwExceptionIfDataNotMetFieldDefinition($value, $this->arrayWorkHourFieldDefinition, $this->arrayWorkHourFieldNameForException, true); + } + } + + if (isset($arrayData["CAL_HOLIDAY"])) { + foreach ($arrayData["CAL_HOLIDAY"] as $value) { + $process->throwExceptionIfDataNotMetFieldDefinition($value, $this->arrayHolidayFieldDefinition, $this->arrayHolidayFieldNameForException, true); + } + } + + //Set variables + $arrayCalendarWorkHour = array(); + + if (isset($arrayData["CAL_WORK_HOUR"])) { + foreach ($arrayData["CAL_WORK_HOUR"] as $value) { + $arrayCalendarWorkHour[] = array( + "CALENDAR_BUSINESS_DAY" => $this->workDaysReplaceData($value["DAY"]), + "CALENDAR_BUSINESS_START" => $value["HOUR_START"], + "CALENDAR_BUSINESS_END" => $value["HOUR_END"] + ); + } + } + + $arrayCalendarHoliday = array(); + + if (isset($arrayData["CAL_HOLIDAY"])) { + foreach ($arrayData["CAL_HOLIDAY"] as $value) { + $arrayCalendarHoliday[] = array( + "CALENDAR_HOLIDAY_NAME" => $value["NAME"], + "CALENDAR_HOLIDAY_START" => $value["DATE_START"], + "CALENDAR_HOLIDAY_END" => $value["DATE_END"] + ); + } + } + + $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_WORK_DAYS"] = explode("|", $this->workDaysReplaceData(implode("|", $arrayData["CAL_WORK_DAYS"]))); + $arrayDataAux["CALENDAR_STATUS"] = $arrayData["CAL_STATUS"]; + + $arrayDataAux["BUSINESS_DAY"] = $arrayCalendarWorkHour; + $arrayDataAux["HOLIDAY"] = $arrayCalendarHoliday; + + //Create + $calendarDefinition = new \CalendarDefinition(); + + $calendarDefinition->saveCalendarInfo($arrayDataAux); + + //Return + $arrayData = array_merge(array("CAL_UID" => $arrayDataAux["CALENDAR_UID"]), $arrayData); + + if (!$this->formatFieldNameInUppercase) { + $arrayData = \G::array_change_key_case2($arrayData, CASE_LOWER); + } + + return $arrayData; + } catch (\Exception $e) { + throw $e; + } + } + /** * Get criteria for Calendar * @@ -103,10 +359,10 @@ class Calendar $criteria->addSelectColumn(\CalendarDefinitionPeer::CALENDAR_UID); $criteria->addSelectColumn(\CalendarDefinitionPeer::CALENDAR_NAME); $criteria->addSelectColumn(\CalendarDefinitionPeer::CALENDAR_DESCRIPTION); - $criteria->addSelectColumn(\CalendarDefinitionPeer::CALENDAR_CREATE_DATE); - $criteria->addSelectColumn(\CalendarDefinitionPeer::CALENDAR_UPDATE_DATE); $criteria->addSelectColumn(\CalendarDefinitionPeer::CALENDAR_WORK_DAYS); $criteria->addSelectColumn(\CalendarDefinitionPeer::CALENDAR_STATUS); + $criteria->addSelectColumn(\CalendarDefinitionPeer::CALENDAR_CREATE_DATE); + $criteria->addSelectColumn(\CalendarDefinitionPeer::CALENDAR_UPDATE_DATE); $criteria->add(\CalendarDefinitionPeer::CALENDAR_STATUS, "DELETED", \Criteria::NOT_EQUAL); return $criteria; @@ -125,14 +381,41 @@ class Calendar public function getCalendarDataFromRecord($record) { try { + $calendarBusinessHours = new \CalendarBusinessHours(); + $calendarHolidays = new \CalendarHolidays(); + + $arrayCalendarWorkHour = array(); + $arrayData = $calendarBusinessHours->getCalendarBusinessHours($record["CALENDAR_UID"]); + + foreach ($arrayData as $value) { + $arrayCalendarWorkHour[] = array( + $this->getFieldNameByFormatFieldName("DAY") => $this->workDaysReplaceData($value["CALENDAR_BUSINESS_DAY"] . "", false), + $this->getFieldNameByFormatFieldName("HOUR_START") => $value["CALENDAR_BUSINESS_START"] . "", + $this->getFieldNameByFormatFieldName("HOUR_END") => $value["CALENDAR_BUSINESS_END"] . "", + ); + } + + $arrayCalendarHoliday = array(); + $arrayData = $calendarHolidays->getCalendarHolidays($record["CALENDAR_UID"]); + + foreach ($arrayData as $value) { + $arrayCalendarHoliday[] = array( + $this->getFieldNameByFormatFieldName("NAME") => $value["CALENDAR_HOLIDAY_NAME"] . "", + $this->getFieldNameByFormatFieldName("DATE_START") => $value["CALENDAR_HOLIDAY_START"] . "", + $this->getFieldNameByFormatFieldName("DATE_END") => $value["CALENDAR_HOLIDAY_END"] . "", + ); + } + return array( $this->getFieldNameByFormatFieldName("CAL_UID") => $record["CALENDAR_UID"], $this->getFieldNameByFormatFieldName("CAL_NAME") => $record["CALENDAR_NAME"], $this->getFieldNameByFormatFieldName("CAL_DESCRIPTION") => $record["CALENDAR_DESCRIPTION"] . "", + $this->getFieldNameByFormatFieldName("CAL_WORK_DAYS") => explode("|", $this->workDaysReplaceData($record["CALENDAR_WORK_DAYS"] . "", false)), + $this->getFieldNameByFormatFieldName("CAL_STATUS") => $record["CALENDAR_STATUS"], + $this->getFieldNameByFormatFieldName("CAL_WORK_HOUR") => $arrayCalendarWorkHour, + $this->getFieldNameByFormatFieldName("CAL_HOLIDAY") => $arrayCalendarHoliday, $this->getFieldNameByFormatFieldName("CAL_CREATE_DATE") => $record["CALENDAR_CREATE_DATE"] . "", $this->getFieldNameByFormatFieldName("CAL_UPDATE_DATE") => $record["CALENDAR_UPDATE_DATE"] . "", - $this->getFieldNameByFormatFieldName("CAL_WORK_DAYS") => $record["CALENDAR_WORK_DAYS"] . "", - $this->getFieldNameByFormatFieldName("CAL_STATUS") => $record["CALENDAR_STATUS"], $this->getFieldNameByFormatFieldName("CAL_TOTAL_USERS") => (int)($record["CALENDAR_TOTAL_USERS"]), $this->getFieldNameByFormatFieldName("CAL_TOTAL_PROCESSES") => (int)($record["CALENDAR_TOTAL_PROCESSES"]), $this->getFieldNameByFormatFieldName("CAL_TOTAL_TASKS") => (int)($record["CALENDAR_TOTAL_TASKS"]) @@ -205,10 +488,10 @@ class Calendar case "CALENDAR_UID": case "CALENDAR_NAME": case "CALENDAR_DESCRIPTION": - case "CALENDAR_CREATE_DATE": - case "CALENDAR_UPDATE_DATE": case "CALENDAR_WORK_DAYS": case "CALENDAR_STATUS": + case "CALENDAR_CREATE_DATE": + case "CALENDAR_UPDATE_DATE": $sortField = \CalendarDefinitionPeer::TABLE_NAME . "." . $sortField; break; default: @@ -252,5 +535,49 @@ class Calendar throw $e; } } + + /** + * Get data of a Calendar + * + * @param string $calendarUid Unique id of Calendar + * + * return array Return an array with data of a Calendar + */ + public function getCalendar($calendarUid) + { + try { + //Verify data + $this->throwExceptionIfNotExistsCalendar($calendarUid, $this->arrayFieldNameForException["calendarUid"]); + + //Get data + //Set variables + $calendar = new \CalendarDefinition(); + + $arrayTotalUsersByCalendar = $calendar->getAllCounterByCalendar("USER"); + $arrayTotalProcessesByCalendar = $calendar->getAllCounterByCalendar("PROCESS"); + $arrayTotalTasksByCalendar = $calendar->getAllCounterByCalendar("TASK"); + + //SQL + $criteria = $this->getCalendarCriteria(); + + $criteria->add(\CalendarDefinitionPeer::CALENDAR_UID, $calendarUid, \Criteria::EQUAL); + + $rsCriteria = \CalendarDefinitionPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + + $rsCriteria->next(); + + $row = $rsCriteria->getRow(); + + $row["CALENDAR_TOTAL_USERS"] = (isset($arrayTotalUsersByCalendar[$calendarUid]))? $arrayTotalUsersByCalendar[$calendarUid] : 0; + $row["CALENDAR_TOTAL_PROCESSES"] = (isset($arrayTotalProcessesByCalendar[$calendarUid]))? $arrayTotalProcessesByCalendar[$calendarUid] : 0; + $row["CALENDAR_TOTAL_TASKS"] = (isset($arrayTotalTasksByCalendar[$calendarUid]))? $arrayTotalTasksByCalendar[$calendarUid] : 0; + + //Return + return $this->getCalendarDataFromRecord($row); + } catch (\Exception $e) { + throw $e; + } + } } diff --git a/workflow/engine/src/BusinessModel/DynaForm.php b/workflow/engine/src/BusinessModel/DynaForm.php index 2664aa1e6..131c441fd 100644 --- a/workflow/engine/src/BusinessModel/DynaForm.php +++ b/workflow/engine/src/BusinessModel/DynaForm.php @@ -360,7 +360,7 @@ class DynaForm //Verify data $process = new \BusinessModel\Process(); - $process->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); + $process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true); @@ -507,7 +507,7 @@ class DynaForm //Verify data $process = new \BusinessModel\Process(); - $process->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); + $process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true); @@ -542,7 +542,7 @@ class DynaForm $dynaFormUidCopyImport = $arrayData["COPY_IMPORT"]["DYN_UID"]; //Verify data - $process->throwExceptionIfNoExistsProcess($processUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.PRJ_UID")); + $process->throwExceptionIfNotExistsProcess($processUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.PRJ_UID")); $this->throwExceptionIfNotExistsDynaForm($dynaFormUidCopyImport, $processUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.DYN_UID")); @@ -710,7 +710,7 @@ class DynaForm //Verify data $process = new \BusinessModel\Process(); - $process->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); + $process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true); diff --git a/workflow/engine/src/BusinessModel/Group.php b/workflow/engine/src/BusinessModel/Group.php index 5a50e3354..e5d6dcc15 100644 --- a/workflow/engine/src/BusinessModel/Group.php +++ b/workflow/engine/src/BusinessModel/Group.php @@ -137,7 +137,7 @@ class Group * * return void Throw exception if doesn't exists the Group in table GROUP */ - public function throwExceptionIfNoExistsGroup($groupUid, $fieldNameForException) + public function throwExceptionIfNotExistsGroup($groupUid, $fieldNameForException) { try { $group = new \Groupwf(); @@ -229,7 +229,7 @@ class Group //Verify data $process = new \BusinessModel\Process(); - $this->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]); + $this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]); $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, false); @@ -268,7 +268,7 @@ class Group { try { //Verify data - $this->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]); + $this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]); //Delete $group = new \Groupwf(); @@ -340,7 +340,7 @@ class Group //Verif data if ($groupUid != "") { - $this->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]); + $this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]); } //Get data @@ -387,7 +387,7 @@ class Group //Verif data if ($groupUid != "") { - $this->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]); + $this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]); } //Get data @@ -555,7 +555,7 @@ class Group { try { //Verify data - $this->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]); + $this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]); //Get data $arrayTotalUsersByGroup = $this->getTotalUsersByGroup($groupUid); @@ -673,7 +673,7 @@ class Group //Verify data $process = new \BusinessModel\Process(); - $this->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]); + $this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]); $process->throwExceptionIfDataNotMetPagerVarDefinition(array("start" => $start, "limit" => $limit), $this->arrayFieldNameForException); diff --git a/workflow/engine/src/BusinessModel/Group/User.php b/workflow/engine/src/BusinessModel/Group/User.php index f3f27a3e3..d7f779f5e 100644 --- a/workflow/engine/src/BusinessModel/Group/User.php +++ b/workflow/engine/src/BusinessModel/Group/User.php @@ -147,11 +147,11 @@ class User $process = new \BusinessModel\Process(); $group = new \BusinessModel\Group(); - $group->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]); + $group->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]); $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true); - $process->throwExceptionIfNoExistsUser($arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]); + $process->throwExceptionIfNotExistsUser($arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]); $this->throwExceptionIfExistsGroupUser($groupUid, $arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]); @@ -188,9 +188,9 @@ class User $process = new \BusinessModel\Process(); $group = new \BusinessModel\Group(); - $group->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]); + $group->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]); - $process->throwExceptionIfNoExistsUser($userUid, $this->arrayFieldNameForException["userUid"]); + $process->throwExceptionIfNotExistsUser($userUid, $this->arrayFieldNameForException["userUid"]); $this->throwExceptionIfNotExistsGroupUser($groupUid, $userUid, $this->arrayFieldNameForException["userUid"]); diff --git a/workflow/engine/src/BusinessModel/InputDocument.php b/workflow/engine/src/BusinessModel/InputDocument.php index 5757b96e6..22a37d89b 100644 --- a/workflow/engine/src/BusinessModel/InputDocument.php +++ b/workflow/engine/src/BusinessModel/InputDocument.php @@ -211,7 +211,7 @@ class InputDocument //Verify data $process = new \BusinessModel\Process(); - $process->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); + $process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true); diff --git a/workflow/engine/src/BusinessModel/Process.php b/workflow/engine/src/BusinessModel/Process.php index d36128ba7..16621b58b 100644 --- a/workflow/engine/src/BusinessModel/Process.php +++ b/workflow/engine/src/BusinessModel/Process.php @@ -214,7 +214,7 @@ class Process // } else { $eregDate = "[1-9]\d{3}\-(?:0[1-9]|1[012])\-(?:[0][1-9]|[12][0-9]|3[01])"; - $eregHour = "(?:[0-1]\d|2[0-3])\:(?:[0-5]\d)\:(?:[0-5]\d)"; + $eregHour = "(?:[0-1]\d|2[0-3])\:(?:[0-5]\d)(?:\:[0-5]\d)?"; $eregDatetime = $eregDate . "\s" . $eregHour; switch ($arrayFieldDefinition[$fieldName]["type"]) { @@ -237,14 +237,50 @@ class Process } break; case 2: - //type switch ($arrayFieldDefinition[$fieldName]["type"]) { case "array": + //type if (!is_array($fieldValue)) { - if ((!preg_match("/^\s*array\s*\(.*\)\s*$/", $fieldValue)) && $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"))); } } + + //empty + if (!$arrayFieldDefinition[$fieldName]["empty"]) { + $arrayAux = array(); + + if (is_array($fieldValue)) { + $arrayAux = $fieldValue; + } + + if (is_string($fieldValue) && trim($fieldValue) . "" != "") { + eval("\$arrayAux = $fieldValue;"); + } + + if (count($arrayAux) == 0) { + throw (new \Exception(str_replace(array("{0}"), array($fieldNameAux), "The \"{0}\" attribute is empty"))); + } + } + + //defaultValues + if (count($arrayFieldDefinition[$fieldName]["defaultValues"]) > 0) { + $arrayAux = array(); + + if (is_array($fieldValue)) { + $arrayAux = $fieldValue; + } + + if (is_string($fieldValue) && trim($fieldValue) . "" != "") { + eval("\$arrayAux = $fieldValue;"); + } + + 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}\""))); + } + } + } break; } break; @@ -287,7 +323,7 @@ class Process * * return void Throw exception if doesn't exists the Process in table PROCESS */ - public function throwExceptionIfNoExistsProcess($processUid, $fieldNameForException) + public function throwExceptionIfNotExistsProcess($processUid, $fieldNameForException) { try { $process = new \Process(); @@ -310,7 +346,7 @@ class Process * * return void Throw exception if doesn't exists the User in table USERS */ - public function throwExceptionIfNoExistsUser($userUid, $fieldNameForException) + public function throwExceptionIfNotExistsUser($userUid, $fieldNameForException) { try { $user = new \Users(); @@ -347,29 +383,6 @@ class Process } } - /** - * Verify if doesn't exists the Calendar Definition in table CALENDAR_DEFINITION - * - * @param string $calendarDefinitionUid Unique id of Calendar Definition - * @param string $fieldNameForException Field name for the exception - * - * return void Throw exception if doesn't exists the Calendar Definition in table CALENDAR_DEFINITION - */ - public function throwExceptionIfNotExistsCalendarDefinition($calendarDefinitionUid, $fieldNameForException) - { - try { - $obj = \CalendarDefinitionPeer::retrieveByPK($calendarDefinitionUid); - - if (!(is_object($obj) && get_class($obj) == "CalendarDefinition")) { - $msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $calendarDefinitionUid), "The calendar definition with {0}: {1}, does not exist"); - - throw (new \Exception($msg)); - } - } catch (\Exception $e) { - throw $e; - } - } - /** * Verify if doesn't exists the Process Category in table PROCESS_CATEGORY * @@ -498,7 +511,7 @@ class Process $arrayData = array_change_key_case($arrayData, CASE_UPPER); //Verify data - $this->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); + $this->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); $this->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, false); @@ -507,7 +520,9 @@ class Process } if (isset($arrayData["PRO_CALENDAR"]) && $arrayData["PRO_CALENDAR"] . "" != "") { - $this->throwExceptionIfNotExistsCalendarDefinition($arrayData["PRO_CALENDAR"], $this->arrayFieldNameForException["processCalendar"]); + $calendar = new \BusinessModel\Calendar(); + + $calendar->throwExceptionIfNotExistsCalendar($arrayData["PRO_CALENDAR"], $this->arrayFieldNameForException["processCalendar"]); } if (isset($arrayData["PRO_CATEGORY"]) && $arrayData["PRO_CATEGORY"] . "" != "") { @@ -543,11 +558,11 @@ class Process } if (isset($arrayData["PRO_PARENT"])) { - $this->throwExceptionIfNoExistsProcess($arrayData["PRO_PARENT"], $this->arrayFieldNameForException["processParent"]); + $this->throwExceptionIfNotExistsProcess($arrayData["PRO_PARENT"], $this->arrayFieldNameForException["processParent"]); } if (isset($arrayData["PRO_CREATE_USER"]) && $arrayData["PRO_CREATE_USER"] . "" != "") { - $this->throwExceptionIfNoExistsUser($arrayData["PRO_CREATE_USER"], $this->arrayFieldNameForException["processCreateUser"]); + $this->throwExceptionIfNotExistsUser($arrayData["PRO_CREATE_USER"], $this->arrayFieldNameForException["processCreateUser"]); } //Update @@ -598,7 +613,7 @@ class Process { try { //Verify data - $this->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); + $this->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); //Get data //Load Process @@ -1372,7 +1387,7 @@ class Process $arrayDynaForm = array(); //Verify data - $this->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); + $this->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); //Get data $dynaForm = new \BusinessModel\DynaForm(); @@ -1413,7 +1428,7 @@ class Process $arrayInputDocument = array(); //Verify data - $this->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); + $this->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); //Get data $inputDocument = new \BusinessModel\InputDocument(); @@ -1545,7 +1560,7 @@ class Process $arrayVariable = array(); //Verify data - $this->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); + $this->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); //Get data switch ($option) { @@ -1602,7 +1617,7 @@ class Process $arrayLibrary = array(); //Verify data - $this->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); + $this->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); //Get data \G::LoadClass("triggerLibrary"); diff --git a/workflow/engine/src/BusinessModel/Step.php b/workflow/engine/src/BusinessModel/Step.php index 42e9ae446..6ae77b440 100644 --- a/workflow/engine/src/BusinessModel/Step.php +++ b/workflow/engine/src/BusinessModel/Step.php @@ -196,7 +196,7 @@ class Step * * return void Throw exception if doesn't exist the Step in table STEP */ - public function throwExceptionIfNoExistsStep($stepUid) + public function throwExceptionIfNotExistsStep($stepUid) { $step = new \Step(); @@ -217,7 +217,7 @@ class Step * * return void Throw exception if doesn't exist the Task in table TASK */ - public function throwExceptionIfNoExistsTask($taskUid) + public function throwExceptionIfNotExistsTask($taskUid) { $task = new \Task(); @@ -238,7 +238,7 @@ class Step * * return void Throw exception if doesn't exist the Process in table PROCESS */ - public function throwExceptionIfNoExistsProcess($processUid) + public function throwExceptionIfNotExistsProcess($processUid) { $process = new \Process(); @@ -269,9 +269,9 @@ class Step unset($arrayData["STEP_UID"]); //Verify data - $this->throwExceptionIfNoExistsTask($taskUid); + $this->throwExceptionIfNotExistsTask($taskUid); - $this->throwExceptionIfNoExistsProcess($processUid); + $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"))); @@ -361,7 +361,7 @@ class Step $arrayData = array_change_key_case($arrayData, CASE_UPPER); //Verify data - $this->throwExceptionIfNoExistsStep($stepUid); + $this->throwExceptionIfNotExistsStep($stepUid); //Load Step $step = new \Step(); @@ -460,7 +460,7 @@ class Step { try { //Verify data - $this->throwExceptionIfNoExistsStep($stepUid); + $this->throwExceptionIfNotExistsStep($stepUid); //Get position $criteria = new \Criteria("workflow"); @@ -503,7 +503,7 @@ class Step $step->setArrayParamException($this->arrayParamException); //Verify data - $this->throwExceptionIfNoExistsTask($taskUid); + $this->throwExceptionIfNotExistsTask($taskUid); //Get data $criteria = new \Criteria("workflow"); @@ -544,7 +544,7 @@ class Step $arrayStep = array(); //Verify data - $this->throwExceptionIfNoExistsStep($stepUid); + $this->throwExceptionIfNotExistsStep($stepUid); //Get data //Call plugin @@ -642,11 +642,11 @@ class Step //Verify data if ($stepUid != "") { - $this->throwExceptionIfNoExistsStep($stepUid); + $this->throwExceptionIfNotExistsStep($stepUid); } if ($stepUid == "") { - $this->throwExceptionIfNoExistsTask($taskUid); + $this->throwExceptionIfNotExistsTask($taskUid); } //Get data @@ -757,11 +757,11 @@ class Step //Verify data if ($stepUid != "") { - $this->throwExceptionIfNoExistsStep($stepUid); + $this->throwExceptionIfNotExistsStep($stepUid); } if ($stepUid == "") { - $this->throwExceptionIfNoExistsTask($taskUid); + $this->throwExceptionIfNotExistsTask($taskUid); } //Get data diff --git a/workflow/engine/src/BusinessModel/Task.php b/workflow/engine/src/BusinessModel/Task.php index f50694b72..ccc940d94 100644 --- a/workflow/engine/src/BusinessModel/Task.php +++ b/workflow/engine/src/BusinessModel/Task.php @@ -70,7 +70,7 @@ class Task * * return void Throw exception if doesn't exist the Task in table TASK */ - public function throwExceptionIfNoExistsTask($taskUid) + public function throwExceptionIfNotExistsTask($taskUid) { $task = new \Task(); @@ -438,7 +438,7 @@ class Task $arrayAvailableStep = array(); //Verify data - $this->throwExceptionIfNoExistsTask($taskUid); + $this->throwExceptionIfNotExistsTask($taskUid); //Load Task $task = new \Task(); @@ -641,7 +641,7 @@ class Task $step->setArrayParamException($this->arrayParamException); //Verify data - $this->throwExceptionIfNoExistsTask($taskUid); + $this->throwExceptionIfNotExistsTask($taskUid); //Get data $criteria = new \Criteria("workflow"); diff --git a/workflow/engine/src/BusinessModel/TriggerWizard.php b/workflow/engine/src/BusinessModel/TriggerWizard.php index a7813293a..90731d16d 100644 --- a/workflow/engine/src/BusinessModel/TriggerWizard.php +++ b/workflow/engine/src/BusinessModel/TriggerWizard.php @@ -676,7 +676,7 @@ class TriggerWizard $this->throwExceptionIfNotExistsMethodInLibrary($libraryName, $methodName, $this->arrayFieldNameForException["libraryName"], $this->arrayFieldNameForException["methodName"]); - $process->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); + $process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true); diff --git a/workflow/engine/src/BusinessModel/WebEntry.php b/workflow/engine/src/BusinessModel/WebEntry.php index f0386d6f8..61593a0c3 100644 --- a/workflow/engine/src/BusinessModel/WebEntry.php +++ b/workflow/engine/src/BusinessModel/WebEntry.php @@ -151,7 +151,7 @@ class WebEntry //Verify data $process = new \BusinessModel\Process(); - $process->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); + $process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); if ($taskUid != "") { $process->throwExceptionIfNotExistsTask($processUid, $taskUid, $this->arrayFieldNameForException["taskUid"]); @@ -279,7 +279,7 @@ class WebEntry //Verify data $process = new \BusinessModel\Process(); - $process->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); + $process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true); diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Calendar.php b/workflow/engine/src/Services/Api/ProcessMaker/Calendar.php index aac0e82f4..612b52aae 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Calendar.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Calendar.php @@ -29,5 +29,47 @@ class Calendar extends Api throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } + + /** + * @url GET /:cal_uid + * + * @param string $cal_uid {@min 32}{@max 32} + */ + public function doGet($cal_uid) + { + try { + $calendar = new \BusinessModel\Calendar(); + $calendar->setFormatFieldNameInUppercase($this->formatFieldNameInUppercase); + + $response = $calendar->getCalendar($cal_uid); + + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * @url POST + * + * @param array $request_data + * + * @status 201 + */ + public function doPost($request_data) + { + try { + $calendar = new \BusinessModel\Calendar(); + $calendar->setFormatFieldNameInUppercase($this->formatFieldNameInUppercase); + + $arrayData = $calendar->create($request_data); + + $response = $arrayData; + + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } }