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
Show 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:
...
@@ -133,6 +133,153 @@ paths:
description
:
"
Layer
does
not
exist"
description
:
"
Layer
does
not
exist"
'
400'
:
'
400'
:
description
:
"
Field
in
request
is
missing
or
attribute
does
not
exist
in
the
Layer"
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
:
/use-case/{use_case}/layers/{name}/mapping
:
delete
:
delete
:
security
:
security
:
...
...
src/participation-hub/business-logic-microservice/app/configs/swagger_local.yml
View file @
36d573c1
...
@@ -118,6 +118,89 @@ paths:
...
@@ -118,6 +118,89 @@ paths:
description
:
"
Layer
does
not
exist"
description
:
"
Layer
does
not
exist"
'
400'
:
'
400'
:
description
:
"
Field
in
request
is
missing
or
attribute
does
not
exist
in
the
Layer"
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
:
/use-case/{use_case}/layers/{name}/mapping
:
delete
:
delete
:
operationId
:
"
routes.layer.delete_mapping"
operationId
:
"
routes.layer.delete_mapping"
...
@@ -189,16 +272,16 @@ paths:
...
@@ -189,16 +272,16 @@ paths:
'
400'
:
'
400'
:
description
:
"
Field
in
request
is
missing"
description
:
"
Field
in
request
is
missing"
/use-case/{use_case}/layers/{name}
:
/use-case/{use_case}/layers/{name}
:
delete
:
get
:
operationId
:
"
routes.layer.
delete_
one"
operationId
:
"
routes.layer.one"
tags
:
tags
:
-
"
Layers"
-
"
Layers"
summary
:
"
Delet
e
one
LayerAdapter
from
the
DB"
summary
:
"
Retriev
e
one
LayerAdapter
from
the
DB"
description
:
"
Delet
e
one
LayerAdapter
from
the
DB"
description
:
"
Retriev
e
one
LayerAdapter
from
the
DB"
parameters
:
parameters
:
-
name
:
"
name"
-
name
:
"
name"
in
:
"
path"
in
:
"
path"
description
:
"
Name
of
the
layer
to
delete
"
description
:
"
Name
of
the
layer"
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
name
:
"
use_case"
-
name
:
"
use_case"
...
@@ -211,16 +294,16 @@ paths:
...
@@ -211,16 +294,16 @@ paths:
description
:
"
Successful
Request"
description
:
"
Successful
Request"
'
404'
:
'
404'
:
description
:
"
Layer
does
not
exist"
description
:
"
Layer
does
not
exist"
ge
t
:
pos
t
:
operationId
:
"
routes.layer.
one
"
operationId
:
"
routes.layer.
add
"
tags
:
tags
:
-
"
Layers"
-
"
Layers"
summary
:
"
Retrieve
one
LayerAdapter
from
the
DB"
summary
:
"
Adds
a
new
layer
to
the
DB"
description
:
"
Retrieve
one
LayerAdapter
from
the
DB"
description
:
"
Adds
a
new
layer
to
the
DB"
parameters
:
parameters
:
-
name
:
"
name"
-
name
:
"
name"
in
:
"
path"
in
:
"
path"
description
:
"
Name
of
the
layer"
description
:
"
Name
of
the
new
layer"
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
name
:
"
use_case"
-
name
:
"
use_case"
...
@@ -231,18 +314,18 @@ paths:
...
@@ -231,18 +314,18 @@ paths:
responses
:
responses
:
'
200'
:
'
200'
:
description
:
"
Successful
Request"
description
:
"
Successful
Request"
'
40
4
'
:
'
40
0
'
:
description
:
"
Layer
does
not
exist
"
description
:
"
Layer
already
exists
"
post
:
delete
:
operationId
:
"
routes.layer.
add
"
operationId
:
"
routes.layer.
delete_one
"
tags
:
tags
:
-
"
Layers"
-
"
Layers"
summary
:
"
Adds
a
new
layer
to
the
DB"
summary
:
"
Delete
one
LayerAdapter
from
the
DB"
description
:
"
Adds
a
new
layer
to
the
DB"
description
:
"
Delete
one
LayerAdapter
from
the
DB"
parameters
:
parameters
:
-
name
:
"
name"
-
name
:
"
name"
in
:
"
path"
in
:
"
path"
description
:
"
Name
of
the
new
layer
"
description
:
"
Name
of
the
layer
to
delete
"
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
name
:
"
use_case"
-
name
:
"
use_case"
...
@@ -253,8 +336,8 @@ paths:
...
@@ -253,8 +336,8 @@ paths:
responses
:
responses
:
'
200'
:
'
200'
:
description
:
"
Successful
Request"
description
:
"
Successful
Request"
'
40
0
'
:
'
40
4
'
:
description
:
"
Layer
already
exists
"
description
:
"
Layer
does
not
exist
"
/layers
:
/layers
:
post
:
post
:
operationId
:
"
routes.layer.add_complete"
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):
...
@@ -52,6 +52,10 @@ class Repository(MongoRepositoryBase):
def
one_by_name_and_usecase
(
self
,
name
:
str
,
use_case
:
str
)
->
LayerAdapter
:
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
}))
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
):
def
update
(
self
,
adapter
:
LayerAdapter
):
collection
=
self
.
_database
[
self
.
_adapter_collection
]
collection
=
self
.
_database
[
self
.
_adapter_collection
]
collection
.
update_one
({
"name"
:
adapter
.
name
,
"use_case"
:
adapter
.
use_case
},
{
"$set"
:
adapter
.
to_serializable_dict
()})
collection
.
update_one
({
"name"
:
adapter
.
name
,
"use_case"
:
adapter
.
use_case
},
{
"$set"
:
adapter
.
to_serializable_dict
()})
...
@@ -65,7 +69,7 @@ class Repository(MongoRepositoryBase):
...
@@ -65,7 +69,7 @@ class Repository(MongoRepositoryBase):
return
list
(
result
)
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
})
result
=
super
()
.
get_entries
(
self
.
_adapter_collection
,
projection
=
{
'_id'
:
False
},
selection
=
{
"use_case"
:
use_case
})
return
list
(
result
)
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):
...
@@ -71,6 +71,26 @@ def one(name: str, use_case: str):
return
Response
(
status
=
200
,
response
=
json
.
dumps
(
layer
.
to_serializable_dict
()))
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
):
def
add_mapping
(
name
:
str
,
use_case
:
str
):
'''
'''
...
@@ -95,6 +115,52 @@ def add_mapping(name: str, use_case: str):
...
@@ -95,6 +115,52 @@ def add_mapping(name: str, use_case: str):
return
Response
(
status
=
200
)
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
):
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:
...
@@ -16,6 +16,7 @@ class LayerAdapterService:
@
staticmethod
@
staticmethod
def
delete_all_use_cases
():
def
delete_all_use_cases
():
LayerAdapterService
.
_repository
.
delete_all_use_cases
()
LayerAdapterService
.
_repository
.
delete_all_use_cases
()
LayerAdapterService
.
_repository
.
delete_all_layers
()
@
staticmethod
@
staticmethod
def
delete_use_case
(
name
:
str
):
def
delete_use_case
(
name
:
str
):
...
@@ -47,6 +48,17 @@ class LayerAdapterService:
...
@@ -47,6 +48,17 @@ class LayerAdapterService:
'''
'''
LayerAdapterService
.
_repository
.
update
(
layer
)
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
@
staticmethod
def
add
(
name
:
str
,
use_case
:
str
):
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