diff --git a/features/backend/application_cases/cases_lists_1-6/basic_sequence_cases_lists_1_6.feature b/features/backend/application_cases/cases_lists_1-6/basic_sequence_cases_lists_1_6.feature index ef951e6e7..a90cf90e5 100644 --- a/features/backend/application_cases/cases_lists_1-6/basic_sequence_cases_lists_1_6.feature +++ b/features/backend/application_cases/cases_lists_1-6/basic_sequence_cases_lists_1_6.feature @@ -12,8 +12,7 @@ Scenario: Returns a list of the cases for the logged in user (Inbox) Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" - And the response has 1 records - + Scenario: Get paging of list inbox Given I request "cases/paged" @@ -21,8 +20,7 @@ Scenario: Get paging of list inbox And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has 1 records - + Scenario: Get order type of Descending Given I request "cases?dir=DESC" @@ -69,8 +67,7 @@ Scenario: Returns a list of the cases for the logged in user (Draft) Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" - And the response has 1 records - + Scenario: Get paging of list Draft Given I request "cases/draft/paged" @@ -78,8 +75,7 @@ Scenario: Get paging of list Draft And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has 1 records - + Scenario: Get order type of Descending Given I request "cases/draft?dir=DESC" @@ -126,8 +122,7 @@ Scenario: Returns a list of the cases for the logged in user (Participated) Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" - And the response has 6 records - + Scenario: Get paging of list Participated Given I request "cases/participated/paged" @@ -135,8 +130,7 @@ Scenario: Get paging of list Participated And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has 1 records - + Scenario: Get order type of Descending Given I request "cases/participated?dir=DESC" @@ -183,8 +177,7 @@ Scenario: Returns a list of the cases for the logged in user (Unassigned) Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" - And the response has 1 records - + Scenario: Get paging of list Unassigned Given I request "cases/unassigned/paged" @@ -192,8 +185,7 @@ Scenario: Get paging of list Unassigned And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has 1 records - + Scenario: Get order type of Descending Given I request "cases/unassigned?dir=DESC" @@ -240,8 +232,7 @@ Scenario: Returns a list of the cases for the logged in user (Paused) Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" - And the response has 1 records - + Scenario: Get paging of list Paused Given I request "cases/paused/paged" @@ -249,8 +240,7 @@ Scenario: Get paging of list Paused And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has 1 records - + Scenario: Get order type of Descending Given I request "cases/paused?dir=DESC" @@ -297,8 +287,7 @@ Scenario: Returns a list of the cases for the logged in user (Advanced Search) Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" - And the response has 1 records - + Scenario: Get paging of list Advanced Search Given I request "cases/advanced-search/paged" @@ -306,8 +295,7 @@ Scenario: Get paging of list Advanced Search And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has 1 records - + Scenario: Get order type of Descending Given I request "cases/advanced-search?dir=DESC" diff --git a/features/backend/application_cases/cases_lists_1-6/main_tests_cases_lists_1_6.feature b/features/backend/application_cases/cases_lists_1-6/main_tests_cases_lists_1_6.feature index 7d53eed58..e4fce90d8 100644 --- a/features/backend/application_cases/cases_lists_1-6/main_tests_cases_lists_1_6.feature +++ b/features/backend/application_cases/cases_lists_1-6/main_tests_cases_lists_1_6.feature @@ -7,49 +7,120 @@ Background: Given that I have a valid access_token +#Obtener la cantidad de casos ACTUALES por cada listado + Scenario: Returns a list of the cases for the logged in user (Inbox) Given I request "cases" Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" - And the response has 1 records + And store response count in session variable as "count_inbox" +Scenario: Returns a list of the cases for the logged in user (Draft) + Given I request "cases/draft" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "array" + And store response count in session variable as "count_draft" + + +Scenario: Returns a list of the cases for the logged in user (Participated) + Given I request "cases/participated" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "array" + And store response count in session variable as "count_participated" + + +Scenario: Returns a list of the cases for the logged in user (Unassigned) + Given I request "cases/unassigned" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "array" + And store response count in session variable as "count_unassigned" + + +Scenario: Returns a list of the cases for the logged in user (Paused) + Given I request "cases/paused" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "array" + And store response count in session variable as "count_paused" + + +Scenario: Returns a list of the cases for the logged in user (Advanced-Search) + Given I request "cases/paused" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "array" + And store response count in session variable as "count_advanced-search" + + +Scenario Outline: Create a new case in workspace with process "Derivation rules - sequential", "Derivation rules - evaluation", "Derivation rules - Parallel", "Derivation rules - parallel evaluation", "Derivation rules - selection" + Given POST this data: + """ + { + "pro_uid": "", + "tas_uid": "", + "variables": [{"name": "admin", "lastname":"admin"}] + } + """ + And I request "cases" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the content type is "application/json" + And the type is "object" + And store "app_uid" in session array as variable "app_uid_" + And store "app_number" in session array as variable "app_number_" + + Examples: + | Description | app_uid_number | pro_uid | tas_uid | variables | + | Create new case with process "Derivation rules - sequential" | 1 | 99209594750ec27ea338927000421575 | 68707275350ec281ada1c95068712556 | | + | Create new case with process "Derivation rules - evaluation" | 2 | 46279907250ec73b9b25a78031279680 | 99371337850ec73c0a38eb6024620271 | | + | Create new case with process "Derivation rules - Parallel" | 3 | 35894775350ec7daa099378048029617 | 52838134750ec7dd0989fc0015625952 | | + | Create new case with process "Derivation rules - parallel evaluation" | 4 | 34579467750ec8d55e8b115057818502 | 89648437550ec8d593c2159010276089 | | + | Create new case with process "Derivation rules - selection" | 5 | 82458496050ec668981ecc7039804404 | 56900024450ec668e4a9243080698854 | | + + + +#Scenarios para filtros y paginacion de las listas Scenario Outline: Get paging of list inbox Given I request "cases/paged?Start=&limit=" Then the response status code should be And the response charset is "UTF-8" And the content type is "application/json" And the type is "" - And the response has records + And the response has records more than "" + Examples: | test_description | start | limit | records | http_code | type | - | lowercase in Start | a | 1 | | 200 | array | - | uppercase in Start | A | 1 | | 200 | array | - | lowercase in Limit | 1 | a | | 200 | array | - | uppercase in Limit | 1 | A | | 200 | array | - | limit=3 | 1 | 3 | | 200 | array | - | start=3 | 3 | 3 | | 200 | array | - | limit and start =3 | 3 | 3 | | 200 | array | - | high number for start | 1000 | 1 | | 200 | array | - | high number for start | 1000 | 0 | | 200 | array | - | empty result | 1 | 0 | | 200 | array | - | empty string | 1 | 10000 | | 200 | array | - | invalid start | b | 25 | | 400 | string | - | invalid limit | 1 | c | | 400 | string | - | start equals zero | 0 | 20 | | 400 | string | - | search 0 | 0 | 0 | | 200 | array | - | search 0 | 0 | 100 | | 200 | array | - | negative numbers in start | -10 | 25 | | 400 | string | - | negative numbers in limit | 1 | -25 | | 400 | string | - | real numbers | 0.0 | 1.0 | | 200 | string | - | real numbers in start | 0.0 | 25 | | 200 | string | - | real numbers in limit | 1 | 1.4599 | | 400 | string | - | only start | 1 | | | 400 | string | - | only limit | | 25 | | 400 | string | - | without start and limit | | | | 400 | string | + | lowercase in Start | a | 1 | 0 | 400 | string | + | uppercase in Start | A | 1 | 0 | 400 | string | + | lowercase in Limit | 1 | a | 0 | 400 | string | + | uppercase in Limit | 1 | A | 0 | 400 | string | + | limit=3 | 1 | 3 | 3 | 200 | array | + | start=3 | 3 | 5 | 3 | 200 | array | + | limit and start =3 | 3 | 3 | 1 | 200 | array | + | high number for start | 1000 | 1 | 0 | 200 | array | + | high number for start | 1000 | 0 | 0 | 200 | array | + | empty result | 1 | 0 | 1 | 200 | array | + | empty string | 1 | 10000 | 1 | 200 | array | + | invalid start | b | 25 | 0 | 400 | string | + | invalid limit | 1 | c | 0 | 400 | string | + | start equals zero | 0 | 20 | 20 | 200 | array | + | search 0 | 0 | 0 | 0 | 200 | array | + | search 0 | 0 | 100 | 100 | 200 | array | + | negative numbers in start | -10 | 25 | 25 | 200 | array | + | negative numbers in limit | 1 | -25 | 25 | 200 | array | + | real numbers | 0.0 | 1.0 | 0 | 400 | string | + | real numbers in start | 0.0 | 25 | 0 | 400 | string | + | real numbers in limit | 1 | 1.4599 | 0 | 400 | string | + | only start | 1 | | 1 | 200 | array | + | only limit | | 25 | 1 | 200 | array | + | without start and limit | | | 1 | 200 | array | Scenario Outline: Get order type of Descending and Acending @@ -58,13 +129,13 @@ Scenario Outline: Get order type of Descending and Acending And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: | test_description | dir | records | - | Order for Acending | asc | | - | Order for Descending | desc | | + | Order for Acending | asc | 1 | + | Order for Descending | desc | 1 | Scenario Outline: Get order type of Process Category @@ -73,12 +144,12 @@ Scenario Outline: Get order type of Process Category And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: - | test_description | cat_uid | records | - | Filter for Category "Category Cases Lists" | 4177095085330818c324501061677193 | | + | test_description | cat_uid | records | + | Filter for Category "Category Cases Lists" | 4177095085330818c324501061677193 | 1 | | Filter all categories | | | @@ -88,7 +159,7 @@ Scenario Outline: Get order type of Process And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -103,7 +174,7 @@ Scenario Outline: Get order type of Search of number the process And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -117,7 +188,7 @@ Scenario: Returns a list of the cases for the logged in user (Draft) Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" - And the response has 1 records + And the response has records more than "" Scenario Outline: Get paging of list Draft @@ -126,35 +197,35 @@ Scenario Outline: Get paging of list Draft And the response charset is "UTF-8" And the content type is "application/json" And the type is "" - And the response has records + And the response has records more than "" Examples: | test_description | start | limit | records | http_code | type | - | lowercase in Start | a | 1 | | 200 | array | - | uppercase in Start | A | 1 | | 200 | array | - | lowercase in Limit | 1 | a | | 200 | array | - | uppercase in Limit | 1 | A | | 200 | array | - | limit=3 | 1 | 3 | | 200 | array | - | start=3 | 3 | 3 | | 200 | array | - | limit and start =3 | 3 | 3 | | 200 | array | - | high number for start | 1000 | 1 | | 200 | array | - | high number for start | 1000 | 0 | | 200 | array | - | empty result | 1 | 0 | | 200 | array | - | empty string | 1 | 10000 | | 200 | array | - | invalid start | b | 25 | | 400 | string | - | invalid limit | 1 | c | | 400 | string | - | start equals zero | 0 | 20 | | 400 | string | - | search 0 | 0 | 0 | | 200 | array | - | search 0 | 0 | 100 | | 200 | array | - | negative numbers in start | -10 | 25 | | 400 | string | - | negative numbers in limit | 1 | -25 | | 400 | string | - | real numbers | 0.0 | 1.0 | | 200 | string | - | real numbers in start | 0.0 | 25 | | 200 | string | - | real numbers in limit | 1 | 1.4599 | | 400 | string | - | only start | 1 | | | 400 | string | - | only limit | | 25 | | 400 | string | - | without start and limit | | | | 400 | string | + | lowercase in Start | a | 1 | 0 | 400 | string | + | uppercase in Start | A | 1 | 0 | 400 | string | + | lowercase in Limit | 1 | a | 0 | 400 | string | + | uppercase in Limit | 1 | A | 0 | 400 | string | + | limit=3 | 1 | 3 | 3 | 200 | array | + | start=3 | 3 | 25 | 22 | 200 | array | + | limit and start =3 | 3 | 3 | 1 | 200 | array | + | high number for start | 1000 | 1 | 0 | 200 | array | + | high number for start | 1000 | 0 | 0 | 200 | array | + | empty result | 1 | 0 | 1 | 200 | array | + | empty string | 1 | 10000 | 1 | 200 | array | + | invalid start | b | 25 | 0 | 400 | string | + | invalid limit | 1 | c | 0 | 400 | string | + | start equals zero | 0 | 20 | 20 | 200 | array | + | search 0 | 0 | 0 | 0 | 200 | array | + | search 0 | 0 | 100 | 100 | 200 | array | + | negative numbers in start | -10 | 25 | 25 | 200 | array | + | negative numbers in limit | 1 | -25 | 25 | 200 | array | + | real numbers | 0.0 | 1.0 | 0 | 400 | string | + | real numbers in start | 0.0 | 25 | 0 | 400 | string | + | real numbers in limit | 1 | 1.4599 | 0 | 400 | string | + | only start | 1 | | 1 | 200 | array | + | only limit | | 25 | 1 | 200 | array | + | without start and limit | | | 1 | 200 | array | Scenario Outline: Get order type of Descending and Ascending @@ -163,7 +234,7 @@ Scenario Outline: Get order type of Descending and Ascending And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -179,7 +250,7 @@ Scenario Outline: Get order type of Process Category And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -194,7 +265,7 @@ Scenario Outline: Get order type of Process And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -209,7 +280,7 @@ Scenario Outline: Get order type of Search of the process And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -223,7 +294,7 @@ Scenario: Returns a list of the cases for the logged in user (Participated) Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" - And the response has 6 records + And the response has records more than "" Scenario Outline: Get paging of list Participated @@ -232,35 +303,35 @@ Scenario Outline: Get paging of list Participated And the response charset is "UTF-8" And the content type is "application/json" And the type is "" - And the response has records + And the response has records more than "" Examples: | test_description | start | limit | records | http_code | type | - | lowercase in Start | a | 1 | | 200 | array | - | uppercase in Start | A | 1 | | 200 | array | - | lowercase in Limit | 1 | a | | 200 | array | - | uppercase in Limit | 1 | A | | 200 | array | - | limit=3 | 1 | 3 | | 200 | array | - | start=3 | 3 | 3 | | 200 | array | - | limit and start =3 | 3 | 3 | | 200 | array | - | high number for start | 1000 | 1 | | 200 | array | - | high number for start | 1000 | 0 | | 200 | array | - | empty result | 1 | 0 | | 200 | array | - | empty string | 1 | 10000 | | 200 | array | - | invalid start | b | 25 | | 400 | string | - | invalid limit | 1 | c | | 400 | string | - | start equals zero | 0 | 20 | | 400 | string | - | search 0 | 0 | 0 | | 200 | array | - | search 0 | 0 | 100 | | 200 | array | - | negative numbers in start | -10 | 25 | | 400 | string | - | negative numbers in limit | 1 | -25 | | 400 | string | - | real numbers | 0.0 | 1.0 | | 200 | string | - | real numbers in start | 0.0 | 25 | | 200 | string | - | real numbers in limit | 1 | 1.4599 | | 400 | string | - | only start | 1 | | | 400 | string | - | only limit | | 25 | | 400 | string | - | without start and limit | | | | 400 | string | + | lowercase in Start | a | 1 | 0 | 400 | string | + | uppercase in Start | A | 1 | 0 | 400 | string | + | lowercase in Limit | 1 | a | 0 | 400 | string | + | uppercase in Limit | 1 | A | 0 | 400 | string | + | limit=3 | 1 | 3 | 3 | 200 | array | + | start=3 | 3 | 25 | 22 | 200 | array | + | limit and start =3 | 3 | 3 | 1 | 200 | array | + | high number for start | 1000 | 1 | 0 | 200 | array | + | high number for start | 1000 | 0 | 0 | 200 | array | + | empty result | 1 | 0 | 1 | 200 | array | + | empty string | 1 | 10000 | 1 | 200 | array | + | invalid start | b | 25 | 0 | 400 | string | + | invalid limit | 1 | c | 0 | 400 | string | + | start equals zero | 0 | 20 | 20 | 200 | array | + | search 0 | 0 | 0 | 0 | 200 | array | + | search 0 | 0 | 100 | 100 | 200 | array | + | negative numbers in start | -10 | 25 | 25 | 200 | array | + | negative numbers in limit | 1 | -25 | 25 | 200 | array | + | real numbers | 0.0 | 1.0 | 0 | 400 | string | + | real numbers in start | 0.0 | 25 | 0 | 400 | string | + | real numbers in limit | 1 | 1.4599 | 0 | 400 | string | + | only start | 1 | | 1 | 200 | array | + | only limit | | 25 | 1 | 200 | array | + | without start and limit | | | 1 | 200 | array | Scenario Outline: Get order type of Descending an Descending @@ -269,7 +340,7 @@ Scenario Outline: Get order type of Descending an Descending And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -285,7 +356,7 @@ Scenario Outline: Get order type of Process Category And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -300,7 +371,7 @@ Scenario Outline: Get order type of Process And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -316,7 +387,7 @@ Scenario Outline: Get order type of Search And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -330,7 +401,7 @@ Scenario: Returns a list of the cases for the logged in user (Unassigned) Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" - And the response has 1 records + And the response has records more than "" Scenario Outline: Get paging of list Unassigned @@ -339,35 +410,35 @@ Scenario Outline: Get paging of list Unassigned And the response charset is "UTF-8" And the content type is "application/json" And the type is "" - And the response has records + And the response has records more than "" Examples: | test_description | start | limit | records | http_code | type | - | lowercase in Start | a | 1 | | 200 | array | - | uppercase in Start | A | 1 | | 200 | array | - | lowercase in Limit | 1 | a | | 200 | array | - | uppercase in Limit | 1 | A | | 200 | array | - | limit=3 | 1 | 3 | | 200 | array | - | start=3 | 3 | 3 | | 200 | array | - | limit and start =3 | 3 | 3 | | 200 | array | - | high number for start | 1000 | 1 | | 200 | array | - | high number for start | 1000 | 0 | | 200 | array | - | empty result | 1 | 0 | | 200 | array | - | empty string | 1 | 10000 | | 200 | array | - | invalid start | b | 25 | | 400 | string | - | invalid limit | 1 | c | | 400 | string | - | start equals zero | 0 | 20 | | 400 | string | - | search 0 | 0 | 0 | | 200 | array | - | search 0 | 0 | 100 | | 200 | array | - | negative numbers in start | -10 | 25 | | 400 | string | - | negative numbers in limit | 1 | -25 | | 400 | string | - | real numbers | 0.0 | 1.0 | | 200 | string | - | real numbers in start | 0.0 | 25 | | 200 | string | - | real numbers in limit | 1 | 1.4599 | | 400 | string | - | only start | 1 | | | 400 | string | - | only limit | | 25 | | 400 | string | - | without start and limit | | | | 400 | string | + | lowercase in Start | a | 1 | 0 | 400 | string | + | uppercase in Start | A | 1 | 0 | 400 | string | + | lowercase in Limit | 1 | a | 0 | 400 | string | + | uppercase in Limit | 1 | A | 0 | 400 | string | + | limit=3 | 1 | 3 | 3 | 200 | array | + | start=3 | 3 | 25 | 22 | 200 | array | + | limit and start =3 | 3 | 3 | 1 | 200 | array | + | high number for start | 1000 | 1 | 0 | 200 | array | + | high number for start | 1000 | 0 | 0 | 200 | array | + | empty result | 1 | 0 | 1 | 200 | array | + | empty string | 1 | 10000 | 1 | 200 | array | + | invalid start | b | 25 | 0 | 400 | string | + | invalid limit | 1 | c | 0 | 400 | string | + | start equals zero | 0 | 20 | 20 | 200 | array | + | search 0 | 0 | 0 | 0 | 200 | array | + | search 0 | 0 | 100 | 100 | 200 | array | + | negative numbers in start | -10 | 25 | 25 | 200 | array | + | negative numbers in limit | 1 | -25 | 25 | 200 | array | + | real numbers | 0.0 | 1.0 | 0 | 400 | string | + | real numbers in start | 0.0 | 25 | 0 | 400 | string | + | real numbers in limit | 1 | 1.4599 | 0 | 400 | string | + | only start | 1 | | 1 | 200 | array | + | only limit | | 25 | 1 | 200 | array | + | without start and limit | | | 1 | 200 | array | Scenario Outline: Get order type of Descending and Acending @@ -376,7 +447,7 @@ Scenario Outline: Get order type of Descending and Acending And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -391,7 +462,7 @@ Scenario Outline: Get order type of Process Category And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -406,7 +477,7 @@ Scenario Outline: Get order type of Process And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -421,7 +492,7 @@ Scenario Outline: Get order type of Search And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -436,7 +507,7 @@ Scenario: Returns a list of the cases for the logged in user (Paused) Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" - And the response has 1 records + And the response has records more than "" Scenario Outline: Get paging of list Paused @@ -445,35 +516,35 @@ Scenario Outline: Get paging of list Paused And the response charset is "UTF-8" And the content type is "application/json" And the type is "" - And the response has records + And the response has records more than "" Examples: | test_description | start | limit | records | http_code | type | - | lowercase in Start | a | 1 | | 200 | array | - | uppercase in Start | A | 1 | | 200 | array | - | lowercase in Limit | 1 | a | | 200 | array | - | uppercase in Limit | 1 | A | | 200 | array | - | limit=3 | 1 | 3 | | 200 | array | - | start=3 | 3 | 3 | | 200 | array | - | limit and start =3 | 3 | 3 | | 200 | array | - | high number for start | 1000 | 1 | | 200 | array | - | high number for start | 1000 | 0 | | 200 | array | - | empty result | 1 | 0 | | 200 | array | - | empty string | 1 | 10000 | | 200 | array | - | invalid start | b | 25 | | 400 | string | - | invalid limit | 1 | c | | 400 | string | - | start equals zero | 0 | 20 | | 400 | string | - | search 0 | 0 | 0 | | 200 | array | - | search 0 | 0 | 100 | | 200 | array | - | negative numbers in start | -10 | 25 | | 400 | string | - | negative numbers in limit | 1 | -25 | | 400 | string | - | real numbers | 0.0 | 1.0 | | 200 | string | - | real numbers in start | 0.0 | 25 | | 200 | string | - | real numbers in limit | 1 | 1.4599 | | 400 | string | - | only start | 1 | | | 400 | string | - | only limit | | 25 | | 400 | string | - | without start and limit | | | | 400 | string | + | lowercase in Start | a | 1 | 0 | 400 | string | + | uppercase in Start | A | 1 | 0 | 400 | string | + | lowercase in Limit | 1 | a | 0 | 400 | string | + | uppercase in Limit | 1 | A | 0 | 400 | string | + | limit=3 | 1 | 3 | 3 | 200 | array | + | start=3 | 3 | 25 | 22 | 200 | array | + | limit and start =3 | 3 | 3 | 1 | 200 | array | + | high number for start | 1000 | 1 | 0 | 200 | array | + | high number for start | 1000 | 0 | 0 | 200 | array | + | empty result | 1 | 0 | 1 | 200 | array | + | empty string | 1 | 10000 | 1 | 200 | array | + | invalid start | b | 25 | 0 | 400 | string | + | invalid limit | 1 | c | 0 | 400 | string | + | start equals zero | 0 | 20 | 20 | 200 | array | + | search 0 | 0 | 0 | 0 | 200 | array | + | search 0 | 0 | 100 | 100 | 200 | array | + | negative numbers in start | -10 | 25 | 25 | 200 | array | + | negative numbers in limit | 1 | -25 | 25 | 200 | array | + | real numbers | 0.0 | 1.0 | 0 | 400 | string | + | real numbers in start | 0.0 | 25 | 0 | 400 | string | + | real numbers in limit | 1 | 1.4599 | 0 | 400 | string | + | only start | 1 | | 1 | 200 | array | + | only limit | | 25 | 1 | 200 | array | + | without start and limit | | | 1 | 200 | array | Scenario Outline: Get order type of Descending and Acending @@ -482,7 +553,7 @@ Scenario Outline: Get order type of Descending and Acending And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -497,7 +568,7 @@ Scenario Outline: Get order type of Process Category And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -512,7 +583,7 @@ Scenario Outline: Get order type of Process And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -527,7 +598,7 @@ Scenario Outline: Get order type of Search And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -541,7 +612,7 @@ Scenario: Returns a list of the cases for the logged in user (Advanced Search) Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" - And the response has 1 records + And the response has records more than "" Scenario Outline: Get paging of list Advanced Search @@ -550,35 +621,35 @@ Scenario Outline: Get paging of list Advanced Search And the response charset is "UTF-8" And the content type is "application/json" And the type is "" - And the response has records + And the response has records more than "" Examples: | test_description | start | limit | records | http_code | type | - | lowercase in Start | a | 1 | | 200 | array | - | uppercase in Start | A | 1 | | 200 | array | - | lowercase in Limit | 1 | a | | 200 | array | - | uppercase in Limit | 1 | A | | 200 | array | - | limit=3 | 1 | 3 | | 200 | array | - | start=3 | 3 | 3 | | 200 | array | - | limit and start =3 | 3 | 3 | | 200 | array | - | high number for start | 1000 | 1 | | 200 | array | - | high number for start | 1000 | 0 | | 200 | array | - | empty result | 1 | 0 | | 200 | array | - | empty string | 1 | 10000 | | 200 | array | - | invalid start | b | 25 | | 400 | string | - | invalid limit | 1 | c | | 400 | string | - | start equals zero | 0 | 20 | | 400 | string | - | search 0 | 0 | 0 | | 200 | array | - | search 0 | 0 | 100 | | 200 | array | - | negative numbers in start | -10 | 25 | | 400 | string | - | negative numbers in limit | 1 | -25 | | 400 | string | - | real numbers | 0.0 | 1.0 | | 200 | string | - | real numbers in start | 0.0 | 25 | | 200 | string | - | real numbers in limit | 1 | 1.4599 | | 400 | string | - | only start | 1 | | | 400 | string | - | only limit | | 25 | | 400 | string | - | without start and limit | | | | 400 | string | + | lowercase in Start | a | 1 | 0 | 400 | string | + | uppercase in Start | A | 1 | 0 | 400 | string | + | lowercase in Limit | 1 | a | 0 | 400 | string | + | uppercase in Limit | 1 | A | 0 | 400 | string | + | limit=3 | 1 | 3 | 3 | 200 | array | + | start=3 | 3 | 25 | 22 | 200 | array | + | limit and start =3 | 3 | 3 | 1 | 200 | array | + | high number for start | 1000 | 1 | 0 | 200 | array | + | high number for start | 1000 | 0 | 0 | 200 | array | + | empty result | 1 | 0 | 1 | 200 | array | + | empty string | 1 | 10000 | 1 | 200 | array | + | invalid start | b | 25 | 0 | 400 | string | + | invalid limit | 1 | c | 0 | 400 | string | + | start equals zero | 0 | 20 | 20 | 200 | array | + | search 0 | 0 | 0 | 0 | 200 | array | + | search 0 | 0 | 100 | 100 | 200 | array | + | negative numbers in start | -10 | 25 | 25 | 200 | array | + | negative numbers in limit | 1 | -25 | 25 | 200 | array | + | real numbers | 0.0 | 1.0 | 0 | 400 | string | + | real numbers in start | 0.0 | 25 | 0 | 400 | string | + | real numbers in limit | 1 | 1.4599 | 0 | 400 | string | + | only start | 1 | | 1 | 200 | array | + | only limit | | 25 | 1 | 200 | array | + | without start and limit | | | 1 | 200 | array | Scenario Outline: Get order type of Descending and Acending @@ -587,7 +658,7 @@ Scenario Outline: Get order type of Descending and Acending And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -602,7 +673,7 @@ Scenario Outline: Get order type of Process Category And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -618,7 +689,7 @@ Scenario Outline: Get order type of Process And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -634,7 +705,7 @@ Scenario Outline: Get order type of Search And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -649,7 +720,7 @@ Scenario Outline: Get order for Status And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -666,7 +737,7 @@ Scenario Outline: Get order for User And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: @@ -683,7 +754,7 @@ Scenario Outline: Get order for date And the response charset is "UTF-8" And the content type is "application/json" And the type is "array" - And the response has records + And the response has records more than "" Examples: 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 94ae0389b..b9cb57ee8 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 @@ -1,37 +1,41 @@ @ProcessMakerMichelangelo @RestAPI Feature: Input Documents cases Requirements: - a workspace with three cases of the process "Test Users-Step-Properties End Point" + a workspace with one case of the process "Test Input Document Case" + and there are three Input Document in the process Background: Given that I have a valid access_token Scenario: Returns a list of the uploaded documents for a given case - Given I request "case{uid}/input-documents" + Given I request "cases/3980158475331a1a0288fd3009853776/input-documents" Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" - + And the response has 5 records + Scenario: Returns an uploaded documents for a given case - Given I request "case/{uid}/input-document/{uid}" + Given I request "cases/3980158475331a1a0288fd3009853776/input-document/6075490825331a1c5eebff9015468244" 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: Post metadata and then upload documents for a given case - Given POST this data: + Given POST upload an input document "/home/wendy/uploadfiles/test1.html" to "cases/3980158475331a1a0288fd3009853776/input-document" """ { - + "inp_doc_uid": "inp_doc_uid", + "tas_uid": "tas_uid", + "app_doc_comment": "app_doc_comment" + } """ - And I request "case/{uid}/input-document" - Then the response status code should be 201 + 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" @@ -40,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 "case/{uid}/input-document/{uid}" + And I request "cases/3980158475331a1a0288fd3009853776/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 e69de29bb..a8759f067 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 @@ -0,0 +1,41 @@ +@ProcessMakerMichelangelo @RestAPI +Feature: Input Documents cases +Requirements: + a workspace with one case of the process "Test Input Document Case" + and there are three Input Document in the process and the verify in one case + +Background: + Given that I have a valid access_token + + +Scenario: Returns a list of the uploaded documents for a given case + Given I request "cases/3980158475331a1a0288fd3009853776/input-documents" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "array" + And the response has 5 records + + +Scenario Outline: Returns an uploaded documents for a given case + Given I request "cases/3980158475331a1a0288fd3009853776/input-document/" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "object" + And the "app_doc_uid" property equals "" + And the "app_doc_filename" property equals "" + And the "doc_uid" property equals "" + And the "app_doc_version" property equals "" + And the "app_doc_create_date" property equals "" + And the "app_doc_create_user" property equals "" + And the "app_doc_type" property equals "" + And the "app_doc_index" property equals "" + And the "app_doc_link" property equals "" + + Examples: + + | test_description | input-document | app_doc_uid | app_doc_filename | doc_uid | app_doc_version | app_doc_create_date | app_doc_create_user | app_doc_type | app_doc_index | app_doc_link | + | Get Input "Desert.jpg" | 6075490825331a1c5eebff9015468244 | 6075490825331a1c5eebff9015468244 | Desert.jpg | 68671480353319e5e1dee74089764900 | 1 | 2014-03-25 11:33:25 | , Administrator (admin) | INPUT | 1 | cases/cases_ShowDocument?a=6075490825331a1c5eebff9015468244&v=1 | + | 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 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 1d3e71069..aacca954c 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 @@ -1,42 +1,42 @@ @ProcessMakerMichelangelo @RestAPI Feature: Output Documents cases Requirements: - a workspace with three cases of the process "Test Users-Step-Properties End Point" + a workspace with one case of the process "Test Output Document Case" + and there are six Output Documents in the process Background: Given that I have a valid access_token -Scenario: Returns a list of the generated documents for a given case - Given I request "case{uid}/output-documents" +Scenario: Returns a list of the generated documents for a given cases + Given I request "cases/24438110553330068247694030259829/output-documents" Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" + And the response has 6 records -Scenario: Returns an uploaded documents for a given case - Given I request "case/{uid}/output-document/{uid}" +Scenario: Returns an generated document for a given case + Given I request "cases/24438110553330068247694030259829/output-document/3000248055333006ab56a01005891659" 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: Generate or regenerates an output documents for a given case Given POST this data: """ { - - - + "out_doc_uid": "2087233055331ef4127d238097105696" } """ - And I request "case/{uid}/output-document" + And I request "case/24438110553330068247694030259829/output-document" 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 - + And the type is "array" + + 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 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 e69de29bb..f75a6bf64 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 @@ -0,0 +1,95 @@ +@ProcessMakerMichelangelo @RestAPI +Feature: Output Documents cases Main Tests +Requirements: + a workspace with one case of the process "Test Output Document Case" + and there are six Output Documents in the process + +Background: + Given that I have a valid access_token + + +Scenario Outline: Generate or regenerates an output documents for a given case + Given POST this data: + """ + { + "out_doc_uid": "" + } + """ + And I request "cases/551390121533343ee886813057396196/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_" + + Examples: + + | test_description | app_doc_uid_number | out_doc_uid | + | Generate "output document only doc" | 1 | 2087233055331ef4127d238097105696 | + | Generate "output document with versioning" | 2 | 5961108155331efc976cee7011445347 | + | Generate "output document only pdf" | 3 | 7074907425331ef837aa8b2055964905 | + | Generate "output document old version" | 4 | 7385645355331ee70ea6a87029841722 | + | Generate "output document with pdf security" | 5 | 8594478445331eff2d30767061922215 | + + +Scenario: Returns a list of the generated documents for a given cases + Given I request "cases/551390121533343ee886813057396196/output-documents" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "array" + And the response has 6 records + And the "app_doc_filename" property in row 0 equals "output document new version.pdf" + And the "app_doc_filename" property in row 1 equals "output document with pdf security.pdf" + And the "app_doc_filename" property in row 2 equals "output document only pdf.pdf" + And the "app_doc_filename" property in row 3 equals "output document only doc.doc" + And the "app_doc_filename" property in row 4 equals "output document with versioning.pdf" + And the "app_doc_filename" property in row 5 equals "output document old version.pdf" + + +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_" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "Object" + And the "app_doc_uid" property equals "" + And the "app_doc_filename" property equals "" + And the "doc_uid" property equals "" + And the "app_doc_version" property equals "" + And the "app_doc_create_date" property equals "" + And the "app_doc_create_user" property equals "" + And the "app_doc_type" property equals "" + And the "app_doc_index" property equals "" + And the "app_doc_link" property equals "" + + + Examples: + + | test_description | app_doc_uid_number | app_doc_filename | doc_uid | app_doc_version | app_doc_create_date | app_doc_create_user | app_doc_type | app_doc_index | app_doc_link | + | Get Output "output document new version.pdf" | 1 | output document new version.pdf | 3391282325331ee81c84715031595672 | 1 | 2014-03-26 12:29:30 | , Administrator (admin) | OUTPUT BOTH | 1 | cases/cases_ShowOutputDocument?a=3000248055333006ab56a01005891659&v=1&ext=pdf&random=1256696859 | + | Get Output "output document old version.pdf" | 2 | output document old version.pdf | 7385645355331ee70ea6a87029841722 | 1 | 2014-03-26 12:29:33 | , Administrator (admin) | OUTPUT BOTH | 2 | cases/cases_ShowOutputDocument?a=8865432395333006d75d824038425476&v=1&ext=pdf&random=1838956992 | + | Get Output "output document only doc.doc" | 3 | output document only doc.doc | 2087233055331ef4127d238097105696 | 1 | 2014-03-26 12:29:35 | , Administrator (admin) | OUTPUT DOC | 3 | cases/cases_ShowOutputDocument?a=4447256265333006fe6fb00061503934&v=1&ext=doc&random=949245639 | + | Get Output "output document only pdf.pdf" | 4 | output document only pdf.pdf | 7074907425331ef837aa8b2055964905 | 1 | 2014-03-26 12:29:38 | , Administrator (admin) | OUTPUT PDF | 4 | cases/cases_ShowOutputDocument?a=828039615533300724fdcb6091842678&v=1&ext=pdf&random=401448562 | + | Get Output "output document with pdf security.pdf" | 5 | output document with pdf security.pdf | 8594478445331eff2d30767061922215 | 1 | 2014-03-26 12:29:40 | , Administrator (admin) | OUTPUT BOTH | 5 | cases/cases_ShowOutputDocument?a=25293137553330074713ab9073501576&v=1&ext=pdf&random=324546362 | + | Get Output "output document with versioning.pdf" | 6 | output document with versioning.pdf | 5961108155331efc976cee7011445347 | 1 | 2014-03-26 12:29:42 | , Administrator (admin) | OUTPUT BOTH | 6 | cases/cases_ShowOutputDocument?a=354826487533300769e65e0027827984&v=1&ext=pdf&random=1682978530 | + + + +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 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 | + + + \ No newline at end of file diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index 328603c94..bec47be6e 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -1191,6 +1191,8 @@ class RestContext extends BehatContext } $this->_restDeleteQueryStringSuffix = "/" . $varValue; + + $this->printDebug("$varName = $varValue\nsessionVarName = $sessionVarName\n"); $this->_restObjectMethod = 'delete'; } @@ -1259,7 +1261,7 @@ class RestContext extends BehatContext $pageUrl = str_replace($varName, $varValue, $pageUrl); - //$this->printDebug("URL: $pageUrl\n$varName = $varValue\n"); + $this->printDebug("URL: $pageUrl\n$varName = $varValue\nsessionVarName = $sessionVarName\n"); $this->iRequest($pageUrl, $urlType); @@ -1435,4 +1437,87 @@ class RestContext extends BehatContext $this->_restObjectMethod = 'delete'; } + /** + * @Given /^store response count in session variable as "([^"]*)"$/ + */ + public function storeResponseCountInSessionVariableAs($varName) + { + $data = $this->_data; + $currentRecordsCount=count($data); + if (file_exists("session.data")) { + $sessionData = json_decode(file_get_contents("session.data")); + } else { + $sessionData = new StdClass(); + } + $sessionData->$varName = $currentRecordsCount; + file_put_contents("session.data", json_encode($sessionData)); + } + + + /** + * @Given /^the response has (\d+) records more than "([^"]*)"$/ + */ + public function theResponseHasRecordsMoreThan($records, $base) + { + if (file_exists("session.data")) { + $sessionData = json_decode(file_get_contents("session.data")); + } else { + $sessionData = array(); + } + if (!isset($sessionData->$base) ) { + $varValue = ''; + } else { + $varValue = $sessionData->$base; + } + + $totalRecords=$varValue + $records; + + $this->theResponseHasRecords($totalRecords); + } + + + /** + * @Given /^POST upload an input document "([^"]*)" to "([^"]*)"$/ + */ + 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); + + + + + + } + + + + + } diff --git a/gulliver/js/ext/pmos-common.js b/gulliver/js/ext/pmos-common.js index 288569aa5..e6978ca33 100755 --- a/gulliver/js/ext/pmos-common.js +++ b/gulliver/js/ext/pmos-common.js @@ -15,6 +15,7 @@ PMExtJSCommon = function() { this.info = function(title, msg, fn) { Ext.MessageBox.show({ + id: 'infoMessageBox', title: title, msg: msg, buttons: Ext.MessageBox.OK, @@ -26,6 +27,7 @@ PMExtJSCommon = function() { this.question = function(title, msg, fn) { Ext.MessageBox.show({ + id: 'questionMessageBox', title: title, msg: msg, buttons: Ext.MessageBox.YESNO, @@ -40,6 +42,7 @@ PMExtJSCommon = function() { this.warning = function(title, msg, fn) { Ext.MessageBox.show({ + id: 'warningMessageBox', title: title, msg: msg, buttons: Ext.MessageBox.OK, @@ -51,6 +54,7 @@ PMExtJSCommon = function() { this.error = function(title, msg, fn) { Ext.MessageBox.show({ + id: 'errorMessageBox', title: title, msg: msg, buttons: Ext.MessageBox.OK, diff --git a/workflow/engine/classes/class.applications.php b/workflow/engine/classes/class.applications.php index 440d70375..f559b08ce 100755 --- a/workflow/engine/classes/class.applications.php +++ b/workflow/engine/classes/class.applications.php @@ -527,7 +527,7 @@ class Applications // replacing the status data with their respective translation if (isset( $aRow['APP_STATUS'] )) { - $aRow['APP_STATUS'] = G::LoadTranslation( "ID_{$aRow['APP_STATUS']}" ); + $aRow['APP_STATUS_LABEL'] = G::LoadTranslation( "ID_{$aRow['APP_STATUS']}" ); } // replacing the priority data with their respective translation diff --git a/workflow/engine/classes/class.configuration.php b/workflow/engine/classes/class.configuration.php index 9045f07d0..5d4853cc6 100755 --- a/workflow/engine/classes/class.configuration.php +++ b/workflow/engine/classes/class.configuration.php @@ -667,7 +667,7 @@ class Configurations // extends Configuration $caseReaderFields[] = array("name" => "USR_UID"); $caseReaderFields[] = array("name" => "PREVIOUS_USR_UID"); $caseReaderFields[] = array("name" => "APP_NUMBER"); - $caseReaderFields[] = array("name" => "APP_STATUS"); + $caseReaderFields[] = array("name" => "APP_STATUS_LABEL"); $caseReaderFields[] = array("name" => "DEL_INDEX"); $caseReaderFields[] = array("name" => "APP_TITLE"); $caseReaderFields[] = array("name" => "APP_PRO_TITLE"); @@ -677,7 +677,7 @@ class Configurations // extends Configuration $caseReaderFields[] = array("name" => "DEL_TASK_DUE_DATE"); $caseReaderFields[] = array("name" => "APP_UPDATE_DATE"); $caseReaderFields[] = array("name" => "DEL_PRIORITY"); - $caseReaderFields[] = array("name" => "APP_STATUS"); + $caseReaderFields[] = array("name" => "APP_STATUS_LABEL"); $caseReaderFields[] = array("name" => "APP_FINISH_DATE"); $caseReaderFields[] = array("name" => "CASE_SUMMARY"); $caseReaderFields[] = array("name" => "CASE_NOTES_COUNT"); @@ -702,7 +702,7 @@ class Configurations // extends Configuration $caseReaderFields[] = array("name" => "PREVIOUS_USR_LASTNAME"); $caseReaderFields[] = array("name" => "PREVIOUS_USR_USERNAME"); $caseReaderFields[] = array("name" => "APP_NUMBER"); - $caseReaderFields[] = array("name" => "APP_STATUS"); + $caseReaderFields[] = array("name" => "APP_STATUS_LABEL"); $caseReaderFields[] = array("name" => "DEL_INDEX"); $caseReaderFields[] = array("name" => "APP_TITLE"); $caseReaderFields[] = array("name" => "APP_PRO_TITLE"); @@ -712,7 +712,7 @@ class Configurations // extends Configuration $caseReaderFields[] = array("name" => "DEL_TASK_DUE_DATE"); $caseReaderFields[] = array("name" => "APP_UPDATE_DATE"); $caseReaderFields[] = array("name" => "DEL_PRIORITY"); - $caseReaderFields[] = array("name" => "APP_STATUS"); + $caseReaderFields[] = array("name" => "APP_STATUS_LABEL"); $caseReaderFields[] = array("name" => "APP_FINISH_DATE"); $caseReaderFields[] = array("name" => "APP_THREAD_INDEX"); $caseReaderFields[] = array("name" => "CASE_SUMMARY"); @@ -739,7 +739,7 @@ class Configurations // extends Configuration $caseReaderFields[] = array("name" => "PREVIOUS_USR_LASTNAME"); $caseReaderFields[] = array("name" => "PREVIOUS_USR_USERNAME"); $caseReaderFields[] = array("name" => "APP_NUMBER"); - $caseReaderFields[] = array("name" => "APP_STATUS"); + $caseReaderFields[] = array("name" => "APP_STATUS_LABEL"); $caseReaderFields[] = array("name" => "DEL_INDEX"); $caseReaderFields[] = array("name" => "APP_TITLE"); $caseReaderFields[] = array("name" => "APP_PRO_TITLE"); @@ -749,7 +749,7 @@ class Configurations // extends Configuration $caseReaderFields[] = array("name" => "DEL_TASK_DUE_DATE"); $caseReaderFields[] = array("name" => "APP_UPDATE_DATE"); $caseReaderFields[] = array("name" => "DEL_PRIORITY"); - $caseReaderFields[] = array("name" => "APP_STATUS"); + $caseReaderFields[] = array("name" => "APP_STATUS_LABEL"); $caseReaderFields[] = array("name" => "APP_FINISH_DATE"); $caseReaderFields[] = array("name" => "CASE_SUMMARY"); $caseReaderFields[] = array("name" => "CASE_NOTES_COUNT"); @@ -766,7 +766,7 @@ class Configurations // extends Configuration $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_TASK") : "**ID_TASK**", "dataIndex" => "APP_TAS_TITLE", "width" => 120); $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_CURRENT_USER") : "**ID_CURRENT_USER**", "dataIndex" => "APP_CURRENT_USER", "width" => 120, "sortable" => true); $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_LAST_MODIFY") : "**ID_LAST_MODIFY**", "dataIndex" => "APP_UPDATE_DATE", "width" => 80); - $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_STATUS") : "**ID_STATUS**", "dataIndex" => "APP_STATUS", "width" => 50); + $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_STATUS") : "**ID_STATUS**", "dataIndex" => "APP_STATUS_LABEL", "width" => 50); $caseReaderFields[] = array("name" => "APP_UID"); $caseReaderFields[] = array("name" => "USR_UID"); @@ -775,7 +775,7 @@ class Configurations // extends Configuration $caseReaderFields[] = array("name" => "PREVIOUS_USR_LASTNAME"); $caseReaderFields[] = array("name" => "PREVIOUS_USR_USERNAME"); $caseReaderFields[] = array("name" => "APP_NUMBER"); - $caseReaderFields[] = array("name" => "APP_STATUS"); + $caseReaderFields[] = array("name" => "APP_STATUS_LABEL"); $caseReaderFields[] = array("name" => "DEL_INDEX"); $caseReaderFields[] = array("name" => "APP_TITLE"); $caseReaderFields[] = array("name" => "APP_PRO_TITLE"); @@ -785,7 +785,7 @@ class Configurations // extends Configuration $caseReaderFields[] = array("name" => "DEL_TASK_DUE_DATE"); $caseReaderFields[] = array("name" => "APP_UPDATE_DATE"); $caseReaderFields[] = array("name" => "DEL_PRIORITY"); - $caseReaderFields[] = array("name" => "APP_STATUS"); + $caseReaderFields[] = array("name" => "APP_STATUS_LABEL"); $caseReaderFields[] = array("name" => "APP_FINISH_DATE"); $caseReaderFields[] = array("name" => "CASE_SUMMARY"); $caseReaderFields[] = array("name" => "CASE_NOTES_COUNT"); @@ -805,13 +805,13 @@ class Configurations // extends Configuration $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_LAST_MODIFY") : "**ID_LAST_MODIFY**", "dataIndex" => "APP_UPDATE_DATE", "width" => 80); $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_DELEGATION_DATE") : "**ID_DELEGATION_DATE**", "dataIndex" => "DEL_DELEGATE_DATE", "width" => 80); $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_DUE_DATE") : "**ID_DUE_DATE**", "dataIndex" => "DEL_TASK_DUE_DATE", "width" => 80); - $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_STATUS") : "**ID_STATUS**", "dataIndex" => "APP_STATUS", "width" => 50); + $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_STATUS") : "**ID_STATUS**", "dataIndex" => "APP_STATUS_LABEL", "width" => 50); $caseReaderFields[] = array("name" => "APP_UID"); $caseReaderFields[] = array("name" => "USR_UID"); $caseReaderFields[] = array("name" => "PREVIOUS_USR_UID"); $caseReaderFields[] = array("name" => "APP_NUMBER"); - $caseReaderFields[] = array("name" => "APP_STATUS"); + $caseReaderFields[] = array("name" => "APP_STATUS_LABEL"); $caseReaderFields[] = array("name" => "DEL_INDEX"); $caseReaderFields[] = array("name" => "APP_TITLE"); $caseReaderFields[] = array("name" => "APP_PRO_TITLE"); @@ -822,7 +822,7 @@ class Configurations // extends Configuration $caseReaderFields[] = array("name" => "APP_UPDATE_DATE"); $caseReaderFields[] = array("name" => "DEL_DELEGATE_DATE"); $caseReaderFields[] = array("name" => "DEL_PRIORITY"); - $caseReaderFields[] = array("name" => "APP_STATUS"); + $caseReaderFields[] = array("name" => "APP_STATUS_LABEL"); $caseReaderFields[] = array("name" => "APP_FINISH_DATE"); $caseReaderFields[] = array("name" => "CASE_SUMMARY"); $caseReaderFields[] = array("name" => "CASE_NOTES_COUNT"); @@ -841,7 +841,7 @@ class Configurations // extends Configuration //$caseColumns[] = array("header" => "Sent By", "dataIndex" => "APP_DEL_PREVIOUS_USER", "width" => 90); //$caseColumns[] = array("header" => ($translation == 1)? G::LoadTranslation("ID_LAST_MODIFY") : "**ID_LAST_MODIFY**", "dataIndex" => "APP_UPDATE_DATE", "width" => 110); $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_PRIORITY") : "**ID_PRIORITY**", "dataIndex" => "DEL_PRIORITY", "width" => 50); - $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_STATUS") : "**ID_STATUS**", "dataIndex" => "APP_STATUS", "width" => 50); + $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_STATUS") : "**ID_STATUS**", "dataIndex" => "APP_STATUS_LABEL", "width" => 50); $caseReaderFields[] = array("name" => "APP_UID"); $caseReaderFields[] = array("name" => "USR_UID"); @@ -859,7 +859,7 @@ class Configurations // extends Configuration $caseReaderFields[] = array("name" => "DEL_TASK_DUE_DATE"); $caseReaderFields[] = array("name" => "APP_UPDATE_DATE"); $caseReaderFields[] = array("name" => "DEL_PRIORITY"); - $caseReaderFields[] = array("name" => "APP_STATUS"); + $caseReaderFields[] = array("name" => "APP_STATUS_LABEL"); $caseReaderFields[] = array("name" => "APP_FINISH_DATE"); $caseReaderFields[] = array("name" => "APP_DEL_PREVIOUS_USER"); $caseReaderFields[] = array("name" => "CASE_SUMMARY"); @@ -877,7 +877,7 @@ class Configurations // extends Configuration $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_CURRENT_USER") : "**ID_CURRENT_USER**", "dataIndex" => "APP_CURRENT_USER", "width" => 90, "sortable" => true); //$caseColumns[] = array("header" => ($translation == 1)? G::LoadTranslation("ID_SENT_BY") : "**ID_SENT_BY**", "dataIndex" => "APP_DEL_PREVIOUS_USER", "width" => 90); $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_LAST_MODIFY") : "**ID_LAST_MODIFY**", "dataIndex" => "APP_UPDATE_DATE", "width" => 110); - $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_STATUS") : "**ID_STATUS**", "dataIndex" => "APP_STATUS", "width" => 50); + $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_STATUS") : "**ID_STATUS**", "dataIndex" => "APP_STATUS_LABEL", "width" => 50); $caseReaderFields[] = array("name" => "TAS_UID"); $caseReaderFields[] = array("name" => "DEL_INDEX"); @@ -891,7 +891,7 @@ class Configurations // extends Configuration $caseReaderFields[] = array("name" => "APP_CURRENT_USER"); //$caseReaderFields[] = array("name" => "APP_DEL_PREVIOUS_USER"); $caseReaderFields[] = array("name" => "APP_UPDATE_DATE"); - $caseReaderFields[] = array("name" => "APP_STATUS"); + $caseReaderFields[] = array("name" => "APP_STATUS_LABEL"); $caseReaderFields[] = array("name" => "CASE_SUMMARY"); $caseReaderFields[] = array("name" => "CASE_NOTES_COUNT"); break; @@ -907,7 +907,7 @@ class Configurations // extends Configuration $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_CURRENT_USER") : "**ID_CURRENT_USER**", "dataIndex" => "APP_CURRENT_USER", "width" => 90, "sortable" => false); $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_SENT_BY") : "**ID_SENT_BY**", "dataIndex" => "APP_DEL_PREVIOUS_USER", "width" => 90); $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_LAST_MODIFY") : "**ID_LAST_MODIFY**", "dataIndex" => "APP_UPDATE_DATE", "width" => 110); - $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_STATUS") : "**ID_STATUS**", "dataIndex" => "APP_STATUS", "width" => 50); + $caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_STATUS") : "**ID_STATUS**", "dataIndex" => "APP_STATUS_LABEL", "width" => 50); $caseReaderFields[] = array("name" => "APP_UID"); $caseReaderFields[] = array("name" => "USR_UID"); @@ -919,7 +919,7 @@ class Configurations // extends Configuration $caseReaderFields[] = array("name" => "APP_CURRENT_USER"); $caseReaderFields[] = array("name" => "APP_DEL_PREVIOUS_USER"); $caseReaderFields[] = array("name" => "APP_UPDATE_DATE"); - $caseReaderFields[] = array("name" => "APP_STATUS"); + $caseReaderFields[] = array("name" => "APP_STATUS_LABEL"); $caseReaderFields[] = array("name" => "CASE_SUMMARY"); $caseReaderFields[] = array("name" => "CASE_NOTES_COUNT"); break; @@ -955,7 +955,7 @@ class Configurations // extends Configuration $caseReaderFields[] = array("name" => "DEL_PRIORITY"); $caseReaderFields[] = array("name" => "APP_FINISH_DATE"); $caseReaderFields[] = array("name" => "APP_CURRENT_USER"); - $caseReaderFields[] = array("name" => "APP_STATUS"); + $caseReaderFields[] = array("name" => "APP_STATUS_LABEL"); $caseReaderFields[] = array("name" => "CASE_SUMMARY"); $caseReaderFields[] = array("name" => "CASE_NOTES_COUNT"); break; diff --git a/workflow/engine/classes/class.processMap.php b/workflow/engine/classes/class.processMap.php index ca87b9004..2d2a65c03 100755 --- a/workflow/engine/classes/class.processMap.php +++ b/workflow/engine/classes/class.processMap.php @@ -4555,6 +4555,7 @@ class processMap { try { $oTask = new Task(); + $oNewTask = new StdClass(); $oNewTask->label = G::LoadTranslation('ID_SUBPROCESS'); $oNewTask->uid = $oTask->create(array('PRO_UID' => $sProcessUID, 'TAS_TITLE' => $oNewTask->label, 'TAS_POSX' => $iX, 'TAS_POSY' => $iY, 'TAS_TYPE' => 'SUBPROCESS' )); //$oJSON = new Services_JSON(); diff --git a/workflow/engine/classes/model/AppDelegation.php b/workflow/engine/classes/model/AppDelegation.php index 5141aa304..1993e047c 100755 --- a/workflow/engine/classes/model/AppDelegation.php +++ b/workflow/engine/classes/model/AppDelegation.php @@ -522,5 +522,18 @@ class AppDelegation extends BaseAppDelegation $data = $oRuleSet->getRow(); return (int)$data['DEL_INDEX']; } + + public function getCurrentTask ($appUid) + { + $oCriteria = new Criteria(); + $oCriteria->addSelectColumn( AppDelegationPeer::TAS_UID ); + $oCriteria->add( AppDelegationPeer::APP_UID, $appUid ); + $oCriteria->addDescendingOrderByColumn( AppDelegationPeer::DEL_INDEX ); + $oRuleSet = AppDelegationPeer::doSelectRS( $oCriteria ); + $oRuleSet->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oRuleSet->next(); + $data = $oRuleSet->getRow(); + return $data['TAS_UID']; + } } diff --git a/workflow/engine/classes/model/BpmnActivity.php b/workflow/engine/classes/model/BpmnActivity.php index 3e8af7ee2..1c4d1e626 100644 --- a/workflow/engine/classes/model/BpmnActivity.php +++ b/workflow/engine/classes/model/BpmnActivity.php @@ -112,7 +112,7 @@ class BpmnActivity extends BaseBpmnActivity $this->setBoundDefaults(); if ($this->bound->getBouUid() == "") { - $this->bound->setBouUid(\ProcessMaker\Util\Hash::generateUID()); + $this->bound->setBouUid(\ProcessMaker\Util\Common::generateUID()); } $this->bound->save($con); @@ -142,7 +142,7 @@ class BpmnActivity extends BaseBpmnActivity $this->bound = $bound; } else { $this->bound = new BpmnBound(); - $this->bound->setBouUid(ProcessMaker\Util\Hash::generateUID()); + $this->bound->setBouUid(ProcessMaker\Util\Common::generateUID()); } $this->bound->fromArray($data, BasePeer::TYPE_FIELDNAME); diff --git a/workflow/engine/classes/model/BpmnEvent.php b/workflow/engine/classes/model/BpmnEvent.php index 9a1446b03..57859f34c 100644 --- a/workflow/engine/classes/model/BpmnEvent.php +++ b/workflow/engine/classes/model/BpmnEvent.php @@ -112,7 +112,7 @@ class BpmnEvent extends BaseBpmnEvent $this->setBoundDefaults(); if ($this->bound->getBouUid() == "") { - $this->bound->setBouUid(\ProcessMaker\Util\Hash::generateUID()); + $this->bound->setBouUid(\ProcessMaker\Util\Common::generateUID()); } $this->bound->save($con); @@ -142,7 +142,7 @@ class BpmnEvent extends BaseBpmnEvent $this->bound = $bound; } else { $this->bound = new BpmnBound(); - $this->bound->setBouUid(ProcessMaker\Util\Hash::generateUID()); + $this->bound->setBouUid(ProcessMaker\Util\Common::generateUID()); } $this->bound->fromArray($data, BasePeer::TYPE_FIELDNAME); diff --git a/workflow/engine/classes/model/BpmnGateway.php b/workflow/engine/classes/model/BpmnGateway.php index 5a5be2835..c402532e7 100644 --- a/workflow/engine/classes/model/BpmnGateway.php +++ b/workflow/engine/classes/model/BpmnGateway.php @@ -117,7 +117,7 @@ class BpmnGateway extends BaseBpmnGateway $this->setBoundDefaults(); if ($this->bound->getBouUid() == "") { - $this->bound->setBouUid(\ProcessMaker\Util\Hash::generateUID()); + $this->bound->setBouUid(\ProcessMaker\Util\Common::generateUID()); } $this->bound->save($con); @@ -147,7 +147,7 @@ class BpmnGateway extends BaseBpmnGateway $this->bound = $bound; } else { $this->bound = new BpmnBound(); - $this->bound->setBouUid(ProcessMaker\Util\Hash::generateUID()); + $this->bound->setBouUid(ProcessMaker\Util\Common::generateUID()); } $this->bound->fromArray($data, BasePeer::TYPE_FIELDNAME); diff --git a/workflow/engine/classes/model/Process.php b/workflow/engine/classes/model/Process.php index 890baaf18..59f09b020 100755 --- a/workflow/engine/classes/model/Process.php +++ b/workflow/engine/classes/model/Process.php @@ -149,7 +149,7 @@ class Process extends BaseProcess * $aData['PRO_UID'] the process id * $aData['USR_UID'] the userid * $aData['PRO_CATEGORY'] the id category - * @return void + * @return string */ public function create ($aData, $generateUid = true) diff --git a/workflow/engine/classes/model/SubProcess.php b/workflow/engine/classes/model/SubProcess.php index 2e7361d9c..9010e5ceb 100755 --- a/workflow/engine/classes/model/SubProcess.php +++ b/workflow/engine/classes/model/SubProcess.php @@ -148,5 +148,14 @@ class SubProcess extends BaseSubProcess throw ($oError); } } + + public static function findByParents($proParent, $tasParent) + { + $criteria = new Criteria('workflow'); + $criteria->add(SubProcessPeer::PRO_PARENT, $proParent); + $criteria->add(SubProcessPeer::TAS_PARENT, $tasParent); + + return SubProcessPeer::doSelectOne($criteria); + } } diff --git a/workflow/engine/classes/model/Task.php b/workflow/engine/classes/model/Task.php index 99952fcc4..d56e5a4a8 100755 --- a/workflow/engine/classes/model/Task.php +++ b/workflow/engine/classes/model/Task.php @@ -354,7 +354,7 @@ class Task extends BaseTask * create a new Task * * @param array $aData with new values - * @return void + * @return string */ public function create($aData, $generateUid = true) { diff --git a/workflow/engine/methods/cases/proxyCasesList.php b/workflow/engine/methods/cases/proxyCasesList.php index 359062b29..83b296a87 100755 --- a/workflow/engine/methods/cases/proxyCasesList.php +++ b/workflow/engine/methods/cases/proxyCasesList.php @@ -29,6 +29,9 @@ $first = isset( $_POST["first"] ) ? true :false; if ($sort == 'CASE_SUMMARY' || $sort == 'CASE_NOTES_COUNT') { $sort = 'APP_NUMBER';//DEFAULT VALUE } +if ($sort == 'APP_STATUS_LABEL') { + $sort = 'APP_STATUS'; +} try { $userUid = (isset($_SESSION["USER_LOGGED"]) && $_SESSION["USER_LOGGED"] != "")? $_SESSION["USER_LOGGED"] : null; diff --git a/workflow/engine/methods/processes/processes_Import_Ajax.php b/workflow/engine/methods/processes/processes_Import_Ajax.php index 4dadcc043..010785d32 100644 --- a/workflow/engine/methods/processes/processes_Import_Ajax.php +++ b/workflow/engine/methods/processes/processes_Import_Ajax.php @@ -23,6 +23,27 @@ */ ini_set( 'max_execution_time', '0' ); + +$ext = pathinfo($_FILES["PROCESS_FILENAME"]["name"], PATHINFO_EXTENSION); + +if ($ext == "pmx") { + $importer = new \ProcessMaker\Importer\XmlImporter(); + $importer->setSourceFromGlobals("PROCESS_FILENAME"); + $data = array("usr_uid" => $_SESSION['USER_LOGGED']); + $res = $importer->import($data); + $result = array( + "success" => true, + "catchMessage" => "", + "ExistProcessInDatabase" => 0, + "ExistGroupsInDatabase" => 0, + "sNewProUid" => $res[0]["new_uid"], + "project_type" => "bpmn" + ); + + echo json_encode($result); + exit(0); +} + function reservedWordsSqlValidate ($data) { $arrayAux = array (); diff --git a/workflow/engine/src/BusinessModel/Cases.php b/workflow/engine/src/BusinessModel/Cases.php index bcc76ad65..452334f1d 100644 --- a/workflow/engine/src/BusinessModel/Cases.php +++ b/workflow/engine/src/BusinessModel/Cases.php @@ -91,7 +91,7 @@ class Cases Validator::catUid($category, '$cat_uid'); } $status = G::toUpper($status); - $listStatus = array('TODO', 'DRAFT', 'COMPLETED', 'CANCEL', 'OPEN', 'CLOSE'); + $listStatus = array('TO_DO', 'DRAFT', 'COMPLETED', 'CANCEL', 'OPEN', 'CLOSE'); if (!(in_array($status, $listStatus))) { $status = ''; } @@ -136,7 +136,6 @@ class Cases } } - if ($solrEnabled) { $result = $ApplicationSolrIndex->getAppGridData( $userUid, @@ -184,25 +183,25 @@ class Cases } } if ($paged == false) { - $result = $result['data']; + $response = $result['data']; } else { - $result['total'] = $result['totalCount']; - unset($result['totalCount']); - $result['start'] = $start+1; - $result['limit'] = $limit; - $result['sort'] = G::toLower($sort); - $result['dir'] = G::toLower($dir); - $result['cat_uid'] = $category; - $result['pro_uid'] = $process; - $result['search'] = $search; + $response['total'] = $result['totalCount']; + $response['start'] = $start+1; + $response['limit'] = $limit; + $response['sort'] = G::toLower($sort); + $response['dir'] = G::toLower($dir); + $response['cat_uid'] = $category; + $response['pro_uid'] = $process; + $response['search'] = $search; if ($action == 'search') { - $result['app_status'] = G::toLower($status); - $result['usr_uid'] = $user; - $result['date_from'] = $dateFrom; - $result['date_to'] = $dateTo; + $response['app_status'] = G::toLower($status); + $response['usr_uid'] = $user; + $response['date_from'] = $dateFrom; + $response['date_to'] = $dateTo; } + $response['data'] = $result['data']; } - return $result; + return $response; } /** @@ -636,14 +635,22 @@ class Cases * @copyright Colosa - Bolivia */ public function putCancelCase($app_uid, $usr_uid, $del_index = false) { - Validator::appUid($app_uid, '$cas_uid'); + Validator::isString($app_uid, '$app_uid'); + Validator::isString($usr_uid, '$usr_uid'); + + Validator::appUid($app_uid, '$app_uid'); Validator::usrUid($usr_uid, '$usr_uid'); if ($del_index === false) { $del_index = \AppDelegation::getCurrentIndex($app_uid); } + Validator::isInteger($del_index, '$del_index'); $case = new \Cases(); + $fields = $case->loadCase($app_uid); + if ($fields['APP_STATUS'] == 'CANCELLED') { + throw (new \Exception("The case '$app_uid' is canceled")); + } $case->cancelCase( $app_uid, $del_index, $usr_uid ); } @@ -661,15 +668,20 @@ class Cases * @copyright Colosa - Bolivia */ public function putPauseCase($app_uid, $usr_uid, $del_index = false, $unpaused_date = null) { - Validator::appUid($app_uid, '$cas_uid'); + Validator::isString($app_uid, '$app_uid'); + Validator::isString($usr_uid, '$usr_uid'); + + Validator::appUid($app_uid, '$app_uid'); Validator::usrUid($usr_uid, '$usr_uid'); - if ($unpaused_date != null) { - Validator::isDate($unpaused_date, 'Y-m-d', '$unpaused_date'); - } if ($del_index === false) { $del_index = \AppDelegation::getCurrentIndex($app_uid); } + Validator::isInteger($del_index, '$del_index'); + + if ($unpaused_date != null) { + Validator::isDate($unpaused_date, 'Y-m-d', '$unpaused_date'); + } $case = new \Cases(); $case->pauseCase( $app_uid, $del_index, $usr_uid, $unpaused_date ); @@ -687,12 +699,16 @@ class Cases * @copyright Colosa - Bolivia */ public function putUnpauseCase($app_uid, $usr_uid, $del_index = false) { - Validator::appUid($app_uid, '$cas_uid'); + Validator::isString($app_uid, '$app_uid'); + Validator::isString($usr_uid, '$usr_uid'); + + Validator::appUid($app_uid, '$app_uid'); Validator::usrUid($usr_uid, '$usr_uid'); if ($del_index === false) { $del_index = \AppDelegation::getCurrentIndex($app_uid); } + Validator::isInteger($del_index, '$del_index'); $case = new \Cases(); $case->unpauseCase( $app_uid, $del_index, $usr_uid ); @@ -710,13 +726,18 @@ class Cases * @copyright Colosa - Bolivia */ public function putExecuteTriggerCase($app_uid, $tri_uid, $usr_uid, $del_index = false) { - Validator::appUid($app_uid, '$cas_uid'); + Validator::isString($app_uid, '$app_uid'); + Validator::isString($tri_uid, '$tri_uid'); + Validator::isString($usr_uid, '$usr_uid'); + + Validator::appUid($app_uid, '$app_uid'); Validator::triUid($tri_uid, '$tri_uid'); Validator::usrUid($usr_uid, '$usr_uid'); if ($del_index === false) { $del_index = \AppDelegation::getCurrentIndex($app_uid); } + Validator::isInteger($del_index, '$del_index'); $case = new \wsBase(); $case->executeTrigger( $usr_uid, $app_uid, $tri_uid, $del_index ); @@ -733,7 +754,8 @@ class Cases * @copyright Colosa - Bolivia */ public function deleteCase($app_uid) { - Validator::appUid($app_uid, '$cas_uid'); + Validator::isString($app_uid, '$app_uid'); + Validator::appUid($app_uid, '$app_uid'); $case = new \Cases(); $case->removeCase( $app_uid ); } @@ -1289,4 +1311,123 @@ class Cases $oCriteria->addDescendingOrderByColumn('CREATE_DATE'); return $oCriteria; } + + /** + * Get Case Variables + * + * @access public + * @param string $app_uid, Uid for case + * @return array + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function getCaseVariables($app_uid) { + Validator::isString($app_uid, '$app_uid'); + Validator::appUid($app_uid, '$app_uid'); + + $case = new \Cases(); + $fields = $case->loadCase($app_uid); + return $fields['APP_DATA']; + } + + /** + * Put Set Case Variables + * + * @access public + * @param string $app_uid, Uid for case + * @param array $app_data, Data for case variables + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function setCaseVariables($app_uid, $app_data) { + Validator::isString($app_uid, '$app_uid'); + Validator::appUid($app_uid, '$app_uid'); + Validator::isArray($app_data, '$app_data'); + + $case = new \Cases(); + $fields = $case->loadCase($app_uid); + $data = array_merge($fields['APP_DATA'], array('APP_DATA' => $app_data)); + $case->updateCase($app_uid, $data); + } + + /** + * Get Case Notes + * + * @access public + * @param string $app_uid, Uid for case + * @return array + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function getCaseNotes($app_uid, $usr_uid) { + Validator::isString($app_uid, '$app_uid'); + Validator::appUid($app_uid, '$app_uid'); + + $case = new \Cases(); + $caseLoad = $case->loadCase($app_uid); + $pro_uid = $caseLoad['PRO_UID']; + $tas_uid = \AppDelegation::getCurrentTask($app_uid); + $respView = $case->getAllObjectsFrom( $pro_uid, $app_uid, $tas_uid, $usr_uid, 'VIEW' ); + $respBlock = $case->getAllObjectsFrom( $pro_uid, $app_uid, $tas_uid, $usr_uid, 'BLOCK' ); + if ($respView['CASES_NOTES'] == 0 && $respBlock['CASES_NOTES'] == 0) { + throw (new \Exception("You do not have permission to cases notes.")); + } + + $appNote = new \AppNotes(); + $note_data = $appNote->getNotesList($app_uid); + $response = array(); + $response['total'] = $note_data['array']['totalCount']; + $response['notes'] = array(); + $con = 0; + foreach ($note_data['array']['notes'] as $value) { + $response['notes'][$con]['app_uid'] = $value['APP_UID']; + $response['notes'][$con]['usr_uid'] = $value['USR_UID']; + $response['notes'][$con]['note_date'] = $value['NOTE_DATE']; + $response['notes'][$con]['note_content'] = $value['NOTE_CONTENT']; + $con++; + } + return $response; + } + + /** + * Save new case note + * + * @access public + * @param string $app_uid, Uid for case + * @param array $app_data, Data for case variables + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function saveCaseNote($app_uid, $usr_uid, $note_content, $send_mail = false) { + Validator::isString($app_uid, '$app_uid'); + Validator::appUid($app_uid, '$app_uid'); + + Validator::isString($usr_uid, '$usr_uid'); + Validator::usrUid($usr_uid, '$usr_uid'); + + Validator::isString($note_content, '$note_content'); + if (strlen($note_content) > 500) { + throw (new \Exception("Invalid value for '$note_content', the permitted maximum length of 500 characters.")); + } + + Validator::isBoolean($send_mail, '$send_mail'); + + $case = new \Cases(); + $caseLoad = $case->loadCase($app_uid); + $pro_uid = $caseLoad['PRO_UID']; + $tas_uid = \AppDelegation::getCurrentTask($app_uid); + $respView = $case->getAllObjectsFrom( $pro_uid, $app_uid, $tas_uid, $usr_uid, 'VIEW' ); + $respBlock = $case->getAllObjectsFrom( $pro_uid, $app_uid, $tas_uid, $usr_uid, 'BLOCK' ); + if ($respView['CASES_NOTES'] == 0 && $respBlock['CASES_NOTES'] == 0) { + throw (new \Exception("You do not have permission to cases notes.")); + } + + $note_content = addslashes($note_content); + $appNote = new \AppNotes(); + $appNote->addCaseNote($app_uid, $usr_uid, $note_content, intval($send_mail)); + } } \ No newline at end of file diff --git a/workflow/engine/src/BusinessModel/Cases/InputDocument.php b/workflow/engine/src/BusinessModel/Cases/InputDocument.php index bdbae4943..7a03f94e7 100644 --- a/workflow/engine/src/BusinessModel/Cases/InputDocument.php +++ b/workflow/engine/src/BusinessModel/Cases/InputDocument.php @@ -6,15 +6,15 @@ class InputDocument /** * Get data of Cases InputDocument * - * @param string $caseUid + * @param string $applicationUid * @param string $userUid * * return array Return an array with data of an InputDocument */ - public function getCasesInputDocuments($caseUid, $userUid) + public function getCasesInputDocuments($applicationUid, $userUid) { try { - $sApplicationUID = $caseUid; + $sApplicationUID = $applicationUid; $sUserUID = $userUid; \G::LoadClass('case'); $oCase = new \Cases(); @@ -49,16 +49,16 @@ class InputDocument /** * Get data of Cases InputDocument * - * @param string $caseUid + * @param string $applicationUid * @param string $userUid * @param string $inputDocumentUid * * return array Return an array with data of an InputDocument */ - public function getCasesInputDocument($caseUid, $userUid, $inputDocumentUid) + public function getCasesInputDocument($applicationUid, $userUid, $inputDocumentUid) { try { - $sApplicationUID = $caseUid; + $sApplicationUID = $applicationUid; $sUserUID = $userUid; \G::LoadClass('case'); $oCase = new \Cases(); @@ -104,7 +104,7 @@ class InputDocument try { $oAppDocument = \AppDocumentPeer::retrieveByPK( $inputDocumentUid, 1 ); if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') { - throw (new \Exception('This row doesn\'t exist!')); + throw (new \Exception('This input document with id: '.$inputDocumentUid.' doesn\'t exist!')); } \G::LoadClass('wsBase'); $ws = new \wsBase(); @@ -117,17 +117,19 @@ class InputDocument /** * Get data of Cases InputDocument * - * @param string $caseUid + * @param string $applicationUid + * @param string $taskUid + * @param string $appDocComment * @param string $inputDocumentUid * @param string $userUid * * return array Return an array with data of an InputDocument */ - public function addCasesInputDocument($caseUid, $inputDocumentUid, $userUid) + public function addCasesInputDocument($applicationUid, $taskUid, $appDocComment, $inputDocumentUid, $userUid) { try { - if ((isset( $_FILES['form'] )) && ($_FILES['form']['error']['APP_DOC_FILENAME'] != 0)) { - $code = $_FILES['form']['error']['APP_DOC_FILENAME']; + if ((isset( $_FILES['form'] )) && ($_FILES['form']['error'] != 0)) { + $code = $_FILES['form']['error']; switch ($code) { case UPLOAD_ERR_INI_SIZE: $message = \G::LoadTranslation( 'ID_UPLOAD_ERR_INI_SIZE' ); @@ -159,31 +161,22 @@ class InputDocument \G::header( "location: " . "/sys" . SYS_SYS . $backUrlObj[1] ); die(); } - \G::LoadClass("case"); - - //$inputDocumentUid = $_GET["UID"]; //$_POST["form"]["DOC_UID"] - $appDocUid = ''; - //$appDocUid = $_POST["form"]["APP_DOC_UID"]; + $appDocUid = \G::generateUniqueID(); $docVersion = ''; - //$docVersion = intval($_POST["form"]["docVersion"]); $appDocType = 'INPUT'; - //$appDocType = $_POST["form"]["APP_DOC_TYPE"]; - $appDocComment = (isset($_POST["form"]["APP_DOC_COMMENT"]))? $_POST["form"]["APP_DOC_COMMENT"] : ""; - $actionType = $_POST["form"]["actionType"]; - $case = new \Cases(); - $case->thisIsTheCurrentUser($_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["USER_LOGGED"], "REDIRECT", "casesListExtJs"); - + $delIndex = \AppDelegation::getCurrentIndex($applicationUid); + $case->thisIsTheCurrentUser($applicationUid, $delIndex, $userUid, "REDIRECT", "casesListExtJs"); //Load the fields - $arrayField = $case->loadCase($_SESSION["APPLICATION"]); + $arrayField = $case->loadCase($applicationUid); $arrayField["APP_DATA"] = array_merge($arrayField["APP_DATA"], \G::getSystemConstants()); - //Triggers - $arrayTrigger = $case->loadTriggers($_SESSION["TASK"], "INPUT_DOCUMENT", $inputDocumentUid, "AFTER"); - - + $arrayTrigger = $case->loadTriggers($taskUid, "INPUT_DOCUMENT", $inputDocumentUid, "AFTER"); //Add Input Document + if (!$_FILES["form"]["error"]) { + $_FILES["form"]["error"] = 0; + } if (isset($_FILES) && isset($_FILES["form"]) && count($_FILES["form"]) > 0) { $appDocUid = $case->addInputDocument( $inputDocumentUid, @@ -191,44 +184,39 @@ class InputDocument $docVersion, $appDocType, $appDocComment, - $actionType, - $_SESSION["APPLICATION"], - $_SESSION["INDEX"], - $_SESSION["TASK"], - $_SESSION["USER_LOGGED"], + '', + $applicationUid, + $delIndex, + $taskUid, + $userUid, "xmlform", - $_FILES["form"]["name"]["APP_DOC_FILENAME"], - $_FILES["form"]["error"]["APP_DOC_FILENAME"], - $_FILES["form"]["tmp_name"]["APP_DOC_FILENAME"] + $_FILES["form"]["name"], + $_FILES["form"]["error"], + $_FILES["form"]["tmp_name"] ); - } - - if ($_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] > 0) { + } + if ($_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] > 0) { //Trigger - Execute after - Start $arrayField["APP_DATA"] = $case->executeTriggers( - $_SESSION["TASK"], + $taskUid, "INPUT_DOCUMENT", $inputDocumentUid, "AFTER", $arrayField["APP_DATA"] ); //Trigger - Execute after - End - } - + } //Save data $arrayData = array(); $arrayData["APP_NUMBER"] = $arrayField["APP_NUMBER"]; //$arrayData["APP_PROC_STATUS"] = $arrayField["APP_PROC_STATUS"]; $arrayData["APP_DATA"] = $arrayField["APP_DATA"]; - $arrayData["DEL_INDEX"] = $_SESSION["INDEX"]; - $arrayData["TAS_UID"] = $_SESSION["TASK"]; - - $case->updateCase($_SESSION["APPLICATION"], $arrayData); - + $arrayData["DEL_INDEX"] = $delIndex; + $arrayData["TAS_UID"] = $taskUid; + $case->updateCase($applicationUid, $arrayData); } catch (\Exception $e) { throw $e; } } - } diff --git a/workflow/engine/src/BusinessModel/Cases/OutputDocument.php b/workflow/engine/src/BusinessModel/Cases/OutputDocument.php index 4653d8d4c..b1ac382bb 100644 --- a/workflow/engine/src/BusinessModel/Cases/OutputDocument.php +++ b/workflow/engine/src/BusinessModel/Cases/OutputDocument.php @@ -6,21 +6,21 @@ class OutputDocument /** * Get data of Cases OutputDocument * - * @param string $caseUid + * @param string $applicationUid * @param string $userUid * * return array Return an array with data of an OutputDocument */ - public function getCasesOutputDocuments($caseUid, $userUid) + public function getCasesOutputDocuments($applicationUid, $userUid) { try { \G::LoadClass('case'); $oCase = new \Cases(); - $fields = $oCase->loadCase( $caseUid ); + $fields = $oCase->loadCase( $applicationUid ); $sProcessUID = $fields['PRO_UID']; $sTaskUID = ''; $oCriteria = new \BusinessModel\Cases(); - $oCriteria->getAllGeneratedDocumentsCriteria( $sProcessUID, $caseUid, $sTaskUID, $userUid); + $oCriteria->getAllGeneratedDocumentsCriteria( $sProcessUID, $applicationUid, $sTaskUID, $userUid); $result = array (); global $_DBArray; foreach ($_DBArray['outputDocuments'] as $key => $row) { @@ -47,16 +47,16 @@ class OutputDocument /** * Get data of Cases OutputDocument * - * @param string $caseUid + * @param string $applicationUid * @param string $userUid - * @param string $outputDocumentUid + * @param string $applicationDocumentUid * - * return array Return an array with data of an OutputDocument + * return object Return an object with data of an OutputDocument */ - public function getCasesOutputDocument($caseUid, $userUid, $outputDocumentUid) + public function getCasesOutputDocument($applicationUid, $userUid, $applicationDocumentUid) { try { - $sApplicationUID = $caseUid; + $sApplicationUID = $applicationUid; $sUserUID = $userUid; \G::LoadClass('case'); $oCase = new \Cases(); @@ -79,12 +79,13 @@ class OutputDocument $docrow['app_doc_type'] = $row['TYPE']; $docrow['app_doc_index'] = $row['APP_DOC_INDEX']; $docrow['app_doc_link'] = 'cases/' . $row['DOWNLOAD_LINK']; - if ($docrow['app_doc_uid'] == $outputDocumentUid) { + if ($docrow['app_doc_uid'] == $applicationDocumentUid) { $result = $docrow; } } } - return $result; + $oResponse = json_decode(json_encode($result), false); + return $oResponse; } catch (\Exception $e) { throw $e; } @@ -93,20 +94,19 @@ class OutputDocument /** * Delete OutputDocument * - * @param string $outputDocumentUid + * @param string $applicationDocumentUid * - * return array Return an array with data of an OutputDocument */ - public function removeOutputDocument($outputDocumentUid) + public function removeOutputDocument($applicationDocumentUid) { try { - $oAppDocument = \AppDocumentPeer::retrieveByPK( $outputDocumentUid, 1 ); + $oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, 1 ); if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') { - throw (new \Exception('This row doesn\'t exist!')); + throw (new \Exception('This output document with id: '.$applicationDocumentUid.' doesn\'t exist!')); } \G::LoadClass('wsBase'); $ws = new \wsBase(); - $ws->removeDocument($outputDocumentUid); + $ws->removeDocument($applicationDocumentUid); } catch (\Exception $e) { throw $e; } @@ -115,116 +115,505 @@ class OutputDocument /** * Get data of Cases OutputDocument * - * @param string $caseUid + * @param string $applicationUid * @param string $outputDocumentUid * @param string $userUid * - * return array Return an array with data of an OutputDocument + * return object Return an object with data of an OutputDocument */ - public function addCasesOutputDocument($caseUid, $outputDocumentUid, $userUid) + public function addCasesOutputDocument($applicationUid, $outputDocumentUid, $userUid) { try { - if ((isset( $_FILES['form'] )) && ($_FILES['form']['error']['APP_DOC_FILENAME'] != 0)) { - $code = $_FILES['form']['error']['APP_DOC_FILENAME']; - switch ($code) { - case UPLOAD_ERR_INI_SIZE: - $message = \G::LoadTranslation( 'ID_UPLOAD_ERR_INI_SIZE' ); + $sApplication = $applicationUid; + $index = \AppDelegation::getCurrentIndex($applicationUid); + $sUserLogged = $userUid; + $outputID = $outputDocumentUid; + $g = new \G(); + $g->sessionVarSave(); + \G::LoadClass( 'case' ); + $oCase = new \Cases(); + $oCase->thisIsTheCurrentUser( $sApplication, $index, $sUserLogged, '', 'casesListExtJs' ); + //require_once 'classes/model/OutputDocument.php'; + $oOutputDocument = new \OutputDocument(); + $aOD = $oOutputDocument->load( $outputID ); + $Fields = $oCase->loadCase( $sApplication ); + $sFilename = preg_replace( '[^A-Za-z0-9_]', '_', \G::replaceDataField( $aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA'] ) ); + require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppFolder.php"); + require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppDocument.php"); + //Get the Custom Folder ID (create if necessary) + $oFolder = new \AppFolder(); + $folderId = $oFolder->createFromPath( $aOD['OUT_DOC_DESTINATION_PATH'], $sApplication ); + //Tags + $fileTags = $oFolder->parseTags( $aOD['OUT_DOC_TAGS'], $sApplication ); + //Get last Document Version and apply versioning if is enabled + $oAppDocument = new \AppDocument(); + $lastDocVersion = $oAppDocument->getLastDocVersion( $outputID, $sApplication ); + $oCriteria = new \Criteria( 'workflow' ); + $oCriteria->add( \AppDocumentPeer::APP_UID, $sApplication ); + $oCriteria->add( \AppDocumentPeer::DOC_UID, $outputID ); + $oCriteria->add( \AppDocumentPeer::DOC_VERSION, $lastDocVersion ); + $oCriteria->add( \AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT' ); + $oDataset = \AppDocumentPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + if (($aOD['OUT_DOC_VERSIONING']) && ($lastDocVersion != 0)) { + //Create new Version of current output + $lastDocVersion ++; + if ($aRow = $oDataset->getRow()) { + $aFields = array ('APP_DOC_UID' => $aRow['APP_DOC_UID'],'APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion + 1,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags); + $oAppDocument = new \AppDocument(); + $oAppDocument->create( $aFields ); + $sDocUID = $aRow['APP_DOC_UID']; + } + } else { + ////No versioning so Update a current Output or Create new if no exist + if ($aRow = $oDataset->getRow()) { + //Update + $aFields = array ('APP_DOC_UID' => $aRow['APP_DOC_UID'],'APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags + ); + $oAppDocument = new \AppDocument(); + $oAppDocument->update( $aFields ); + $sDocUID = $aRow['APP_DOC_UID']; + } else { + //we are creating the appdocument row + //create + if ($lastDocVersion == 0) { + $lastDocVersion ++; + } + $aFields = array ('APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags + ); + $oAppDocument = new \AppDocument(); + $aFields['APP_DOC_UID'] = $sDocUID = $oAppDocument->create( $aFields ); + } + } + $sFilename = $aFields['APP_DOC_UID'] . "_" . $lastDocVersion; + $pathOutput = PATH_DOCUMENT . \G::getPathFromUID($sApplication) . PATH_SEP . 'outdocs' . PATH_SEP; //G::pr($sFilename);die; + \G::mk_dir( $pathOutput ); + $aProperties = array (); + if (! isset( $aOD['OUT_DOC_MEDIA'] )) { + $aOD['OUT_DOC_MEDIA'] = 'Letter'; + } + if (! isset( $aOD['OUT_DOC_LEFT_MARGIN'] )) { + $aOD['OUT_DOC_LEFT_MARGIN'] = '15'; + } + if (! isset( $aOD['OUT_DOC_RIGHT_MARGIN'] )) { + $aOD['OUT_DOC_RIGHT_MARGIN'] = '15'; + } + if (! isset( $aOD['OUT_DOC_TOP_MARGIN'] )) { + $aOD['OUT_DOC_TOP_MARGIN'] = '15'; + } + if (! isset( $aOD['OUT_DOC_BOTTOM_MARGIN'] )) { + $aOD['OUT_DOC_BOTTOM_MARGIN'] = '15'; + } + $aProperties['media'] = $aOD['OUT_DOC_MEDIA']; + $aProperties['margins'] = array ('left' => $aOD['OUT_DOC_LEFT_MARGIN'],'right' => $aOD['OUT_DOC_RIGHT_MARGIN'],'top' => $aOD['OUT_DOC_TOP_MARGIN'],'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN'] + ); + if (isset($aOD['OUT_DOC_REPORT_GENERATOR'])) { + $aProperties['report_generator'] = $aOD['OUT_DOC_REPORT_GENERATOR']; + } + $this->generate( $outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (boolean) $aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'], $aProperties , $applicationUid); + //Plugin Hook PM_UPLOAD_DOCUMENT for upload document + //G::LoadClass('plugin'); + $oPluginRegistry = & \PMPluginRegistry::getSingleton(); + if ($oPluginRegistry->existsTrigger( PM_UPLOAD_DOCUMENT ) && class_exists( 'uploadDocumentData' )) { + $triggerDetail = $oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT ); + $aFields['APP_DOC_PLUGIN'] = $triggerDetail->sNamespace; + $oAppDocument1 = new \AppDocument(); + $oAppDocument1->update( $aFields ); + $sPathName = PATH_DOCUMENT . \G::getPathFromUID($sApplication) . PATH_SEP; + $oData['APP_UID'] = $sApplication; + $oData['ATTACHMENT_FOLDER'] = true; + switch ($aOD['OUT_DOC_GENERATE']) { + case "BOTH": + $documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion() ); + $documentData->sFileType = "PDF"; + $documentData->bUseOutputFolder = true; + $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData ); + if ($uploadReturn) { + //Only delete if the file was saved correctly + unlink( $pathOutput . $sFilename . '.pdf' ); + } + $documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion() ); + $documentData->sFileType = "DOC"; + $documentData->bUseOutputFolder = true; + $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData ); + if ($uploadReturn) { + //Only delete if the file was saved correctly + unlink( $pathOutput . $sFilename . '.doc' ); + } break; - case UPLOAD_ERR_FORM_SIZE: - $message = \G::LoadTranslation( 'ID_UPLOAD_ERR_FORM_SIZE' ); + case "PDF": + $documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion() ); + $documentData->sFileType = "PDF"; + $documentData->bUseOutputFolder = true; + $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData ); + if ($uploadReturn) { + //Only delete if the file was saved correctly + unlink( $pathOutput . $sFilename . '.pdf' ); + } break; - case UPLOAD_ERR_PARTIAL: - $message = \G::LoadTranslation( 'ID_UPLOAD_ERR_PARTIAL' ); - break; - case UPLOAD_ERR_NO_FILE: - $message = \G::LoadTranslation( 'ID_UPLOAD_ERR_NO_FILE' ); - break; - case UPLOAD_ERR_NO_TMP_DIR: - $message = \G::LoadTranslation( 'ID_UPLOAD_ERR_NO_TMP_DIR' ); - break; - case UPLOAD_ERR_CANT_WRITE: - $message = \G::LoadTranslation( 'ID_UPLOAD_ERR_CANT_WRITE' ); - break; - case UPLOAD_ERR_EXTENSION: - $message = \G::LoadTranslation( 'ID_UPLOAD_ERR_EXTENSION' ); - break; - default: - $message = \G::LoadTranslation( 'ID_UPLOAD_ERR_UNKNOWN' ); + case "DOC": + $documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion() ); + $documentData->sFileType = "DOC"; + $documentData->bUseOutputFolder = true; + $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData ); + if ($uploadReturn) { + //Only delete if the file was saved correctly + unlink( $pathOutput . $sFilename . '.doc' ); + } break; } - \G::SendMessageText( $message, "ERROR" ); - $backUrlObj = explode( "sys" . SYS_SYS, $_SERVER['HTTP_REFERER'] ); - \G::header( "location: " . "/sys" . SYS_SYS . $backUrlObj[1] ); - die(); } - - \G::LoadClass("case"); - - //$inputDocumentUid = $_GET["UID"]; //$_POST["form"]["DOC_UID"] - $appDocUid = ''; - //$appDocUid = $_POST["form"]["APP_DOC_UID"]; - $docVersion = ''; - //$docVersion = intval($_POST["form"]["docVersion"]); - $appDocType = 'INPUT'; - //$appDocType = $_POST["form"]["APP_DOC_TYPE"]; - $appDocComment = (isset($_POST["form"]["APP_DOC_COMMENT"]))? $_POST["form"]["APP_DOC_COMMENT"] : ""; - $actionType = $_POST["form"]["actionType"]; - - $case = new \Cases(); - $case->thisIsTheCurrentUser($_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["USER_LOGGED"], "REDIRECT", "casesListExtJs"); - - //Load the fields - $arrayField = $case->loadCase($_SESSION["APPLICATION"]); - $arrayField["APP_DATA"] = array_merge($arrayField["APP_DATA"], \G::getSystemConstants()); - - //Triggers - $arrayTrigger = $case->loadTriggers($_SESSION["TASK"], "INPUT_DOCUMENT", $outputDocumentUid, "AFTER"); - - - //Add Input Document - if (isset($_FILES) && isset($_FILES["form"]) && count($_FILES["form"]) > 0) { - $appDocUid = $case->addInputDocument( - $outputDocumentUid, - $appDocUid, - $docVersion, - $appDocType, - $appDocComment, - $actionType, - $_SESSION["APPLICATION"], - $_SESSION["INDEX"], - $_SESSION["TASK"], - $_SESSION["USER_LOGGED"], - "xmlform", - $_FILES["form"]["name"]["APP_DOC_FILENAME"], - $_FILES["form"]["error"]["APP_DOC_FILENAME"], - $_FILES["form"]["tmp_name"]["APP_DOC_FILENAME"] - ); - } - - if ($_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] > 0) { - //Trigger - Execute after - Start - $arrayField["APP_DATA"] = $case->executeTriggers( - $_SESSION["TASK"], - "INPUT_DOCUMENT", - $outputDocumentUid, - "AFTER", - $arrayField["APP_DATA"] - ); - //Trigger - Execute after - End - } - - //Save data - $arrayData = array(); - $arrayData["APP_NUMBER"] = $arrayField["APP_NUMBER"]; - //$arrayData["APP_PROC_STATUS"] = $arrayField["APP_PROC_STATUS"]; - $arrayData["APP_DATA"] = $arrayField["APP_DATA"]; - $arrayData["DEL_INDEX"] = $_SESSION["INDEX"]; - $arrayData["TAS_UID"] = $_SESSION["TASK"]; - - $case->updateCase($_SESSION["APPLICATION"], $arrayData); - + $g->sessionVarRestore(); + return $this->getCasesOutputDocument($applicationUid, $userUid, $sDocUID); } catch (\Exception $e) { throw $e; } } + + /* + * Generate the output document + * @param string $sUID + * @param array $aFields + * @param string $sPath + * @return variant + */ + public function generate($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $sTypeDocToGener = 'BOTH', $aProperties = array(), $sApplication) + { + if (($sUID != '') && is_array($aFields) && ($sPath != '')) { + $sContent = \G::replaceDataGridField($sContent, $aFields); + \G::verifyPath($sPath, true); + //Start - Create .doc + $oFile = fopen($sPath . $sFilename . '.doc', 'wb'); + $size = array(); + $size["Letter"] = "216mm 279mm"; + $size["Legal"] = "216mm 357mm"; + $size["Executive"] = "184mm 267mm"; + $size["B5"] = "182mm 257mm"; + $size["Folio"] = "216mm 330mm"; + $size["A0Oversize"] = "882mm 1247mm"; + $size["A0"] = "841mm 1189mm"; + $size["A1"] = "594mm 841mm"; + $size["A2"] = "420mm 594mm"; + $size["A3"] = "297mm 420mm"; + $size["A4"] = "210mm 297mm"; + $size["A5"] = "148mm 210mm"; + $size["A6"] = "105mm 148mm"; + $size["A7"] = "74mm 105mm"; + $size["A8"] = "52mm 74mm"; + $size["A9"] = "37mm 52mm"; + $size["A10"] = "26mm 37mm"; + $size["Screenshot640"] = "640mm 480mm"; + $size["Screenshot800"] = "800mm 600mm"; + $size["Screenshot1024"] = "1024mm 768mm"; + $sizeLandscape["Letter"] = "279mm 216mm"; + $sizeLandscape["Legal"] = "357mm 216mm"; + $sizeLandscape["Executive"] = "267mm 184mm"; + $sizeLandscape["B5"] = "257mm 182mm"; + $sizeLandscape["Folio"] = "330mm 216mm"; + $sizeLandscape["A0Oversize"] = "1247mm 882mm"; + $sizeLandscape["A0"] = "1189mm 841mm"; + $sizeLandscape["A1"] = "841mm 594mm"; + $sizeLandscape["A2"] = "594mm 420mm"; + $sizeLandscape["A3"] = "420mm 297mm"; + $sizeLandscape["A4"] = "297mm 210mm"; + $sizeLandscape["A5"] = "210mm 148mm"; + $sizeLandscape["A6"] = "148mm 105mm"; + $sizeLandscape["A7"] = "105mm 74mm"; + $sizeLandscape["A8"] = "74mm 52mm"; + $sizeLandscape["A9"] = "52mm 37mm"; + $sizeLandscape["A10"] = "37mm 26mm"; + $sizeLandscape["Screenshot640"] = "480mm 640mm"; + $sizeLandscape["Screenshot800"] = "600mm 800mm"; + $sizeLandscape["Screenshot1024"] = "768mm 1024mm"; + if (!isset($aProperties['media'])) { + $aProperties['media'] = 'Letter'; + } + if ($sLandscape) { + $media = $sizeLandscape[$aProperties['media']]; + } else { + $media = $size[$aProperties['media']]; + } + $marginLeft = '15'; + if (isset($aProperties['margins']['left'])) { + $marginLeft = $aProperties['margins']['left']; + } + $marginRight = '15'; + if (isset($aProperties['margins']['right'])) { + $marginRight = $aProperties['margins']['right']; + } + $marginTop = '15'; + if (isset($aProperties['margins']['top'])) { + $marginTop = $aProperties['margins']['top']; + } + $marginBottom = '15'; + if (isset($aProperties['margins']['bottom'])) { + $marginBottom = $aProperties['margins']['bottom']; + } + fwrite($oFile, ' + + + + + + + + + + + +
'); + fwrite($oFile, $sContent); + fwrite($oFile, "\n
\n\n"); + fclose($oFile); + /* End - Create .doc */ + if ($sTypeDocToGener == 'BOTH' || $sTypeDocToGener == 'PDF') { + $oFile = fopen($sPath . $sFilename . '.html', 'wb'); + fwrite($oFile, $sContent); + fclose($oFile); + /* Start - Create .pdf */ + if (isset($aProperties['report_generator'])) { + switch ($aProperties['report_generator']) { + case 'TCPDF': + $o = new \OutputDocument(); + $o->generateTcpdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties); + break; + case 'HTML2PDF': + default: + $this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties, $sApplication); + break; + } + } else { + $this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties); + } + } + //end if $sTypeDocToGener + /* End - Create .pdf */ + } else { + return \PEAR::raiseError( + null, G_ERROR_USER_UID, null, null, 'You tried to call to a generate method without send the Output Document UID, fields to use and the file path!', 'G_Error', true + ); + } + } + + /* + * Generate Html2ps_pdf + * @param string $sUID + * @param array $aFields + * @param string $sPath + * @param string $sApplication + * @return variant + */ + public function generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $aProperties = array(), $sApplication) + { + define("MAX_FREE_FRACTION", 1); + define('PATH_OUTPUT_FILE_DIRECTORY', PATH_HTML . 'files/' . $sApplication . '/outdocs/'); + \G::verifyPath(PATH_OUTPUT_FILE_DIRECTORY, true); + require_once (PATH_THIRDPARTY . 'html2ps_pdf/config.inc.php'); + require_once (PATH_THIRDPARTY . 'html2ps_pdf/pipeline.factory.class.php'); + parse_config_file(PATH_THIRDPARTY . 'html2ps_pdf/html2ps.config'); + $GLOBALS['g_config'] = array( + 'cssmedia' => 'screen', + 'media' => 'Letter', + 'scalepoints' => false, + 'renderimages' => true, + 'renderfields' => true, + 'renderforms' => false, + 'pslevel' => 3, + 'renderlinks' => true, + 'pagewidth' => 800, + 'landscape' => $sLandscape, + 'method' => 'fpdf', + 'margins' => array('left' => 15, 'right' => 15, 'top' => 15, 'bottom' => 15,), + 'encoding' => '', + 'ps2pdf' => false, + 'compress' => true, + 'output' => 2, + 'pdfversion' => '1.3', + 'transparency_workaround' => false, + 'imagequality_workaround' => false, + 'draw_page_border' => isset($_REQUEST['pageborder']), + 'debugbox' => false, + 'html2xhtml' => true, + 'mode' => 'html', + 'smartpagebreak' => true + ); + $GLOBALS['g_config'] = array_merge($GLOBALS['g_config'], $aProperties); + $g_media = \Media::predefined($GLOBALS['g_config']['media']); + $g_media->set_landscape($GLOBALS['g_config']['landscape']); + $g_media->set_margins($GLOBALS['g_config']['margins']); + $g_media->set_pixels($GLOBALS['g_config']['pagewidth']); + if (isset($GLOBALS['g_config']['pdfSecurity'])) { + if (isset($GLOBALS['g_config']['pdfSecurity']['openPassword']) && + $GLOBALS['g_config']['pdfSecurity']['openPassword'] != "" + ) { + $GLOBALS['g_config']['pdfSecurity']['openPassword'] = G::decrypt( + $GLOBALS['g_config']['pdfSecurity']['openPassword'], $sUID + ); + } + if (isset($GLOBALS['g_config']['pdfSecurity']['ownerPassword']) && + $GLOBALS['g_config']['pdfSecurity']['ownerPassword'] != "" + ) { + $GLOBALS['g_config']['pdfSecurity']['ownerPassword'] = G::decrypt( + $GLOBALS['g_config']['pdfSecurity']['ownerPassword'], $sUID + ); + } + $g_media->set_security($GLOBALS['g_config']['pdfSecurity']); + require_once (HTML2PS_DIR . 'pdf.fpdf.encryption.php'); + } + $pipeline = new \Pipeline(); + if (extension_loaded('curl')) { + require_once (HTML2PS_DIR . 'fetcher.url.curl.class.php'); + $pipeline->fetchers = array(new \FetcherURLCurl()); + if (isset($proxy)) { + if ($proxy != '') { + $pipeline->fetchers[0]->set_proxy($proxy); + } + } + } else { + require_once (HTML2PS_DIR . 'fetcher.url.class.php'); + $pipeline->fetchers[] = new \FetcherURL(); + } + $pipeline->data_filters[] = new \DataFilterDoctype(); + $pipeline->data_filters[] = new \DataFilterUTF8($GLOBALS['g_config']['encoding']); + if ($GLOBALS['g_config']['html2xhtml']) { + $pipeline->data_filters[] = new \DataFilterHTML2XHTML(); + } else { + $pipeline->data_filters[] = new \DataFilterXHTML2XHTML(); + } + $pipeline->parser = new \ParserXHTML(); + $pipeline->pre_tree_filters = array(); + $header_html = ''; + $footer_html = ''; + $filter = new \PreTreeFilterHeaderFooter($header_html, $footer_html); + $pipeline->pre_tree_filters[] = $filter; + + if ($GLOBALS['g_config']['renderfields']) { + $pipeline->pre_tree_filters[] = new \PreTreeFilterHTML2PSFields(); + } + if ($GLOBALS['g_config']['method'] === 'ps') { + $pipeline->layout_engine = new \LayoutEnginePS(); + } else { + $pipeline->layout_engine = new \LayoutEngineDefault(); + } + $pipeline->post_tree_filters = array(); + if ($GLOBALS['g_config']['pslevel'] == 3) { + $image_encoder = new \PSL3ImageEncoderStream(); + } else { + $image_encoder = new \PSL2ImageEncoderStream(); + } + switch ($GLOBALS['g_config']['method']) { + case 'fastps': + if ($GLOBALS['g_config']['pslevel'] == 3) { + $pipeline->output_driver = new \OutputDriverFastPS($image_encoder); + } else { + $pipeline->output_driver = new \OutputDriverFastPSLevel2($image_encoder); + } + break; + case 'pdflib': + $pipeline->output_driver = new \OutputDriverPDFLIB16($GLOBALS['g_config']['pdfversion']); + break; + case 'fpdf': + $pipeline->output_driver = new \OutputDriverFPDF(); + break; + case 'png': + $pipeline->output_driver = new \OutputDriverPNG(); + break; + case 'pcl': + $pipeline->output_driver = new \OutputDriverPCL(); + break; + default: + die('Unknown output method'); + } + if (isset($GLOBALS['g_config']['watermarkhtml'])) { + $watermark_text = $GLOBALS['g_config']['watermarkhtml']; + } else { + $watermark_text = ''; + } + $pipeline->output_driver->set_watermark($watermark_text); + if ($watermark_text != '') { + $dispatcher = & $pipeline->getDispatcher(); + } + if ($GLOBALS['g_config']['debugbox']) { + $pipeline->output_driver->set_debug_boxes(true); + } + if ($GLOBALS['g_config']['draw_page_border']) { + $pipeline->output_driver->set_show_page_border(true); + } + if ($GLOBALS['g_config']['ps2pdf']) { + $pipeline->output_filters[] = new \OutputFilterPS2PDF($GLOBALS['g_config']['pdfversion']); + } + if ($GLOBALS['g_config']['compress'] && $GLOBALS['g_config']['method'] == 'fastps') { + $pipeline->output_filters[] = new \OutputFilterGZip(); + } + if (!isset($GLOBALS['g_config']['process_mode'])) { + $GLOBALS['g_config']['process_mode'] = ''; + } + if ($GLOBALS['g_config']['process_mode'] == 'batch') { + $filename = 'batch'; + } else { + $filename = $sFilename; + } + switch ($GLOBALS['g_config']['output']) { + case 0: + $pipeline->destination = new \DestinationBrowser($filename); + break; + case 1: + $pipeline->destination = new \DestinationDownload($filename); + break; + case 2: + $pipeline->destination = new \DestinationFile($filename); + break; + } + copy($sPath . $sFilename . '.html', PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html'); + try { + $status = $pipeline->process(((isset($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/files/' . $sApplication . '/outdocs/' . $sFilename . '.html', $g_media); + copy(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf', $sPath . $sFilename . '.pdf'); + unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf'); + unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html'); + } catch (\Exception $e) { + if ($e->getMessage() == 'ID_OUTPUT_NOT_GENERATE') { + include_once 'classes/model/AppDocument.php'; + $dataDocument = explode('_', $sFilename); + if (!isset($dataDocument[1])) { + $dataDocument[1] = 1; + } + $oAppDocument = new \AppDocument(); + $oAppDocument->remove($dataDocument[0], $dataDocument[1]); + \G::SendTemporalMessage(\G::LoadTranslation('ID_OUTPUT_NOT_GENERATE'), 'Error'); + } + } + } } diff --git a/workflow/engine/src/BusinessModel/Subprocess.php b/workflow/engine/src/BusinessModel/Subprocess.php index 1f185ab71..f2f327c4a 100644 --- a/workflow/engine/src/BusinessModel/Subprocess.php +++ b/workflow/engine/src/BusinessModel/Subprocess.php @@ -44,7 +44,7 @@ class Subprocess $response['spr_name'] = $aRow['con_value']; $response['spr_synchronous'] = $aRow['sp_synchronous']; $response['spr_variables_out'] = unserialize($aRow['sp_variables_out']); - if ($response['spr_synchronous'] === 1) { + if ((int)$response['spr_synchronous'] === 1) { $response['spr_variables_in'] = unserialize($aRow['sp_variables_in']); } return $response; @@ -91,7 +91,7 @@ class Subprocess 'PRO_PARENT' => $pro_uid, 'TAS_PARENT' => $tas_uid, 'SP_TYPE' => 'SIMPLE', - 'SP_SYNCHRONOUS' => $spr_data['spr_synchronous'], + 'SP_SYNCHRONOUS' => (int)$spr_data['spr_synchronous'], 'SP_SYNCHRONOUS_TYPE' => 'ALL', 'SP_SYNCHRONOUS_WAIT' => 0, 'SP_VARIABLES_OUT' => serialize( $spr_data['spr_variables_out'] ), diff --git a/workflow/engine/src/BusinessModel/Validator.php b/workflow/engine/src/BusinessModel/Validator.php index de3b01f1c..88041e0a0 100644 --- a/workflow/engine/src/BusinessModel/Validator.php +++ b/workflow/engine/src/BusinessModel/Validator.php @@ -237,11 +237,11 @@ class Validator{ { $date = trim($date); if ($date == '') { - throw (new \Exception("The value '' is not valid fot the format '$format'.")); + throw (new \Exception("The value '' is not a valid date for the format '$format'.")); } $d = \DateTime::createFromFormat($format, $date); if (!($d && $d->format($format) == $date)) { - throw (new \Exception("The value '$date' is not valid fot the format '$format'.")); + throw (new \Exception("The value '$date' is not a valid date for the format '$format'.")); } return $date; } @@ -263,6 +263,40 @@ class Validator{ } } + /** + * Validate is string + * @var array $field. Field type string + * + * @access public + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + * + * @return void + */ + static public function isString($field, $nameField) + { + if (!is_string($field)) { + throw (new \Exception("Invalid value for '$nameField' it must be a string.")); + } + } + + /** + * Validate is integer + * @var array $field. Field type integer + * + * @access public + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + * + * @return void + */ + static public function isInteger($field, $nameField) + { + if (!is_integer($field)) { + throw (new \Exception("Invalid value for '$nameField' it must be a integer.")); + } + } + /** * Validate is boolean * @var boolean $field. Field type boolean diff --git a/workflow/engine/src/ProcessMaker/Exporter/Exporter.php b/workflow/engine/src/ProcessMaker/Exporter/Exporter.php index 1232c3165..d9969a624 100644 --- a/workflow/engine/src/ProcessMaker/Exporter/Exporter.php +++ b/workflow/engine/src/ProcessMaker/Exporter/Exporter.php @@ -14,7 +14,7 @@ abstract class Exporter /** * Exporter version */ - const VERSION = "2.0"; + const VERSION = "3.0"; /** * @var \ProcessMaker\Project\Adapter\BpmnWorkflow @@ -67,18 +67,18 @@ abstract class Exporter { $data = array(); - $data["Metadata"] = $this->getMetadata(); - $data["Metadata"]["project_name"] = $this->getProjectName(); + $data["metadata"] = $this->getMetadata(); + $data["metadata"]["project_name"] = $this->getProjectName(); $bpmnStruct["ACTIVITY"] = \BpmnActivity::getAll($this->prjUid); $bpmnStruct["BOUND"] = \BpmnBound::getAll($this->prjUid); $bpmnStruct["DATA"] = array(); $bpmnStruct["DIAGRAM"] = \BpmnDiagram::getAll($this->prjUid); $bpmnStruct["DOCUMENTATION"] = array(); - $bpmnStruct["BPMN_EVENT"] = \BpmnEvent::getAll($this->prjUid); + $bpmnStruct["EVENT"] = \BpmnEvent::getAll($this->prjUid); $bpmnStruct["EXTENSION"] = array(); $bpmnStruct["FLOW"] = \BpmnFlow::getAll($this->prjUid, null, null, "", CASE_UPPER, false); - $bpmnStruct["BPMN_GATEWAY"] = \BpmnGateway::getAll($this->prjUid); + $bpmnStruct["GATEWAY"] = \BpmnGateway::getAll($this->prjUid); $bpmnStruct["LANE"] = array(); $bpmnStruct["LANESET"] = array(); $bpmnStruct["PARTICIPANT"] = array(); @@ -95,9 +95,9 @@ abstract class Exporter $workflowData["processCategory"] = empty($workflowData["processCategory"]) ? array() : $workflowData["processCategory"]; - $data["BPMN-Definition"] = $bpmnStruct; - $data["Workflow-Definition"] = $workflowData; - $data["Workflow-Files"] = array(); + $data["bpmn-definition"] = $bpmnStruct; + $data["workflow-definition"] = $workflowData; + $data["workflow-files"] = array(); // getting dynaforms $dynaforms = array(); @@ -113,7 +113,7 @@ abstract class Exporter $htmlFile = PATH_DYNAFORM . $dynaform['DYN_FILENAME'] . '.html'; if (file_exists($htmlFile)) { - $data["Workflow-Files"]["DYNAFORMS"][] = array( + $data["workflow-files"]["DYNAFORMS"][] = array( "filename" => $dynaform['DYN_FILENAME'] . '.html', "filepath" => $dynaform['DYN_FILENAME'] . '.html', "file_content" => file_get_contents($htmlFile) @@ -132,7 +132,7 @@ abstract class Exporter foreach ($templatesFiles as $templatesFile) { if (is_dir($templatesFile)) continue; - $data["Workflow-Files"][$target][] = array( + $data["workflow-files"][$target][] = array( "filename" => basename($templatesFile), "filepath" => str_replace($templatesDir, "", $templatesFile), "file_content" => file_get_contents($templatesFile) @@ -148,7 +148,7 @@ abstract class Exporter * * @return string */ - public function getContainerName() + public static function getContainerName() { return "ProcessMaker-Project"; } diff --git a/workflow/engine/src/ProcessMaker/Exporter/XmlExporter.php b/workflow/engine/src/ProcessMaker/Exporter/XmlExporter.php index c4607109b..080658165 100644 --- a/workflow/engine/src/ProcessMaker/Exporter/XmlExporter.php +++ b/workflow/engine/src/ProcessMaker/Exporter/XmlExporter.php @@ -38,21 +38,20 @@ class XmlExporter extends Exporter */ public function build() { - $this->rootNode = $this->dom->createElement($this->getContainerName()); + $this->rootNode = $this->dom->createElement(self::getContainerName()); $this->rootNode->setAttribute("version", self::getVersion()); $this->dom->appendChild($this->rootNode); $data = $this->buildData(); // metadata set up - $metadata = $data["Metadata"]; - $metadataNode = $this->dom->createElement("Metadata"); + $metadata = $data["metadata"]; + $metadataNode = $this->dom->createElement("metadata"); foreach ($metadata as $key => $value) { - $metaNode = $this->dom->createElement("meta:$key"); - //$metaNode->setAttribute("key", $key); - //$metaNode->setAttribute("value", $value); - $metaNode->appendChild($this->dom->createTextNode($value)); + $metaNode = $this->dom->createElement("meta"); + $metaNode->setAttribute("key", $key); + $metaNode->appendChild($this->getTextNode($value)); $metadataNode->appendChild($metaNode); } @@ -60,10 +59,10 @@ class XmlExporter extends Exporter // end setting metadata // bpmn struct data set up - $dbData = array("BPMN" => $data["BPMN-Definition"], "Workflow" => $data["Workflow-Definition"]); - //file_put_contents("/home/erik/out.log", print_r($dbData, true)); die; + $dbData = array("BPMN" => $data["bpmn-definition"], "workflow" => $data["workflow-definition"]); + foreach ($dbData as $sectionName => $sectionData) { - $dataNode = $this->dom->createElement("Definition"); + $dataNode = $this->dom->createElement("definition"); $dataNode->setAttribute("class", $sectionName); foreach ($sectionData as $elementName => $elementData) { @@ -73,19 +72,10 @@ class XmlExporter extends Exporter foreach ($elementData as $recordData) { $recordNode = $this->dom->createElement("record"); $recordData = array_change_key_case($recordData, CASE_LOWER); - //var_dump($recordData); die; - foreach ($recordData as $key => $value) { $columnNode = $this->dom->createElement($key); - - if (preg_match('/^[\w\s\.]+$/', $value, $match) || empty($value)) { - $textNode = $this->dom->createTextNode($value); - } else { - $textNode = $this->dom->createCDATASection($value); - } - - $columnNode->appendChild($textNode); + $columnNode->appendChild($this->getTextNode($value)); $recordNode->appendChild($columnNode); } @@ -98,20 +88,16 @@ class XmlExporter extends Exporter $this->rootNode->appendChild($dataNode); } - $workflowFilesNode = $this->dom->createElement("Workflow-Files"); + $workflowFilesNode = $this->dom->createElement("workflow-files"); // workflow dynaforms files - foreach ($data["Workflow-Files"] as $elementName => $elementData) { + foreach ($data["workflow-files"] as $elementName => $elementData) { foreach ($elementData as $fileData) { $fileNode = $this->dom->createElement("file"); $fileNode->setAttribute("target", strtolower($elementName)); $filenameNode = $this->dom->createElement("file_name"); - if (preg_match('/^[\w\s\.\-]+$/', $fileData["filename"], $match)) { - $filenameNode->appendChild($this->dom->createTextNode($fileData["filename"])); - } else { - $filenameNode->appendChild($this->dom->createCDATASection($fileData["filename"])); - } + $filenameNode->appendChild($this->getTextNode($fileData["filename"])); $fileNode->appendChild($filenameNode); $filepathNode = $this->dom->createElement("file_path"); @@ -146,4 +132,13 @@ class XmlExporter extends Exporter $this->build(); return $this->dom->saveXml(); } + + private function getTextNode($value) + { + if (preg_match('/^[\w\s\.\-]+$/', $value, $match)) { + return $this->dom->createTextNode($value); + } else { + return $this->dom->createCDATASection($value); + } + } } \ No newline at end of file diff --git a/workflow/engine/src/ProcessMaker/Importer/Importer.php b/workflow/engine/src/ProcessMaker/Importer/Importer.php index d8ff8102d..c1f2327b8 100644 --- a/workflow/engine/src/ProcessMaker/Importer/Importer.php +++ b/workflow/engine/src/ProcessMaker/Importer/Importer.php @@ -24,16 +24,66 @@ abstract class Importer const IMPORT_STAT_INVALID_SOURCE_FILE = 102; - public abstract function import(); - public abstract function validateSource(); - public abstract function targetExists(); + public function import($option = self::IMPORT_OPTION_CREATE_NEW) + { + switch ($option) { + case self::IMPORT_OPTION_CREATE_NEW: + $this->prepare(); + $this->createNewProject(); + break; + case self::IMPORT_OPTION_DISABLE_AND_CREATE_NEW: + break; + case self::IMPORT_OPTION_OVERWRITE: + break; + } + } + /** + * Validates the source file + * @return mixed + */ + public function validateSource() + { + return true; + } + /** + * Verify if the project already exists + * @return mixed + */ + public function targetExists() + { + return false; + } + + public function createNewProject() + { + + } + + public function updateProject() + { + + } + + public function disableCurrentProject() + { + + } + + /** + * Sets the temporal file save directory + * @param $dirName + */ public function setSaveDir($dirName) { $this->saveDir = rtrim($dirName, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; } + /** + * Gets the temporal file save directory + * @return string + */ public function getSaveDir() { if (empty($this->saveDir)) { @@ -43,11 +93,20 @@ abstract class Importer return $this->saveDir; } + /** + * Sets the temporal source file + * @param $filename + */ public function setSourceFile($filename) { $this->filename = $filename; } + /** + * Set source from Global Http Request resource + * @param $varName + * @throws \Exception + */ public function setSourceFromGlobals($varName) { /*[PROCESS_FILENAME] => Array @@ -77,6 +136,11 @@ abstract class Importer umask($oldUmask); } + /** + * Prepare for import, it makes all validations needed + * @return int + * @throws \Exception + */ public function prepare() { if ($this->validateSource() === false) { diff --git a/workflow/engine/src/ProcessMaker/Importer/XmlImporter.php b/workflow/engine/src/ProcessMaker/Importer/XmlImporter.php index 2061e01c3..1404bb997 100644 --- a/workflow/engine/src/ProcessMaker/Importer/XmlImporter.php +++ b/workflow/engine/src/ProcessMaker/Importer/XmlImporter.php @@ -1,17 +1,150 @@ dom = new \DOMDocument(); + } public function setSourceFile($filename) { $this->filename = $filename; } - public function import() + public function load() { + $this->dom->load($this->filename); + $this->root = $this->dom->documentElement; + // validate version + $this->version = $this->root->getAttribute("version"); + + if (empty($this->version)) { + throw new \Exception("ProcessMaker Project version is missing on file source."); + } + + // read metadata section + $metadata = $this->root->getElementsByTagName("metadata"); + + if ($metadata->length != 1) { + throw new \Exception("Invalid Document format, metadata section is missing or has multiple definition."); + } + + $metadata = $metadata->item(0); + + // load project definition + /** @var \DOMElement[]|\DomNodeList $definitions */ + $definitions = $this->root->getElementsByTagName("definition"); + + if ($definitions->length == 0) { + throw new \Exception("Definition section is missing."); + } elseif ($definitions->length < 2) { + throw new \Exception("Definition section is incomplete."); + } + + $tables = array(); + + foreach ($definitions as $definition) { + $defClass = strtoupper($definition->getAttribute("class")); + $tables[$defClass] = array(); + + // getting tables def + // first we need to know if the project already exists + /** @var \DOMElement[] $tablesNodeList */ + $tablesNodeList = $definition->getElementsByTagName("table"); + + foreach ($tablesNodeList as $tableNode) { + $tableName = $tableNode->getAttribute("name"); //strtoupper($tableNode->getAttribute("name")); + $tables[$defClass][$tableName] = array(); + /** @var \DOMElement[] $recordsNodeList */ + $recordsNodeList = $tableNode->getElementsByTagName("record"); + + foreach ($recordsNodeList as $recordsNode) { + if (! $recordsNode->hasChildNodes()) { + continue; + } + + $columns = array(); + + foreach ($recordsNode->childNodes as $columnNode) { + if ($columnNode->nodeName == "#text") continue; + //$columns[strtoupper($columnNode->nodeName)] = self::getNodeText($columnNode);; + $columns[$columnNode->nodeName] = self::getNodeText($columnNode);; + } + + $tables[$defClass][$tableName][] = $columns; + } + } + } + + $wfFilesNodeList = $this->root->getElementsByTagName("workflow-files"); + $wfFiles = array(); + + if ($wfFilesNodeList->length > 0) { + $filesNodeList = $wfFilesNodeList->item(0)->getElementsByTagName("file"); + + foreach ($filesNodeList as $fileNode) { + $target = $fileNode->getAttribute("target"); + + if (! isset($wfFiles[$target])) { + $wfFiles[$target] = array(); + } + + $fileContent = self::getNodeText($fileNode->getElementsByTagName("file_content")->item(0)); + $fileContent = base64_decode($fileContent); + + $wfFiles[$target][] = array( + "file_name" => self::getNodeText($fileNode->getElementsByTagName("file_name")->item(0)), + "file_path" => self::getNodeText($fileNode->getElementsByTagName("file_path")->item(0)), + "file_content" => $fileContent + ); + } + } + + //print_r($tables); + //print_r($wfFiles); + return $tables; + } + + public function import($data = array()) + { + $tables = $this->load(); + + // Build BPMN project struct + $project = $tables["BPMN"]["PROJECT"][0]; + $diagram = $tables["BPMN"]["DIAGRAM"][0]; + $diagram["activities"] = $tables["BPMN"]["ACTIVITY"]; + $diagram["artifacts"] = array(); + $diagram["events"] = $tables["BPMN"]["EVENT"]; + $diagram["flows"] = $tables["BPMN"]["FLOW"]; + $diagram["gateways"] = $tables["BPMN"]["GATEWAY"]; + $diagram["lanes"] = array(); + $diagram["laneset"] = array(); + $project["diagrams"] = array($diagram); + $project["prj_author"] = isset($data["usr_uid"])? $data["usr_uid"]: "00000000000000000000000000000001"; + $project["process"] = $tables["BPMN"]["PROCESS"][0]; + $result = Adapter\BpmnWorkflow::createFromStruct($project); + + return $result; + } + + private static function getNodeText($node) + { + if ($node->nodeType == XML_ELEMENT_NODE) { + return $node->textContent; + } else if ($node->nodeType == XML_TEXT_NODE || $node->nodeType == XML_CDATA_SECTION_NODE) { + return (string) simplexml_import_dom($node->parentNode); + } } } \ No newline at end of file diff --git a/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php b/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php index 1dde7bdf2..51aa25085 100644 --- a/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php +++ b/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php @@ -2,7 +2,7 @@ namespace ProcessMaker\Project\Adapter; use ProcessMaker\Project; -use ProcessMaker\Util\Hash; +use ProcessMaker\Util; /** * Class BpmnWorkflow @@ -69,7 +69,9 @@ class BpmnWorkflow extends Project\Bpmn } catch (\Exception $e) { $prjUid = $this->getUid(); - $this->remove(); + //$this->remove(); + $bpmnProject = Project\Bpmn::load($prjUid); + $bpmnProject->remove(); throw new \RuntimeException(sprintf( "Can't create Bpmn Project with prj_uid: %s, workflow creation fails." . PHP_EOL . $e->getMessage() @@ -134,6 +136,13 @@ class BpmnWorkflow extends Project\Bpmn if (array_key_exists("ACT_NAME", $data)) { $taskData["TAS_POSY"] = $data["BOU_Y"]; } + if (array_key_exists("ACT_TYPE", $data)) { + if ($data["ACT_TYPE"] == "SUB_PROCESS") { + $taskData["TAS_TYPE"] = "SUBPROCESS"; + } else { + $taskData["TAS_TYPE"] = "NORMAL"; + } + } $this->wp->addTask($taskData); @@ -163,6 +172,7 @@ class BpmnWorkflow extends Project\Bpmn { parent::removeActivity($actUid); $this->wp->removeTask($actUid); + } public function removeGateway($gatUid) @@ -393,4 +403,308 @@ class BpmnWorkflow extends Project\Bpmn $this->wp->remove(); } -} \ No newline at end of file + public static function createFromStruct($projectData) + { + $bwp = new self; + $result = array(); + +// if (array_key_exists("prj_uid", $projectData)) { +// $result[0]["old_uid"] = $projectData["prj_uid"]; +// } else { +// $result[0]["old_uid"] = ""; +// } + + //$projectData["prj_uid"] = Util\Common::generateUID(); + $result[0]["new_uid"] = $projectData["prj_uid"]; + $result[0]["old_uid"] = ""; + $result[0]["object"] = "project"; + + $bwp->create(array( + "PRJ_UID" => $projectData["prj_uid"], + "PRJ_AUTHOR" => $projectData["prj_author"] + )); + $bwp->addDiagram(array_change_key_case($projectData["diagrams"][0], CASE_UPPER)); + $bwp->addProcess(array_change_key_case($projectData["process"], CASE_UPPER)); + + $result = array_merge($result, self::updateFromStruct($bwp->prjUid, $projectData)); + + return $result; + } + + /** + * Compose and return a Project struct + * + * Example struct return: + * array( + * "prj_uid" => "25111170353317e324d6e23073851309", + * "prj_name" => "example project", + * "prj_description" => "project desc.", + * ... + * "diagrams" => array( + * array( + * "dia_uid" => "94208559153317e325f1c24068030751", + * "dia_name" => "Example Diagram", + * ... + * "activities" => array(...), + * "events" => array(...), + * "gateways" => array(...), + * "flows" => array(...), + * "artifacts" => array(...), + * "laneset" => array(...), + * "lanes" => array(...) + * ) + * ) + * ) + * + * @param $prjUid + * @return array + */ + public static function getStruct($prjUid) + { + $bwp = BpmnWorkflow::load($prjUid); + + $project = array_change_key_case($bwp->getProject(), CASE_LOWER); + $diagram = $bwp->getDiagram(); + $process = $bwp->getProcess(); + $diagram["pro_uid"] = $process["PRO_UID"]; + + $configList = array("changeCaseTo" => CASE_LOWER); + + if (! is_null($diagram)) { + $diagram = array_change_key_case($diagram, CASE_LOWER); + $diagram["activities"] = $bwp->getActivities($configList); + $diagram["events"] = $bwp->getEvents($configList); + $diagram["gateways"] = $bwp->getGateways($configList); + $diagram["flows"] = $bwp->getFlows($configList); + $diagram["artifacts"] = $bwp->getArtifacts($configList); + $diagram["laneset"] = $bwp->getLanesets($configList); + $diagram["lanes"] = $bwp->getLanes($configList); + $project["diagrams"][] = $diagram; + } + + return $project; + } + + /** + * Update project from a struct defined. + * + * This function make add, update or delete of elements of a project + * Actions is based on a diff from project save in Db and the given structure as param, by the following criteria. + * + * 1. Elements that are on the struct, but they are not in the Db will be created on Db + * 2. Elements that are on the struct and they are found in db, will be compared, if they have been modified then will be updated on Db + * 3. Elements found in Db but they are not present on the struct will be considered deleted, so they will be deleted from Db. + * + * Example Struct: + * array( + * "prj_uid" => "25111170353317e324d6e23073851309", + * "prj_name" => "example project", + * "prj_description" => "project desc.", + * ... + * "diagrams" => array( + * array( + * "dia_uid" => "94208559153317e325f1c24068030751", + * "dia_name" => "Example Diagram", + * ... + * "activities" => array(...), + * "events" => array(...), + * "gateways" => array(...), + * "flows" => array(...), + * "artifacts" => array(...), + * "laneset" => array(...), + * "lanes" => array(...) + * ) + * ) + * ) + * + * Notes: + * 1. All elements keys are in lowercase + * 2. the "diagrams" element is an array of arrays + * + * @param $prjUid + * @param $projectData + * @return array + */ + public static function updateFromStruct($prjUid, $projectData) + { + $diagram = isset($projectData["diagrams"]) && isset($projectData["diagrams"][0]) ? $projectData["diagrams"][0] : array(); + $result = array(); + $bwp = BpmnWorkflow::load($prjUid); + //var_dump($bwp->getUid()); die; + + /* + * Diagram's Activities Handling + */ + $whiteList = array(); + foreach ($diagram["activities"] as $i => $activityData) { + $activityData = array_change_key_case($activityData, CASE_UPPER); + unset($activityData["_EXTENDED"], $activityData["BOU_ELEMENT_ID"]); + $activityData = Util\ArrayUtil::boolToIntValues($activityData); + + $activity = $bwp->getActivity($activityData["ACT_UID"]); + if (is_null($activity)) { + $oldActUid = $activityData["ACT_UID"]; + $activityData["ACT_UID"] = Util\Common::generateUID(); + $bwp->addActivity($activityData); + $result[] = array("object" => "activity", "new_uid" => $activityData["ACT_UID"], "old_uid" => $oldActUid); + } elseif (! $bwp->isEquals($activity, $activityData)) { + $bwp->updateActivity($activityData["ACT_UID"], $activityData); + } else { + Util\Logger::log("Update Activity ({$activityData["ACT_UID"]}) Skipped - No changes required"); + } + + $diagram["activities"][$i] = $activityData; + $whiteList[] = $activityData["ACT_UID"]; + } + + $activities = $bwp->getActivities(); + + // looking for removed elements + foreach ($activities as $activityData) { + if (! in_array($activityData["ACT_UID"], $whiteList)) { + $bwp->removeActivity($activityData["ACT_UID"]); + } + } + + + /* + * Diagram's Gateways Handling + */ + $whiteList = array(); + //print_r($diagram); + foreach ($diagram["gateways"] as $i => $gatewayData) { + $gatewayData = array_change_key_case($gatewayData, CASE_UPPER); + unset($gatewayData["_EXTENDED"]); + + $gateway = $bwp->getGateway($gatewayData["GAT_UID"]); + if (is_null($gateway)) { + $oldActUid = $gatewayData["GAT_UID"]; + $gatewayData["GAT_UID"] = Util\Common::generateUID(); + $bwp->addGateway($gatewayData); + $result[] = array("object" => "gateway", "new_uid" => $gatewayData["GAT_UID"], "old_uid" => $oldActUid); + } elseif (! $bwp->isEquals($gateway, $gatewayData)) { + $bwp->updateGateway($gatewayData["GAT_UID"], $gatewayData); + } else { + Util\Logger::log("Update Gateway ({$gatewayData["GAT_UID"]}) Skipped - No changes required"); + } + + $diagram["gateways"][$i] = $gatewayData; + $whiteList[] = $gatewayData["GAT_UID"]; + } + + $gateways = $bwp->getGateways(); + + // looking for removed elements + foreach ($gateways as $gatewayData) { + if (! in_array($gatewayData["GAT_UID"], $whiteList)) { + $bwp->removeGateway($gatewayData["GAT_UID"]); + } + } + + /* + * Diagram's Events Handling + */ + $whiteList = array(); + foreach ($diagram["events"] as $i => $eventData) { + $eventData = array_change_key_case($eventData, CASE_UPPER); + unset($eventData["_EXTENDED"]); + if (array_key_exists("EVN_CANCEL_ACTIVITY", $eventData)) { + $eventData["EVN_CANCEL_ACTIVITY"] = $eventData["EVN_CANCEL_ACTIVITY"] ? 1 : 0; + } + if (array_key_exists("EVN_WAIT_FOR_COMPLETION", $eventData)) { + $eventData["EVN_WAIT_FOR_COMPLETION"] = $eventData["EVN_WAIT_FOR_COMPLETION"] ? 1 : 0; + } + + $event = $bwp->getEvent($eventData["EVN_UID"]); + if (is_null($event)) { + $oldActUid = $eventData["EVN_UID"]; + $eventData["EVN_UID"] = Util\Common::generateUID(); + $bwp->addEvent($eventData); + $result[] = array("object" => "event", "new_uid" => $eventData["EVN_UID"], "old_uid" => $oldActUid); + } elseif (! $bwp->isEquals($event, $eventData)) { + $bwp->updateEvent($eventData["EVN_UID"], $eventData); + } else { + Util\Logger::log("Update Event ({$eventData["EVN_UID"]}) Skipped - No changes required"); + } + + $diagram["events"][$i] = $eventData; + $whiteList[] = $eventData["EVN_UID"]; + } + + $events = $bwp->getEvents(); + + // looking for removed elements + foreach ($events as $eventData) { + if (! in_array($eventData["EVN_UID"], $whiteList)) { + // If it is not in the white list so, then remove them + $bwp->removeEvent($eventData["EVN_UID"]); + } + } + + + /* + * Diagram's Flows Handling + */ + $whiteList = array(); + + foreach ($diagram["flows"] as $i => $flowData) { + $flowData = array_change_key_case($flowData, CASE_UPPER); + + // if it is a new flow record + if (! \BpmnFlow::exists($flowData["FLO_UID"])) { + $oldFloUid = $flowData["FLO_UID"]; + $flowData["FLO_UID"] = Util\Common::generateUID(); + + $mappedUid = self::mapUid($flowData["FLO_ELEMENT_ORIGIN"], $result); + if ($mappedUid !== false) { + $flowData["FLO_ELEMENT_ORIGIN"] = $mappedUid; + } + + $mappedUid = self::mapUid($flowData["FLO_ELEMENT_DEST"], $result); + if ($mappedUid !== false) { + $flowData["FLO_ELEMENT_DEST"] = $mappedUid; + } + + $result[] = array("object" => "flow", "new_uid" => $flowData["FLO_UID"], "old_uid" => $oldFloUid); + } + + $diagram["flows"][$i] = $flowData; + $whiteList[] = $flowData["FLO_UID"]; + } + + foreach ($diagram["flows"] as $flowData) { + $flow = $bwp->getFlow($flowData["FLO_UID"]); + if (is_null($flow)) { + $bwp->addFlow($flowData, $diagram["flows"]); + } elseif (! $bwp->isEquals($flow, $flowData)) { + $bwp->updateFlow($flowData["FLO_UID"], $flowData, $diagram["flows"]); + } else { + Util\Logger::log("Update Flow ({$flowData["FLO_UID"]}) Skipped - No changes required"); + } + } + + $flows = $bwp->getFlows(); + + // looking for removed elements + foreach ($flows as $flowData) { + if (! in_array($flowData["FLO_UID"], $whiteList)) { + $bwp->removeFlow($flowData["FLO_UID"]); + } + } + + $bwp->mapBpmnFlowsToWorkflowRoutes(); + + return $result; + } + + protected static function mapUid($oldUid, $list) + { + foreach ($list as $item) { + if ($item["old_uid"] == $oldUid) { + return $item["new_uid"]; + } + } + + return false; + } +} diff --git a/workflow/engine/src/ProcessMaker/Project/Adapter/WorkflowBpmn.php b/workflow/engine/src/ProcessMaker/Project/Adapter/WorkflowBpmn.php index 61c658efb..0914008a3 100644 --- a/workflow/engine/src/ProcessMaker/Project/Adapter/WorkflowBpmn.php +++ b/workflow/engine/src/ProcessMaker/Project/Adapter/WorkflowBpmn.php @@ -2,7 +2,7 @@ namespace ProcessMaker\Project\Adapter; use ProcessMaker\Project; -use ProcessMaker\Util\Hash; +use ProcessMaker\Util\Common; /** * Class WorkflowBpmn diff --git a/workflow/engine/src/ProcessMaker/Project/Bpmn.php b/workflow/engine/src/ProcessMaker/Project/Bpmn.php index 8a6065f21..f08865314 100644 --- a/workflow/engine/src/ProcessMaker/Project/Bpmn.php +++ b/workflow/engine/src/ProcessMaker/Project/Bpmn.php @@ -27,7 +27,7 @@ use \BpmnArtifactPeer as ArtifactPeer; use \BasePeer; -use ProcessMaker\Util\Hash; +use ProcessMaker\Util\Common; use ProcessMaker\Exception; /** @@ -99,7 +99,7 @@ class Bpmn extends Handler public function create($data) { // setting defaults - $data['PRJ_UID'] = array_key_exists('PRJ_UID', $data) ? $data['PRJ_UID'] : Hash::generateUID(); + $data['PRJ_UID'] = array_key_exists('PRJ_UID', $data) ? $data['PRJ_UID'] : Common::generateUID(); self::log("Create Project with data: ", $data); $this->project = new Project(); @@ -175,6 +175,11 @@ class Bpmn extends Handler return $this->prjUid; } + /** + * @param string $retType + * @return array|Project + * @throws \RuntimeException + */ public function getProject($retType = "array") { if (empty($this->project)) { @@ -195,7 +200,7 @@ class Bpmn extends Handler } // setting defaults - $data['DIA_UID'] = array_key_exists('DIA_UID', $data) ? $data['DIA_UID'] : Hash::generateUID(); + $data['DIA_UID'] = array_key_exists('DIA_UID', $data) ? $data['DIA_UID'] : Common::generateUID(); $data['DIA_NAME'] = array_key_exists('DIA_NAME', $data) ? $data['DIA_NAME'] : $this->project->getPrjName(); $this->diagram = new Diagram(); @@ -225,7 +230,7 @@ class Bpmn extends Handler } // setting defaults - $data['PRO_UID'] = array_key_exists('PRO_UID', $data) ? $data['PRO_UID'] : Hash::generateUID();; + $data['PRO_UID'] = array_key_exists('PRO_UID', $data) ? $data['PRO_UID'] : Common::generateUID();; $data['PRO_NAME'] = array_key_exists('PRO_NAME', $data) ? $data['PRO_NAME'] : $this->diagram->getDiaName(); $this->process = new Process(); @@ -256,7 +261,7 @@ class Bpmn extends Handler } // setting defaults - $data['ACT_UID'] = array_key_exists('ACT_UID', $data) ? $data['ACT_UID'] : Hash::generateUID();; + $data['ACT_UID'] = array_key_exists('ACT_UID', $data) ? $data['ACT_UID'] : Common::generateUID();; try { self::log("Add Activity with data: ", $data); @@ -342,7 +347,7 @@ class Bpmn extends Handler public function addEvent($data) { // setting defaults - $data['EVN_UID'] = array_key_exists('EVN_UID', $data) ? $data['EVN_UID'] : Hash::generateUID(); + $data['EVN_UID'] = array_key_exists('EVN_UID', $data) ? $data['EVN_UID'] : Common::generateUID(); try { self::log("Add Event with data: ", $data); @@ -432,7 +437,7 @@ class Bpmn extends Handler public function addGateway($data) { // setting defaults - $data['GAT_UID'] = array_key_exists('GAT_UID', $data) ? $data['GAT_UID'] : Hash::generateUID(); + $data['GAT_UID'] = array_key_exists('GAT_UID', $data) ? $data['GAT_UID'] : Common::generateUID(); try { self::log("Add Gateway with data: ", $data); @@ -517,7 +522,7 @@ class Bpmn extends Handler self::log("Add Flow with data: ", $data); // setting defaults - $data['FLO_UID'] = array_key_exists('FLO_UID', $data) ? $data['FLO_UID'] : Hash::generateUID(); + $data['FLO_UID'] = array_key_exists('FLO_UID', $data) ? $data['FLO_UID'] : Common::generateUID(); if (array_key_exists('FLO_STATE', $data)) { $data['FLO_STATE'] = is_array($data['FLO_STATE']) ? json_encode($data['FLO_STATE']) : $data['FLO_STATE']; } diff --git a/workflow/engine/src/ProcessMaker/Project/Workflow.php b/workflow/engine/src/ProcessMaker/Project/Workflow.php index 14162a8d8..b98cb07e1 100644 --- a/workflow/engine/src/ProcessMaker/Project/Workflow.php +++ b/workflow/engine/src/ProcessMaker/Project/Workflow.php @@ -10,8 +10,9 @@ use \Task; use \Route; use \RoutePeer; -use ProcessMaker\Util\Hash; +use ProcessMaker\Util\Common; use ProcessMaker\Exception; +use ProcessMaker\Util; /** * Class Workflow @@ -55,7 +56,7 @@ class Workflow extends Handler public function create($data) { // setting defaults - $data['PRO_UID'] = array_key_exists('PRO_UID', $data) ? $data['PRO_UID'] : Hash::generateUID(); + $data['PRO_UID'] = array_key_exists('PRO_UID', $data) ? $data['PRO_UID'] : Common::generateUID(); $data['USR_UID'] = array_key_exists('PRO_CREATE_USER', $data) ? $data['PRO_CREATE_USER'] : null; $data['PRO_TITLE'] = array_key_exists('PRO_TITLE', $data) ? trim($data['PRO_TITLE']) : ""; $data['PRO_CATEGORY'] = array_key_exists('PRO_CATEGORY', $data) ? $data['PRO_CATEGORY'] : ""; @@ -165,7 +166,7 @@ class Workflow extends Handler public function addTask($taskData) { // Setting defaults - $taskData['TAS_UID'] = array_key_exists('TAS_UID', $taskData) ? $taskData['TAS_UID'] : Hash::generateUID(); + $taskData['TAS_UID'] = array_key_exists('TAS_UID', $taskData) ? $taskData['TAS_UID'] : Common::generateUID(); $taskData['PRO_UID'] = $this->proUid; try { @@ -173,6 +174,12 @@ class Workflow extends Handler $task = new Task(); $tasUid = $task->create($taskData, false); self::log("Add Task Success!"); + + // SubProcess Handling + if ($task->getTasType() == "SUBPROCESS") { + $this->addSubProcess($this->proUid, $tasUid); + } + } catch (\Exception $e) { self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString()); throw $e; @@ -201,9 +208,17 @@ class Workflow extends Handler { try { self::log("Remove Task: $tasUid"); + $task = \TaskPeer::retrieveByPK($tasUid); + $tasType = $task->getTasType(); + $task = new Tasks(); $task->deleteTask($tasUid); self::log("Remove Task Success!"); + + if ($tasType == "SUBPROCESS") { + $this->removeSupProcess($this->proUid, $tasUid); + } + } catch (\Exception $e) { self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString()); throw $e; @@ -237,6 +252,53 @@ class Workflow extends Handler return $tasks->getAllTasks($this->proUid); } + public function addSubProcess($proUid = '', $tasUid)//$iX = 0, $iY = 0) + { + try { + $subProcess = new \SubProcess(); + $data = array( + 'SP_UID' => Util\Common::generateUID(), + 'PRO_UID' => 0, + 'TAS_UID' => 0, + 'PRO_PARENT' => $proUid, + 'TAS_PARENT' => $tasUid, + 'SP_TYPE' => 'SIMPLE', + 'SP_SYNCHRONOUS' => 0, + 'SP_SYNCHRONOUS_TYPE' => 'ALL', + 'SP_SYNCHRONOUS_WAIT' => 0, + 'SP_VARIABLES_OUT' => '', + 'SP_VARIABLES_IN' => '', + 'SP_GRID_IN' => '' + ); + + self::log("Adding SubProcess with data: ", $data); + $spUid = $subProcess->create($data); + self::log("Adding SubProcess success!, created sp_uid: ", $spUid); + + return $spUid; + } catch (\Exception $oError) { + throw ($oError); + } + } + + public function removeSupProcess($proUid, $tasUid) + { + try { + $subProcess = \SubProcess::findByParents($proUid, $tasUid); + self::log("Remove SupProcess: ".$subProcess->getSpUid()); + $subProcess->delete(); + self::log("Remove SupProcess Success!"); + } catch (\Exception $e) { + self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString()); + throw $e; + } + } + + public function updateSubProcess() + { + + } + /** * @param string $tasUid * @param bool $value diff --git a/workflow/engine/src/ProcessMaker/Util/Common.php b/workflow/engine/src/ProcessMaker/Util/Common.php index 6245c1e84..8991e303b 100644 --- a/workflow/engine/src/ProcessMaker/Util/Common.php +++ b/workflow/engine/src/ProcessMaker/Util/Common.php @@ -3,4 +3,65 @@ namespace ProcessMaker\Util; class Common extends \Maveriks\Util\Common { + /** + * Generate random number + * + * @author Fernando Ontiveros Lira + * @access public + * @return string + */ + public static function generateUID() + { + do { + $sUID = str_replace('.', '0', uniqid(rand(0, 999999999), true)); + } while (strlen( $sUID ) != 32); + + return $sUID; + } + + /** + * Generate a numeric or alphanumeric code + * + * @author Julio Cesar Laura AvendaƱo + * @access public + * @param int $iDigits + * @param string $sType + * @return string + */ + public function generateCode($iDigits = 4, $sType = 'NUMERIC') + { + if (($iDigits < 4) || ($iDigits > 50)) { + $iDigits = 4; + } + if (($sType != 'NUMERIC') && ($sType != 'ALPHA') && ($sType != 'ALPHANUMERIC')) { + $sType = 'NUMERIC'; + } + + $aValidCharacters = array( + '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H', + 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' + ); + + switch ($sType) { + case 'NUMERIC': + $iMin = 0; + $iMax = 9; + break; + case 'ALPHA': + $iMin = 10; + $iMax = 35; + break; + case 'ALPHANUMERIC': + $iMin = 0; + $iMax = 35; + break; + } + + $sCode = ''; + for ($i = 0; $i < $iDigits; $i ++) { + $sCode .= $aValidCharacters[rand($iMin, $iMax)]; + } + + return $sCode; + } } \ No newline at end of file diff --git a/workflow/engine/src/ProcessMaker/Util/Hash.php b/workflow/engine/src/ProcessMaker/Util/Hash.php deleted file mode 100644 index 3e6e22ee5..000000000 --- a/workflow/engine/src/ProcessMaker/Util/Hash.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @access public - * @return string - */ - public static function generateUID() - { - do { - $sUID = str_replace('.', '0', uniqid(rand(0, 999999999), true)); - } while (strlen( $sUID ) != 32); - - return $sUID; - } - - /** - * Generate a numeric or alphanumeric code - * - * @author Julio Cesar Laura AvendaƱo - * @access public - * @param int $iDigits - * @param string $sType - * @return string - */ - public function generateCode($iDigits = 4, $sType = 'NUMERIC') - { - if (($iDigits < 4) || ($iDigits > 50)) { - $iDigits = 4; - } - if (($sType != 'NUMERIC') && ($sType != 'ALPHA') && ($sType != 'ALPHANUMERIC')) { - $sType = 'NUMERIC'; - } - - $aValidCharacters = array( - '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H', - 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' - ); - - switch ($sType) { - case 'NUMERIC': - $iMin = 0; - $iMax = 9; - break; - case 'ALPHA': - $iMin = 10; - $iMax = 35; - break; - case 'ALPHANUMERIC': - $iMin = 0; - $iMax = 35; - break; - } - - $sCode = ''; - for ($i = 0; $i < $iDigits; $i ++) { - $sCode .= $aValidCharacters[rand($iMin, $iMax)]; - } - - return $sCode; - } -} - diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Cases.php b/workflow/engine/src/Services/Api/ProcessMaker/Cases.php index 822c4e5af..2aa46d61a 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Cases.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Cases.php @@ -721,7 +721,7 @@ class Cases extends Api * @author Brayan Pereyra (Cochalo) * @copyright Colosa - Bolivia * - * @url PUT /:cas_uid/cancel-case + * @url PUT /:cas_uid/cancel */ public function doPutCancelCase($cas_uid) { @@ -743,7 +743,7 @@ class Cases extends Api * @author Brayan Pereyra (Cochalo) * @copyright Colosa - Bolivia * - * @url PUT /:cas_uid/pause-case + * @url PUT /:cas_uid/pause */ public function doPutPauseCase($cas_uid, $unpaused_date = null) { @@ -768,7 +768,7 @@ class Cases extends Api * @author Brayan Pereyra (Cochalo) * @copyright Colosa - Bolivia * - * @url PUT /:cas_uid/unpause-case + * @url PUT /:cas_uid/unpause */ public function doPutUnpauseCase($cas_uid) { @@ -822,5 +822,93 @@ class Cases extends Api throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } + + /** + * Get Case Variables + * + * @param string $app_uid {@min 1}{@max 32} + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + * + * @url GET /:app_uid/variables + */ + public function doGetCaseVariables($app_uid) + { + try { + $cases = new \BusinessModel\Cases(); + $response = $cases->getCaseVariables($app_uid); + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * Put Case Variables + * + * @param string $app_uid {@min 1}{@max 32} + * @param array $request_data + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + * + * @url PUT /:app_uid/variable + */ + public function doPutCaseVariables($app_uid, $request_data) + { + try { + $cases = new \BusinessModel\Cases(); + $cases->setCaseVariables($app_uid, $request_data); + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * Get Case Notes + * + * @param string $app_uid {@min 1}{@max 32} + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + * + * @url GET /:app_uid/notes + */ + public function doGetCaseNotes($app_uid) + { + try { + $usr_uid = $this->getUserId(); + $cases = new \BusinessModel\Cases(); + $response = $cases->getCaseNotes($app_uid, $usr_uid); + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * Put Case Variables + * + * @param string $app_uid {@min 1}{@max 32} + * @param string $note_content {@min 1}{@max 500} + * @param int $send_mail {@choice 1,0} + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + * + * @url POST /:app_uid/note + */ + public function doPostCaseNote($app_uid, $note_content, $send_mail = 0) + { + try { + $usr_uid = $this->getUserId(); + $cases = new \BusinessModel\Cases(); + $send_mail = ($send_mail == 0) ? false : true; + $cases->saveCaseNote($app_uid, $usr_uid, $note_content, $send_mail); + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } } diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Cases/InputDocument.php b/workflow/engine/src/Services/Api/ProcessMaker/Cases/InputDocument.php index 7a4fc778e..69e413233 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Cases/InputDocument.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Cases/InputDocument.php @@ -12,16 +12,16 @@ use \Luracast\Restler\RestException; class InputDocument extends Api { /** - * @url GET /:cas_uid/input-documents + * @url GET /:app_uid/input-documents * - * @param string $cas_uid {@min 32}{@max 32} + * @param string $app_uid {@min 32}{@max 32} */ - public function doGetInputDocuments($cas_uid) + public function doGetInputDocuments($app_uid) { try { $userUid = $this->getUserId(); $inputDocument = new \BusinessModel\Cases\InputDocument(); - $response = $inputDocument->getCasesInputDocuments($cas_uid, $userUid); + $response = $inputDocument->getCasesInputDocuments($app_uid, $userUid); return $response; } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); @@ -29,17 +29,17 @@ class InputDocument extends Api } /** - * @url GET /:cas_uid/input-document/:inp_doc_uid + * @url GET /:app_uid/input-document/:inp_doc_uid * - * @param string $cas_uid {@min 32}{@max 32} + * @param string $app_uid {@min 32}{@max 32} * @param string $inp_doc_uid {@min 32}{@max 32} */ - public function doGetInputDocument($cas_uid, $inp_doc_uid) + public function doGetInputDocument($app_uid, $inp_doc_uid) { try { $userUid = $this->getUserId(); $inputDocument = new \BusinessModel\Cases\InputDocument(); - $response = $inputDocument->getCasesInputDocument($cas_uid, $userUid, $inp_doc_uid); + $response = $inputDocument->getCasesInputDocument($app_uid, $userUid, $inp_doc_uid); return $response; } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); @@ -47,12 +47,12 @@ class InputDocument extends Api } /** - * @url DELETE /:cas_uid/input-document/:inp_doc_uid + * @url DELETE /:app_uid/input-document/:inp_doc_uid * - * @param string $cas_uid {@min 32}{@max 32} + * @param string $app_uid {@min 32}{@max 32} * @param string $inp_doc_uid {@min 32}{@max 32} */ - public function doDeleteInputDocument($cas_uid, $inp_doc_uid) + public function doDeleteInputDocument($app_uid, $inp_doc_uid) { try { $inputDocument = new \BusinessModel\Cases\InputDocument(); @@ -62,22 +62,22 @@ class InputDocument extends Api } } /** - * @url POST /:cas_uid/input-document + * @url POST /:app_uid/input-document * - * @param string $cas_uid {@min 32}{@max 32} + * @param string $app_uid { @min 32}{@max 32} + * @param string $tas_uid {@min 32}{@max 32} + * @param string $app_doc_comment * @param string $inp_doc_uid {@min 32}{@max 32} */ - public function doPostInputDocument($cas_uid, $inp_doc_uid) + public function doPostInputDocument($app_uid, $tas_uid, $app_doc_comment, $inp_doc_uid) { try { $userUid = $this->getUserId(); $inputDocument = new \BusinessModel\Cases\InputDocument(); - $response = $inputDocument->addCasesInputDocument($cas_uid, $inp_doc_uid, $userUid); + $response = $inputDocument->addCasesInputDocument($app_uid, $tas_uid, $app_doc_comment, $inp_doc_uid, $userUid); return $response; } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } } - - diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Cases/OutputDocument.php b/workflow/engine/src/Services/Api/ProcessMaker/Cases/OutputDocument.php index 1b42e53e8..009891848 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Cases/OutputDocument.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Cases/OutputDocument.php @@ -12,16 +12,16 @@ use \Luracast\Restler\RestException; class OutputDocument extends Api { /** - * @url GET /:cas_uid/output-documents + * @url GET /:app_uid/output-documents * - * @param string $cas_uid {@min 32}{@max 32} + * @param string $app_uid {@min 32}{@max 32} */ - public function doGetOutputDocuments($cas_uid) + public function doGetOutputDocuments($app_uid) { try { $userUid = $this->getUserId(); $outputDocument = new \BusinessModel\Cases\OutputDocument(); - $response = $outputDocument->getCasesOutputDocuments($cas_uid, $userUid); + $response = $outputDocument->getCasesOutputDocuments($app_uid, $userUid); return $response; } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); @@ -29,17 +29,17 @@ class OutputDocument extends Api } /** - * @url GET /:cas_uid/output-document/:out_doc_uid + * @url GET /:app_uid/output-document/:app_doc_uid * - * @param string $cas_uid {@min 32}{@max 32} - * @param string $out_doc_uid {@min 32}{@max 32} + * @param string $app_uid {@min 32}{@max 32} + * @param string $app_doc_uid {@min 32}{@max 32} */ - public function doGetOutputDocument($cas_uid, $out_doc_uid) + public function doGetOutputDocument($app_uid, $app_doc_uid) { try { $userUid = $this->getUserId(); $outputDocument = new \BusinessModel\Cases\OutputDocument(); - $response = $outputDocument->getCasesOutputDocument($cas_uid, $userUid, $out_doc_uid); + $response = $outputDocument->getCasesOutputDocument($app_uid, $userUid, $app_doc_uid); return $response; } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); @@ -47,32 +47,32 @@ class OutputDocument extends Api } /** - * @url DELETE /:cas_uid/output-document/:out_doc_uid + * @url DELETE /:app_uid/output-document/:app_doc_uid * - * @param string $cas_uid {@min 32}{@max 32} - * @param string $out_doc_uid {@min 32}{@max 32} + * @param string $app_uid {@min 32}{@max 32} + * @param string $app_doc_uid {@min 32}{@max 32} */ - public function doDeleteOutputDocument($cas_uid, $out_doc_uid) + public function doDeleteOutputDocument($app_uid, $app_doc_uid) { try { $outputDocument = new \BusinessModel\Cases\OutputDocument(); - $outputDocument->removeOutputDocument($out_doc_uid); + $outputDocument->removeOutputDocument($app_doc_uid); } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } /** - * @url POST /:cas_uid/output-document + * @url POST /:app_uid/output-document * - * @param string $cas_uid {@min 32}{@max 32} + * @param string $app_uid {@min 32}{@max 32} * @param string $out_doc_uid {@min 32}{@max 32} */ - public function doPostOutputDocument($cas_uid, $out_doc_uid) + public function doPostOutputDocument($app_uid, $out_doc_uid) { try { $userUid = $this->getUserId(); $outputDocument = new \BusinessModel\Cases\OutputDocument(); - $response = $outputDocument->addCasesOutputDocument($cas_uid, $out_doc_uid, $userUid); + $response = $outputDocument->addCasesOutputDocument($app_uid, $out_doc_uid, $userUid); return $response; } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Project.php b/workflow/engine/src/Services/Api/ProcessMaker/Project.php index d8f866620..ed9e38505 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Project.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Project.php @@ -3,7 +3,6 @@ namespace Services\Api\ProcessMaker; use Luracast\Restler\RestException; use ProcessMaker\Services\Api; -use ProcessMaker\Adapter\Bpmn\Model as BpmnModel; use \ProcessMaker\Project\Adapter; use \ProcessMaker\Util; @@ -35,29 +34,7 @@ class Project extends Api public function get($prjUid) { try { - $bwp = Adapter\BpmnWorkflow::load($prjUid); - - $project = array_change_key_case($bwp->getProject(), CASE_LOWER); - $diagram = $bwp->getDiagram(); - $process = $bwp->getProcess(); - $diagram["pro_uid"] = $process["PRO_UID"]; - - $configList = array("changeCaseTo" => CASE_LOWER); - - if (! is_null($diagram)) { - $diagram = array_change_key_case($diagram, CASE_LOWER); - $diagram["activities"] = $bwp->getActivities($configList); - $diagram["events"] = $bwp->getEvents($configList); - $diagram["gateways"] = $bwp->getGateways($configList); - $diagram["flows"] = $bwp->getFlows($configList); - $diagram["artifacts"] = $bwp->getArtifacts($configList); - $diagram["laneset"] = $bwp->getLanesets($configList); - $diagram["lanes"] = $bwp->getLanes($configList); - - $project["diagrams"][] = $diagram; - } - - return $project; + return Adapter\BpmnWorkflow::getStruct($prjUid); } catch (\Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } @@ -69,28 +46,7 @@ class Project extends Api public function post($request_data) { try { -// NEED REFACTOR -// $config = array(); -// $config['project'] = array('replace_uids' => true); -// -// $bpmnModel = new BpmnModel(); -// $result = $bpmnModel->createProject($request_data, $config['project']['replace_uids']); -// -// if (array_key_exists('prj_uid', $result)) { -// $prjUid = $result['prj_uid']; -// } else { -// $prjUid = $result[0]['new_uid']; -// } -// -// $wfProcess = Workflow::loadFromBpmnProject($prjUid); -// -// $process = new \BusinessModel\Process(); -// $userUid = $this->getUserId(); -// $data = array('process' => $wfProcess); -// -// $process->createProcess($userUid, $data); - -// return $result; + //TODO } catch (\Exception $e) { // TODO in case that $process->createProcess($userUid, $data); fails maybe the BPMN project was created successfully // so, we need remove it or change the creation order. @@ -102,173 +58,7 @@ class Project extends Api public function put($prjUid, $request_data) { try { - $projectData = $request_data; - $diagram = isset($projectData["diagrams"]) && isset($projectData["diagrams"][0]) ? $projectData["diagrams"][0] : array(); - $result = array(); - $bwp = Adapter\BpmnWorkflow::load($prjUid); - - /* - * Diagram's Activities Handling - */ - $whiteList = array(); - foreach ($diagram["activities"] as $i => $activityData) { - $activityData = array_change_key_case($activityData, CASE_UPPER); - unset($activityData["_EXTENDED"], $activityData["BOU_ELEMENT_ID"]); - $activityData = Util\ArrayUtil::boolToIntValues($activityData); - - $activity = $bwp->getActivity($activityData["ACT_UID"]); - if (is_null($activity)) { - $oldActUid = $activityData["ACT_UID"]; - $activityData["ACT_UID"] = Util\Hash::generateUID(); - $bwp->addActivity($activityData); - $result[] = array("object" => "activity", "new_uid" => $activityData["ACT_UID"], "old_uid" => $oldActUid); - } elseif (! $bwp->isEquals($activity, $activityData)) { - $bwp->updateActivity($activityData["ACT_UID"], $activityData); - } else { - Util\Logger::log("Update Activity ({$activityData["ACT_UID"]}) Skipped - No changes required"); - } - - $diagram["activities"][$i] = $activityData; - $whiteList[] = $activityData["ACT_UID"]; - } - - $activities = $bwp->getActivities(); - - // looking for removed elements - foreach ($activities as $activityData) { - if (! in_array($activityData["ACT_UID"], $whiteList)) { - $bwp->removeActivity($activityData["ACT_UID"]); - } - } - - - /* - * Diagram's Gateways Handling - */ - $whiteList = array(); - foreach ($diagram["gateways"] as $i => $gatewayData) { - $gatewayData = array_change_key_case($gatewayData, CASE_UPPER); - unset($gatewayData["_EXTENDED"]); - - $gateway = $bwp->getGateway($gatewayData["GAT_UID"]); - if (is_null($gateway)) { - $oldActUid = $gatewayData["GAT_UID"]; - $gatewayData["GAT_UID"] = Util\Hash::generateUID(); - $bwp->addGateway($gatewayData); - $result[] = array("object" => "gateway", "new_uid" => $gatewayData["GAT_UID"], "old_uid" => $oldActUid); - } elseif (! $bwp->isEquals($gateway, $gatewayData)) { - $bwp->updateGateway($gatewayData["GAT_UID"], $gatewayData); - } else { - Util\Logger::log("Update Gateway ({$gatewayData["GAT_UID"]}) Skipped - No changes required"); - } - - $diagram["gateways"][$i] = $gatewayData; - $whiteList[] = $gatewayData["GAT_UID"]; - } - - $gateways = $bwp->getGateways(); - - // looking for removed elements - foreach ($gateways as $gatewayData) { - if (! in_array($gatewayData["GAT_UID"], $whiteList)) { - $bwp->removeGateway($gatewayData["GAT_UID"]); - } - } - - /* - * Diagram's Events Handling - */ - $whiteList = array(); - foreach ($diagram["events"] as $i => $eventData) { - $eventData = array_change_key_case($eventData, CASE_UPPER); - unset($eventData["_EXTENDED"]); - if (array_key_exists("EVN_CANCEL_ACTIVITY", $eventData)) { - $eventData["EVN_CANCEL_ACTIVITY"] = $eventData["EVN_CANCEL_ACTIVITY"] ? 1 : 0; - } - if (array_key_exists("EVN_WAIT_FOR_COMPLETION", $eventData)) { - $eventData["EVN_WAIT_FOR_COMPLETION"] = $eventData["EVN_WAIT_FOR_COMPLETION"] ? 1 : 0; - } - - $event = $bwp->getEvent($eventData["EVN_UID"]); - if (is_null($event)) { - $oldActUid = $eventData["EVN_UID"]; - $eventData["EVN_UID"] = Util\Hash::generateUID(); - $bwp->addEvent($eventData); - $result[] = array("object" => "event", "new_uid" => $eventData["EVN_UID"], "old_uid" => $oldActUid); - } elseif (! $bwp->isEquals($event, $eventData)) { - $bwp->updateEvent($eventData["EVN_UID"], $eventData); - } else { - Util\Logger::log("Update Event ({$eventData["EVN_UID"]}) Skipped - No changes required"); - } - - $diagram["events"][$i] = $eventData; - $whiteList[] = $eventData["EVN_UID"]; - } - - $events = $bwp->getEvents(); - - // looking for removed elements - foreach ($events as $eventData) { - if (! in_array($eventData["EVN_UID"], $whiteList)) { - // If it is not in the white list so, then remove them - $bwp->removeEvent($eventData["EVN_UID"]); - } - } - - - /* - * Diagram's Flows Handling - */ - $whiteList = array(); - - foreach ($diagram["flows"] as $i => $flowData) { - $flowData = array_change_key_case($flowData, CASE_UPPER); - - // if it is a new flow record - if (! \BpmnFlow::exists($flowData["FLO_UID"])) { - $oldFloUid = $flowData["FLO_UID"]; - $flowData["FLO_UID"] = Util\Hash::generateUID(); - - $mappedUid = self::mapUid($flowData["FLO_ELEMENT_ORIGIN"], $result); - if ($mappedUid !== false) { - $flowData["FLO_ELEMENT_ORIGIN"] = $mappedUid; - } - - $mappedUid = self::mapUid($flowData["FLO_ELEMENT_DEST"], $result); - if ($mappedUid !== false) { - $flowData["FLO_ELEMENT_DEST"] = $mappedUid; - } - - $result[] = array("object" => "flow", "new_uid" => $flowData["FLO_UID"], "old_uid" => $oldFloUid); - } - - $diagram["flows"][$i] = $flowData; - $whiteList[] = $flowData["FLO_UID"]; - } - - foreach ($diagram["flows"] as $flowData) { - $flow = $bwp->getFlow($flowData["FLO_UID"]); - if (is_null($flow)) { - $bwp->addFlow($flowData, $diagram["flows"]); - } elseif (! $bwp->isEquals($flow, $flowData)) { - $bwp->updateFlow($flowData["FLO_UID"], $flowData, $diagram["flows"]); - } else { - Util\Logger::log("Update Flow ({$flowData["FLO_UID"]}) Skipped - No changes required"); - } - } - - $flows = $bwp->getFlows(); - - // looking for removed elements - foreach ($flows as $flowData) { - if (! in_array($flowData["FLO_UID"], $whiteList)) { - $bwp->removeFlow($flowData["FLO_UID"]); - } - } - - $bwp->mapBpmnFlowsToWorkflowRoutes(); - - return $result; + return Adapter\BpmnWorkflow::updateFromStruct($prjUid, $request_data); } catch (\Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } @@ -277,10 +67,7 @@ class Project extends Api public function delete($prjUid) { try { - $process = new \BusinessModel\Process(); - $process->deleteProcess($prjUid); - - BpmnModel::deleteProject($prjUid); + // TODO } catch (\Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } @@ -385,17 +172,6 @@ class Project extends Api } } - protected static function mapUid($oldUid, $list) - { - foreach ($list as $item) { - if ($item["old_uid"] == $oldUid) { - return $item["new_uid"]; - } - } - - return false; - } - /** * @url GET /:prj_uid/variables * diff --git a/workflow/engine/src/Tests/BusinessModel/CasesActionTest13_17.php b/workflow/engine/src/Tests/BusinessModel/CasesActionTest13_17.php new file mode 100644 index 000000000..861b7a7d3 --- /dev/null +++ b/workflow/engine/src/Tests/BusinessModel/CasesActionTest13_17.php @@ -0,0 +1,392 @@ + + * @copyright Colosa - Bolivia + * + * @protected + * @package Tests\BusinessModel + */ +class CasesAction13_17Test extends \PHPUnit_Framework_TestCase +{ + protected $oCases; + protected $nowCountTodo = 0; + protected $nowCountDraft = 0; + protected $nowCountPaused = 0; + protected $idCaseToDo = ''; + protected $idCaseDraft = ''; + + /** + * Set class for test + * + * @coversNothing + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function setUp() + { + \G::loadClass('pmFunctions'); + + $usrUid = '00000000000000000000000000000001'; + $proUid = '2317283235320c1a36972b2028131767'; + $tasUid = '7983935495320c1a75e1df6068322280'; + $idCaseToDo = PMFNewCase($proUid, $usrUid, $tasUid, array()); + PMFDerivateCase($idCaseToDo, 1); + $this->idCaseToDo = $idCaseToDo; + + $idCaseDraft = PMFNewCase($proUid, $usrUid, $tasUid, array()); + $this->idCaseDraft = $idCaseDraft; + + $this->oCases = new \BusinessModel\Cases(); + $listToDo = $this->oCases->getList(array('userId' => '00000000000000000000000000000001')); + $this->nowCountTodo = $listToDo['total']; + + $listDraft = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'draft')); + $this->nowCountDraft = $listDraft['total']; + + $listPaused = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'paused')); + $this->nowCountPaused = $listPaused['total']; + } + + /** + * Test error for type in first field the function + * + * @covers \BusinessModel\Cases::putCancelCase + * @expectedException Exception + * @expectedExceptionMessage Invalid value for '$app_uid' it must be a string. + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testPutCancelCaseErrorAppUidArray() + { + $this->oCases->putCancelCase(array(), '00000000000000000000000000000001'); + } + + /** + * Test error for type in first field the function + * + * @covers \BusinessModel\Cases::putCancelCase + * @expectedException Exception + * @expectedExceptionMessage The application with $app_uid: 'IdDoesNotExists' does not exist. + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testPutCancelCaseErrorAppUidIncorrect() + { + $this->oCases->putCancelCase('IdDoesNotExists', '00000000000000000000000000000001'); + } + + /** + * Test error for type in second field the function + * + * @covers \BusinessModel\Cases::putCancelCase + * @expectedException Exception + * @expectedExceptionMessage Invalid value for '$usr_uid' it must be a string. + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testPutCancelCaseErrorUsrUidArray() + { + $this->oCases->putCancelCase($this->idCaseDraft, array()); + } + + /** + * Test error for type in second field the function + * + * @covers \BusinessModel\Cases::putCancelCase + * @expectedException Exception + * @expectedExceptionMessage The user with $usr_uid: 'IdDoesNotExists' does not exist. + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testPutCancelCaseErrorUsrUidIncorrect() + { + $this->oCases->putCancelCase($this->idCaseDraft, 'IdDoesNotExists'); + } + + /** + * Test error for type in third field the function + * + * @covers \BusinessModel\Cases::putCancelCase + * @expectedException Exception + * @expectedExceptionMessage Invalid value for '$del_index' it must be a integer. + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testPutCancelCaseErrorDelIndexIncorrect() + { + $this->oCases->putCancelCase($this->idCaseDraft, '00000000000000000000000000000001', 'string'); + } + + /** + * Test for cancel case + * + * @covers \BusinessModel\Cases::putCancelCase + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testPutCancelCase() + { + $this->oCases->putCancelCase($this->idCaseDraft, '00000000000000000000000000000001'); + $this->oCases = new \BusinessModel\Cases(); + $listDraft = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'draft')); + $this->assertNotEquals($this->nowCountDraft, $listDraft['total']); + } + + /** + * Test error for type in first field the function + * + * @covers \BusinessModel\Cases::putPauseCase + * @expectedException Exception + * @expectedExceptionMessage Invalid value for '$app_uid' it must be a string. + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testPutPauseCaseErrorAppUidArray() + { + $this->oCases->putPauseCase(array(), '00000000000000000000000000000001'); + } + + /** + * Test error for type in first field the function + * + * @covers \BusinessModel\Cases::putPauseCase + * @expectedException Exception + * @expectedExceptionMessage The application with $app_uid: 'IdDoesNotExists' does not exist. + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testPutPauseCaseErrorAppUidIncorrect() + { + $this->oCases->putPauseCase('IdDoesNotExists', '00000000000000000000000000000001'); + } + + /** + * Test error for type in second field the function + * + * @covers \BusinessModel\Cases::putPauseCase + * @expectedException Exception + * @expectedExceptionMessage Invalid value for '$usr_uid' it must be a string. + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testPutPauseCaseErrorUsrUidArray() + { + $this->oCases->putPauseCase($this->idCaseDraft, array()); + } + + /** + * Test error for type in second field the function + * + * @covers \BusinessModel\Cases::putPauseCase + * @expectedException Exception + * @expectedExceptionMessage The user with $usr_uid: 'IdDoesNotExists' does not exist. + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testPutPauseCaseErrorUsrUidIncorrect() + { + $this->oCases->putPauseCase($this->idCaseDraft, 'IdDoesNotExists'); + } + + /** + * Test error for type in third field the function + * + * @covers \BusinessModel\Cases::putPauseCase + * @expectedException Exception + * @expectedExceptionMessage Invalid value for '$del_index' it must be a integer. + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testPutPauseCaseErrorDelIndexIncorrect() + { + $this->oCases->putPauseCase($this->idCaseDraft, '00000000000000000000000000000001', 'string'); + } + + /** + * Test error for type in fourth field the function + * + * @covers \BusinessModel\Cases::putPauseCase + * @expectedException Exception + * @expectedExceptionMessage The value '2014-44-44' is not a valid date for the format 'Y-m-d'. + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testPutPauseCaseErrorDateIncorrect() + { + $this->oCases->putPauseCase($this->idCaseDraft, '00000000000000000000000000000001', false, '2014-44-44'); + } + + /** + * Test for cancel case + * + * @covers \BusinessModel\Cases::putPauseCase + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testPutPauseCase() + { + $this->oCases->putPauseCase($this->idCaseToDo, '00000000000000000000000000000001'); + $this->oCases = new \BusinessModel\Cases(); + $listPaused = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'paused')); + $this->assertNotEquals($this->nowCountPaused, $listPaused['total']); + } + + /** + * Test error for type in first field the function + * + * @covers \BusinessModel\Cases::putUnpauseCase + * @expectedException Exception + * @expectedExceptionMessage Invalid value for '$app_uid' it must be a string. + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testPutUnpauseCaseErrorAppUidArray() + { + $this->oCases->putUnpauseCase(array(), '00000000000000000000000000000001'); + } + + /** + * Test error for type in first field the function + * + * @covers \BusinessModel\Cases::putUnpauseCase + * @expectedException Exception + * @expectedExceptionMessage The application with $app_uid: 'IdDoesNotExists' does not exist. + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testPutUnpauseCaseErrorAppUidIncorrect() + { + $this->oCases->putUnpauseCase('IdDoesNotExists', '00000000000000000000000000000001'); + } + + /** + * Test error for type in second field the function + * + * @covers \BusinessModel\Cases::putUnpauseCase + * @expectedException Exception + * @expectedExceptionMessage Invalid value for '$usr_uid' it must be a string. + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testPutUnpauseCaseErrorUsrUidArray() + { + $this->oCases->putUnpauseCase($this->idCaseDraft, array()); + } + + /** + * Test error for type in second field the function + * + * @covers \BusinessModel\Cases::putUnpauseCase + * @expectedException Exception + * @expectedExceptionMessage The user with $usr_uid: 'IdDoesNotExists' does not exist. + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testPutUnpauseCaseErrorUsrUidIncorrect() + { + $this->oCases->putUnpauseCase($this->idCaseDraft, 'IdDoesNotExists'); + } + + /** + * Test error for type in third field the function + * + * @covers \BusinessModel\Cases::putUnpauseCase + * @expectedException Exception + * @expectedExceptionMessage Invalid value for '$del_index' it must be a integer. + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testPutUnpauseCaseErrorDelIndexIncorrect() + { + $this->oCases->putUnpauseCase($this->idCaseDraft, '00000000000000000000000000000001', 'string'); + } + + /** + * Test for cancel case + * + * @covers \BusinessModel\Cases::putUnpauseCase + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testPutUnpauseCase() + { + $this->oCases->putUnpauseCase($this->idCaseToDo, '00000000000000000000000000000001'); + $this->oCases = new \BusinessModel\Cases(); + $listPaused = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'paused')); + $this->assertEquals($this->nowCountPaused, $listPaused['total']); + } + + /** + * Test error for type in first field the function + * + * @covers \BusinessModel\Cases::deleteCase + * @expectedException Exception + * @expectedExceptionMessage Invalid value for '$app_uid' it must be a string. + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testDeleteCaseErrorAppUidArray() + { + $this->oCases->deleteCase(array()); + } + + /** + * Test error for type in first field the function + * + * @covers \BusinessModel\Cases::deleteCase + * @expectedException Exception + * @expectedExceptionMessage The application with $app_uid: 'IdDoesNotExists' does not exist. + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testDeleteCaseErrorAppUidIncorrect() + { + $this->oCases->deleteCase('IdDoesNotExists'); + } + + /** + * Test for cancel case + * + * @covers \BusinessModel\Cases::deleteCase + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function testDeleteCase() + { + $this->oCases->deleteCase($this->idCaseToDo); + $this->oCases = new \BusinessModel\Cases(); + $listToDo = $this->oCases->getList(array('userId' => '00000000000000000000000000000001')); + $this->assertNotEquals($this->nowCountTodo, $listToDo['total']); + } +} \ No newline at end of file diff --git a/workflow/engine/src/Tests/BusinessModel/CasesTest.php b/workflow/engine/src/Tests/BusinessModel/CasesTest.php index 6f83fe541..bcaccb004 100644 --- a/workflow/engine/src/Tests/BusinessModel/CasesTest.php +++ b/workflow/engine/src/Tests/BusinessModel/CasesTest.php @@ -67,14 +67,14 @@ class CasesTest extends \PHPUnit_Framework_TestCase * * @covers \BusinessModel\Cases::getList * @expectedException Exception - * @expectedExceptionMessage The user with userId: 'UidInexistente' does not exist. + * @expectedExceptionMessage The user with userId: 'IdDoesNotExists' does not exist. * * @author Brayan Pereyra (Cochalo) * @copyright Colosa - Bolivia */ public function testGetListCasesErrorNotExistsUserIdArray() { - $this->oCases->getList(array('userId' => 'UidInexistente')); + $this->oCases->getList(array('userId' => 'IdDoesNotExists')); } /** @@ -97,7 +97,7 @@ class CasesTest extends \PHPUnit_Framework_TestCase * * @covers \BusinessModel\Cases::getList * @expectedException Exception - * @expectedExceptionMessage The process with $pro_uid: 'UidInexistente' does not exist. + * @expectedExceptionMessage The process with $pro_uid: 'IdDoesNotExists' does not exist. * * @author Brayan Pereyra (Cochalo) * @copyright Colosa - Bolivia @@ -106,7 +106,7 @@ class CasesTest extends \PHPUnit_Framework_TestCase { $this->oCases->getList(array( 'userId' => '00000000000000000000000000000001', - 'process' => 'UidInexistente' + 'process' => 'IdDoesNotExists' )); } @@ -115,7 +115,7 @@ class CasesTest extends \PHPUnit_Framework_TestCase * * @covers \BusinessModel\Cases::getList * @expectedException Exception - * @expectedExceptionMessage The category with $cat_uid: 'UidInexistente' does not exist. + * @expectedExceptionMessage The category with $cat_uid: 'IdDoesNotExists' does not exist. * * @author Brayan Pereyra (Cochalo) * @copyright Colosa - Bolivia @@ -124,7 +124,7 @@ class CasesTest extends \PHPUnit_Framework_TestCase { $this->oCases->getList(array( 'userId' => '00000000000000000000000000000001', - 'category' => 'UidInexistente' + 'category' => 'IdDoesNotExists' )); } @@ -133,7 +133,7 @@ class CasesTest extends \PHPUnit_Framework_TestCase * * @covers \BusinessModel\Cases::getList * @expectedException Exception - * @expectedExceptionMessage The user with $usr_uid: 'UidInexistente' does not exist. + * @expectedExceptionMessage The user with $usr_uid: 'IdDoesNotExists' does not exist. * * @author Brayan Pereyra (Cochalo) * @copyright Colosa - Bolivia @@ -142,7 +142,7 @@ class CasesTest extends \PHPUnit_Framework_TestCase { $this->oCases->getList(array( 'userId' => '00000000000000000000000000000001', - 'user' => 'UidInexistente' + 'user' => 'IdDoesNotExists' )); } @@ -151,7 +151,7 @@ class CasesTest extends \PHPUnit_Framework_TestCase * * @covers \BusinessModel\Cases::getList * @expectedException Exception - * @expectedExceptionMessage The value '2014-44-44' is not valid fot the format 'Y-m-d'. + * @expectedExceptionMessage The value '2014-44-44' is not a valid date for the format 'Y-m-d'. * * @author Brayan Pereyra (Cochalo) * @copyright Colosa - Bolivia @@ -169,7 +169,7 @@ class CasesTest extends \PHPUnit_Framework_TestCase * * @covers \BusinessModel\Cases::getList * @expectedException Exception - * @expectedExceptionMessage The value '2014-44-44' is not valid fot the format 'Y-m-d'. + * @expectedExceptionMessage The value '2014-44-44' is not a valid date for the format 'Y-m-d'. * * @author Brayan Pereyra (Cochalo) * @copyright Colosa - Bolivia @@ -440,7 +440,7 @@ class CasesTest extends \PHPUnit_Framework_TestCase * * @covers \BusinessModel\Cases::getTaskCase * @depends testAddCase - * @param array $aResponse, Data for parent department + * @param array $aResponse * * @copyright Colosa - Bolivia */ diff --git a/workflow/engine/src/Tests/BusinessModel/OutputDocumentsCasesTest.php b/workflow/engine/src/Tests/BusinessModel/OutputDocumentsCasesTest.php new file mode 100644 index 000000000..a5a4dd90a --- /dev/null +++ b/workflow/engine/src/Tests/BusinessModel/OutputDocumentsCasesTest.php @@ -0,0 +1,100 @@ +oOutputDocument = new \BusinessModel\Cases\OutputDocument(); + + } + + /** + * Test add OutputDocument + * + * @covers \BusinessModel\Cases\OutputDocument::addCasesOutputDocument + * + * @copyright Colosa - Bolivia + */ + public function testAddCasesOutputDocument() + { + \G::loadClass('pmFunctions'); + $usrUid = '00000000000000000000000000000001'; + $proUid = '1265557095225ff5c688f46031700471'; + $tasUid = '1352844695225ff5fe54de2005407079'; + $idCase = PMFNewCase($proUid, $usrUid, $tasUid, array()); + $response = $this->oOutputDocument->addCasesOutputDocument($idCase, '10401087752fa8bc6f0cab6048419434', '00000000000000000000000000000001'); + $this->assertTrue(is_object($response)); + $aResponse = json_decode(json_encode($response), true); + $aResponse = array_merge(array("idCase" => $idCase), $aResponse); + return $aResponse; + } + + /** + * Test get OutputDocuments + * + * @covers \BusinessModel\Cases\OutputDocument::getCasesOutputDocuments + * @depends testAddCasesOutputDocument + * @param array $aResponse + * + * @copyright Colosa - Bolivia + */ + public function testGetCasesOutputDocuments(array $aResponse) + { + $response = $this->oOutputDocument->getCasesOutputDocuments($aResponse["idCase"], '00000000000000000000000000000001'); + $this->assertTrue(is_array($response)); + } + + /** + * Test get OutputDocument + * + * @covers \BusinessModel\Cases\OutputDocument::getCasesOutputDocument + * @depends testAddCasesOutputDocument + * @param array $aResponse + * + * @copyright Colosa - Bolivia + */ + public function testGetCasesOutputDocument(array $aResponse) + { + $response = $this->oOutputDocument->getCasesOutputDocument($aResponse["idCase"], '00000000000000000000000000000001', $aResponse["app_doc_uid"]); + $this->assertTrue(is_object($response)); + } + + /** + * Test remove OutputDocument + * + * @covers \BusinessModel\Cases\OutputDocument::removeOutputDocument + * @depends testAddCasesOutputDocument + * @param array $aResponse + * + * @copyright Colosa - Bolivia + */ + public function testRemoveOutputDocument(array $aResponse) + { + echo $aResponse["app_doc_uid"]; + $response = $this->oOutputDocument->removeOutputDocument($aResponse["app_doc_uid"]); + $this->assertTrue(empty($response)); + } +} \ No newline at end of file diff --git a/workflow/engine/templates/pmTables/data.js b/workflow/engine/templates/pmTables/data.js index fa5ec31d3..e50711417 100755 --- a/workflow/engine/templates/pmTables/data.js +++ b/workflow/engine/templates/pmTables/data.js @@ -559,6 +559,7 @@ ImportPMTableCSV = function(){ [',', 'Comma (,)']] }); var w = new Ext.Window({ + id: 'windowImportUploader', title : '', width : 440, height : 180, @@ -672,6 +673,7 @@ ExportPMTableCSV = function(){ [',', 'Comma (,)']] }); var w = new Ext.Window({ + id: 'windowExportUploader', title : '', width : 320, height : 140, diff --git a/workflow/engine/templates/pmTables/list.js b/workflow/engine/templates/pmTables/list.js index 384ac39eb..9a46f9329 100755 --- a/workflow/engine/templates/pmTables/list.js +++ b/workflow/engine/templates/pmTables/list.js @@ -511,6 +511,7 @@ DeletePMTable = function() { ImportPMTable = function(){ var w = new Ext.Window({ + id: 'windowPmTableUploaderImport', title: '', width: 420, height: 160, @@ -570,6 +571,7 @@ ImportPMTable = function(){ } else { win = new Ext.Window({ + id: 'windowImportingError', applyTo:'hello-win', layout:'fit', width:500, @@ -659,6 +661,7 @@ PMTableData = function() } win = new Ext.Window({ + id: 'windowPmtablesReportTable', layout: 'fit', width: 700, height: 400, diff --git a/workflow/engine/templates/processes/main.js b/workflow/engine/templates/processes/main.js index 6bebe6e6e..50e9a7f1f 100755 --- a/workflow/engine/templates/processes/main.js +++ b/workflow/engine/templates/processes/main.js @@ -1086,7 +1086,11 @@ importProcess = function() if (resp_.ExistProcessInDatabase == "0") { if (resp_.ExistGroupsInDatabase == "0") { var sNewProUid = resp_.sNewProUid; - window.location.href = "processes_Map?PRO_UID=" + sNewProUid; + if (resp_.project_type && resp_.project_type == "bpmn") { + window.location.href = "../designer?prj_uid=" + sNewProUid; + } else { + window.location.href = "processes_Map?PRO_UID=" + sNewProUid; + } } else { importProcessGlobal.sNewProUid = resp_.sNewProUid;