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 tablespaces 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 036 DefaultTablespace defaultTablespace = configuration.getDefaultTablespace(); 037 if (defaultTablespace != null) { 038 String tables = defaultTablespace.getTables(); 039 if (isNotEmpty(tables)) { 040 this.tableTablespace = tables; 041 } 042 String indexes = defaultTablespace.getIndexes(); 043 if (isNotEmpty(indexes)) { 044 this.indexTablespace = indexes; 045 } 046 String history = defaultTablespace.getHistory(); 047 if (isNotEmpty(history)) { 048 this.historyTablespace = history; 049 } 050 } 051 } 052 053 /** 054 * Return the default tablespace to use for tables. 055 */ 056 public String getTableTablespace() { 057 return tableTablespace; 058 } 059 060 /** 061 * Return the default tablespace to use for indexes. 062 */ 063 public String getIndexTablespace() { 064 return indexTablespace; 065 } 066 067 /** 068 * Return the default tablespace to use for history tables. 069 */ 070 public String getHistoryTablespace() { 071 return historyTablespace; 072 } 073 074 protected boolean isNotEmpty(String tables) { 075 return tables != null && !tables.trim().isEmpty(); 076 } 077}