public Set<String> getParamNames() { return queryTree.visit(new ParameterCounter(true)).getParameterNames(); }
public List<SimpleConditionNode> getConditions() { return queryTree.visit(NodesFinder.of(SimpleConditionNode.class)).getFoundNodes(); }
@Override public String getResult() { return getTree().visit(new TreeToQuery()).getQueryString().trim(); }
@Override public boolean hasIsNullCondition(String attribute) { IdentificationVariableNode identificationVariable = getAnalyzer().getMainIdentificationVariableNode(); if (identificationVariable != null) { String variableName = identificationVariable.getVariableName(); return queryTree.visit(NodesFinder.of(SimpleConditionNode.class)).getFoundNodes().stream() .filter(condition -> getAnalyzer().isConditionForEntityProperty(condition, variableName, attribute)) .anyMatch(condition -> getAnalyzer().isConditionISNULL(condition)); } return false; }
public Set<String> getEntityNames() { return queryTree.visit(new EntitiesFinder()) .resolveEntityNames(queryTree.getModel(), queryTree.getQueryVariableContext()); }
@Override public List<QueryPath> getQueryPaths() { List<QueryPath> queryPaths = new ArrayList<>(); QueryVariableContext variableContext = getTree().getQueryVariableContext(); PathNodeFinder finder = getTree().visit(new PathNodeFinder()); for (PathNode node : finder.getSelectedPathNodes()) { JpqlEntityModel model = variableContext.getEntityByVariableNameHierarchically(node.getEntityVariableName()); QueryPath queryPath = new QueryPath(model.getName(), node.getEntityVariableName(), node.asPathString(), true); queryPaths.add(queryPath); } for (PathNode node : finder.getOtherPathNodes()) { JpqlEntityModel model = variableContext.getEntityByVariableNameHierarchically(node.getEntityVariableName()); QueryPath queryPath = new QueryPath(model.getName(), node.getEntityVariableName(), node.asPathString(), false); queryPaths.add(queryPath); } return queryPaths; }