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;
}
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);
}
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();
}
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;
}
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());
}
Aggregations