Ejemplo n.º 1
0
 public static Cleaning buildFromElement(Element e, List<Item> items) throws ParseException {
   SimpleDateFormat sdf = new SimpleDateFormat(CleaningApplication.DATE_FORMAT);
   Cleaning cleaning = new Cleaning();
   cleaning.setName(e.getAttribute("name"));
   cleaning.setPlanedDate(sdf.parse(e.getAttribute("planedDate")));
   String doneDate = e.getAttribute("doneDate");
   if (!doneDate.isEmpty()) {
     cleaning.setDoneDate(sdf.parse(doneDate));
   }
   NodeList itemsList = e.getChildNodes();
   for (int i = 0; i < itemsList.getLength(); i++) {
     Node childNode = itemsList.item(i);
     if (childNode.getNodeType() == Node.ELEMENT_NODE) {
       if (childNode.getNodeName().equalsIgnoreCase("itemClening")) {
         Element child = (Element) childNode;
         Integer idItem = new Integer(child.getAttribute("idItem"));
         for (Item item : items) {
           if (item.getIdItem() == idItem) {
             cleaning.items.add(item);
             break;
           }
         }
       } else if (childNode.getNodeName().equalsIgnoreCase("tasks")) {
         Element child = (Element) childNode;
         cleaning.getTasks().add(Task.TaskBuilder.buildFromElement(child, items));
       }
     }
   }
   return cleaning;
 }
Ejemplo n.º 2
0
 public static Cleaning buildCleaning(String name, Date scheduled) {
   Cleaning cleaning = new Cleaning();
   cleaning.name = name;
   cleaning.planedDate = scheduled;
   cleaning.items = new ArrayList<>();
   return cleaning;
 }