use of com.varsql.core.db.MetaControlBean in project varsql by varsqlinfo.
the class ExportServiceImpl method selectExportDbObjectInfo.
/**
* @Method Name : selectExportDbObjectInfo
* @Method 설명 : db object info
* @작성자 : ytkim
* @작성일 : 2018. 8. 29.
* @변경이력 :
* @param preferencesInfo
* @param mode
* @param model
* @return
* @throws Exception
*/
public ResponseResult selectExportDbObjectInfo(DatabaseParamInfo databaseParam) throws Exception {
MetaControlBean dbMetaEnum = MetaControlFactory.getDbInstanceFactory(databaseParam.getDbType());
Map customParam = databaseParam.getCustom();
String ddlObjInfo = String.valueOf(customParam.get("ddlObjInfo"));
String[] objArr = ddlObjInfo.split(",");
ResponseResult result = new ResponseResult();
for (int i = 0; i < objArr.length; i++) {
String mode = objArr[i];
result.addCustoms(mode, dbMetaEnum.getDBObjectList(ObjectType.getDBObjectType(mode).getObjectTypeId(), databaseParam));
}
return result;
}
use of com.varsql.core.db.MetaControlBean 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());
}
use of com.varsql.core.db.MetaControlBean in project varsql by varsqlinfo.
the class ExportServiceImpl method selectExportConfigInfo.
/**
* @Method Name : selectConfigInfo
* @Method 설명 : table export Info
* @작성자 : ytkim
* @작성일 : 2017. 11. 22.
* @변경이력 :
* @param preferencesInfo
* @param model
* @throws Exception
*/
public void selectExportConfigInfo(PreferencesRequestDTO preferencesInfo, ModelMap model) throws Exception {
MetaControlBean dbMetaEnum = MetaControlFactory.getDbInstanceFactory(preferencesInfo.getDbType());
model.addAttribute("userSettingInfo", preferencesServiceImpl.selectPreferencesInfo(preferencesInfo, true));
model.addAttribute("columnInfo", Arrays.stream(VarsqlReportConfig.TABLE_COLUMN.values()).map(EnumMapperValue::new).collect(Collectors.toList()));
if (SecurityUtil.isSchemaView(preferencesInfo)) {
model.addAttribute("schemaList", dbMetaEnum.getSchemas(preferencesInfo));
} else {
model.addAttribute("schemaInfo", "");
}
}
use of com.varsql.core.db.MetaControlBean in project varsql by varsqlinfo.
the class DbDiffServiceImpl method objectTypeList.
/**
* @Method Name : objectTypeList
* @Method 설명 : db object type list (table , view 등등)
* @작성자 : ytkim
* @작성일 : 2019. 1. 2.
* @변경이력 :
* @param vconnid
* @return
* @throws SQLException
*/
public ResponseResult objectTypeList(String vconnid) throws SQLException {
ResponseResult resultObject = new ResponseResult();
DBConnectionEntity vtConnRVO = dbConnectionEntityRepository.findByVconnid(vconnid);
if (vtConnRVO == null) {
resultObject.setResultCode(RequestResultCode.ERROR);
resultObject.setItemList(null);
} else {
MetaControlBean dbMetaEnum = MetaControlFactory.getDbInstanceFactory(vtConnRVO.getDbTypeDriverProvider().getDbType());
resultObject.setItemList(dbMetaEnum.getServiceMenu());
resultObject.addCustoms("schemaInfo", dbMetaEnum.getSchemas(getDatabaseParamInfo(vtConnRVO)));
}
return resultObject;
}
use of com.varsql.core.db.MetaControlBean in project varsql by varsqlinfo.
the class DatabaseServiceImpl method dbInfo.
/**
* @Method Name : dbInfo
* @Method 설명 : db 정보
* @작성자 : ytkim
* @작성일 : 2018. 10. 8.
* @변경이력 :
* @param databaseParamInfo
* @return
*/
public ResponseResult dbInfo(DatabaseParamInfo databaseParamInfo) {
MetaControlBean dbMetaEnum = MetaControlFactory.getDbInstanceFactory(databaseParamInfo.getDbType());
ResponseResult result = new ResponseResult();
try {
result.setItemList(dbMetaEnum.getDBInfo(databaseParamInfo));
} catch (Exception e) {
logger.error("createDDL : ", e);
}
return result;
}
Aggregations