001package io.ebeaninternal.dbmigration.model; 002 003import io.ebeaninternal.dbmigration.migration.Configuration; 004import io.ebeaninternal.dbmigration.migration.DefaultTablespace; 005 006/** 007 * Holds configuration such as the default tablespace to use for tables, 008 * indexes, history tables etc. 009 */ 010public class MConfiguration { 011 012 /** 013 * Default tablespace for tables. 014 */ 015 protected String tableTablespace; 016 017 /** 018 * Default tablespace for indexes. 019 */ 020 protected String indexTablespace; 021 022 /** 023 * Default tablespace for history tables. 024 */ 025 protected String historyTablespace; 026 027 /** 028 * Apply the migration configuration. 029 * <p> 030 * It is expected that these are applied in the correct chronological order 031 * from earliest to latest. 032 * </p> 033 */ 034 public void apply(Configuration configuration) { 035 DefaultTablespace defaultTablespace = configuration.getDefaultTablespace(); 036 if (defaultTablespace != null) { 037 String tables = defaultTablespace.getTables(); 038 if (isNotEmpty(tables)) { 039 this.tableTablespace = tables; 040 } 041 String indexes = defaultTablespace.getIndexes(); 042 if (isNotEmpty(indexes)) { 043 this.indexTablespace = indexes; 044 } 045 String history = defaultTablespace.getHistory(); 046 if (isNotEmpty(history)) { 047 this.historyTablespace = history; 048 } 049 } 050 } 051 052 /** 053 * Return the default tablespace to use for tables. 054 */ 055 public String getTableTablespace() { 056 return tableTablespace; 057 } 058 059 /** 060 * Return the default tablespace to use for indexes. 061 */ 062 public String getIndexTablespace() { 063 return indexTablespace; 064 } 065 066 /** 067 * Return the default tablespace to use for history tables. 068 */ 069 public String getHistoryTablespace() { 070 return historyTablespace; 071 } 072 073 protected boolean isNotEmpty(String tables) { 074 return tables != null && !tables.trim().isEmpty(); 075 } 076}