Search in sources :

Example 1 with DfRefClsReferredCDef

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

the class DfRefClsLoadingHandler method registerRefClsReference.

// ===================================================================================
// Register Reference
// ==================
public void registerRefClsReference(String requestName, String clsTheme, List<DfClassificationTop> topList, Map<String, Object> optionMap) {
    if (!isOptionLastaFlute(optionMap)) {
        // only LastaFlute classifications can be referred (to be simple logic)
        return;
    }
    if (isOptionLastaDoc(optionMap)) {
        // LastaDoc uses real loader's registration (to avoid unexpected data use)
        return;
    }
    final Map<String, DfClassificationTop> clsTopMap = topList.stream().collect(Collectors.toMap(top -> top.getClassificationName(), top -> top));
    // not null here, already checked here
    final String cdefPackage = extractCDefPackage(optionMap);
    // me too
    final String cdefClassName = extractCDefClassName(optionMap);
    if (cdefPackage == null || cdefClassName == null) {
        // just in case
        throwRefClsReferenceCDefInfoNotFoundException(requestName, clsTheme, optionMap, cdefPackage, cdefClassName);
    }
    final DfRefClsReferredCDef referredCDef = new DfRefClsReferredCDef(cdefPackage, cdefClassName);
    DfRefClsReferenceRegistry.getInstance().registerReference(clsTheme, clsTopMap, referredCDef);
}
Also used : DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException) DfClassificationElement(org.dbflute.properties.assistant.classification.DfClassificationElement) DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop) DfRefClsReferredCDef(org.dbflute.properties.assistant.classification.refcls.DfRefClsReferredCDef) DfBuildProperties(org.dbflute.DfBuildProperties) DfBasicProperties(org.dbflute.properties.DfBasicProperties) Collectors(java.util.stream.Collectors) DfClassificationGroup(org.dbflute.properties.assistant.classification.DfClassificationGroup) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) List(java.util.List) Map(java.util.Map) Optional(java.util.Optional) DfRefClsElement(org.dbflute.properties.assistant.classification.refcls.DfRefClsElement) DfFreeGenResource(org.dbflute.logic.manage.freegen.DfFreeGenResource) Srl(org.dbflute.util.Srl) DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop) DfRefClsReferredCDef(org.dbflute.properties.assistant.classification.refcls.DfRefClsReferredCDef)

Example 2 with DfRefClsReferredCDef

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

the class DfRefClsLoadingHandler method createRefClsElement.

public DfRefClsElement createRefClsElement(String classificationName, Map<String, Object> elementMap, DfFreeGenResource resource) {
    // e.g. map:{ refCls=maihamadb@MemberStatus ; refType=included }
    final String refAttr = (String) elementMap.get(DfRefClsElement.KEY_REFCLS);
    // of e.g. DB or "appcls" or namedcls's name
    final String refClsTheme;
    // classification name
    final String refClsName;
    final String refGroupName;
    if (refAttr.contains("@")) {
        // #hope other schema's reference
        refClsTheme = Srl.substringFirstFront(refAttr, "@");
        final String rearName = Srl.substringFirstRear(refAttr, "@");
        if (rearName.contains(".")) {
            refClsName = Srl.substringFirstFront(rearName, ".");
            refGroupName = Srl.substringFirstRear(rearName, ".");
        } else {
            refClsName = rearName;
            refGroupName = null;
        }
    } else {
        // current DB as default
        refClsTheme = getBasicProperties().getProjectName();
        if (refAttr.contains(".")) {
            refClsName = Srl.substringFirstFront(refAttr, ".");
            refGroupName = Srl.substringFirstRear(refAttr, ".");
        } else {
            refClsName = refAttr;
            refGroupName = null;
        }
    }
    final String refType = extractRefType(classificationName, elementMap);
    final DfClassificationTop referredClsTop = findReferredClsTop(classificationName, refAttr, refClsTheme, refClsName, resource);
    final DfRefClsReferredCDef referredCDef = findReferredCDef(classificationName, refAttr, refClsTheme, refClsName, resource);
    final DfClassificationGroup referredGroup = findReferredGroup(classificationName, refAttr, refClsTheme, refClsName, refGroupName, referredClsTop, resource);
    final String resourceFile = resource.getResourceFile();
    return new DfRefClsElement(refClsTheme, refClsName, refGroupName, refType, referredClsTop, referredCDef, referredGroup, resourceFile);
}
Also used : DfClassificationGroup(org.dbflute.properties.assistant.classification.DfClassificationGroup) DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop) DfRefClsReferredCDef(org.dbflute.properties.assistant.classification.refcls.DfRefClsReferredCDef) DfRefClsElement(org.dbflute.properties.assistant.classification.refcls.DfRefClsElement)

Example 3 with DfRefClsReferredCDef

use of org.dbflute.properties.assistant.classification.refcls.DfRefClsReferredCDef 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)

Aggregations

DfClassificationTop (org.dbflute.properties.assistant.classification.DfClassificationTop)3 DfRefClsReferredCDef (org.dbflute.properties.assistant.classification.refcls.DfRefClsReferredCDef)3 DfClassificationGroup (org.dbflute.properties.assistant.classification.DfClassificationGroup)2 DfRefClsElement (org.dbflute.properties.assistant.classification.refcls.DfRefClsElement)2 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 DfBuildProperties (org.dbflute.DfBuildProperties)1 DfIllegalPropertySettingException (org.dbflute.exception.DfIllegalPropertySettingException)1 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)1 DfFreeGenResource (org.dbflute.logic.manage.freegen.DfFreeGenResource)1 DfBasicProperties (org.dbflute.properties.DfBasicProperties)1 DfClassificationElement (org.dbflute.properties.assistant.classification.DfClassificationElement)1 Srl (org.dbflute.util.Srl)1