use of org.apache.torque.engine.database.model.Table in project dbflute-core by dbflute.
the class DfLReverseDataExtractor method extractData.
// ===================================================================================
// Extract Data
// ============
/**
* Extract load-data.
* @param tableMap The map of table. (NotNull)
*/
public Map<String, DfLReverseDataResult> extractData(Map<String, Table> tableMap) {
final Map<String, DfLReverseDataResult> loadDataMap = new LinkedHashMap<String, DfLReverseDataResult>();
for (Entry<String, Table> entry : tableMap.entrySet()) {
final String tableDbName = entry.getKey();
final Table table = entry.getValue();
final DfLReverseDataResult result = selectData(table);
loadDataMap.put(tableDbName, result);
}
return loadDataMap;
}
use of org.apache.torque.engine.database.model.Table in project dbflute-core by dbflute.
the class DfLReverseTableData method reverseTableData.
// ===================================================================================
// Reverse Table
// =============
public void reverseTableData(Map<File, DfLReverseOutputResource> orderedMap, File baseDir, List<String> sectionInfoList) {
deletePreviousDataFile(baseDir);
final Integer limit = getRecordLimit();
for (Entry<File, DfLReverseOutputResource> entry : orderedMap.entrySet()) {
final File xlsFile = entry.getKey();
final DfLReverseOutputResource resource = entry.getValue();
final List<Table> tableList = resource.getTableList();
final Map<String, Table> tableInfoMap = DfCollectionUtil.newLinkedHashMap();
for (Table table : tableList) {
tableInfoMap.put(table.getTableDbName(), table);
}
final String sectionTitle = "[" + xlsFile.getName() + "]: tables=" + tableList.size();
_log.info("");
_log.info(sectionTitle);
sectionInfoList.add("");
sectionInfoList.add(sectionTitle);
_outputHandler.outputData(tableInfoMap, limit, xlsFile, resource, sectionInfoList);
}
}
use of org.apache.torque.engine.database.model.Table in project dbflute-core by dbflute.
the class DfLReverseSchemaTableFilter method filterTableList.
// ===================================================================================
// Filter Table
// ============
public List<Table> filterTableList(Database database) {
final List<Table> tableList = database.getTableList();
final Set<String> commonExistingTableSet = getCommonExistingTableSet();
final List<Table> filteredList = DfCollectionUtil.newArrayListSized(tableList.size());
_skippedTableList.clear();
final List<Table> commonSkippedList = DfCollectionUtil.newArrayList();
final List<Table> exceptSkippedList = DfCollectionUtil.newArrayList();
_log.info("...Filtering reversed table: " + tableList.size());
for (Table table : tableList) {
if (table.isTypeView() || table.isAdditionalSchema()) {
// additional schema - tables on main schema only are target
continue;
}
if (commonExistingTableSet.contains(table.getTableDbName())) {
commonSkippedList.add(table);
continue;
}
if (!isTargetTable(table)) {
exceptSkippedList.add(table);
continue;
}
filteredList.add(table);
}
if (!commonSkippedList.isEmpty()) {
_log.info("[Common Table] *skipped");
for (Table table : commonSkippedList) {
_log.info(" " + table.getTableDbName());
_skippedTableList.add(table);
}
}
if (!exceptSkippedList.isEmpty()) {
_log.info("[Except Table] *skipped");
for (Table table : exceptSkippedList) {
_log.info(" " + table.getTableDbName());
_skippedTableList.add(table);
}
}
return filteredList;
}
use of org.apache.torque.engine.database.model.Table in project dbflute-core by dbflute.
the class DfSchemaDiff method processChangedTable.
// -----------------------------------------------------
// Changed
// -------
protected void processChangedTable() {
final List<Table> tableList = _nextDb.getTableList();
for (Table next : tableList) {
final Table previous = findPreviousTable(next);
if (previous == null || !isSameTableName(next, previous)) {
continue;
}
// found
final DfTableDiff tableDiff = DfTableDiff.createChanged(next.getTableDbName());
// direct attributes
processUnifiedSchema(next, previous, tableDiff);
processObjectType(next, previous, tableDiff);
processColumnDefOrder(next, previous, tableDiff);
processTableComment(next, previous, tableDiff);
// nested attributes
processColumn(tableDiff, next, previous);
processPrimaryKey(tableDiff, next, previous);
processForeignKey(tableDiff, next, previous);
processUniqueKey(tableDiff, next, previous);
processIndex(tableDiff, next, previous);
if (tableDiff.hasDiff()) {
// changed
addTableDiff(tableDiff);
}
}
}
use of org.apache.torque.engine.database.model.Table in project dbflute-core by dbflute.
the class DfSql2EntityTask method setupSql2EntityRelatedTable.
protected Table setupSql2EntityRelatedTable(String entityName, DfCustomizeEntityInfo entityInfo, Map<String, DfColumnMeta> metaMap, String columnName, Column column, String pkRelatedTableName) {
final DfColumnMeta columnMeta = metaMap.get(columnName);
final String sql2EntityRelatedTableName = columnMeta.getSql2EntityRelatedTableName();
// first attack
Table relatedTable = getRelatedTable(sql2EntityRelatedTableName);
if (relatedTable == null) {
if (pkRelatedTableName != null) {
// second attack using PK-related
relatedTable = getRelatedTable(pkRelatedTableName);
if (relatedTable == null) {
throwTableRelatedPrimaryKeyNotFoundException(entityName, entityInfo, pkRelatedTableName, columnName);
}
} else {
return null;
}
} else {
if (pkRelatedTableName != null) {
if (!Srl.equalsFlexible(sql2EntityRelatedTableName, pkRelatedTableName)) {
throwTableRelatedPrimaryKeyDifferentException(entityName, entityInfo, sql2EntityRelatedTableName, pkRelatedTableName, columnName);
}
}
}
column.setSql2EntityRelatedTable(relatedTable);
return relatedTable;
}
Aggregations