
prerna.theme.AbstractThemeUtils Maven / Gradle / Ivy
The newest version!
package prerna.theme;
import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import org.apache.commons.io.IOUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import prerna.engine.api.IHeadersDataRow;
import prerna.engine.api.IRawSelectWrapper;
import prerna.engine.impl.rdbms.RDBMSNativeEngine;
import prerna.util.Constants;
import prerna.util.Utility;
import prerna.util.sql.AbstractSqlQueryUtil;
public abstract class AbstractThemeUtils {
private static final Logger classLogger = LogManager.getLogger(AbstractThemeUtils.class);
static boolean initialized = false;
static RDBMSNativeEngine themeDb;
/**
* Only used for static references
*/
AbstractThemeUtils() {
}
public static void loadThemingDatabase() throws Exception {
themeDb = (RDBMSNativeEngine) Utility.getDatabase(Constants.THEMING_DB);
ThemeOwlCreator owlCreator = new ThemeOwlCreator(themeDb);
if(owlCreator.needsRemake()) {
owlCreator.remakeOwl();
}
initialize();
initialized = true;
}
private static void initialize() throws SQLException {
String[] colNames = null;
String[] types = null;
/*
* Currently used
*/
// ADMIN_THEME
AbstractSqlQueryUtil queryUtil = themeDb.getQueryUtil();
colNames = new String[] { "ID", "THEME_NAME", "THEME_MAP", "IS_ACTIVE" };
types = new String[] { "varchar(255)", "varchar(255)", queryUtil.getClobDataTypeName(), queryUtil.getBooleanDataTypeName() };
if(queryUtil.allowsIfExistsTableSyntax()) {
themeDb.insertData(queryUtil.createTableIfNotExists("ADMIN_THEME", colNames, types));
} else {
if(!queryUtil.tableExists(themeDb.getConnection(), "ADMIN_THEME", themeDb.getDatabase(), themeDb.getSchema())) {
themeDb.insertData(queryUtil.createTable("ADMIN_THEME", colNames, types));
}
}
// commit the changes
themeDb.commit();
}
/**
* Determine if the theme db is present to be able to set custom themes
* @return
*/
public static boolean isInitalized() {
return AbstractThemeUtils.initialized;
}
static List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy