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 DfLReverseOutputHandler method transferToXls.
/**
* Transfer data to excel. (state-less)
* @param tableMap The map of table. (NotNull)
* @param loadDataMap The map of load data. (NotNull)
* @param limit The limit of extracted record. (MinusAllowed: if minus, no limit)
* @param xlsFile The file of XLS. (NotNull)
* @param resource The resource information of output data. (NotNull)
* @param sectionInfoList The list of section info. (NotNull)
*/
protected void transferToXls(Map<String, Table> tableMap, Map<String, DfLReverseDataResult> loadDataMap, int limit, File xlsFile, DfLReverseOutputResource resource, List<String> sectionInfoList) {
final DfDataSet dataSet = new DfDataSet();
int sheetNumber = 0;
for (Entry<String, Table> entry : tableMap.entrySet()) {
++sheetNumber;
final String tableDbName = entry.getKey();
final Table table = entry.getValue();
final DfLReverseDataResult dataResult = loadDataMap.get(tableDbName);
if (dataResult.isLargeData()) {
outputDelimiterData(table, dataResult, limit, resource, sheetNumber, sectionInfoList);
} else {
final List<Map<String, String>> extractedList = dataResult.getResultList();
setupXlsDataTable(dataSet, table, extractedList, sheetNumber, sectionInfoList);
}
}
if (dataSet.getTableSize() > 0) {
writeXlsData(dataSet, xlsFile);
}
}
use of org.apache.torque.engine.database.model.Table in project dbflute-core by dbflute.
the class DfLReverseProcess method toReplaceReverseOrderedMap.
// -----------------------------------------------------
// Replace Reverse
// ---------------
protected Map<File, DfLReverseOutputResource> toReplaceReverseOrderedMap(List<List<Table>> orderedList) {
final Map<File, DfLReverseOutputResource> orderedMap = DfCollectionUtil.newLinkedHashMap();
int sectionNo = 1;
for (List<Table> nestedList : orderedList) {
final String number = (sectionNo < 10 ? "0" + sectionNo : String.valueOf(sectionNo));
final String mainName = extractMainName(nestedList);
final File xlsFile = new File(buildXlsFilePath(number, mainName));
orderedMap.put(xlsFile, createOutputResource(xlsFile, nestedList, sectionNo, mainName));
++sectionNo;
}
return orderedMap;
}
use of org.apache.torque.engine.database.model.Table in project dbflute-core by dbflute.
the class DfLReverseProcess method toOverrideReverseOrderedMap.
// ===================================================================================
// Ordered Map
// ===========
// -----------------------------------------------------
// Override Reverse
// ----------------
protected Map<File, DfLReverseOutputResource> toOverrideReverseOrderedMap(List<List<Table>> orderedList, File baseDir) {
final DfLReverseExistingXlsInfo existingXlsInfo = extractExistingXlsInfo(baseDir);
final Map<File, DfLReverseOutputResource> orderedMap = createOrderedMap();
final String dataDirPath = resolvePath(baseDir);
final Map<String, String> tableNameMap = _tableNameProp.getTableNameMap(dataDirPath);
final Map<String, File> translatedXlsMap = prepareTranslatedXlsMap(existingXlsInfo, tableNameMap);
final List<Table> addedTableList = DfCollectionUtil.newArrayList();
int sectionNo = 1;
for (List<Table> nestedList : orderedList) {
for (Table table : nestedList) {
final File existingXls = translatedXlsMap.get(table.getTableDbName());
if (existingXls == null) {
addedTableList.add(table);
continue;
}
DfLReverseOutputResource resource = orderedMap.get(existingXls);
if (resource == null) {
final String mainName = extractMainName(nestedList);
final List<Table> initialList = new ArrayList<Table>();
resource = createOutputResource(existingXls, initialList, sectionNo, mainName);
orderedMap.put(existingXls, resource);
++sectionNo;
}
resource.addTable(table);
}
}
registerAddedTableIfExists(orderedMap, addedTableList, sectionNo);
orderTableByExistingOrder(orderedMap, existingXlsInfo);
return orderedMap;
}
use of org.apache.torque.engine.database.model.Table in project dbflute-core by dbflute.
the class DfLReverseProcess method filterTableList.
// ===================================================================================
// Table List
// ==========
protected 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;
}
Aggregations