use of org.apache.torque.engine.database.model.Database in project dbflute-core by dbflute.
the class TorqueDocumentationTask method initializeSchemaData.
// ===================================================================================
// Prepare Generation
// ==================
@Override
protected void initializeSchemaData() {
// basically called in fireVelocityProcess()
if (isLoadDataReverseOnly() || isSchemaSyncCheckOnly()) {
// don't use basic schema data
// not to depends on JDBC task
_schemaData = AppData.createAsEmpty();
} else {
// normally here (SchemaHTML, HistoryHTML)
if (_schemaData == null) {
// basically false, already initialized in SchemaHTML process so just in case
purelyInitializeSchemaHtmlSchemaData();
}
final Database database = _schemaData.getDatabase();
if (_schemaPolicyResult != null) {
// null allowed when no policy
database.setSchemaPolicyDisplay(new DfSPolicyDisplay(_schemaPolicyResult));
}
database.setEmbeddedPickup(_decoMapPickup);
database.setFirstDateAgent(new DfFirstDateAgent(() -> {
// for SchemaHTML's firstDate display
return prepareCoreSchemaDiffList();
}));
}
}
use of org.apache.torque.engine.database.model.Database in project dbflute-core by dbflute.
the class DfPmbPropertyOptionReference method getPmbMetaDataPropertyOptionReferenceColumn.
// ===================================================================================
// Reference Column
// ================
public Column getPmbMetaDataPropertyOptionReferenceColumn(AppData appData) {
if (appData == null) {
return null;
}
final Database database = appData.getDatabase();
if (database == null) {
return null;
}
final String refPrefix = OPTION_PREFIX;
final String refSuffix = OPTION_SUFFIX;
final String option;
{
final String optionExp = getPmbMetaDataPropertyOption();
if (optionExp == null) {
return null;
}
final List<String> splitOption = splitOption(optionExp);
String firstOption = null;
for (String element : splitOption) {
if (element.startsWith(refPrefix) && element.endsWith(refSuffix)) {
firstOption = element;
break;
}
}
if (firstOption == null) {
return null;
}
option = firstOption;
}
final ScopeInfo scope = Srl.extractScopeFirst(option, refPrefix, refSuffix);
final String content = scope.getContent().trim();
final String delimiter = ".";
final String tableName;
final String columnName;
if (content.contains(".")) {
tableName = Srl.substringFirstFront(content, delimiter);
columnName = Srl.substringFirstRear(content, delimiter);
} else {
tableName = content;
columnName = null;
}
final Table table = database.getTable(tableName);
if (table == null) {
throwParameterBeanReferenceTableNotFoundException(option, tableName);
}
final String columnKeyName;
if (columnName != null) {
columnKeyName = columnName;
} else {
if (_pmbMetaData.isPropertyTypeList(_propertyName) && Srl.endsWith(_propertyName, "List")) {
// e.g. statusList to status
columnKeyName = Srl.substringLastFront(_propertyName, "List");
} else {
columnKeyName = _propertyName;
}
}
final Column column = table.getColumn(columnKeyName);
if (column == null) {
throwParameterBeanReferenceColumnNotFoundException(option, tableName, columnName);
}
return column;
}
use of org.apache.torque.engine.database.model.Database in project dbflute-core by dbflute.
the class DfFreeGenInitializer method prepareDatabase.
protected Database prepareDatabase(DfSchemaXmlReader reader) {
final AppData appData = reader.read();
final Database database = appData.getDatabase();
// same as ControlGenerateJava.vm
database.initializeVersion(90);
database.initializeSupplementaryMetaData();
database.initializeIncludeQuery();
database.checkProperties();
return database;
}
use of org.apache.torque.engine.database.model.Database in project dbflute-core by dbflute.
the class DfFreeGenInitializer method setupReservedOption.
// ===================================================================================
// Reserved Option
// ===============
protected void setupReservedOption(String requestName, Map<String, Object> optionMap) {
@SuppressWarnings("unchecked") final Map<String, Object> databaseMap = (Map<String, Object>) optionMap.get("databaseMap");
if (databaseMap == null) {
return;
}
for (Entry<String, Object> entry : databaseMap.entrySet()) {
final String databaseName = entry.getKey();
@SuppressWarnings("unchecked") final Map<String, Object> settingsMap = (Map<String, Object>) entry.getValue();
final String schemaDir = (String) settingsMap.get("schemaDir");
final String schemaXml;
if (Srl.is_NotNull_and_NotTrimmedEmpty(schemaDir)) {
schemaXml = schemaDir + "/project-schema-" + databaseName + ".xml";
} else {
final String schemaFile = (String) settingsMap.get("schemaFile");
if (Srl.is_Null_or_TrimmedEmpty(schemaFile)) {
String msg = "Not found the schemaDir or schemaFile property in the " + databaseName + " for " + requestName;
throw new DfIllegalPropertySettingException(msg);
}
schemaXml = schemaFile;
}
final DfSchemaXmlReader reader = DfSchemaXmlReader.createAsFlexibleToManage(schemaXml);
final Database database = prepareDatabase(reader);
settingsMap.put("instance", database);
}
}
use of org.apache.torque.engine.database.model.Database in project dbflute-core by dbflute.
the class DfLReverseProcess method execute.
// ===================================================================================
// Execute
// =======
public void execute() {
final Database database = prepareDatabase();
final List<Table> tableList = filterTableList(database);
final List<String> sectionInfoList = prepareTitleSection(tableList);
final File baseDir = prepareBaseDir();
final Map<File, DfLReverseOutputResource> orderedMap = prepareOrderedMap(tableList, baseDir);
reverseTableData(orderedMap, baseDir, sectionInfoList);
outputTableNameMap();
synchronizeOriginDateIfNeeds(sectionInfoList);
outputResultMark(sectionInfoList);
}
Aggregations