use of com.developmentontheedge.be5.metadata.exception.ReadException in project be5 by DevelopmentOnTheEdge.
the class YamlDeserializer method readMacroFiles.
private void readMacroFiles(BaseDeserializer deserializer, Map<String, Object> serializedModuleBody, FreemarkerCatalog macroFiles) throws ReadException {
final Object includes = serializedModuleBody.get(TAG_MACRO_FILES);
if (includes == null)
return;
for (final String scriptName : deserializer.asStrList(includes)) {
final Path macroFile = getFileSystem().getMacroFile(scriptName);
try {
final FreemarkerScript script = new FreemarkerScript(scriptName, macroFiles);
if (Files.exists(macroFile)) {
script.setLinkedFile(macroFile);
script.getTemplateCode();
}
DataElementUtils.saveQuiet(script);
} catch (final Exception e) {
loadContext.addWarning(new ReadException(e, macroFiles.getCompletePath().getChildPath(scriptName), macroFile));
}
}
}
use of com.developmentontheedge.be5.metadata.exception.ReadException in project be5 by DevelopmentOnTheEdge.
the class YamlDeserializer method reloadSecurityCollection.
public SecurityCollection reloadSecurityCollection(final Path path, final Project project) throws ReadException {
final SecurityCollection security = project.newSecurityCollection();
final SecurityDeserializer securityDeserializer = new SecurityDeserializer(path, security);
securityDeserializer.deserialize();
DataElementUtils.saveQuiet(securityDeserializer.getResult());
return securityDeserializer.getResult();
}
use of com.developmentontheedge.be5.metadata.exception.ReadException in project be5 by DevelopmentOnTheEdge.
the class AppSync method execute.
// /////////////////////////////////////////////////////////////////
@Override
public void execute() throws MojoFailureException {
init();
PrintStream ps = null;
try {
if (logPath != null) {
logPath.mkdirs();
ps = new PrintStream(new File(logPath, be5Project.getName() + "_sync_ddl.sql"), "UTF-8");
}
sqlExecutor = new BeSqlExecutor(connector, ps);
if (be5Project.getDebugStream() != null) {
be5Project.getDebugStream().println("Modules and extras for " + be5Project.getName() + ":");
be5Project.allModules().map(m -> "- " + m.getName() + ": " + (m.getExtras() == null ? "" : String.join(", ", m.getExtras()))).forEach(be5Project.getDebugStream()::println);
}
readSchema();
createEntities();
String ddlString = getDdlStatements(false);
ddlString = MultiSqlParser.normalize(be5Project.getDatabaseSystem().getType(), ddlString);
if (ddlString.isEmpty()) {
getLog().info("Database scheme is up-to-date");
return;
}
if (forceUpdate) {
sqlExecutor.startSection("Sync schema");
logger.setOperationName("[>] Schema");
sqlExecutor.executeMultiple(ddlString);
sqlExecutor.startSection(null);
} else {
System.err.println("The following statements should be executed to update database scheme:");
System.err.println(ddlString);
System.err.println("Use -DBE5_FORCE_UPDATE=true, for apply");
}
checkSynchronizationStatus();
logger.setOperationName("Finished");
} catch (// ReadException | ProjectLoadException | SQLException e )
FreemarkerSqlException | ExtendedSqlException | SQLException e) {
if (debug)
throw new MojoFailureException("Synchronisation error: " + e.getMessage(), e);
throw new MojoFailureException("Synchronisation error: " + e.getMessage());
} catch (IOException | ProcessInterruptedException e) {
throw new MojoFailureException("Synchronisation error: " + e.getMessage(), e);
} catch (Throwable t) {
t.printStackTrace();
throw new MojoFailureException("Synchronisation error: " + t.getMessage(), t);
} finally {
if (ps != null) {
ps.close();
}
}
}
Aggregations