Search in sources :

Example 11 with DfSchemaXmlSerializer

use of org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlSerializer in project dbflute-core by dbflute.

the class DfLReverseSchemaMetaProvider method prepareDatabase.

// ===================================================================================
// Prepare
// =======
public Database prepareDatabase() {
    final String schemaXml = getReverseSchemaXml();
    final DfSchemaXmlSerializer serializer = createSchemaXmlSerializer(schemaXml);
    serializer.serialize();
    final DfSchemaXmlReader reader = createSchemaXmlReader(schemaXml);
    final AppData appData = reader.read();
    return appData.getDatabase();
}
Also used : AppData(org.apache.torque.engine.database.model.AppData) DfSchemaXmlSerializer(org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlSerializer) DfSchemaXmlReader(org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlReader)

Example 12 with DfSchemaXmlSerializer

use of org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlSerializer in project dbflute-core by dbflute.

the class DfAlterCheckProcess method serializeNextSchema.

// ===================================================================================
// Serialize Schema
// ================
protected void serializeNextSchema() {
    final String nextXml = getMigrationAlterCheckNextSchemaXml();
    final DfCraftDiffAssertDirection direction = DfCraftDiffAssertDirection.DIRECT_NEXT;
    final DfSchemaXmlSerializer serializer = createSchemaXmlSerializer(nextXml, direction);
    serializer.serialize();
}
Also used : DfSchemaXmlSerializer(org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlSerializer) DfCraftDiffAssertDirection(org.dbflute.logic.doc.craftdiff.DfCraftDiffAssertDirection)

Example 13 with DfSchemaXmlSerializer

use of org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlSerializer in project dbflute-core by dbflute.

the class DfAlterCheckProcess method createSchemaXmlSerializer.

protected DfSchemaXmlSerializer createSchemaXmlSerializer(String schemaXml, DfCraftDiffAssertDirection direction) {
    // no use history here (use SchemaDiff directly later)
    final String historyFile = null;
    final DfSchemaXmlSerializer serializer = DfSchemaXmlSerializer.createAsManage(_dataSource, schemaXml, historyFile);
    final String craftMetaDir = getMigrationAlterCheckCraftMetaDir();
    serializer.enableCraftDiff(_dataSource, craftMetaDir, direction);
    return serializer;
}
Also used : DfSchemaXmlSerializer(org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlSerializer)

Example 14 with DfSchemaXmlSerializer

use of org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlSerializer 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)

Example 15 with DfSchemaXmlSerializer

use of org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlSerializer in project dbflute-core by dbflute.

the class DfSchemaSyncChecker method serializeTargetSchema.

protected DfSchemaXmlSerializer serializeTargetSchema() {
    // as previous
    final DataSource targetDs = prepareTargetDataSource();
    final DfSchemaXmlSerializer targetSerializer = createTargetSerializer(targetDs);
    // same reason as main schema
    targetSerializer.suppressSchemaDiff();
    targetSerializer.serialize();
    return targetSerializer;
}
Also used : DfSchemaXmlSerializer(org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlSerializer) DfFittingDataSource(org.dbflute.helper.jdbc.connection.DfFittingDataSource) DataSource(javax.sql.DataSource)

Aggregations

DfSchemaXmlSerializer (org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlSerializer)15 DfCraftDiffAssertDirection (org.dbflute.logic.doc.craftdiff.DfCraftDiffAssertDirection)4 AppData (org.apache.torque.engine.database.model.AppData)3 DfSchemaXmlReader (org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlReader)3 DataSource (javax.sql.DataSource)1 Database (org.apache.torque.engine.database.model.Database)1 DfFittingDataSource (org.dbflute.helper.jdbc.connection.DfFittingDataSource)1 DfSPolicyChecker (org.dbflute.logic.doc.spolicy.DfSPolicyChecker)1 DfSPolicyResult (org.dbflute.logic.doc.spolicy.result.DfSPolicyResult)1 DfSchemaDiff (org.dbflute.logic.jdbc.schemadiff.DfSchemaDiff)1 DfReplaceSchemaProperties (org.dbflute.properties.DfReplaceSchemaProperties)1 DfSchemaPolicyProperties (org.dbflute.properties.DfSchemaPolicyProperties)1