Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
36d573c1
Commit
36d573c1
authored
Aug 24, 2020
by
Manuel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
businessLogic: added additional requests
parent
82e8dd19
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
332 additions
and
20 deletions
+332
-20
swagger.yml
...n-hub/business-logic-microservice/app/configs/swagger.yml
+147
-0
swagger_local.yml
...business-logic-microservice/app/configs/swagger_local.yml
+102
-19
repository.py
...tion-hub/business-logic-microservice/app/db/repository.py
+5
-1
layer.py
...ation-hub/business-logic-microservice/app/routes/layer.py
+66
-0
layer_adapter_service.py
...-logic-microservice/app/services/layer_adapter_service.py
+12
-0
No files found.
src/participation-hub/business-logic-microservice/app/configs/swagger.yml
View file @
36d573c1
...
...
@@ -133,6 +133,153 @@ paths:
description
:
"
Layer
does
not
exist"
'
400'
:
description
:
"
Field
in
request
is
missing
or
attribute
does
not
exist
in
the
Layer"
/use-case/{use_case}/layers/use-case
:
put
:
security
:
-
JwtRegular
:
[]
operationId
:
"
routes.layer.update_use_case_for_all"
tags
:
-
"
Layers"
summary
:
"
Update
the
use-case
of
all
layers
belonging
to
the
use-case
in
the
query"
description
:
"
Update
the
use-case
of
all
layers
belonging
to
the
use-case
in
the
query"
parameters
:
-
name
:
"
use_case"
in
:
"
path"
description
:
"
Name
of
the
Use-Case
the
layer
belongs
to"
required
:
true
type
:
"
string"
-
in
:
body
name
:
"
Object"
required
:
true
schema
:
type
:
object
properties
:
use_case
:
type
:
string
example
:
"
air-bnb"
responses
:
'
200'
:
description
:
"
Successful
Request"
'
400'
:
description
:
"
Field
in
request
is
missing"
/use-case/{use_case}/layers/mapping
:
put
:
security
:
-
JwtRegular
:
[]
operationId
:
"
routes.layer.add_mapping_for_all"
tags
:
-
"
Layers"
summary
:
"
Adds
an
attribute
mapping
to
the
each
layer
of
the
use-case"
description
:
"
Adds
an
attribute
mapping
to
the
each
layer
of
the
use-case"
parameters
:
-
name
:
"
use_case"
in
:
"
path"
description
:
"
Name
of
the
Use-Case
the
layer
belongs
to"
required
:
true
type
:
"
string"
-
in
:
body
name
:
"
Object"
required
:
true
schema
:
type
:
object
properties
:
internal
:
type
:
string
example
:
"
end_time"
external
:
type
:
string
example
:
"
arrival_unix_timestamp_utc"
responses
:
'
200'
:
description
:
"
Successful
Request"
'
400'
:
description
:
"
Field
in
request
is
missing"
delete
:
security
:
-
JwtRegular
:
[]
operationId
:
"
routes.layer.delete_mapping_for_all"
tags
:
-
"
Layers"
summary
:
"
Deletes
an
attribute
mapping
for
all
layers
of
the
use-case"
description
:
"
Deletes
an
attribute
mapping
for
all
layers
of
the
use-case"
parameters
:
-
name
:
"
use_case"
in
:
"
path"
description
:
"
Name
of
the
Use-Case
the
layer
belongs
to"
required
:
true
type
:
"
string"
-
in
:
body
name
:
"
Object"
required
:
true
schema
:
type
:
object
properties
:
internal
:
type
:
string
example
:
"
end_time"
responses
:
'
200'
:
description
:
"
Successful
Request"
'
400'
:
description
:
"
Field
in
request
is
missing"
/use-case/{use_case}/layers/mapping
:
put
:
operationId
:
"
routes.layer.add_mapping_for_all"
tags
:
-
"
Layers"
summary
:
"
Adds
an
attribute
mapping
to
the
each
layer
of
the
use-case"
description
:
"
Adds
an
attribute
mapping
to
the
each
layer
of
the
use-case"
parameters
:
-
name
:
"
use_case"
in
:
"
path"
description
:
"
Name
of
the
Use-Case
the
layer
belongs
to"
required
:
true
type
:
"
string"
-
in
:
body
name
:
"
Object"
required
:
true
schema
:
type
:
object
properties
:
internal
:
type
:
string
example
:
"
end_time"
external
:
type
:
string
example
:
"
arrival_unix_timestamp_utc"
responses
:
'
200'
:
description
:
"
Successful
Request"
'
400'
:
description
:
"
Field
in
request
is
missing"
delete
:
operationId
:
"
routes.layer.delete_mapping_for_all"
tags
:
-
"
Layers"
summary
:
"
Deletes
an
attribute
mapping
for
all
layers
of
the
use-case"
description
:
"
Deletes
an
attribute
mapping
for
all
layers
of
the
use-case"
parameters
:
-
name
:
"
use_case"
in
:
"
path"
description
:
"
Name
of
the
Use-Case
the
layer
belongs
to"
required
:
true
type
:
"
string"
-
in
:
body
name
:
"
Object"
required
:
true
schema
:
type
:
object
properties
:
internal
:
type
:
string
example
:
"
end_time"
responses
:
'
200'
:
description
:
"
Successful
Request"
'
404'
:
description
:
"
Layer
does
not
exist"
'
400'
:
description
:
"
Field
in
request
is
missing"
/use-case/{use_case}/layers/{name}/mapping
:
delete
:
security
:
...
...
src/participation-hub/business-logic-microservice/app/configs/swagger_local.yml
View file @
36d573c1
...
...
@@ -118,6 +118,89 @@ paths:
description
:
"
Layer
does
not
exist"
'
400'
:
description
:
"
Field
in
request
is
missing
or
attribute
does
not
exist
in
the
Layer"
/use-case/{use_case}/layers/use-case
:
put
:
operationId
:
"
routes.layer.update_use_case_for_all"
tags
:
-
"
Layers"
summary
:
"
Update
the
use-case
of
all
layers
belonging
to
the
use-case
in
the
query"
description
:
"
Update
the
use-case
of
all
layers
belonging
to
the
use-case
in
the
query"
parameters
:
-
name
:
"
use_case"
in
:
"
path"
description
:
"
Name
of
the
Use-Case
the
layer
belongs
to"
required
:
true
type
:
"
string"
-
in
:
body
name
:
"
Object"
required
:
true
schema
:
type
:
object
properties
:
use_case
:
type
:
string
example
:
"
air-bnb"
responses
:
'
200'
:
description
:
"
Successful
Request"
'
400'
:
description
:
"
Field
in
request
is
missing"
/use-case/{use_case}/layers/mapping
:
put
:
operationId
:
"
routes.layer.add_mapping_for_all"
tags
:
-
"
Layers"
summary
:
"
Adds
an
attribute
mapping
to
the
each
layer
of
the
use-case"
description
:
"
Adds
an
attribute
mapping
to
the
each
layer
of
the
use-case"
parameters
:
-
name
:
"
use_case"
in
:
"
path"
description
:
"
Name
of
the
Use-Case
the
layer
belongs
to"
required
:
true
type
:
"
string"
-
in
:
body
name
:
"
Object"
required
:
true
schema
:
type
:
object
properties
:
internal
:
type
:
string
example
:
"
end_time"
external
:
type
:
string
example
:
"
arrival_unix_timestamp_utc"
responses
:
'
200'
:
description
:
"
Successful
Request"
'
400'
:
description
:
"
Field
in
request
is
missing"
delete
:
operationId
:
"
routes.layer.delete_mapping_for_all"
tags
:
-
"
Layers"
summary
:
"
Deletes
an
attribute
mapping
for
all
layers
of
the
use-case"
description
:
"
Deletes
an
attribute
mapping
for
all
layers
of
the
use-case"
parameters
:
-
name
:
"
use_case"
in
:
"
path"
description
:
"
Name
of
the
Use-Case
the
layer
belongs
to"
required
:
true
type
:
"
string"
-
in
:
body
name
:
"
Object"
required
:
true
schema
:
type
:
object
properties
:
internal
:
type
:
string
example
:
"
end_time"
responses
:
'
200'
:
description
:
"
Successful
Request"
'
400'
:
description
:
"
Field
in
request
is
missing"
/use-case/{use_case}/layers/{name}/mapping
:
delete
:
operationId
:
"
routes.layer.delete_mapping"
...
...
@@ -189,16 +272,16 @@ paths:
'
400'
:
description
:
"
Field
in
request
is
missing"
/use-case/{use_case}/layers/{name}
:
delete
:
operationId
:
"
routes.layer.
delete_
one"
get
:
operationId
:
"
routes.layer.one"
tags
:
-
"
Layers"
summary
:
"
Delet
e
one
LayerAdapter
from
the
DB"
description
:
"
Delet
e
one
LayerAdapter
from
the
DB"
summary
:
"
Retriev
e
one
LayerAdapter
from
the
DB"
description
:
"
Retriev
e
one
LayerAdapter
from
the
DB"
parameters
:
-
name
:
"
name"
in
:
"
path"
description
:
"
Name
of
the
layer
to
delete
"
description
:
"
Name
of
the
layer"
required
:
true
type
:
"
string"
-
name
:
"
use_case"
...
...
@@ -211,16 +294,16 @@ paths:
description
:
"
Successful
Request"
'
404'
:
description
:
"
Layer
does
not
exist"
ge
t
:
operationId
:
"
routes.layer.
one
"
pos
t
:
operationId
:
"
routes.layer.
add
"
tags
:
-
"
Layers"
summary
:
"
Retrieve
one
LayerAdapter
from
the
DB"
description
:
"
Retrieve
one
LayerAdapter
from
the
DB"
summary
:
"
Adds
a
new
layer
to
the
DB"
description
:
"
Adds
a
new
layer
to
the
DB"
parameters
:
-
name
:
"
name"
in
:
"
path"
description
:
"
Name
of
the
layer"
description
:
"
Name
of
the
new
layer"
required
:
true
type
:
"
string"
-
name
:
"
use_case"
...
...
@@ -231,18 +314,18 @@ paths:
responses
:
'
200'
:
description
:
"
Successful
Request"
'
40
4
'
:
description
:
"
Layer
does
not
exist
"
post
:
operationId
:
"
routes.layer.
add
"
'
40
0
'
:
description
:
"
Layer
already
exists
"
delete
:
operationId
:
"
routes.layer.
delete_one
"
tags
:
-
"
Layers"
summary
:
"
Adds
a
new
layer
to
the
DB"
description
:
"
Adds
a
new
layer
to
the
DB"
summary
:
"
Delete
one
LayerAdapter
from
the
DB"
description
:
"
Delete
one
LayerAdapter
from
the
DB"
parameters
:
-
name
:
"
name"
in
:
"
path"
description
:
"
Name
of
the
new
layer
"
description
:
"
Name
of
the
layer
to
delete
"
required
:
true
type
:
"
string"
-
name
:
"
use_case"
...
...
@@ -253,8 +336,8 @@ paths:
responses
:
'
200'
:
description
:
"
Successful
Request"
'
40
0
'
:
description
:
"
Layer
already
exists
"
'
40
4
'
:
description
:
"
Layer
does
not
exist
"
/layers
:
post
:
operationId
:
"
routes.layer.add_complete"
...
...
src/participation-hub/business-logic-microservice/app/db/repository.py
View file @
36d573c1
...
...
@@ -52,6 +52,10 @@ class Repository(MongoRepositoryBase):
def
one_by_name_and_usecase
(
self
,
name
:
str
,
use_case
:
str
)
->
LayerAdapter
:
return
list
(
super
()
.
get_entries
(
self
.
_adapter_collection
,
selection
=
{
"name"
:
name
,
"use_case"
:
use_case
}))
def
update_use_case
(
self
,
adapter
:
LayerAdapter
,
use_case
:
str
):
collection
=
self
.
_database
[
self
.
_adapter_collection
]
collection
.
update_one
({
"name"
:
adapter
.
name
,
"use_case"
:
use_case
},
{
"$set"
:
adapter
.
to_serializable_dict
()})
def
update
(
self
,
adapter
:
LayerAdapter
):
collection
=
self
.
_database
[
self
.
_adapter_collection
]
collection
.
update_one
({
"name"
:
adapter
.
name
,
"use_case"
:
adapter
.
use_case
},
{
"$set"
:
adapter
.
to_serializable_dict
()})
...
...
@@ -65,7 +69,7 @@ class Repository(MongoRepositoryBase):
return
list
(
result
)
def
all_for_use_case
(
self
,
use_case
:
str
)
->
Dict
:
def
all_for_use_case
(
self
,
use_case
:
str
)
->
List
[
Dict
]
:
result
=
super
()
.
get_entries
(
self
.
_adapter_collection
,
projection
=
{
'_id'
:
False
},
selection
=
{
"use_case"
:
use_case
})
return
list
(
result
)
\ No newline at end of file
src/participation-hub/business-logic-microservice/app/routes/layer.py
View file @
36d573c1
...
...
@@ -71,6 +71,26 @@ def one(name: str, use_case: str):
return
Response
(
status
=
200
,
response
=
json
.
dumps
(
layer
.
to_serializable_dict
()))
def
add_mapping_for_all
(
use_case
:
str
):
'''
add a new mapping to each layer of the use-case
@params:
use_case - Required : String-identifier for the use-case
'''
data
=
request
.
json
if
"internal"
not
in
data
or
"external"
not
in
data
:
return
Response
(
status
=
400
,
response
=
f
"Field missing! Fields required: (internal, external)"
)
layers
=
LayerAdapterService
.
all_for_use_case
(
use_case
)
layers
=
[
LayerAdapter
.
from_serializable_dict
(
d
)
for
d
in
layers
]
for
layer
in
layers
:
layer
.
add_mapping
(
data
[
"internal"
],
data
[
"external"
])
LayerAdapterService
.
update
(
layer
)
return
Response
(
status
=
200
)
def
add_mapping
(
name
:
str
,
use_case
:
str
):
'''
...
...
@@ -95,6 +115,52 @@ def add_mapping(name: str, use_case: str):
return
Response
(
status
=
200
)
def
update_use_case_for_all
(
use_case
:
str
):
'''
update the use-case for each layer in the use-case
this changes the use-case of all layers, meaning the use-case used
for this request might not be usable after the request
@params:
use_case - Required : String-identifier for the use-case
'''
data
=
request
.
json
if
"use_case"
not
in
data
:
return
Response
(
status
=
400
,
response
=
f
"Field missing! Fields required: (use_case)"
)
layers
=
LayerAdapterService
.
all_for_use_case
(
use_case
)
layers
=
[
LayerAdapter
.
from_serializable_dict
(
d
)
for
d
in
layers
]
for
layer
in
layers
:
layer
.
use_case
=
data
[
"use_case"
]
LayerAdapterService
.
update_use_case
(
layer
,
use_case
)
return
Response
(
status
=
200
)
def
delete_mapping_for_all
(
use_case
:
str
):
'''
delete a mapping from each layer in the use-case
@params:
use_case - Required : String-identifier for the use-case
'''
data
=
request
.
json
if
"internal"
not
in
data
:
return
Response
(
status
=
400
,
response
=
f
"Field missing! Fields required: (internal)"
)
layers
=
LayerAdapterService
.
all_for_use_case
(
use_case
)
layers
=
[
LayerAdapter
.
from_serializable_dict
(
d
)
for
d
in
layers
]
for
layer
in
layers
:
try
:
layer
.
delete_mapping
(
data
[
"internal"
])
except
ValueError
:
continue
LayerAdapterService
.
update
(
layer
)
return
Response
(
status
=
200
)
def
delete_mapping
(
name
:
str
,
use_case
:
str
):
'''
...
...
src/participation-hub/business-logic-microservice/app/services/layer_adapter_service.py
View file @
36d573c1
...
...
@@ -16,6 +16,7 @@ class LayerAdapterService:
@
staticmethod
def
delete_all_use_cases
():
LayerAdapterService
.
_repository
.
delete_all_use_cases
()
LayerAdapterService
.
_repository
.
delete_all_layers
()
@
staticmethod
def
delete_use_case
(
name
:
str
):
...
...
@@ -47,6 +48,17 @@ class LayerAdapterService:
'''
LayerAdapterService
.
_repository
.
update
(
layer
)
@
staticmethod
def
update_use_case
(
layer
:
LayerAdapter
,
use_case
:
str
):
'''
Overwrite the stored instance with the given one which is
identified by the layer name
@params:
layer - Required : layer object holding the current data
'''
LayerAdapterService
.
_repository
.
update_use_case
(
layer
,
use_case
)
@
staticmethod
def
add
(
name
:
str
,
use_case
:
str
):
'''
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment