protected Department lookuDepartment(
     org.hibernate.Session hibSession,
     DepartmentInterface original,
     boolean future,
     Long sessionId) {
   if (original == null) return null;
   if (future) {
     return Department.findByDeptCode(original.getDeptCode(), sessionId, hibSession);
   } else {
     return DepartmentDAO.getInstance().get(original.getId(), hibSession);
   }
 }
示例#2
0
  /**
   * Method validate
   *
   * @param mapping
   * @param request
   * @return ActionErrors
   */
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();

    if (name == null || name.equalsIgnoreCase("")) {
      errors.add("roomGroup", new ActionMessage("errors.required", "Name"));
    }

    if (abbv == null || abbv.equalsIgnoreCase("")) {
      errors.add("roomGroup", new ActionMessage("errors.required", "Abbreviation"));
    }

    try {

      for (Iterator i = RoomGroup.getAllGlobalRoomGroups(getSessionId()).iterator();
          i.hasNext(); ) {
        RoomGroup rg = (RoomGroup) i.next();
        if (rg.getName().equalsIgnoreCase(name) && !rg.getUniqueId().toString().equals(id))
          errors.add("name", new ActionMessage("errors.exists", name));
      }

      Department dept =
          (deptCode == null ? null : Department.findByDeptCode(deptCode, getSessionId()));
      if (dept != null) {
        for (Iterator i = RoomGroup.getAllDepartmentRoomGroups(dept).iterator(); i.hasNext(); ) {
          RoomGroup rg = (RoomGroup) i.next();
          if (rg.getName().equalsIgnoreCase(name) && !rg.getUniqueId().toString().equals(id))
            errors.add("name", new ActionMessage("errors.exists", name));
        }
      }

    } catch (Exception e) {
      Debug.error(e);
      errors.add("name", new ActionMessage("errors.generic", e.getMessage()));
    }

    if (!global && (deptCode == null || deptCode.equalsIgnoreCase(""))) {
      errors.add("Department", new ActionMessage("errors.required", "Department"));
    }

    return errors;
  }