Search in sources :

Example 1 with GlusterHookEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity in project ovirt-engine by oVirt.

the class ClusterGlusterHookListModel method viewHook.

private void viewHook() {
    if (getWindow() != null) {
        return;
    }
    GlusterHookEntity hookEntity = getSelectedItem();
    if (hookEntity == null) {
        return;
    }
    final GlusterHookContentModel contentModel = new GlusterHookContentModel();
    contentModel.setTitle(ConstantsManager.getInstance().getConstants().viewContentGlusterHookTitle());
    contentModel.setHelpTag(HelpTag.view_gluster_hook);
    // $NON-NLS-1$
    contentModel.setHashName("view_gluster_hook");
    setWindow(contentModel);
    contentModel.startProgress();
    AsyncDataProvider.getInstance().getGlusterHookContent(new AsyncQuery<>(content -> {
        contentModel.getContent().setEntity(content);
        if (content == null) {
            contentModel.getContent().setIsAvailable(false);
            contentModel.setMessage(ConstantsManager.getInstance().getConstants().viewContentErrorGlusterHook());
        } else if (content.length() == 0) {
            contentModel.getContent().setIsAvailable(false);
            contentModel.setMessage(ConstantsManager.getInstance().getConstants().viewContentEmptyGlusterHook());
        }
        contentModel.stopProgress();
    }), hookEntity.getId(), null);
    // $NON-NLS-1$
    UICommand command = new UICommand("Cancel", this);
    command.setTitle(ConstantsManager.getInstance().getConstants().close());
    command.setIsCancel(true);
    contentModel.getCommands().add(command);
}
Also used : GlusterHookManageParameters(org.ovirt.engine.core.common.action.gluster.GlusterHookManageParameters) GlusterHookEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity) GlusterHookStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookStatus) Guid(org.ovirt.engine.core.compat.Guid) GlusterHookContentType(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookContentType) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) GlusterServerHook(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerHook) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) 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) List(java.util.List) GlusterHookParameters(org.ovirt.engine.core.common.action.gluster.GlusterHookParameters) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) GlusterClusterParameters(org.ovirt.engine.core.common.action.gluster.GlusterClusterParameters) GlusterHookEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 2 with GlusterHookEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity in project ovirt-engine by oVirt.

the class ClusterGlusterHookListModel method updateActionAvailability.

private void updateActionAvailability() {
    boolean allowEnable = true;
    boolean allowDisable = true;
    boolean allowViewContent = true;
    boolean allowResolveConflict = true;
    if (getSelectedItems() == null || getSelectedItems().size() == 0) {
        allowEnable = false;
        allowDisable = false;
        allowViewContent = false;
        allowResolveConflict = false;
    } else {
        for (Object item : getSelectedItems()) {
            GlusterHookEntity hook = (GlusterHookEntity) item;
            if (hook.getStatus() == GlusterHookStatus.ENABLED) {
                allowEnable = false;
            } else if (hook.getStatus() == GlusterHookStatus.DISABLED) {
                allowDisable = false;
            }
            if (!allowEnable && !allowDisable) {
                break;
            }
        }
        allowViewContent = getSelectedItems().size() == 1 && getSelectedItems().get(0).getContentType() == GlusterHookContentType.TEXT;
        allowResolveConflict = getSelectedItems().size() == 1 && getSelectedItems().get(0).hasConflicts();
    }
    getEnableHookCommand().setIsExecutionAllowed(allowEnable);
    getDisableHookCommand().setIsExecutionAllowed(allowDisable);
    getViewHookCommand().setIsExecutionAllowed(allowViewContent);
    getResolveConflictsCommand().setIsExecutionAllowed(allowResolveConflict);
}
Also used : GlusterHookEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity)

Example 3 with GlusterHookEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity in project ovirt-engine by oVirt.

the class ClusterGlusterHookListModel method enableHook.

private void enableHook() {
    if (getEntity() == null || getSelectedItems() == null || getSelectedItems().size() == 0) {
        return;
    }
    ArrayList<ActionParametersBase> list = new ArrayList<>();
    for (GlusterHookEntity hook : getSelectedItems()) {
        list.add(new GlusterHookParameters(hook.getId()));
    }
    Frontend.getInstance().runMultipleAction(ActionType.EnableGlusterHook, list, null, null);
}
Also used : GlusterHookParameters(org.ovirt.engine.core.common.action.gluster.GlusterHookParameters) GlusterHookEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity) ArrayList(java.util.ArrayList) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 4 with GlusterHookEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity in project ovirt-engine by oVirt.

the class ClusterGlusterHookListModel method onResolveConflicts.

/*
     * If there are multiple types of conflicts found for a hook and the user choose to resolve them. The conflicts will
     * be resolved in the following order 1)Content Conflict, 2)Status Conflict, 3)Missing Conflict
     *
     * If any conflict resolution is failed the next one will not be executed
     */
private void onResolveConflicts() {
    final GlusterHookResolveConflictsModel resolveConflictsModel = (GlusterHookResolveConflictsModel) getWindow();
    if (resolveConflictsModel == null) {
        return;
    }
    if (!resolveConflictsModel.isAnyResolveActionSelected()) {
        resolveConflictsModel.setMessage(ConstantsManager.getInstance().getConstants().noResolveActionSelectedGlusterHook());
        return;
    }
    resolveConflictsModel.startProgress();
    GlusterHookEntity hookEntity = resolveConflictsModel.getGlusterHookEntity();
    ArrayList<ActionType> actionTypes = new ArrayList<>();
    ArrayList<ActionParametersBase> parameters = new ArrayList<>();
    ArrayList<IFrontendActionAsyncCallback> callbacks = new ArrayList<>();
    if (resolveConflictsModel.getResolveContentConflict().getEntity()) {
        actionTypes.add(ActionType.UpdateGlusterHook);
        GlusterServerHook serverHook = resolveConflictsModel.getServerHooksList().getSelectedItem();
        Guid serverId = (serverHook == null) ? null : serverHook.getServerId();
        parameters.add(new GlusterHookManageParameters(hookEntity.getId(), serverId));
        IFrontendActionAsyncCallback callback = result -> {
            if (result.getReturnValue().getSucceeded()) {
                resolveConflictsModel.getResolveContentConflict().setEntity(Boolean.FALSE);
                resolveConflictsModel.getResolveContentConflict().setIsChangeable(Boolean.FALSE);
            }
        };
        callbacks.add(callback);
    }
    if (resolveConflictsModel.getResolveStatusConflict().getEntity()) {
        boolean isEnable = resolveConflictsModel.getResolveStatusConflictEnable().getEntity();
        actionTypes.add(isEnable ? ActionType.EnableGlusterHook : ActionType.DisableGlusterHook);
        parameters.add(new GlusterHookParameters(hookEntity.getId()));
        IFrontendActionAsyncCallback callback = result -> {
            if (result.getReturnValue().getSucceeded()) {
                resolveConflictsModel.getResolveStatusConflict().setEntity(Boolean.FALSE);
                resolveConflictsModel.getResolveStatusConflict().setIsChangeable(Boolean.FALSE);
            }
        };
        callbacks.add(callback);
    }
    if (resolveConflictsModel.getResolveMissingConflict().getEntity()) {
        boolean isAdd = resolveConflictsModel.getResolveMissingConflictCopy().getEntity();
        actionTypes.add(isAdd ? ActionType.AddGlusterHook : ActionType.RemoveGlusterHook);
        parameters.add(new GlusterHookManageParameters(hookEntity.getId()));
        IFrontendActionAsyncCallback callback = result -> {
            if (result.getReturnValue().getSucceeded()) {
                resolveConflictsModel.getResolveMissingConflict().setEntity(Boolean.FALSE);
                resolveConflictsModel.getResolveMissingConflict().setIsChangeable(Boolean.FALSE);
            }
        };
        callbacks.add(callback);
    }
    IFrontendActionAsyncCallback onFinishCallback = result -> {
        if (result.getReturnValue().getSucceeded()) {
            resolveConflictsModel.stopProgress();
            cancel();
            syncSearch();
        }
    };
    IFrontendActionAsyncCallback failureCallback = result -> resolveConflictsModel.stopProgress();
    // Replacing the last callback with onFinishCallback, as we just want to close the dialog and execute the search
    if (callbacks.size() > 0) {
        callbacks.remove(callbacks.size() - 1);
        callbacks.add(onFinishCallback);
        Frontend.getInstance().runMultipleActions(actionTypes, parameters, callbacks, failureCallback, null);
    }
}
Also used : GlusterHookManageParameters(org.ovirt.engine.core.common.action.gluster.GlusterHookManageParameters) GlusterHookEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity) GlusterHookStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookStatus) Guid(org.ovirt.engine.core.compat.Guid) GlusterHookContentType(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookContentType) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) GlusterServerHook(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerHook) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) 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) List(java.util.List) GlusterHookParameters(org.ovirt.engine.core.common.action.gluster.GlusterHookParameters) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) GlusterClusterParameters(org.ovirt.engine.core.common.action.gluster.GlusterClusterParameters) GlusterHookParameters(org.ovirt.engine.core.common.action.gluster.GlusterHookParameters) ActionType(org.ovirt.engine.core.common.action.ActionType) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) GlusterHookManageParameters(org.ovirt.engine.core.common.action.gluster.GlusterHookManageParameters) GlusterHookEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) GlusterServerHook(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerHook)

Example 5 with GlusterHookEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity in project ovirt-engine by oVirt.

the class ClusterGlusterHookListModel method disableHook.

private void disableHook() {
    if (getWindow() != null) {
        return;
    }
    if (getSelectedItems() == null || getSelectedItems().size() == 0) {
        return;
    }
    ConfirmationModel model = new ConfirmationModel();
    setConfirmWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().confirmDisableGlusterHooks());
    model.setHelpTag(HelpTag.disable_hooks);
    // $NON-NLS-1$
    model.setHashName("disable_hooks");
    model.setMessage(ConstantsManager.getInstance().getConstants().disableGlusterHooksMessage());
    ArrayList<String> list = new ArrayList<>();
    for (GlusterHookEntity hook : getSelectedItems()) {
        list.add(hook.getName());
    }
    model.setItems(list);
    // $NON-NLS-1$
    UICommand okCommand = UICommand.createDefaultOkUiCommand("OnDisableHook", this);
    model.getCommands().add(okCommand);
    // $NON-NLS-1$
    UICommand cancelCommand = UICommand.createCancelUiCommand("OnCancelConfirmation", this);
    model.getCommands().add(cancelCommand);
}
Also used : GlusterHookEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity) ArrayList(java.util.ArrayList) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)

Aggregations

GlusterHookEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity)34 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)11 GlusterServerHook (org.ovirt.engine.core.common.businessentities.gluster.GlusterServerHook)8 Guid (org.ovirt.engine.core.compat.Guid)6 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)5 GlusterHookParameters (org.ovirt.engine.core.common.action.gluster.GlusterHookParameters)5 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)5 List (java.util.List)4 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)4 ActionType (org.ovirt.engine.core.common.action.ActionType)3 GlusterClusterParameters (org.ovirt.engine.core.common.action.gluster.GlusterClusterParameters)3 GlusterHookManageParameters (org.ovirt.engine.core.common.action.gluster.GlusterHookManageParameters)3 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)3 GlusterHookContentType (org.ovirt.engine.core.common.businessentities.gluster.GlusterHookContentType)3 GlusterHookStatus (org.ovirt.engine.core.common.businessentities.gluster.GlusterHookStatus)3 ApplicationMode (org.ovirt.engine.core.common.mode.ApplicationMode)3 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)3 Frontend (org.ovirt.engine.ui.frontend.Frontend)3 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)3