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
Show 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:
...
@@ -509,6 +509,8 @@ paths:
security
:
security
:
-
JwtRegular
:
[]
-
JwtRegular
:
[]
operationId
:
"
routes.enum.put_new"
operationId
:
"
routes.enum.put_new"
tags
:
-
"
Enums"
summary
:
"
Updates
an
existing
Enum
with
a
new
value."
summary
:
"
Updates
an
existing
Enum
with
a
new
value."
description
:
"
Updates
an
existing
Enum
with
a
new
value."
description
:
"
Updates
an
existing
Enum
with
a
new
value."
parameters
:
parameters
:
...
@@ -527,11 +529,11 @@ paths:
...
@@ -527,11 +529,11 @@ paths:
description
:
"
Name
of
the
Enum"
description
:
"
Name
of
the
Enum"
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
in
:
query
-
name
:
value
name
:
value
in
:
query
schema
:
type
:
string
description
:
Value of the Enum.
description
:
Value of the Enum.
required
:
true
type
:
string
responses
:
responses
:
'
200'
:
'
200'
:
description
:
"
Successful
Request"
description
:
"
Successful
Request"
...
...
src/participation-hub/business-logic-microservice/app/db/enum_repository.py
View file @
b38aa85f
...
@@ -34,14 +34,11 @@ class EnumRepository(MongoRepositoryBase):
...
@@ -34,14 +34,11 @@ class EnumRepository(MongoRepositoryBase):
return
[
Enum
.
from_serializable_dict
(
row
)
for
row
in
list
(
result
)]
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
=
{
result
=
list
(
super
()
.
get_entries
(
self
.
_enum_collection
,
selection
=
{
"name"
:
name
,
"use_case"
:
use_case
,
"table"
:
table
}))
"name"
:
name
,
"use_case"
:
use_case
,
"table"
:
table
}))
if
len
(
result
)
==
1
:
return
[
Enum
.
from_serializable_dict
(
row
)
for
row
in
result
]
return
Enum
.
from_serializable_dict
(
result
[
0
])
return
None
def
delete_all
(
self
):
def
delete_all
(
self
):
collection
=
self
.
_database
[
self
.
_enum_collection
]
collection
=
self
.
_database
[
self
.
_enum_collection
]
...
...
src/participation-hub/business-logic-microservice/app/main.py
View file @
b38aa85f
...
@@ -13,9 +13,11 @@ import connexion
...
@@ -13,9 +13,11 @@ import connexion
from
security
import
swagger_util
from
security
import
swagger_util
from
env_info
import
is_running_locally
,
get_resources_path
from
env_info
import
is_running_locally
,
get_resources_path
from
flask
import
request
from
flask
import
request
from
flask_cors
import
CORS
from
flask
import
redirect
from
flask
import
redirect
app
=
connexion
.
App
(
__name__
,
specification_dir
=
'configs/'
)
app
=
connexion
.
App
(
__name__
,
specification_dir
=
'configs/'
)
CORS
(
app
.
app
)
from
db.entities.layer_adapter
import
LayerAdapter
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
...
@@ -11,6 +11,7 @@ connexion==2.7.0
coverage==5.3.1
coverage==5.3.1
cryptography==3.1
cryptography==3.1
Flask==1.1.2
Flask==1.1.2
Flask-Cors==3.0.10
idna==2.10
idna==2.10
importlib-metadata==1.7.0
importlib-metadata==1.7.0
inflection==0.5.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):
...
@@ -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
table - Required : unique identifier of the Table the Enum belongs to
name - Required : unique identifier for the Enum
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
:
found
=
False
return
Response
(
status
=
404
,
response
=
f
"Enum with name '{name}' does not exist!"
)
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
(
enum_target
.
to_serializable_dict
()))
return
Response
(
status
=
200
,
response
=
json
.
dumps
(
existing_enum
.
to_serializable_dict
()))
\ No newline at end of file
\ 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