use of com.varsql.core.db.MetaControlBean in project varsql by varsqlinfo.
the class DatabaseServiceImpl method dbObjectList.
/**
* @Method Name : dbObjectList
* @Method 설명 : db object 목록 보기 (table, view 등등)
* @작성자 : ytkim
* @작성일 : 2017. 11. 16.
* @변경이력 :
* @param databaseParamInfo
* @return
* @throws Exception
*/
@Cacheable(cacheNames = CacheInfo.CACHE_KEY_OBJECTYPE_METADATA, key = "@" + CacheInfo.CACHE_KEY_OBJECTYPE_METADATA + ".dbObjectTypeKey(#databaseParamInfo)", condition = "@" + CacheInfo.CACHE_KEY_OBJECTYPE_METADATA + ".dbObjectListCondition(#databaseParamInfo)")
public ResponseResult dbObjectList(DatabaseParamInfo databaseParamInfo) {
MetaControlBean dbMetaEnum = MetaControlFactory.getDbInstanceFactory(databaseParamInfo.getDbType());
ResponseResult result = new ResponseResult();
String objectType = databaseParamInfo.getObjectType();
try {
String[] objectNames = databaseParamInfo.getObjectNames();
if (ObjectType.TABLE.getObjectTypeId().equals(objectType) && databaseParamInfo.isLazyLoad()) {
if (databaseParamInfo.getCustom() != null && "Y".equals(databaseParamInfo.getCustom().get("allMetadata"))) {
result.setItemList(dbMetaEnum.getDBObjectMeta(ObjectType.getDBObjectType(objectType).getObjectTypeId(), databaseParamInfo, objectNames));
} else {
result.setItemList(dbMetaEnum.getDBObjectList(ObjectType.getDBObjectType(objectType).getObjectTypeId(), databaseParamInfo));
}
} else {
result.setItemList(dbMetaEnum.getDBObjectMeta(ObjectType.getDBObjectType(objectType).getObjectTypeId(), databaseParamInfo, objectNames));
}
} catch (Exception e) {
logger.error("dbObjectList objectType : [{}]", objectType);
logger.error("dbObjectList ", e);
if (e instanceof DBMetadataException) {
result.setResultCode(((DBMetadataException) e).getErrorCode());
result.setMessage(e.getMessage());
} else {
try {
result.setItemList(MetaControlFactory.getDbInstanceFactory(DBType.OTHER).getDBObjectMeta(ObjectType.getDBObjectType(objectType).getObjectTypeId(), databaseParamInfo));
} catch (Exception subE) {
logger.error("dbObjectList serverName : [{}]", objectType);
logger.error("dbObjectList ", subE);
throw subE;
}
}
}
return result;
}
use of com.varsql.core.db.MetaControlBean in project varsql by varsqlinfo.
the class DbDiffServiceImpl method objectList.
/**
* @param objectType
* @Method Name : objectList
* @Method 설명 : object list
* @작성자 : ytkim
* @작성일 : 2018. 12. 19.
* @변경이력 :
* @param paramMap
* @return
*/
public ResponseResult objectList(String vconnid, String schema, String objectType) {
ResponseResult resultObject = new ResponseResult();
DBConnectionEntity vtConnRVO = dbConnectionEntityRepository.findByVconnid(vconnid);
if (vtConnRVO == null) {
resultObject.setResultCode(RequestResultCode.ERROR);
resultObject.setItemList(null);
} else {
DatabaseParamInfo dpi = getDatabaseParamInfo(vtConnRVO);
dpi.setSchema(schema);
dpi.setObjectType(objectType);
MetaControlBean dbMetaEnum = MetaControlFactory.getDbInstanceFactory(vtConnRVO.getDbTypeDriverProvider().getDbType());
String objectId = ObjectType.getDBObjectType(objectType).getObjectTypeId();
if (ObjectType.TABLE.getObjectTypeId().equals(objectId)) {
resultObject.setItemList(dbMetaEnum.getDBObjectMeta(objectId, dpi));
} else {
List<BaseObjectInfo> objectList = dbMetaEnum.getDBObjectList(objectId, dpi);
String[] objectNameArr = new String[objectList.size()];
int idx = 0;
for (BaseObjectInfo boi : objectList) {
// System.out.println("boi.getName() : "+ boi.getName());
objectNameArr[idx] = boi.getName();
++idx;
}
resultObject.setItemList(dbMetaEnum.getDDLScript(objectId, dpi, new DDLCreateOption(), objectNameArr));
}
}
return resultObject;
}
Aggregations