Example #1
0
 private void createSubValue(Entity e, EasytoryFile subEntity, FilterListItem fiNext) {
   EasytoryFile subValue = createFile(subEntity, fiNext.getValue(), true);
   LinkedList<FilterListItem> search = new LinkedList<FilterListItem>();
   search.add(fiNext);
   Iterator<Thing> ti = controller.getFilteredThings(search, e.getName()).iterator();
   while (ti.hasNext()) {
     Thing t = ti.next();
     createFile(subValue, t.getName(), true);
   }
 }
Example #2
0
  /** please refactor me! */
  public void createFilesystem() {
    EasytoryFile root = createRoot();
    Iterator<Entity> entities = controller.getEntities().iterator();
    while (entities.hasNext()) // all entities
    {
      Entity e = entities.next();
      EasytoryFile entity = createFile(root, e.getName(), true);

      Vector<FilterListItem> filterList = controller.getFilter(e.getName());
      Collections.sort(filterList);
      Iterator<FilterListItem> filterIter = filterList.iterator();

      EasytoryFile all; // Create all items
      if (filterIter.hasNext()) all = createFile(entity, "All", true);
      else all = entity;
      Iterator<Thing> items = controller.getThingsByEntity(e.getName()).iterator();
      while (items.hasNext()) {
        Thing t = items.next();
        createFile(all, t.getName(), true);
      }

      while (filterIter.hasNext()) // filter criteria
      {
        FilterListItem fi = filterIter.next();
        EasytoryFile subEntity = createFile(entity, e.getName() + " by " + fi.getValueName(), true);
        createSubValue(e, subEntity, fi);
        String lastFilterEntity = fi.getValueName();
        while (filterIter.hasNext()) {
          FilterListItem fiNext = filterIter.next();
          if (!lastFilterEntity.equals(fiNext.getValueName())) // next subEntity
          {
            subEntity = createFile(entity, e.getName() + " by " + fiNext.getValueName(), true);
          }
          createSubValue(e, subEntity, fiNext);
          lastFilterEntity = fiNext.getValueName();
        }
      }
    }
  }