Search in sources :

Example 1 with DfProcedureArgumentInfo

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

the class DfProcedureParameterNativeExtractorOracle method doSelectProcedureArgumentInfoList.

protected List<DfProcedureArgumentInfo> doSelectProcedureArgumentInfoList(String sql) {
    final DfJdbcFacade facade = new DfJdbcFacade(_dataSource);
    final List<String> columnList = new ArrayList<String>();
    columnList.add("PACKAGE_NAME");
    columnList.add("OBJECT_NAME");
    columnList.add("OVERLOAD");
    columnList.add("SEQUENCE");
    columnList.add("ARGUMENT_NAME");
    columnList.add("IN_OUT");
    columnList.add("DATA_TYPE");
    columnList.add("DATA_LENGTH");
    columnList.add("DATA_PRECISION");
    columnList.add("DATA_SCALE");
    columnList.add("TYPE_OWNER");
    columnList.add("TYPE_NAME");
    columnList.add("TYPE_SUBNAME");
    final List<Map<String, String>> resultList;
    try {
        log(sql);
        resultList = facade.selectStringList(sql, columnList);
    } catch (Exception continued) {
        // because it's basically assist info
        log("Failed to select procedure argument info: " + continued.getMessage());
        return DfCollectionUtil.emptyList();
    }
    final List<DfProcedureArgumentInfo> infoList = DfCollectionUtil.newArrayList();
    for (Map<String, String> map : resultList) {
        final DfProcedureArgumentInfo info = new DfProcedureArgumentInfo();
        info.setPackageName(map.get("PACKAGE_NAME"));
        info.setObjectName(map.get("OBJECT_NAME"));
        info.setOverload(map.get("OVERLOAD"));
        info.setSequence(map.get("SEQUENCE"));
        info.setArgumentName(map.get("ARGUMENT_NAME"));
        info.setInOut(map.get("IN_OUT"));
        info.setDataType(map.get("DATA_TYPE"));
        info.setDataLength(map.get("DATA_LENGTH"));
        info.setDataPrecision(map.get("DATA_PRECISION"));
        info.setDataScale(map.get("DATA_SCALE"));
        // ARRAY and STRUCT only
        final String typeOwner = map.get("TYPE_OWNER");
        info.setTypeOwner(typeOwner);
        // nullable
        final String typeName = map.get("TYPE_NAME");
        if (Srl.is_NotNull_and_NotTrimmedEmpty(typeName)) {
            info.setTypeName(Srl.connectPrefix(typeName, typeOwner, "."));
        }
        info.setTypeSubName(map.get("TYPE_SUBNAME"));
        infoList.add(info);
    }
    return infoList;
}
Also used : ArrayList(java.util.ArrayList) DfProcedureArgumentInfo(org.dbflute.logic.jdbc.metadata.info.DfProcedureArgumentInfo) Map(java.util.Map) StringKeyMap(org.dbflute.helper.StringKeyMap) DfJdbcFacade(org.dbflute.helper.jdbc.facade.DfJdbcFacade)

Example 2 with DfProcedureArgumentInfo

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

the class DfProcedureParameterNativeExtractorOracle method filterParameterArgumentInfoList.

protected List<DfProcedureArgumentInfo> filterParameterArgumentInfoList(List<DfProcedureArgumentInfo> infoList) {
    final StringKeyMap<DfProcedureArgumentInfo> infoMap = StringKeyMap.createAsFlexibleOrdered();
    for (int i = 0; i < infoList.size(); i++) {
        final DfProcedureArgumentInfo info = infoList.get(i);
        final String argumentName = info.getArgumentName();
        final String key = generateParameterInfoMapKey(info.getPackageName(), info.getObjectName(), argumentName);
        final DfProcedureArgumentInfo alreadyRegistered = infoMap.get(key);
        if (alreadyRegistered != null) {
            // overload should be ordered by ascend
            continue;
        }
        infoMap.put(key, info);
    }
    return DfCollectionUtil.newArrayList(infoMap.values());
}
Also used : DfProcedureArgumentInfo(org.dbflute.logic.jdbc.metadata.info.DfProcedureArgumentInfo)

Example 3 with DfProcedureArgumentInfo

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

the class DfProcedureSupplementExtractorOracle method findParameterArrayInfoMap.

protected StringKeyMap<DfTypeArrayInfo> findParameterArrayInfoMap(UnifiedSchema unifiedSchema) {
    StringKeyMap<DfTypeArrayInfo> parameterArrayInfoMap = _arrayInfoMapMap.get(unifiedSchema);
    if (parameterArrayInfoMap != null) {
        return parameterArrayInfoMap;
    }
    final List<DfProcedureArgumentInfo> argInfoList = findProcedureArgumentInfoList(unifiedSchema);
    parameterArrayInfoMap = StringKeyMap.createAsFlexibleOrdered();
    final StringKeyMap<DfTypeArrayInfo> flatArrayInfoMap = findFlatArrayInfoMap(unifiedSchema);
    for (int i = 0; i < argInfoList.size(); i++) {
        final DfProcedureArgumentInfo argInfo = argInfoList.get(i);
        final String argumentName = argInfo.getArgumentName();
        if (Srl.is_Null_or_TrimmedEmpty(argumentName)) {
            continue;
        }
        final String realTypeName = buildArrayTypeName(argInfo);
        final DfTypeArrayInfo foundInfo = flatArrayInfoMap.get(realTypeName);
        if (foundInfo == null) {
            continue;
        }
        final DfTypeArrayInfo arrayInfo = new DfTypeArrayInfo(foundInfo.getUnifiedSchema(), foundInfo.getTypeName());
        arrayInfo.setElementType(foundInfo.getElementType());
        processArrayNestedElement(unifiedSchema, flatArrayInfoMap, arrayInfo);
        final String packageName = argInfo.getPackageName();
        final String objectName = argInfo.getObjectName();
        final String key = generateParameterInfoMapKey(packageName, objectName, argumentName);
        parameterArrayInfoMap.put(key, arrayInfo);
    }
    log("Array Parameter: " + unifiedSchema);
    for (Entry<String, DfTypeArrayInfo> entry : parameterArrayInfoMap.entrySet()) {
        log("  " + entry.getKey() + " = " + entry.getValue());
    }
    _arrayInfoMapMap.put(unifiedSchema, parameterArrayInfoMap);
    return _arrayInfoMapMap.get(unifiedSchema);
}
Also used : DfTypeArrayInfo(org.dbflute.logic.jdbc.metadata.info.DfTypeArrayInfo) DfProcedureArgumentInfo(org.dbflute.logic.jdbc.metadata.info.DfProcedureArgumentInfo)

Example 4 with DfProcedureArgumentInfo

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

the class DfProcedureNativeExtractorOracle method arrangeProcedureArgumentInfoMap.

protected Map<String, List<DfProcedureArgumentInfo>> arrangeProcedureArgumentInfoMap(List<DfProcedureArgumentInfo> allArgList) {
    final Map<String, List<DfProcedureArgumentInfo>> map = DfCollectionUtil.newLinkedHashMap();
    for (DfProcedureArgumentInfo currentArgInfo : allArgList) {
        final String packageName = currentArgInfo.getPackageName();
        final String procedureName = currentArgInfo.getObjectName();
        // DBFlute treats overload methods as one method
        // final String overload = currentArgInfo.getOverload();
        final String key = generateNativeInfoMapKey(packageName, procedureName);
        List<DfProcedureArgumentInfo> argList = map.get(key);
        if (argList == null) {
            argList = DfCollectionUtil.newArrayList();
            map.put(key, argList);
        }
        argList.add(currentArgInfo);
    }
    return map;
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) DfProcedureArgumentInfo(org.dbflute.logic.jdbc.metadata.info.DfProcedureArgumentInfo)

Example 5 with DfProcedureArgumentInfo

use of org.dbflute.logic.jdbc.metadata.info.DfProcedureArgumentInfo 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)

Aggregations

DfProcedureArgumentInfo (org.dbflute.logic.jdbc.metadata.info.DfProcedureArgumentInfo)9 DfTypeArrayInfo (org.dbflute.logic.jdbc.metadata.info.DfTypeArrayInfo)3 ArrayList (java.util.ArrayList)2 List (java.util.List)1 Map (java.util.Map)1 UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)1 StringKeyMap (org.dbflute.helper.StringKeyMap)1 StringSet (org.dbflute.helper.StringSet)1 DfJdbcFacade (org.dbflute.helper.jdbc.facade.DfJdbcFacade)1 DfProcedureColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta)1 DfProcedureMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta)1