use of org.dbflute.exception.DfIllegalPropertySettingException in project dbflute-core by dbflute.
the class DfAbstractHelperProperties method throwDfPropDefinitionDuplicateDefinitionException.
protected void throwDfPropDefinitionDuplicateDefinitionException(String mapName, String elementName, String keyword) {
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Found the duplicate definition.");
br.addItem("Advice");
br.addElement("The element names should be unique.");
br.addElement("(in all split files if split)");
br.addElement("For example:");
br.addElement(" (x):");
br.addElement(" Sea = map:{");
br.addElement(" ; ...");
br.addElement(" }");
br.addElement(" Sea = map:{");
br.addElement(" ; ...");
br.addElement(" }");
br.addElement(" (o):");
br.addElement(" Land = map:{");
br.addElement(" ; ...");
br.addElement(" }");
br.addElement(" Sea = map:{");
br.addElement(" ; ...");
br.addElement(" }");
br.addItem("DBFlute Property");
br.addElement(mapName);
if (keyword != null) {
br.addItem("Duplicate Found Location");
br.addElement(keyword);
}
br.addItem("Duplicate Name");
br.addElement(elementName);
final String msg = br.buildExceptionMessage();
throw new DfIllegalPropertySettingException(msg);
}
use of org.dbflute.exception.DfIllegalPropertySettingException in project dbflute-core by dbflute.
the class DfClassificationProperties method throwUnknownClassificationUndefinedCodeHandlingTypeException.
protected void throwUnknownClassificationUndefinedCodeHandlingTypeException(String code) {
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Unknown handling type of classification undefined code.");
br.addItem("Advice");
br.addElement("You can specify following types:");
for (ClassificationUndefinedHandlingType handlingType : ClassificationUndefinedHandlingType.values()) {
br.addElement(" " + handlingType.code());
}
final String exampleCode = ClassificationUndefinedHandlingType.EXCEPTION.code();
br.addElement("");
br.addElement("For example: (classificationDefinitionMap.dfprop)");
br.addElement("; [classification-name] = list:{");
br.addElement(" ; map:{");
br.addElement(" ; topComment=...");
br.addElement(" ; codeType=String");
br.addElement(" ; classificationUndefinedCodeHandlingType = " + exampleCode);
br.addElement(" ...");
br.addElement(" }");
br.addElement("}");
br.addItem("Specified Unknown Type");
br.addElement(code);
final String msg = br.buildExceptionMessage();
throw new DfIllegalPropertySettingException(msg);
}
use of org.dbflute.exception.DfIllegalPropertySettingException 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);
}
use of org.dbflute.exception.DfIllegalPropertySettingException 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());
}
}
}
use of org.dbflute.exception.DfIllegalPropertySettingException in project dbflute-core by dbflute.
the class DfWebClsTableLoader method loadTable.
// ===================================================================================
// Load Table
// ==========
// ; resourceMap = map:{
// ; baseDir = ../src/main
// ; resourceType = WEB_CLS
// ; resourceFile = ../../../dockside_webcls.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) {
// _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
// very similar to AppCls but no recycle because of silent maintenance
// _/_/_/_/_/_/_/_/_/_/
final String resourceFile = resource.getResourceFile();
final Map<String, Object> webclsMap;
try {
webclsMap = new MapListFile().readMap(new FileInputStream(resourceFile));
} catch (FileNotFoundException e) {
throw new DfIllegalPropertySettingException("Not found the dfprop file: " + resourceFile, e);
} catch (IOException e) {
throw new DfIllegalPropertySettingException("Cannot read the the dfprop file: " + resourceFile, e);
}
// lazy load because it might be unused
Map<String, DfClassificationTop> dbClsMap = null;
boolean hasRefCls = false;
final DfClassificationProperties clsProp = getClassificationProperties();
final DfClassificationLiteralArranger literalArranger = new DfClassificationLiteralArranger();
final List<DfClassificationTop> topList = new ArrayList<DfClassificationTop>();
for (Entry<String, Object> entry : webclsMap.entrySet()) {
final String classificationName = entry.getKey();
final DfClassificationTop classificationTop = new DfClassificationTop();
topList.add(classificationTop);
classificationTop.setClassificationName(classificationName);
DfRefClsElement refClsElement = null;
@SuppressWarnings("unchecked") final List<Map<String, Object>> elementMapList = (List<Map<String, Object>>) entry.getValue();
for (Map<String, Object> elementMap : elementMapList) {
if (isElementMapClassificationTop(elementMap)) {
classificationTop.acceptClassificationTopBasicItemMap(elementMap);
// pickup from DfClassificationProperties@processClassificationTopFromLiteralIfNeeds()
classificationTop.putGroupingAll(clsProp.getElementMapGroupingMap(elementMap));
classificationTop.putDeprecatedAll(clsProp.getElementMapDeprecatedMap(elementMap));
} else {
if (isElementMapRefCls(elementMap)) {
assertRefClsOnlyOne(classificationName, refClsElement, elementMap, resource);
if (dbClsMap == null) {
dbClsMap = getClassificationProperties().getClassificationTopMap();
}
refClsElement = createRefClsElement(classificationName, elementMap, dbClsMap, resource);
handleRefCls(classificationTop, refClsElement);
} else {
literalArranger.arrange(classificationName, elementMap);
final DfClassificationElement element = new DfClassificationElement();
element.setClassificationName(classificationName);
element.acceptBasicItemMap(elementMap);
classificationTop.addClassificationElement(element);
}
}
}
if (refClsElement != null) {
refClsElement.checkRelationshipByRefTypeIfNeeds(classificationTop);
hasRefCls = true;
}
}
final Map<String, Object> optionMap = mapProp.getOptionMap();
final String clsTheme = "webcls";
optionMap.put("clsTheme", clsTheme);
optionMap.put("classificationTopList", topList);
optionMap.put("classificationNameList", topList.stream().map(top -> {
return top.getClassificationName();
}).collect(Collectors.toList()));
optionMap.put("hasRefCls", hasRefCls);
optionMap.put("allcommonPackage", getBasicProperties().getBaseCommonPackage());
return DfFreeGenMetaData.asOnlyOne(optionMap, clsTheme, Collections.emptyList());
}
Aggregations