use of org.dbflute.properties.assistant.classification.DfClassificationElement in project dbflute-core by dbflute.
the class DfClsTableClassificationArranger method arrangeTableClassification.
// ===================================================================================
// Table Classification
// ====================
public void arrangeTableClassification(Map<String, DfClassificationElement> tableClassificationMap, DfClassificationTop classificationTop, Map<String, Object> elementMap, String table, List<DfClassificationElement> elementList, Connection conn) {
final DfClassificationElement metaElement = createBasicElement(classificationTop, elementMap, table);
if (isCompatibleElementMapSuppressAutoDeploy(elementMap)) {
// for compatible
classificationTop.setSuppressAutoDeploy(true);
}
final String where = (String) elementMap.get("where");
final String orderBy = (String) elementMap.get("orderBy");
final Set<String> exceptCodeSet = extractExceptCodeSet(classificationTop, elementMap);
final String sql = buildTableClassificationSql(metaElement, table, where, orderBy);
selectTableClassification(classificationTop, elementList, metaElement, exceptCodeSet, conn, sql);
final String classificationName = classificationTop.getClassificationName();
// e.g. for auto-deploy and determination
tableClassificationMap.put(classificationName, metaElement);
metaElement.setClassificationTop(classificationTop);
}
use of org.dbflute.properties.assistant.classification.DfClassificationElement in project dbflute-core by dbflute.
the class DfClassificationProperties method processAllInOneTableClassification.
// -----------------------------------------------------
// All-in-One Table Classification
// -------------------------------
protected void processAllInOneTableClassification(Connection conn, String sql) {
final DfClassificationAllInOneSqlExecutor executor = new DfClassificationAllInOneSqlExecutor();
final List<Map<String, String>> resultList = executor.executeAllInOneSql(conn, sql);
for (Map<String, String> map : resultList) {
final String classificationName = map.get("classificationName");
final DfClassificationTop classificationTop;
{
DfClassificationTop tmpTop = _classificationTopMap.get(classificationName);
if (tmpTop == null) {
tmpTop = createAllInOneTableClassificationTop(classificationName);
_classificationTopMap.put(classificationName, tmpTop);
}
classificationTop = tmpTop;
}
// }
if (!classificationTop.hasTopComment()) {
final String topComment = map.get(DfClassificationTop.KEY_TOP_COMMENT);
classificationTop.setTopComment(topComment);
}
if (!classificationTop.hasCodeType()) {
final String codeType;
{
String tmpType = map.get(DfClassificationTop.KEY_CODE_TYPE);
if (Srl.is_Null_or_TrimmedEmpty(tmpType)) {
// for compatibility
tmpType = map.get(DfClassificationTop.KEY_DATA_TYPE);
}
codeType = tmpType;
}
classificationTop.setCodeType(codeType);
}
final DfClassificationElement element = new DfClassificationElement();
element.setClassificationName(classificationName);
element.acceptBasicItemMap(map);
classificationTop.addClassificationElement(element);
}
}
use of org.dbflute.properties.assistant.classification.DfClassificationElement in project dbflute-core by dbflute.
the class DfClassificationProperties method setupTableClassification.
protected void setupTableClassification(DfClassificationTop classificationTop, List<DfClassificationElement> elementList, DfClassificationElement metaElement, Set<String> exceptCodeSet, Connection conn, String sql) {
final String classificationName = classificationTop.getClassificationName();
final String[] sisters = metaElement.getSisters();
final Map<String, Object> subItemPropMap = metaElement.getSubItemMap();
Statement st = null;
ResultSet rs = null;
try {
st = conn.createStatement();
_log.info("...Selecting for " + classificationName + " classification" + ln() + sql);
rs = st.executeQuery(sql);
final Set<String> duplicateCheckSet = StringSet.createAsCaseInsensitive();
while (rs.next()) {
final String code = rs.getString("cls_code");
final String name = rs.getString("cls_name");
final String alias = rs.getString("cls_alias");
final String comment = rs.getString("cls_comment");
if (exceptCodeSet.contains(code)) {
_log.info(" exceptd: " + code);
continue;
}
if (duplicateCheckSet.contains(code)) {
_log.info(" duplicate: " + code);
continue;
} else {
duplicateCheckSet.add(code);
}
final Map<String, Object> selectedMap = newLinkedHashMap();
selectedMap.put(DfClassificationElement.KEY_CODE, code);
selectedMap.put(DfClassificationElement.KEY_NAME, filterTableClassificationName(classificationTop, name));
selectedMap.put(DfClassificationElement.KEY_ALIAS, filterTableClassificationLiteralOutput(alias));
if (Srl.is_NotNull_and_NotTrimmedEmpty(comment)) {
// because of not required
selectedMap.put(DfClassificationElement.KEY_COMMENT, comment);
}
if (sisters != null && sisters.length > 0) {
final String sisterValue = rs.getString("cls_sister");
selectedMap.put(DfClassificationElement.KEY_SISTER_CODE, sisterValue);
}
if (subItemPropMap != null && !subItemPropMap.isEmpty()) {
final Map<String, Object> subItemMap = new LinkedHashMap<String, Object>();
for (String subItemKey : subItemPropMap.keySet()) {
final String clsKey = "cls_" + subItemKey;
final String subItemValue = rs.getString(clsKey);
final String subItemVeloFriendlyValue;
if (subItemValue != null) {
subItemVeloFriendlyValue = filterTableClassificationLiteralOutput(subItemValue);
} else {
// for determination in templates
subItemVeloFriendlyValue = "null";
}
subItemMap.put(subItemKey, subItemVeloFriendlyValue);
}
selectedMap.put(DfClassificationElement.KEY_SUB_ITEM_MAP, subItemMap);
}
final DfClassificationElement element = new DfClassificationElement();
element.setClassificationName(classificationName);
element.acceptBasicItemMap(selectedMap);
elementList.add(element);
}
} catch (SQLException e) {
throwTableClassificationSelectSQLFailureException(classificationName, sql, e);
throw new SQLFailureException("Failed to execute the SQL:" + ln() + sql, e);
} finally {
new DfClassificationSqlResourceCloser().closeStatement(st, rs);
}
}
use of org.dbflute.properties.assistant.classification.DfClassificationElement in project dbflute-core by dbflute.
the class DfClassificationProperties method processTableClassification.
protected void processTableClassification(DfClassificationTop classificationTop, Map<?, ?> elementMap, String table, List<DfClassificationElement> elementList, Connection conn) {
final DfClassificationElement metaElement = new DfClassificationElement();
metaElement.setClassificationName(classificationTop.getClassificationName());
metaElement.setTable(table);
metaElement.acceptBasicItemMap(elementMap);
if (isElementMapSuppressAutoDeploy(elementMap)) {
// for compatible
classificationTop.setSuppressAutoDeploy(true);
}
final String where = (String) elementMap.get("where");
final String orderBy = (String) elementMap.get("orderBy");
final Set<String> exceptCodeSet = extractExceptCodeSet(classificationTop, elementMap);
final String sql = buildTableClassificationSql(metaElement, table, where, orderBy);
setupTableClassification(classificationTop, elementList, metaElement, exceptCodeSet, conn, sql);
final String classificationName = classificationTop.getClassificationName();
// e.g. for auto-deploy and determination
_tableClassificationMap.put(classificationName, metaElement);
metaElement.setClassificationTop(classificationTop);
}
use of org.dbflute.properties.assistant.classification.DfClassificationElement in project dbflute-core by dbflute.
the class ForeignKey method doExtractFixedConditionEmbeddedCommentClassificationNormalCode.
protected String doExtractFixedConditionEmbeddedCommentClassificationNormalCode(DfClassificationTop classificationTop, String elementName) {
final List<DfClassificationElement> elementList = classificationTop.getClassificationElementList();
String code = null;
for (final DfClassificationElement element : elementList) {
final String name = element.getName();
if (elementName.equals(name)) {
code = quoteClassifiationElementIfNeeds(classificationTop, element.getCode());
break;
}
}
return code;
}
Aggregations