Search in sources :

Example 6 with FreemarkerSqlException

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()]));
    }
}
Also used : FreemarkerSqlException(com.developmentontheedge.be5.metadata.exception.FreemarkerSqlException) ExtendedSqlException(com.developmentontheedge.dbms.ExtendedSqlException)

Aggregations

FreemarkerSqlException (com.developmentontheedge.be5.metadata.exception.FreemarkerSqlException)4 PrintStream (java.io.PrintStream)4 Module (com.developmentontheedge.be5.metadata.model.Module)3 Project (com.developmentontheedge.be5.metadata.model.Project)3 BeSqlExecutor (com.developmentontheedge.be5.metadata.sql.BeSqlExecutor)3 File (java.io.File)3 MojoFailureException (org.apache.maven.plugin.MojoFailureException)3 ProjectElementException (com.developmentontheedge.be5.metadata.exception.ProjectElementException)2 FreemarkerScript (com.developmentontheedge.be5.metadata.model.FreemarkerScript)2 ExtendedSqlException (com.developmentontheedge.dbms.ExtendedSqlException)2 SqlExecutor (com.developmentontheedge.dbms.SqlExecutor)2 IOException (java.io.IOException)2 ProcessInterruptedException (com.developmentontheedge.be5.metadata.exception.ProcessInterruptedException)1 ColumnDef (com.developmentontheedge.be5.metadata.model.ColumnDef)1 DataElementUtils (com.developmentontheedge.be5.metadata.model.DataElementUtils)1 DdlElement (com.developmentontheedge.be5.metadata.model.DdlElement)1 Entity (com.developmentontheedge.be5.metadata.model.Entity)1 EntityType (com.developmentontheedge.be5.metadata.model.EntityType)1 FreemarkerCatalog (com.developmentontheedge.be5.metadata.model.FreemarkerCatalog)1 IndexColumnDef (com.developmentontheedge.be5.metadata.model.IndexColumnDef)1