Search in sources :

Example 81 with ActionParametersBase

use of org.ovirt.engine.core.common.action.ActionParametersBase in project ovirt-engine by oVirt.

the class DataCenterListModel method onRemove.

public void onRemove() {
    ConfirmationModel model = (ConfirmationModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    ArrayList<ActionParametersBase> parameters = new ArrayList<>();
    for (StoragePool a : getSelectedItems()) {
        parameters.add(new StoragePoolParametersBase(a.getId()));
    }
    model.startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.RemoveStoragePool, parameters, result -> {
        ConfirmationModel localModel = (ConfirmationModel) result.getState();
        localModel.stopProgress();
        cancel();
    }, model);
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) ArrayList(java.util.ArrayList) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) StoragePoolParametersBase(org.ovirt.engine.core.common.action.StoragePoolParametersBase)

Example 82 with ActionParametersBase

use of org.ovirt.engine.core.common.action.ActionParametersBase in project ovirt-engine by oVirt.

the class DataCenterListModel method onSaveInternal.

public void onSaveInternal() {
    DataCenterModel model = (DataCenterModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    StoragePool dataCenter = model.getIsNew() ? new StoragePool() : (StoragePool) Cloner.clone(getSelectedItem());
    // cancel confirm window if there is
    cancelConfirmation();
    // Save changes.
    dataCenter.setName(model.getName().getEntity());
    dataCenter.setdescription(model.getDescription().getEntity());
    dataCenter.setComment(model.getComment().getEntity());
    dataCenter.setIsLocal(model.getStoragePoolType().getSelectedItem());
    dataCenter.setCompatibilityVersion(model.getVersion().getSelectedItem());
    dataCenter.setQuotaEnforcementType(model.getQuotaEnforceTypeListModel().getSelectedItem());
    model.startProgress();
    if (model.getIsNew()) {
        // When adding a data center use sync action to be able present a Guide Me dialog afterwards.
        Frontend.getInstance().runAction(ActionType.AddEmptyStoragePool, new StoragePoolManagementParameter(dataCenter), result -> {
            DataCenterListModel localModel = (DataCenterListModel) result.getState();
            localModel.postOnSaveInternal(result.getReturnValue());
        }, this);
    } else {
        // Use async action in order to close dialog immediately.
        Frontend.getInstance().runMultipleAction(ActionType.UpdateStoragePool, new ArrayList<ActionParametersBase>(Arrays.asList(new StoragePoolManagementParameter(dataCenter))), result -> {
            DataCenterListModel localModel = (DataCenterListModel) result.getState();
            localModel.postOnSaveInternal(result.getReturnValue().get(0));
        }, this);
    }
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) StoragePoolManagementParameter(org.ovirt.engine.core.common.action.StoragePoolManagementParameter) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 83 with ActionParametersBase

use of org.ovirt.engine.core.common.action.ActionParametersBase in project ovirt-engine by oVirt.

the class DataCenterListModel method onForceRemove.

public void onForceRemove() {
    ConfirmationModel model = (ConfirmationModel) getWindow();
    if (!model.validate()) {
        return;
    }
    StoragePoolParametersBase tempVar = new StoragePoolParametersBase(getSelectedItem().getId());
    tempVar.setForceDelete(true);
    ActionParametersBase parametersBase = tempVar;
    Frontend.getInstance().runAction(ActionType.RemoveStoragePool, parametersBase);
    cancel();
}
Also used : ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) StoragePoolParametersBase(org.ovirt.engine.core.common.action.StoragePoolParametersBase) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 84 with ActionParametersBase

use of org.ovirt.engine.core.common.action.ActionParametersBase in project ovirt-engine by oVirt.

the class DataCenterStorageListModel method postDetach.

public void postDetach(Model model) {
    Frontend.getInstance().runMultipleAction(ActionType.RemoveStorageDomain, getRemoveParams(), outerResult -> {
        Object[] array = (Object[]) outerResult.getState();
        ConfirmationModel localModel1 = (ConfirmationModel) array[0];
        List<ActionParametersBase> parameters = (List<ActionParametersBase>) array[1];
        Frontend.getInstance().runMultipleAction(ActionType.DetachStorageDomainFromPool, parameters, innerResult -> {
            ConfirmationModel localModel2 = (ConfirmationModel) innerResult.getState();
            localModel2.stopProgress();
            cancel();
        }, localModel1);
    }, new Object[] { model, getDetachParams() });
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 85 with ActionParametersBase

use of org.ovirt.engine.core.common.action.ActionParametersBase in project ovirt-engine by oVirt.

the class DataCenterStorageListModel method onDetach.

public void onDetach() {
    final ConfirmationModel confirmModel = (ConfirmationModel) getWindow();
    if (confirmModel.getProgress() != null) {
        return;
    }
    if (!confirmModel.validate()) {
        return;
    }
    // A list of 'detach' action parameters
    setDetachParams(new ArrayList<>());
    // A list of 'remove' action parameters
    setRemoveParams(new ArrayList<>());
    String localStorgaeDC = null;
    for (StorageDomain a : getSelectedItems()) {
        // For local storage - remove; otherwise - detach
        if (a.getStorageType() == StorageType.LOCALFS && a.getStorageDomainType() != StorageDomainType.ISO) {
            getRemoveParams().add(new RemoveStorageDomainParameters(a.getId()));
            localStorgaeDC = a.getStoragePoolName();
        } else {
            getDetachParams().add(new DetachStorageDomainFromPoolParameters(a.getId(), getEntity().getId()));
        }
    }
    confirmModel.startProgress();
    if (getRemoveParams().size() > 0) {
        AsyncDataProvider.getInstance().getLocalStorageHost(new AsyncQuery<>(locaVds -> {
            for (ActionParametersBase item : getRemoveParams()) {
                ((RemoveStorageDomainParameters) item).setVdsId(locaVds != null ? locaVds.getId() : null);
                ((RemoveStorageDomainParameters) item).setDoFormat(confirmModel.getForce().getEntity());
            }
            postDetach(getWindow());
        }), localStorgaeDC);
    } else {
        postDetach(confirmModel);
    }
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) StorageDomainPoolParametersBase(org.ovirt.engine.core.common.action.StorageDomainPoolParametersBase) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StorageFormatType(org.ovirt.engine.core.common.businessentities.StorageFormatType) Model(org.ovirt.engine.ui.uicommonweb.models.Model) AttachStorageDomainToPoolParameters(org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters) RemoveStorageDomainParameters(org.ovirt.engine.core.common.action.RemoveStorageDomainParameters) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) ActionUtils(org.ovirt.engine.core.common.ActionUtils) Linq(org.ovirt.engine.ui.uicommonweb.Linq) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) StorageDomainSharedStatus(org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus) Collectors(java.util.stream.Collectors) NotifyCollectionChangedEventArgs(org.ovirt.engine.ui.uicompat.NotifyCollectionChangedEventArgs) List(java.util.List) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) DeactivateStorageDomainWithOvfUpdateParameters(org.ovirt.engine.core.common.action.DeactivateStorageDomainWithOvfUpdateParameters) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) DetachStorageDomainFromPoolParameters(org.ovirt.engine.core.common.action.DetachStorageDomainFromPoolParameters) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) RemoveStorageDomainParameters(org.ovirt.engine.core.common.action.RemoveStorageDomainParameters) DetachStorageDomainFromPoolParameters(org.ovirt.engine.core.common.action.DetachStorageDomainFromPoolParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Aggregations

ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)204 ArrayList (java.util.ArrayList)149 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)53 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)52 ActionType (org.ovirt.engine.core.common.action.ActionType)45 Test (org.junit.Test)44 Guid (org.ovirt.engine.core.compat.Guid)35 VDS (org.ovirt.engine.core.common.businessentities.VDS)26 List (java.util.List)23 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)23 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)20 VM (org.ovirt.engine.core.common.businessentities.VM)19 QueryType (org.ovirt.engine.core.common.queries.QueryType)18 Frontend (org.ovirt.engine.ui.frontend.Frontend)18 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)18 IFrontendActionAsyncCallback (org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback)18 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)16 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)16 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)16 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)15