use of com.developmentontheedge.be5.metadata.util.NullLogger in project be5 by DevelopmentOnTheEdge.
the class ModuleUtilsTest method testMergeAllModulesWithLoadRead.
@Test
public void testMergeAllModulesWithLoadRead() throws Exception {
Path tpmProjectPath = tmp.newFolder().toPath();
Path tpmModulePath = tmp.newFolder().toPath();
Project module = getModule();
Serialization.save(module, tpmModulePath);
Project app = getProject();
Serialization.save(app, tpmProjectPath);
ArrayList<URL> urls = new ArrayList<>();
urls.add(tpmModulePath.resolve("project.yaml").toUri().toURL());
urls.add(tpmProjectPath.resolve("project.yaml").toUri().toURL());
ModuleLoader2.loadAllProjects(urls);
assertNotNull(ModuleLoader2.getModulePath("app").resolve("project.yaml"));
app = ModuleLoader2.getModulesMap().get("app");
ModuleLoader2.mergeModules(app, new NullLogger());
assertEquals(Collections.singleton("mentity"), app.getEntityNames());
assertEquals(EntityType.DICTIONARY, app.getEntity("mentity").getType());
BeModelCollection<Query> queries = app.getEntity("mentity").getQueries();
assertEquals("QUERY1 customized", queries.get("q1").getQuery());
assertEquals("Query1 title", queries.get("q1").getTitleName());
assertEquals("QUERY2", queries.get("q2").getQuery());
assertEquals("Query2 title", queries.get("q2").getTitleName());
assertEquals("QUERY3", queries.get("q3").getQuery());
assertEquals("Query3 title", queries.get("q3").getTitleName());
}
use of com.developmentontheedge.be5.metadata.util.NullLogger in project be5 by DevelopmentOnTheEdge.
the class AppSync method readSchema.
private void readSchema() throws ExtendedSqlException, SQLException, ProcessInterruptedException {
getLog().info("Read database scheme ...");
long time = System.currentTimeMillis();
ProcessController controller = new NullLogger();
Rdbms rdbms = DatabaseUtils.getRdbms(connector);
DbmsSchemaReader schemaReader = rdbms.getSchemaReader();
defSchema = schemaReader.getDefaultSchema(sqlExecutor);
tableTypes = schemaReader.readTableNames(sqlExecutor, defSchema, controller);
columns = schemaReader.readColumns(sqlExecutor, defSchema, controller);
indices = schemaReader.readIndices(sqlExecutor, defSchema, controller);
if (debug) {
if (!warnings.isEmpty()) {
System.err.println(warnings.size() + " warning(s) during loading the project from " + sqlExecutor.getConnector().getConnectString());
Collections.sort(warnings);
for (String warning : warnings) {
System.err.println(warning);
}
}
}
getLog().info("comleted, " + (System.currentTimeMillis() - time) + "ms.");
}
use of com.developmentontheedge.be5.metadata.util.NullLogger in project be5 by DevelopmentOnTheEdge.
the class AppTools method execute.
@Override
public void execute() throws MojoFailureException {
init();
BeConnectionProfile prof = be5Project.getConnectionProfile();
if (prof == null) {
throw new MojoFailureException("Connection profile is required for SQL console");
}
try {
getLog().info("Welcome to FTL/SQL console!");
BeSqlExecutor sql = new BeSqlExecutor(connector) {
@Override
public void executeSingle(String statement) throws ExtendedSqlException {
ResultSet rs = null;
try {
rs = connector.executeQuery(statement);
format(rs, System.err, 20);
} catch (SQLException e) {
throw new ExtendedSqlException(connector, statement, e);
} finally {
connector.close(rs);
}
}
};
FreemarkerScript fs = new FreemarkerScript("SQL", be5Project.getApplication().getFreemarkerScripts());
DataElementUtils.save(fs);
ProcessController log = new NullLogger();
while (true) {
getLog().info("Enter FTL/SQL (use 'quit' to exit):");
String line = new BufferedReader(new InputStreamReader(inputStream)).readLine();
if (line == null) {
break;
}
line = line.trim();
if (line.equals("quit")) {
break;
}
fs.setSource(line);
ParseResult result = fs.getResult();
if (result.getResult() != null) {
getLog().info("SQL> " + result.getResult());
} else {
getLog().info("ERROR> " + result.getError());
continue;
}
try {
sql.executeScript(fs, log);
} catch (Exception e) {
getLog().info("ERROR> " + e.getMessage());
}
}
} catch (Exception e) {
throw new MojoFailureException("Console error: " + e.getMessage(), e);
}
}
Aggregations