diff options
Diffstat (limited to 'src/semanticxo/indexstore.py')
-rw-r--r-- | src/semanticxo/indexstore.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/semanticxo/indexstore.py b/src/semanticxo/indexstore.py index 8947ed5..84e2be6 100644 --- a/src/semanticxo/indexstore.py +++ b/src/semanticxo/indexstore.py @@ -21,6 +21,7 @@ import httplib import urllib from semanticxo import layoutmanager +from semanticxo.sparql import SPARQL from semanticxo.layoutmanager import MAX_QUERY_LIMIT from semanticxo.metadatastore import OLPC_TERMS @@ -92,14 +93,11 @@ class Enquire(object): pass def get_set(self, offset, limit): + sparql = SPARQL() query = "SELECT ?uid WHERE {\n %s \n}" % "\n".join(self._graph_patterns) - params = {'query': query, 'format' : 'csv'} - headers = {'Content-Type': 'application/x-www-form-urlencoded'} - conn = httplib.HTTPConnection('127.0.0.1:8080') - conn.request("POST", "/sparql", urllib.urlencode(params), headers=headers) - response = conn.getresponse() - results = response.read().split('\n')[1:-1] - conn.close() + results = [] + for result in sparql.execute_select(query): + results.append(result['uid']) return results class IndexStore(object): @@ -179,24 +177,26 @@ class IndexStore(object): query_result = enquire.get_set(offset, limit) total_count = len(query_result) - + logging.debug('[IDX] query result %r' % query_result) + uids = [] for hit in query_result: - uids.append(hit.split(",")[1][1:-1]) + uids.append(hit) #.split(",")[1][1:-1] return (uids, total_count) def delete(self, uid): # TODO Needed ? - self._database.delete_document(_PREFIX_FULL_VALUE + _PREFIX_UID + uid) - self._flush() - + #self._database.delete_document(_PREFIX_FULL_VALUE + _PREFIX_UID + uid) + #self._flush() + pass + def get_activities(self): logging.debug('[IDX] get_activities') activities = [] - prefix = _PREFIX_FULL_VALUE + _PREFIX_ACTIVITY - for term in self._database.allterms(prefix): - activities.append(term.term[len(prefix):]) + #prefix = _PREFIX_FULL_VALUE + _PREFIX_ACTIVITY + #for term in self._database.allterms(prefix): + # activities.append(term.term[len(prefix):]) return activities def flush(self): |