Package org.apache.marmotta.kiwi.persistence.util

Examples of org.apache.marmotta.kiwi.persistence.util.ScriptRunner


                createNeeded = createNeeded || !tables.contains(tableName);
            }
            if(createNeeded) {
                log.info("creating new KiWi database ...");

                ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false);
                runner.runScript(new StringReader(configuration.getDialect().getCreateScript(scriptName)));

            } else {
                int version = connection.getDatabaseVersion();

                String updateScript = configuration.getDialect().getMigrationScript(version,scriptName);
                if(updateScript != null && updateScript.length() > 0) {
                    log.info("upgrading existing KiWi database from version {} to version {}", version, configuration.getDialect().getVersion());

                    ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false);
                    runner.runScript(new StringReader(updateScript));

                } else {
                    log.info("connecting to existing KiWi database (version: {})",version);
                }
            }
View Full Code Here


                    for(String table : tables) {
                        log.debug("- found table: {}",table);
                    }
                }

                ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false);
                runner.runScript(new StringReader(configuration.getDialect().getDropScript(scriptName)));


                if(log.isDebugEnabled()) {
                    tables = connection.getDatabaseTables();
                    log.debug("AFTER DROP: database tables");
View Full Code Here

                        // for postgres, we need to create
                        // - a stored procedure for mapping ISO language codes to PostgreSQL fulltext configuration names
                        // - if languages are not null, for each configured language as well as for the generic configuration
                        //   an index over nodes.svalue

                        ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false);
                        if(connection.getMetadata("ft.lookup") == null) {
                            log.info("PostgreSQL: creating language configuration lookup function");
                            StringBuilder script = new StringBuilder();
                            for(String line : IOUtils.readLines(PostgreSQLDialect.class.getResourceAsStream("create_fulltext_langlookup.sql"))) {
                                if(!line.startsWith("--")) {
                                    script.append(line);
                                    script.append(" ");
                                }
                            }
                            log.debug("PostgreSQL: running SQL script '{}'", script.toString());
                            runner.runScript(new StringReader(script.toString()));
                        }

                        // language specific indexes
                        if(configuration.getFulltextLanguages() != null) {
                            StringBuilder script = new StringBuilder();
                            for(String line : IOUtils.readLines(PostgreSQLDialect.class.getResourceAsStream("create_fulltext_index.sql"))) {
                                if(!line.startsWith("--")) {
                                    script.append(line);
                                    script.append(" ");
                                }
                            }
                            for(String lang : configuration.getFulltextLanguages()) {
                                if(connection.getMetadata("ft.idx."+lang) == null) {
                                    String pg_configuration = POSTGRES_LANG_MAPPINGS.get(lang);
                                    if(pg_configuration != null) {
                                        log.info("PostgreSQL: creating fulltext index for language {}", lang);
                                        String script_lang = script.toString().replaceAll("@LANGUAGE@", lang).replaceAll("@CONFIGURATION@",pg_configuration);
                                        log.debug("PostgreSQL: running SQL script '{}'", script_lang);
                                        runner.runScript(new StringReader(script_lang));
                                    }
                                }
                            }
                        }

                        // generic index
                        if(configuration.getFulltextLanguages() != null) {
                            if(connection.getMetadata("ft.idx.generic") == null) {
                                StringBuilder script = new StringBuilder();
                                for(String line : IOUtils.readLines(PostgreSQLDialect.class.getResourceAsStream("create_fulltext_index_generic.sql"))) {
                                    if(!line.startsWith("--")) {
                                        script.append(line);
                                        script.append(" ");
                                    }
                                }
                                log.info("PostgreSQL: creating generic fulltext index ");
                                log.debug("PostgreSQL: running SQL script '{}'", script.toString());
                                runner.runScript(new StringReader(script.toString()));
                            }
                        }

                        /*
                    } else if(configuration.getDialect() instanceof MySQLDialect) {
View Full Code Here


    @Override
    protected void dropIndexes() throws SQLException {
        try {
            ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false);

            StringBuilder script = new StringBuilder();
            for(String line : IOUtils.readLines(KiWiPostgresHandler.class.getResourceAsStream("drop_indexes.sql"))) {
                if(!line.startsWith("--")) {
                    script.append(line);
                    script.append(" ");
                }
            }
            log.debug("PostgreSQL: running SQL script '{}'", script.toString());
            runner.runScript(new StringReader(script.toString()));
        } catch (IOException ex) {
            throw new SQLException("error while dropping indexes",ex);
        }
    }
View Full Code Here

    }

    @Override
    protected void createIndexes() throws SQLException {
        try {
            ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false);

            StringBuilder script = new StringBuilder();
            for(String line : IOUtils.readLines(KiWiPostgresHandler.class.getResourceAsStream("create_indexes.sql"))) {
                if(!line.startsWith("--")) {
                    script.append(line);
                    script.append(" ");
                }
            }
            log.debug("PostgreSQL: running SQL script '{}'", script.toString());
            runner.runScript(new StringReader(script.toString()));
        } catch (IOException ex) {
            throw new SQLException("error while creating indexes",ex);
        }
    }
View Full Code Here

                createNeeded = createNeeded || !tables.contains(tableName);
            }
            if(createNeeded) {
                log.info("creating new KiWi database ...");

                ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false);
                runner.runScript(new StringReader(configuration.getDialect().getCreateScript(scriptName)));

            } else {
                int version = connection.getDatabaseVersion();

                String updateScript = configuration.getDialect().getMigrationScript(version,scriptName);
                if(updateScript != null && updateScript.length() > 0) {
                    log.info("upgrading existing KiWi database from version {} to version {}", version, configuration.getDialect().getVersion());

                    ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false);
                    runner.runScript(new StringReader(updateScript));

                } else {
                    log.info("connecting to existing KiWi database (version: {})",version);
                }
            }
View Full Code Here

                    for(String table : tables) {
                        log.debug("- found table: {}",table);
                    }
                }

                ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false);
                runner.runScript(new StringReader(configuration.getDialect().getDropScript(scriptName)));


                if(log.isDebugEnabled()) {
                    tables = connection.getDatabaseTables();
                    log.debug("AFTER DROP: database tables");
View Full Code Here

                createNeeded = createNeeded || !tables.contains(tableName);
            }
            if(createNeeded) {
                log.info("creating new KiWi database ...");

                ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false);
                runner.runScript(new StringReader(dialect.getCreateScript(scriptName)));

            } else {
                int version = connection.getDatabaseVersion();

                String updateScript = dialect.getMigrationScript(version,scriptName);
                if(updateScript != null && updateScript.length() > 0) {
                    log.info("upgrading existing KiWi database from version {} to version {}", version, dialect.getVersion());

                    ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false);
                    runner.runScript(new StringReader(updateScript));

                } else {
                    log.info("connecting to existing KiWi database (version: {})",version);
                }
            }
View Full Code Here

                    for(String table : tables) {
                        log.debug("- found table: {}",table);
                    }
                }

                ScriptRunner runner = new ScriptRunner(connection.getJDBCConnection(), false, false);
                runner.runScript(new StringReader(dialect.getDropScript(scriptName)));


                if(log.isDebugEnabled()) {
                    tables = connection.getDatabaseTables();
                    log.debug("AFTER DROP: database tables");
View Full Code Here

TOP

Related Classes of org.apache.marmotta.kiwi.persistence.util.ScriptRunner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.