public static void proceedLUNInDb(final LUNs lun, StorageType storageType) {
    if (DbFacade.getInstance().getLunDAO().get(lun.getLUN_id()) == null) {
      DbFacade.getInstance().getLunDAO().save(lun);
    }
    for (storage_server_connections connection : lun.getLunConnections()) {
      List<storage_server_connections> connections =
          DbFacade.getInstance().getStorageServerConnectionDAO().getAllForConnection(connection);
      if (connections.isEmpty()) {
        connection.setid(Guid.NewGuid().toString());
        connection.setstorage_type(storageType);
        DbFacade.getInstance().getStorageServerConnectionDAO().save(connection);

      } else {
        connection.setid(connections.get(0).getid());
      }
      if (DbFacade.getInstance()
              .getStorageServerConnectionLunMapDAO()
              .get(new LUN_storage_server_connection_map_id(lun.getLUN_id(), connection.getid()))
          == null) {
        DbFacade.getInstance()
            .getStorageServerConnectionLunMapDAO()
            .save(new LUN_storage_server_connection_map(lun.getLUN_id(), connection.getid()));
      }
    }
  }
  /** Creates model items from the provided list of business entities. */
  public void ApplyData(java.util.List<LUNs> source, boolean isIncluded) {
    java.util.ArrayList<LunModel> newItems = new java.util.ArrayList<LunModel>();

    for (LUNs a : source) {
      if (a.getLunType() == getType() || a.getLunType() == StorageType.UNKNOWN) {
        java.util.ArrayList<SanTargetModel> targets = new java.util.ArrayList<SanTargetModel>();
        for (storage_server_connections b : a.getLunConnections()) {
          SanTargetModel tempVar = new SanTargetModel();
          tempVar.setAddress(b.getconnection());
          tempVar.setPort(b.getport());
          tempVar.setName(b.getiqn());
          tempVar.setIsSelected(true);
          tempVar.setIsLoggedIn(true);
          tempVar.setLuns(new ObservableCollection<LunModel>());
          SanTargetModel model = tempVar;
          model.getLoginCommand().setIsExecutionAllowed(false);

          targets.add(model);
        }

        LunModel tempVar2 = new LunModel();
        tempVar2.setLunId(a.getLUN_id());
        tempVar2.setVendorId(a.getVendorId());
        tempVar2.setProductId(a.getProductId());
        tempVar2.setSerial(a.getSerial());
        tempVar2.setMultipathing(a.getPathCount());
        tempVar2.setTargets(targets);
        tempVar2.setSize(a.getDeviceSize());
        tempVar2.setIsAccessible(a.getAccessible());
        tempVar2.setIsIncluded(isIncluded);
        tempVar2.setIsSelected(isIncluded);
        LunModel lun = tempVar2;
        newItems.add(lun);

        // Remember included LUNs to prevent their removal while updating items.
        if (isIncluded) {
          includedLUNs.add(lun);
        }
      }
    }

    InitializeItems(newItems, null);
    ProposeDiscover();
  }