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
b38aa85f
Commit
b38aa85f
authored
Mar 31, 2021
by
Manuel Herold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[businessLogic] finished enum-support
parent
6796bbfc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
14 deletions
+23
-14
routes.yml
...on-hub/business-logic-microservice/app/configs/routes.yml
+6
-4
enum_repository.py
...hub/business-logic-microservice/app/db/enum_repository.py
+2
-5
main.py
...participation-hub/business-logic-microservice/app/main.py
+2
-0
requirements.txt
...tion-hub/business-logic-microservice/app/requirements.txt
+1
-0
enum.py
...pation-hub/business-logic-microservice/app/routes/enum.py
+12
-5
No files found.
src/participation-hub/business-logic-microservice/app/configs/routes.yml
View file @
b38aa85f
...
...
@@ -509,6 +509,8 @@ paths:
security
:
-
JwtRegular
:
[]
operationId
:
"
routes.enum.put_new"
tags
:
-
"
Enums"
summary
:
"
Updates
an
existing
Enum
with
a
new
value."
description
:
"
Updates
an
existing
Enum
with
a
new
value."
parameters
:
...
...
@@ -527,11 +529,11 @@ paths:
description
:
"
Name
of
the
Enum"
required
:
true
type
:
"
string"
-
in
:
query
name
:
value
schema
:
type
:
string
-
name
:
value
in
:
query
description
:
Value of the Enum.
required
:
true
type
:
string
responses
:
'
200'
:
description
:
"
Successful
Request"
...
...
src/participation-hub/business-logic-microservice/app/db/enum_repository.py
View file @
b38aa85f
...
...
@@ -34,14 +34,11 @@ class EnumRepository(MongoRepositoryBase):
return
[
Enum
.
from_serializable_dict
(
row
)
for
row
in
list
(
result
)]
def
one
(
self
,
name
:
str
,
use_case
:
str
,
table
:
str
)
->
Enum
:
def
all_instances
(
self
,
name
:
str
,
use_case
:
str
,
table
:
str
)
->
Enum
:
result
=
list
(
super
()
.
get_entries
(
self
.
_enum_collection
,
selection
=
{
"name"
:
name
,
"use_case"
:
use_case
,
"table"
:
table
}))
if
len
(
result
)
==
1
:
return
Enum
.
from_serializable_dict
(
result
[
0
])
return
None
return
[
Enum
.
from_serializable_dict
(
row
)
for
row
in
result
]
def
delete_all
(
self
):
collection
=
self
.
_database
[
self
.
_enum_collection
]
...
...
src/participation-hub/business-logic-microservice/app/main.py
View file @
b38aa85f
...
...
@@ -13,9 +13,11 @@ import connexion
from
security
import
swagger_util
from
env_info
import
is_running_locally
,
get_resources_path
from
flask
import
request
from
flask_cors
import
CORS
from
flask
import
redirect
app
=
connexion
.
App
(
__name__
,
specification_dir
=
'configs/'
)
CORS
(
app
.
app
)
from
db.entities.layer_adapter
import
LayerAdapter
...
...
src/participation-hub/business-logic-microservice/app/requirements.txt
View file @
b38aa85f
...
...
@@ -11,6 +11,7 @@ connexion==2.7.0
coverage==5.3.1
cryptography==3.1
Flask==1.1.2
Flask-Cors==3.0.10
idna==2.10
importlib-metadata==1.7.0
inflection==0.5.0
...
...
src/participation-hub/business-logic-microservice/app/routes/enum.py
View file @
b38aa85f
...
...
@@ -48,10 +48,17 @@ def put_new(use_case: str, table: str, name: str, value: str):
table - Required : unique identifier of the Table the Enum belongs to
name - Required : unique identifier for the Enum
'''
existing_enum
=
enum_repository
.
one
(
name
,
use_case
,
table
)
existing_enums
=
enum_repository
.
all_instances
(
name
,
use_case
,
table
)
enum_target
=
None
if
existing_enum
==
None
:
return
Response
(
status
=
404
,
response
=
f
"Enum with name '{name}' does not exist!"
)
found
=
False
for
enum
in
existing_enums
:
if
enum
.
value
==
value
:
enum_target
=
enum
break
if
enum_target
==
None
:
enum_target
=
Enum
(
use_case
,
table
,
name
,
value
,
len
(
existing_enums
))
enum_repository
.
add
(
enum_target
)
# todo
return
Response
(
status
=
200
,
response
=
json
.
dumps
(
existing_enum
.
to_serializable_dict
()))
\ No newline at end of file
return
Response
(
status
=
200
,
response
=
json
.
dumps
(
enum_target
.
to_serializable_dict
()))
\ No newline at end of file
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