use of com.developmentontheedge.be5.metadata.exception.ProjectElementException in project be5 by DevelopmentOnTheEdge.
the class AppDb method execute.
@Override
public void execute() throws MojoFailureException {
init();
try {
if (logPath != null) {
logPath.mkdirs();
ps = new PrintStream(new File(logPath, (moduleName == null ? be5Project.getName() : moduleName) + "_db.sql"), "UTF-8");
}
sql = new BeSqlExecutor(connector, ps);
if (moduleName != null) {
Module module = be5Project.getModule(moduleName);
if (module == null) {
throw new MojoFailureException("Module '" + moduleName + "' not found!");
}
createDb(module);
} else {
for (Module module : be5Project.getModules()) {
if (ModuleLoader2.containsModule(module.getName()))
createDb(module);
}
createDb(be5Project.getApplication());
}
getLog().info("Created tables: " + createdTables + ", created views: " + createdViews);
} catch (MojoFailureException e) {
throw e;
} catch (ProjectElementException | FreemarkerSqlException e) {
if (debug) {
e.printStackTrace();
throw new MojoFailureException("Setup db error", e);
}
throw new MojoFailureException(e.getMessage());
} catch (Exception e) {
e.printStackTrace();
throw new MojoFailureException("Setup db error", e);
} finally {
if (ps != null) {
ps.close();
}
}
}
use of com.developmentontheedge.be5.metadata.exception.ProjectElementException in project be5 by DevelopmentOnTheEdge.
the class AppDb method processDdl.
private void processDdl(final DdlElement tableDef) throws ProjectElementException {
try {
final String generatedQuery = tableDef.getDdl();
sql.executeMultiple(generatedQuery);
} catch (Exception e) {
throw new ProjectElementException(tableDef, e);
}
}
use of com.developmentontheedge.be5.metadata.exception.ProjectElementException in project be5 by DevelopmentOnTheEdge.
the class AppValidate method loadModules.
private void loadModules() throws MojoFailureException {
LoadContext loadContext = new LoadContext();
// List<ProjectElementException> errors = new ArrayList<>();
try {
// final Project model = be5Project;
// List<Project> moduleProjects = ModuleLoader2.loadModules(model, logger, loadContext);
// errors.addAll( validateDeps(moduleProjects) );
// ModuleLoader2.mergeAllModules( model, moduleProjects, loadContext );
ModuleLoader2.mergeModules(be5Project, logger);
} catch (ProjectLoadException e) {
throw new MojoFailureException("Can not load project modules", e);
}
checkErrors(loadContext, "Modules have %d error(s)");
}
use of com.developmentontheedge.be5.metadata.exception.ProjectElementException in project be5 by DevelopmentOnTheEdge.
the class FreemarkerSqlHandler method execute.
public void execute(FreemarkerScript freemarkerScript) throws ProjectElementException, FreemarkerSqlException {
DataElementPath path = freemarkerScript.getCompletePath();
if (log != null) {
log.setOperationName("[>] " + path);
}
sqlExecutor.comment("Execute " + path);
Project project = freemarkerScript.getProject();
ResultToConsumerWriter out = new ResultToConsumerWriter(new MultiSqlConsumer(project.getDatabaseSystem().getType(), this));
FreemarkerUtils.mergeTemplateByPath(path.toString(), project.getContext(freemarkerScript), project.getConfiguration(), out);
for (int j = includeChain.size() - 1; j >= 0; j--) {
sqlExecutor.comment("End of included " + includeChain.get(j), false);
}
}
use of com.developmentontheedge.be5.metadata.exception.ProjectElementException in project be5 by DevelopmentOnTheEdge.
the class TableDef method getWarnings.
@Override
public List<ProjectElementException> getWarnings() {
ArrayList<ProjectElementException> warnings = new ArrayList<>();
Rdbms rdbms = getProject().getDatabaseSystem();
DbmsTypeManager typeManager = rdbms.getTypeManager();
if (!typeManager.isFunctionalIndexSupported()) {
for (IndexDef index : getIndices().getAvailableElements()) {
if (index.isFunctional()) {
warnings.add(new ProjectElementException(index, "Functional indices are not supported by " + rdbms));
}
}
}
if (rdbms == Rdbms.DB2) {
for (IndexDef index : getIndices().getAvailableElements()) {
if (index.getName().length() > Rdbms.DB2_INDEX_LENGTH) {
warnings.add(new ProjectElementException(index, "Index name too long for DB2 (" + index.getName().length() + ">" + Rdbms.DB2_INDEX_LENGTH + "); will be skipped"));
}
}
}
if (!typeManager.isCustomAutoincrementSupported()) {
ColumnDef autoincrementColumn = getAutoincrementColumn();
if (autoincrementColumn != null && getStartId() != null) {
warnings.add(new ProjectElementException(autoincrementColumn, "Custom starting autoincrement value is not supported by " + rdbms));
}
}
for (ColumnDef def : getColumns().getAvailableElements()) {
if (def.getType().getTypeName().equals(TYPE_UNKNOWN)) {
warnings.add(new ProjectElementException(def, "Cannot determine column type: probably it references to invalid table or column"));
}
}
for (IndexDef def : getIndices().getAvailableElements()) {
for (IndexColumnDef col : def) {
ColumnDef column = getColumns().getCaseInsensitive(col.getName());
if (column == null)
warnings.add(new ProjectElementException(col, "Index refers to unknown column"));
else if (!column.isAvailable())
warnings.add(new ProjectElementException(col, "Index refers to non-available column"));
}
}
return warnings;
}
Aggregations