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
0d338b8d
Commit
0d338b8d
authored
Dec 11, 2019
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/nodeinfo-messages' into develop
parents
48c4791d
b96d0f24
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
9 deletions
+32
-9
.gitignore
.gitignore
+1
-0
MongoRepositoryBase.py
modules/database/MongoRepositoryBase.py
+8
-7
MongoRepository.py
...ce-retrieval-microservice/app/database/MongoRepository.py
+21
-0
main.py
transaction-hub-in/trace-retrieval-microservice/app/main.py
+1
-1
blockchain_trace.py
...trace-retrieval-microservice/app/rest/blockchain_trace.py
+1
-1
No files found.
.gitignore
View file @
0d338b8d
...
...
@@ -2,3 +2,4 @@
**/.vscode
**/.idea
*.log
**/env
\ No newline at end of file
transaction-hub-in/trace-retrieval-microservice/app/db/MongoRepository
.py
→
modules/database/MongoRepositoryBase
.py
View file @
0d338b8d
import
pymongo
import
network_constants
as
netconst
class
MongoRepository
:
class
MongoRepositoryBase
:
'''Base class to connect to, insert and read from a single MongoDB collection'''
# TODO extract to docker env var
_username
=
'root'
_password
=
'root'
...
...
@@ -9,18 +10,18 @@ class MongoRepository:
_collection
:
pymongo
.
collection
.
Collection
=
None
_mongo_client
:
pymongo
.
MongoClient
=
None
def
__init__
(
self
,
username
=
_username
,
password
=
_password
):
def
__init__
(
self
,
database_name
,
collection_name
,
username
=
_username
,
password
=
_password
):
self
.
_mongo_client
=
pymongo
.
MongoClient
(
f
"mongodb://{username}:{password}@{netconst.MONGO_DB_HOSTNAME}:{netconst.MONGO_DB_PORT}/"
)
database
=
self
.
_mongo_client
[
'traceRetrievalDB'
]
self
.
_collection
=
database
[
'traces'
]
database
=
self
.
_mongo_client
[
database_name
]
self
.
_collection
=
database
[
collection_name
]
def
insert_
trace
(
self
,
content
:
dict
):
def
insert_
entry
(
self
,
content
:
dict
):
self
.
_collection
.
insert_one
(
content
)
def
get_
trac
es
(
self
,
selection
:
dict
=
{},
projection
:
dict
=
{
'_'
:
0
})
->
pymongo
.
cursor
.
Cursor
:
def
get_
entri
es
(
self
,
selection
:
dict
=
{},
projection
:
dict
=
{
'_'
:
0
})
->
pymongo
.
cursor
.
Cursor
:
return
self
.
_collection
.
find
(
selection
,
projection
)
def
close_connection
(
self
):
self
.
_mongo_client
.
close
()
self
.
_collection
=
None
self
.
_mongo_client
=
None
self
.
_collection
=
None
transaction-hub-in/trace-retrieval-microservice/app/database/MongoRepository.py
0 → 100644
View file @
0d338b8d
import
pymongo
import
network_constants
as
netconst
from
database.MongoRepositoryBase
import
MongoRepositoryBase
class
MongoRepository
(
MongoRepositoryBase
):
# TODO extract to docker env var
_username
=
'root'
_password
=
'root'
_collection
:
pymongo
.
collection
.
Collection
=
None
_mongo_client
:
pymongo
.
MongoClient
=
None
def
__init__
(
self
,
username
=
_username
,
password
=
_password
):
super
()
.
__init__
(
'traceRetrievalDB'
,
'traces'
)
def
insert_trace
(
self
,
content
:
dict
):
super
()
.
insert_entry
(
content
)
def
get_traces
(
self
,
selection
:
dict
=
{},
projection
:
dict
=
{
'_'
:
0
})
->
pymongo
.
cursor
.
Cursor
:
return
super
()
.
get_entries
(
selection
,
projection
)
transaction-hub-in/trace-retrieval-microservice/app/main.py
View file @
0d338b8d
...
...
@@ -14,7 +14,7 @@ LOGGER = logging.getLogger(__name__)
#############################
import
connexion
from
d
b
.MongoRepository
import
MongoRepository
from
d
atabase
.MongoRepository
import
MongoRepository
from
messaging.MessageHandler
import
MessageHandler
from
messaging.ReconnectingMessageManager
import
ReconnectingMessageManager
...
...
transaction-hub-in/trace-retrieval-microservice/app/rest/blockchain_trace.py
View file @
0d338b8d
from
flask
import
request
,
Response
from
d
b
.MongoRepository
import
MongoRepository
from
d
atabase
.MongoRepository
import
MongoRepository
mongo_repo
=
MongoRepository
()
...
...
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