Exemplo n.º 1
0
 @Override
 public void saveWeight(ServiceContext context, Weight weight) throws JServiceException {
   if (JStringUtils.isNullOrEmpty(weight.getUserName())) {
     // DEFAULT TO LOGIN USER
     weight.setUserName(context.getUser().getUserName());
   }
   if (weight.getRecordTime() == null) {
     weight.setRecordTime(new Timestamp(new Date().getTime()));
   }
   saveOnly(context, weight);
 }
Exemplo n.º 2
0
 public String toViewChart() throws Exception {
   List<Weight> weights =
       weightService.getWeightByName(getServiceContext(), getSessionUser().getUserName());
   List<SimpleLineChart> lineCharts = new ArrayList<SimpleLineChart>();
   if (weights != null) {
     for (Iterator<Weight> iterator = weights.iterator(); iterator.hasNext(); ) {
       Weight weight = iterator.next();
       SimpleLineChart lineChart = new SimpleLineChart();
       lineChart.setXvalue(JDateUtils.formatWithSeconds(weight.getRecordTime()));
       lineChart.setYvalue(weight.getWeight());
       lineCharts.add(lineChart);
     }
   }
   setAttribute("lineCharts", lineCharts);
   return "/WEB-INF/jsp/weight/view-chart-weight.jsp";
 }