Exemplo n.º 1
0
 private HashMap<String, HashMap<String, Object>> updateProc(
     HashMap<String, Object> params, HttpServletRequest request, Session session, Login login)
     throws Exception {
   @SuppressWarnings("unused")
   String screen = request.getParameter("screen");
   Map<String, Object> updateInput = preProc(params);
   UserTable upd = null;
   try {
     upd = BeanUtil.copyMapToNewBean(updateInput, UserTable.class);
   } catch (Exception e) {
     ServiceUtil.mapToNewBeanExceptionAnalyze(e);
   }
   UserTable dbUserTable = em.find(UserTable.class, upd.getId());
   if (dbUserTable == null) {
     throw new SystemException("id:" + upd.getId().toString() + " が見つかりません");
   }
   if (!(upd.getTableName().equals(dbUserTable.getTableName())
           && upd.getKey1().equals(dbUserTable.getKey1())
           && upd.getKey2().equals(dbUserTable.getKey2()))
       && userTableCodeDupCheck(upd)) {
     return DBFluteUtil.setErrorMessage("このDataは既に使用されています。", params);
   }
   BeanUtil.copyBeanToBean(upd, dbUserTable, CopyOptionsUtil.excludeNull());
   em.merge(dbUserTable);
   Map<String, Object> map = null;
   map = entityToMap(upd);
   return DBFluteUtil.setFetchResult(map, params);
 }
Exemplo n.º 2
0
  public HashMap<String, HashMap<String, Object>> execute(
      HashMap<String, Object> params, HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    Session session = loginUtil.getSessionFromRequestCookie(request);
    if (session == null) {
      return DBFluteUtil.setErrorMessage("セッションがありません。再度ログインして下さい。", params);
    }
    Login login = loginUtil.getLoginFromSession(session);
    HashMap<String, HashMap<String, Object>> res = loginUtil.checkLogin(session, params);
    if (res != null) {
      return res;
    }
    String op = (String) params.get("operationType");
    if (op.equals("fetch")) {
      return fetchProc(params, request, session, login);
    }
    if (op.equals("update")) {
      return updateProc(params, request, session, login);
    }
    if (op.equals("remove")) {
      return deleteProc(params, request, session, login);
    }
    if (op.equals("add")) {
      return insertProc(params, request, session, login);
    }

    return null;
  }
Exemplo n.º 3
0
  private HashMap<String, HashMap<String, Object>> fetchProc(
      HashMap<String, Object> params, HttpServletRequest request, Session session, Login login)
      throws Exception {
    String screen = request.getParameter("screen");

    List<UserTable> userTableList =
        em.createQuery(
                "From UserTable where delFlag = :delFlag ORDER BY tableName, key1, key2",
                UserTable.class)
            .setParameter("delFlag", 0)
            .getResultList();
    //		ListResultBean<UserTable> res = userTableBhv.selectList(cb -> {
    //			cb.query().setDelFlag_Equal(0);
    //			cb.query().addOrderBy_TableName_Asc().addOrderBy_Key1_Asc().addOrderBy_Key2_Asc();
    //			HashMap<String, Object> data = (HashMap<String, Object>) params.get("data");
    //			String maxRecord = (String) data.get("maxRecord");
    //			if (maxRecord != null) {
    //				cb.paging(Integer.parseInt(maxRecord), 1);
    //			} else {
    //				cb.paging(MAX_RECORD, 1);
    //			}
    //			setupQueryCriteria(cb, data); FIXME
    //		});
    ArrayList<Map<String, Object>> ar = resultToMap(userTableList, screen);

    return DBFluteUtil.setFetchResult(ar, 0, 0, userTableList.size(), params);
  }
Exemplo n.º 4
0
 private HashMap<String, HashMap<String, Object>> deleteProc(
     HashMap<String, Object> params, HttpServletRequest request, Session session, Login login)
     throws Exception {
   BigDecimal bid = (BigDecimal) params.get("data");
   Integer id = bid.intValue();
   UserTable delUserTable = em.find(UserTable.class, id);
   if (delUserTable == null) {
     throw new SystemException("id:" + id.toString() + " が見つかりません");
   }
   delUserTable.setDelFlag(getDelFlagMaxValue(delUserTable) + 1);
   em.merge(delUserTable);
   return DBFluteUtil.setFetchResult(entityToMap(delUserTable), params);
 }
Exemplo n.º 5
0
  private HashMap<String, HashMap<String, Object>> insertProc(
      HashMap<String, Object> params, HttpServletRequest request, Session session, Login login)
      throws Exception {
    @SuppressWarnings("unused")
    String screen = request.getParameter("screen");
    Map<String, Object> newin = preProc(params);
    UserTable newEntity = null;
    try {
      newEntity = BeanUtil.copyMapToNewBean(newin, UserTable.class);
    } catch (Exception e) {
      ServiceUtil.mapToNewBeanExceptionAnalyze(e);
    }
    if (userTableCodeDupCheck(newEntity)) {
      return DBFluteUtil.setErrorMessage("このDataは既に使用されています。", params);
    }

    HashMap<String, HashMap<String, Object>> res;
    em.persist(newEntity);
    Map<String, Object> map = null;
    map = entityToMap(newEntity);
    res = DBFluteUtil.setFetchResult(map, params);
    return res;
  }