Ejemplo n.º 1
0
 // populate (could optionally have reflective populate)
 public synchronized void populate(SQLRow row) {
   row.setValue("source", food.getSource().getName());
   row.setValue("food", food.getSourceID());
   if (date != 0) {
     row.setValue("time", new Timestamp(date));
   }
   row.setValue("grams", new Double(grams));
   if (measure != Measure.GRAM) {
     row.setValue("measure", measure.getDescription());
   }
 }
Ejemplo n.º 2
0
 /**
  * Find a matching measure by name in this food
  *
  * @param measureName
  */
 public void setMeasure(String measureName) {
   if (food == null) {
     return;
   }
   List measures = getFoodProxy().getFood().getMeasures();
   for (int i = 0; i < measures.size(); i++) {
     Measure m = (Measure) measures.get(i);
     if (m.getDescription().equals(measureName)) {
       setMeasure(m);
       return;
     }
   }
   // if nothing found, default to GRAMS
   setMeasure(Measure.GRAM);
 }
Ejemplo n.º 3
0
 public synchronized XMLNode toXML() {
   XMLNode node = new XMLNode("serving");
   node.addAttribute("source", food.getSource().getName());
   node.addAttribute("food", food.getSourceID());
   if (date != 0) {
     node.addAttribute("date", date);
   }
   node.addAttribute("grams", grams);
   if (measure != Measure.GRAM) {
     node.addAttribute("measure", measure.getDescription());
   }
   if (meal != -1) {
     node.addAttribute("meal", meal);
   }
   return node;
 }