use of org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo in project dbflute-core by dbflute.
the class DfProcedureSupplementExtractorOracle method doResolveStructAttributeArray.
protected DfTypeArrayInfo doResolveStructAttributeArray(StringKeyMap<DfTypeStructInfo> structInfoMap, StringKeyMap<DfTypeArrayInfo> flatArrayInfoMap, String attrTypeName) {
if (!flatArrayInfoMap.containsKey(attrTypeName)) {
return null;
}
final DfTypeArrayInfo foundInfo = flatArrayInfoMap.get(attrTypeName);
final DfTypeArrayInfo typeArrayInfo = new DfTypeArrayInfo(foundInfo.getUnifiedSchema(), foundInfo.getTypeName());
final String elementType = foundInfo.getElementType();
typeArrayInfo.setElementType(elementType);
if (flatArrayInfoMap.containsKey(elementType)) {
// array in array in ...
// recursive call
final DfTypeArrayInfo nestedArrayInfo = doResolveStructAttributeArray(structInfoMap, flatArrayInfoMap, elementType);
typeArrayInfo.setNestedArrayInfo(nestedArrayInfo);
} else if (structInfoMap.containsKey(elementType)) {
// struct in array in ...
final DfTypeStructInfo elementStructInfo = structInfoMap.get(elementType);
typeArrayInfo.setElementStructInfo(elementStructInfo);
}
return typeArrayInfo;
}
use of org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo in project dbflute-core by dbflute.
the class DfProcedureSupplementExtractorOracle method processArrayNestedElement.
protected void processArrayNestedElement(UnifiedSchema unifiedSchema, final StringKeyMap<DfTypeArrayInfo> flatArrayInfoMap, DfTypeArrayInfo arrayInfo) {
// ARRAY element
final DfTypeArrayInfo foundInfo = flatArrayInfoMap.get(arrayInfo.getElementType());
if (foundInfo != null) {
final DfTypeArrayInfo nestedInfo = new DfTypeArrayInfo(foundInfo.getUnifiedSchema(), foundInfo.getTypeName());
nestedInfo.setElementType(foundInfo.getElementType());
arrayInfo.setNestedArrayInfo(nestedInfo);
// recursive call
processArrayNestedElement(unifiedSchema, flatArrayInfoMap, nestedInfo);
// *ARRAY type of additional schema is unsupported for now
}
// STRUCT element
final StringKeyMap<DfTypeStructInfo> structInfoMap = findParameterStructInfoMap(unifiedSchema);
final DfTypeStructInfo structInfo = structInfoMap.get(arrayInfo.getElementType());
if (structInfo != null) {
// the structInfo has already been resolved about nested objects
arrayInfo.setElementStructInfo(structInfo);
// *STRUCT type of additional schema is unsupported for now
}
}
use of org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo in project dbflute-core by dbflute.
the class DfProcedureSupplementExtractorOracle method doResolveStructAttributeInfo.
protected void doResolveStructAttributeInfo(UnifiedSchema unifiedSchema, StringKeyMap<DfTypeStructInfo> structInfoMap, StringKeyMap<DfTypeArrayInfo> flatArrayInfoMap, DfTypeStructInfo structInfo, DfColumnMeta columnInfo) {
final String attrTypeName = columnInfo.getDbTypeName();
final DfTypeArrayInfo arrayInfo = doResolveStructAttributeArray(structInfoMap, flatArrayInfoMap, attrTypeName);
if (arrayInfo != null) {
// array attribute
columnInfo.setTypeArrayInfo(arrayInfo);
}
final DfTypeStructInfo nestedStructInfo = structInfoMap.get(attrTypeName);
if (nestedStructInfo != null) {
// nested struct
columnInfo.setTypeStructInfo(nestedStructInfo);
}
// for default mapping type
columnInfo.setProcedureParameter(true);
}
use of org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo in project dbflute-core by dbflute.
the class DfStructExtractorOracle method extractStructInfoMap.
// ===================================================================================
// Extract
// =======
/**
* Extract the map of struct info. <br>
* The info is so simple, for example, no nested info.
* And this sets type name and attributes only.
* @param unifiedSchema The unified schema. (NotNull)
* @return The map of struct info. {key = schema.struct-type-name} (NotNull)
*/
public StringKeyMap<DfTypeStructInfo> extractStructInfoMap(UnifiedSchema unifiedSchema) {
final List<Map<String, String>> resultList = selectStructAttribute(unifiedSchema);
final StringKeyMap<DfTypeStructInfo> structInfoMap = StringKeyMap.createAsFlexibleOrdered();
for (Map<String, String> map : resultList) {
final String typeName = DfTypeStructInfo.generateTypeName(unifiedSchema, map.get("TYPE_NAME"));
DfTypeStructInfo info = structInfoMap.get(typeName);
if (info == null) {
info = new DfTypeStructInfo(unifiedSchema, typeName);
structInfoMap.put(typeName, info);
}
final DfColumnMeta attributeInfo = new DfColumnMeta();
final String attrName = map.get("ATTR_NAME");
if (Srl.is_Null_or_TrimmedEmpty(attrName)) {
continue;
}
attributeInfo.setColumnName(attrName);
final String dbTypeName;
{
// ARRAY and STRUCT only
final String attrTypeOwner = map.get("ATTR_TYPE_OWNER");
final String attrTypeName = map.get("ATTR_TYPE_NAME");
dbTypeName = Srl.connectPrefix(attrTypeName, attrTypeOwner, ".");
}
attributeInfo.setDbTypeName(dbTypeName);
final String length = map.get("LENGTH");
if (Srl.is_NotNull_and_NotTrimmedEmpty(length)) {
// for example, varchar2
attributeInfo.setColumnSize(Integer.valueOf(length));
} else {
final String precision = map.get("PRECISION");
if (Srl.is_NotNull_and_NotTrimmedEmpty(precision)) {
// for example, number
attributeInfo.setColumnSize(Integer.valueOf(precision));
}
}
final String scale = map.get("SCALE");
if (Srl.is_NotNull_and_NotTrimmedEmpty(scale)) {
attributeInfo.setDecimalDigits(Integer.valueOf(scale));
}
info.putAttributeInfo(attributeInfo);
}
return structInfoMap;
}
use of org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo in project dbflute-core by dbflute.
the class DfProcedurePmbSetupper method setupStructAttribute.
protected void setupStructAttribute(DfTypeStructInfo structInfo, ProcedurePropertyInfo propertyInfo) {
final StringKeyMap<DfColumnMeta> attrMap = structInfo.getAttributeInfoMap();
for (DfColumnMeta attrInfo : attrMap.values()) {
// nested array or struct handling
if (attrInfo.hasTypeArrayInfo()) {
// array in struct
final DfTypeArrayInfo typeArrayInfo = attrInfo.getTypeArrayInfo();
if (typeArrayInfo.hasElementStructInfo()) {
// struct in array in struct
registerEntityInfoIfNeeds(typeArrayInfo.getElementStructInfo(), propertyInfo);
}
if (typeArrayInfo.hasElementJavaNative()) {
final String elementJavaNative = typeArrayInfo.getElementJavaNative();
attrInfo.setSql2EntityForcedJavaNative(getGenericListClassName(elementJavaNative));
} else {
final String elementType;
if (typeArrayInfo.hasNestedArray()) {
// array in array in struct
final DfTypeArrayInfo nestedArrayInfo = typeArrayInfo.getNestedArrayInfo();
elementType = getGenericListClassName(doProcessArrayProperty(nestedArrayInfo, propertyInfo));
} else if (typeArrayInfo.hasElementStructInfo()) {
// struct in array in struct
final DfTypeStructInfo elementStructInfo = typeArrayInfo.getElementStructInfo();
elementType = buildStructEntityType(elementStructInfo);
} else {
// scalar in array in struct
elementType = findArrayScalarElementPropertyType(attrInfo.getTypeArrayInfo());
}
typeArrayInfo.setElementJavaNative(elementType);
attrInfo.setSql2EntityForcedJavaNative(getGenericListClassName(elementType));
}
} else if (attrInfo.hasTypeStructInfo()) {
final DfTypeStructInfo nestedStructInfo = attrInfo.getTypeStructInfo();
registerEntityInfoIfNeeds(nestedStructInfo, propertyInfo);
if (nestedStructInfo.hasEntityType()) {
attrInfo.setSql2EntityForcedJavaNative(nestedStructInfo.getEntityType());
} else {
attrInfo.setSql2EntityForcedJavaNative(buildStructEntityType(nestedStructInfo));
}
}
}
}
Aggregations