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;
}
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());
}
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());
}
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);
}
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);
}
Aggregations