예제 #1
0
  private void ClearItems() {
    if (getItems() == null) {
      return;
    }

    if (getIsGrouppedByTarget()) {
      java.util.List<SanTargetModel> items = (java.util.List<SanTargetModel>) getItems();

      for (SanTargetModel target : Linq.ToList(items)) {
        boolean found = false;

        // Ensure remove targets that are not in last dicovered targets list.
        if (Linq.FirstOrDefault(lastDiscoveredTargets, new Linq.TargetPredicate(target)) != null) {
          found = true;
        } else {
          // Ensure remove targets that are not contain already included LUNs.
          for (LunModel lun : target.getLuns()) {
            LunModel foundItem = Linq.FirstOrDefault(includedLUNs, new Linq.LunPredicate(lun));
            if (foundItem == null) {
              found = true;
              break;
            }
          }
        }

        if (!found) {
          items.remove(target);
        }
      }
    } else {
      java.util.List<LunModel> items = (java.util.List<LunModel>) getItems();

      // Ensure remove targets that are not contain already included LUNs.
      for (LunModel lun : Linq.ToList(items)) {
        LunModel foundItem = Linq.FirstOrDefault(includedLUNs, new Linq.LunPredicate(lun));
        if (foundItem == null) {
          items.remove(lun);
        }
      }
    }
  }