Search in sources :

Example 1 with DfLReverseExistingXlsInfo

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;
}
Also used : DfLReverseOutputResource(org.dbflute.logic.doc.lreverse.DfLReverseOutputResource) Table(org.apache.torque.engine.database.model.Table) DfLReverseExistingXlsInfo(org.dbflute.logic.doc.lreverse.existing.DfLReverseExistingXlsInfo) ArrayList(java.util.ArrayList) File(java.io.File)

Aggregations

File (java.io.File)1 ArrayList (java.util.ArrayList)1 Table (org.apache.torque.engine.database.model.Table)1 DfLReverseOutputResource (org.dbflute.logic.doc.lreverse.DfLReverseOutputResource)1 DfLReverseExistingXlsInfo (org.dbflute.logic.doc.lreverse.existing.DfLReverseExistingXlsInfo)1