use of com.varsql.core.exception.DBMetadataException in project varsql by varsqlinfo.
the class MetaControlBean method getDBObjectMeta.
/**
* @Method Name : getDBMeta
* @Method 설명 : get db object metadata
* @작성일 : 2018. 9. 18.
* @작성자 : ytkim
* @변경이력 :
* @param metaType
* @param paramInfo
* @param objNm
* @return
* @throws Exception
*/
@SuppressWarnings("unchecked")
public <T> T getDBObjectMeta(String metaType, DatabaseParamInfo paramInfo, String... objNm) {
String callMethodName = String.format("get%sMetadata", StringUtils.capitalize(metaType));
boolean hasMethod = VartechReflectionUtils.hasMethod(this.dbMetaImpl.getClass(), callMethodName, DatabaseParamInfo.class, new String[0].getClass());
try {
if (hasMethod) {
if (objNm == null) {
objNm = new String[0];
}
Object[] paramArr = { paramInfo, objNm };
return (T) VartechReflectionUtils.invokeMethod(this.dbMetaImpl, callMethodName, paramArr);
} else {
return (T) this.dbMetaImpl.getExtensionMetadata(paramInfo, metaType, paramInfo.getCustom());
}
} catch (Exception e) {
logger.error("getDBMeta class : {} , callMethodName: {}, objArr : {} ", this.dbMetaImpl.getClass(), callMethodName, StringUtils.join(objNm));
logger.error("getDBMeta callMethodName ", e);
if (hasMethod) {
throw new DBMetadataException(VarsqlAppCode.DB_META_ERROR, e);
}
}
return null;
}
use of com.varsql.core.exception.DBMetadataException 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;
}
Aggregations