use of org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta.DfProcedureType 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(" ");
}
Aggregations