Search in sources :

Example 46 with EntityModel

use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.

the class VolumeModel method addBricks.

public void addBricks() {
    if (getWindow() != null || getCluster().getSelectedItem() == null) {
        return;
    }
    final VolumeBrickModel volumeBrickModel = new VolumeBrickModel();
    volumeBrickModel.getVolumeType().setEntity(getTypeList().getSelectedItem());
    volumeBrickModel.getReplicaCount().setEntity(getReplicaCount().getEntity());
    volumeBrickModel.getReplicaCount().setIsChangeable(true);
    volumeBrickModel.getReplicaCount().setIsAvailable(getReplicaCount().getIsAvailable());
    volumeBrickModel.getStripeCount().setEntity(getStripeCount().getEntity());
    volumeBrickModel.getStripeCount().setIsChangeable(true);
    volumeBrickModel.getStripeCount().setIsAvailable(getStripeCount().getIsAvailable());
    Cluster cluster = getCluster().getSelectedItem();
    if (cluster != null) {
        volumeBrickModel.getForce().setIsAvailable(true);
        volumeBrickModel.getForce().setEntity(isForceAddBricks());
        volumeBrickModel.setIsBrickProvisioningSupported();
    }
    setWindow(volumeBrickModel);
    volumeBrickModel.setTitle(ConstantsManager.getInstance().getConstants().addBricksTitle());
    volumeBrickModel.setHelpTag(HelpTag.add_bricks);
    // $NON-NLS-1$
    volumeBrickModel.setHashName("add_bricks");
    AsyncDataProvider.getInstance().getHostListByCluster(volumeBrickModel.asyncQuery(hostList -> {
        Iterator<VDS> iterator = hostList.iterator();
        while (iterator.hasNext()) {
            if (iterator.next().getStatus() != VDSStatus.Up) {
                iterator.remove();
            }
        }
        volumeBrickModel.setHostList(hostList);
    }), getCluster().getSelectedItem().getName());
    // TODO: fetch the mount points to display
    if (getBricks().getItems() != null) {
        volumeBrickModel.getBricks().setItems(getBricks().getItems());
    } else {
        volumeBrickModel.getBricks().setItems(new ArrayList<EntityModel<GlusterBrickEntity>>());
    }
    // $NON-NLS-1$
    UICommand command = UICommand.createDefaultOkUiCommand("OnAddBricks", this);
    volumeBrickModel.getCommands().add(command);
    // $NON-NLS-1$
    volumeBrickModel.getCommands().add(UICommand.createCancelUiCommand("Cancel", this));
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) GlusterVolumeType(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) VolumeListModel(org.ovirt.engine.ui.uicommonweb.models.volumes.VolumeListModel) Version(org.ovirt.engine.core.compat.Version) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Model(org.ovirt.engine.ui.uicommonweb.models.Model) Iterator(java.util.Iterator) Linq(org.ovirt.engine.ui.uicommonweb.Linq) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ApplicationModeHelper(org.ovirt.engine.ui.uicommonweb.models.ApplicationModeHelper) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) AsciiNameValidation(org.ovirt.engine.ui.uicommonweb.validation.AsciiNameValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) VDS(org.ovirt.engine.core.common.businessentities.VDS) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) Iterator(java.util.Iterator) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 47 with EntityModel

use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.

the class VolumeModel method clusterSelectedItemChanged.

private void clusterSelectedItemChanged() {
    setBricks(new ListModel<EntityModel<GlusterBrickEntity>>());
    if (getCluster().getSelectedItem() != null) {
        final Cluster cluster = getCluster().getSelectedItem();
        updateArbiterAvailability();
        updateDefaults();
        AsyncDataProvider.getInstance().isAnyHostUpInCluster(new AsyncQuery<>(returnValue -> {
            // In case the result of previous call is returned after selecting some other cluster
            if (!getCluster().getSelectedItem().getId().equals(cluster.getId())) {
                return;
            }
            if (returnValue) {
                getAddBricksCommand().setIsExecutionAllowed(true);
                setMessage(null);
            } else {
                getAddBricksCommand().setIsExecutionAllowed(false);
                setMessage(ConstantsManager.getInstance().getConstants().volumeEmptyClusterValidationMsg());
            }
        }), cluster.getName());
    } else {
        getAddBricksCommand().setIsExecutionAllowed(false);
        setMessage(null);
    }
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) GlusterVolumeType(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) VolumeListModel(org.ovirt.engine.ui.uicommonweb.models.volumes.VolumeListModel) Version(org.ovirt.engine.core.compat.Version) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Model(org.ovirt.engine.ui.uicommonweb.models.Model) Iterator(java.util.Iterator) Linq(org.ovirt.engine.ui.uicommonweb.Linq) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ApplicationModeHelper(org.ovirt.engine.ui.uicommonweb.models.ApplicationModeHelper) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) AsciiNameValidation(org.ovirt.engine.ui.uicommonweb.validation.AsciiNameValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) VDS(org.ovirt.engine.core.common.businessentities.VDS) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Example 48 with EntityModel

use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.

the class GlusterClusterSnapshotConfigModel method clusterSelectedItemChanged.

private void clusterSelectedItemChanged() {
    Cluster selectedCluster = getClusters().getSelectedItem();
    if (selectedCluster == null) {
        return;
    }
    AsyncDataProvider.getInstance().getGlusterSnapshotConfig(new AsyncQuery<>(new AsyncCallback<QueryReturnValue>() {

        @Override
        public void onSuccess(QueryReturnValue returnValue) {
            Pair<List<GlusterVolumeSnapshotConfig>, List<GlusterVolumeSnapshotConfig>> configs = returnValue.getReturnValue();
            if (configs != null) {
                List<GlusterVolumeSnapshotConfig> clusterConfigOptions = configs.getFirst();
                Collections.sort(clusterConfigOptions, Comparator.comparing(GlusterVolumeSnapshotConfig::getParamName));
                setModelItems(getClusterConfigOptions(), clusterConfigOptions, existingClusterConfigs);
            } else {
                getClusterConfigOptions().setItems(null);
            }
        }

        private void setModelItems(ListModel<EntityModel<GlusterVolumeSnapshotConfig>> listModel, List<GlusterVolumeSnapshotConfig> cfgs, Map<String, String> fetchedCfgsBackup) {
            List<EntityModel<GlusterVolumeSnapshotConfig>> coll = new ArrayList<>();
            for (GlusterVolumeSnapshotConfig cfg : cfgs) {
                EntityModel<GlusterVolumeSnapshotConfig> cfgModel = new EntityModel<>();
                cfgModel.setEntity(cfg);
                fetchedCfgsBackup.put(cfg.getParamName(), cfg.getParamValue());
                coll.add(cfgModel);
            }
            // set the entity items
            listModel.setItems(coll);
        }
    }), selectedCluster.getId(), null);
}
Also used : GlusterVolumeSnapshotConfig(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 49 with EntityModel

use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.

the class GlusterClusterSnapshotConfigModel method validate.

public boolean validate() {
    boolean isValid = true;
    setMessage(null);
    Iterable<EntityModel<GlusterVolumeSnapshotConfig>> items1 = getClusterConfigOptions().getItems();
    for (EntityModel<GlusterVolumeSnapshotConfig> model : items1) {
        GlusterVolumeSnapshotConfig option = model.getEntity();
        if (option.getParamValue().trim().length() == 0) {
            setMessage(ConstantsManager.getInstance().getMessages().clusterSnapshotOptionValueEmpty(option.getParamName()));
            isValid = false;
            break;
        }
    }
    return isValid;
}
Also used : GlusterVolumeSnapshotConfig(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel)

Example 50 with EntityModel

use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.

the class InstanceImageLineModel method attachDisk.

public void attachDisk() {
    if (parentModel.getUnitVmModel().getSelectedCluster() == null || parentModel.getUnitVmModel().getSelectedDataCenter() == null) {
        return;
    }
    InstanceImagesAttachDiskModel model = new InstanceImagesAttachDiskModel() {

        @Override
        public void onSave() {
            if (validate()) {
                flush();
                List<EntityModel<DiskModel>> selectedDisks = getSelectedDisks();
                if (selectedDisks.size() == 1) {
                    // only 0 or 1 is allowed
                    setDisk(selectedDisks.iterator().next().getEntity().getDisk());
                }
                getDiskModel().setEntity(this);
                InstanceImageLineModel.this.setChanged(true);
                setDiskModel(null);
                // from now on only editing is possible
                attachCommand.setIsAvailable(false);
                fillData();
            }
        }

        @Override
        public void updateInterface(Version clusterVersion) {
            InstanceImageLineModel.this.updateInterface(clusterVersion, this);
        }

        @Override
        protected void updateBootableDiskAvailable() {
            updateBootableFrom(parentModel.getAllCurrentDisksModels());
        }

        @Override
        protected List<Disk> getAttachedNotSubmittedDisks() {
            return parentModel.getNotYetAttachedNotAttachableDisks();
        }
    };
    VM realOrFakeVm = vm;
    Version compatibilityVersion = parentModel.getUnitVmModel().getSelectedCluster().getCompatibilityVersion();
    if (realOrFakeVm == null) {
        realOrFakeVm = new VM();
        realOrFakeVm.setId(null);
        realOrFakeVm.setClusterId(parentModel.getUnitVmModel().getSelectedCluster().getId());
        realOrFakeVm.setStoragePoolId(parentModel.getUnitVmModel().getSelectedDataCenter().getId());
        realOrFakeVm.setClusterCompatibilityVersion(compatibilityVersion);
    }
    model.setVm(realOrFakeVm);
    setupModelAsDialog(model, ConstantsManager.getInstance().getConstants().attachVirtualDiskTitle(), HelpTag.attach_virtual_disk, // $NON-NLS-1$
    "attach_virtual_disk");
    setDiskModel(model);
    model.initialize(parentModel.getAllCurrentDisksModels());
    maybeLoadAttachableDisks(model);
}
Also used : Version(org.ovirt.engine.core.compat.Version) VM(org.ovirt.engine.core.common.businessentities.VM) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Aggregations

EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)105 ArrayList (java.util.ArrayList)56 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)27 List (java.util.List)26 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)23 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)22 ListModel (org.ovirt.engine.ui.uicommonweb.models.ListModel)22 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)22 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)20 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)19 ActionType (org.ovirt.engine.core.common.action.ActionType)18 Frontend (org.ovirt.engine.ui.frontend.Frontend)18 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)17 Guid (org.ovirt.engine.core.compat.Guid)17 PropertyChangedEventArgs (org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs)17 VDS (org.ovirt.engine.core.common.businessentities.VDS)16 QueryType (org.ovirt.engine.core.common.queries.QueryType)16 NoSelectionModel (com.google.gwt.view.client.NoSelectionModel)13 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)13 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)13