Skip to content

Commit

Permalink
routes to eva's interface
Browse files Browse the repository at this point in the history
  • Loading branch information
lazarocosta committed Jun 15, 2020
1 parent 3e56481 commit 1a14f19
Show file tree
Hide file tree
Showing 4 changed files with 485 additions and 419 deletions.
60 changes: 30 additions & 30 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,35 @@ services:
networks:
- archgraph-docker-deployment
restart: on-failure
archgraph:
container_name: archgraph
image: feupinfolab/archgraph:latest
build:
dockerfile: Dockerfile
args:
SOURCE_BRANCH: "master"
context: .
environment:
- "NEO4J_HOST=archgraph-neo4j"
- "NEO4J_PORT=7687"
- "MONGODB_HOST=archgraph-mongodb"
- "MONGODB_PORT=27017"
- "MONGODB_USERNAME=root"
- "MONGODB_PASSWORD=rootpassword"
- "CUSTOM_HOST_FOR_SERVER_BIND=0.0.0.0"
- "RUN_IN_PRODUCTION=1"
- "INIT_GRAPH=1"
- "FORCE_RELOAD_GRAPH=0"
ports:
- published: 4200
target: 4200
- published: 5000
target: 5000
depends_on:
- mongodb
- neo4j
networks:
- archgraph-docker-deployment
restart: on-failure
# archgraph:
# container_name: archgraph
# image: feupinfolab/archgraph:latest
# build:
# dockerfile: Dockerfile
# args:
# SOURCE_BRANCH: "master"
# context: .
# environment:
# - "NEO4J_HOST=archgraph-neo4j"
# - "NEO4J_PORT=7687"
# - "MONGODB_HOST=archgraph-mongodb"
# - "MONGODB_PORT=27017"
# - "MONGODB_USERNAME=root"
# - "MONGODB_PASSWORD=rootpassword"
# - "CUSTOM_HOST_FOR_SERVER_BIND=0.0.0.0"
# - "RUN_IN_PRODUCTION=1"
# - "INIT_GRAPH=1"
# - "FORCE_RELOAD_GRAPH=0"
# ports:
# - published: 4200
# target: 4200
# - published: 5000
# target: 5000
# depends_on:
# - mongodb
# - neo4j
# networks:
# - archgraph-docker-deployment
# restart: on-failure
networks:
archgraph-docker-deployment: {}
20 changes: 18 additions & 2 deletions src/Routes/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_project_root():
from neomodel import config

from src.Utils.JsonEncoder import search_cidoc, search_specific_cidoc
from src.Utils.Utils import get_node_by_uid, build_next_json, updated_node, make_result
from src.Utils.Utils import get_node_by_uid, build_next_json, updated_node, make_result, build_information_eva

import src.Utils.EnvVarManager as EnvVarManager

Expand Down Expand Up @@ -170,7 +170,7 @@ def response_create_node_with_template(uid):
node = get_node_by_uid(uid)
template = {"E52_Time_Span": {}}
if node is not None:
result = nested_json(node, template)
result = build_next_json(node, template)
if result is not None:
print("ONE")
print(result)
Expand Down Expand Up @@ -239,6 +239,7 @@ def get_schema(uid):
@app.route("/templatesfromentity/<uid>", methods=["GET"])
@cross_origin()
def get_templates_from_entity(uid):
print("lindo")
node = get_node_by_uid(uid)
if node is not None:
get_all_records_from_collection("createdTemplate")
Expand All @@ -255,6 +256,21 @@ def get_templates_from_entity(uid):
return make_response(jsonify(message="Node doesn't exists"), 404)


@app.route("/eva/<uid>", methods=["GET"])
@cross_origin()
def response_eva_view(uid):
node = get_node_by_uid(uid)
print("lindo")
if node is not None:
response = build_information_eva(node)
if response:
return make_response(jsonify(response), 201)
else:
make_response(jsonify(message="Node doesn't have information"), 404)
else:
return make_response(jsonify(message="Node doesn't exists"), 404)


# update node
@app.route("/<uid>", methods=["POST"])
@cross_origin()
Expand Down
25 changes: 25 additions & 0 deletions src/Utils/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,3 +582,28 @@ def find_name_of_schema_classes_in_project(classes_name):
return None
else:
return schemas_classes


def build_information_eva(node):
title = node.P102_has_title.all()[0]
registo =title.has_value.all()[0]
identifier = node.P1_is_identified_by.all()[0]
identifier_value = identifier.has_value.all()[0]
# todo
#identifier_type = node.P2_has_type.all()[0]
#codigo = identifier_type.has_value.all()[0]

result = {
"title": {
"value": registo.stringValue,
"type": "Formal"
},
"identifier": {
"value": identifier_value.stringValue,
"type": "codigo.stringValue"

}
}

return result

Loading

0 comments on commit 1a14f19

Please sign in to comment.