use of org.dbflute.exception.DfIllegalPropertySettingException in project dbflute-core by dbflute.
the class DfClassificationProperties method getClassificationDefinitionMap.
// -----------------------------------------------------
// Native Definition
// -----------------
/**
* Get the map of classification definition.
* @return The map of classification definition. (NotNull)
*/
protected Map<String, DfClassificationTop> getClassificationDefinitionMap() {
if (_classificationTopMap != null) {
return _classificationTopMap;
}
_classificationTopMap = newLinkedHashMap();
final Map<String, Object> plainDefinitionMap;
{
final String mapName = KEY_classificationDefinitionMap;
final String propKey = "torque." + mapName;
plainDefinitionMap = resolveSplit(mapName, mapProp(propKey, DEFAULT_EMPTY_MAP));
}
final DfClsElementLiteralArranger literalArranger = new DfClsElementLiteralArranger();
String allInOneSql = null;
Connection conn = null;
try {
for (Entry<String, Object> entry : plainDefinitionMap.entrySet()) {
final String classificationName = entry.getKey();
final Object objValue = entry.getValue();
// handle special elements
if (classificationName.equalsIgnoreCase("$$SQL$$")) {
allInOneSql = (String) objValue;
continue;
}
// check duplicate classification
if (_classificationTopMap.containsKey(classificationName)) {
String msg = "Duplicate classification: " + classificationName;
throw new DfIllegalPropertySettingException(msg);
}
final DfClassificationTop classificationTop = new DfClassificationTop(classificationName);
_classificationTopMap.put(classificationName, classificationTop);
// handle classification elements
if (!(objValue instanceof List<?>)) {
throwClassificationMapValueIllegalListTypeException(objValue);
}
final List<?> plainList = (List<?>) objValue;
final List<DfClassificationElement> elementList = new ArrayList<DfClassificationElement>();
boolean tableClassification = false;
for (Object element : plainList) {
if (!(element instanceof Map<?, ?>)) {
throwClassificationListElementIllegalMapTypeException(element);
}
@SuppressWarnings("unchecked") final Map<String, Object> elementMap = (Map<String, Object>) element;
// from table
final String table = (String) elementMap.get(DfClassificationElement.KEY_TABLE);
if (Srl.is_NotNull_and_NotTrimmedEmpty(table)) {
tableClassification = true;
if (conn == null) {
// on demand
conn = createMainSchemaConnection();
}
arrangeTableClassification(classificationTop, elementMap, table, elementList, conn);
continue;
}
// from literal
if (isElementMapClassificationTop(elementMap)) {
// top definition
arrangeClassificationTopFromLiteral(classificationTop, elementMap);
} else {
literalArranger.arrange(classificationName, elementMap);
final DfClassificationElement classificationElement = new DfClassificationElement();
classificationElement.setClassificationName(classificationName);
classificationElement.acceptBasicItemMap(elementMap);
elementList.add(classificationElement);
}
}
// adjust classification top
classificationTop.addClassificationElementAll(elementList);
classificationTop.setTableClassification(tableClassification);
_classificationTopMap.put(classificationName, classificationTop);
}
if (allInOneSql != null) {
if (conn == null) {
// on demand
conn = createMainSchemaConnection();
}
arrangeAllInOneTableClassification(conn, allInOneSql);
}
// *Classification Resource Point!
reflectClassificationResourceToDefinition();
filterUseDocumentOnly();
verifyClassificationConstraintsIfNeeds();
prepareSuppressedDBAccessClassTableSet();
} finally {
new DfClassificationJdbcCloser().closeConnection(conn);
}
return _classificationTopMap;
}
use of org.dbflute.exception.DfIllegalPropertySettingException in project dbflute-core by dbflute.
the class DfRefClsRefTypeVerifier method verifyFormalRefType.
// ===================================================================================
// Verify Formal RefType
// =====================
public void verifyFormalRefType(DfClassificationTop classificationTop) {
if (_refType.isFormalRefType()) {
return;
}
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Unknown refType to referred classification in the app classification.");
br.addItem("Advice");
br.addElement("refType can be set: 'included', 'exists', 'matches'");
br.addElement(" included : referred classification codes are included as app classification");
br.addElement(" exists : app classification codes should exist in referred classification");
br.addElement(" matches : app classification codes matches with referred classification");
br.addItem("dfprop File");
br.addElement(_resourceFile);
br.addItem("AppCls");
br.addElement(classificationTop.getClassificationName());
br.addItem("Unknown refType");
br.addElement(_refType);
final String msg = br.buildExceptionMessage();
throw new DfIllegalPropertySettingException(msg);
}
use of org.dbflute.exception.DfIllegalPropertySettingException in project dbflute-core by dbflute.
the class DfRefClsRefTypeVerifier method doVerifyRefMatches.
// -----------------------------------------------------
// Matches
// -------
protected void doVerifyRefMatches(DfClassificationTop classificationTop) {
final List<DfClassificationElement> appElementList = classificationTop.getClassificationElementList();
final List<DfClassificationElement> referredElementList = _referredElementList;
final boolean hasNonExisting = appElementList.stream().anyMatch(appElement -> {
return notMatchesReferredElement(referredElementList, appElement);
});
if (appElementList.size() != referredElementList.size() || hasNonExisting) {
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Unmatched the web classification code with the referred classification");
br.addItem("Advice");
br.addElement("The codes of the web classification should match");
br.addElement("with referred classification because of refType='matches'.");
br.addElement("For example:");
br.addElement(" (x): web(A), referred(A, C)");
br.addElement(" (x): web(A, B), referred(A, C)");
br.addElement(" (o): web(A, B), referred(A, B)");
br.addElement(" (o): web(A, B, C), referred(A, B, C)");
br.addItem("dfprop File");
br.addElement(_resourceFile);
br.addItem("AppCls");
br.addElement(classificationTop.getClassificationName() + ": " + buildClsCodesExp(appElementList));
br.addItem("ReferredCls");
br.addElement(buildReferredExp() + ": " + buildClsCodesExp(referredElementList));
br.addItem("Ref Type");
br.addElement(_refType);
br.addItem("Code Count");
br.addElement("app=" + appElementList.size() + " / referred=" + referredElementList.size());
final String msg = br.buildExceptionMessage();
throw new DfIllegalPropertySettingException(msg);
}
}
use of org.dbflute.exception.DfIllegalPropertySettingException in project dbflute-core by dbflute.
the class DfClassificationResourceDefinitionReflector method throwClassificationAlreadyExistsInDfPropException.
protected void throwClassificationAlreadyExistsInDfPropException(String classificationName, String settingName) {
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("The classification already exists in dfprop settings.");
br.addItem("Advice");
br.addElement("Check the classification names in '" + settingName + "' settings.");
br.addElement("The settings may contain classifications existing in dfprop.");
br.addItem("Classification");
br.addElement(classificationName);
final String msg = br.buildExceptionMessage();
throw new DfIllegalPropertySettingException(msg);
}
use of org.dbflute.exception.DfIllegalPropertySettingException in project dbflute-core by dbflute.
the class DfSplittingDfpropHandler method throwClassificationSplitDefinitionNotFoundException.
protected void throwClassificationSplitDefinitionNotFoundException(String mapName, String keyword) {
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Not found the split definition of DBFlute property.");
br.addItem("Advice");
br.addElement("Make sure the file name of your split dfprop");
br.addElement("or define at least one definition in the split file.");
br.addElement("");
br.addElement("For example:");
br.addElement(" $$split$$ = map:{");
br.addElement(" ; land = dummy");
br.addElement(" ; sea = dummy");
br.addElement(" }");
br.addElement("");
br.addElement("The following files should exist:");
br.addElement(" dfprop/" + mapName + "_land.dfprop");
br.addElement(" dfprop/" + mapName + "_sea.dfprop");
br.addItem("DBFlute Property");
br.addElement(mapName);
br.addItem("Split Keyword");
br.addElement(keyword);
final String msg = br.buildExceptionMessage();
throw new DfIllegalPropertySettingException(msg);
}
Aggregations