Search in sources :

Example 1 with DfClassificationTop

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

the class ForeignKey method extractFixedConditionEmbeddedCommentClassification.

// -----------------------------------------------------
// EmbeddedComment Classification
// ------------------------------
protected String extractFixedConditionEmbeddedCommentClassification(String peace, String parameterType) {
    // parameterType is e.g. MemberStatus.Formalized
    if (!parameterType.contains(".")) {
        String msg = "The classification expression should be 'classificationName.elementName':";
        msg = msg + " expression=" + parameterType + " embeddedComment=" + peace;
        throw new DfFixedConditionInvalidClassificationEmbeddedCommentException(msg);
    }
    // e.g. MemberStatus
    final String classificationName = parameterType.substring(0, parameterType.indexOf("."));
    // e.g. Formalized
    final String elementName = parameterType.substring(parameterType.indexOf(".") + ".".length());
    final Map<String, DfClassificationTop> topMap = getClassificationProperties().getClassificationTopMap();
    final DfClassificationTop classificationTop = topMap.get(classificationName);
    if (classificationTop == null) {
        throwFixedConditionEmbeddedCommentClassificationNotFoundException(classificationName);
    }
    String code = doExtractFixedConditionEmbeddedCommentClassificationNormalCode(classificationTop, elementName);
    if (code != null) {
        return code;
    }
    // may be group here
    code = doExtractFixedConditionEmbeddedCommentClassificationGroupCode(classificationTop, elementName);
    if (code != null) {
        return code;
    }
    throwFixedConditionEmbeddedCommentClassificationElementNotFoundException(classificationTop, elementName);
    // unreachable
    return null;
}
Also used : DfFixedConditionInvalidClassificationEmbeddedCommentException(org.dbflute.exception.DfFixedConditionInvalidClassificationEmbeddedCommentException) DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop)

Example 2 with DfClassificationTop

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

the class DfClassificationProperties method extractClassificationResource.

protected List<DfClassificationTop> extractClassificationResource() {
    final DfClassificationResourceAnalyzer analyzer = new DfClassificationResourceAnalyzer();
    final String dirBaseName = "./dfprop";
    final String resource = NAME_CLASSIFICATION_RESOURCE;
    final String extension = "dfprop";
    if (isSpecifiedEnvironmentType()) {
        final String dirEnvName = dirBaseName + "/" + getEnvironmentType();
        final List<DfClassificationTop> ls = analyzer.analyze(dirEnvName, resource, extension);
        if (!ls.isEmpty()) {
            return ls;
        }
        return analyzer.analyze(dirBaseName, resource, extension);
    } else {
        return analyzer.analyze(dirBaseName, resource, extension);
    }
}
Also used : DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop) DfClassificationResourceAnalyzer(org.dbflute.properties.assistant.classification.DfClassificationResourceAnalyzer)

Example 3 with DfClassificationTop

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

the class DfClassificationProperties method createAllInOneTableClassificationTop.

protected DfClassificationTop createAllInOneTableClassificationTop(final String classificationName) {
    final DfClassificationTop tmpTop = new DfClassificationTop();
    tmpTop.setClassificationName(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)

Example 4 with DfClassificationTop

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

the class DfAppClsTableLoader 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 5 with DfClassificationTop

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

the class DfAppClsTableLoader method handleRefCls.

protected void handleRefCls(DfClassificationTop classificationTop, DfRefClsElement refClsElement) {
    refClsElement.checkFormalRefType(classificationTop);
    classificationTop.addRefClsElement(refClsElement);
    if (refClsElement.isRefTypeIncluded()) {
        final DfClassificationTop dbClsTop = refClsElement.getDBClsTop();
        final String groupName = refClsElement.getGroupName();
        if (groupName != null) {
            final DfClassificationGroup group = dbClsTop.getGroupList().stream().filter(gr -> {
                return gr.getGroupName().equals(groupName);
            }).findFirst().orElseThrow(() -> {
                String msg = "Not found the group name: " + refClsElement.getClassificationName() + "." + groupName;
                return new DfIllegalPropertySettingException(msg);
            });
            classificationTop.addClassificationElementAll(group.getElementList());
        } else {
            final List<DfClassificationElement> dbElementList = dbClsTop.getClassificationElementList();
            classificationTop.addClassificationElementAll(dbElementList);
            classificationTop.acceptGroupList(dbClsTop.getGroupList());
        }
    }
}
Also used : DfClassificationGroup(org.dbflute.properties.assistant.classification.DfClassificationGroup) DfClassificationElement(org.dbflute.properties.assistant.classification.DfClassificationElement) DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException)

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