Merge branch 'master' of bitbucket.org:colosa/processmaker
This commit is contained in:
@@ -1,121 +1,158 @@
|
||||
@ProcessMakerMichelangelo @RestAPI
|
||||
Feature: Activity Resources
|
||||
|
||||
@1: TEST FOR GET ACTIVITY /-----------------------------------------------------------------------
|
||||
Scenario: Get a activity
|
||||
Background:
|
||||
Given that I have a valid access_token
|
||||
And I request "project/251815090529619a99a2bf4013294414/activity/97192372152a5c78f04a794095806311"
|
||||
|
||||
@1: TEST FOR GET PROPERTIES & DEFINITION OF A ACTIVITY /-----------------------------------------------------------------------
|
||||
Scenario Outline: Get an activity
|
||||
Given I request "project/<project>/activity/<activity>"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the type is "object"
|
||||
And the "definition" property type is "array"
|
||||
And the "properties" property type is "array"
|
||||
And that "tas_title" is set to "Task 1"
|
||||
And that "tas_title" is set to "<tas_title>"
|
||||
|
||||
Examples:
|
||||
|
||||
| project | activity | tas_title |
|
||||
| 251815090529619a99a2bf4013294414 | 97192372152a5c78f04a794095806311 | Task 1 |
|
||||
|
||||
|
||||
@2: TEST FOR GET PROPERTIES ACTIVITY /---------------------------------------------------------
|
||||
Scenario: Get properties of activity
|
||||
Given that I have a valid access_token
|
||||
And I request "project/251815090529619a99a2bf4013294414/activity/97192372152a5c78f04a794095806311?filter=properties"
|
||||
Scenario Outline: Get properties of activity
|
||||
Given I request "project/<project>/activity/<activity>?filter=properties"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the type is "object"
|
||||
And the response has not a "definition" property
|
||||
|
||||
Examples:
|
||||
|
||||
| project | activity |
|
||||
| 251815090529619a99a2bf4013294414 | 97192372152a5c78f04a794095806311 |
|
||||
|
||||
|
||||
|
||||
@3: TEST FOR GET DEFINITION ACTIVITY /---------------------------------------------------------
|
||||
Scenario: Get definition of activity
|
||||
Given that I have a valid access_token
|
||||
And I request "project/251815090529619a99a2bf4013294414/activity/97192372152a5c78f04a794095806311?filter=definition"
|
||||
Scenario Outline: Get definition of activity
|
||||
Given I request "project/<project>/activity/<activity>?filter=definition"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the type is "object"
|
||||
And the response has not a "properties" property
|
||||
|
||||
Examples:
|
||||
|
||||
| project | activity |
|
||||
| 251815090529619a99a2bf4013294414 | 97192372152a5c78f04a794095806311 |
|
||||
|
||||
|
||||
|
||||
@4: TEST FOR PUT DEFINITION ACTIVITY /---------------------------------------------------------
|
||||
Scenario: Put propertie of activity
|
||||
Given that I have a valid access_token
|
||||
And PUT this data:
|
||||
"""
|
||||
Scenario Outline: Put property of activity
|
||||
Given PUT this data:
|
||||
"""
|
||||
{
|
||||
"definition": [],
|
||||
"properties": {
|
||||
"tas_type": "NORMAL",
|
||||
"tas_duration": 1,
|
||||
"tas_type_day": "",
|
||||
"tas_timeunit": "DAYS",
|
||||
"tas_priority_variable": "",
|
||||
"tas_assign_type": "BALANCED",
|
||||
"tas_assign_variable": "@@SYS_NEXT_USER_TO_BE_ASSIGNED",
|
||||
"tas_group_variable": null,
|
||||
"tas_transfer_fly": "FALSE",
|
||||
"tas_send_last_email": "FALSE",
|
||||
"tas_derivation_screen_tpl": "",
|
||||
"tas_selfservice_timeout": 0,
|
||||
"tas_selfservice_time": "",
|
||||
"tas_selfservice_time_unit": "",
|
||||
"tas_selfservice_trigger_uid": "",
|
||||
"tas_title": "Task Edit",
|
||||
"tas_description": "",
|
||||
"tas_def_title": "",
|
||||
"tas_def_description": "",
|
||||
"tas_def_message": "",
|
||||
"tas_def_subject_message": "",
|
||||
"tas_calendar": ""
|
||||
|
||||
"definition": {},
|
||||
"properties":
|
||||
{
|
||||
"tas_title": "<tas_title>",
|
||||
"tas_description": "<tas_description>",
|
||||
"tas_priority_variable": "@@VAR_PRIORITY",
|
||||
"tas_derivation_screen_tpl": "template.html",
|
||||
"tas_start": <tas_start>,
|
||||
"tas_assign_type" : "<tas_assign_type>",
|
||||
"tas_assign_variable": "@@USER_LOGGED",
|
||||
"tas_group_variable": "@@GROUP_UID",
|
||||
"tas_selfservice_timeout": "<tas_selfservice_timeout>",
|
||||
"tas_selfservice_time": "<tas_selfservice_time>",
|
||||
"tas_selfservice_time_unit" : "<tas_selfservice_time_unit>",
|
||||
"tas_selfservice_trigger_uid" : "3229227245298e1c5191f95009451434",
|
||||
"tas_transfer_fly": <tas_transfer_fly>,
|
||||
"tas_duration" : "<tas_duration>",
|
||||
"tas_timeunit" : "<tas_timeunit>",
|
||||
"tas_type_day": "<tas_type_day>",
|
||||
"tas_calendar": "00000000000000000000000000000001",
|
||||
"tas_type": "<tas_type>",
|
||||
"tas_def_title": "Case Title",
|
||||
"tas_def_description": "Case Descripction",
|
||||
"tas_send_last_email": <tas_send_last_email>,
|
||||
"tas_def_subject_message": "<tas_def_subject_message>",
|
||||
"tas_def_message_type": "template",
|
||||
"tas_def_message": "<tas_def_message>",
|
||||
"tas_def_message_template": "template.html"
|
||||
}
|
||||
}
|
||||
"""
|
||||
And I request "project/251815090529619a99a2bf4013294414/activity/97192372152a5c78f04a794095806311"
|
||||
"""
|
||||
And I request "project/<project>/activity/<activity>"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the type is "object"
|
||||
|
||||
|
||||
|
||||
Examples:
|
||||
|
||||
| project | activity | tas_title | tas_description | tas_start | tas_assign_type | tas_selfservice_timeout | tas_selfservice_time | tas_selfservice_time_unit | tas_transfer_fly | tas_duration | tas_timeunit | tas_type_day | tas_type | tas_send_last_email | tas_def_subject_message | tas_def_message |
|
||||
| 251815090529619a99a2bf4013294414 | 97192372152a5c78f04a794095806311 | update activity | update description | true | BALANCED | 0 | 0 | DAYS | true | 4 | DAYS | 1 | NORMAL | true | Email desde tarea | Contenido del email |
|
||||
|
||||
|
||||
@5: TEST FOR GET ACTIVITY /-----------------------------------------------------------------------
|
||||
Scenario: Get a activity
|
||||
Given that I have a valid access_token
|
||||
And I request "project/251815090529619a99a2bf4013294414/activity/97192372152a5c78f04a794095806311"
|
||||
Scenario Outline: Get a activity
|
||||
Given I request "project/<project>/activity/<activity>"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the type is "object"
|
||||
And that "tas_title" is set to "Task Edit"
|
||||
And that "tas_title" is set to "<tas_title>"
|
||||
|
||||
Examples:
|
||||
|
||||
@6: TEST FOR PUT DEFINITION ACTIVITY /---------------------------------------------------------
|
||||
Scenario: Put propertie of activity
|
||||
Given that I have a valid access_token
|
||||
And PUT this data:
|
||||
"""
|
||||
{
|
||||
"definition": [],
|
||||
"properties": {
|
||||
"tas_type": "NORMAL",
|
||||
"tas_duration": 1,
|
||||
"tas_type_day": "",
|
||||
"tas_timeunit": "DAYS",
|
||||
"tas_priority_variable": "",
|
||||
"tas_assign_type": "BALANCED",
|
||||
"tas_assign_variable": "@@SYS_NEXT_USER_TO_BE_ASSIGNED",
|
||||
"tas_group_variable": null,
|
||||
"tas_transfer_fly": "FALSE",
|
||||
"tas_send_last_email": "FALSE",
|
||||
"tas_derivation_screen_tpl": "",
|
||||
"tas_selfservice_timeout": 0,
|
||||
"tas_selfservice_time": "",
|
||||
"tas_selfservice_time_unit": "",
|
||||
"tas_selfservice_trigger_uid": "",
|
||||
"tas_title": "Task 1",
|
||||
"tas_description": "",
|
||||
"tas_def_title": "",
|
||||
"tas_def_description": "",
|
||||
"tas_def_message": "",
|
||||
"tas_def_subject_message": "",
|
||||
"tas_calendar": ""
|
||||
}
|
||||
}
|
||||
"""
|
||||
And I request "project/251815090529619a99a2bf4013294414/activity/97192372152a5c78f04a794095806311"
|
||||
Then the response status code should be 200
|
||||
| project | activity | tas_title |
|
||||
| 251815090529619a99a2bf4013294414 | 97192372152a5c78f04a794095806311 | Task Edit |
|
||||
|
||||
@6: TEST FOR GET PROPERTIES & DEFINITION OF A ACTIVITY /-----------------------------------------------------------------------
|
||||
Scenario Outline: Get an activity
|
||||
Given I request "project/<project>/activity/<activity>"
|
||||
Then the response status code should be <error_code>
|
||||
And the response charset is "UTF-8"
|
||||
And the type is "object"
|
||||
And the type is "object"
|
||||
|
||||
|
||||
Examples:
|
||||
|
||||
| project | activity | tas_title | error_code |
|
||||
| 251815090529619a99a2bf4013294414 | 97192372152a5c78f04a794095845000 | Task 1 | 400 |
|
||||
| 251815090529619a99a2bf4013294414 | | Task 1 | 404 |
|
||||
| | 97192372152a5c78f04a794095806311 | Task 1 | 400 |
|
||||
|
||||
|
||||
@7: TEST FOR GET PROPERTIES ACTIVITY /---------------------------------------------------------
|
||||
Scenario Outline: Get properties of activity
|
||||
Given I request "project/<project>/activity/<activity>?filter=properties"
|
||||
Then the response status code should be <error_code>
|
||||
And the response charset is "UTF-8"
|
||||
And the type is "object"
|
||||
|
||||
Examples:
|
||||
|
||||
| project | activity | error_code |
|
||||
| 251815090529619a99a2bf4013294414 | 97192372152a5c78f04a794095801000 | 400 |
|
||||
| 251815090529619a99a2bf4013294414 | | 404 |
|
||||
| | 97192372152a5c78f04a794095806311 | 400 |
|
||||
|
||||
@8: TEST FOR GET DEFINITION ACTIVITY /---------------------------------------------------------
|
||||
Scenario Outline: Get definition of activity
|
||||
Given I request "project/<project>/activity/<activity>?filter=definition"
|
||||
Then the response status code should be <error_code>
|
||||
And the response charset is "UTF-8"
|
||||
And the type is "object"
|
||||
|
||||
Examples:
|
||||
|
||||
| project | activity | error_code |
|
||||
| 251815090529619a99a2bf4013294414 | 97192372152a5c78f04a794095200000 | 400 |
|
||||
| 251815090529619a99a2bf4013294414 | | 404 |
|
||||
| | 97192372152a5c78f04a794095806311 | 400 |
|
||||
|
||||
@@ -1,122 +1,162 @@
|
||||
@ProcessMakerMichelangelo @RestAPI
|
||||
Feature: Project Properties - Assignee Resources
|
||||
@ProcessMakerMichelangelo @RestAPI @assignee
|
||||
Feature: Project Properties -Adhoc Assignee Resources
|
||||
|
||||
Background:
|
||||
Given that I have a valid access_token
|
||||
|
||||
Scenario: Get a list of available users and groups to be assigned to an activity
|
||||
Given I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/adhoc-available-assignee"
|
||||
Scenario Outline: Get a list of available adhoc users and groups to be assigned to an activity
|
||||
Given I request "project/<project>/activity/<activity>/adhoc-available-assignee"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the content type is "application/json"
|
||||
And the type is "array"
|
||||
And the response has 79 records
|
||||
And the "aas_uid" property in row 0 equals "35762872152cda4323207c6035916735"
|
||||
And the "aas_type" property in row 0 equals "group"
|
||||
And the response has <records> records
|
||||
And the "aas_uid" property in row 0 equals "<aas_uid>"
|
||||
And the "aas_type" property in row 0 equals "<aas_type>"
|
||||
|
||||
Scenario: Get a list of available users and groups to be assigned to an activity with filter
|
||||
Given I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/adhoc-available-assignee?filter=departa&start=0&limit=50"
|
||||
Examples:
|
||||
| project | activity | records | aas_uid | aas_type |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 82 | 35762872152cda4323207c6035916735 | group |
|
||||
|
||||
Scenario Outline: Get a list of available adhoc users and groups to be assigned to an activity with filter
|
||||
Given I request "project/<project>/activity/<activity>/adhoc-available-assignee?filter=<filter>&start=<start>&limit=<limit>"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the content type is "application/json"
|
||||
And the type is "array"
|
||||
And the response has 3 records
|
||||
And the "aas_uid" property in row 0 equals "90268877852b7b4b9f134b1096735994"
|
||||
And the "aas_type" property in row 0 equals "group"
|
||||
And the response has <records> records
|
||||
And the "aas_uid" property in row 0 equals "<aas_uid>"
|
||||
And the "aas_type" property in row 0 equals "<aas_type>"
|
||||
|
||||
Scenario: Assign a user or group to an activity
|
||||
Examples:
|
||||
| project | activity | filter | start | limit | records | aas_uid | aas_type |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | departa | 0 | 50 | 3 | 90268877852b7b4b9f134b1096735994 | group |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | departa | 0 | 1 | 1 | 90268877852b7b4b9f134b1096735994 | group |
|
||||
|
||||
Scenario Outline: Assign a adhoc user or group to an activity
|
||||
Given POST this data:
|
||||
"""
|
||||
{
|
||||
"ass_uid": "84643774552cda42dabb732033709262",
|
||||
"ass_type": "user"
|
||||
"aas_uid": "<aas_uid>",
|
||||
"aas_type": "<aas_type>"
|
||||
}
|
||||
"""
|
||||
And I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/adhoc-assignee"
|
||||
And I request "project/<project>/activity/<activity>/adhoc-assignee"
|
||||
Then the response status code should be 201
|
||||
And the type is "object"
|
||||
|
||||
Scenario: Assign a user or group to an activity
|
||||
Given POST this data:
|
||||
"""
|
||||
{
|
||||
"ass_uid": "95888918452cda41a2b5d11013819411",
|
||||
"ass_type": "user"
|
||||
}
|
||||
"""
|
||||
And I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/adhoc-assignee"
|
||||
Then the response status code should be 201
|
||||
And the type is "object"
|
||||
Examples:
|
||||
| project | activity | aas_uid | aas_type |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 84643774552cda42dabb732033709262 | user |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 95888918452cda41a2b5d11013819411 | user |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 16698718252cda431814024050455569 | group |
|
||||
| 4224292655297723eb98691001100052 | 68911670852a22d93c22c06005808422 | 90706007452cda42ed1c326093152317 | group |
|
||||
|
||||
Scenario: Assign a user or group to an activity
|
||||
Given POST this data:
|
||||
"""
|
||||
{
|
||||
"ass_uid": "16698718252cda431814024050455569",
|
||||
"ass_type": "group"
|
||||
}
|
||||
"""
|
||||
And I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/adhoc-assignee"
|
||||
Then the response status code should be 201
|
||||
And the type is "object"
|
||||
|
||||
Scenario: Assign a user or group to an activity
|
||||
Given POST this data:
|
||||
"""
|
||||
{
|
||||
"ass_uid": "90706007452cda42ed1c326093152317",
|
||||
"ass_type": "group"
|
||||
}
|
||||
"""
|
||||
And I request "project/4224292655297723eb98691001100052/activity/68911670852a22d93c22c06005808422/adhoc-assignee"
|
||||
Then the response status code should be 201
|
||||
And the type is "object"
|
||||
|
||||
Scenario: List assignees of an activity
|
||||
Given I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/adhoc-assignee"
|
||||
Scenario Outline: List adhoc assignees of an activity
|
||||
Given I request "project/<project>/activity/<activity>/adhoc-assignee"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the content type is "application/json"
|
||||
And the type is "array"
|
||||
And the response has 7 records
|
||||
And the "aas_uid" property in row 0 equals "10732248352cda434c43997043577116"
|
||||
And the "aas_type" property in row 0 equals "group"
|
||||
And the response has <records> records
|
||||
And the "aas_uid" property in row 0 equals "<aas_uid>"
|
||||
And the "aas_type" property in row 0 equals "<aas_type>"
|
||||
|
||||
Scenario: List assignees of an activity with filter
|
||||
Given I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/adhoc-assignee?filter=emi"
|
||||
Examples:
|
||||
| project | activity | records | aas_uid | aas_type |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 7 | 10732248352cda434c43997043577116 | group |
|
||||
| 4224292655297723eb98691001100052 | 68911670852a22d93c22c06005808422 | 5 | 90706007452cda42ed1c326093152317 | group |
|
||||
|
||||
|
||||
Scenario Outline: After assignation - List adhoc assignees of an activity with filter
|
||||
Given I request "project/<project>/activity/<activity>/adhoc-assignee?filter=<filter>"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the content type is "application/json"
|
||||
And the type is "array"
|
||||
And the response has 1 record
|
||||
And the "aas_uid" property in row 0 equals "84643774552cda42dabb732033709262"
|
||||
And the "aas_type" property in row 0 equals "user"
|
||||
And the "aas_uid" property in row 0 equals "<aas_uid>"
|
||||
And the "aas_type" property in row 0 equals "<aas_type>"
|
||||
|
||||
Scenario: Get a single user or group of an activity
|
||||
Given I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/adhoc-assignee/95888918452cda41a2b5d11013819411"
|
||||
Examples:
|
||||
| project | activity | records | aas_uid | aas_type | filter |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 1 | 84643774552cda42dabb732033709262 | user | emi |
|
||||
| 4224292655297723eb98691001100052 | 68911670852a22d93c22c06005808422 | 1 | 90706007452cda42ed1c326093152317 | group | dep |
|
||||
|
||||
Scenario Outline: Get a single adhoc user or group of an activity
|
||||
Given I request "project/<project>/activity/<activity>/adhoc-assignee/<aas_uid>"
|
||||
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 the "aas_uid" property equals "95888918452cda41a2b5d11013819411"
|
||||
And the "aas_name" property equals "Mike"
|
||||
And the "aas_lastname" property equals "Balisi"
|
||||
And the "aas_username" property equals "mike"
|
||||
And the "aas_uid" property equals "<aas_uid>"
|
||||
And the "aas_name" property equals "<aas_name>"
|
||||
And the "aas_lastname" property equals "<aas_lastname>"
|
||||
And the "aas_username" property equals "<aas_username>"
|
||||
And the "aas_type" property equals "user"
|
||||
|
||||
Examples:
|
||||
| project | activity | aas_uid | aas_type | aas_name | aas_lastname | aas_username |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 95888918452cda41a2b5d11013819411 | user | Mike | Balisi | mike |
|
||||
|
||||
Scenario: Remove assignee from an activity
|
||||
Scenario Outline: Remove adhoc assignee from an activity
|
||||
Given that I want to delete a resource with the key "aas_uid" stored in session array
|
||||
And I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/adhoc-assignee/91968412052cda4097270a3085279286"
|
||||
And I request "project/<project>/activity/<activity>/adhoc-assignee/<aas_uid>"
|
||||
Then the response status code should be 200
|
||||
|
||||
Examples:
|
||||
| project | activity | aas_uid |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 84643774552cda42dabb732033709262 |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 95888918452cda41a2b5d11013819411 |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 16698718252cda431814024050455569 |
|
||||
| 4224292655297723eb98691001100052 | 68911670852a22d93c22c06005808422 | 90706007452cda42ed1c326093152317 |
|
||||
|
||||
Scenario: List assignees of an activity
|
||||
Given I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/adhoc-assignee"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the content type is "application/json"
|
||||
And the type is "array"
|
||||
And the response has 6 records
|
||||
And the response has 4 records
|
||||
|
||||
Scenario: List assignees of an activity
|
||||
Given I request "project/4224292655297723eb98691001100052/activity/12345/adhoc-assignee"
|
||||
|
||||
|
||||
Scenario Outline: List assignees of an activity with bad parameters
|
||||
Given I request "project/<project>/activity/<activity>/adhoc-assignee"
|
||||
Then the response status code should be 400
|
||||
|
||||
|
||||
Examples:
|
||||
| project | activity |
|
||||
| 4224292655297723eb98691001100052 | 1234556 |
|
||||
| 122134324 | 65496814252977243d57684076211485 |
|
||||
| 345345345 | 345345345 |
|
||||
| | |
|
||||
|
||||
|
||||
Scenario Outline: Assign a user or group to an activity (Field validation)
|
||||
Given POST this data:
|
||||
"""
|
||||
{
|
||||
"ass_uid": "<aas_uid>",
|
||||
"ass_type": "<aas_type>"
|
||||
}
|
||||
"""
|
||||
And I request "project/<project>/activity/<activity>/adhoc-assignee"
|
||||
Then the response status code should be 400
|
||||
And the type is "object"
|
||||
|
||||
# Asignando un user vacio
|
||||
# Asignando un user inexistente
|
||||
# Asignando un usuario como grupo
|
||||
# Asignando un usuario con type inexistente
|
||||
|
||||
Examples:
|
||||
| project | activity | aas_uid | aas_type |
|
||||
| 4224292655297723eb98691001100052 | 68911670852a22d93c22c06005808422 | | |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | !@#$%^&*()_+=-[]{};:~, | user |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 15746307552d00a66624889076110382 | group |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 69191356252cda41acde328048794164 | department |
|
||||
|
||||
|
||||
@@ -4,123 +4,159 @@ Feature: Project Properties - Assignee Resources
|
||||
Background:
|
||||
Given that I have a valid access_token
|
||||
|
||||
Scenario: Get a list of available users and groups to be assigned to an activity
|
||||
Given I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/available-assignee"
|
||||
Scenario Outline: Get a list of available users and groups to be assigned to an activity
|
||||
Given I request "project/<project>/activity/<activity>/available-assignee"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the content type is "application/json"
|
||||
And the type is "array"
|
||||
And the response has 79 records
|
||||
And the "aas_uid" property in row 0 equals "35762872152cda4323207c6035916735"
|
||||
And the "aas_type" property in row 0 equals "group"
|
||||
|
||||
Scenario: Get a list of available users and groups to be assigned to an activity with filter
|
||||
Given I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/available-assignee?filter=departa&start=0&limit=50"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the content type is "application/json"
|
||||
And the type is "array"
|
||||
And the response has 3 records
|
||||
And the "aas_uid" property in row 0 equals "90268877852b7b4b9f134b1096735994"
|
||||
And the "aas_type" property in row 0 equals "group"
|
||||
|
||||
Scenario: Assign a user or group to an activity
|
||||
Given POST this data:
|
||||
"""
|
||||
{
|
||||
"ass_uid": "66386662252cda3f9a63226052377198",
|
||||
"ass_type": "user"
|
||||
}
|
||||
"""
|
||||
And I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/assignee"
|
||||
Then the response status code should be 201
|
||||
And the type is "object"
|
||||
|
||||
Scenario: Assign a user or group to an activity
|
||||
Given POST this data:
|
||||
"""
|
||||
{
|
||||
"ass_uid": "69191356252cda41acde328048794164",
|
||||
"ass_type": "user"
|
||||
}
|
||||
"""
|
||||
And I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/assignee"
|
||||
Then the response status code should be 201
|
||||
And the type is "object"
|
||||
|
||||
Scenario: Assign a user or group to an activity
|
||||
Given POST this data:
|
||||
"""
|
||||
{
|
||||
"ass_uid": "35762872152cda4323207c6035916735",
|
||||
"ass_type": "group"
|
||||
}
|
||||
"""
|
||||
And I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/assignee"
|
||||
Then the response status code should be 201
|
||||
And the type is "object"
|
||||
|
||||
Scenario: Assign a user or group to an activity
|
||||
Given POST this data:
|
||||
"""
|
||||
{
|
||||
"ass_uid": "90706007452cda42ed1c326093152317",
|
||||
"ass_type": "group"
|
||||
}
|
||||
"""
|
||||
And I request "project/4224292655297723eb98691001100052/activity/68911670852a22d93c22c06005808422/assignee"
|
||||
Then the response status code should be 201
|
||||
And the type is "object"
|
||||
|
||||
Scenario: List assignees of an activity
|
||||
Given I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/assignee"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the content type is "application/json"
|
||||
And the type is "array"
|
||||
And the response has 7 records
|
||||
And the "aas_uid" property in row 0 equals "35762872152cda4323207c6035916735"
|
||||
And the "aas_type" property in row 0 equals "group"
|
||||
|
||||
Scenario: List assignees of an activity with filter
|
||||
Given I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/assignee?filter=oli"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the content type is "application/json"
|
||||
And the type is "array"
|
||||
And the response has 1 record
|
||||
And the "aas_uid" property in row 0 equals "69191356252cda41acde328048794164"
|
||||
And the "aas_type" property in row 0 equals "user"
|
||||
|
||||
Scenario: Get a single user or group of an activity
|
||||
Given I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/assignee/69191356252cda41acde328048794164"
|
||||
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 the "aas_uid" property equals "69191356252cda41acde328048794164"
|
||||
And the "aas_name" property equals "Olivia"
|
||||
And the "aas_lastname" property equals "Austin"
|
||||
And the "aas_username" property equals "olivia"
|
||||
And the "aas_type" property equals "user"
|
||||
|
||||
Scenario: Remove assignee from an activity
|
||||
Given that I want to delete a resource with the key "aas_uid" stored in session array
|
||||
And I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/assignee/69191356252cda41acde328048794164"
|
||||
Then the response status code should be 200
|
||||
|
||||
Scenario: List assignees of an activity
|
||||
Given I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/assignee"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the content type is "application/json"
|
||||
And the type is "array"
|
||||
And the response has 6 records
|
||||
And the response has <records> records
|
||||
And the "aas_uid" property in row 0 equals "<aas_uid>"
|
||||
And the "aas_type" property in row 0 equals "<aas_type>"
|
||||
|
||||
Examples:
|
||||
| project | activity | records | aas_uid | aas_type |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 82 | 35762872152cda4323207c6035916735 | group |
|
||||
|
||||
Scenario Outline: Get a list of available users and groups to be assigned to an activity with filter
|
||||
Given I request "project/<project>/activity/<activity>/available-assignee?filter=<filter>&start=<start>&limit=<limit>"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the content type is "application/json"
|
||||
And the type is "array"
|
||||
And the response has <records> records
|
||||
And the "aas_uid" property in row 0 equals "<aas_uid>"
|
||||
And the "aas_type" property in row 0 equals "<aas_type>"
|
||||
|
||||
Examples:
|
||||
| project | activity | filter | start | limit | records | aas_uid | aas_type|
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | departa | 0 | 50 | 3 | 90268877852b7b4b9f134b1096735994 | group |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | departa | 0 | 1 | 1 | 90268877852b7b4b9f134b1096735994 | group |
|
||||
|
||||
Scenario Outline: Assign a user or group to an activity
|
||||
Given POST this data:
|
||||
"""
|
||||
{
|
||||
"aas_uid": "<aas_uid>",
|
||||
"aas_type": "<aas_type>"
|
||||
}
|
||||
"""
|
||||
And I request "project/<project>/activity/<activity>/assignee"
|
||||
Then the response status code should be 201
|
||||
And the type is "object"
|
||||
|
||||
Examples:
|
||||
| project | activity | aas_uid | aas_type |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 66386662252cda3f9a63226052377198 | user |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 69191356252cda41acde328048794164 | user |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 35762872152cda4323207c6035916735 | group |
|
||||
| 4224292655297723eb98691001100052 | 68911670852a22d93c22c06005808422 | 90706007452cda42ed1c326093152317 | group |
|
||||
|
||||
|
||||
|
||||
|
||||
Scenario Outline: After assignation - List assignees of an activity
|
||||
Given I request "project/<project>/activity/<activity>/assignee"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the content type is "application/json"
|
||||
And the type is "array"
|
||||
And the response has <records> records
|
||||
And the "aas_uid" property in row 0 equals "<aas_uid>"
|
||||
And the "aas_type" property in row 0 equals "<aas_type>"
|
||||
|
||||
Examples:
|
||||
| project | activity | records | aas_uid | aas_type |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 7 | 135762872152cda4323207c6035916735 | group |
|
||||
| 4224292655297723eb98691001100052 | 68911670852a22d93c22c06005808422 | 5 | 90706007452cda42ed1c326093152317 | group |
|
||||
|
||||
|
||||
Scenario Outline: List assignees of an activity with filter
|
||||
Given I request "project/<project>/activity/<activity>/assignee?filter=<filter>"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the content type is "application/json"
|
||||
And the type is "array"
|
||||
And the response has <records> record
|
||||
And the "aas_uid" property in row 0 equals "<aas_uid>"
|
||||
And the "aas_type" property in row 0 equals "<aas_type>"
|
||||
|
||||
Examples:
|
||||
| project | activity | records | aas_uid | aas_type | filter |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 1 | 69191356252cda41acde328048794164 | user | oli |
|
||||
| 4224292655297723eb98691001100052 | 68911670852a22d93c22c06005808422 | 1 | 90706007452cda42ed1c326093152317 | group | dep |
|
||||
|
||||
Scenario Outline: Get a single user or group of an activity
|
||||
Given I request "project/<project>/activity/<activity>/assignee/<aas_uid>"
|
||||
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 the "aas_uid" property equals "<aas_uid>"
|
||||
And the "aas_name" property equals "<aas_name>"
|
||||
And the "aas_lastname" property equals "<aas_lastname>"
|
||||
And the "aas_username" property equals "<aas_username>"
|
||||
And the "aas_type" property equals "<aas_type>"
|
||||
|
||||
Examples:
|
||||
| project | activity | aas_uid | aas_type | aas_name | aas_lastname | aas_username |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 69191356252cda41acde328048794164 | user | Olivia | Austin | olivia |
|
||||
|
||||
Scenario Outline: Remove assignee from an activity
|
||||
Given that I want to delete a resource with the key "aas_uid" stored in session array
|
||||
And I request "project/<project>/activity/<activity>/assignee/<aas_uid>"
|
||||
Then the response status code should be 200
|
||||
|
||||
Examples:
|
||||
| project | activity | aas_uid |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 66386662252cda3f9a63226052377198 |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 69191356252cda41acde328048794164 |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 35762872152cda4323207c6035916735 |
|
||||
| 4224292655297723eb98691001100052 | 68911670852a22d93c22c06005808422 | 90706007452cda42ed1c326093152317 |
|
||||
|
||||
|
||||
|
||||
Scenario: List assignees of an activity
|
||||
Given I request "project/4224292655297723eb98691001100052/activity/12345/assignee"
|
||||
Given I request "project/4224292655297723eb98691001100052/activity/65496814252977243d57684076211485/assignee"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the content type is "application/json"
|
||||
And the type is "array"
|
||||
And the response has 4 records
|
||||
|
||||
Scenario Outline: List assignees of an activity with bad parameters
|
||||
Given I request "project/<project>/activity/<activity>/assignee"
|
||||
Then the response status code should be 400
|
||||
|
||||
|
||||
|
||||
Examples:
|
||||
| project | activity |
|
||||
| 4224292655297723eb98691001100052 | 1234556 |
|
||||
| 122134324 | 65496814252977243d57684076211485 |
|
||||
| 345345345 | 345345345 |
|
||||
| | |
|
||||
|
||||
|
||||
Scenario Outline: Assign a user or group to an activity (Field validation)
|
||||
Given POST this data:
|
||||
"""
|
||||
{
|
||||
"ass_uid": "<aas_uid>",
|
||||
"ass_type": "<aas_type>"
|
||||
}
|
||||
"""
|
||||
And I request "project/<project>/activity/<activity>/assignee"
|
||||
Then the response status code should be 400
|
||||
And the type is "object"
|
||||
|
||||
# Asignando un user inexistente
|
||||
# Asignando un usuario como grupo
|
||||
# Asignando un usuario con type inexistente
|
||||
Examples:
|
||||
|
||||
| project | activity | aas_uid | aas_type |
|
||||
| 4224292655297723eb98691001100052 | 68911670852a22d93c22c06005808422 | | |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | !@#$%^&*()_+=-[]{};:~, | user |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 69191356252cda41acde328048794164 | group |
|
||||
| 4224292655297723eb98691001100052 | 65496814252977243d57684076211485 | 69191356252cda41acde328048794164 | department |
|
||||
|
||||
@@ -1,82 +1,126 @@
|
||||
@ProcessMakerMichelangelo @RestAPI
|
||||
Feature: Triggers Resources
|
||||
Feature: Testing triggers
|
||||
|
||||
Background:
|
||||
Given that I have a valid access_token
|
||||
|
||||
@1: TEST FOR POST TRIGGER /--------------------------------------------------------------------
|
||||
Scenario Outline: Get a list of triggers of a project
|
||||
Given I request "project/<prj_uid>/triggers"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the content type is "application/json"
|
||||
And the type is "array"
|
||||
And the response has <records> records
|
||||
|
||||
Examples:
|
||||
| project | records |
|
||||
| 251815090529619a99a2bf4013294414 | 0 |
|
||||
|
||||
@1: TEST FOR GET TRIGGERS /--------------------------------------------------------------------
|
||||
Scenario: List all the events (result 1 trigger)
|
||||
Given that I have a valid access_token
|
||||
And I request "project/251815090529619a99a2bf4013294414/triggers"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the response has 1 record
|
||||
|
||||
|
||||
@2: TEST FOR POST TRIGGER /--------------------------------------------------------------------
|
||||
Scenario: Create a trigger
|
||||
Given that I have a valid access_token
|
||||
And POST this data:
|
||||
Scenario Outline: Create a trigger
|
||||
|
||||
Given POST this data:
|
||||
"""
|
||||
{
|
||||
"tri_title": "nuevo trigger",
|
||||
"tri_description": "descripcion"
|
||||
"tri_title": "<tri_title>",
|
||||
"tri_description": "<tri_description>",
|
||||
"tri_type": "<tri_type>",
|
||||
"tri_webbot": "<tri_webbot>",
|
||||
"tri_param": "PRIVATE"
|
||||
}
|
||||
"""
|
||||
And I request "project/251815090529619a99a2bf4013294414/trigger"
|
||||
And I request "project/<project>/trigger"
|
||||
Then the response status code should be 201
|
||||
And store "tri_uid" in session array
|
||||
And store "tri_uid" in session array as variable "tri_uid_<tri_number>"
|
||||
|
||||
Examples:
|
||||
|
||||
@3: TEST FOR PUT TRIGGER /---------------------------------------------------------------------
|
||||
Scenario: Update a trigger
|
||||
Given that I have a valid access_token
|
||||
And PUT this data:
|
||||
| project | tri_number | tri_title | tri_description |tri_type | tri_webbot |
|
||||
| 251815090529619a99a2bf4013294414 | 1 | nuevo trigger 2 | descripcion |SCRIPT | @@user1 = @@USER_LOGGED; \n $x = rand();|
|
||||
| 251815090529619a99a2bf4013294414 | 2 | otro trigger 2 | descripcion de otro trigger |SCRIPT | //Trigger with comments |
|
||||
|
||||
|
||||
@3: TEST FOR PUT TRIGGER /-----------------------------------------------------------------------
|
||||
Scenario Outline: Update a trigger
|
||||
|
||||
Given PUT this data:
|
||||
"""
|
||||
{
|
||||
"tri_title": "trigger editado",
|
||||
"tri_description": "descripcion editada"
|
||||
"tri_title": "<tri_title>",
|
||||
"tri_description": "<tri_description>"
|
||||
}
|
||||
"""
|
||||
And that I want to update a resource with the key "tri_uid" stored in session array
|
||||
And I request "project/251815090529619a99a2bf4013294414/trigger"
|
||||
And that I want to update a resource with the key "tri_uid" stored in session array as variable "tri_uid_<tri_number>"
|
||||
And I request "project/<project>/trigger"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the type is "object"
|
||||
|
||||
Examples:
|
||||
|
||||
@4: TEST FOR GET TRIGGER /---------------------------------------------------------------------
|
||||
Scenario: Get a trigger
|
||||
Given that I have a valid access_token
|
||||
And that I want to get a resource with the key "tri_uid" stored in session array
|
||||
And I request "project/251815090529619a99a2bf4013294414/trigger"
|
||||
| project | tri_number | tri_title | tri_description |
|
||||
| 251815090529619a99a2bf4013294414 | 1 | trigger editado 2 | descripcion editada |
|
||||
| 251815090529619a99a2bf4013294414 | 2 | otro trigger editado 2 | descripcion de otro trigger editado |
|
||||
|
||||
|
||||
@4: TEST FOR GET TRIGGER /-----------------------------------------------------------------------
|
||||
Scenario Outline: Get a trigger
|
||||
|
||||
Given that I want to get a resource with the key "tri_uid" stored in session array as variable "tri_uid_<tri_number>"
|
||||
And I request "project/<project>/trigger"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the type is "object"
|
||||
And that "tri_title" is set to "trigger editado"
|
||||
And that "tri_description" is set to "descripcion editada"
|
||||
And that "tri_title" is set to "<tri_title>"
|
||||
And that "tri_description" is set to "<tri_description>"
|
||||
|
||||
Examples:
|
||||
|
||||
| project | tri_number | tri_title | tri_description |
|
||||
| 251815090529619a99a2bf4013294414 | 1 | trigger editado 2 | descripcion editada |
|
||||
| 251815090529619a99a2bf4013294414 | 2 | otro trigger editado 2 | descripcion de otro trigger editado |
|
||||
|
||||
|
||||
@5: TEST FOR GET TRIGGERS /--------------------------------------------------------------------
|
||||
Scenario: List all the events (result 2 trigger)
|
||||
Given that I have a valid access_token
|
||||
And I request "project/251815090529619a99a2bf4013294414/triggers"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the response has 2 record
|
||||
|
||||
|
||||
@6: TEST FOR DELETE TRIGGER /-----------------------------------------------------------------------
|
||||
Scenario: Get a trigger
|
||||
Given that I have a valid access_token
|
||||
And that I want to delete a resource with the key "tri_uid" stored in session array
|
||||
And I request "project/251815090529619a99a2bf4013294414/trigger"
|
||||
@5: TEST FOR DELETE TRIGGER /-----------------------------------------------------------------------
|
||||
Scenario Outline: Get a trigger
|
||||
|
||||
Given that I want to delete a resource with the key "tri_uid" stored in session array as variable "tri_uid_<tri_number>"
|
||||
And I request "project/<project>/trigger"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the type is "object"
|
||||
|
||||
Examples:
|
||||
|
||||
@7: TEST FOR GET TRIGGERS /--------------------------------------------------------------------
|
||||
Scenario: List all the events (result 1 trigger)
|
||||
Given that I have a valid access_token
|
||||
And I request "project/251815090529619a99a2bf4013294414/triggers"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the response has 1 record
|
||||
| project | tri_number |
|
||||
| 251815090529619a99a2bf4013294414 | 1 |
|
||||
| 251815090529619a99a2bf4013294414 | 2 |
|
||||
|
||||
|
||||
|
||||
|
||||
@6: TEST FOR POST TRIGGER /--------------------------------------------------------------------
|
||||
Scenario Outline: Create a trigger
|
||||
|
||||
Given POST this data:
|
||||
"""
|
||||
{
|
||||
"tri_title": "<tri_title>",
|
||||
"tri_description": "<tri_description>"
|
||||
"tri_type": "<tri_type>",
|
||||
"tri_webbot": "",
|
||||
"tri_param": "PRIVATE"
|
||||
}
|
||||
"""
|
||||
And I request "project/<project>/trigger"
|
||||
Then the response status code should be 400
|
||||
|
||||
Examples:
|
||||
|
||||
| project | tri_title | tri_description |tri_type |
|
||||
| 251815090529619a99a2bf4013294414 | Especial !@#$%^&*(){[/½‘€¤@ | Trigger con caracteres especiales |SCRIPT |
|
||||
| 251815090529619a99a2bf4013294414 | | Trigger con nombre en blanco |SCRIPT |
|
||||
| 251815090529619a99a2bf4013294414 | Trigger 3 | Descripcion con caracteres especiales !@#$%^&*(){[/½‘€¤@ |SCRIPT |
|
||||
| 251815090529619a99a2bf4013294414 | Trigger 4 | descripcion |SCRI123%@$|
|
||||
|
||||
@@ -1108,4 +1108,67 @@ class RestContext extends BehatContext
|
||||
throw new Exception('Records quantity not match ' . $quantityOfRecords . ' (actual: ' . $currentRecordsCount . ")\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^that I want to update a resource with the key "([^"]*)" stored in session array as variable "([^"]*)"$/
|
||||
*/
|
||||
public function thatIWantToUpdateAResourceWithTheKeyStoredInSessionArrayAsVariable($varName, $sessionVarName)
|
||||
{
|
||||
if (file_exists("session.data")) {
|
||||
$sessionData = json_decode(file_get_contents("session.data"));
|
||||
} else {
|
||||
$sessionData = array();
|
||||
}
|
||||
if (!isset($sessionData->$sessionVarName) ) {
|
||||
$varValue = '';
|
||||
} else {
|
||||
$varValue = $sessionData->$sessionVarName;
|
||||
}
|
||||
|
||||
$this->_restUpdateQueryStringSuffix = "/" . $varValue;
|
||||
$this->_restObjectMethod = 'put';
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^that I want to get a resource with the key "([^"]*)" stored in session array as variable "([^"]*)"$/
|
||||
*/
|
||||
public function thatIWantToGetAResourceWithTheKeyStoredInSessionArrayAsVariable($varName, $sessionVarName)
|
||||
{
|
||||
if (file_exists("session.data")) {
|
||||
$sessionData = json_decode(file_get_contents("session.data"));
|
||||
} else {
|
||||
$sessionData = array();
|
||||
}
|
||||
if (!isset($sessionData->$sessionVarName) ) {
|
||||
$varValue = '';
|
||||
} else {
|
||||
$varValue = $sessionData->$sessionVarName;
|
||||
}
|
||||
|
||||
$this->_restGetQueryStringSuffix = "/" . $varValue;
|
||||
$this->_restObjectMethod = 'get';
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^that I want to delete a resource with the key "([^"]*)" stored in session array as variable "([^"]*)"$/
|
||||
*/
|
||||
public function thatIWantToDeleteAResourceWithTheKeyStoredInSessionArrayAsVariable($varName, $sessionVarName)
|
||||
{
|
||||
if (file_exists("session.data")) {
|
||||
$sessionData = json_decode(file_get_contents("session.data"));
|
||||
} else {
|
||||
$sessionData = array();
|
||||
}
|
||||
if (!isset($sessionData->$varName) ) {
|
||||
$varValue = '';
|
||||
} else {
|
||||
$varValue = $sessionData->$sessionVarName;
|
||||
}
|
||||
|
||||
$this->_restDeleteQueryStringSuffix = "/" . $varValue;
|
||||
$this->_restObjectMethod = 'delete';
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
526
workflow/engine/src/BusinessModel/CaseScheduler.php
Normal file
526
workflow/engine/src/BusinessModel/CaseScheduler.php
Normal file
@@ -0,0 +1,526 @@
|
||||
<?php
|
||||
namespace BusinessModel;
|
||||
|
||||
use \G;
|
||||
|
||||
class CaseScheduler
|
||||
{
|
||||
/**
|
||||
* Return case scheduler of a project
|
||||
* @param string $sProcessUID
|
||||
* @return array
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getCaseSchedulers($sProcessUID = '')
|
||||
{
|
||||
try {
|
||||
$oCriteria = new \Criteria( 'workflow' );
|
||||
$oCriteria->clearSelectColumns();
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_UID );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_NAME );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_DEL_USER_NAME );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_DEL_USER_PASS );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_DEL_USER_UID );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::PRO_UID );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::TAS_UID );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_TIME_NEXT_RUN );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_LAST_RUN_TIME );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_STATE );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_LAST_STATE );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::USR_UID );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_OPTION );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_START_TIME );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_START_DATE );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_DAYS_PERFORM_TASK );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_EVERY_DAYS );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_WEEK_DAYS );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_START_DAY );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_MONTHS );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_END_DATE );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_REPEAT_EVERY );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_REPEAT_UNTIL );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_REPEAT_STOP_IF_RUNNING );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::CASE_SH_PLUGIN_UID );
|
||||
$oCriteria->add( \CaseSchedulerPeer::PRO_UID, $sProcessUID );
|
||||
$oDataset = \CaseSchedulerPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
$aRows = array();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$aRow = array_change_key_case($aRow, CASE_LOWER);
|
||||
$aRows[] = $aRow;
|
||||
$oDataset->next();
|
||||
}
|
||||
return $aRows;
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return case scheduler of a project
|
||||
* @param string $sProcessUID
|
||||
* @param string $sCaseSchedulerUID
|
||||
* @return array
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getCaseScheduler($sProcessUID = '', $sCaseSchedulerUID = '')
|
||||
{
|
||||
try {
|
||||
$oCriteria = new \Criteria( 'workflow' );
|
||||
$oCriteria->clearSelectColumns();
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_UID );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_NAME );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_DEL_USER_NAME );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_DEL_USER_PASS );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_DEL_USER_UID );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::PRO_UID );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::TAS_UID );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_TIME_NEXT_RUN );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_LAST_RUN_TIME );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_STATE );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_LAST_STATE );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::USR_UID );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_OPTION );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_START_TIME );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_START_DATE );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_DAYS_PERFORM_TASK );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_EVERY_DAYS );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_WEEK_DAYS );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_START_DAY );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_MONTHS );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_END_DATE );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_REPEAT_EVERY );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_REPEAT_UNTIL );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::SCH_REPEAT_STOP_IF_RUNNING );
|
||||
$oCriteria->addSelectColumn( \CaseSchedulerPeer::CASE_SH_PLUGIN_UID );
|
||||
$oCriteria->add( \CaseSchedulerPeer::PRO_UID, $sProcessUID );
|
||||
$oCriteria->add( \CaseSchedulerPeer::SCH_UID, $sCaseSchedulerUID );
|
||||
$oDataset = \CaseSchedulerPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
$aRows = array();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$aRow = array_change_key_case($aRow, CASE_LOWER);
|
||||
$aRows = $aRow;
|
||||
$oDataset->next();
|
||||
}
|
||||
return $aRows;
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new case scheduler of a project
|
||||
* @param string $sProcessUID
|
||||
* @param array $aData
|
||||
* @param string $userUID
|
||||
* @return array
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function addCaseScheduler($sProcessUID, $aData, $userUID)
|
||||
{
|
||||
try {
|
||||
require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes". PATH_SEP . "model" . PATH_SEP . "CaseScheduler.php");
|
||||
$aData = array_change_key_case($aData, CASE_UPPER);
|
||||
$oCaseScheduler = new \CaseScheduler();
|
||||
if (empty($aData)) {
|
||||
die( 'The information sended is empty!' );
|
||||
}
|
||||
$aData['SCH_UID'] = \G::generateUniqueID();
|
||||
$aData['SCH_DEL_USER_PASS'] = md5( $aData['SCH_DEL_USER_PASS']);
|
||||
$aData['SCH_STATE'] = 'ACTIVE';
|
||||
$aData['SCH_LAST_STATE'] = 'CREATED'; // 'ACTIVE';
|
||||
$aData['USR_UID'] = $userUID;
|
||||
$sOption = $aData['SCH_OPTION'];
|
||||
if ($aData['SCH_START_DATE'] != '') {
|
||||
$sDateTmp = $aData['SCH_START_DATE'];
|
||||
} else {
|
||||
$sDateTmp = date( 'Y-m-d' );
|
||||
}
|
||||
$sTimeTmp = $aData['SCH_START_TIME'];
|
||||
// $aData['SCH_START_TIME'] = date( 'Y-m-d', strtotime( $sDateTmp ) ) . ' ' . date( 'H:i:s', strtotime( $sTimeTmp ) );
|
||||
// $aData['SCH_START_DATE'] = date( 'Y-m-d', strtotime( $sDateTmp ) ) . ' ' . date( 'H:i:s', strtotime( $sTimeTmp ) );
|
||||
$nActualTime = $aData['SCH_START_TIME']; // time();
|
||||
$sValue = '';
|
||||
$sDaysPerformTask = '';
|
||||
$sWeeks = '';
|
||||
$sMonths = '';
|
||||
$sMonths = '';
|
||||
$sStartDay = '';
|
||||
$nSW = 0;
|
||||
switch ($sOption) {
|
||||
case '1': // Option 1
|
||||
$sValue = $aData['SCH_DAYS_PERFORM_TASK'];
|
||||
switch ($sValue) {
|
||||
case '1':
|
||||
$aData['SCH_DAYS_PERFORM_TASK'] = $aData['SCH_DAYS_PERFORM_TASK'] . '|1';
|
||||
break;
|
||||
case '2':
|
||||
$aData['SCH_OPTION'] = '2';
|
||||
$aData['SCH_EVERY_DAYS'] = '1'; //check
|
||||
$aData['SCH_WEEK_DAYS'] = '1|2|3|4|5|'; //check
|
||||
break;
|
||||
case '3': // Every [n] Days
|
||||
$sDaysPerformTask = $aData['SCH_DAYS_PERFORM_TASK_OPT_3'];
|
||||
$aData['SCH_DAYS_PERFORM_TASK'] = $aData['SCH_DAYS_PERFORM_TASK'] . '|' . $aData['SCH_DAYS_PERFORM_TASK_OPT_3'];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case '2': // If the option is zero, set by default 1
|
||||
if (empty( $aData['SCH_EVERY_DAYS'] )) {
|
||||
$nEveryDays = 1;
|
||||
} else {
|
||||
$nEveryDays = $aData['SCH_EVERY_DAYS'];
|
||||
}
|
||||
$aData['SCH_EVERY_DAYS'] = $nEveryDays;
|
||||
$sWeeks = '';
|
||||
if (! empty( $aData['SCH_WEEK_DAYS'] )) {
|
||||
$aWeekDays = $aData['SCH_WEEK_DAYS'];
|
||||
foreach ($aWeekDays as $value) {
|
||||
$sWeeks = $sWeeks . $value . '|';
|
||||
}
|
||||
}
|
||||
if (! empty( $aData['SCH_WEEK_DAYS_2'] )) {
|
||||
$aWeekDays2 = $aData['SCH_WEEK_DAYS_2'];
|
||||
foreach ($aWeekDays2 as $value) {
|
||||
$sWeeks = $sWeeks . $value . '|';
|
||||
}
|
||||
}
|
||||
$sStartTime = $aData['SCH_START_TIME'];
|
||||
$aData['SCH_WEEK_DAYS'] = $sWeeks;
|
||||
break;
|
||||
case '3':
|
||||
$nStartDay = $aData['SCH_START_DAY'];
|
||||
if ($nStartDay == 1) {
|
||||
$aData['SCH_START_DAY'] = $nStartDay . '|' . $aData['SCH_START_DAY_OPT_1'];
|
||||
} else {
|
||||
$aData['SCH_START_DAY'] = $nStartDay . '|' . $aData['SCH_START_DAY_OPT_2_WEEKS'] . '|' . $aData['SCH_START_DAY_OPT_2_DAYS_WEEK'];
|
||||
}
|
||||
|
||||
$sMonths = '';
|
||||
if (! empty( $aData['SCH_MONTHS'] )) {
|
||||
$aMonths = $aData['SCH_MONTHS'];
|
||||
foreach ($aMonths as $value) {
|
||||
$sMonths = $sMonths . $value . '|';
|
||||
}
|
||||
}
|
||||
if (! empty( $aData['SCH_MONTHS_2'] )) {
|
||||
$aMonths2 = $aData['SCH_MONTHS_2'];
|
||||
foreach ($aMonths2 as $value) {
|
||||
$sMonths = $sMonths . $value . '|';
|
||||
}
|
||||
}
|
||||
if (! empty( $aData['SCH_MONTHS_3'] )) {
|
||||
$aMonths3 = $aData['SCH_MONTHS_3'];
|
||||
foreach ($aMonths3 as $value) {
|
||||
$sMonths = $sMonths . $value . '|';
|
||||
}
|
||||
}
|
||||
$aData['SCH_MONTHS'] = $sMonths;
|
||||
$sStartDay = $aData['SCH_START_DAY'];
|
||||
$sValue = $nStartDay;
|
||||
break;
|
||||
}
|
||||
if (($sOption != '1') && ($sOption != '4') && ($sOption != '5')) {
|
||||
if ($sStartDay == '') {
|
||||
$sStartDay = date( 'Y-m-d' );
|
||||
}
|
||||
$dCurrentDay = date( "d" );
|
||||
$dCurrentMonth = date( "m" );
|
||||
$aStartDay = explode( "|", $aData['SCH_START_DAY'] );
|
||||
if ($sOption == '3' && $aStartDay[0] == '1') {
|
||||
$monthsArray = explode( "|", $sMonths );
|
||||
foreach ($monthsArray as $row) {
|
||||
if ($dCurrentMonth == $row && $dCurrentDay < $aStartDay[1]) {
|
||||
$startTime = $aData['SCH_START_TIME'] . ":00";
|
||||
$aData['SCH_TIME_NEXT_RUN'] = date( 'Y' ) . '-' . $row . '-' . $aStartDay[1] . ' ' . $startTime;
|
||||
break;
|
||||
} else {
|
||||
$aData['SCH_TIME_NEXT_RUN'] = $oCaseScheduler->updateNextRun( $sOption, $sValue, $nActualTime, $sDaysPerformTask, $sWeeks, $sStartDay, $sMonths, $sDateTmp );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* echo $sOption; echo " - ";
|
||||
echo $sValue; echo " - "; echo $nActualTime; echo " - "; echo $sDaysPerformTask; echo " - "; echo $sWeeks;
|
||||
echo " - "; echo $sStartDay; echo " - "; echo $sMonths; echo " - "; echo $sDateTmp; die();
|
||||
|
||||
*/
|
||||
echo $sOption."*". $sValue."*". $nActualTime."*". $sDaysPerformTask."*". $sWeeks."*". $sStartDay ."*". $sMonths."<br>";
|
||||
$aData['SCH_TIME_NEXT_RUN'] = $oCaseScheduler->updateNextRun( $sOption, $sValue, $nActualTime, $sDaysPerformTask, $sWeeks, $sStartDay, $sMonths, $sDateTmp );
|
||||
echo $aData['SCH_TIME_NEXT_RUN']; die ();
|
||||
}
|
||||
|
||||
} else {
|
||||
if ($sOption == '4') {
|
||||
$aData['SCH_END_DATE'] = $aData['SCH_START_TIME'];
|
||||
}
|
||||
|
||||
$aData['SCH_TIME_NEXT_RUN'] = $aData['SCH_START_TIME'];
|
||||
|
||||
if ($sOption == 5) {
|
||||
$aData['SCH_START_TIME'] = time();
|
||||
$aData['SCH_START_DATE'] = $aData['SCH_START_TIME'];
|
||||
$nextRun = $aData['SCH_REPEAT_EVERY'] * 60 * 60;
|
||||
$aData['SCH_REPEAT_EVERY'] = $aData['SCH_REPEAT_EVERY'];
|
||||
$date = $aData['SCH_START_TIME'];
|
||||
$date += $nextRun;
|
||||
$date = date( "Y-m-d H:i", $date );
|
||||
$aData['SCH_TIME_NEXT_RUN'] = $date;
|
||||
}
|
||||
}
|
||||
if (trim( $aData['SCH_END_DATE'] ) != '') {
|
||||
$aData['SCH_END_DATE'] = $aData['SCH_END_DATE'];
|
||||
}
|
||||
if (! empty( $aData['SCH_REPEAT_TASK_CHK'] )) {
|
||||
$nOptEvery = $aData['SCH_REPEAT_EVERY_OPT'];
|
||||
if ($nOptEvery == 2) {
|
||||
$aData['SCH_REPEAT_EVERY'] = $aData['SCH_REPEAT_EVERY'] * 60;
|
||||
} else {
|
||||
$aData['SCH_REPEAT_EVERY'] = $aData['SCH_REPEAT_EVERY'];
|
||||
}
|
||||
}
|
||||
if ((isset( $aData['CASE_SH_PLUGIN_UID'] )) && ($aData['CASE_SH_PLUGIN_UID'] != "")) {
|
||||
$aData['CASE_SH_PLUGIN_UID'] = $aData['CASE_SH_PLUGIN_UID'];
|
||||
}
|
||||
$oCaseScheduler->create( $aData );
|
||||
$oCriteria = $this->getCaseScheduler($sProcessUID, $aData['SCH_UID']);
|
||||
return $oCriteria;
|
||||
} catch (Exception $oException) {
|
||||
die( $oException->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update case scheduler for a project
|
||||
* @param string $sProcessUID
|
||||
* @param string $sSchUID
|
||||
* @param array $aData
|
||||
* @param string $userUID
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function updateCaseScheduler($sProcessUID, $sSchUID = '', $aData, $userUID)
|
||||
{
|
||||
try {
|
||||
require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes". PATH_SEP . "model" . PATH_SEP . "CaseScheduler.php");
|
||||
$aData = array_change_key_case($aData, CASE_UPPER);
|
||||
if (empty( $aData )) {
|
||||
die( 'The information sended is empty!' );
|
||||
}
|
||||
$oCaseScheduler = new \CaseScheduler();
|
||||
|
||||
$oCaseScheduler->Load($sSchUID);
|
||||
$aData['SCH_DEL_USER_NAME'] = $aData['SCH_USER_NAME'];
|
||||
if ($aData['SCH_USER_PASSWORD'] != 'DefaultPM') {
|
||||
$aData['SCH_DEL_USER_PASS'] = md5( $aData['SCH_USER_PASSWORD'] );
|
||||
}
|
||||
$aData['SCH_DEL_USER_UID'] = $aData['SCH_USER_UID'];
|
||||
$aData['USR_UID'] = $userUID;
|
||||
$sOption = $aData['SCH_OPTION'];
|
||||
$sDateTmp = $aData['SCH_START_DATE'];
|
||||
$sTimeTmp = $aData['SCH_START_TIME'];
|
||||
// $aData['SCH_START_TIME'] = date( 'Y-m-d', strtotime( $sDateTmp ) ) . ' ' . date( 'H:i:s', strtotime( $sTimeTmp ) );
|
||||
// $aData['SCH_START_DATE'] = date( 'Y-m-d', strtotime( $sDateTmp ) ) . ' ' . date( 'H:i:s', strtotime( $sTimeTmp ) );
|
||||
$previousStartTime = date( 'Y-m-d', strtotime( $aData['PREV_SCH_START_DATE'] ) ) . ' ' . date( 'H:i:s', strtotime( $aData['PREV_SCH_START_TIME'] ) );
|
||||
$previousStartDate = date( 'Y-m-d', strtotime( $aData['PREV_SCH_START_DATE'] ) ) . ' ' . date( 'H:i:s', strtotime( $aData['PREV_SCH_START_TIME'] ) );
|
||||
$sValue = '';
|
||||
$sDaysPerformTask = '';
|
||||
$sWeeks = '';
|
||||
$sMonths = '';
|
||||
$sMonths = '';
|
||||
$sStartDay = '';
|
||||
$nSW = 0;
|
||||
switch ($sOption) {
|
||||
case '1':
|
||||
// Option 1
|
||||
$sValue = $aData['SCH_DAYS_PERFORM_TASK'];
|
||||
switch ($sValue) {
|
||||
case '1':
|
||||
$aData['SCH_DAYS_PERFORM_TASK'] = $aData['SCH_DAYS_PERFORM_TASK'] . '|1';
|
||||
break;
|
||||
case '2':
|
||||
$aData['SCH_OPTION'] = '2';
|
||||
$aData['SCH_EVERY_DAYS'] = '1';
|
||||
$aData['SCH_WEEK_DAYS'] = '1|2|3|4|5|';
|
||||
break;
|
||||
case '3': // Every [n] Days
|
||||
$sDaysPerformTask = $aData['SCH_DAYS_PERFORM_TASK_OPT_3'];
|
||||
$aData['SCH_DAYS_PERFORM_TASK'] = $aData['SCH_DAYS_PERFORM_TASK'] . '|' . $aData['SCH_DAYS_PERFORM_TASK_OPT_3'];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case '2':
|
||||
// If the option is zero, set by default 1
|
||||
if (empty( $aData['SCH_EVERY_DAYS'] )) {
|
||||
$nEveryDays = 1;
|
||||
} else {
|
||||
$nEveryDays = $aData['SCH_EVERY_DAYS'];
|
||||
}
|
||||
$aData['SCH_EVERY_DAYS'] = $nEveryDays;
|
||||
$sWeeks = '';
|
||||
if (! empty( $aData['SCH_WEEK_DAYS'] )) {
|
||||
$aWeekDays = $aData['SCH_WEEK_DAYS'];
|
||||
foreach ($aWeekDays as $value) {
|
||||
$sWeeks = $sWeeks . $value . '|';
|
||||
}
|
||||
}
|
||||
if (! empty( $aData['SCH_WEEK_DAYS_2'] )) {
|
||||
$aWeekDays2 = $aData['SCH_WEEK_DAYS_2'];
|
||||
foreach ($aWeekDays2 as $value) {
|
||||
$sWeeks = $sWeeks . $value . '|';
|
||||
}
|
||||
}
|
||||
$sStartTime = $aData['SCH_START_TIME'];
|
||||
$aData['SCH_WEEK_DAYS'] = $sWeeks;
|
||||
break;
|
||||
case '3':
|
||||
$nStartDay = $aData['SCH_START_DAY'];
|
||||
if ($nStartDay == 1) {
|
||||
$aData['SCH_START_DAY'] = $nStartDay . '|' . $aData['SCH_START_DAY_OPT_1'];
|
||||
} else {
|
||||
$aData['SCH_START_DAY'] = $nStartDay . '|' . $aData['SCH_START_DAY_OPT_2_WEEKS'] . '|' . $aData['SCH_START_DAY_OPT_2_DAYS_WEEK'];
|
||||
}
|
||||
|
||||
$sMonths = '';
|
||||
if (! empty( $aData['SCH_MONTHS'] )) {
|
||||
$aMonths = $aData['SCH_MONTHS'];
|
||||
foreach ($aMonths as $value) {
|
||||
$sMonths = $sMonths . $value . '|';
|
||||
}
|
||||
}
|
||||
if (! empty( $aData['SCH_MONTHS_2'] )) {
|
||||
$aMonths2 = $aData['SCH_MONTHS_2'];
|
||||
foreach ($aMonths2 as $value) {
|
||||
$sMonths = $sMonths . $value . '|';
|
||||
}
|
||||
}
|
||||
if (! empty( $aData['SCH_MONTHS_3'] )) {
|
||||
$aMonths3 = $aData['SCH_MONTHS_3'];
|
||||
foreach ($aMonths3 as $value) {
|
||||
$sMonths = $sMonths . $value . '|';
|
||||
}
|
||||
}
|
||||
$aData['SCH_MONTHS'] = $sMonths;
|
||||
$sStartDay = $aData['SCH_START_DAY'];
|
||||
$sValue = $nStartDay;
|
||||
break;
|
||||
|
||||
}
|
||||
if (trim( $aData['SCH_END_DATE'] ) != '') {
|
||||
$aData['SCH_END_DATE'] = $aData['SCH_END_DATE'];
|
||||
}
|
||||
// if the start date has changed then recalculate the next run time
|
||||
if ($aData['SCH_START_DATE'] == $aData['PREV_SCH_START_DATE']) {
|
||||
$recalculateDate = false;
|
||||
} else {
|
||||
$recalculateDate = true;
|
||||
}
|
||||
if (date( 'H:i:s', strtotime( $aData['SCH_START_TIME'] ) ) == date( 'H:i:s', strtotime( $aData['PREV_SCH_START_TIME'] ) )) {
|
||||
$recalculateTime = false;
|
||||
} else {
|
||||
$recalculateTime = true;
|
||||
}
|
||||
// if the start date has changed then recalculate the next run time
|
||||
$nActualTime = $aData['SCH_START_TIME'];
|
||||
if (($sOption != '1') && ($sOption != '4') && ($sOption != '5')) {
|
||||
if ($sStartDay == '') {
|
||||
$sStartDay = date( 'Y-m-d' );
|
||||
}
|
||||
$dCurrentDay = date( "d" );
|
||||
$dCurrentMonth = date( "m" );
|
||||
$aStartDay = explode( "|", $aData['SCH_START_DAY'] );
|
||||
if ($sOption == '3' && $aStartDay[0] == '1') {
|
||||
$monthsArray = explode( "|", $sMonths );
|
||||
foreach ($monthsArray as $row) {
|
||||
if ($dCurrentMonth == $row && $dCurrentDay < $aStartDay[1]) {
|
||||
$startTime = $_POST['form']['SCH_START_TIME'] . ":00";
|
||||
if ($recalculateDate) {
|
||||
$aData['SCH_TIME_NEXT_RUN'] = date( 'Y' ) . '-' . $row . '-' . $aStartDay[1] . ' ' . $startTime;
|
||||
} elseif ($recalculateTime) {
|
||||
$aData['SCH_TIME_NEXT_RUN'] = $oCaseScheduler->getSchTimeNextRun( "Y-m-d" ) . " " . $_POST['form']['SCH_START_TIME'] . ":00";
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
if ($recalculateDate) {
|
||||
$aData['SCH_TIME_NEXT_RUN'] = $oCaseScheduler->updateNextRun( $sOption, $sValue, $nActualTime, $sDaysPerformTask, $sWeeks, $sStartDay, $sMonths, $sDateTmp );
|
||||
} elseif ($recalculateTime) {
|
||||
$aData['SCH_TIME_NEXT_RUN'] = $oCaseScheduler->getSchTimeNextRun( "Y-m-d" ) . " " . $_POST['form']['SCH_START_TIME'] . ":00";
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($recalculateDate) {
|
||||
$aData['SCH_TIME_NEXT_RUN'] = $oCaseScheduler->updateNextRun( $sOption, $sValue, $nActualTime, $sDaysPerformTask, $sWeeks, $sStartDay, $sMonths, $sDateTmp );
|
||||
} elseif ($recalculateTime) {
|
||||
$aData['SCH_TIME_NEXT_RUN'] = $oCaseScheduler->getSchTimeNextRun( "Y-m-d" ) . " " . $_POST['form']['SCH_START_TIME'] . ":00";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($sOption == '4') {
|
||||
$aData['SCH_END_DATE'] = $aData['SCH_START_TIME'];
|
||||
}
|
||||
if ($recalculateDate) {
|
||||
$aData['SCH_TIME_NEXT_RUN'] = $aData['SCH_START_TIME'];
|
||||
} elseif ($recalculateTime) {
|
||||
$aData['SCH_TIME_NEXT_RUN'] = $oCaseScheduler->getSchTimeNextRun( "Y-m-d" ) . " " . $aData['SCH_START_TIME'] . ":00";
|
||||
}
|
||||
if ($sOption == '5') {
|
||||
$date = $oCaseScheduler->getSchLastRunTime();
|
||||
if ($date == null) {
|
||||
$date = $oCaseScheduler->getSchStartTime();
|
||||
}
|
||||
$date = strtotime( $date );
|
||||
$nextRun = $aData['SCH_REPEAT_EVERY'] * 60 * 60;
|
||||
$aData['SCH_REPEAT_EVERY'] = $aData['SCH_REPEAT_EVERY'];
|
||||
$date += $nextRun;
|
||||
$date = date( "Y-m-d H:i", $date );
|
||||
$aData['SCH_TIME_NEXT_RUN'] = $date;
|
||||
}
|
||||
}
|
||||
if (! empty( $aData['SCH_REPEAT_TASK_CHK'] )) {
|
||||
$nOptEvery = $aData['SCH_REPEAT_EVERY_OPT'];
|
||||
if ($nOptEvery == 2) {
|
||||
$aData['SCH_REPEAT_EVERY'] = $aData['SCH_REPEAT_EVERY'] * 60;
|
||||
} else {
|
||||
$aData['SCH_REPEAT_EVERY'] = $aData['SCH_REPEAT_EVERY'];
|
||||
}
|
||||
}
|
||||
$aData["SCH_UID"] = $sSchUID;
|
||||
$oCaseScheduler->Update($aData);
|
||||
$oCriteria = $this->getCaseScheduler($sProcessUID, $sSchUID);
|
||||
return $oCriteria;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a case scheduler of a project
|
||||
*
|
||||
* @param string $sProcessUID
|
||||
* @param string $sSchUID
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function deleteCaseScheduler($sProcessUID, $sSchUID)
|
||||
{
|
||||
try {
|
||||
require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes". PATH_SEP . "model" . PATH_SEP . "CaseScheduler.php");
|
||||
$oCaseScheduler = new \CaseScheduler();
|
||||
if ( !isset($sSchUID ) ) {
|
||||
return;
|
||||
}
|
||||
$oCaseScheduler->remove($sSchUID);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
namespace Services\Api\ProcessMaker\Project;
|
||||
|
||||
use \ProcessMaker\Services\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
|
||||
/**
|
||||
* Project\CaseScheduler Api Controller
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
class CaseScheduler extends Api
|
||||
{
|
||||
/**
|
||||
* @param string $prjUid {@min 32} {@max 32}
|
||||
*
|
||||
* @url GET /:prjUid/case-schedulers
|
||||
*/
|
||||
public function doGetProjectCaseSchedulers($prjUid)
|
||||
{
|
||||
try {
|
||||
$caseScheduler = new \BusinessModel\CaseScheduler();
|
||||
$arrayData = $caseScheduler->getCaseSchedulers($prjUid);
|
||||
//Response
|
||||
$response = $arrayData;
|
||||
} catch (\Exception $e) {
|
||||
//response
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $prjUid {@min 32} {@max 32}
|
||||
* @param string $caseSchedulerUid {@min 32} {@max 32}
|
||||
*
|
||||
* @url GET /:prjUid/case-scheduler/:caseSchedulerUid
|
||||
*/
|
||||
public function doGetProjectCaseScheduler($prjUid, $caseSchedulerUid)
|
||||
{
|
||||
try {
|
||||
$caseScheduler = new \BusinessModel\CaseScheduler();
|
||||
$objectData = $caseScheduler->getCaseScheduler($prjUid, $caseSchedulerUid);
|
||||
//Response
|
||||
$response = $objectData;
|
||||
} catch (\Exception $e) {
|
||||
//response
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $prjUid {@min 32} {@max 32}
|
||||
* @param CaseSchedulerStructure $request_data
|
||||
*
|
||||
* @url POST /:prjUid/case-scheduler
|
||||
*
|
||||
* @status 201
|
||||
*/
|
||||
public function doPostProjectCaseScheduler($prjUid, CaseSchedulerStructure $request_data = null)
|
||||
{
|
||||
try {
|
||||
$userUid = $this->getUserId();
|
||||
$request_data = (array)($request_data);
|
||||
$caseScheduler = new \BusinessModel\CaseScheduler();
|
||||
$objectData = $caseScheduler->addCaseScheduler($prjUid, $request_data, $userUid);
|
||||
//Response
|
||||
$response = $objectData;
|
||||
} catch (\Exception $e) {
|
||||
//response
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @url PUT /:prjUid/case-scheduler/:schUid
|
||||
*
|
||||
* @param string $prjUid {@min 32} {@max 32}
|
||||
* @param string $schUid {@min 32} {@max 32}
|
||||
* @param CaseSchedulerStructure $request_data
|
||||
*
|
||||
*/
|
||||
public function doPutProjectCaseScheduler($prjUid, $schUid, CaseSchedulerStructure $request_data)
|
||||
{
|
||||
try {
|
||||
$userUid = $this->getUserId();
|
||||
$request_data = (array)($request_data);
|
||||
$caseScheduler = new \BusinessModel\CaseScheduler();
|
||||
$objectData = $caseScheduler->updateCaseScheduler($prjUid, $schUid, $request_data, $userUid);
|
||||
//Response
|
||||
$response = $objectData;
|
||||
} catch (\Exception $e) {
|
||||
//response
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @url DELETE /:prjUid/case-scheduler/:schUid
|
||||
* @param string $prjUid {@min 32} {@max 32}
|
||||
* @param string $schUid {@min 32} {@max 32}
|
||||
*
|
||||
*/
|
||||
public function doDeleteProjectCaseScheduler($prjUid, $schUid)
|
||||
{
|
||||
try {
|
||||
$caseScheduler = new \BusinessModel\CaseScheduler();
|
||||
$caseScheduler->deleteCaseScheduler($prjUid, $schUid);
|
||||
} catch (\Exception $e) {
|
||||
//response
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CaseSchedulerStructure
|
||||
{ /**
|
||||
* @var string {@from body} {@min 0} {@max 100}
|
||||
*/
|
||||
public $sch_name;
|
||||
|
||||
/**
|
||||
* @var string {@from body} {@min 0} {@max 100}
|
||||
*/
|
||||
public $sch_del_user_name;
|
||||
|
||||
/**
|
||||
* @var string {@from body} {@min 0} {@max 100}
|
||||
*/
|
||||
public $sch_del_user_pass;
|
||||
|
||||
/**
|
||||
* @var string {@from body} {@min 0} {@max 100}
|
||||
*/
|
||||
public $sch_del_user_uid;
|
||||
|
||||
/**
|
||||
* @var string {@from body} {@min 32} {@max 32}
|
||||
*/
|
||||
public $pro_uid;
|
||||
|
||||
/**
|
||||
* @var string {@from body} {@min 32} {@max 32}
|
||||
*/
|
||||
public $tas_uid;
|
||||
|
||||
/**
|
||||
* @var string {@from body}
|
||||
*/
|
||||
public $sch_time_next_run;
|
||||
|
||||
/**
|
||||
* @var string {@from body}
|
||||
*/
|
||||
public $sch_last_run_time;
|
||||
|
||||
/**
|
||||
* @var string {@from body} {@min 0} {@max 15}
|
||||
*/
|
||||
public $sch_state;
|
||||
|
||||
/**
|
||||
* @var string {@from body} {@min 0} {@max 15}
|
||||
*/
|
||||
public $sch_last_state;
|
||||
|
||||
/**
|
||||
* @var string {@from body} {@min 32} {@max 32}
|
||||
*/
|
||||
public $usr_uid;
|
||||
|
||||
/**
|
||||
* @var string {@from body}
|
||||
*/
|
||||
public $sch_option;
|
||||
|
||||
/**
|
||||
* @var string {@from body}
|
||||
*/
|
||||
public $sch_start_time;
|
||||
|
||||
/**
|
||||
* @var string {@from body}
|
||||
*/
|
||||
public $sch_start_date;
|
||||
|
||||
/**
|
||||
* @var string {@from body} {@min 0} {@max 5}
|
||||
*/
|
||||
public $sch_days_perform_task;
|
||||
|
||||
/**
|
||||
* @var string {@from body} {@min 0} {@max 4}
|
||||
*/
|
||||
public $sch_every_days;
|
||||
|
||||
/**
|
||||
* @var string {@from body} {@min 0} {@max 14}
|
||||
*/
|
||||
public $sch_week_days;
|
||||
|
||||
/**
|
||||
* @var string {@from body} {@min 0} {@max 6}
|
||||
*/
|
||||
public $sch_start_day;
|
||||
|
||||
/**
|
||||
* @var string {@from body} {@min 0} {@max 24}
|
||||
*/
|
||||
public $sch_months;
|
||||
|
||||
/**
|
||||
* @var string {@from body}
|
||||
*/
|
||||
public $sch_end_date;
|
||||
|
||||
/**
|
||||
* @var string {@from body} {@min 0} {@max 15}
|
||||
*/
|
||||
public $sch_repeat_every;
|
||||
|
||||
/**
|
||||
* @var string {@from body} {@min 0} {@max 15}
|
||||
*/
|
||||
public $sch_repeat_until;
|
||||
|
||||
/**
|
||||
* @var string {@from body} {@min 0} {@max 4}
|
||||
*/
|
||||
public $sch_repeat_stop_if_running;
|
||||
|
||||
/**
|
||||
* @var string {@from body} {@min 0} {@max 100}
|
||||
*/
|
||||
public $case_sh_plugin_uid;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user