1 25 package org.ofbiz.entity.config; 26 27 import java.util.LinkedList ; 28 import java.util.List ; 29 30 import org.ofbiz.base.util.Debug; 31 import org.ofbiz.base.util.UtilXml; 32 import org.w3c.dom.Element ; 33 34 42 public class DatasourceInfo { 43 public static final String module = DatasourceInfo.class.getName(); 44 45 public String name; 46 public String helperClass; 47 public String fieldTypeName; 48 public List sqlLoadPaths = new LinkedList (); 49 public List readDatas = new LinkedList (); 50 public Element datasourceElement; 51 52 public static final int TYPE_JNDI_JDBC = 1; 53 public static final int TYPE_INLINE_JDBC = 2; 54 public static final int TYPE_TYREX_DATA_SOURCE = 3; 55 public static final int TYPE_OTHER = 4; 56 57 public Element jndiJdbcElement; 58 public Element tyrexDataSourceElement; 59 public Element inlineJdbcElement; 60 61 public String schemaName = null; 62 public boolean useSchemas = true; 63 public boolean checkOnStart = true; 64 public boolean addMissingOnStart = false; 65 public boolean useFks = true; 66 public boolean useFkIndices = true; 67 public boolean checkPrimaryKeysOnStart = false; 68 public boolean checkForeignKeysOnStart = false; 69 public boolean checkFkIndicesOnStart = false; 70 public boolean usePkConstraintNames = true; 71 public int constraintNameClipLength = 30; 72 public boolean useProxyCursor = false; 73 public String cursorName = "p_cursor"; 74 public int resultFetchSize = -1; 75 public String fkStyle = null; 76 public boolean useFkInitiallyDeferred = true; 77 public boolean useIndices = true; 78 public boolean checkIndicesOnStart = false; 79 public String joinStyle = null; 80 public boolean aliasViews = true; 81 public boolean alwaysUseConstraintKeyword = false; 82 public boolean dropFkUseForeignKeyKeyword = false; 83 public String tableType = null; 84 public String characterSet = null; 85 public String collate = null; 86 87 public DatasourceInfo(Element element) { 88 this.name = element.getAttribute("name"); 89 this.helperClass = element.getAttribute("helper-class"); 90 this.fieldTypeName = element.getAttribute("field-type-name"); 91 92 sqlLoadPaths = UtilXml.childElementList(element, "sql-load-path"); 93 readDatas = UtilXml.childElementList(element, "read-data"); 94 datasourceElement = element; 95 96 if (datasourceElement == null) { 97 Debug.logWarning("datasource def not found with name " + this.name + ", using default for schema-name (none)", module); 98 Debug.logWarning("datasource def not found with name " + this.name + ", using default for use-schemas (true)", module); 99 Debug.logWarning("datasource def not found with name " + this.name + ", using default for check-on-start (true)", module); 100 Debug.logWarning("datasource def not found with name " + this.name + ", using default for add-missing-on-start (false)", module); 101 Debug.logWarning("datasource def not found with name " + this.name + ", using default for check-pks-on-start (true)", module); 102 Debug.logWarning("datasource def not found with name " + this.name + ", using default for use-foreign-keys (true)", module); 103 Debug.logWarning("datasource def not found with name " + this.name + ", using default use-foreign-key-indices (true)", module); 104 Debug.logWarning("datasource def not found with name " + this.name + ", using default for check-fks-on-start (false)", module); 105 Debug.logWarning("datasource def not found with name " + this.name + ", using default for check-fk-indices-on-start (false)", module); 106 Debug.logWarning("datasource def not found with name " + this.name + ", using default for use-pk-constraint-names (true)", module); 107 Debug.logWarning("datasource def not found with name " + this.name + ", using default for constraint-name-clip-length (30)", module); 108 Debug.logWarning("datasource def not found with name " + this.name + ", using default for fk-style (name_constraint)", module); 109 Debug.logWarning("datasource def not found with name " + this.name + ", using default for use-fk-initially-deferred (true)", module); 110 Debug.logWarning("datasource def not found with name " + this.name + ", using default for use-indices (true)", module); 111 Debug.logWarning("datasource def not found with name " + this.name + ", using default for check-indices-on-start (false)", module); 112 Debug.logWarning("datasource def not found with name " + this.name + ", using default for join-style (ansi)", module); 113 Debug.logWarning("datasource def not found with name " + this.name + ", using default for always-use-constraint-keyword (false)", module); 114 Debug.logWarning("datasource def not found with name " + this.name + ", using default for drop-fk-use-foreign-key-keyword (false)", module); 115 Debug.logWarning("datasource def not found with name " + this.name + ", using default for table-type (none)", module); 116 Debug.logWarning("datasource def not found with name " + this.name + ", using default for character-set (none)", module); 117 Debug.logWarning("datasource def not found with name " + this.name + ", using default for collate (none)", module); 118 } else { 119 this.schemaName = datasourceElement.getAttribute("schema-name"); 120 this.useSchemas = !"false".equals(datasourceElement.getAttribute("use-schemas")); 122 this.checkOnStart = !"false".equals(datasourceElement.getAttribute("check-on-start")); 124 this.checkPrimaryKeysOnStart = !"false".equals(datasourceElement.getAttribute("check-pks-on-start")); 126 this.addMissingOnStart = "true".equals(datasourceElement.getAttribute("add-missing-on-start")); 128 this.useFks = !"false".equals(datasourceElement.getAttribute("use-foreign-keys")); 130 this.useFkIndices = !"false".equals(datasourceElement.getAttribute("use-foreign-key-indices")); 132 this.checkForeignKeysOnStart = "true".equals(datasourceElement.getAttribute("check-fks-on-start")); 134 this.checkFkIndicesOnStart = "true".equals(datasourceElement.getAttribute("check-fk-indices-on-start")); 136 this.usePkConstraintNames = !"false".equals(datasourceElement.getAttribute("use-pk-constraint-names")); 138 try { 139 this.constraintNameClipLength = Integer.parseInt(datasourceElement.getAttribute("constraint-name-clip-length")); 140 } catch (Exception e) { 141 Debug.logError("Could not parse constraint-name-clip-length value for datasource with name " + this.name + ", using default value of 30", module); 142 } 143 this.useProxyCursor = "true".equalsIgnoreCase(datasourceElement.getAttribute("use-proxy-cursor")); 144 this.cursorName = datasourceElement.getAttribute("proxy-cursor-name"); 145 try { 146 this.resultFetchSize = Integer.parseInt(datasourceElement.getAttribute("result-fetch-size")); 147 } catch (Exception e) { 148 Debug.logWarning("Could not parse result-fetch-size value for datasource with name " + this.name + ", using JDBC driver default value", module); 149 } 150 this.fkStyle = datasourceElement.getAttribute("fk-style"); 151 this.useFkInitiallyDeferred = "true".equals(datasourceElement.getAttribute("use-fk-initially-deferred")); 153 this.useIndices = !"false".equals(datasourceElement.getAttribute("use-indices")); 155 this.checkIndicesOnStart = "true".equals(datasourceElement.getAttribute("check-indices-on-start")); 157 this.joinStyle = datasourceElement.getAttribute("join-style"); 158 this.aliasViews = !"false".equals(datasourceElement.getAttribute("alias-view-columns")); 159 this.alwaysUseConstraintKeyword = "true".equals(datasourceElement.getAttribute("always-use-constraint-keyword")); 161 this.dropFkUseForeignKeyKeyword = "true".equals(datasourceElement.getAttribute("drop-fk-use-foreign-key-keyword")); 162 163 this.tableType = datasourceElement.getAttribute("table-type"); 164 this.characterSet = datasourceElement.getAttribute("character-set"); 165 this.collate = datasourceElement.getAttribute("collate"); 166 } 167 if (this.fkStyle == null || this.fkStyle.length() == 0) this.fkStyle = "name_constraint"; 168 if (this.joinStyle == null || this.joinStyle.length() == 0) this.joinStyle = "ansi"; 169 170 this.jndiJdbcElement = UtilXml.firstChildElement(datasourceElement, "jndi-jdbc"); 171 this.tyrexDataSourceElement = UtilXml.firstChildElement(datasourceElement, "tyrex-dataSource"); 172 this.inlineJdbcElement = UtilXml.firstChildElement(datasourceElement, "inline-jdbc"); 173 } 174 } 175 | Popular Tags |