def get_all_node_properties(uid): node = get_node_by_uid(uid) property_array = node.get_all_properties_from_entity() if node is not None: return make_response(jsonify(property_array), 201) else: return make_response(jsonify(message="Node doesn't exists"), 404)
def default_template(uid): node = get_node_by_uid(uid) if node is not None: return make_response(jsonify(node.generate_template()["template"]), 201) else: return make_response(jsonify(message="Node doesn't exists"), 404)
def get_record(uid): # template = { # "E52_Time_Span": { # "has_value": "DataObject"} # } # template = { # "E52_Time_Span": { # "P86_falls_within": "E52_Time_Span"} # } # record = get_record_from_collection(uid, "data") # if record is not None: # return make_response(jsonify(json.loads(record["data"])), 201) # else: # template = json.loads(template_str) template = request.json node = get_node_by_uid(uid) if node is not None: data = build_next_json(node, template) # print(data) # add_record_to_collection(uid, data, "data") get_all_records_from_collection("data") if data is not None: return make_response(jsonify(data), 201) else: return make_response(jsonify(message="Some error occurred"), 404) else: return make_response(jsonify(message="Node doesn't exists"), 404)
def response_get_node(uid): node = get_node_by_uid(uid) if node is not None: return Response(node.encodeJSON(), mimetype="application/json", status=201) else: return make_response(jsonify(message="Node doesn't exists"), 404)
def create_base_schema_node_with_template(uid): node = get_node_by_uid(uid) template = {"E52_Time_Span": {}} if node is not None: result = node.get_schema_with_template(template) return make_response(jsonify(result), 201) else: return make_response(jsonify(message="Node doesn't exists"), 404)
def response_create_node_with_template(uid): node = get_node_by_uid(uid) template = {"E52_Time_Span": {}} if node is not None: result = build_next_json(node, template) if result is not None: print("ONE") print(result) return make_response(jsonify(result), 201) else: return make_response(jsonify(message="Some error occurred"), 404) else: return make_response(jsonify(message="Node doesn't exists"), 404)
def response_update(uid): node = get_node_by_uid(uid) if node is not None: data = request.json merged = updated_node(node, data["data"], data["template"]) if merged: # update_data_in_mongo(uid, node.encodeJSON()) # get_all_records_from_collection("data") new_data = build_next_json(node, data["template"]) return make_response(jsonify(new_data), 201) else: return make_response(jsonify(message="Unsaved node"), 404) else: return make_response(jsonify(message="Node doesn't exists"), 404)
def response_uidglab_view(uid): node = get_node_by_uid(uid) if node.__class__.__name__ is not "E24_Physical_Human_Made_ThingSchema" or node.__class__.__name__ is not "E18_Physical_ThingSchema": if node is not None: response = build_information_uidglab(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) else: return make_response(jsonify(message="Node is not a valid type"), 404)
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") classes_name = node.get_superclasses_name() templates = get_templates_from_mongo_by_classes_name(classes_name) if templates is None: return make_response( jsonify(message="Don't have templates for this entity"), 200) else: test = jsonify(templates) return make_response(test, 201) else: return make_response(jsonify(message="Node doesn't exists"), 404)
def response_uidglab_edit(uid): node = get_node_by_uid(uid) if node.__class__.__name__ is not "E24_Physical_Human_Made_ThingSchema" or node.__class__.__name__ is not "E18_Physical_ThingSchema": if node is not None: data = request.json identifiers = data.get("identifier", None) titles = data.get("title", None) if dglab_node_update(node, identifiers, titles): response = build_information_uidglab(node) if response: return make_response(jsonify(response), 201) else: return make_response( jsonify(message="Node doesn't have information"), 404) else: return make_response(jsonify(message="Unsaved node"), 404) else: return make_response(jsonify(message="Node doesn't exists"), 404) else: return make_response(jsonify(message="Node is not a valid type"), 404)
def get_schema(uid): node = get_node_by_uid(uid) # template = { # "E52_Time_Span": { # "has_value": "DataObject"} # } # template = { # "E52_Time_Span": { # "P86_falls_within": "E52_Time_Span"} # } template = request.json print(template) if node is not None: result = get_schema_from_mongo(template) if result is not None: return make_response(jsonify(json.loads(result)), 201) else: make_response(jsonify(message="Template doesn't exists"), 404) else: return make_response(jsonify(message="Node doesn't exists"), 404)
def insert_template_in_mongodb(uid): node = get_node_by_uid(uid) template = request.json # template = { # "E52_Time_Span": { # "P86_falls_within": "E52_Time_Span"} # } # template = { # "E52_Time_Span": { # "has_value": "DataObject", # } # } if node is not None: schema_of_node = node.get_schema_with_template(template) classes_name = node.get_superclasses_name() message = insert_template_in_mongo(classes_name, schema_of_node, template) print("Received Message") print(message) get_all_records_from_collection("createdTemplate") return make_response(jsonify(message=message), 200) else: return make_response(jsonify(message="Node doesn't exists"), 404)
def response_get_schema_node(uid): node = get_node_by_uid(uid) if node is not None: return make_response(jsonify(node.getSchema()), 201) else: return make_response(jsonify(message="Node doesn't exists"), 404)