Beispiel #1
0
void handleMagicAnswers(const std::string& answer)
{
  if(answer == Linda::Messages::TIMEOUT_MESSAGE)
    throw QueryTimeoutException();
  else if(answer == Linda::Messages::INVALID_MESSAGE)
    throw InvalidQueryException();
}
Beispiel #2
0
Operation::Type checkQueryType(const std::string& query)
{
  try
  {
    Parser parser;
    Operation* op = parser.parse(query.c_str());
    Operation::Type type = op->type;
    delete op;
    return type;
  }
  catch(...) //Parses thorws something stupid so i dont care for now.
  {
    throw InvalidQueryException();
  }
}
Beispiel #3
0
void Ontology::query(const string& var_name, const string& query, set<string>& result){
    vector<server_param_types> args;
    args.push_back(var_name);
    args.push_back(query);

    ServerResponse res = _connector.execute("query", args);

    if (res.status != ServerResponse::ok)
    {
        if (res.exception_msg.find(SERVER_QUERYPARSE_EXCEPTION) != string::npos)
            throw InvalidQueryException(query + "\nYour SPARQL query is invalid: " + res.error_msg);
        throw OntologyServerException("Query was not successful: server threw a " + res.exception_msg + " (" + res.error_msg +").");
    }

    if (set<string>* result_p = get<set<string> >(&res.result))
        result = *result_p;
}