use of com.developmentontheedge.be5.metadata.exception.FreemarkerSqlException in project be5 by DevelopmentOnTheEdge.
the class FreemarkerSqlHandler method endStatement.
@Override
public void endStatement(String statement) {
List<Position> positions = calculatePosition();
if (debug) {
for (Position position : positions) {
sqlExecutor.comment("At " + position, false);
}
}
List<String> newIncludeChain = getIncludeChain(positions);
if (!newIncludeChain.equals(includeChain)) {
int i = 0;
while (newIncludeChain.size() > i && includeChain.size() > i && newIncludeChain.get(i).equals(includeChain.get(i))) {
i++;
}
for (int j = includeChain.size() - 1; j >= i; j--) {
sqlExecutor.comment("End of included " + includeChain.get(j), false);
}
for (int j = i; j < newIncludeChain.size(); j++) {
if (log != null) {
StringBuilder sb = new StringBuilder("[>] ");
for (int k = 0; k < j; k++) sb.append(" ");
sb.append(newIncludeChain.get(j));
log.setOperationName(sb.toString());
}
sqlExecutor.comment("Start of included " + newIncludeChain.get(j));
}
}
includeChain = newIncludeChain;
try {
sqlExecutor.executeSingle(statement);
} catch (ExtendedSqlException e) {
if (!debug) {
for (Position position : positions) {
sqlExecutor.comment("At " + position, false);
}
}
throw new FreemarkerSqlException(e, positions.toArray(new Position[positions.size()]));
}
}
Aggregations