Search in sources :

Example 71 with ActionParametersBase

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

the class VmBackupModel method onRemove.

private void onRemove() {
    ConfirmationModel model = (ConfirmationModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    model.startProgress();
    AsyncDataProvider.getInstance().getDataCentersByStorageDomain(new AsyncQuery<>(pools -> {
        if (pools != null && pools.size() > 0) {
            StoragePool pool = pools.get(0);
            ArrayList<ActionParametersBase> list = new ArrayList<>();
            for (VM vm : getSelectedItems()) {
                list.add(new RemoveVmFromImportExportParameters(vm.getId(), getEntity().getId(), pool.getId()));
            }
            Frontend.getInstance().runMultipleAction(ActionType.RemoveVmFromImportExport, list, result -> {
                ConfirmationModel localModel = (ConfirmationModel) result.getState();
                localModel.stopProgress();
                cancel();
                onEntityChanged();
            }, getWindow());
        }
    }), getEntity().getId());
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) GetAllFromExportDomainQueryParameters(org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters) VmAppListModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmAppListModel) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) RemoveVmFromImportExportParameters(org.ovirt.engine.core.common.action.RemoveVmFromImportExportParameters) Inject(com.google.inject.Inject) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) LexoNumericNameableComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericNameableComparator) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) StorageDomainSharedStatus(org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus) StringHelper(org.ovirt.engine.core.compat.StringHelper) VM(org.ovirt.engine.core.common.businessentities.VM) Provider(com.google.inject.Provider) ImportVmData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportVmData) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) ImportVmFromExportDomainModel(org.ovirt.engine.ui.uicommonweb.models.vms.ImportVmFromExportDomainModel) Collections(java.util.Collections) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) RemoveVmFromImportExportParameters(org.ovirt.engine.core.common.action.RemoveVmFromImportExportParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)

Example 72 with ActionParametersBase

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

the class AttachDiskModel method store.

@Override
public void store(IFrontendActionAsyncCallback callback) {
    if (getProgress() != null || !validate()) {
        return;
    }
    ArrayList<ActionType> actionTypes = new ArrayList<>();
    ArrayList<ActionParametersBase> paramerterList = new ArrayList<>();
    ArrayList<IFrontendActionAsyncCallback> callbacks = new ArrayList<>();
    IFrontendActionAsyncCallback onFinishCallback = callback != null ? callback : result -> {
        NewDiskModel diskModel = (NewDiskModel) result.getState();
        diskModel.stopProgress();
        diskModel.cancel();
    };
    List<EntityModel<DiskModel>> disksToAttach = getSelectedDisks();
    for (int i = 0; i < disksToAttach.size(); i++) {
        DiskModel disk = disksToAttach.get(i).getEntity();
        /*
            IDE disks can be activated only when the VM is down.
            Other disks can be hot plugged.
             */
        boolean activate = false;
        if (getIsPlugged().getEntity()) {
            activate = disk.getDiskInterface().getSelectedItem() == DiskInterface.IDE ? getVm().getStatus() == VMStatus.Down : true;
        }
        DiskVmElement dve = new DiskVmElement(disk.getDisk().getId(), getVm().getId());
        dve.setBoot(disk.getIsBootable().getEntity());
        dve.setDiskInterface(disk.getDiskInterface().getSelectedItem());
        dve.setReadOnly(disk.isReadOnly());
        AttachDetachVmDiskParameters parameters = new AttachDetachVmDiskParameters(dve, activate);
        actionTypes.add(ActionType.AttachDiskToVm);
        paramerterList.add(parameters);
        callbacks.add(i == disksToAttach.size() - 1 ? onFinishCallback : null);
    }
    startProgress();
    Frontend.getInstance().runMultipleActions(actionTypes, paramerterList, callbacks, null, this);
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) AttachDetachVmDiskParameters(org.ovirt.engine.core.common.action.AttachDetachVmDiskParameters) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)

Example 73 with ActionParametersBase

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

the class UserListModel method onRemove.

public void onRemove() {
    List<DbUser> selectedItems = getSelectedItems();
    ArrayList<ActionParametersBase> userPrms = new ArrayList<>();
    ArrayList<ActionParametersBase> groupPrms = new ArrayList<>();
    for (DbUser item : selectedItems) {
        if (!item.isGroup()) {
            userPrms.add(new IdParameters(item.getId()));
        } else {
            groupPrms.add(new IdParameters(item.getId()));
        }
    }
    IFrontendMultipleActionAsyncCallback lastCallback = result -> Scheduler.get().scheduleDeferred(() -> {
        // Refresh user list.
        syncSearch();
        cancel();
    });
    if (getUserOrGroup() == UserOrGroup.User) {
        if (userPrms.size() > 0) {
            Frontend.getInstance().runMultipleAction(ActionType.RemoveUser, userPrms, lastCallback);
        }
    } else if (getUserOrGroup() == UserOrGroup.Group) {
        if (groupPrms.size() > 0) {
            Frontend.getInstance().runMultipleAction(ActionType.RemoveGroup, groupPrms, lastCallback);
        }
    }
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel) QueryType(org.ovirt.engine.core.common.queries.QueryType) AttachEntityToTagParameters(org.ovirt.engine.core.common.action.AttachEntityToTagParameters) AddGroupParameters(org.ovirt.engine.core.common.action.AddGroupParameters) SearchObjects(org.ovirt.engine.core.searchbackend.SearchObjects) Guid(org.ovirt.engine.core.compat.Guid) AdSearchType(org.ovirt.engine.ui.uicommonweb.models.users.AdElementListModel.AdSearchType) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) Inject(com.google.inject.Inject) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel) HashMap(java.util.HashMap) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) IFrontendMultipleActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback) 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) Map(java.util.Map) Tags(org.ovirt.engine.core.common.businessentities.Tags) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) ActionUtils(org.ovirt.engine.core.common.ActionUtils) UserOrGroup(org.ovirt.engine.core.searchbackend.VdcUserConditionFieldAutoCompleter.UserOrGroup) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) Scheduler(com.google.gwt.core.client.Scheduler) List(java.util.List) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) AddUserParameters(org.ovirt.engine.core.common.action.AddUserParameters) TagAssigningModel(org.ovirt.engine.ui.uicommonweb.TagAssigningModel) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) IdParameters(org.ovirt.engine.core.common.action.IdParameters) IFrontendMultipleActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback) IdParameters(org.ovirt.engine.core.common.action.IdParameters) ArrayList(java.util.ArrayList) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 74 with ActionParametersBase

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

the class UserListModel method onAdd.

public void onAdd(final boolean closeWindow) {
    AdElementListModel model = (AdElementListModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (model.getSelectedItems() == null) {
        cancel();
        return;
    }
    List<EntityModel<DbUser>> selectedItems = new ArrayList<>();
    for (EntityModel<DbUser> dbUserEntity : model.getItems()) {
        if (dbUserEntity.getIsSelected()) {
            selectedItems.add(dbUserEntity);
        }
    }
    List<ActionType> actionsList = new ArrayList<>(selectedItems.size());
    List<ActionParametersBase> parametersList = new ArrayList<>(selectedItems.size());
    ActionParametersBase parameters = null;
    for (EntityModel<DbUser> item : selectedItems) {
        if (item.getEntity().isGroup()) {
            actionsList.add(ActionType.AddGroup);
            DbGroup grp = new DbGroup();
            grp.setExternalId(item.getEntity().getExternalId());
            grp.setName(item.getEntity().getFirstName());
            grp.setNamespace(item.getEntity().getNamespace());
            grp.setId(item.getEntity().getId());
            grp.setDomain(item.getEntity().getDomain());
            parameters = new AddGroupParameters(grp);
        } else {
            actionsList.add(ActionType.AddUser);
            parameters = new AddUserParameters(item.getEntity());
        }
        parametersList.add(parameters);
    }
    model.startProgress();
    IFrontendActionAsyncCallback lastCallback = result -> {
        AdElementListModel localModel = (AdElementListModel) result.getState();
        localModel.stopProgress();
        // Refresh user list.
        syncSearch();
        if (closeWindow) {
            cancel();
        }
    };
    Collection<EntityModel<DbUser>> currentItems = model.getItems();
    List<IFrontendActionAsyncCallback> callbacksList = new ArrayList<>(selectedItems.size());
    for (EntityModel<DbUser> user : selectedItems) {
        callbacksList.add(nopCallback);
        currentItems.remove(user);
    }
    callbacksList.remove(callbacksList.size() - 1);
    callbacksList.add(lastCallback);
    // Refresh display
    model.setItems(null);
    model.setItems(currentItems);
    Frontend.getInstance().runMultipleActions(actionsList, parametersList, callbacksList, lastCallback, model);
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel) QueryType(org.ovirt.engine.core.common.queries.QueryType) AttachEntityToTagParameters(org.ovirt.engine.core.common.action.AttachEntityToTagParameters) AddGroupParameters(org.ovirt.engine.core.common.action.AddGroupParameters) SearchObjects(org.ovirt.engine.core.searchbackend.SearchObjects) Guid(org.ovirt.engine.core.compat.Guid) AdSearchType(org.ovirt.engine.ui.uicommonweb.models.users.AdElementListModel.AdSearchType) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) Inject(com.google.inject.Inject) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel) HashMap(java.util.HashMap) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) IFrontendMultipleActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback) 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) Map(java.util.Map) Tags(org.ovirt.engine.core.common.businessentities.Tags) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) ActionUtils(org.ovirt.engine.core.common.ActionUtils) UserOrGroup(org.ovirt.engine.core.searchbackend.VdcUserConditionFieldAutoCompleter.UserOrGroup) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) Scheduler(com.google.gwt.core.client.Scheduler) List(java.util.List) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) AddUserParameters(org.ovirt.engine.core.common.action.AddUserParameters) TagAssigningModel(org.ovirt.engine.ui.uicommonweb.TagAssigningModel) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) IdParameters(org.ovirt.engine.core.common.action.IdParameters) DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) ActionType(org.ovirt.engine.core.common.action.ActionType) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) AddGroupParameters(org.ovirt.engine.core.common.action.AddGroupParameters) AddUserParameters(org.ovirt.engine.core.common.action.AddUserParameters) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 75 with ActionParametersBase

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

the class UserPermissionListModel method onRemove.

private void onRemove() {
    if (getSelectedItems() != null && getSelectedItems().size() > 0) {
        ConfirmationModel model = (ConfirmationModel) getWindow();
        if (model.getProgress() != null) {
            return;
        }
        ArrayList<ActionParametersBase> list = new ArrayList<>();
        for (Object perm : getSelectedItems()) {
            PermissionsOperationsParameters tempVar = new PermissionsOperationsParameters();
            tempVar.setPermission((Permission) perm);
            list.add(tempVar);
        }
        model.startProgress();
        Frontend.getInstance().runMultipleAction(ActionType.RemovePermission, list, result -> {
            ConfirmationModel localModel = (ConfirmationModel) result.getState();
            localModel.stopProgress();
            cancel();
        }, model);
    } else {
        cancel();
    }
}
Also used : PermissionsOperationsParameters(org.ovirt.engine.core.common.action.PermissionsOperationsParameters) ArrayList(java.util.ArrayList) 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