use of org.dbflute.logic.doc.lreverse.existing.DfLReverseExistingXlsInfo in project dbflute-core by dbflute.
the class DfLReverseFileOrder method toOverrideReverseOrderedMap.
// -----------------------------------------------------
// 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.findTableNameMap(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;
}
Aggregations