public java.util.ArrayList<LunModel> getAddedLuns() { java.util.ArrayList<LunModel> luns = new java.util.ArrayList<LunModel>(); if (getIsGrouppedByTarget()) { java.util.List<SanTargetModel> items = (java.util.List<SanTargetModel>) getItems(); for (SanTargetModel item : items) { for (LunModel lun : item.getLuns()) { if (lun.getIsSelected() && !lun.getIsIncluded() && Linq.FirstOrDefault(luns, new Linq.LunPredicate(lun)) == null) { luns.add(lun); } } } } else { java.util.List<LunModel> items = (java.util.List<LunModel>) getItems(); for (LunModel lun : items) { if (lun.getIsSelected() && !lun.getIsIncluded() && Linq.FirstOrDefault(luns, new Linq.LunPredicate(lun)) == null) { luns.add(lun); } } } return luns; }
private java.util.List<SanTargetModel> ToTargetModelList(java.util.List<LunModel> source) { ObservableCollection<SanTargetModel> list = new ObservableCollection<SanTargetModel>(); for (LunModel lun : source) { for (SanTargetModel target : lun.getTargets()) { SanTargetModel item = Linq.FirstOrDefault(list, new Linq.TargetPredicate(target)); if (item == null) { item = target; list.add(item); } if (Linq.FirstOrDefault(item.getLuns(), new Linq.LunPredicate(lun)) == null) { item.getLuns().add(lun); } } } // Merge with last discovered targets list. for (SanTargetModel target : lastDiscoveredTargets) { if (Linq.FirstOrDefault(list, new Linq.TargetPredicate(target)) == null) { list.add(target); } } return list; }
private void MergeLunsToTargets( java.util.List<LunModel> newLuns, java.util.List<SanTargetModel> targets) { for (LunModel lun : newLuns) { for (SanTargetModel target : lun.getTargets()) { SanTargetModel item = Linq.FirstOrDefault(targets, new Linq.TargetPredicate(target)); if (item == null) { item = target; targets.add(item); } if (Linq.FirstOrDefault(item.getLuns(), new Linq.LunPredicate(lun)) == null) { item.getLuns().add(lun); } } } }
private java.util.List<LunModel> ToLunModelList(java.util.List<SanTargetModel> source) { ObservableCollection<LunModel> list = new ObservableCollection<LunModel>(); for (SanTargetModel target : source) { for (LunModel lun : target.getLuns()) { LunModel item = Linq.FirstOrDefault(list, new Linq.LunPredicate(lun)); if (item == null) { item = lun; list.add(item); } if (Linq.FirstOrDefault(item.getTargets(), new Linq.TargetPredicate(target)) == null) { item.getTargets().add(target); } } } return list; }
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); } } } }