use of org.dbflute.properties.DfClassificationProperties in project dbflute-core by dbflute.
the class DfClassificationPropertiesTest method test_isTableClassificationSuppressAutoDeploy.
public void test_isTableClassificationSuppressAutoDeploy() {
// ## Arrange ##
final Map<String, Map<String, String>> deploymentMap = new LinkedHashMap<String, Map<String, String>>();
final DfClassificationProperties prop = createClassificationProperties(deploymentMap);
final Map<String, String> elementMap = new HashMap<String, String>();
// ## Act & Assert ##
assertFalse(prop.isElementMapSuppressAutoDeploy(elementMap));
elementMap.put("suppressAutoDeploy", "false");
assertFalse(prop.isElementMapSuppressAutoDeploy(elementMap));
elementMap.put("suppressAutoDeploy", "true");
assertTrue(prop.isElementMapSuppressAutoDeploy(elementMap));
elementMap.put("suppressAutoDeploy", "True");
assertTrue(prop.isElementMapSuppressAutoDeploy(elementMap));
}
use of org.dbflute.properties.DfClassificationProperties in project dbflute-core by dbflute.
the class DfSPolicyInRepsChecker method initializeClassificationDeployment.
protected void initializeClassificationDeployment(final Database database) {
final DfClassificationProperties clsProp = getClassificationProperties();
clsProp.initializeClassificationDeployment(database);
}
use of org.dbflute.properties.DfClassificationProperties 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.DfClassificationProperties 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());
}
use of org.dbflute.properties.DfClassificationProperties in project dbflute-core by dbflute.
the class DfImplicitClassificationChecker method check.
public void check(File file, String tableDbName, String columnDbName, Connection conn) throws SQLException {
final DfClassificationProperties prop = getClassificationProperties();
final String classificationName = prop.getClassificationName(tableDbName, columnDbName);
final DfClassificationTop classificationTop = prop.getClassificationTop(classificationName);
if (classificationTop == null) {
// no way (just in case)
return;
}
if (classificationTop.isTableClassification()) {
// basically checked by FK constraint
return;
}
if (!classificationTop.isCheckClassificationCode() && !classificationTop.isCheckImplicitSet()) {
// no option
return;
}
final ClassificationUndefinedHandlingType undefinedHandlingType = classificationTop.getUndefinedHandlingType();
if (undefinedHandlingType == null) {
// no way (just in case)
return;
}
if (!undefinedHandlingType.isChecked()) {
// no handling option
return;
}
final boolean quote = prop.isCodeTypeNeedsQuoted(classificationName);
final List<String> codeList = prop.getClassificationElementCodeList(classificationName);
final String sql = buildDistinctSql(tableDbName, columnDbName, quote, codeList);
PreparedStatement ps = null;
ResultSet rs = null;
try {
_log.info(sql);
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
final List<String> illegalCodeList = new ArrayList<String>();
while (rs.next()) {
illegalCodeList.add(rs.getString(1));
}
if (!illegalCodeList.isEmpty()) {
handleLoadDataIllegalImplicitClassificationValueException(file, tableDbName, columnDbName, classificationName, codeList, illegalCodeList, undefinedHandlingType);
}
} finally {
if (rs != null) {
rs.close();
}
if (ps != null) {
ps.close();
}
}
}
Aggregations