// 修改HAB值
  public void changeHAB(Context context) {
    List errList = context.errList;
    HashMap outputMap = new HashMap();
    if (errList.isEmpty()) {
      SqlMapClient sqlMapper = DataAccessor.getSession();

      try {
        sqlMapper.startTransaction();
        sqlMapper.update("activitiesLog.modifyHAB", context.getContextMap());
        sqlMapper.commitTransaction();
      } catch (SQLException e) {
        e.printStackTrace();
        LogPrint.getLogStackTrace(e, logger);
        errList.add(e);
      } finally {
        try {
          sqlMapper.endTransaction();
        } catch (SQLException e) {
          e.printStackTrace();
          LogPrint.getLogStackTrace(e, logger);
          errList.add(e);
        }
      }
    } else {
      outputMap.put("errList", errList);
      Output.jspOutput(outputMap, context, "/error.jsp");
    }

    if (errList.isEmpty()) {
      //
    } else {
      outputMap.put("errList", errList);
      Output.jspOutput(outputMap, context, "/error.jsp");
    }
  }
 //	AOP注入核心, 为service层方法做事务控制
 public Object intercept(Object obj, Method method, Object[] args, MethodProxy arg3)
     throws Throwable {
   Object object = new Object();
   //		通过方法上加的注解来决定该方法适合要做事务控制
   MethodTransactionConfig annotation = method.getAnnotation(MethodTransactionConfig.class);
   if (annotation == null || !annotation.needControl()) {
     object = method.invoke(this.target, args);
   } else {
     try {
       sqlMapClient.startTransaction();
       object = method.invoke(this.target, args);
       sqlMapClient.commitTransaction();
     } catch (Exception e) {
       e.printStackTrace();
     } finally {
       sqlMapClient.endTransaction();
     }
   }
   return object;
 }
Esempio n. 3
0
  /**
   * Plus Tok 순위 변경
   *
   * @param viewRank
   * @param viewRankPlusTokId
   * @throws AdminPlusTokServiceException
   */
  public void updateViewRank(String[] viewRank, String[] viewRankPlusTokId)
      throws AdminPlusTokServiceException {
    AdminPlusTokDAO dao = AdminPlusTokDAO.getInstance();
    SqlMapClient sqlMapClient = dao.getSqlMapClient();
    try {

      sqlMapClient.startTransaction();

      if (viewRank != null && viewRankPlusTokId != null) {

        // 기존 seq값 변경
        AdminPlusTokVO param = new AdminPlusTokVO();
        param.setSeqArray(viewRank);

        dao.updatePlusTokViewRank(param);

        for (int i = 0; i < viewRank.length; i++) {
          param = null;
          param = new AdminPlusTokVO();

          param.setSeq(viewRank[i]);
          param.setPlusTokId(Integer.parseInt(CommUtils.checkNull(viewRankPlusTokId[i], "-1")));

          dao.updatePlusTokViewRank(param);
        }
      }
      sqlMapClient.commitTransaction();
    } catch (Exception e) {
      m_traceLogger.error(e.getMessage(), e);

      AdminPlusTokServiceException ex =
          new AdminPlusTokServiceException("The ServiceException Occured While updateViewRank");
      throw ex;
    } finally {
      try {
        sqlMapClient.endTransaction();
      } catch (SQLException e) {
      }
    }
  }
Esempio n. 4
0
  public boolean insertRankingHistory(UserDTO dto) throws Exception {
    boolean result = false;

    try {
      sqlClient.startTransaction();
      sqlClient.startBatch();

      sqlClient.insert("UserInfo.insertRankingHistory", dto);

      sqlClient.executeBatch();
      sqlClient.commitTransaction();

      result = true;
    } catch (Exception e) {
      logger.error("sql Exception : " + e.getMessage());
      throw new Exception("TwitterRankDAO.insertRankingHistory:" + e.getMessage());
    } finally {
      sqlClient.endTransaction();
    }

    return result;
  }
Esempio n. 5
0
 public boolean insertUserList(List<UserDTO> list) throws Exception {
   boolean result = false;
   try {
     // 트랜잭션 시작
     sqlClient.startTransaction();
     // 배치작업 준비 시작
     sqlClient.startBatch();
     for (UserDTO dto : list) {
       sqlClient.insert("UserInfo.insertUserList", dto);
     }
     // 배치작업 실행.
     sqlClient.executeBatch();
     // 정상 완료 후 커밋
     sqlClient.commitTransaction();
     result = true;
   } catch (Exception e) {
     logger.error("sql Exception : " + e.getMessage());
     throw new Exception("TwitterRankDAO.getUserList:" + e.getMessage());
   } finally { // 문제 발생시 트랜잭션 종료(작업 적용안함)
     sqlClient.endTransaction();
   }
   return result;
 }
Esempio n. 6
0
  @PUT
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.TEXT_PLAIN)
  public String updateLedger(Ledger objLedger) {
    try {
      Reader reader = Resources.getResourceAsReader("./dao/SqlMapConfig.xml");
      SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

      Ledger temp = (Ledger) sqlMap.queryForObject("Ledger.getLedgerById", objLedger);
      if (temp == null) {
        return "Ledger can not be identified. Try logging in again.!";
      }

      sqlMap.startTransaction();
      sqlMap.update("Ledger.updateByLedgerId", objLedger);
      sqlMap.commitTransaction();
      sqlMap.endTransaction();
    } catch (Exception e) {
      e.printStackTrace();
      return "Some problem occured while updating Ledger information. Kindly try again!";
    }
    return "Information updated successfully";
  }
Esempio n. 7
0
  @POST
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.TEXT_PLAIN)
  public String insertLedger(Ledger objLedger) {
    try {
      Reader reader = Resources.getResourceAsReader("./dao/SqlMapConfig.xml");
      SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
      Ledger temp = (Ledger) sqlMap.queryForObject("Ledger.getDuplicateLedger", objLedger);
      if (temp != null) {
        return "Sorry, Ledger name already exists.! Kindly try some other name.";
      }

      sqlMap.startTransaction();
      sqlMap.insert("Ledger.insertLedger", objLedger);
      sqlMap.commitTransaction();
      sqlMap.endTransaction();

    } catch (Exception e) {
      e.printStackTrace();
      return "Some problem occured while creating New Ledger. Kindly try again!";
    }
    return "New Ledger created successfully";
  }
Esempio n. 8
0
  public static void main(String[] args) {

    SqlMapClient sqlMapClient = SqlConfig.getAtSqlMapInstance();
    try {
      sqlMapClient.startTransaction();
      ProviderAccountDao dao = new ProviderAccountDao(sqlMapClient);
      //			update for delete
      ProviderAccount oldAccount = new ProviderAccount();
      oldAccount.setTxnId("54321");
      oldAccount.setDeleted(1L);
      oldAccount.setUpdatedBy("test");
      oldAccount.setUpdatedDate(new Date());
      dao.updateDeleted(oldAccount);
      //			insert new record
      sqlMapClient.commitTransaction();
    } catch (Exception e) {
      try {
        sqlMapClient.endTransaction();
      } catch (SQLException e1) {

      }
    }
  }
  // 修改主档明细
  public void updateLog(Context context) {
    Map outputMap = new HashMap();
    List errList = context.errList;

    String prvLogSun1 = "已访厂";
    String prvLogSun2 = "首次拜访";

    int casesun = Integer.parseInt(context.request.getParameter("casesun"));
    // 通过casesun(明细档Id),查询出name
    Map logName = null;
    try {
      context.contextMap.put("reportactlogid", context.contextMap.get("casesun"));
      logName =
          (Map)
              DataAccessor.query(
                  "activitiesLog.getActlogNameByActlogId",
                  context.contextMap,
                  DataAccessor.RS_TYPE.MAP);
    } catch (Exception e) {
      e.printStackTrace();
      LogPrint.getLogStackTrace(e, logger);
      // 添加详细错误信息
      errList.add("活动日志管理--修改主档明细错误!请联系管理员");
    }
    Object actLogName1 = logName.get("ACTLOG_NAME");
    String actLogName = null;
    if (actLogName1 != null && !"".equals(actLogName1)) {
      actLogName = actLogName1.toString();
    }
    int casesun1 = Integer.parseInt(context.request.getParameter("CASESUN1"));

    SqlMapClient sqlMapper = null;
    if (errList.isEmpty()) {
      try {
        sqlMapper = DataAccessor.getSession();
        sqlMapper.startTransaction();
        sqlMapper.update("activitiesLog.updateLog", context.contextMap);
        context.contextMap.put("logName", actLogName);
        if (actLogName.equals(prvLogSun1)) {
          sqlMapper.update("activitiesLog.updateCaseStateByVisitFactoryDate", context.contextMap);
        } else if (actLogName.equals(prvLogSun2)) {
          sqlMapper.update("activitiesLog.updateCaseStateByVisitFirst", context.contextMap);
        } else {
          sqlMapper.update("activitiesLog.updateCaseState", context.contextMap);
        }
        sqlMapper.commitTransaction();
      } catch (Exception e) {
        e.printStackTrace();
        LogPrint.getLogStackTrace(e, logger);
        errList.add("活动日志管理--修改主档明细错误!请联系管理员");
      } finally {
        try {
          sqlMapper.endTransaction();
        } catch (SQLException e) {
          e.printStackTrace();
          LogPrint.getLogStackTrace(e, logger);
        }
      }
    }
    if (errList.isEmpty()) {
      Output.jspSendRedirect(context, "defaultDispatcher?__action=activitiesLog.query");
    } else {
      outputMap.put("errList", errList);
      Output.jspOutput(outputMap, context, "/error.jsp");
    }
  }