Search in sources :

Example 26 with ReadException

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));
        }
    }
}
Also used : Path(java.nio.file.Path) DataElementPath(com.developmentontheedge.be5.metadata.model.base.DataElementPath) ReadException(com.developmentontheedge.be5.metadata.exception.ReadException) FreemarkerScript(com.developmentontheedge.be5.metadata.model.FreemarkerScript) ReadException(com.developmentontheedge.be5.metadata.exception.ReadException) InvocationTargetException(java.lang.reflect.InvocationTargetException) MarkedYAMLException(org.yaml.snakeyaml.error.MarkedYAMLException) YAMLException(org.yaml.snakeyaml.error.YAMLException)

Example 27 with ReadException

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();
}
Also used : SecurityCollection(com.developmentontheedge.be5.metadata.model.SecurityCollection)

Example 28 with ReadException

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();
        }
    }
}
Also used : FreemarkerSqlException(com.developmentontheedge.be5.metadata.exception.FreemarkerSqlException) Arrays(java.util.Arrays) ViewDef(com.developmentontheedge.be5.metadata.model.ViewDef) NullLogger(com.developmentontheedge.be5.metadata.util.NullLogger) HashMap(java.util.HashMap) BeSqlExecutor(com.developmentontheedge.be5.metadata.sql.BeSqlExecutor) Parameter(org.apache.maven.plugins.annotations.Parameter) MultiSqlParser(com.developmentontheedge.dbms.MultiSqlParser) Rdbms(com.developmentontheedge.be5.metadata.sql.Rdbms) ArrayList(java.util.ArrayList) Entity(com.developmentontheedge.be5.metadata.model.Entity) DefaultTypeManager(com.developmentontheedge.be5.metadata.sql.type.DefaultTypeManager) Mojo(org.apache.maven.plugins.annotations.Mojo) SQLException(java.sql.SQLException) IndexDef(com.developmentontheedge.be5.metadata.model.IndexDef) DatabaseUtils(com.developmentontheedge.be5.metadata.sql.DatabaseUtils) ResultSet(java.sql.ResultSet) Locale(java.util.Locale) Map(java.util.Map) ExtendedSqlException(com.developmentontheedge.dbms.ExtendedSqlException) DdlElement(com.developmentontheedge.be5.metadata.model.DdlElement) Module(com.developmentontheedge.be5.metadata.model.Module) TableDef(com.developmentontheedge.be5.metadata.model.TableDef) DataElementUtils(com.developmentontheedge.be5.metadata.model.DataElementUtils) ProcessController(com.developmentontheedge.be5.metadata.util.ProcessController) PrintStream(java.io.PrintStream) DbmsTypeManager(com.developmentontheedge.be5.metadata.sql.type.DbmsTypeManager) ProcessInterruptedException(com.developmentontheedge.be5.metadata.exception.ProcessInterruptedException) IndexColumnDef(com.developmentontheedge.be5.metadata.model.IndexColumnDef) IOException(java.io.IOException) File(java.io.File) MojoFailureException(org.apache.maven.plugin.MojoFailureException) SqlColumnInfo(com.developmentontheedge.be5.metadata.sql.pojo.SqlColumnInfo) List(java.util.List) ColumnDef(com.developmentontheedge.be5.metadata.model.ColumnDef) IndexInfo(com.developmentontheedge.be5.metadata.sql.pojo.IndexInfo) SqlColumnType(com.developmentontheedge.be5.metadata.model.SqlColumnType) DbmsType(com.developmentontheedge.dbms.DbmsType) IntStreamEx(one.util.streamex.IntStreamEx) Pattern(java.util.regex.Pattern) Project(com.developmentontheedge.be5.metadata.model.Project) Collections(java.util.Collections) EntityType(com.developmentontheedge.be5.metadata.model.EntityType) DbmsSchemaReader(com.developmentontheedge.be5.metadata.sql.schema.DbmsSchemaReader) FreemarkerSqlException(com.developmentontheedge.be5.metadata.exception.FreemarkerSqlException) PrintStream(java.io.PrintStream) SQLException(java.sql.SQLException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) IOException(java.io.IOException) ExtendedSqlException(com.developmentontheedge.dbms.ExtendedSqlException) BeSqlExecutor(com.developmentontheedge.be5.metadata.sql.BeSqlExecutor) File(java.io.File) ProcessInterruptedException(com.developmentontheedge.be5.metadata.exception.ProcessInterruptedException)

Aggregations

YamlDeserializer (com.developmentontheedge.be5.metadata.serialization.yaml.YamlDeserializer)10 ReadException (com.developmentontheedge.be5.metadata.exception.ReadException)9 Map (java.util.Map)5 IOException (java.io.IOException)4 Entity (com.developmentontheedge.be5.metadata.model.Entity)3 Path (java.nio.file.Path)3 BeConnectionProfile (com.developmentontheedge.be5.metadata.model.BeConnectionProfile)2 BeModelElement (com.developmentontheedge.be5.metadata.model.base.BeModelElement)2 DataElementPath (com.developmentontheedge.be5.metadata.model.base.DataElementPath)2 LinkedHashMap (java.util.LinkedHashMap)2 MarkedYAMLException (org.yaml.snakeyaml.error.MarkedYAMLException)2 YAMLException (org.yaml.snakeyaml.error.YAMLException)2 FreemarkerSqlException (com.developmentontheedge.be5.metadata.exception.FreemarkerSqlException)1 ProcessInterruptedException (com.developmentontheedge.be5.metadata.exception.ProcessInterruptedException)1 ProjectLoadException (com.developmentontheedge.be5.metadata.exception.ProjectLoadException)1 BeConnectionProfiles (com.developmentontheedge.be5.metadata.model.BeConnectionProfiles)1 ColumnDef (com.developmentontheedge.be5.metadata.model.ColumnDef)1 Daemons (com.developmentontheedge.be5.metadata.model.Daemons)1 DataElementUtils (com.developmentontheedge.be5.metadata.model.DataElementUtils)1 DdlElement (com.developmentontheedge.be5.metadata.model.DdlElement)1