Search in sources :

Example 11 with DfProcedureMeta

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

the class DfProcedureExtractor method doSetupGreatWallOracle.

// ===================================================================================
// Great Wall
// ==========
protected void doSetupGreatWallOracle(StringKeyMap<DfTypeArrayInfo> parameterArrayInfoMap, StringKeyMap<DfTypeStructInfo> structInfoMap, List<DfProcedureMeta> metaInfoList, DfProcedureSupplementExtractorOracle extractor) {
    final Set<String> resolvedArrayDispSet = new LinkedHashSet<String>();
    final Set<String> resolvedStructDispSet = new LinkedHashSet<String>();
    for (DfProcedureMeta metaInfo : metaInfoList) {
        final String catalog = metaInfo.getProcedureCatalog();
        final String procedureName = metaInfo.getProcedureName();
        final List<DfProcedureColumnMeta> columnList = metaInfo.getProcedureColumnList();
        for (DfProcedureColumnMeta columnInfo : columnList) {
            final String columnName = columnInfo.getColumnName();
            final String key = extractor.generateParameterInfoMapKey(catalog, procedureName, columnName);
            // Array
            final DfTypeArrayInfo arrayInfo = parameterArrayInfoMap.get(key);
            if (arrayInfo != null) {
                resolvedArrayDispSet.add(arrayInfo.toString());
                columnInfo.setTypeArrayInfo(arrayInfo);
            }
            // Struct
            final String dbTypeName = columnInfo.getDbTypeName();
            final DfTypeStructInfo structInfo = structInfoMap.get(dbTypeName);
            if (structInfo != null) {
                resolvedStructDispSet.add(structInfo.toString());
                columnInfo.setTypeStructInfo(structInfo);
            }
        }
    }
    if (!resolvedArrayDispSet.isEmpty()) {
        log("Array related to parameter: " + resolvedArrayDispSet.size());
        for (String arrayInfo : resolvedArrayDispSet) {
            log("  " + arrayInfo);
        }
    }
    if (!resolvedStructDispSet.isEmpty()) {
        log("Struct related to parameter: " + resolvedStructDispSet.size());
        for (String structInfo : resolvedStructDispSet) {
            log("  " + structInfo);
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DfProcedureColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta) DfTypeStructInfo(org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo) DfProcedureMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta) DfTypeArrayInfo(org.dbflute.logic.jdbc.metadata.info.DfTypeArrayInfo)

Example 12 with DfProcedureMeta

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

the class DfProcedureExtractor method setupProcedureToDBLinkIncluded.

// -----------------------------------------------------
// Included Procedure to DBLink
// ----------------------------
protected void setupProcedureToDBLinkIncluded(List<DfProcedureMeta> procedureList) {
    if (_procedureToDBLinkDataSource == null) {
        return;
    }
    final DfProcedureNativeTranslatorOracle translator = new DfProcedureNativeTranslatorOracle(_procedureToDBLinkDataSource);
    final DfOutsideSqlProperties prop = getOutsideSqlProperties();
    final List<String> procedureNameToDBLinkList = prop.getTargetProcedureNameToDBLinkList();
    for (String propertyName : procedureNameToDBLinkList) {
        final String packageName;
        final String procedureName;
        final String dbLinkName;
        final String nameResource;
        if (propertyName.contains(".")) {
            packageName = Srl.substringLastFront(propertyName, ".");
            nameResource = Srl.substringLastRear(propertyName, ".");
        } else {
            packageName = null;
            nameResource = propertyName;
        }
        procedureName = Srl.substringLastFront(nameResource, "@");
        dbLinkName = Srl.substringLastRear(nameResource, "@");
        final DfProcedureMeta meta = translator.translateProcedureToDBLink(packageName, procedureName, dbLinkName, this);
        if (meta == null) {
            throwProcedureToDBLinkTranslationFailureException(propertyName, packageName, procedureName, dbLinkName);
        }
        meta.setIncludedProcedureToDBLink(true);
        procedureList.add(meta);
    }
}
Also used : DfOutsideSqlProperties(org.dbflute.properties.DfOutsideSqlProperties) DfProcedureMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta) DfProcedureNativeTranslatorOracle(org.dbflute.logic.jdbc.metadata.procedure.DfProcedureNativeTranslatorOracle)

Example 13 with DfProcedureMeta

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

the class DfProcedureNativeTranslatorOracle method createDBLinkProcedureMeta.

protected DfProcedureMeta createDBLinkProcedureMeta(ProcedureNativeInfo nativeInfo, String dbLinkName) {
    final DfProcedureMeta procedureMeta = new DfProcedureMeta();
    setupProcedureName(nativeInfo, procedureMeta, dbLinkName);
    final List<DfProcedureArgumentInfo> argInfoList = nativeInfo.getArgInfoList();
    for (DfProcedureArgumentInfo argInfo : argInfoList) {
        final DfProcedureColumnMeta columnMeta = new DfProcedureColumnMeta();
        columnMeta.setColumnName(argInfo.getArgumentName());
        setupProcedureColumnDataType(argInfo, columnMeta);
        setupProcedureColumnInOutType(argInfo, columnMeta);
        setupProcedureColumnSize(argInfo, columnMeta);
        procedureMeta.addProcedureColumn(columnMeta);
    }
    // assist info (e.g. great walls) is not set here (set later)
    return procedureMeta;
}
Also used : DfProcedureColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta) DfProcedureMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta) DfProcedureArgumentInfo(org.dbflute.logic.jdbc.metadata.info.DfProcedureArgumentInfo)

Example 14 with DfProcedureMeta

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

the class DfSchemaHtmlProcedure method getAvailableSchemaProcedureMap.

public Map<String, List<DfProcedureMeta>> getAvailableSchemaProcedureMap(Supplier<DfSchemaSource> dataSourceProvider) throws SQLException {
    if (_schemaProcedureMap != null) {
        return _schemaProcedureMap;
    }
    final List<DfProcedureMeta> procedureList = getAvailableProcedureList(dataSourceProvider);
    final Map<String, List<DfProcedureMeta>> schemaProcedureListMap = DfCollectionUtil.newLinkedHashMap();
    final String mainName = "(main schema)";
    for (DfProcedureMeta meta : procedureList) {
        final UnifiedSchema procedureSchema = meta.getProcedureSchema();
        final String schemaName;
        if (procedureSchema != null) {
            final String drivenSchema = procedureSchema.getDrivenSchema();
            if (drivenSchema != null) {
                schemaName = drivenSchema;
            } else {
                schemaName = procedureSchema.isMainSchema() ? mainName : procedureSchema.getSqlPrefixSchema();
            }
        } else {
            schemaName = "(no schema)";
        }
        List<DfProcedureMeta> metaList = schemaProcedureListMap.get(schemaName);
        if (metaList == null) {
            metaList = DfCollectionUtil.newArrayList();
            schemaProcedureListMap.put(schemaName, metaList);
        }
        metaList.add(meta);
    }
    _schemaProcedureMap = schemaProcedureListMap;
    return _schemaProcedureMap;
}
Also used : UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) DfProcedureMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta) List(java.util.List)

Example 15 with DfProcedureMeta

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

the class DfProcedurePmbSetupper method setupProcedure.

// ===================================================================================
// Set up
// ======
public void setupProcedure() throws SQLException {
    if (!getOutsideSqlProperties().isGenerateProcedureParameterBean()) {
        return;
    }
    _log.info(" ");
    _log.info("...Setting up procedures for generating parameter-beans");
    final List<DfProcedureMeta> procedureList = getAvailableProcedureList();
    _log.info("");
    _log.info("/= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =");
    for (DfProcedureMeta procedure : procedureList) {
        final Map<String, String> propertyNameTypeMap = DfCollectionUtil.newLinkedHashMap();
        final Map<String, String> propertyNameOptionMap = DfCollectionUtil.newLinkedHashMap();
        final Map<String, String> propertyNameColumnNameMap = DfCollectionUtil.newLinkedHashMap();
        final Map<String, DfProcedureColumnMeta> propertyNameColumnInfoMap = DfCollectionUtil.newLinkedHashMap();
        final List<DfProcedureColumnMeta> procedureColumnList = procedure.getProcedureColumnList();
        final List<DfProcedureNotParamResultMeta> notParamResultList = procedure.getNotParamResultList();
        final String pmbName = convertProcedureNameToPmbName(procedure.getProcedureName());
        {
            final String procDisp = procedure.buildProcedureLoggingName();
            final DfProcedureType procType = procedure.getProcedureType();
            _log.info("[" + pmbName + "]: " + procDisp + " // " + procType);
            if (procedureColumnList.isEmpty() && notParamResultList.isEmpty()) {
                _log.info("    *No Parameter");
            }
        }
        boolean refCustomizeEntity = false;
        // Procedure Parameter handling
        int index = 0;
        for (DfProcedureColumnMeta column : procedureColumnList) {
            if (!column.isBindParameter()) {
                continue;
            }
            final String columnName;
            {
                final String plainColumnName = column.getColumnName();
                if (Srl.is_NotNull_and_NotTrimmedEmpty(plainColumnName)) {
                    columnName = resolveVendorColumnNameHeadable(plainColumnName);
                } else {
                    columnName = "arg" + (index + 1);
                }
            }
            final String propertyName;
            {
                propertyName = convertColumnNameToPropertyName(columnName);
            }
            // procedure's overload is unsupported because of this (override property)
            propertyNameColumnInfoMap.put(propertyName, column);
            final ProcedurePropertyInfo propertyInfo = processProcedureProperty(pmbName, column, propertyName);
            final String propertyType = propertyInfo.getPropertyType();
            if (propertyInfo.isRefCustomizeEntity()) {
                refCustomizeEntity = true;
            }
            propertyNameTypeMap.put(propertyName, propertyType);
            final DfProcedureColumnType procedureColumnType = column.getProcedureColumnType();
            propertyNameOptionMap.put(propertyName, procedureColumnType.toString());
            propertyNameColumnNameMap.put(propertyName, columnName);
            String msg = "    " + propertyType + " " + propertyName + ";";
            msg = msg + " // " + column.getProcedureColumnType();
            msg = msg + "(" + column.getJdbcDefType() + ", " + column.getDbTypeName() + ")";
            _log.info(msg);
            ++index;
        }
        // NotParamResult handling
        for (DfProcedureNotParamResultMeta result : notParamResultList) {
            final String propertyName = result.getPropertyName();
            final String propertyType;
            if (result.hasResultSetColumnInfo()) {
                final String entityName = convertProcedurePmbNameToEntityName(pmbName, propertyName);
                _entityInfoMap.put(entityName, createEntityInfo(entityName, result.getResultSetColumnInfoMap()));
                propertyType = convertProcedureListPropertyType(entityName);
                refCustomizeEntity = true;
            } else {
                propertyType = getProcedureDefaultResultSetPropertyType();
            }
            propertyNameTypeMap.put(propertyName, propertyType);
            propertyNameOptionMap.put(propertyName, DfProcedureColumnType.procedureColumnResult.toString());
            propertyNameColumnNameMap.put(propertyName, propertyName);
            String msg = "    " + propertyType + " " + propertyName + ";";
            msg = msg + " // " + DfProcedureColumnType.procedureColumnResult;
            _log.info(msg);
        }
        final DfPmbMetaData parameterBeanMetaData = new DfPmbMetaData();
        parameterBeanMetaData.setClassName(pmbName);
        parameterBeanMetaData.setPropertyNameTypeMap(propertyNameTypeMap);
        parameterBeanMetaData.setPropertyNameOptionMap(propertyNameOptionMap);
        parameterBeanMetaData.setProcedureName(procedure.buildProcedureSqlName());
        parameterBeanMetaData.setPropertyNameColumnNameMap(propertyNameColumnNameMap);
        parameterBeanMetaData.setPropertyNameColumnInfoMap(propertyNameColumnInfoMap);
        parameterBeanMetaData.setProcedureCalledBySelect(procedure.isCalledBySelect());
        parameterBeanMetaData.setProcedureRefCustomizeEntity(refCustomizeEntity);
        _pmbMetaDataMap.put(pmbName, parameterBeanMetaData);
    }
    _log.info("= = = = = = = = = =/");
    _log.info(" ");
}
Also used : DfProcedureColumnType(org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta.DfProcedureColumnType) DfProcedureColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta) DfProcedureNotParamResultMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureNotParamResultMeta) DfProcedureMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta) DfProcedureType(org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta.DfProcedureType)

Aggregations

DfProcedureMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta)24 UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)8 SQLException (java.sql.SQLException)5 DfProcedureColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta)5 ArrayList (java.util.ArrayList)4 DfOutsideSqlProperties (org.dbflute.properties.DfOutsideSqlProperties)4 SQLFailureException (org.dbflute.exception.SQLFailureException)3 DfProcedureExtractor (org.dbflute.logic.jdbc.metadata.basic.DfProcedureExtractor)3 Connection (java.sql.Connection)2 ResultSet (java.sql.ResultSet)2 Statement (java.sql.Statement)2 List (java.util.List)2 DfProcedureSynonymMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureSynonymMeta)2 DfProcedureNativeTranslatorOracle (org.dbflute.logic.jdbc.metadata.procedure.DfProcedureNativeTranslatorOracle)2 DatabaseMetaData (java.sql.DatabaseMetaData)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Entry (java.util.Map.Entry)1 DfProcedureArgumentInfo (org.dbflute.logic.jdbc.metadata.info.DfProcedureArgumentInfo)1 DfProcedureColumnType (org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta.DfProcedureColumnType)1