Skip to content
Snippets Groups Projects
Commit cfc4a343 authored by Cornelia Michlits's avatar Cornelia Michlits
Browse files

104 - change returning message of endpoints

Former-commit-id: 38016203
parent 78519186
No related branches found
No related tags found
1 merge request!42Fixed the query service tests
...@@ -61,7 +61,7 @@ def valitate(): ...@@ -61,7 +61,7 @@ def valitate():
res = {"success": False, "message": str(e)} res = {"success": False, "message": str(e)}
return jsonify(res) return jsonify(res)
@app.route('/api/units/geturi', methods=["POST"], endpoint='geturi') @app.route('/api/units/uri', methods=["GET"], endpoint='uri')
@swag_from('geturi.yml') @swag_from('geturi.yml')
def geturi(): def geturi():
input_json = request.get_json() input_json = request.get_json()
...@@ -81,8 +81,10 @@ def saveconcept(): ...@@ -81,8 +81,10 @@ def saveconcept():
try: try:
uri = str(input_json['uri']) uri = str(input_json['uri'])
c_name = str(input_json['name']) c_name = str(input_json['name'])
res = insert_mdb_concepts(uri, c_name) if insert_mdb_concepts(uri, c_name) > 0:
return jsonify(res), 200 return jsonify({'uri': uri}), 201
else:
return jsonify({'status': 'error'}), 400
except Exception as e: except Exception as e:
print(e) print(e)
res = {"success": False, "message": str(e)} res = {"success": False, "message": str(e)}
...@@ -97,8 +99,10 @@ def saveconcept(): ...@@ -97,8 +99,10 @@ def saveconcept():
cid = int(input_json['cid']) cid = int(input_json['cid'])
tid = int(input_json['tid']) tid = int(input_json['tid'])
cdbid = int(input_json['cdbid']) cdbid = int(input_json['cdbid'])
res = insert_mdb_columns_concepts(cdbid, tid, cid, uri) if insert_mdb_columns_concepts(cdbid, tid, cid, uri)>0:
return jsonify(res), 200 return jsonify({'uri': uri}), 201
else:
return jsonify({'status': 'error'}), 400
except Exception as e: except Exception as e:
print(e) print(e)
res = {"success": False, "message": str(e)} res = {"success": False, "message": str(e)}
......
...@@ -16,12 +16,12 @@ def insert_mdb_concepts(uri, c_name): ...@@ -16,12 +16,12 @@ def insert_mdb_concepts(uri, c_name):
# Insert tblnames into table mdb_TABLES # Insert tblnames into table mdb_TABLES
cursor.execute("INSERT INTO mdb_concepts (URI,name,created) VALUES (%s,%s,current_timestamp) ON CONFLICT (URI) DO NOTHING", (uri,c_name)) cursor.execute("INSERT INTO mdb_concepts (URI,name,created) VALUES (%s,%s,current_timestamp) ON CONFLICT (URI) DO NOTHING", (uri,c_name))
r = cursor.statusmessage r = cursor.rowcount
conn.commit() conn.commit()
conn.close() conn.close()
except Exception as e: except Exception as e:
print("Error while connecting to metadatabase.",e) print("Error while connecting to metadatabase.",e)
return json.dumps(r) return r
def insert_mdb_columns_concepts(cdbid,tid, cid, uri): def insert_mdb_columns_concepts(cdbid,tid, cid, uri):
try: try:
...@@ -37,9 +37,9 @@ def insert_mdb_columns_concepts(cdbid,tid, cid, uri): ...@@ -37,9 +37,9 @@ def insert_mdb_columns_concepts(cdbid,tid, cid, uri):
# Insert tblnames into table mdb_TABLES # Insert tblnames into table mdb_TABLES
cursor.execute("INSERT INTO mdb_columns_concepts (cDBID,tID, cID,URI,created) VALUES (%s,%s,%s,%s,current_timestamp) ON CONFLICT (cDBID, tID, cID, URI) DO NOTHING", (cdbid,tid,cid,uri)) cursor.execute("INSERT INTO mdb_columns_concepts (cDBID,tID, cID,URI,created) VALUES (%s,%s,%s,%s,current_timestamp) ON CONFLICT (cDBID, tID, cID, URI) DO NOTHING", (cdbid,tid,cid,uri))
r = cursor.statusmessage r = cursor.rowcount
conn.commit() conn.commit()
conn.close() conn.close()
except Exception as e: except Exception as e:
print("Error while connecting to metadatabase.",e) print("Error while connecting to metadatabase.",e)
return json.dumps(r) return r
\ No newline at end of file \ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment