/** * {@inheritDoc} */ public Operator buildQueryPlan(String query, DQPResourceAccessor dqpResourceAccessor, RequestDetails requestDetails) throws ActivityUserException { // get function repository from the context FunctionRepository functionRepository = (FunctionRepository) OGSADAIContext .getInstance().get(FunctionRepository.FUNCTION_REPOSITORY_KEY); CommonTree ast = parseSPARQL(query); if (LOG.isDebugEnabled()) { LOG.debug("Parsed query"); LOG.debug((new DOTTreeGenerator()).toDOT(ast).toString()); } return buildValidatedLQP(ast, dqpResourceAccessor, requestDetails, functionRepository); }
public static void main(String[] args) throws Exception { StringInputStream inputStream = new StringInputStream("sum (sma(9, macd (1,2,3, close)) , close)"); ANTLRInputStream in = new ANTLRInputStream(inputStream); ParameterizedOperationsLexer lexer = new ParameterizedOperationsLexer(in); CommonTokenStream tokens = new CommonTokenStream(lexer); ParameterizedOperationsParser parser = new ParameterizedOperationsParser(tokens); CommonTree tree = (CommonTree) parser.indicatorexpr().getTree(); DOTTreeGenerator gen = new DOTTreeGenerator(); StringTemplate st = gen.toDOT(tree); System.out.println(st); }
private Operation parse(String formula) throws Exception { CommonTree commonTree = parameterizedBuilder.antlrParser.buildTree(new StringInputStream(formula)); if (LOGGER.isDebugEnabled()) { DOTTreeGenerator gen = new DOTTreeGenerator(); StringTemplate st = gen.toDOT(commonTree); LOGGER.debug(st); } Operation builtOperation = buildOperation(commonTree); if (builtOperation != null) builtOperation.setFormula(formula); return builtOperation; }
/** * Produce a dot source for an abstract syntax tree. * * @param ast the abstract syntax tree * @return a dot source */ private String getGraph(final Tree ast) { DOTTreeGenerator gen = new DOTTreeGenerator(); StringTemplate st = gen.toDOT(ast); return st.toString(); }