Search in sources :

Example 1 with DfProcedureSourceInfo

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

the class DfSchemaXmlSerializer method doProcessProcedure.

protected void doProcessProcedure(Element procedureGroupElement, final DfProcedureMeta procedureMeta) {
    final Element procedureElement = _doc.createElement("procedure");
    procedureElement.setAttribute("name", procedureMeta.getProcedureName());
    final UnifiedSchema unifiedSchema = procedureMeta.getProcedureSchema();
    if (unifiedSchema.hasSchema()) {
        procedureElement.setAttribute("schema", unifiedSchema.getIdentifiedSchema());
    }
    final String noMetaMark = DfSchemaDiff.PROCEDURE_SOURCE_NO_META_MARK;
    final DfProcedureSourceInfo sourceInfo = procedureMeta.getProcedureSourceInfo();
    {
        final Integer sourceLine = sourceInfo != null ? sourceInfo.getSourceLine() : null;
        procedureElement.setAttribute("sourceLine", sourceLine != null ? sourceLine.toString() : noMetaMark);
    }
    {
        final Integer sourceSize = sourceInfo != null ? sourceInfo.getSourceSize() : null;
        procedureElement.setAttribute("sourceSize", sourceSize != null ? sourceSize.toString() : noMetaMark);
    }
    {
        final String sourceHash = sourceInfo != null ? sourceInfo.toSourceHash() : null;
        procedureElement.setAttribute("sourceHash", sourceHash != null ? sourceHash : noMetaMark);
    }
    final String procedureComment = procedureMeta.getProcedureComment();
    if (Srl.is_NotNull_and_NotTrimmedEmpty(procedureComment)) {
        procedureElement.setAttribute("comment", procedureComment);
    }
    procedureGroupElement.appendChild(procedureElement);
}
Also used : DfProcedureSourceInfo(org.dbflute.logic.jdbc.metadata.info.DfProcedureSourceInfo) Element(org.w3c.dom.Element) UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema)

Example 2 with DfProcedureSourceInfo

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

the class DfProcedureSupplementExtractorMySQL method doExtractProcedureSourceInfo.

// ===================================================================================
// Source Info
// ===========
@Override
protected Map<String, DfProcedureSourceInfo> doExtractProcedureSourceInfo(UnifiedSchema unifiedSchema) {
    final List<Map<String, String>> sourceList = selectProcedureSourceList(unifiedSchema);
    final Map<String, DfProcedureSourceInfo> resultMap = StringKeyMap.createAsFlexibleOrdered();
    for (Map<String, String> sourceMap : sourceList) {
        final String name = sourceMap.get("ROUTINE_NAME");
        if (name == null) {
            // just in case
            continue;
        }
        final DfProcedureSourceInfo sourceInfo = new DfProcedureSourceInfo();
        // ROUTINES does not have parameter list
        final String body = sourceMap.get("ROUTINE_DEFINITION");
        if (body == null) {
            continue;
        }
        sourceInfo.setSourceCode(body);
        // body part only
        sourceInfo.setSourceLine(calculateSourceLine(body));
        sourceInfo.setSourceSize(calculateSourceSize(body));
        resultMap.put(name, sourceInfo);
    }
    return resultMap;
}
Also used : DfProcedureSourceInfo(org.dbflute.logic.jdbc.metadata.info.DfProcedureSourceInfo) Map(java.util.Map) StringKeyMap(org.dbflute.helper.StringKeyMap)

Example 3 with DfProcedureSourceInfo

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

the class DfProcedureSupplementExtractorH2 method doExtractProcedureSourceInfo.

// ===================================================================================
// Source Info
// ===========
@Override
protected Map<String, DfProcedureSourceInfo> doExtractProcedureSourceInfo(UnifiedSchema unifiedSchema) {
    final List<Map<String, String>> sourceList = selectProcedureSourceList(unifiedSchema);
    final Map<String, DfProcedureSourceInfo> resultMap = StringKeyMap.createAsFlexibleOrdered();
    for (Map<String, String> sourceMap : sourceList) {
        final String name = sourceMap.get("ALIAS_NAME");
        if (name == null) {
            // just in case
            continue;
        }
        final DfProcedureSourceInfo sourceInfo = new DfProcedureSourceInfo();
        // full text
        final String body = sourceMap.get("SOURCE");
        if (body == null) {
            continue;
        }
        sourceInfo.setSourceCode(body);
        sourceInfo.setSourceLine(calculateSourceLine(body));
        sourceInfo.setSourceSize(calculateSourceSize(body));
        resultMap.put(name, sourceInfo);
    }
    return resultMap;
}
Also used : DfProcedureSourceInfo(org.dbflute.logic.jdbc.metadata.info.DfProcedureSourceInfo) Map(java.util.Map) StringKeyMap(org.dbflute.helper.StringKeyMap)

Example 4 with DfProcedureSourceInfo

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

the class DfProcedureExtractor method doSetupSourceInfo.

// ===================================================================================
// Source Info
// ===========
protected void doSetupSourceInfo(DataSource dataSource, List<DfProcedureMeta> metaInfoList, DfProcedureSupplementExtractor extractor, UnifiedSchema unifiedSchema, boolean reflectParamsToHash) {
    final Map<String, DfProcedureSourceInfo> sourceInfoMap = extractor.extractProcedureSourceInfo(unifiedSchema);
    if (sourceInfoMap == null) {
        return;
    }
    log("...Reflecting source info to procedure meta: schema=" + unifiedSchema.getCatalogSchema());
    for (DfProcedureMeta procedureMeta : metaInfoList) {
        final UnifiedSchema procedureSchema = procedureMeta.getProcedureSchema();
        if (!unifiedSchema.equals(procedureSchema)) {
            continue;
        }
        final DfProcedureSourceInfo sourceInfo = sourceInfoMap.get(procedureMeta.getProcedureName());
        if (sourceInfo == null) {
            continue;
        }
        if (reflectParamsToHash) {
            sourceInfo.setSupplementCode(procedureMeta.getColumnDefinitionIndentity());
        }
        showReflectedSourceInfo(procedureMeta, sourceInfo);
        procedureMeta.setProcedureSourceInfo(sourceInfo);
    }
}
Also used : DfProcedureSourceInfo(org.dbflute.logic.jdbc.metadata.info.DfProcedureSourceInfo) UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) DfProcedureMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta)

Example 5 with DfProcedureSourceInfo

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

the class DfProcedureSupplementExtractorOracle method setupProcedureSourceInfo.

protected void setupProcedureSourceInfo(Map<String, DfProcedureSourceInfo> resultMap, String procedureName, String sourceCode, int line) {
    final DfProcedureSourceInfo sourceInfo = new DfProcedureSourceInfo();
    sourceInfo.setSourceCode(sourceCode.trim());
    sourceInfo.setSourceLine(line);
    sourceInfo.setSourceSize(sourceCode.length());
    final DfProcedureSourceInfo existingInfo = resultMap.get(procedureName);
    if (existingInfo != null) {
        // means e.g. split overload
        mergeExistingSourceInfo(sourceInfo, existingInfo);
    } else {
        // basically here
        resultMap.put(procedureName, sourceInfo);
    }
}
Also used : DfProcedureSourceInfo(org.dbflute.logic.jdbc.metadata.info.DfProcedureSourceInfo)

Aggregations

DfProcedureSourceInfo (org.dbflute.logic.jdbc.metadata.info.DfProcedureSourceInfo)7 Map (java.util.Map)4 StringKeyMap (org.dbflute.helper.StringKeyMap)4 UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)2 DfProcedureMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta)1 Element (org.w3c.dom.Element)1