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
0652b32f
Commit
0652b32f
authored
Aug 20, 2019
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trace Retrieval: new traces: inform semantic-linking; expose rest get
parent
07074316
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
4 deletions
+34
-4
swagger.yml
...b-in/trace-retrieval-microservice/app/configs/swagger.yml
+13
-1
MongoRepository.py
...in/trace-retrieval-microservice/app/db/MongoRepository.py
+2
-2
MessageHandler.py
...ce-retrieval-microservice/app/messaging/MessageHandler.py
+12
-0
blockchain_trace.py
...trace-retrieval-microservice/app/rest/blockchain_trace.py
+7
-1
No files found.
transaction-hub-in/trace-retrieval-microservice/app/configs/swagger.yml
View file @
0652b32f
...
...
@@ -32,7 +32,7 @@ paths:
/trace
:
post
:
operationId
:
"
rest.blockchain_trace.
receive
"
operationId
:
"
rest.blockchain_trace.
post
"
tags
:
-
"
Blockchain
Trace"
summary
:
"
Add
a
new
blockchain
trace
to
SMART"
...
...
@@ -49,6 +49,18 @@ paths:
description
:
"
Successful
operation"
400
:
description
:
"
Invalid
input"
get
:
operationId
:
"
rest.blockchain_trace.get"
tags
:
-
"
Blockchain
Trace"
summary
:
"
Get
blockchain
traces"
description
:
"
Returns
all
blockchain
traces
in
the
database"
parameters
:
[]
responses
:
200
:
description
:
"
Successful
operation"
schema
:
$ref
:
"
#/definitions/BlockchainTrace"
definitions
:
BlockchainTrace
:
...
...
transaction-hub-in/trace-retrieval-microservice/app/db/MongoRepository.py
View file @
0652b32f
...
...
@@ -17,8 +17,8 @@ class MongoRepository:
def
insert_trace
(
self
,
content
:
dict
):
self
.
_collection
.
insert_one
(
content
)
def
get_traces
(
self
,
selection
:
dict
=
{}
)
:
return
self
.
_collection
.
find
(
selection
)
def
get_traces
(
self
,
selection
:
dict
=
{}
,
projection
:
dict
=
{
'_'
:
0
})
->
pymongo
.
cursor
.
Cursor
:
return
self
.
_collection
.
find
(
selection
,
projection
)
def
close_connection
(
self
):
self
.
_mongo_client
.
close
()
...
...
transaction-hub-in/trace-retrieval-microservice/app/messaging/MessageHandler.py
View file @
0652b32f
from
db.MongoRepository
import
MongoRepository
from
messaging.MessageSender
import
MessageSender
import
json
import
logging
...
...
@@ -6,9 +7,16 @@ LOGGER = logging.getLogger(__name__)
class
MessageHandler
:
_mongo_repo
=
None
_message_sender
=
None
def
__init__
(
self
):
self
.
_mongo_repo
=
MongoRepository
()
self
.
_init_message_sender
()
def
_init_message_sender
(
self
):
self
.
_message_sender
=
MessageSender
()
self
.
_message_sender
.
connect
()
self
.
_message_sender
.
create_exchange
(
'inhub'
,
'direct'
)
def
handle_generic
(
self
,
body
):
LOGGER
.
info
(
f
"Received message: {body}"
)
...
...
@@ -31,3 +39,7 @@ class MessageHandler:
def
handle_blockchain_transaction
(
self
,
transaction
):
self
.
_mongo_repo
.
insert_trace
(
transaction
)
# inform semantic linking microservice
msg
=
{
'type'
:
'new-traces-available'
}
self
.
_message_sender
.
send
(
'datahub'
,
json
.
dumps
(
msg
),
'semantic-linking'
)
transaction-hub-in/trace-retrieval-microservice/app/rest/blockchain_trace.py
View file @
0652b32f
from
flask
import
request
,
Response
from
db.MongoRepository
import
MongoRepository
def
receive
():
mongo_repo
=
MongoRepository
()
def
post
():
return
Response
(
status
=
501
)
def
get
():
return
list
(
mongo_repo
.
get_traces
(
projection
=
{
'_id'
:
0
}))
\ 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