Skip to content

Commit

Permalink
Merge pull request #214 from 1AhmedYasser/Connecting-Service-to-an-In…
Browse files Browse the repository at this point in the history
…tent

Connecting Service to Intent
  • Loading branch information
PaulaMerle authored Feb 29, 2024
2 parents ff57668 + 8f06a75 commit e462d43
Show file tree
Hide file tree
Showing 36 changed files with 1,072 additions and 974 deletions.
3 changes: 3 additions & 0 deletions DSL/Liquibase/changelog/1709066018-add-ready-status.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- liquibase formatted sql
-- changeset ahmedyasser:1709066018
ALTER TYPE service_state ADD VALUE 'ready';
2 changes: 2 additions & 0 deletions DSL/Resql/training/add-service-trigger.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO service_trigger (intent, service, status, author_role, service_name)
VALUES (:intent, :serviceId, :status::trigger_status, :authorRole::author_role, :serviceName)
2 changes: 2 additions & 0 deletions DSL/Resql/training/delete-service-trigger.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO service_trigger (intent, service, status, author_role, service_name)
VALUES (:intent, :serviceId, 'deleted'::trigger_status, :authorRole::author_role, :serviceName)
27 changes: 27 additions & 0 deletions DSL/Resql/training/get-available-intents.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
WITH connected_intents AS
(SELECT intent,
service,
service_name,
status,
created
FROM service_trigger
WHERE (intent,
service,
service_name,
created) IN
(SELECT intent,
service,
service_name,
max(created)
FROM service_trigger
GROUP BY intent,
service,
service_name)
AND status in ('pending',
'approved'))
SELECT intent
FROM intent
WHERE intent NOT IN
(SELECT intent
FROM connected_intents)
ORDER BY intent ASC
10 changes: 10 additions & 0 deletions DSL/Resql/training/get-requested-service-triggers.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SELECT intent,
service,
MAX(service_name) AS service_name,
MAX(created) AS requested_at,
MAX(author_role) as author_role
FROM service_trigger
GROUP BY intent,
service
HAVING MAX(status) = 'pending'
AND max("author_role") != 'service_manager';
9 changes: 9 additions & 0 deletions DSL/Resql/training/get-service-trigger.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
SELECT id, intent, service, service_name, status, author_role, created
FROM service_trigger
WHERE service = :serviceId
AND id = (
SELECT MAX(id)
FROM service_trigger
WHERE service = :serviceId
)
AND status NOT IN ('deleted', 'declined');
8 changes: 8 additions & 0 deletions DSL/Ruuter/GET/services/available-intents.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
get_available_intents:
call: http.post
args:
url: "[#SERVICE_TRAINING_RESQL]/get-available-intents"
result: res

return_result:
return: ${res.response.body}
8 changes: 8 additions & 0 deletions DSL/Ruuter/GET/services/connection-requests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
get_connection_requests:
call: http.post
args:
url: "[#SERVICE_TRAINING_RESQL]/get-requested-service-triggers"
result: res

return_result:
return: ${res.response.body}
15 changes: 15 additions & 0 deletions DSL/Ruuter/POST/services/check-intent-connection.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
extract_request_data:
assign:
serviceId: ${incoming.body.serviceId}

check_for_intent_connection:
call: http.post
args:
url: "[#SERVICE_TRAINING_RESQL]/get-service-trigger"
body:
serviceId: ${serviceId}
result: res

return_result:
status: 200
return: ${res.response.body[0]}
27 changes: 27 additions & 0 deletions DSL/Ruuter/POST/services/delete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,35 @@ delete_endpoints:
body:
name: ${name_res.response.body[0].name}
result: delete_endpoints_res
next: check_for_intent_connection

check_for_intent_connection:
call: http.post
args:
url: "[#SERVICE_TRAINING_RESQL]/get-service-trigger"
body:
serviceId: ${id}
result: connection_res
next: check_is_connected_to_intents_or_has_requests

check_is_connected_to_intents_or_has_requests:
switch:
- condition: ${connection_res.response.body.length > 0}
next: delete_intent_connection
next: return_ok

delete_intent_connection:
call: http.post
args:
url: "[#SERVICE_TRAINING_RESQL]/add-service-trigger"
body:
serviceId: ${id}
intent: ${connection_res.response.body[0].intent}
status: "deleted"
authorRole: ${connection_res.response.body[0].authorRole}
serviceName: ${connection_res.response.body[0].serviceName}
result: return_ok

return_ok:
status: 200
return: "Service Deleted Successfully"
Expand Down
21 changes: 21 additions & 0 deletions DSL/Ruuter/POST/services/request-service-intent-connection.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
extract_request_data:
assign:
serviceId: ${incoming.body.serviceId}
serviceName: ${incoming.body.serviceName}
intent: ${incoming.body.intent}

add_connection_request:
call: http.post
args:
url: "[#SERVICE_TRAINING_RESQL]/add-service-trigger"
body:
serviceId: ${serviceId}
intent: ${intent}
status: "pending"
authorRole: "service_manager"
serviceName: ${serviceName}
result: res

return_result:
status: 200
return: "Connection request sent successfully"
23 changes: 23 additions & 0 deletions DSL/Ruuter/POST/services/respond-to-connection-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
extract_request_data:
assign:
serviceId: ${incoming.body.serviceId}
serviceName: ${incoming.body.serviceName}
authorRole: ${incoming.body.authorRole}
intent: ${incoming.body.intent}
status: ${incoming.body.status}

add_connection_request:
call: http.post
args:
url: "[#SERVICE_TRAINING_RESQL]/add-service-trigger"
body:
serviceId: ${serviceId}
intent: ${intent}
status: ${status}
authorRole: ${authorRole}
serviceName: ${serviceName}
result: res

return_result:
status: 200
return: "Response to connection request"
60 changes: 52 additions & 8 deletions DSL/Ruuter/POST/services/status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ check_for_required_parameters:
switch:
- condition: ${id === null || new_state === null || ruuter_type === null}
next: return_incorrect_request
- condition: ${new_state === "draft"}
next: return_cant_set_to_draft
- condition: ${new_state === "ready"}
next: set_plain_status
next: get_current_status

get_current_status:
Expand All @@ -24,7 +24,7 @@ get_current_status:

assign_old_status_and_path:
assign:
old_file_status_path: ${status_res.response.body[0].currentState}
old_file_status_path: "${status_res.response.body[0].currentState === 'ready' ? 'draft' : status_res.response.body[0].currentState}"
old_file_end: "${status_res.response.body[0].currentState !== 'active' ? '.tmp' : '.yml'}"
next: check_status

Expand All @@ -44,6 +44,16 @@ set_status:
result: res
next: get_status_name

set_plain_status:
call: http.post
args:
url: "[#SERVICE_RESQL]/set-status"
body:
id: ${id}
new_state: ${new_state}
result: draft_res
next: return_ok

get_status_name:
call: http.post
args:
Expand Down Expand Up @@ -78,6 +88,8 @@ check_for_status:
switch:
- condition: ${new_state === "active"}
next: activate_service
- condition: ${new_state === "draft"}
next: draft_service
next: deactivate_service

activate_service:
Expand All @@ -100,6 +112,43 @@ deactivate_service:
result: deactivate_service_result
next: return_ok

draft_service:
call: http.post
args:
url: "[#SERVICE_NODE]/file/move"
body:
current_path: "/Ruuter/${ruuter_type}/services/${old_file_status_path}/${name + old_file_end}"
new_path: "/Ruuter/${ruuter_type}/services/draft/${name}.tmp"
result: draft_service_result
next: check_for_intent_connection

check_for_intent_connection:
call: http.post
args:
url: "[#SERVICE_TRAINING_RESQL]/get-service-trigger"
body:
serviceId: ${id}
result: connection_res
next: check_is_connected_to_intents_or_has_requests

check_is_connected_to_intents_or_has_requests:
switch:
- condition: ${connection_res.response.body.length > 0}
next: delete_intent_connection
next: return_ok

delete_intent_connection:
call: http.post
args:
url: "[#SERVICE_TRAINING_RESQL]/add-service-trigger"
body:
serviceId: ${id}
intent: ${connection_res.response.body[0].intent}
status: "deleted"
authorRole: ${connection_res.response.body[0].authorRole}
serviceName: ${connection_res.response.body[0].serviceName}
result: return_ok

return_ok:
status: 200
return: "Status Changed Successfully"
Expand All @@ -115,11 +164,6 @@ return_incorrect_request:
return: "Required parameter(s) missing"
next: end

return_cant_set_to_draft:
status: 400
return: "Changing state to draft is not allowed"
next: end

return_same_state_update:
status: 400
return: "Service is already in this state"
Expand Down
4 changes: 2 additions & 2 deletions GUI/src/RootComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import NotFoundPage from './pages/NotFoundPage'
import OverviewPage from './pages/OverviewPage'
import FaultyServicesPage from './pages/FaultyServicesPage'
import { ROUTES } from './resources/routes-constants'
import IntentsFollowupTraining from './pages/Training/IntentsFollowupTraining'
import NewServicePage from './pages/NewServicePage'
import ServiceFlowPage from './pages/ServiceFlowPage'
import ServiceSettingPage from './pages/ServiceSettingPage'
import './styles/main.scss'
import ConnectionRequestsPage from 'pages/ConnectionRequestsPage'

const RootComponent: React.FC = () => {
return (
Expand All @@ -22,7 +22,7 @@ const RootComponent: React.FC = () => {
<Route element={<Layout />}>
<Route path={"/service"} element={<Navigate to="/services/overview" />} />
<Route path={ROUTES.OVERVIEW_ROUTE} element={<OverviewPage />} />
<Route path={ROUTES.FOLLOWUPTRAINING_ROUTE} element={<IntentsFollowupTraining />} />
<Route path={ROUTES.AUTOSERVICES_ROUTE} element={<ConnectionRequestsPage />} />
<Route path={ROUTES.FAULTY_SERVICES_ROUTE} element={<FaultyServicesPage />} />
<Route path={ROUTES.SERVICE_SETTINGS} element={<ServiceSettingPage />} />
<Route path={ROUTES.FAULTY_SERVICES_ROUTE} element={<FaultyServicesPage />} />
Expand Down
Loading

0 comments on commit e462d43

Please sign in to comment.