Search in sources :

Example 1 with DfSPolicyChecker

use of org.dbflute.logic.doc.spolicy.DfSPolicyChecker in project dbflute-core by dbflute.

the class TorqueDocumentationTask method processSchemaPolicyCheck.

// -----------------------------------------------------
// SchemaPolicyCheck
// -----------------
protected void processSchemaPolicyCheck() {
    if (_schemaData == null) {
        throw new IllegalStateException("SchemaPolicyCheck should be before making SchemaHTML because of schema data.");
    }
    final DfSchemaPolicyProperties prop = getSchemaPolicyCheckProperties();
    final DfSPolicyChecker checker = prop.createChecker(_schemaData.getDatabase(), () -> prepareCoreSchemaDiffList());
    // not ending yet (ending after SchemaHTML)
    _schemaPolicyResult = checker.checkPolicyIfNeeds();
}
Also used : DfSPolicyChecker(org.dbflute.logic.doc.spolicy.DfSPolicyChecker) DfSchemaPolicyProperties(org.dbflute.properties.DfSchemaPolicyProperties)

Example 2 with DfSPolicyChecker

use of org.dbflute.logic.doc.spolicy.DfSPolicyChecker in project dbflute-core by dbflute.

the class DfSPolicyInRepsChecker method checkSchemaPolicyInRepsIfNeeds.

// ===================================================================================
// Check
// =====
public boolean checkSchemaPolicyInRepsIfNeeds() {
    // returns check executed or not
    final DfReplaceSchemaProperties repsProp = getReplaceSchemaProperties();
    if (!repsProp.isCheckSchemaPolicyInReps()) {
        return false;
    }
    final DfSchemaPolicyProperties policyProp = getSchemaPolicyProperties();
    if (!policyProp.hasPolicy()) {
        return false;
    }
    _log.info("");
    _log.info("* * * * * * * * * * * *");
    _log.info("*                     *");
    _log.info("*    Schema Policy    *");
    _log.info("*                     *");
    _log.info("* * * * * * * * * * * *");
    final String schemaXml = repsProp.getSchemaPolicyInRepsSchemaXml();
    deleteTemporarySchemaXmlIfExists(schemaXml);
    final DfSchemaXmlSerializer serializer = createSchemaXmlSerializer(schemaXml);
    serializer.serialize();
    try {
        final DfSchemaXmlReader reader = createSchemaXmlReader(schemaXml);
        final AppData appData = reader.read();
        final Database database = appData.getDatabase();
        // for e.g. "then classification"
        initializeSupplementaryMetaData(database);
        final DfSPolicyChecker checker = createChecker(policyProp, database);
        final DfSPolicyResult policyResult = checker.checkPolicyIfNeeds();
        if (policyResult == null) {
            // no way already checked, just in case
            return false;
        }
        // immediately handles violation (may be throw)
        policyResult.ending();
    } finally {
        deleteTemporarySchemaXmlIfExists(schemaXml);
    }
    return true;
}
Also used : DfSPolicyChecker(org.dbflute.logic.doc.spolicy.DfSPolicyChecker) DfReplaceSchemaProperties(org.dbflute.properties.DfReplaceSchemaProperties) AppData(org.apache.torque.engine.database.model.AppData) DfSPolicyResult(org.dbflute.logic.doc.spolicy.result.DfSPolicyResult) Database(org.apache.torque.engine.database.model.Database) DfSchemaXmlSerializer(org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlSerializer) DfSchemaPolicyProperties(org.dbflute.properties.DfSchemaPolicyProperties) DfSchemaXmlReader(org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlReader)

Aggregations

DfSPolicyChecker (org.dbflute.logic.doc.spolicy.DfSPolicyChecker)2 DfSchemaPolicyProperties (org.dbflute.properties.DfSchemaPolicyProperties)2 AppData (org.apache.torque.engine.database.model.AppData)1 Database (org.apache.torque.engine.database.model.Database)1 DfSPolicyResult (org.dbflute.logic.doc.spolicy.result.DfSPolicyResult)1 DfSchemaXmlReader (org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlReader)1 DfSchemaXmlSerializer (org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlSerializer)1 DfReplaceSchemaProperties (org.dbflute.properties.DfReplaceSchemaProperties)1