Search in sources :

Example 1 with DfTableXlsReader

use of org.dbflute.helper.io.xls.DfTableXlsReader in project dbflute-core by dbflute.

the class DfXlsDataHandlerImpl method readSeveralData.

// ===================================================================================
// Read
// ====
public List<DfDataSet> readSeveralData(DfXlsDataResource resource) {
    final String dataDirectory = resource.getDataDirectory();
    final List<File> xlsList = getXlsList(resource);
    final List<DfDataSet> ls = new ArrayList<DfDataSet>();
    for (File file : xlsList) {
        final DfTableXlsReader xlsReader = createTableXlsReader(dataDirectory, file);
        ls.add(xlsReader.read());
    }
    return ls;
}
Also used : DfDataSet(org.dbflute.helper.dataset.DfDataSet) ArrayList(java.util.ArrayList) File(java.io.File) DfTableXlsReader(org.dbflute.helper.io.xls.DfTableXlsReader)

Example 2 with DfTableXlsReader

use of org.dbflute.helper.io.xls.DfTableXlsReader in project dbflute-core by dbflute.

the class DfXlsDataHandlingWriter method writeSeveralData.

// ===================================================================================
// Read
// ====
// unused so comment out by jflute (2021/01/18)
// public List<DfDataSet> readSeveralData(DfXlsDataResource resource) {
// final String dataDirectory = resource.getDataDirectory();
// final List<File> xlsList = findXlsList(resource);
// final List<DfDataSet> ls = new ArrayList<DfDataSet>();
// for (File file : xlsList) {
// final DfTableXlsReader xlsReader = createTableXlsReader(dataDirectory, file);
// ls.add(xlsReader.read());
// }
// return ls;
// }
// ===================================================================================
// Write
// =====
public void writeSeveralData(DfXlsDataResource resource, DfLoadedDataInfo loadedDataInfo) {
    final String dataDirectory = resource.getDataDirectory();
    final List<File> xlsList = findXlsList(resource);
    if (xlsList.isEmpty()) {
        return;
    }
    final StringBuilder msgSb = new StringBuilder();
    for (File file : xlsList) {
        _log.info("/= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ");
        _log.info("writeData(" + file + ")");
        _log.info("= = = = = = =/");
        final DfTableXlsReader xlsReader = createTableXlsReader(dataDirectory, file);
        final DfDataSet dataSet = xlsReader.read();
        filterValidColumn(dataSet);
        setupDefaultValue(dataDirectory, dataSet);
        doWriteDataSet(resource, file, dataSet, msgSb);
        // this has no warning fixedly
        final boolean warned = false;
        loadedDataInfo.addLoadedFile(resource.getEnvType(), "xls", null, file.getName(), warned);
    }
    prepareImplicitClassificationLazyCheck(loadedDataInfo);
    markOutputResult(resource.getDataDirectory(), msgSb.toString());
}
Also used : DfDataSet(org.dbflute.helper.dataset.DfDataSet) File(java.io.File) DfTableXlsReader(org.dbflute.helper.io.xls.DfTableXlsReader)

Example 3 with DfTableXlsReader

use of org.dbflute.helper.io.xls.DfTableXlsReader in project dbflute-core by dbflute.

the class DfXlsDataHandlerImpl method writeSeveralData.

// ===================================================================================
// Write
// =====
public void writeSeveralData(DfXlsDataResource resource, DfLoadedDataInfo loadedDataInfo) {
    final String dataDirectory = resource.getDataDirectory();
    final List<File> xlsList = getXlsList(resource);
    if (xlsList.isEmpty()) {
        return;
    }
    final StringBuilder msgSb = new StringBuilder();
    for (File file : xlsList) {
        _log.info("/= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ");
        _log.info("writeData(" + file + ")");
        _log.info("= = = = = = =/");
        final DfTableXlsReader xlsReader = createTableXlsReader(dataDirectory, file);
        final DfDataSet dataSet = xlsReader.read();
        filterValidColumn(dataSet);
        setupDefaultValue(dataDirectory, dataSet);
        doWriteDataSet(resource, file, dataSet, msgSb);
        // this has no warning fixedly
        final boolean warned = false;
        loadedDataInfo.addLoadedFile(resource.getEnvType(), "xls", null, file.getName(), warned);
    }
    prepareImplicitClassificationLazyCheck(loadedDataInfo);
    outputResultMark(resource.getDataDirectory(), msgSb.toString());
}
Also used : DfDataSet(org.dbflute.helper.dataset.DfDataSet) File(java.io.File) DfTableXlsReader(org.dbflute.helper.io.xls.DfTableXlsReader)

Example 4 with DfTableXlsReader

use of org.dbflute.helper.io.xls.DfTableXlsReader in project dbflute-core by dbflute.

the class DfLReverseProcess method extractExistingXlsInfo.

// ===================================================================================
// Existing Xls
// ============
protected DfLReverseExistingXlsInfo extractExistingXlsInfo(File baseDir) {
    final List<File> existingXlsList = extractExistingXlsList(baseDir);
    final Map<File, List<String>> existingXlsTableListMap = DfCollectionUtil.newLinkedHashMap();
    final Map<String, File> tableExistingXlsMap = StringKeyMap.createAsFlexible();
    final String dataDirPath = resolvePath(baseDir);
    final Map<String, String> tableNameMap = _tableNameProp.getTableNameMap(dataDirPath);
    for (File existingXls : existingXlsList) {
        final DfTableXlsReader reader = createTableXlsReader(baseDir, existingXls, tableNameMap);
        final DfDataSet dataSet = reader.read();
        final List<String> tableList = new ArrayList<String>();
        for (int i = 0; i < dataSet.getTableSize(); i++) {
            final DfDataTable dataTable = dataSet.getTable(i);
            final String tableDbName = dataTable.getTableDbName();
            tableList.add(tableDbName);
            if (tableExistingXlsMap.containsKey(tableDbName)) {
                throwLoadDataReverseDuplicateTableException(tableExistingXlsMap, tableDbName);
            }
            tableExistingXlsMap.put(tableDbName, existingXls);
        }
        existingXlsTableListMap.put(existingXls, tableList);
    }
    return new DfLReverseExistingXlsInfo(existingXlsTableListMap, tableExistingXlsMap);
}
Also used : ArrayList(java.util.ArrayList) DfDataTable(org.dbflute.helper.dataset.DfDataTable) DfDataSet(org.dbflute.helper.dataset.DfDataSet) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) DfTableXlsReader(org.dbflute.helper.io.xls.DfTableXlsReader)

Example 5 with DfTableXlsReader

use of org.dbflute.helper.io.xls.DfTableXlsReader in project dbflute-core by dbflute.

the class DfLReverseExistingFileProvider method extractExistingXlsInfo.

// ===================================================================================
// Existing Xls
// ============
public DfLReverseExistingXlsInfo extractExistingXlsInfo(File baseDir) {
    final List<File> existingXlsList = findExistingXlsList(baseDir);
    final Map<File, List<String>> existingXlsTableListMap = DfCollectionUtil.newLinkedHashMap();
    final Map<String, File> tableExistingXlsMap = StringKeyMap.createAsFlexible();
    final String dataDirPath = resolvePath(baseDir);
    final Map<String, String> tableNameMap = _tableNameProp.findTableNameMap(dataDirPath);
    for (File existingXls : existingXlsList) {
        final DfTableXlsReader reader = createTableXlsReader(baseDir, existingXls, tableNameMap);
        final DfDataSet dataSet = reader.read();
        final List<String> tableList = new ArrayList<String>();
        for (int i = 0; i < dataSet.getTableSize(); i++) {
            final DfDataTable dataTable = dataSet.getTable(i);
            final String tableDbName = dataTable.getTableDbName();
            tableList.add(tableDbName);
            if (tableExistingXlsMap.containsKey(tableDbName)) {
                throwLoadDataReverseDuplicateTableException(tableExistingXlsMap, tableDbName);
            }
            tableExistingXlsMap.put(tableDbName, existingXls);
        }
        existingXlsTableListMap.put(existingXls, tableList);
    }
    return new DfLReverseExistingXlsInfo(existingXlsTableListMap, tableExistingXlsMap);
}
Also used : ArrayList(java.util.ArrayList) DfDataTable(org.dbflute.helper.dataset.DfDataTable) DfDataSet(org.dbflute.helper.dataset.DfDataSet) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) DfTableXlsReader(org.dbflute.helper.io.xls.DfTableXlsReader)

Aggregations

File (java.io.File)5 DfDataSet (org.dbflute.helper.dataset.DfDataSet)5 DfTableXlsReader (org.dbflute.helper.io.xls.DfTableXlsReader)5 ArrayList (java.util.ArrayList)3 List (java.util.List)2 DfDataTable (org.dbflute.helper.dataset.DfDataTable)2