Exemplo n.º 1
0
  // 生成选中消费日时的sql语句
  public static <T> String sqlForDate(T form, String check) {
    String sqlAdd = null;
    String strl = null;
    String strr = null;
    try {
      strl = BeanUtils.getProperty(form, "l_date");
      strr = BeanUtils.getProperty(form, "r_date");
      if (strl == null || strl.equals("")) {
        strl = "1971-01-01";
      }
      if (strr == null || strr.equals("")) {
        strr = DateUntil.getLocationTime1();
      }

      sqlAdd =
          " cast("
              + check
              + " as unsigned) between "
              + String.valueOf(DateUntil.dateToLong(strl))
              + " and "
              + String.valueOf(DateUntil.dateToLong(strr))
              + " and ";
    } catch (Exception e) {
      // TODO: handle exception
      throw new RuntimeException(e);
    }
    return sqlAdd;
  }
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    Long feedbackId = Long.decode(BeanUtils.getProperty(form, "id"));
    String commentedited = BeanUtils.getProperty(form, "commentedited");
    String makepublic = BeanUtils.getProperty(form, "makepublic");
    boolean makepublicBool = "true".equals(makepublic);

    Feedback feedback = LegacySpringUtils.getFeedbackManager().get(feedbackId);

    feedback.setCommentedited(commentedited);
    feedback.setMakepublic(makepublicBool);

    LegacySpringUtils.getFeedbackManager().save(feedback);

    List feedbacks = LegacySpringUtils.getFeedbackManager().get(feedback.getUnitcode());

    request.setAttribute("feedbacks", feedbacks);

    return LogonUtils.logonChecks(mapping, request);
  }
Exemplo n.º 3
0
  @Override
  public boolean isValid(Object value, ConstraintValidatorContext context) {
    try {
      String fieldVal = BeanUtils.getProperty(value, field);
      String verifyFieldVal = BeanUtils.getProperty(value, verifyField);
      if (fieldVal == null && verifyFieldVal == null) {
        return true;
      }

      if (fieldVal != null && !fieldVal.equals(verifyFieldVal)) {
        String messageTemplate = context.getDefaultConstraintMessageTemplate();
        context.disableDefaultConstraintViolation();
        context
            .buildConstraintViolationWithTemplate(messageTemplate)
            .addNode(verifyField)
            .addConstraintViolation();

        return false;
      }

    } catch (IllegalAccessException e) {
      e.printStackTrace();
    } catch (InvocationTargetException e) {
      e.printStackTrace();
    } catch (NoSuchMethodException e) {
      e.printStackTrace();
    }

    return true;
  }
Exemplo n.º 4
0
  // 페이징 객체를 설정한다.
  public void executePagenation(HttpServletRequest request, ModelMap modelMap, Object command)
      throws Exception {
    // 페이징 관련 해서 뷰페이지에서 현재 페이지와 페이지 싸이즈 그리고 토탈 카운트 정보만 있으면 페이지징을 처리할수있다.
    // totalCount 구한다.
    int totalCount = this.listTotalCount(request, modelMap, command);

    int pageIndex = Integer.parseInt(BeanUtils.getProperty(command, "pageIndex").toString());
    int pageSize = Integer.parseInt(BeanUtils.getProperty(command, "pageSize").toString());
    int recordCountPerPage =
        Integer.parseInt(BeanUtils.getProperty(command, "recordCountPerPage").toString());

    // egov pagination 객체 생성
    PaginationInfo paginationInfo = new PaginationInfo();

    paginationInfo.setCurrentPageNo(pageIndex);
    paginationInfo.setRecordCountPerPage(recordCountPerPage);
    paginationInfo.setPageSize(pageSize);
    paginationInfo.setTotalRecordCount(totalCount);
    int lastPageNo = paginationInfo.getLastPageNo();
    if (pageIndex > lastPageNo) {
      paginationInfo.setCurrentPageNo(lastPageNo);
    }

    // 검색 리스트 쿼리에서 사용할 페이징 정보를 구한다.
    BeanUtils.setProperty(command, "firstIndex", paginationInfo.getFirstRecordIndex());
    BeanUtils.setProperty(command, "lastIndex", paginationInfo.getLastRecordIndex());
    // comDefaultVo 에 pageSize 와 recordCountPerPage 같은 정보인것 같은데 왜 있는지 모르겠다 recordCountPerPage는
    // 주석처리한다.
    // BeanUtils.setProperty(command,"recordCountPerPage",paginationInfo.getRecordCountPerPage());

    modelMap.addAttribute("paginationInfo", paginationInfo);
  }
Exemplo n.º 5
0
  @RequestMapping(value = "reg.user", method = RequestMethod.POST)
  public MappingJacksonJsonView registerUser(
      HttpServletRequest request, HttpServletResponse response, @ModelAttribute UserBean userBean) {
    logger.info("Register User!!");
    MappingJacksonJsonView view = null;
    try {
      view = new MappingJacksonJsonView();
      hmsService.registerUser(userBean);

      AuthBean authBean = new AuthBean();
      authBean.setUserId(BeanUtils.getProperty(userBean, "enrollNo"));
      authBean.setPassword(BeanUtils.getProperty(userBean, "pass"));
      authBean.setEmailId(BeanUtils.getProperty(userBean, "studentEmail"));
      authBean.setUserType("S");
      hmsService.createAuthDetails(authBean);
      HttpSession session = request.getSession();
      if (session.isNew()) {
        logger.info("New Session is created.");
        session.setAttribute("user", userBean);
      } else {
        logger.info("Old Session.");
        session.setAttribute("user", userBean);
      }
      view.addStaticAttribute("success", true);
      view.addStaticAttribute("redirectURL", "studentHome");
    } catch (Exception e) {
      e.printStackTrace();
    }
    return view;
  }
 public ActionForward execute(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   User user = LegacySpringUtils.getUserManager().getLoggedInUser();
   String suppliedOldPassword = BeanUtils.getProperty(form, "oldpassword");
   String actualOldPassword = user.getPassword();
   String hashedSuppliedOldPassword = LogonUtils.hashPassword(suppliedOldPassword);
   if (hashedSuppliedOldPassword.equals(actualOldPassword)) {
     user.setPassword(LogonUtils.hashPassword(BeanUtils.getProperty(form, "passwordPwd")));
     user.setFirstlogon(false);
     LegacySpringUtils.getUserManager().save(user);
     AddLog.addLog(
         user.getUsername(),
         AddLog.PASSWORD_CHANGE,
         user.getUsername(),
         "",
         UserUtils.retrieveUsersRealUnitcodeBestGuess(user.getUsername()),
         "");
     return mapping.findForward("success");
   } else {
     request.setAttribute("error", "incorrect current password");
     return mapping.findForward("input");
   }
 }
Exemplo n.º 7
0
    @Override
    public int compare(T o1, T o2) {

      try {
        String val1 = BeanUtils.getProperty(o1, property);
        String val2 = BeanUtils.getProperty(o2, property);

        if (isAscending) {
          if (val1 == null) {
            if (val2 == null) {
              return 0;
            } else {
              return 1;
            }
          } else if (val2 == null) {
            return -1;
          } else return val1.toLowerCase().compareTo(val2.toLowerCase());
        } else {
          if (val2 == null) {
            if (val1 == null) {
              return 0;
            } else {
              return 1;
            }
          } else if (val1 == null) {
            return -1;
          } else return val2.toLowerCase().compareTo(val1.toLowerCase());
        }
      } catch (Exception ex) {
        throw new RuntimeException(ex);
      }
    }
 @Override
 protected String getConfirmationMessage(ServiceAccessRule object) throws Exception {
   return (String) BeanUtils.getProperty(object, "service")
       + "."
       + (String) BeanUtils.getProperty(object, "method")
       + "="
       + (String) BeanUtils.getProperty(object, "roles");
 }
 /**
  * Retrieving comparable fields from object. Throws {@code IllegalStateException} whether the
  * field is not found.
  *
  * @param value object from which value of the fields are taken
  */
 private void getComparableFields(Object value) {
   try {
     fieldValue2 = BeanUtils.getProperty(value, firstPropertyName);
     fieldValue1 = BeanUtils.getProperty(value, secondPropertyName);
   } catch (Exception e) {
     throw new IllegalStateException(e);
   }
 }
  public Object assignValues2Fields(Object obj, List<Stubparamconfig> stublist, Class clstype) {
    try {

      Class cls = clstype;
      Object target_obj = clstype.newInstance();
      Field[] fields = cls.getDeclaredFields();
      logger.info("fields.length:" + fields.length);
      System.out.println("fields.length:" + fields.length);
      /*
       * Search for the available fields from the database and assign it
       * to the fields
       */
      /*for(int p=0;p<fields.length;p++)
      {
      	for (Stubparamconfig s : stublist)
      	{
      			System.out.println(">>>>"+BeanUtils.getProperty(obj,s.getSourcefield()));
      	}
      }
      */
      for (int k = 0; k < fields.length; k++) {
        for (Stubparamconfig s : stublist) {
          if (s.getDestfieldname().equalsIgnoreCase(fields[k].getName())) {
            // System.out.println("Class type address:"+fields[k].getType());
            fields[k].setAccessible(true);
            Object value = null;
            if (fields[k].getType().toString().equals("class java.math.BigDecimal")) {
              System.out.println("bigger");
              value = new BigDecimal(BeanUtils.getProperty(obj, s.getSourcefieldname()));
            } else if (fields[k].getType().toString().equals("class java.lang.Integer")) {
              value = Integer.parseInt(BeanUtils.getProperty(obj, s.getSourcefieldname()));
            } else {
              value = BeanUtils.getProperty(obj, s.getSourcefieldname());
            }
            fields[k].set(target_obj, value);
          }
        }
      }
      return target_obj;
    } catch (IllegalArgumentException e) {
      e.printStackTrace();
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    } catch (InvocationTargetException e) {
      e.printStackTrace();
    } catch (NoSuchMethodException e) {
      e.printStackTrace();
    } catch (InstantiationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return stublist;
  }
Exemplo n.º 11
0
 public boolean isValid(final Object value, ConstraintValidatorContext context) {
   try {
     final Object firstObj = BeanUtils.getProperty(value, firstFieldName);
     final Object secondObj = BeanUtils.getProperty(value, secondFieldName);
     System.out.println("------------ First " + firstObj + " Second" + secondObj);
     return firstObj == null && secondObj == null
         || firstObj != null && firstObj.equals(secondObj);
   } catch (final Exception ignore) {
     ignore.printStackTrace();
   }
   return true;
 }
Exemplo n.º 12
0
  /** {@inheritDoc} */
  public String getHtmlDisplay(TableModel model, Column column) {
    ColumnBuilder columnBuilder = new ColumnBuilder(column);

    columnBuilder.tdStart();

    try {
      Object bean = model.getCurrentRowBean();
      String outageid = BeanUtils.getProperty(bean, "outageid");

      @SuppressWarnings("unchecked")
      Collection<String> selectedoutagesIds =
          (Collection<String>)
              model
                  .getContext()
                  .getSessionAttribute(SuppressOutageCheckBoxConstants.SELECTED_OUTAGES);
      if (selectedoutagesIds != null && selectedoutagesIds.contains(outageid)) {
        columnBuilder
            .getHtmlBuilder()
            .input("hidden")
            .name("chkbx_" + outageid)
            .value(SuppressOutageCheckBoxConstants.SELECTED)
            .xclose();
        columnBuilder
            .getHtmlBuilder()
            .input("checkbox")
            .name(BeanUtils.getProperty(bean, "outageid"));
        columnBuilder.getHtmlBuilder().onclick("setOutageState(this)");
        columnBuilder.getHtmlBuilder().checked();
        columnBuilder.getHtmlBuilder().xclose();
      } else {
        columnBuilder
            .getHtmlBuilder()
            .input("hidden")
            .name("chkbx_" + outageid)
            .value(SuppressOutageCheckBoxConstants.UNSELECTED)
            .xclose();
        columnBuilder
            .getHtmlBuilder()
            .input("checkbox")
            .name(BeanUtils.getProperty(bean, "outageid"));
        columnBuilder.getHtmlBuilder().onclick("setOutageState(this)");
        columnBuilder.getHtmlBuilder().xclose();
      }
    } catch (Throwable e) {
    }

    columnBuilder.tdEnd();
    return columnBuilder.toString();
  }
Exemplo n.º 13
0
  @Override
  public List<TableRowDto<T>> extractData(ResultSet resultSet)
      throws SQLException, DataAccessException {
    List<TableRowDto<T>> listTableRow = new ArrayList<TableRowDto<T>>();

    while (resultSet.next()) {
      TableRowDto<T> tableRow = new TableRowDto<T>();
      tableRow.setPage(resultSet.getInt("PAGE"));
      tableRow.setPageLine(resultSet.getInt("PAGELINE"));
      tableRow.setTableLine(resultSet.getInt("TABLELINE"));

      T model = rowMapper.mapRow(resultSet, resultSet.getRow());
      tableRow.setModel(model);
      try {
        for (String pk : this.pkColums) {
          tableRow.addPrimaryKey(pk, BeanUtils.getProperty(model, pk));
        }
        listTableRow.add(tableRow);
      } catch (IllegalAccessException e) {
        throw new SQLException(e);
      } catch (InvocationTargetException e) {
        throw new SQLException(e);
      } catch (NoSuchMethodException e) {
        throw new SQLException(e);
      }
    }
    return listTableRow;
  }
Exemplo n.º 14
0
 // revise BeanUtils describe method do not copy data type
 public static Map describe(Object bean)
     throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
   if (bean == null) {
     return (new java.util.HashMap());
   }
   Map description = new HashMap();
   if (bean instanceof DynaBean) {
     DynaProperty[] descriptors = ((DynaBean) bean).getDynaClass().getDynaProperties();
     for (int i = 0; i < descriptors.length; i++) {
       String name = descriptors[i].getName();
       description.put(name, org.apache.commons.beanutils.BeanUtils.getProperty(bean, name));
     }
   } else {
     PropertyDescriptor[] descriptors =
         BeanUtilsBean.getInstance().getPropertyUtils().getPropertyDescriptors(bean);
     Class clazz = bean.getClass();
     for (int i = 0; i < descriptors.length; i++) {
       String name = descriptors[i].getName();
       if (MethodUtils.getAccessibleMethod(clazz, descriptors[i].getReadMethod()) != null) {
         description.put(name, PropertyUtils.getNestedProperty(bean, name));
       }
     }
   }
   return (description);
 }
 @Override
 public boolean isValid(final Object value, final ConstraintValidatorContext context) {
   try {
     final Object firstObj = BeanUtils.getProperty(value, firstFieldName);
     final Object secondObj = BeanUtils.getProperty(value, secondFieldName);
     if (firstObj instanceof String && secondObj instanceof String) {
       String firstString = (String) firstObj;
       String secondString = (String) secondObj;
       return firstString.equalsIgnoreCase(secondString);
     }
     return firstObj == null && secondObj == null;
   } catch (final Exception ignore) {
     // ignore
   }
   return true;
 }
  @Override
  public void setBean(B bean) {
    Class<?> beanClass = bean.getClass();
    java.lang.reflect.Field[] fields = ClassUtils.getAllFields(beanClass);
    for (java.lang.reflect.Field field : fields) {
      Field<?> formField = onCreateField(field.getName());
      if (formField != null) {
        attachForm.attachField(field.getName(), formField);
      } else {
        if (field.getAnnotation(NotBindable.class) != null) {
          continue;
        } else {
          try {
            final String propertyValue =
                BeanUtils.getProperty(attachForm.getBean(), field.getName());
            formField = new DefaultViewField(propertyValue);
          } catch (Exception e) {
            LOG.error("Error while get field value", e);
            formField = new DefaultViewField("Error");
          }

          attachForm.attachField(field.getName(), formField);
        }
      }
    }
  }
Exemplo n.º 17
0
  /** @param args */
  public static void main(String[] args) {
    try {
      Address[] addresses = new Address[2];
      addresses[0] = new Address();
      addresses[0].setCountry("China");
      addresses[0].setCity("Beijing");
      addresses[0].setStreet("Road 1187#");

      addresses[1] = new Address();
      // 为对象的指定属性设值
      BeanUtils.setProperty(addresses[1], "country", "China");
      BeanUtils.setProperty(addresses[1], "city", "Jinan");
      BeanUtils.setProperty(addresses[1], "street", "Road WenHuaDong");

      String[] phoneNumbers = new String[] {"129837132", "394394872"};

      Customer ori = new Customer();
      ori.setId("0001");
      ori.setName("Andy Lau");
      ori.setAddresses(addresses);
      ori.setPhoneNumbers(Arrays.asList(phoneNumbers));
      System.out.println(ori);

      Customer dest = new Customer();
      // 将源对象的所有属性复制给目标属性,实际证明支持内置对象的浅复制
      BeanUtils.copyProperties(dest, ori);
      System.out.println(dest);
      System.out.println(
          "ori.getAddresses() == dest.getAddresses() is "
              + (ori.getAddresses() == dest.getAddresses()));
      System.out.println();

      System.out.println(BeanUtils.getProperty(dest, "name"));
      // 可以通过这种方式访问内置集合(或数组)的元素,等价于以下代码
      // dest.getPhoneNumbers().get(0);
      System.out.println(BeanUtils.getProperty(dest, "phoneNumbers[0]"));
      // 可以通过这种方式访问内置对象的属性,等价于以下代码
      // dest.getAddresses()[1].getCity();
      System.out.println(BeanUtils.getProperty(dest, "addresses[1].city"));
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    } catch (InvocationTargetException e) {
      e.printStackTrace();
    } catch (NoSuchMethodException e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 18
0
 /** @see org.apache.commons.collections.Closure#execute(java.lang.Object) */
 public void execute(Object input) {
   try {
     String value = BeanUtils.getProperty(input, propName_);
     max_ = Math.max(max_, value.length());
   } catch (Exception e) {
     logger_.error(e);
   }
 }
  @Override
  public boolean isValid(Object value, ConstraintValidatorContext context) {
    String idValue = "";
    String[] uniqueValues = new String[uniqueFields.length];

    try {
      idValue = BeanUtils.getProperty(value, idField);

      for (int i = 0; i < uniqueFields.length; i++) {
        uniqueValues[i] = BeanUtils.getProperty(value, uniqueFields[i]);
      }
    } catch (Exception e) {
      log.error("Error looking up field");
      log.error(e.getMessage());
    }

    return !idValue.equals("0") || uniqueValues != null && query(uniqueValues) == 0;
  }
 public Object getId(Object targetObject) throws Exception {
   Object id = null;
   for (Field field : targetObject.getClass().getDeclaredFields()) {
     if (field.isAnnotationPresent(Id.class)) {
       id = BeanUtils.getProperty(targetObject, field.getName());
       break;
     }
   }
   return id;
 }
Exemplo n.º 21
0
  /**
   * Compares to object of the same type
   *
   * @param original
   * @param compare
   * @param consumeFieldsOnly
   * @return True is different, false if the same
   */
  public static boolean isObjectsDifferent(
      Object original, Object compare, boolean consumeFieldsOnly) {
    boolean changed = false;

    if (original != null && compare == null) {
      changed = true;
    } else if (original == null && compare != null) {
      changed = true;
    } else if (original != null && compare != null) {
      if (original.getClass().isInstance(compare)) {
        List<Field> fields = getAllFields(original.getClass());
        for (Field field : fields) {
          boolean check = true;
          if (consumeFieldsOnly) {
            ConsumeField consume = (ConsumeField) field.getAnnotation(ConsumeField.class);
            if (consume == null) {
              check = false;
            }
          }
          if (check) {
            try {
              changed =
                  isFieldsDifferent(
                      BeanUtils.getProperty(original, field.getName()),
                      BeanUtils.getProperty(compare, field.getName()));
              if (changed) {
                break;
              }
            } catch (IllegalAccessException
                | InvocationTargetException
                | NoSuchMethodException ex) {
              throw new OpenStorefrontRuntimeException("Can't compare object types", ex);
            }
          }
        }
      } else {
        throw new OpenStorefrontRuntimeException(
            "Can't compare different object types", "Check objects");
      }
    }
    return changed;
  }
Exemplo n.º 22
0
 // 生成选中消费合计时的sql语句
 public static <T> String sqlForTotal_Cost(T form, String check) {
   String sqlAdd = null;
   String strl = null;
   String strr = null;
   try {
     strl = BeanUtils.getProperty(form, "l_total_cost");
     strr = BeanUtils.getProperty(form, "r_total_cost");
     if (strl == null || strl.equals("")) {
       strl = "0";
     }
     if (strr == null || strr.equals("")) {
       strr = "9999999999";
     }
     sqlAdd = " cast(" + check + " as unsigned) between " + strl + " and " + strr + " and ";
   } catch (Exception e) {
     // TODO Auto-generated catch block
     throw new RuntimeException(e);
   }
   return sqlAdd;
 }
Exemplo n.º 23
0
 /**
  * Initializes the object in the UIDefaults denoted by 'key' to either the property in the metal
  * look and feel associated with defaultMetalObjName, or the defaultObj if all else fails.
  *
  * @param key
  * @param defaultMetalObjName
  * @param defaultObj
  */
 public static void initDefault(String key, String defaultMetalObjName, Object defaultObj) {
   Object obj = UIManager.get(key);
   if (obj == null) {
     try {
       UIManager.put(
           key,
           BeanUtils.getProperty(
               ((MetalLookAndFeel) UIManager.getLookAndFeel()), defaultMetalObjName));
     } catch (Exception e) {
       UIManager.put(key, defaultObj);
     }
   }
 }
Exemplo n.º 24
0
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    String unitcode = BeanUtils.getProperty(form, "unitcode");

    Unit unit = LegacySpringUtils.getUnitManager().get(unitcode);

    request.getSession().setAttribute("unit", unit);

    return LogonUtils.logonChecks(mapping, request);
  }
    /**
     * Renders the HTML content for the browser.
     *
     * @param request the request being handled.
     * @param response the response to write to.
     * @throws Exception on error
     */
    private void doRender(final HttpServletRequest request, final HttpServletResponse response)
        throws Exception {
      SimpleFormBean formBean = getFormBean(request);
      String title = "Some title";

      PrintWriter writer = response.getWriter();

      writer.print("<!DOCTYPE html>");
      writer.print("\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">");
      writer.print("\n<head>");
      writer.print("\n<meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\">");
      writer.print("<title>" + title + "</title>");
      writer.print(
          "<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/my.css/\" media=\"all\">");
      writer.print("\n</head>");
      writer.print("\n<body>");

      writer.print(
          "\n<form method=\"post\" action=\"" + request.getRequestURI() + "\" id=\"mainForm\">");
      writer.print(
          "\n<label id=\"label_formBean.property1\" for=\"formBean.property1\">Property 1:</label>");
      writer.print(
          "\n<input type=\"text\" id=\"formBean.property1\" name=\"formBean.property1\" value=\""
              + BeanUtils.getProperty(formBean, "property1")
              + "\"/>");
      writer.print(
          "\n<label id=\"label_formBean.property2\" for=\"formBean.property2\">Property 2:</label>");
      writer.print(
          "\n<input type=\"text\" id=\"formBean.property2\" name=\"formBean.property2\" value=\""
              + BeanUtils.getProperty(formBean, "property2")
              + "\"/>");
      writer.print("\n<input type=\"submit\" id=\"submit\" name=\"submit\" value=\"Submit\">");
      writer.print("\n</form>");

      writer.print("\n</body>");
      writer.print("\n</html>");
    }
 public ActionForward execute(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   String unitcode = BeanUtils.getProperty(form, "unitcode");
   unitcode = (unitcode == null) ? "" : unitcode;
   String nhsno = BeanUtils.getProperty(form, "nhsno");
   nhsno = (nhsno == null) ? "" : nhsno;
   String name = BeanUtils.getProperty(form, "name");
   name = (name == null) ? "" : name;
   boolean showgps = "true".equals(BeanUtils.getProperty(form, "showgps"));
   DatabaseDAO dao = getDao(request);
   if (!"".equals(unitcode)) {
     HibernateUtil.retrievePersistentObjectAndAddToRequestWithIdParameter(
         request, Unit.class, unitcode, "unit");
   }
   UnitPatientsWithTreatmentDao patientDao =
       new UnitPatientsWithTreatmentDao(unitcode, nhsno, name, showgps);
   List patients = dao.retrieveList(patientDao);
   request.setAttribute("patients", patients);
   return LogonUtils.logonChecks(mapping, request);
 }
 public ActionForward execute(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   Calendar startdate = LoggingUtils.getDefaultStartDateForLogQuery();
   Calendar enddate = LoggingUtils.getDefaultEndDateForLogQuery();
   String nhsno = BeanUtils.getProperty(form, "nhsno");
   List log = getLogEntries(nhsno, startdate, enddate);
   request.setAttribute("log", log);
   UnitUtils.putRelevantUnitsInRequest(request);
   LoggingUtils.defaultDatesInForm(form, startdate, enddate);
   return LogonUtils.logonChecks(mapping, request);
 }
Exemplo n.º 28
0
  private void setupHtcWifiConfiguration(WifiConfiguration config) {
    try {
      Log.d(tag, "config=  " + config);
      Object mWifiApProfileValue = BeanUtils.getProperty(config, "mWifiApProfile");

      if (mWifiApProfileValue != null) {
        BeanUtils.setProperty(mWifiApProfileValue, "SSID", config.SSID);
        BeanUtils.setProperty(mWifiApProfileValue, "BSSID", config.BSSID);
        BeanUtils.setProperty(mWifiApProfileValue, "secureType", "open");
        BeanUtils.setProperty(mWifiApProfileValue, "dhcpEnable", 1);
      }
    } catch (Exception e) {
      Log.e(tag, "" + e.getMessage(), e);
    }
  }
 /**
  * Add the aggregate(grouped by) values passed in via javascript and ajax, to the fields map for
  * the DAO search.
  *
  * @param aggregateValues
  * @param fields
  * @param columns
  * @throws IllegalAccessException
  * @throws InvocationTargetException
  * @throws NoSuchMethodException
  */
 protected void populateAggregateValues(
     ReportTracking aggregateValues, Map<String, String> fields, List<String> columns)
     throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
   for (String column : columns) {
     if (Date.class.isAssignableFrom(ObjectUtils.easyGetPropertyType(aggregateValues, column))
         && ObjectUtils.getPropertyValue(aggregateValues, column) != null) {
       fields.put(
           column,
           getDateTimeService()
               .toDateString(
                   (java.util.Date) ObjectUtils.getPropertyValue(aggregateValues, column)));
     } else {
       fields.put(column, BeanUtils.getProperty(aggregateValues, column));
     }
   }
 }
Exemplo n.º 30
0
 public String toString() {
   StringBuffer sb = new StringBuffer();
   PropertyDescriptor[] pd = PropertyUtils.getPropertyDescriptors(this);
   String value = null;
   for (PropertyDescriptor propertyDescriptor : pd) {
     if (propertyDescriptor.getPropertyType().getName().equals("java.lang.Class")
         && propertyDescriptor.getName().equals("class")) continue;
     try {
       value = BeanUtils.getProperty(this, propertyDescriptor.getName());
     } catch (Exception e) {
       value = "Convert Error";
     }
     sb.append(propertyDescriptor.getName() + "=" + value + "|");
   }
   if (sb.length() > 0) sb.deleteCharAt(sb.length() - 1);
   return sb.toString();
 }