private void addLastPatchIfEmptyDb() {
   Log.CMDBUILD.info(
       "inside addLastPatchIfEmptyDb method but before if. Database type: "
           + configuration.getDatabaseType());
   if (EMPTY_DBTYPE.equals(configuration.getDatabaseType())) {
     Log.CMDBUILD.info("Before adding last patch to the empty database...");
     patchManager.createLastPatch();
   }
 }
 private void grantSchemaPrivileges(final String schema, final String role) {
   Log.CMDBUILD.info("Granting schema privileges");
   new JdbcTemplate(systemDataSource())
       .execute(
           String.format(
               GRANT_SCHEMA_PRIVILEGES, escapeSchemaName(schema), escapeSchemaName(role)));
 }
 private void alterDatabaseOwner(final String database, final String role) {
   Log.CMDBUILD.info("Changing database ownership");
   new JdbcTemplate(superDataSource())
       .execute(
           String.format(
               ALTER_DATABASE_OWNER, escapeSchemaName(database), escapeSchemaName(role)));
 }
 private void createPLSQLLanguage() {
   Log.CMDBUILD.info("Creating PL/SQL language");
   try {
     new JdbcTemplate(superDataSource()).execute(CREATE_LANGUAGE);
   } catch (final DataAccessException e) {
     forwardIfNotAlreadyPresentElement(e);
   }
 }
 private void createSharkRole() {
   Log.CMDBUILD.info("Creating shark role");
   try {
     final JdbcTemplate jdbcTemplate = new JdbcTemplate(superDataSource());
     jdbcTemplate.execute(String.format(CREATE_ROLE, SHARK_USERNAME, SHARK_PASSWORD));
     jdbcTemplate.execute(String.format(ALTER_ROLE_PATH, SHARK_USERNAME, "pg_default,shark"));
   } catch (final DataAccessException e) {
     forwardIfNotAlreadyPresentElement(e);
   }
 }
 private void createCmdbuildStructure() {
   Log.CMDBUILD.info("Creating CMDBuild structure");
   final List<String> sqlFiles =
       Arrays.asList( //
           baseSqlPath + "01_system_functions_base.sql", //
           baseSqlPath + "02_system_functions_class.sql", //
           baseSqlPath + "03_system_functions_attribute.sql", //
           baseSqlPath + "04_system_functions_domain.sql", //
           baseSqlPath + "05_base_tables.sql", //
           baseSqlPath + "06_system_views_base.sql", //
           baseSqlPath + "07_support_tables.sql", //
           baseSqlPath + "08_user_tables.sql", //
           baseSqlPath + "09_system_views_extras.sql", //
           baseSqlPath + "10_system_functions_extras.sql", //
           baseSqlPath + "11_workflow.sql", //
           baseSqlPath + "12_tecnoteca_extras.sql", //
           baseSqlPath + "13_bim.sql");
   for (final String file : sqlFiles) {
     Log.CMDBUILD.info("applying '{}'", file);
     final String content = FileUtils.getContents(file);
     new JdbcTemplate(systemDataSource()).execute(content);
   }
 }
 private void saveConfiguration() throws IOException {
   Log.CMDBUILD.info("Saving configuration");
   final DatabaseProperties dp = DatabaseProperties.getInstance();
   dp.store();
 }
 private void createRole(final String roleName, final String rolePassword) {
   Log.CMDBUILD.info("Creating role " + roleName);
   new JdbcTemplate(superDataSource())
       .execute(String.format(CREATE_ROLE, escapeSchemaName(roleName), escapeValue(rolePassword)));
 }
 private void createSharkTables() {
   Log.CMDBUILD.info("Creating shark tables");
   new JdbcTemplate(sharkDataSource())
       .execute(FileUtils.getContents(sharkSqlPath + "02_shark_emptydb.sql"));
 }
示例#10
0
 private void restoreSampleDB() {
   Log.CMDBUILD.info("Restoring demo structure");
   final String filename = sampleSqlPath + configuration.getDatabaseType() + "_schema.sql";
   final String sql = FileUtils.getContents(filename);
   new JdbcTemplate(systemDataSource()).execute(sql);
 }
示例#11
0
 private void createDatabase(final String name) {
   Log.CMDBUILD.info("Creating database " + name);
   new JdbcTemplate(superDataSource())
       .execute(String.format(CREATE_DATABASE, escapeSchemaName(name)));
 }