コード例 #1
0
 private boolean isSelectedDiskInterfaceIDE(List<EntityModel<DiskModel>> selectedDisks) {
   for (EntityModel<DiskModel> selectedDisk : selectedDisks) {
     if (selectedDisk.getEntity().getDisk().getDiskInterface() == DiskInterface.IDE) {
       return true;
     }
   }
   return false;
 }
コード例 #2
0
 @Override
 protected void updateDetailsAvailability() {
   if (getSelectedItem() != null) {
     DbUser adUser = (DbUser) getSelectedItem();
     userGroupListModel.setIsAvailable(!adUser.isGroup());
     userEventNotifierListModel.setIsAvailable(!adUser.isGroup());
   }
 }
コード例 #3
0
  @Override
  public void executeCommand(UICommand command) {
    super.executeCommand(command);

    startProgress();

    ArrayList<VdcActionParametersBase> actionParameters = new ArrayList<>();

    for (EntityModel entity : getEntities()) {
      RepoImage repoImage = (RepoImage) entity.getEntity();
      ImportRepoImageParameters importParameters = new ImportRepoImageParameters();

      // source
      importParameters.setSourceRepoImageId(repoImage.getRepoImageId());
      importParameters.setSourceStorageDomainId(sourceStorageDomain.getId());

      // destination
      importParameters.setDiskAlias(((RepoImageModel) entity).getDiskImageAlias());
      importParameters.setStoragePoolId(((StoragePool) getDataCenter().getSelectedItem()).getId());
      importParameters.setStorageDomainId(
          ((StorageDomain) getStorageDomain().getSelectedItem()).getId());
      importParameters.setClusterId(((StorageDomain) getStorageDomain().getSelectedItem()).getId());

      Quota selectedQuota = (Quota) getQuota().getSelectedItem();

      if (selectedQuota != null) {
        importParameters.setQuotaId(selectedQuota.getId());
      }

      Boolean importAsTemplate = getImportAsTemplate().getEntity();
      importParameters.setImportAsTemplate(importAsTemplate);

      if (importAsTemplate) {
        importParameters.setClusterId(((VDSGroup) getCluster().getSelectedItem()).getId());
      }

      actionParameters.add(importParameters);
    }

    Frontend.getInstance()
        .runMultipleAction(
            VdcActionType.ImportRepoImage,
            actionParameters,
            new IFrontendMultipleActionAsyncCallback() {
              @Override
              public void executed(FrontendMultipleActionAsyncResult result) {
                ImportExportRepoImageBaseModel model =
                    (ImportExportRepoImageBaseModel) result.getState();
                model.stopProgress();
                model.cancel();
              }
            },
            this);
  }
コード例 #4
0
ファイル: Linq.java プロジェクト: derekhiggins/ovirt-engine
  public static <T> ArrayList<EntityModel> ToEntityModelList(ArrayList<T> list) {
    ArrayList<EntityModel> entityModelList = new ArrayList<EntityModel>();

    if (list != null) {
      for (Object item : list) {
        EntityModel model = new EntityModel();
        model.setEntity(item);
        entityModelList.add(model);
      }
    }

    return entityModelList;
  }
コード例 #5
0
 private void addBondOptionIfMissing(
     String candidateOption, boolean doesBondHaveVmNetworkAttached) {
   if (doesBondHaveVmNetworkAttached && !BondMode.isBondModeValidForVmNetwork(candidateOption)) {
     return;
   }
   if (!pairForBondOption.containsKey(candidateOption)) {
     EntityModel<String> entityModel = new EntityModel<String>();
     entityModel.setEntity(candidateOption);
     Entry<String, EntityModel<String>> newPair =
         new KeyValuePairCompat<String, EntityModel<String>>("custom", entityModel); // $NON-NLS-1$
     bondOptions.add(newPair);
     pairForBondOption.put(candidateOption, newPair);
   }
 }
コード例 #6
0
  public ListModel getEntityListModel() {
    ListModel listModel = new ListModel();
    ArrayList arrayList = new ArrayList();

    for (Object object : (List) getEntity()) {
      EntityModel entityModel = new EntityModel();
      entityModel.setEntity(object);

      arrayList.add(entityModel);
    }
    listModel.setItems(arrayList);

    return listModel;
  }
コード例 #7
0
 @Override
 protected void addUsersToModel(VdcQueryReturnValue returnValue, Set<String> excludeUsers) {
   Iterable<DbUser> filteredUsers =
       Linq.where(
           (ArrayList<DbUser>) returnValue.getReturnValue(),
           new Linq.DbUserPredicate(getTargetDbUser()));
   for (DbUser dbUser : filteredUsers) {
     if (!excludeUsers.contains(dbUser.getExternalId())) {
       EntityModel tempVar2 = new EntityModel();
       tempVar2.setEntity(dbUser);
       getusers().add(tempVar2);
     }
   }
 }
コード例 #8
0
ファイル: ProviderModel.java プロジェクト: nirs/ovirt-engine
  private void flush() {
    provider.setName(name.getEntity());
    provider.setType(type.getSelectedItem());
    provider.setDescription(description.getEntity());
    provider.setUrl(url.getEntity());

    if (isTypeOpenStackNetwork()) {
      getNeutronAgentModel().flush(provider);
    } else if (isTypeOpenStackImage()) {
      provider.setAdditionalProperties(new OpenStackImageProviderProperties());
    } else if (isTypeOpenStackVolume()) {
      provider.setAdditionalProperties(
          new OpenStackVolumeProviderProperties(getDataCenter().getSelectedItem().getId()));
    } else if (isTypeVmware()) {
      provider.setAdditionalProperties(
          getVmwarePropertiesModel()
              .getVmwareVmProviderProperties(dataCenter.getSelectedItem().getId()));
      provider.setUrl(getVmwarePropertiesModel().getUrl());
    }

    boolean authenticationRequired = requiresAuthentication.getEntity();
    provider.setRequiringAuthentication(authenticationRequired);
    if (authenticationRequired) {
      provider.setUsername(getUsername().getEntity());
      provider.setPassword(getPassword().getEntity());
      if (getTenantName().getIsAvailable()) {
        TenantProviderProperties properties =
            (TenantProviderProperties) provider.getAdditionalProperties();
        if (properties == null) {
          properties = new TenantProviderProperties();
          provider.setAdditionalProperties(properties);
        }
        properties.setTenantName(getTenantName().getEntity());
      }
      provider.setAuthUrl(getAuthUrl().getEntity());
    } else {
      provider.setUsername(null);
      provider.setPassword(null);
      if (getTenantName().getIsAvailable()) {
        TenantProviderProperties properties =
            (TenantProviderProperties) provider.getAdditionalProperties();
        if (properties != null) {
          properties.setTenantName(null);
        }
      }
      provider.setAuthUrl(null);
    }
  }
コード例 #9
0
  @Override
  protected void OnEntityChanged() {
    super.OnEntityChanged();

    if (getEntity() != null) {
      UpdateProperties();
    }
  }
コード例 #10
0
  public UserPortalLoginModel() {
    setChangePasswordCommand(new UICommand("ChangePassword", this));

    setNewPassword(new EntityModel());
    setVerifyPassword(new EntityModel());

    EntityModel tempVar = new EntityModel();
    tempVar.setEntity(true);
    setIsENGINEUser(tempVar);
    EntityModel tempVar2 = new EntityModel();
    tempVar2.setEntity(true);
    setIsAutoConnect(tempVar2);
  }
コード例 #11
0
  @Override
  protected void addGroupsToModel(VdcQueryReturnValue returnValue, Set<String> excludeUsers) {
    Iterable<DbGroup> filteredGroups =
        Linq.where(
            (ArrayList<DbGroup>) returnValue.getReturnValue(),
            new Linq.DbGroupPredicate(getTargetDbGroup()));

    for (DbGroup group : filteredGroups) {
      if (!excludeUsers.contains(group.getId().toString())) {
        DbUser dbUser = new DbUser();
        dbUser.setExternalId(group.getExternalId());
        dbUser.setFirstName(group.getName());
        dbUser.setLastName(""); // $NON-NLS-1$
        dbUser.setLoginName(""); // $NON-NLS-1$
        dbUser.setDomain(group.getDomain());
        dbUser.setNamespace(group.getNamespace());

        EntityModel entity = new EntityModel();
        entity.setEntity(dbUser);
        getgroups().add(entity);
      }
    }
  }
コード例 #12
0
ファイル: Linq.java プロジェクト: derekhiggins/ovirt-engine
  public static DiskModel DiskToModel(Disk disk) {
    DiskModel diskModel = new DiskModel();
    diskModel.setIsNew(true);
    diskModel.getAlias().setEntity(disk.getDiskAlias());

    if (disk.getDiskStorageType() == DiskStorageType.IMAGE) {
      DiskImage diskImage = (DiskImage) disk;
      EntityModel sizeEntity = new EntityModel();
      sizeEntity.setEntity(diskImage.getSizeInGigabytes());
      diskModel.setSize(sizeEntity);
      ListModel volumeList = new ListModel();
      volumeList.setItems(
          (diskImage.getvolume_type() == VolumeType.Preallocated
              ? new ArrayList<VolumeType>(Arrays.asList(new VolumeType[] {VolumeType.Preallocated}))
              : DataProvider.GetVolumeTypeList()));
      volumeList.setSelectedItem(diskImage.getvolume_type());
      diskModel.setVolumeType(volumeList);
    }

    diskModel.setDisk(disk);

    return diskModel;
  }
コード例 #13
0
  @Override
  protected void initDetailModels() {
    super.initDetailModels();

    ObservableCollection<EntityModel> list = new ObservableCollection<EntityModel>();
    list.add(new UserGeneralModel());
    list.add(new UserQuotaListModel());
    list.add(new UserPermissionListModel());
    list.add(new UserEventListModel());
    userGroupListModel = new UserGroupListModel();
    userGroupListModel.setIsAvailable(false);
    list.add(userGroupListModel);
    userEventNotifierListModel = new UserEventNotifierListModel();
    list.add(userEventNotifierListModel);
    setDetailModels(list);
  }
コード例 #14
0
  @Override
  protected void onEntityChanged() {
    super.onEntityChanged();

    if (getEntity() != null) {
      StorageDomain storageDomain = (StorageDomain) getEntity();

      setIsNfs(storageDomain.getStorageType() == StorageType.NFS);
      setIsLocalS(storageDomain.getStorageType() == StorageType.LOCALFS);
      setIsPosix(storageDomain.getStorageType() == StorageType.POSIXFS);

      if (getIsNfs() || getIsLocalS() || getIsPosix()) {
        AsyncQuery _asyncQuery = new AsyncQuery();
        _asyncQuery.setModel(this);
        _asyncQuery.asyncCallback =
            new INewAsyncCallback() {
              @Override
              public void onSuccess(Object model, Object ReturnValue) {
                StorageServerConnections connection = (StorageServerConnections) ReturnValue;
                StorageGeneralModel generalModel = (StorageGeneralModel) model;

                generalModel.setPath(connection == null ? null : connection.getconnection());

                if (isNfs) {
                  generalModel.setNfsVersion(connection.getNfsVersion());
                  generalModel.setRetransmissions(connection.getNfsRetrans());
                  generalModel.setTimeout(connection.getNfsTimeo());
                }

                if (isPosix) {
                  generalModel.setVfsType(connection.getVfsType());
                  generalModel.setMountOptions(connection.getMountOptions());
                }
              }
            };
        AsyncDataProvider.getInstance()
            .getStorageConnectionById(_asyncQuery, storageDomain.getStorage(), true);
      } else {
        setPath(null);
      }
    }
  }
コード例 #15
0
  private void onAdd() {
    AdElementListModel model = (AdElementListModel) getWindow();

    if (model.getProgress() != null) {
      return;
    }

    if (!model.getIsEveryoneSelected() && model.getSelectedItems() == null) {
      cancel();
      return;
    }

    ArrayList<DbUser> items = new ArrayList<DbUser>();
    if (model.getIsEveryoneSelected()) {
      DbUser tempVar = new DbUser();
      tempVar.setId(ApplicationGuids.everyone.asGuid());
      items.add(tempVar);
    } else {
      for (Object item : model.getItems()) {
        EntityModel entityModel = (EntityModel) item;
        if (entityModel.getIsSelected()) {
          items.add((DbUser) entityModel.getEntity());
        }
      }
    }

    Role role = (Role) model.getRole().getSelectedItem();
    // adGroup/user

    ArrayList<VdcActionParametersBase> list = new ArrayList<VdcActionParametersBase>();
    for (DbUser user : items) {
      Permissions tempVar2 = new Permissions();
      tempVar2.setad_element_id(user.getId());
      tempVar2.setrole_id(role.getId());
      Permissions perm = tempVar2;
      perm.setObjectId(getEntityGuid());
      perm.setObjectType(this.getObjectType());

      if (user.isGroup()) {
        DbGroup group = new DbGroup();
        group.setId(user.getId());
        group.setExternalId(user.getExternalId());
        group.setName(user.getFirstName());
        group.setDomain(user.getDomain());
        group.setNamespace(user.getNamespace());
        PermissionsOperationsParameters tempVar3 = new PermissionsOperationsParameters();
        tempVar3.setPermission(perm);
        tempVar3.setGroup(group);
        list.add(tempVar3);
      } else {
        PermissionsOperationsParameters tempVar4 = new PermissionsOperationsParameters();
        tempVar4.setPermission(perm);
        tempVar4.setUser(user);
        list.add(tempVar4);
      }
    }

    model.startProgress(null);

    Frontend.getInstance()
        .runMultipleAction(
            VdcActionType.AddPermission,
            list,
            new IFrontendMultipleActionAsyncCallback() {
              @Override
              public void executed(FrontendMultipleActionAsyncResult result) {

                AdElementListModel localModel = (AdElementListModel) result.getState();
                localModel.stopProgress();
                cancel();
              }
            },
            model);
  }
コード例 #16
0
 @Override
 protected void OnEntityChanged() {
   // TODO Auto-generated method stub
   super.OnEntityChanged();
   updatePropeties();
 }
コード例 #17
0
  @Override
  protected void EntityPropertyChanged(Object sender, PropertyChangedEventArgs e) {
    super.EntityPropertyChanged(sender, e);

    UpdateProperties();
  }
コード例 #18
0
  public void onAdd() {
    AdElementListModel model = (AdElementListModel) getWindow();

    if (model.getProgress() != null) {
      return;
    }

    if (model.getSelectedItems() == null) {
      cancel();
      return;
    }

    ArrayList<DbUser> items = new ArrayList<DbUser>();
    for (Object item : model.getItems()) {
      EntityModel entityModel = (EntityModel) item;
      if (entityModel.getIsSelected()) {
        items.add((DbUser) entityModel.getEntity());
      }
    }

    ArrayList<VdcActionType> actionsList = new ArrayList<VdcActionType>(items.size());
    ArrayList<VdcActionParametersBase> parametersList =
        new ArrayList<VdcActionParametersBase>(items.size());
    VdcActionParametersBase parameters = null;
    for (DbUser item : items) {
      if (item.isGroup()) {
        actionsList.add(VdcActionType.AddGroup);
        DbGroup grp = new DbGroup();
        grp.setExternalId(item.getExternalId());
        grp.setName(item.getFirstName());
        grp.setNamespace(item.getNamespace());
        grp.setId(item.getId());
        grp.setDomain(item.getDomain());
        grp.setActive(item.isActive());
        parameters = new AddGroupParameters(grp);
      } else {
        actionsList.add(VdcActionType.AddUser);
        parameters = new AddUserParameters(item);
      }
      parametersList.add(parameters);
    }

    model.startProgress(null);

    IFrontendActionAsyncCallback nopCallback =
        new IFrontendActionAsyncCallback() {
          @Override
          public void executed(FrontendActionAsyncResult result) {
            // Nothing.
          }
        };

    IFrontendActionAsyncCallback lastCallback =
        new IFrontendActionAsyncCallback() {
          @Override
          public void executed(FrontendActionAsyncResult result) {
            AdElementListModel localModel = (AdElementListModel) result.getState();
            localModel.stopProgress();
            cancel();
          }
        };

    ArrayList<IFrontendActionAsyncCallback> callbacksList =
        new ArrayList<IFrontendActionAsyncCallback>(items.size());
    for (int i = 1; i < items.size(); i++) {
      callbacksList.add(nopCallback);
    }
    callbacksList.add(lastCallback);

    Frontend.getInstance()
        .runMultipleActions(actionsList, parametersList, callbacksList, lastCallback, model);
  }
コード例 #19
0
  public void OnManage() {
    ListModel model = (ListModel) getWindow();

    java.util.ArrayList<EntityModel> items = Linq.<EntityModel>Cast(model.getItems());
    java.util.ArrayList<network> networks = Linq.<network>Cast(getItems());

    if (getEntity() == null) {
      Cancel();
      return;
    }

    java.util.ArrayList<VdcActionParametersBase> prms1 =
        new java.util.ArrayList<VdcActionParametersBase>();
    for (EntityModel a : items) {
      boolean value = false;
      for (network b : networks) {
        if (b.getId().equals(((network) a.getEntity()).getId())) {
          value = true;
          break;
        }
      }
      if (a.getIsSelected() && !value) {
        prms1.add(new AttachNetworkToVdsGroupParameter(getEntity(), (network) a.getEntity()));
      }
    }

    // Call the command only if necessary (i.e. only if there are paramters):
    if (prms1.size() > 0) {
      Frontend.RunMultipleAction(VdcActionType.AttachNetworkToVdsGroup, prms1);
    }

    java.util.ArrayList<VdcActionParametersBase> prms2 =
        new java.util.ArrayList<VdcActionParametersBase>();
    for (EntityModel a : items) {
      boolean value = true;
      for (network b : networks) {
        if (b.getId().equals(((network) a.getEntity()).getId())) {
          value = false;
          break;
        }
      }
      if (!a.getIsSelected() && !value) {
        prms2.add(new AttachNetworkToVdsGroupParameter(getEntity(), (network) a.getEntity()));
      }
    }

    // Call the command only if necessary (i.e. only if there are paramters):
    if (prms2.size() > 0) {
      Frontend.RunMultipleAction(VdcActionType.DetachNetworkToVdsGroup, prms2);
    }

    Cancel();
  }
コード例 #20
0
  private void onAttach() {
    AdElementListModel model = (AdElementListModel) getWindow();

    if (model.getProgress() != null) {
      return;
    }

    if (model.getSelectedItems() == null) {
      cancel();
      return;
    }

    ArrayList<DbUser> items = new ArrayList<DbUser>();
    for (Object item : model.getItems()) {
      EntityModel entityModel = (EntityModel) item;
      if (entityModel.getIsSelected()) {
        items.add((DbUser) entityModel.getEntity());
      }
    }

    Role role = model.getRole().getSelectedItem();

    ArrayList<VdcActionParametersBase> list = new ArrayList<VdcActionParametersBase>();
    for (DbUser user : items) {
      Permission perm = new Permission(user.getId(), role.getId(), null, null);

      if (user.isGroup()) {
        DbGroup group = new DbGroup();
        group.setId(user.getId());
        group.setName(user.getFirstName());
        group.setDomain(user.getDomain());
        group.setExternalId(user.getExternalId());
        group.setNamespace(user.getNamespace());
        PermissionsOperationsParameters tempVar2 = new PermissionsOperationsParameters();
        tempVar2.setPermission(perm);
        tempVar2.setGroup(group);
        list.add(tempVar2);
      } else {
        PermissionsOperationsParameters tempVar3 = new PermissionsOperationsParameters();
        tempVar3.setPermission(perm);
        tempVar3.setUser(user);
        list.add(tempVar3);
      }
    }

    model.startProgress(null);

    Frontend.getInstance()
        .runMultipleAction(
            VdcActionType.AddSystemPermission,
            list,
            new IFrontendMultipleActionAsyncCallback() {
              @Override
              public void executed(FrontendMultipleActionAsyncResult result) {

                AdElementListModel localModel = (AdElementListModel) result.getState();
                localModel.stopProgress();
                cancel();
              }
            },
            model);
  }
コード例 #21
0
  public void PostManage(java.util.ArrayList<network> networkList, ListModel model) {
    Collections.sort(networkList, new Linq.NetworkByNameComparer());

    java.util.ArrayList<EntityModel> items = new java.util.ArrayList<EntityModel>();
    for (network a : networkList) {
      if (!a.getname().equals("engine")) {
        EntityModel tempVar = new EntityModel();
        tempVar.setEntity(a);
        tempVar.setTitle(a.getname());
        items.add(tempVar);
      }
    }
    model.setItems(items);

    boolean noItems = items.isEmpty();

    java.util.ArrayList<network> networks = Linq.<network>Cast(getItems());
    java.util.ArrayList<EntityModel> selectedItems = new java.util.ArrayList<EntityModel>();
    for (EntityModel item : items) {
      network net = (network) item.getEntity();
      boolean value = false;
      for (network a : networks) {
        if (a.getId().equals(net.getId())) {
          value = true;
          break;
        }
      }
      item.setIsSelected(value);
      if (value) {
        selectedItems.add(item);
      }
    }

    model.setSelectedItems(selectedItems);

    UICommand tempVar2 = new UICommand("Cancel", this);
    tempVar2.setTitle("Cancel");
    tempVar2.setIsDefault(noItems);
    tempVar2.setIsCancel(true);
    model.getCommands().add(tempVar2);

    if (!noItems) {
      UICommand tempVar3 = new UICommand("OnManage", this);
      tempVar3.setTitle("OK");
      tempVar3.setIsDefault(true);
      model.getCommands().add(0, tempVar3);
    }
  }