use of org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlReader 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;
}
use of org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlReader in project dbflute-core by dbflute.
the class DfSchemaDiff method loadNextSchema.
public void loadNextSchema() {
// }
if (_previousDb == null) {
// always exists after loadPreviousSchema() even if first time
String msg = "You should not call this because of previous not loaded.";
throw new IllegalStateException(msg);
}
final DfSchemaXmlReader reader = _nextReader;
try {
_nextDb = reader.read().getDatabase();
} catch (RuntimeException e) {
_loadingFailure = true;
handleReadingException(e, reader);
}
_diffDate = DBFluteSystem.currentDate();
final int nextTableCount = _nextDb.getTableList().size();
_tableCountDiff = createNextPreviousDiff(nextTableCount, _previousTableCount);
setupDocumentAuthorOfNextSchema();
}
use of org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlReader in project dbflute-core by dbflute.
the class DfSchemaDiff method createAsAlterCheck.
public static DfSchemaDiff createAsAlterCheck(String previousXml, String nextXml) {
final DfSchemaXmlReader previousReader = DfSchemaXmlReader.createAsFlexibleToManage(previousXml);
final DfSchemaXmlReader nextReader = DfSchemaXmlReader.createAsFlexibleToManage(nextXml);
return prepareDiffOption(newReader(previousReader, nextReader));
}
use of org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlReader in project dbflute-core by dbflute.
the class DfSchemaDiff method loadPreviousSchema.
// ===================================================================================
// Load Schema
// ===========
public void loadPreviousSchema() {
// before loading next schema
final DfSchemaXmlReader reader = _previousReader;
if (!reader.exists()) {
_firstTime = true;
// to make history of the first time @since 1.1.9
// dummy database (has no object, can return empty)
_previousDb = new Database();
// fixedly no table
_previousTableCount = 0;
return;
}
try {
_previousDb = reader.read().getDatabase();
} catch (RuntimeException e) {
_loadingFailure = true;
handleReadingException(e, reader);
}
_previousTableCount = _previousDb.getTableList().size();
}
Aggregations