use of org.dbflute.logic.jdbc.metadata.info.DfSequenceMeta in project dbflute-core by dbflute.
the class DfSequenceIdentityProperties method getSequenceElement.
protected DfSequenceMeta getSequenceElement(UnifiedSchema unifiedSchema, String sequenceName, Map<String, DfSequenceMeta> sequenceMap) {
DfSequenceMeta info = sequenceMap.get(sequenceName);
if (info != null) {
return info;
}
if (sequenceName.contains(".")) {
// pure sequence name
sequenceName = Srl.substringLastRear(sequenceName, ".");
}
info = sequenceMap.get(unifiedSchema.buildFullQualifiedName(sequenceName));
if (info != null) {
return info;
}
info = sequenceMap.get(unifiedSchema.buildSchemaQualifiedName(sequenceName));
if (info != null) {
return info;
}
return info;
}
use of org.dbflute.logic.jdbc.metadata.info.DfSequenceMeta in project dbflute-core by dbflute.
the class DfSequenceExtractorH2 method doGetSequenceMap.
// ===================================================================================
// Sequence Map
// ============
protected Map<String, DfSequenceMeta> doGetSequenceMap() {
_log.info("...Loading sequence informations");
final Map<String, DfSequenceMeta> resultMap = StringKeyMap.createAsFlexibleOrdered();
final String sql = buildMetaSelectSql();
final List<String> columnList = new ArrayList<String>();
columnList.add("SEQUENCE_CATALOG");
columnList.add("SEQUENCE_SCHEMA");
columnList.add("SEQUENCE_NAME");
// no column on H2 (why?)
// columnList.add("MINIMUM_VALUE");
// columnList.add("MAXIMUM_VALUE");
columnList.add("INCREMENT");
final List<Map<String, String>> resultList = selectStringList(sql, columnList);
final StringBuilder logSb = new StringBuilder();
logSb.append(ln()).append("[SEQUENCE]");
for (Map<String, String> recordMap : resultList) {
final DfSequenceMeta info = new DfSequenceMeta();
final String sequenceCatalog = recordMap.get("SEQUENCE_CATALOG");
info.setSequenceCatalog(sequenceCatalog);
final String sequenceSchema = recordMap.get("SEQUENCE_SCHEMA");
info.setSequenceSchema(sequenceSchema);
final String sequenceName = recordMap.get("SEQUENCE_NAME");
info.setSequenceName(sequenceName);
// final String minimumValue = recordMap.get("MINIMUM_VALUE");
// info.setMinimumValue(minimumValue != null ? new BigDecimal(minimumValue) : null);
// final String maximumValue = recordMap.get("MAXIMUM_VALUE");
// nfo.setMaximumValue(maximumValue != null ? new BigDecimal(maximumValue) : null);
final String incrementSize = recordMap.get("INCREMENT");
info.setIncrementSize(incrementSize != null ? Integer.valueOf(incrementSize) : null);
final String key = buildSequenceMapKey(sequenceCatalog, sequenceSchema, sequenceName);
resultMap.put(key, info);
logSb.append(ln()).append(" ").append(key).append(" = ").append(info.toString());
}
_log.info(logSb.toString());
return resultMap;
}
use of org.dbflute.logic.jdbc.metadata.info.DfSequenceMeta in project dbflute-core by dbflute.
the class DfSequenceExtractorDB2 method doGetSequenceMap.
// ===================================================================================
// Sequence Map
// ============
protected Map<String, DfSequenceMeta> doGetSequenceMap() {
_log.info("...Loading sequence informations");
final Map<String, DfSequenceMeta> resultMap = StringKeyMap.createAsFlexibleOrdered();
final String sql = buildMetaSelectSql();
if (sql == null) {
return DfCollectionUtil.emptyMap();
}
final List<String> columnList = new ArrayList<String>();
columnList.add("SEQSCHEMA");
columnList.add("SEQNAME");
columnList.add("MINVALUE");
columnList.add("MAXVALUE");
columnList.add("INCREMENT");
final List<Map<String, String>> resultList = selectStringList(sql, columnList);
final StringBuilder logSb = new StringBuilder();
logSb.append(ln()).append("[SEQUENCE]");
for (Map<String, String> recordMap : resultList) {
final DfSequenceMeta info = new DfSequenceMeta();
String sequenceSchema = recordMap.get("SEQSCHEMA");
// trim because DB2 returns "char(8)-owner"
sequenceSchema = sequenceSchema != null ? sequenceSchema.trim() : null;
info.setSequenceSchema(sequenceSchema);
final String sequenceName = recordMap.get("SEQNAME");
info.setSequenceName(sequenceName);
final String minValue = recordMap.get("MINVALUE");
info.setMinimumValue(minValue != null ? new BigDecimal(minValue) : null);
final String maxValue = recordMap.get("MAXVALUE");
info.setMaximumValue(maxValue != null ? new BigDecimal(maxValue) : null);
final String incrementSize = recordMap.get("INCREMENT");
info.setIncrementSize(incrementSize != null ? Integer.valueOf(incrementSize) : null);
// DB2 does not return sequence catalog so catalog argument is null
final String key = buildSequenceMapKey(null, sequenceSchema, sequenceName);
resultMap.put(key, info);
logSb.append(ln()).append(" ").append(key).append(" = ").append(info.toString());
}
_log.info(logSb.toString());
return resultMap;
}
use of org.dbflute.logic.jdbc.metadata.info.DfSequenceMeta in project dbflute-core by dbflute.
the class DfSequenceExtractorPostgreSQL method doGetSequenceMap.
// ===================================================================================
// Sequence Map
// ============
protected Map<String, DfSequenceMeta> doGetSequenceMap() {
_log.info("...Loading sequence informations");
final Map<String, DfSequenceMeta> resultMap = StringKeyMap.createAsFlexibleOrdered();
final String sql = buildMetaSelectSql();
final List<String> columnList = new ArrayList<String>();
columnList.add("sequence_catalog");
columnList.add("sequence_schema");
columnList.add("sequence_name");
columnList.add("minimum_value");
columnList.add("maximum_value");
columnList.add("increment");
final List<Map<String, String>> resultList = selectStringList(sql, columnList);
final StringBuilder logSb = new StringBuilder();
logSb.append(ln()).append("[SEQUENCE]");
for (Map<String, String> recordMap : resultList) {
final DfSequenceMeta info = new DfSequenceMeta();
final String sequenceCatalog = recordMap.get("sequence_catalog");
info.setSequenceCatalog(sequenceCatalog);
final String sequenceSchema = recordMap.get("sequence_schema");
info.setSequenceSchema(sequenceSchema);
final String sequenceName = recordMap.get("sequence_name");
info.setSequenceName(sequenceName);
final UnifiedSchema unifiedSchema = createAsDynamicSchema(sequenceCatalog, sequenceSchema);
String minValue = recordMap.get("minimum_value");
if (minValue == null || minValue.trim().length() == 0) {
minValue = selectMinimumValue(unifiedSchema, sequenceName);
}
info.setMinimumValue(minValue != null ? new BigDecimal(minValue) : null);
String maxValue = recordMap.get("maximum_value");
if (maxValue == null || maxValue.trim().length() == 0) {
maxValue = selectMaximumValue(unifiedSchema, sequenceName);
}
info.setMaximumValue(maxValue != null ? new BigDecimal(maxValue) : null);
String incrementSize = recordMap.get("increment");
if (incrementSize == null || incrementSize.trim().length() == 0) {
incrementSize = selectIncrementSize(unifiedSchema, sequenceName);
}
info.setIncrementSize(incrementSize != null ? Integer.valueOf(incrementSize) : null);
final String key = buildSequenceMapKey(sequenceCatalog, sequenceSchema, sequenceName);
resultMap.put(key, info);
logSb.append(ln()).append(" ").append(key).append(" = ").append(info.toString());
}
_log.info(logSb.toString());
return resultMap;
}
Aggregations