use of com.varsql.web.dto.file.FileImportResult in project varsql by varsqlinfo.
the class FileImportExportServiceImpl method importFile.
/**
* @Method Name : importFile
* @Method 설명 : import file
* @작성자 : ytkim
* @작성일 : 2020. 11. 22.
* @변경이력 :
*/
public ResponseResult importFile(FileImportInfo fii) {
String conuid = fii.getConuid();
String importType = fii.getImportType();
List<FileInfoEntity> importFileList = fileInfoEntityRepository.findAllById(Arrays.asList(CommUtils.getFileIds(fii.getFileIds())));
ResponseResult result = new ResponseResult();
List<FileImportResult> resultInfo = new ArrayList<>();
importFileList.forEach(fileInfo -> {
FileImportResult fileImportResult = new FileImportResult();
try {
fileImportResult.setFileName(fileInfo.getFileName());
SQLExecuteResult ser = null;
if ("sql".equals(importType)) {
ser = sqlImport(fileInfo, conuid);
} else if ("xml".equals(importType)) {
ser = xmlImport(fileInfo, conuid);
} else if ("json".equals(importType)) {
ser = jsonImport(fileInfo, conuid);
} else if ("csv".equals(importType)) {
ser = csvImport(fileInfo, conuid);
}
if (ser.getResultCode() != null) {
fileImportResult.setResultCode(ser.getResultCode());
}
fileImportResult.setResultCount(ser.getExecuteCount());
fileImportResult.setMessage(ser.getMessage());
} catch (IOException | SQLException e) {
fileImportResult.setResultCode(VarsqlAppCode.ERROR);
fileImportResult.setMessage(e.getMessage());
logger.error("file import error importType : {} , conuid : {} , fileInfo :{} ", importType, fileInfo);
logger.error("error message : {}", e.getMessage(), e);
}
resultInfo.add(fileImportResult);
});
result.setItemList(resultInfo);
return result;
}
Aggregations