Package org.yaac.shared.egql

Examples of org.yaac.shared.egql.Response


      for (Statement stmt : cmd.getStatements()) {
        stmt.validate();
      }
     
      // validation passed, kick off all statements
      Response resp = new Response();
      for (Statement stmt : cmd.getStatements()) {
       
        // TODO : how to handle exceptions for simple statement?
        if (stmt.isSimpleStatement()) {
          if (stmt instanceof InsertStatement) {
            InsertStatement insertStmt = (InsertStatement) stmt;
            resp.getImmediateStmts().add(insertStmt.getRawStatement());
            executeSimpleInsert(insertStmt)
          } else {
            // TODO supports other simple statements 
          }
        } else {
          ProcessContext context = new ProcessContext();
          context.setClientId(userService.getCurrentUser().getEmail());
          String pipelineId = pipeline.startNewPipeline(new ProcessorManager(), stmt.generateProcessors(), context);
         
          resp.add(pipelineId, stmt.getRawStatement());
          logger.info("started pipeline " + pipelineId + " for query: " + stmt.getRawStatement())
        }
      }
     
      resp.setStatus(ResponseStatus.SUCCESS);
      return resp;
    } catch (RecognitionException e) {  // syntax error (should not happen as ANTLR will always try to recover from error)
      Response response = new Response();
      response.setStatus(ResponseStatus.SYNTAX_ERROR);
      response.setMessage(e.getMessage());
      return response;
    } catch (YaacException e) {  // syntax error (throw from EGQLParser.displayRecognitionError )
      Response response = new Response();
      response.setStatus(ResponseStatus.SYNTAX_ERROR);
      response.setMessage(e.getErrorMsg());     
      return response;
    } catch (EGQLException e) {  // logical exception
      Response response = new Response();
      response.setStatus(ResponseStatus.LOGICAL_ERROR);
      response.setErrorCode(e.getErrorCode());
      return response;
    }
  }
View Full Code Here


    // testing data
    String command = "select a, b, c from d \n select e, f, g from h";
    Request req = new Request(command, 100, 200);
   
    // test
    Response resp = service.execute(req);
   
    Map<String, String> expected = ImmutableMap.<String, String>of(
        "key1", "select a, b, c from d",
        "key2", "select e, f, g from h");
   
    assertEquals(expected, resp.getResponseMap());
  }
View Full Code Here

TOP

Related Classes of org.yaac.shared.egql.Response

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.