private void checkInitialization() throws IntermediateQueryBuilderException { if (tree == null) throw new IntermediateQueryBuilderException("Not initialized!"); }
@Override public NodeCentricOptimizationResults<N> apply(SubstitutionPropagationProposal<N> proposal, IntermediateQuery query, QueryTreeComponent treeComponent) throws InvalidQueryOptimizationProposalException, EmptyQueryException { try { return applySubstitution(proposal, query, treeComponent); } catch (QueryNodeSubstitutionException e) { throw new InvalidQueryOptimizationProposalException(e.getMessage()); } }
@Override public void addChild(QueryNode parentNode, QueryNode childNode, ArgumentPosition position) throws IntermediateQueryBuilderException { checkEditMode(); try { tree.addChild(parentNode, childNode, Optional.of(position), true, false); } catch (IllegalTreeUpdateException e) { throw new IntermediateQueryBuilderException(e.getMessage()); } }
@Override public void visit(SliceNode sliceNode) { if (query.getChildren(sliceNode).size() != 1) { throw new InvalidIntermediateQueryException("SLICE node " + sliceNode + " must have ONE and ONLY ONE child.\n" + query); } }
@Override public QueryNode getRootNode() throws InconsistentIntermediateQueryException{ try { return treeComponent.getRootNode(); } catch (IllegalTreeException e) { throw new InconsistentIntermediateQueryException(e.getMessage()); } }
@Override public void addChild(QueryNode parentNode, QueryNode childNode) throws IntermediateQueryBuilderException { checkEditMode(); try { tree.addChild(parentNode, childNode, Optional.<ArgumentPosition>empty(), true, false); } catch (IllegalTreeUpdateException e) { throw new IntermediateQueryBuilderException(e.getMessage()); } }
@Override public void visit(TrueNode trueNode) { if (query.getChildren(trueNode).size() != 0) { throw new InvalidIntermediateQueryException("TRUENODE node " + trueNode + " has a child.\n" + query); } }
@Override public Optional<QueryNode> getNextSibling(QueryNode node) { try { return treeComponent.nextSibling(node); } catch (IllegalTreeException e) { throw new InconsistentIntermediateQueryException(e.getMessage()); } }
private void checkInitialization() throws IntermediateQueryBuilderException { if (tree == null) throw new IntermediateQueryBuilderException("Not initialized!"); }
@Override public void addChild(QueryNode parentNode, QueryNode childNode, ArgumentPosition position) throws IntermediateQueryBuilderException { checkEditMode(); try { tree.addChild(parentNode, childNode, Optional.of(position), true, false); } catch (IllegalTreeUpdateException e) { throw new IntermediateQueryBuilderException(e.getMessage()); } }
@Override public void visit(ExtensionalDataNode extensionalDataNode) { if (query.getChildren(extensionalDataNode).size() != 0) { throw new InvalidIntermediateQueryException("DATA node "+ extensionalDataNode + " has a child.\n" + query); } }
@Override public ImmutableList<QueryNode> getNodesInBottomUpOrder() throws InconsistentIntermediateQueryException { try { return treeComponent.getNodesInBottomUpOrder(); } catch (IllegalTreeException e) { throw new InconsistentIntermediateQueryException(e.getMessage()); } }
@Override public void addChild(QueryNode parentNode, QueryNode childNode) throws IntermediateQueryBuilderException { checkEditMode(); try { tree.addChild(parentNode, childNode, Optional.<ArgumentPosition>empty(), true, false); } catch (IllegalTreeUpdateException e) { throw new IntermediateQueryBuilderException(e.getMessage()); } }
@Override public void visit(IntensionalDataNode intensionalDataNode) { if (query.getChildren(intensionalDataNode).size() != 0) { throw new InvalidIntermediateQueryException("DATA node "+ intensionalDataNode + " has a child.\n" + query); } }
@Override public ImmutableList<QueryNode> getAncestors(QueryNode descendantNode) { try { return treeComponent.getAncestors(descendantNode); } catch (IllegalTreeException e) { throw new InconsistentIntermediateQueryException(e.getMessage()); } }
@Override public void visit(EmptyNode emptyNode) { if (query.getChildren(emptyNode).size() != 0) { throw new InvalidIntermediateQueryException("EMPTY node " + emptyNode + " has a child.\n" + query); } }
@Override public Optional<QueryNode> getParent(QueryNode node) { try { return treeComponent.getParent(node); } catch (IllegalTreeException e) { throw new InconsistentIntermediateQueryException(e.getMessage()); } }
@Override public void visit(DistinctNode distinctNode) { if (query.getChildren(distinctNode).size() != 1) { throw new InvalidIntermediateQueryException("DISTINCT node " + distinctNode + " must have ONE and ONLY ONE child.\n" + query); } }
@Override public ImmutableList<QueryNode> getNodesInTopDownOrder() { try { return treeComponent.getNodesInTopDownOrder(); } catch (IllegalTreeException e) { throw new InconsistentIntermediateQueryException(e.getMessage()); } }
@Override public Optional<QueryNode> getParent(QueryNode node) { try { return treeComponent.getParent(node); } catch (IllegalTreeException e) { throw new InconsistentIntermediateQueryException(e.getMessage()); } }