Search in sources :

Example 1 with DfSequenceMeta

use of org.dbflute.logic.jdbc.metadata.info.DfSequenceMeta in project dbflute-core by dbflute.

the class DfSequenceExtractorOracle method setupSequenceSynonym.

protected void setupSequenceSynonym(Map<String, DfSequenceMeta> resultMap, StringBuilder logSb) {
    final List<String> columnList = new ArrayList<String>();
    columnList.add("SYNONYM_OWNER");
    columnList.add("SYNONYM_NAME");
    columnList.add("SEQUENCE_OWNER");
    columnList.add("SEQUENCE_NAME");
    columnList.add("MIN_VALUE");
    columnList.add("MAX_VALUE");
    columnList.add("INCREMENT_BY");
    final String sql = buildSequenceSynonymSelectSql();
    if (sql == null) {
        return;
    }
    final List<Map<String, String>> synonymList = selectStringList(sql, columnList);
    for (Map<String, String> recordMap : synonymList) {
        final DfSequenceMeta info = new DfSequenceMeta();
        final String sequenceSchema = recordMap.get("SYNONYM_OWNER");
        info.setSequenceSchema(sequenceSchema);
        final String sequenceName = recordMap.get("SYNONYM_NAME");
        info.setSequenceName(sequenceName);
        final String minValue = recordMap.get("MIN_VALUE");
        info.setMinimumValue(minValue != null ? new BigDecimal(minValue) : null);
        final String maxValue = recordMap.get("MAX_VALUE");
        info.setMaximumValue(maxValue != null ? new BigDecimal(maxValue) : null);
        final String incrementSize = recordMap.get("INCREMENT_BY");
        info.setIncrementSize(incrementSize != null ? Integer.valueOf(incrementSize) : null);
        final String key = buildSequenceMapKey(null, sequenceSchema, sequenceName);
        resultMap.put(key, info);
        logSb.append(ln()).append(" ").append(key).append(" = ").append(info.toString());
    }
}
Also used : DfSequenceMeta(org.dbflute.logic.jdbc.metadata.info.DfSequenceMeta) ArrayList(java.util.ArrayList) Map(java.util.Map) StringKeyMap(org.dbflute.helper.StringKeyMap) BigDecimal(java.math.BigDecimal)

Example 2 with DfSequenceMeta

use of org.dbflute.logic.jdbc.metadata.info.DfSequenceMeta in project dbflute-core by dbflute.

the class DfSequenceExtractorOracle method setupPureSequence.

protected void setupPureSequence(Map<String, DfSequenceMeta> resultMap, StringBuilder logSb) {
    final String sql = buildMetaSelectSql();
    if (sql == null) {
        return;
    }
    final List<String> columnList = new ArrayList<String>();
    columnList.add("SEQUENCE_OWNER");
    columnList.add("SEQUENCE_NAME");
    columnList.add("MIN_VALUE");
    columnList.add("MAX_VALUE");
    columnList.add("INCREMENT_BY");
    final List<Map<String, String>> resultList = selectStringList(sql, columnList);
    logSb.append(ln()).append("[SEQUENCE]");
    for (Map<String, String> recordMap : resultList) {
        final DfSequenceMeta info = new DfSequenceMeta();
        final String sequenceSchema = recordMap.get("SEQUENCE_OWNER");
        info.setSequenceSchema(sequenceSchema);
        final String sequenceName = recordMap.get("SEQUENCE_NAME");
        info.setSequenceName(sequenceName);
        final String minValue = recordMap.get("MIN_VALUE");
        info.setMinimumValue(minValue != null ? new BigDecimal(minValue) : null);
        final String maxValue = recordMap.get("MAX_VALUE");
        info.setMaximumValue(maxValue != null ? new BigDecimal(maxValue) : null);
        final String incrementSize = recordMap.get("INCREMENT_BY");
        info.setIncrementSize(incrementSize != null ? Integer.valueOf(incrementSize) : null);
        final String key = buildSequenceMapKey(null, sequenceSchema, sequenceName);
        resultMap.put(key, info);
        logSb.append(ln()).append(" ").append(key).append(" = ").append(info.toString());
    }
}
Also used : DfSequenceMeta(org.dbflute.logic.jdbc.metadata.info.DfSequenceMeta) ArrayList(java.util.ArrayList) Map(java.util.Map) StringKeyMap(org.dbflute.helper.StringKeyMap) BigDecimal(java.math.BigDecimal)

Example 3 with DfSequenceMeta

use of org.dbflute.logic.jdbc.metadata.info.DfSequenceMeta in project dbflute-core by dbflute.

the class DfSchemaXmlSerializer method processSequence.

// -----------------------------------------------------
// Sequence
// --------
protected void processSequence(Connection conn, DatabaseMetaData metaData) throws SQLException {
    _log.info("...Getting sequences");
    final Map<String, DfSequenceMeta> sequenceMap = extractSequenceMap();
    if (sequenceMap == null) {
        // means sequence-not-supported DBMS
        return;
    }
    _log.info("...Processing sequences: " + sequenceMap.size());
    final Element sequenceGroupElement = _doc.createElement("sequenceGroup");
    for (Entry<String, DfSequenceMeta> entry : sequenceMap.entrySet()) {
        final DfSequenceMeta sequenceMeta = entry.getValue();
        doProcessSequence(sequenceGroupElement, sequenceMeta);
    }
    _databaseNode.appendChild(sequenceGroupElement);
}
Also used : DfSequenceMeta(org.dbflute.logic.jdbc.metadata.info.DfSequenceMeta) Element(org.w3c.dom.Element)

Example 4 with DfSequenceMeta

use of org.dbflute.logic.jdbc.metadata.info.DfSequenceMeta in project dbflute-core by dbflute.

the class DfSchemaXmlSerializer method extractSequenceMap.

protected Map<String, DfSequenceMeta> extractSequenceMap() {
    final DfSequenceExtractorFactory factory = createSequenceExtractorFactory(_dataSource);
    final DfSequenceExtractor sequenceExtractor = factory.createSequenceExtractor();
    Map<String, DfSequenceMeta> sequenceMap = null;
    if (sequenceExtractor != null) {
        sequenceMap = sequenceExtractor.extractSequenceMap();
    }
    return sequenceMap;
}
Also used : DfSequenceMeta(org.dbflute.logic.jdbc.metadata.info.DfSequenceMeta) DfSequenceExtractorFactory(org.dbflute.logic.jdbc.metadata.sequence.factory.DfSequenceExtractorFactory) DfSequenceExtractor(org.dbflute.logic.jdbc.metadata.sequence.DfSequenceExtractor)

Example 5 with DfSequenceMeta

use of org.dbflute.logic.jdbc.metadata.info.DfSequenceMeta in project dbflute-core by dbflute.

the class DfSequenceIdentityProperties method getSequenceMap.

public Map<String, DfSequenceMeta> getSequenceMap(DfSchemaSource dataSource) {
    if (_sequenceMap != null) {
        return _sequenceMap;
    }
    final DfSequenceExtractorFactory factory = createSequenceExtractorFactory(dataSource);
    final DfSequenceExtractor sequenceExtractor = factory.createSequenceExtractor();
    Map<String, DfSequenceMeta> sequenceMap = null;
    if (sequenceExtractor != null) {
        sequenceMap = sequenceExtractor.extractSequenceMap();
    }
    if (sequenceMap != null) {
        _sequenceMap = sequenceMap;
    } else {
        _sequenceMap = DfCollectionUtil.emptyMap();
    }
    return _sequenceMap;
}
Also used : DfSequenceMeta(org.dbflute.logic.jdbc.metadata.info.DfSequenceMeta) DfSequenceExtractorFactory(org.dbflute.logic.jdbc.metadata.sequence.factory.DfSequenceExtractorFactory) DfSequenceExtractor(org.dbflute.logic.jdbc.metadata.sequence.DfSequenceExtractor)

Aggregations

DfSequenceMeta (org.dbflute.logic.jdbc.metadata.info.DfSequenceMeta)9 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 StringKeyMap (org.dbflute.helper.StringKeyMap)5 BigDecimal (java.math.BigDecimal)4 DfSequenceExtractor (org.dbflute.logic.jdbc.metadata.sequence.DfSequenceExtractor)2 DfSequenceExtractorFactory (org.dbflute.logic.jdbc.metadata.sequence.factory.DfSequenceExtractorFactory)2 UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)1 Element (org.w3c.dom.Element)1