use of org.dbflute.exception.DfIllegalPropertySettingException in project dbflute-core by dbflute.
the class DfAppClsTableLoader method assertRefClsOnlyOne.
protected void assertRefClsOnlyOne(String classificationName, DfRefClsElement refClsElement, Map<String, Object> elementMap, DfFreeGenResource resource) {
if (refClsElement != null) {
// only-one refCls is supported #for_now
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Duplicate refCls in the app classification.");
br.addItem("Advice");
br.addElement("Only-one refCls is supported in one app classification.");
br.addItem("AppCls");
br.addElement(classificationName);
br.addItem("Existing refCls");
br.addElement(refClsElement);
br.addItem("Duplicate refCls");
br.addElement(elementMap);
br.addItem("dfprop File");
br.addElement(resource.getResourceFile());
final String msg = br.buildExceptionMessage();
throw new DfIllegalPropertySettingException(msg);
}
}
use of org.dbflute.exception.DfIllegalPropertySettingException in project dbflute-core by dbflute.
the class DfWebClsTableLoader method assertRefClsOnlyOne.
protected void assertRefClsOnlyOne(String classificationName, DfRefClsElement refClsElement, Map<String, Object> elementMap, DfFreeGenResource resource) {
if (refClsElement != null) {
// only-one refCls is supported #for_now
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Duplicate refCls in the web classification.");
br.addItem("Advice");
br.addElement("Only-one refCls is supported in one web classification.");
br.addItem("WebCls");
br.addElement(classificationName);
br.addItem("Existing refCls");
br.addElement(refClsElement);
br.addItem("Duplicate refCls");
br.addElement(elementMap);
br.addItem("dfprop File");
br.addElement(resource.getResourceFile());
final String msg = br.buildExceptionMessage();
throw new DfIllegalPropertySettingException(msg);
}
}
use of org.dbflute.exception.DfIllegalPropertySettingException 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.exception.DfIllegalPropertySettingException in project dbflute-core by dbflute.
the class DfRefClsElement method checkRefMatches.
protected void checkRefMatches(DfClassificationTop classificationTop) {
final List<DfClassificationElement> webElementList = classificationTop.getClassificationElementList();
final List<DfClassificationElement> dbElementList = _dbClsTop.getClassificationElementList();
final boolean hasNonExisting = webElementList.stream().anyMatch(webElement -> {
return !dbElementList.stream().anyMatch(dbElement -> {
return webElement.getCode().equals(dbElement.getCode());
});
});
if (webElementList.size() != dbElementList.size() || hasNonExisting) {
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Unmatched the web classification code with the DB classification");
br.addItem("Advice");
br.addElement("The codes of the web classification should match");
br.addElement("with DB classification because of refType='matches'.");
br.addElement("For example:");
br.addElement(" (x): web(A), db(A, C)");
br.addElement(" (x): web(A, B), db(A, C)");
br.addElement(" (o): web(A, B), db(A, B)");
br.addElement(" (o): web(A, B, C), db(A, B, C)");
br.addItem("WebCls");
final String webCodes = classificationTop.getClassificationElementList().stream().map(element -> {
return element.getCode();
}).collect(Collectors.joining(", "));
br.addElement(classificationTop.getClassificationName() + ": " + webCodes);
br.addItem("DBCls");
final String dbCodes = _dbClsTop.getClassificationElementList().stream().map(element -> {
return element.getCode();
}).collect(Collectors.joining(", "));
br.addElement(_dbClsTop.getClassificationName() + ": " + dbCodes);
br.addItem("Ref Type");
br.addElement(_refType);
br.addItem("Code Count");
br.addElement("web=" + webElementList.size() + " / db=" + dbElementList.size());
final String msg = br.buildExceptionMessage();
throw new DfIllegalPropertySettingException(msg);
}
}
use of org.dbflute.exception.DfIllegalPropertySettingException in project dbflute-core by dbflute.
the class DfRefClsElement method checkFormalRefType.
// ===================================================================================
// Check by RefType
// ================
public void checkFormalRefType(DfClassificationTop classificationTop) {
if (isRefTypeIncluded() || isRefTypeExists() || isRefTypeMatches()) {
return;
}
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Unknown refType to DB classification in the web classification.");
br.addItem("Advice");
br.addElement("refType can be set: 'included', 'exists', 'matches'");
br.addElement(" included : DB classification codes are included as web classification");
br.addElement(" exists : web classification codes should exist in DB classification");
br.addElement(" matches : web classification codes matches with DB classification");
br.addItem("WebCls");
br.addElement(classificationTop.getClassificationName());
br.addItem("Unknown refType");
br.addElement(_refType);
final String msg = br.buildExceptionMessage();
throw new DfIllegalPropertySettingException(msg);
}
Aggregations