Exemplo n.º 1
0
 @Override
 public GroupData getGroupData(LinkedList<LinkedHashMap<String, Object>> srcData) {
   GroupData resData = null;
   try {
     LinkedHashMap<String, Object> tmpValue = srcData.get(0);
     resData = SourceUtil.getGroupData(tmpValue);
   } catch (Exception e) {
     logger.error(DBConstant.RESULT_DATA_CONVERT_ERROR, e);
     throw new DBRuntimeException(DBConstant.RESULT_DATA_CONVERT_ERROR, e);
   }
   return resData;
 }
Exemplo n.º 2
0
 @Override
 public RepeatData getRepeatData(LinkedList<LinkedHashMap<String, Object>> srcData) {
   RepeatData resData = null;
   RepeatData rData = new RepeatData();
   try {
     int listSize = srcData.size();
     for (int i = 0; i < listSize; i++) {
       GroupData gData = SourceUtil.getGroupData(srcData.get(i));
       rData.addGroupData(gData);
     }
   } catch (Exception e) {
     logger.error(DBConstant.RESULT_DATA_CONVERT_ERROR, e);
     throw new DBRuntimeException(DBConstant.RESULT_DATA_CONVERT_ERROR, e);
   }
   resData = rData;
   return resData;
 }
Exemplo n.º 3
0
  @SuppressWarnings("unchecked")
  @Override
  public void operate(BaseContext dbContext) {
    // 从上下文中获取数据库资源访问总入参对象
    DBInDataModel dbInDataModel = (DBInDataModel) (dbContext.getInData());
    // 从总入参对象中得到连接信息
    DBConnModel dbConnModel = (DBConnModel) dbInDataModel.getData(ProcessDataType.CONN);
    // 从总入参对象中得到结果信息
    DBResModel dbResModel = (DBResModel) dbInDataModel.getData(ProcessDataType.RESULT);

    DBConnEnumTypes dbConnEnumType = dbConnModel.getDbEnumConnType();
    Object srcData = dbContext.get(DBConstant.CONST_DBExchangeRes);
    Object resData = null;
    DBResEnumTypes dbEnumResType = dbResModel.getDbResEnumType();
    try {
      switch (dbConnEnumType) {
          // 连接类型
        case Class_DefaultDbExec:
          switch (dbEnumResType) {
            case NoConvert:
              resData = this.getNoConvert(srcData);
              break;
            case FieldData:
              resData = this.getFileData((LinkedList<LinkedHashMap<String, Object>>) srcData);
              break;
            case GroupData:
              resData = this.getGroupData((LinkedList<LinkedHashMap<String, Object>>) srcData);
              break;
            case RepeatData:
              resData = this.getRepeatData((LinkedList<LinkedHashMap<String, Object>>) srcData);
              break;
            default:
              logger.error(DBConstant.RESULT_UNSUPPORT_TYPE + ":" + dbEnumResType);
              throw new DBRuntimeException(DBConstant.RESULT_UNSUPPORT_TYPE + ":" + dbEnumResType);
          }
          break;
          // Dao接口方式
        case Class_DBBaseDao:
          try {
            switch (dbEnumResType) {
              case NoConvert:
                resData = this.getNoConvert(srcData);
                break;
              case FieldData:
                resData = SourceUtil.getFileData(srcData);
                break;
              case GroupData:
                if (srcData instanceof Map) {
                  resData = SourceUtil.getGroupData((Map<String, Object>) srcData);
                } else { // 否则当作List去处理
                  resData = SourceUtil.getGroupData((List<Object>) srcData);
                }
                break;
              case RepeatData:
                resData = SourceUtil.getRepeatData((List<Map<String, Object>>) srcData);
                break;
              default:
                logger.error(DBConstant.RESULT_UNSUPPORT_TYPE + ":" + dbEnumResType);
                throw new DBRuntimeException(
                    DBConstant.RESULT_UNSUPPORT_TYPE + ":" + dbEnumResType);
            }
          } catch (Exception e) {
            logger.error(DBConstant.RESULT_DATA_CONVERT_ERROR, e);
            throw new DBRuntimeException(DBConstant.RESULT_DATA_CONVERT_ERROR, e);
          }
          break;
        default:
          logger.error(DBConstant.CONN_TYPE_ERROR + ":" + dbConnEnumType);
          throw new DBRuntimeException(DBConstant.CONN_TYPE_ERROR + ":" + dbConnEnumType);
      }
    } catch (Exception e) {
      logger.error(DBConstant.RESULT_DATA_CONVERT_ERROR + ":" + dbConnEnumType, e);
      throw new DBRuntimeException(DBConstant.RESULT_DATA_CONVERT_ERROR + ":" + dbConnEnumType, e);
    }
    dbContext.setOutData(resData);
  }