Search in sources :

Example 31 with DfClassificationTop

use of org.dbflute.properties.assistant.classification.DfClassificationTop in project dbflute-core by dbflute.

the class DfRefClsReferenceRegistry method createDBClsReference.

protected DfRefClsReference createDBClsReference(String clsTheme) {
    final Map<String, DfClassificationTop> topMap = getClassificationProperties().getClassificationTopMap();
    final String cdefPackage = getBasicProperties().getBaseCommonPackage();
    final String cdefInterfaceName = getBasicProperties().getCDefPureName();
    final DfRefClsReferredCDef refCDef = new DfRefClsReferredCDef(cdefPackage, cdefInterfaceName);
    return new DfRefClsReference(clsTheme, topMap, refCDef);
}
Also used : DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop) DfRefClsReferredCDef(org.dbflute.properties.assistant.classification.refcls.DfRefClsReferredCDef)

Example 32 with DfClassificationTop

use of org.dbflute.properties.assistant.classification.DfClassificationTop in project dbflute-core by dbflute.

the class DfPmbPropertyOptionClassification method getPropertyOptionClassificationTop.

public DfClassificationTop getPropertyOptionClassificationTop() {
    final String classificationName = extractClassificationNameFromOption(true);
    final DfClassificationTop classificationTop = _classificationProperties.getClassificationTop(classificationName);
    if (classificationTop == null) {
        throwClassificationNotFoundException(classificationName);
    }
    return classificationTop;
}
Also used : DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop)

Example 33 with DfClassificationTop

use of org.dbflute.properties.assistant.classification.DfClassificationTop in project dbflute-core by dbflute.

the class DfClassificationProperties method filterUseDocumentOnly.

// -----------------------------------------------------
// DocumentOnly
// ------------
protected void filterUseDocumentOnly() {
    final boolean docOnlyTask = isDocOnlyTask();
    for (Entry<String, DfClassificationTop> entry : _classificationTopMap.entrySet()) {
        final String classificationName = entry.getKey();
        final DfClassificationTop classificationTop = entry.getValue();
        if (!docOnlyTask && classificationTop.isUseDocumentOnly()) {
            _log.info("...Skipping document-only classification: " + classificationName);
            // e.g. Generate or Sql2Entity, and document-only classification
            _documentOnlyClassificationSet.add(classificationName);
        }
    }
    for (String documentOnlyClassificationName : _documentOnlyClassificationSet) {
        _classificationTopMap.remove(documentOnlyClassificationName);
        _tableClassificationMap.remove(documentOnlyClassificationName);
    }
}
Also used : DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop)

Example 34 with DfClassificationTop

use of org.dbflute.properties.assistant.classification.DfClassificationTop in project dbflute-core by dbflute.

the class DfClassificationProperties method getClassificationDefinitionMap.

// -----------------------------------------------------
// Native Definition
// -----------------
/**
 * Get the map of classification definition.
 * @return The map of classification definition. (NotNull)
 */
protected Map<String, DfClassificationTop> getClassificationDefinitionMap() {
    if (_classificationTopMap != null) {
        return _classificationTopMap;
    }
    _classificationTopMap = newLinkedHashMap();
    final Map<String, Object> plainDefinitionMap;
    {
        final String mapName = KEY_classificationDefinitionMap;
        final String propKey = "torque." + mapName;
        plainDefinitionMap = resolveSplit(mapName, mapProp(propKey, DEFAULT_EMPTY_MAP));
    }
    final DfClsElementLiteralArranger literalArranger = new DfClsElementLiteralArranger();
    String allInOneSql = null;
    Connection conn = null;
    try {
        for (Entry<String, Object> entry : plainDefinitionMap.entrySet()) {
            final String classificationName = entry.getKey();
            final Object objValue = entry.getValue();
            // handle special elements
            if (classificationName.equalsIgnoreCase("$$SQL$$")) {
                allInOneSql = (String) objValue;
                continue;
            }
            // check duplicate classification
            if (_classificationTopMap.containsKey(classificationName)) {
                String msg = "Duplicate classification: " + classificationName;
                throw new DfIllegalPropertySettingException(msg);
            }
            final DfClassificationTop classificationTop = new DfClassificationTop(classificationName);
            _classificationTopMap.put(classificationName, classificationTop);
            // handle classification elements
            if (!(objValue instanceof List<?>)) {
                throwClassificationMapValueIllegalListTypeException(objValue);
            }
            final List<?> plainList = (List<?>) objValue;
            final List<DfClassificationElement> elementList = new ArrayList<DfClassificationElement>();
            boolean tableClassification = false;
            for (Object element : plainList) {
                if (!(element instanceof Map<?, ?>)) {
                    throwClassificationListElementIllegalMapTypeException(element);
                }
                @SuppressWarnings("unchecked") final Map<String, Object> elementMap = (Map<String, Object>) element;
                // from table
                final String table = (String) elementMap.get(DfClassificationElement.KEY_TABLE);
                if (Srl.is_NotNull_and_NotTrimmedEmpty(table)) {
                    tableClassification = true;
                    if (conn == null) {
                        // on demand
                        conn = createMainSchemaConnection();
                    }
                    arrangeTableClassification(classificationTop, elementMap, table, elementList, conn);
                    continue;
                }
                // from literal
                if (isElementMapClassificationTop(elementMap)) {
                    // top definition
                    arrangeClassificationTopFromLiteral(classificationTop, elementMap);
                } else {
                    literalArranger.arrange(classificationName, elementMap);
                    final DfClassificationElement classificationElement = new DfClassificationElement();
                    classificationElement.setClassificationName(classificationName);
                    classificationElement.acceptBasicItemMap(elementMap);
                    elementList.add(classificationElement);
                }
            }
            // adjust classification top
            classificationTop.addClassificationElementAll(elementList);
            classificationTop.setTableClassification(tableClassification);
            _classificationTopMap.put(classificationName, classificationTop);
        }
        if (allInOneSql != null) {
            if (conn == null) {
                // on demand
                conn = createMainSchemaConnection();
            }
            arrangeAllInOneTableClassification(conn, allInOneSql);
        }
        // *Classification Resource Point!
        reflectClassificationResourceToDefinition();
        filterUseDocumentOnly();
        verifyClassificationConstraintsIfNeeds();
        prepareSuppressedDBAccessClassTableSet();
    } finally {
        new DfClassificationJdbcCloser().closeConnection(conn);
    }
    return _classificationTopMap;
}
Also used : Connection(java.sql.Connection) ArrayList(java.util.ArrayList) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException) DfClassificationJdbcCloser(org.dbflute.properties.assistant.classification.coins.DfClassificationJdbcCloser) DfClsElementLiteralArranger(org.dbflute.properties.assistant.classification.element.proploading.DfClsElementLiteralArranger) DfClassificationElement(org.dbflute.properties.assistant.classification.DfClassificationElement) DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) StringKeyMap(org.dbflute.helper.StringKeyMap)

Example 35 with DfClassificationTop

use of org.dbflute.properties.assistant.classification.DfClassificationTop in project dbflute-core by dbflute.

the class DfClsTableAllInOneArranger method createAllInOneTableClassificationTop.

protected DfClassificationTop createAllInOneTableClassificationTop(final String classificationName) {
    final DfClassificationTop tmpTop = new DfClassificationTop(classificationName);
    final DfLittleAdjustmentProperties prop = getLittleAdjustmentProperties();
    tmpTop.setCheckClassificationCode(prop.isPlainCheckClassificationCode());
    tmpTop.setUndefinedHandlingType(prop.getClassificationUndefinedHandlingType());
    // unsupported
    tmpTop.setCheckImplicitSet(false);
    tmpTop.setCheckSelectedClassification(prop.isCheckSelectedClassification());
    tmpTop.setForceClassificationSetting(prop.isForceClassificationSetting());
    return tmpTop;
}
Also used : DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop) DfLittleAdjustmentProperties(org.dbflute.properties.DfLittleAdjustmentProperties)

Aggregations

DfClassificationTop (org.dbflute.properties.assistant.classification.DfClassificationTop)38 DfClassificationElement (org.dbflute.properties.assistant.classification.DfClassificationElement)11 ArrayList (java.util.ArrayList)10 DfIllegalPropertySettingException (org.dbflute.exception.DfIllegalPropertySettingException)10 List (java.util.List)6 Map (java.util.Map)6 DfClassificationProperties (org.dbflute.properties.DfClassificationProperties)5 DfClassificationGroup (org.dbflute.properties.assistant.classification.DfClassificationGroup)5 LinkedHashMap (java.util.LinkedHashMap)4 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)4 DfRefClsElement (org.dbflute.properties.assistant.classification.refcls.DfRefClsElement)4 DfRefClsElement (org.dbflute.properties.assistant.classification.DfRefClsElement)3 DfRefClsReferredCDef (org.dbflute.properties.assistant.classification.refcls.DfRefClsReferredCDef)3 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 Collectors (java.util.stream.Collectors)2 DfFixedConditionInvalidClassificationEmbeddedCommentException (org.dbflute.exception.DfFixedConditionInvalidClassificationEmbeddedCommentException)2 StringKeyMap (org.dbflute.helper.StringKeyMap)2 ClassificationUndefinedHandlingType (org.dbflute.jdbc.ClassificationUndefinedHandlingType)2 DfClsElementLiteralArranger (org.dbflute.properties.assistant.classification.element.proploading.DfClsElementLiteralArranger)2