def getTermId(term): query = """SELECT id FROM tb_conceito WHERE termo='""" + str( term) + """'""" termId = aux_actions_db.consulta_BD(query) if len(termId) < 1: termId = addConcept(term, query) return termId
def conceitoDocs(conceitoId): keys = ["conceitoId", "docId", "nome", "contexto", "arquivo"] response = [] query = "SELECT cd.id_conceito, d.id, d.nome, d.contexto, d.arquivo FROM tb_documento d, tb_conceito_documento cd WHERE (cd.id_documento=d.id AND cd.id_conceito=\'"+str(conceitoId)+"\')" results = aux_actions_db.consulta_BD(query) for value in results: response.append(dictionary(keys, value)) return response
def description(conceitoId): keys = ["conceitoId", "termo", "description"] response = [] query = "SELECT id, termo, descricao FROM tb_conceito WHERE id=\'"+str(conceitoId)+"\'" results = aux_actions_db.consulta_BD(query) for value in results: response.append(dictionary(keys, value)) return response
def contextos(termo): keys = ["conceitoId", "termo", "contexto"] response = [] query = "SELECT id, termo, contexto FROM tb_conceito WHERE termo=\'"+str(termo)+"\'" results = aux_actions_db.consulta_BD(query) for value in results: response.append(dictionary(keys, value)) return response
def isInDB(term, desc, ctxt): query = """SELECT id FROM tb_conceito WHERE termo='""" + str( term) + """' AND descricao='""" + str( desc) + """' AND contexto='""" + str(ctxt) + """'""" conceptId = aux_actions_db.consulta_BD(query) if len(conceptId) < 1: return False else: return True
def documents(docId): keys = ["docId", "nome", "contexto", "arquivo"] query = "" response = [] if docId == None: query = "SELECT id, nome, contexto, arquivo FROM tb_documento" else: query = "SELECT id, nome, contexto, arquivo FROM tb_documento WHERE id=\'"+str(docId)+"\'" results = aux_actions_db.consulta_BD(query) for value in results: response.append(dictionary(keys, value)) return response
def conceitosRel(conceitoId): keys = ["idPrincipal", "relacao", "idSecundario"] query = "" response = [] if conceitoId == None: query = "SELECT id_conceito_principal, relacao, id_conceito_secundario FROM tb_relacao_semantica" else: query = "SELECT id_conceito_principal, relacao, id_conceito_secundario FROM tb_relacao_semantica WHERE id_conceito_principal=\'"+str(conceitoId)+"\'" results = aux_actions_db.consulta_BD(query) for value in results: response.append(dictionary(keys, value)) return response
def conceitosInfo(conceitoId): keys = ["conceitoId", "termo", "descricao", "contexto"] query = "" response = [] if conceitoId == None: query = "SELECT id, termo, descricao, contexto FROM tb_conceito" else: query = "SELECT id, termo, descricao, contexto FROM tb_conceito WHERE id=\'"+str(conceitoId)+"\'" results = aux_actions_db.consulta_BD(query) for value in results: response.append(dictionary(keys, value)) return response
def getDocumentId(document): query = """SELECT id FROM tb_documento WHERE nome='""" + str( document) + """';""" termId = aux_actions_db.consulta_BD(query) return termId
def addConcept(term, query): query_add = """INSERT INTO tb_conceito (termo,contexto) VALUES ('""" + term + """','thing');""" aux_actions_db.update_BD(query_add) termId = aux_actions_db.consulta_BD(query) insertConceptDoc(termId[0][0]) return termId
def get_users(self): query = 'SELECT * FROM tb_user' rows = aux_actions_db.consulta_BD(query) return rows