Verified Commit 532cf7b6 authored by dockx thibault's avatar dockx thibault
Browse files

:sparkles: Feat(Orchestrator) - lifecycle supann check logic

Changes supann check logic
Showing with 23 additions and 19 deletions
+23 -19
...@@ -138,31 +138,35 @@ class LifeCycle implements EndpointInterface ...@@ -138,31 +138,35 @@ class LifeCycle implements EndpointInterface
if (empty($currentUserLifeCycle[0]['supannressourceetatdate'][0])) { if (empty($currentUserLifeCycle[0]['supannressourceetatdate'][0])) {
return FALSE; return FALSE;
} }
// Perform the regular expression match
preg_match($pattern, $currentUserLifeCycle[0]['supannressourceetatdate'][0], $matches);
// Extracting values of current user
$userSupann['Resource'] = $matches[1] ?? '';
$userSupann['State'] = $matches[2] ?? '';
$userSupann['SubState'] = $matches[3] ?? '';
// Array index 4 is skipped, we only use end date to apply our life cycle logic. Start date has no use here.
$userSupann['EndDate'] = $matches[5] ?? '';
// Extracting values of desired pre-state behavior // Extracting values of desired pre-state behavior
$preStateSupann['Resource'] = $lifeCycleBehavior[0]['fdtaskslifecyclepreresource'][0]; $preStateSupann['Resource'] = $lifeCycleBehavior[0]['fdtaskslifecyclepreresource'][0];
$preStateSupann['State'] = $lifeCycleBehavior[0]['fdtaskslifecycleprestate'][0]; $preStateSupann['State'] = $lifeCycleBehavior[0]['fdtaskslifecycleprestate'][0];
$preStateSupann['SubState'] = $lifeCycleBehavior[0]['fdtaskslifecyclepresubstate'][0] ?? ''; //SubState is optional $preStateSupann['SubState'] = $lifeCycleBehavior[0]['fdtaskslifecyclepresubstate'][0] ?? ''; //SubState is optional
// Verifying if the user end date for selected resource is overdue // Iteration of all potential existing supann states of the user in order to find a match
if (!empty($userSupann['EndDate']) && strtotime($userSupann['EndDate']) <= time()) { foreach ($currentUserLifeCycle[0]['supannressourceetatdate'] as $resource) {
// Comparing value in a nesting conditions // Perform the regular expression match
if ($userSupann['Resource'] == $preStateSupann['Resource']) { preg_match($pattern, $resource, $matches);
if ($userSupann['State'] == $preStateSupann['State']) {
// as SubState is optional, if both resource and state match at this point, modification is allowed. // Extracting values of current user
if (empty($preStateSupann['SubState'])) { $userSupann['Resource'] = $matches[1] ?? '';
$result = TRUE; $userSupann['State'] = $matches[2] ?? '';
} else if ($preStateSupann['SubState'] == $userSupann['SubState']) { $userSupann['SubState'] = $matches[3] ?? '';
$result = TRUE; // Array index 4 is skipped, we only use end date to apply our life cycle logic. Start date has no use here.
$userSupann['EndDate'] = $matches[5] ?? '';
// Verifying if the user end date for selected resource is overdue
if (!empty($userSupann['EndDate']) && strtotime($userSupann['EndDate']) <= time()) {
// Comparing value in a nesting conditions
if ($userSupann['Resource'] == $preStateSupann['Resource']) {
if ($userSupann['State'] == $preStateSupann['State']) {
// as SubState is optional, if both resource and state match at this point, modification is allowed.
if (empty($preStateSupann['SubState'])) {
$result = TRUE;
} else if ($preStateSupann['SubState'] == $userSupann['SubState']) {
$result = TRUE;
}
} }
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment