com.elefana.util.CoreDbInitializer Maven / Gradle / Ivy
The newest version!
/*******************************************************************************
* Copyright 2018 Viridian Software Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package com.elefana.util;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.jdbc.datasource.init.ScriptUtils;
import org.springframework.stereotype.Component;
import com.elefana.indices.IndexFieldMappingService;
import com.elefana.node.NodeSettingsService;
@Component
public class CoreDbInitializer implements DbInitializer {
private static final Logger LOGGER = LoggerFactory.getLogger(CoreDbInitializer.class);
@Autowired
private NodeSettingsService nodeSettingsService;
@Autowired
private JdbcTemplate jdbcTemplate;
public void initialiseDatabase() throws SQLException {
createSqlFunctions();
createMasterTableIfNotExists();
createPartitionTrackingTableIfNotExists();
createFieldStatsTablesIfNotExists();
createIndexTemplatesTableIfNotExists();
}
public boolean isTableDistributed(String tableName) {
if (!nodeSettingsService.isUsingCitus()) {
return false;
}
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy