1 2 12 package com.versant.core.jdbc.metadata; 13 14 import com.versant.core.metadata.ModelMetaData; 15 import com.versant.core.metadata.ClassMetaData; 16 import com.versant.core.jdbc.JdbcConfig; 17 import com.versant.core.util.BeanUtils; 18 import com.versant.core.jdbc.sql.diff.ControlParams; 19 import com.versant.core.jdbc.JdbcConfig; 20 21 import java.io.Serializable ; 22 import java.util.ArrayList ; 23 import java.util.HashSet ; 24 import java.util.Collections ; 25 26 29 public class JdbcMetaData { 30 31 private final ModelMetaData jmd; 32 private final ControlParams migrationParams; 33 34 37 public JdbcTable[] keyGenTables; 38 42 public int maxPkSimpleColumns; 43 44 public JdbcMetaData(ModelMetaData jmd, JdbcConfig config) { 45 this.jmd = jmd; 46 migrationParams = new ControlParams(); 47 BeanUtils.setProperties(migrationParams, 48 config.jdbcMigrationControlProps); 49 } 50 51 public ControlParams getMigrationParams() { 52 return migrationParams; 53 } 54 55 59 public ArrayList getTables() { 60 return getTables(false); 61 } 62 63 67 public ArrayList getTables(boolean all) { 68 HashSet tables = new HashSet (); 69 ClassMetaData[] classes = jmd.classes; 70 for (int i = classes.length - 1; i >= 0; i--) { 71 ClassMetaData cmd = jmd.classes[i]; 72 JdbcClass jdbcClass = (JdbcClass)cmd.storeClass; 73 if (!all && jdbcClass.doNotCreateTable) { 74 continue; 75 } 76 jdbcClass.getTables(tables); 77 } 78 ArrayList a = new ArrayList (tables); 79 80 JdbcTable[] keyGenTables = ((JdbcMetaData)jmd.jdbcMetaData).keyGenTables; 81 if (keyGenTables != null) { 82 for (int i = 0; i < keyGenTables.length; i++) { 83 JdbcTable keyGenTable = keyGenTables[i]; 84 if (keyGenTable != null) { 85 a.add(keyGenTable); 86 } 87 } 88 } 89 Collections.sort(a); 90 return a; 91 } 92 93 } 94 | Popular Tags |