Search in sources :

Example 21 with DfClassificationTop

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

the class DfAppClsTableLoader method findDBCls.

protected DfClassificationTop findDBCls(String classificationName, String refClsName, Map<String, DfClassificationTop> dbClsMap, DfFreeGenResource resource) {
    final DfClassificationTop refTop = dbClsMap.get(refClsName);
    if (refTop == null) {
        final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
        br.addNotice("Not found the DB classification for app classification.");
        br.addItem("Advice");
        br.addElement("Make sure your DB classification name.");
        br.addItem("AppCls");
        br.addElement(classificationName);
        br.addItem("NotFound DBCls");
        br.addElement(refClsName);
        br.addItem("Existing DBCls");
        br.addElement(dbClsMap.keySet());
        br.addItem("dfprop File");
        br.addElement(resource.getResourceFile());
        final String msg = br.buildExceptionMessage();
        throw new DfIllegalPropertySettingException(msg);
    }
    return refTop;
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException)

Example 22 with DfClassificationTop

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

the class DfWebClsTableLoader method createRefClsElement.

protected DfRefClsElement createRefClsElement(String classificationName, Map<String, Object> elementMap, Map<String, DfClassificationTop> dbClsMap, DfFreeGenResource resource) {
    final String refCls = (String) elementMap.get(DfRefClsElement.KEY_REFCLS);
    final String projectName;
    final String refClsName;
    final String groupName;
    if (refCls.contains("@")) {
        // #hope other schema's reference
        projectName = Srl.substringFirstFront(refCls, "@");
        final String rearName = Srl.substringFirstRear(refCls, "@");
        if (rearName.contains(".")) {
            refClsName = Srl.substringFirstFront(rearName, ".");
            groupName = Srl.substringFirstRear(rearName, ".");
        } else {
            refClsName = rearName;
            groupName = null;
        }
    } else {
        projectName = null;
        if (refCls.contains(".")) {
            refClsName = Srl.substringFirstFront(refCls, ".");
            groupName = Srl.substringFirstRear(refCls, ".");
        } else {
            refClsName = refCls;
            groupName = null;
        }
    }
    final String classificationType = buildClassificationType(refClsName);
    final String refType = (String) elementMap.get(DfRefClsElement.KEY_REFTYPE);
    if (refType == null) {
        String msg = "Not found the refType in refCls elementMap: " + classificationName + " " + elementMap;
        throw new DfIllegalPropertySettingException(msg);
    }
    final DfClassificationTop dbClsTop = findDBCls(classificationName, refClsName, dbClsMap, resource);
    return new DfRefClsElement(projectName, refClsName, classificationType, groupName, refType, dbClsTop);
}
Also used : DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException) DfRefClsElement(org.dbflute.properties.assistant.classification.DfRefClsElement)

Example 23 with DfClassificationTop

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

the class Column method hasCheckImplicitSetClassification.

protected boolean hasCheckImplicitSetClassification() {
    // old style
    if (!hasClassification()) {
        return false;
    }
    final String classificationName = getClassificationName();
    if (classificationName == null) {
        return false;
    }
    final DfClassificationProperties prop = getClassificationProperties();
    final DfClassificationTop classificationTop = prop.getClassificationTop(classificationName);
    return classificationTop != null && classificationTop.isCheckImplicitSet();
}
Also used : DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop) DfClassificationProperties(org.dbflute.properties.DfClassificationProperties)

Example 24 with DfClassificationTop

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

the class Column method getClassificationTop.

public DfClassificationTop getClassificationTop() {
    final Map<String, DfClassificationTop> definitionMap = getClassificationTopMap();
    final String classificationName = getClassificationName();
    final DfClassificationTop classificationTop = definitionMap.get(classificationName);
    if (classificationTop == null) {
        throwClassificationDeploymentClassificationNotFoundException(classificationName);
    }
    return classificationTop;
}
Also used : DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop)

Example 25 with DfClassificationTop

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

the class DfAppClsTableLoader method loadTable.

// ===================================================================================
// Load Table
// ==========
// ; resourceMap = map:{
// ; baseDir = ../src/main
// ; resourceType = APP_CLS
// ; resourceFile = ../../../dockside_appcls.properties
// }
// ; outputMap = map:{
// ; templateFile = LaAppCDef.vm
// ; outputDirectory = $$baseDir$$/java
// ; package = org.dbflute...
// ; className = unused
// }
// ; optionMap = map:{
// }
@Override
public DfFreeGenMetaData loadTable(String requestName, DfFreeGenResource resource, DfFreeGenMapProp mapProp) {
    final String resourceFile = resource.getResourceFile();
    final Map<String, Object> appClsMap = readAppClsMap(resourceFile);
    boolean hasRefCls = false;
    final DfClassificationProperties clsProp = getClassificationProperties();
    final DfClsElementLiteralArranger literalArranger = new DfClsElementLiteralArranger();
    final List<DfClassificationTop> topList = new ArrayList<DfClassificationTop>();
    for (Entry<String, Object> entry : appClsMap.entrySet()) {
        final String classificationName = entry.getKey();
        final DfClassificationTop classificationTop = new DfClassificationTop(classificationName);
        topList.add(classificationTop);
        DfRefClsElement refClsElement = null;
        @SuppressWarnings("unchecked") final List<Map<String, Object>> elementMapList = (List<Map<String, Object>>) entry.getValue();
        for (Map<String, Object> elementMap : elementMapList) {
            if (isElementMapTop(elementMap)) {
                // e.g. map:{ topComment=... ; codeType=String }
                classificationTop.acceptBasicItem(elementMap);
                classificationTop.putGroupingAll(clsProp.getElementMapGroupingMap(elementMap));
                classificationTop.putDeprecatedAll(clsProp.getElementMapDeprecatedMap(elementMap));
            } else {
                if (isElementMapRefCls(elementMap)) {
                    // e.g. map:{ refCls=maihamadb@MemberStatus ; refType=included }
                    refClsElement = arrangeRefCls(resource, classificationName, classificationTop, refClsElement, elementMap);
                } else {
                    // e.g. map:{ code=FML ; name=OneMan ; alias=ShowBase ; comment=Formalized }
                    arrangeLiteral(resource, classificationName, classificationTop, refClsElement, elementMap, literalArranger);
                }
            }
        }
        if (refClsElement != null) {
            // should be after all literal evaluation
            inheritRefClsGroup(classificationTop, refClsElement);
            refClsElement.verifyRelationshipByRefTypeIfNeeds(classificationTop);
            hasRefCls = true;
        }
    }
    final Map<String, Object> optionMap = mapProp.getOptionMap();
    // basically exists
    final String clsTheme = (String) optionMap.getOrDefault("clsTheme", getDefaultClsTheme());
    setupOptionMap(optionMap, topList, hasRefCls, clsTheme);
    // @since 1.2.5
    stopRedundantCommentIfNeeds(requestName, resourceFile, topList, optionMap);
    // for next appcls's refCls @since 1.2.5
    registerRefClsReference(requestName, clsTheme, topList, optionMap);
    // #for_now can be flexible? (table name is unused?)
    return DfFreeGenMetaData.asOnlyOne(optionMap, clsTheme, Collections.emptyList());
}
Also used : ArrayList(java.util.ArrayList) DfRefClsElement(org.dbflute.properties.assistant.classification.refcls.DfRefClsElement) DfClsElementLiteralArranger(org.dbflute.properties.assistant.classification.element.proploading.DfClsElementLiteralArranger) DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) DfClassificationProperties(org.dbflute.properties.DfClassificationProperties)

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