use of com.varsql.web.common.beans.DataCommonVO in project varsql by varsqlinfo.
the class ExportServiceImpl method tableSpecExport.
/**
* @param req
* @param paramInfo
* @Method Name : tableExport
* @Method 설명 : 테이블 정보 내보내기.
* @작성자 : ytkim
* @작성일 : 2017. 11. 23.
* @변경이력 :
* @param databaseParamInfo
* @param paramInfo
* @param res
* @throws Exception
*/
public void tableSpecExport(PreferencesRequestDTO preferencesInfo, HttpServletRequest req, HttpServletResponse res) throws Exception {
preferencesInfo.setPrefKey(PreferencesConstants.PREFKEY.TABLE_EXPORT.key());
String jsonString = preferencesInfo.getPrefVal();
logger.debug("tableSpecExport :{}", VartechUtils.reflectionToString(preferencesInfo));
logger.debug("settingInfo :{}", jsonString);
logger.debug("MetaControlFactory.getDbInstanceFactory(preferencesInfo.getDbType()).getTableReportImpl() :{}", MetaControlFactory.getDbInstanceFactory(preferencesInfo.getDbType()).getTableReportImpl());
// 설정 정보 저장.
preferencesServiceImpl.savePreferencesInfo(preferencesInfo);
DataCommonVO settingInfo = VartechUtils.jsonStringToObject(jsonString, DataCommonVO.class);
List<Map> tables = (List<Map>) settingInfo.get("tables");
List<Map> columns = (List<Map>) settingInfo.get("columns");
String[] tableNmArr = Arrays.stream(tables.toArray(new HashMap[tables.size()])).map(tmp -> tmp.get("name")).toArray(String[]::new);
ExcelReport excelReport = MetaControlFactory.getDbInstanceFactory(preferencesInfo.getDbType()).getTableReportImpl().columnsInfo(preferencesInfo, columns, settingInfo.getBoolean("addTableDefinitionFlag", false), settingInfo.getBoolean("sheetFlag", false), tableNmArr);
String exportFileName = settingInfo.getString("exportName", "table-spec");
exportFileName += exportFileName.endsWith(".xlsx") ? "" : ".xlsx";
VarsqlUtils.setResponseDownAttr(res, req, exportFileName);
excelReport.write(res.getOutputStream());
}
use of com.varsql.web.common.beans.DataCommonVO in project varsql by varsqlinfo.
the class ExportServiceImpl method ddlExport.
/**
* @Method Name : tableDDLExport
* @Method 설명 : 테이블 ddl 내보내기
* @작성자 : ytkim
* @작성일 : 2017. 8. 24.
* @변경이력 :
* @param preferencesInfo
* @param req
* @param res
* @throws Exception
*/
public void ddlExport(PreferencesRequestDTO preferencesInfo, HttpServletRequest req, HttpServletResponse res) throws Exception {
String jsonString = preferencesInfo.getPrefVal();
logger.debug("ddlExport PreferencesInfo :{}", VartechUtils.reflectionToString(preferencesInfo));
logger.debug("settingInfo :{}", jsonString);
DataCommonVO settingInfo = VartechUtils.jsonStringToObject(jsonString, DataCommonVO.class);
Map<String, List<Map>> exportInfo = (Map<String, List<Map>>) settingInfo.get("exportInfo");
Iterator<String> iter = exportInfo.keySet().iterator();
MetaControlBean dbMetaEnum = MetaControlFactory.getDbInstanceFactory(preferencesInfo.getDbType());
StringBuilder allDDLScript = new StringBuilder();
DDLCreateOption ddlOption = new DDLCreateOption();
while (iter.hasNext()) {
String objectName = iter.next();
allDDLScript.append("--------- " + objectName + " start----------").append(BlankConstants.NEW_LINE_TWO);
List<Map> objList = exportInfo.get(objectName);
String[] objNmArr = Arrays.stream(objList.toArray(new HashMap[objList.size()])).map(tmp -> tmp.get("name")).toArray(String[]::new);
preferencesInfo.setObjectType(ObjectType.getDBObjectType(objectName).name());
List<DDLInfo> ddlList = dbMetaEnum.getDDLScript(ObjectType.getDBObjectType(objectName).getObjectTypeId(), preferencesInfo, ddlOption, objNmArr);
for (DDLInfo ddlInfo : ddlList) {
allDDLScript.append(ddlInfo.getCreateScript()).append(BlankConstants.NEW_LINE_TWO);
}
allDDLScript.append(BlankConstants.NEW_LINE).append("--------- // " + objectName + " end----------").append(BlankConstants.NEW_LINE_THREE);
}
String exportFileName = settingInfo.getString("exportName", "export-ddl");
exportFileName += exportFileName.endsWith(".sql") ? "" : ".sql";
VarsqlUtils.setResponseDownAttr(res, req, exportFileName);
VarsqlUtils.textDownload(res.getOutputStream(), allDDLScript.toString());
}
Aggregations