コード例 #1
0
  /**
   * @param req
   * @return
   */
  public String serviceGroup(HttpServletRequest req) {
    // AshaLogger.logInfo(logger, this.getClass().getName(), "lovValues", "Entered");
    Session session = null;
    ArrayList<ValueName> detailsArrayList = new ArrayList<ValueName>();
    List list = null;
    ValueName valueName = null;
    Object obj[] = {};
    try {
      session = HibernateUtil.currentSession();
      session.beginTransaction();
      Query detailsQuery =
          session.createSQLQuery(
              "select SG_Code, SG_ServiceGroup FROM service_group where Delete_Flag=1 and sg_code!=5");

      list = detailsQuery.list();

      for (int i = 0; i < list.size(); i++) {
        valueName = new ValueName();
        obj = (Object[]) list.get(i);
        valueName.setCode(obj[0].toString());
        valueName.setName((String) obj[1].toString());
        detailsArrayList.add(valueName);
      }
      req.setAttribute("1", detailsArrayList);

      status = "lovs";
    } catch (HibernateException e) {
      status = "error";
      logger.error("Exception", e);
    } finally {
      session.beginTransaction().commit();
    }
    return status;
  }
コード例 #2
0
  /**
   * @param req
   * @return
   */
  public String lovValues(HttpServletRequest req, String values) {
    AshaLogger.logInfo(logger, this.getClass().getName(), "lovValues", "Entered");
    Session session = null;
    ArrayList<ListofvaluesId> detailsArrayList = new ArrayList<ListofvaluesId>();
    List list = null;
    ListofvaluesId lov = null;
    Object obj[] = {};
    try {
      session = HibernateUtil.currentSession();
      session.beginTransaction();
      Query detailsQuery =
          session.createSQLQuery(
              "select List_Id, Value_id, Value_Name FROM listofvalues where List_Id IN ("
                  + values
                  + ") and Value_id!=0  and delete_flag=1 order by List_Id");

      list = detailsQuery.list();
      int listid = 0;
      int check_listid = 0;
      for (int i = 0; i < list.size(); i++) {
        lov = new ListofvaluesId();
        obj = (Object[]) list.get(i);
        check_listid = (Integer) obj[0];
        lov.setValueId((Integer) obj[1]);
        lov.setValueName((String) obj[2]);

        if (check_listid != listid) {
          if (i != 0) {
            req.setAttribute((new Integer(listid)).toString(), detailsArrayList);
            detailsArrayList = null;
            detailsArrayList = new ArrayList<ListofvaluesId>();
          }
        }
        detailsArrayList.add(lov);
        listid = check_listid;
      }
      req.setAttribute((new Integer(listid)).toString(), detailsArrayList);

      status = "lovs";
    } catch (HibernateException e) {
      status = "error";
      logger.error("Exception", e);
    } finally {
      session.beginTransaction().commit();
    }
    return status;
  }