Search in sources :

Example 1 with Role

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

the class RoleListModel method cloneRole.

public void cloneRole() {
    commandType = CommandType.Clone;
    Role role = getSelectedItem();
    initRoleDialog(role);
}
Also used : Role(org.ovirt.engine.core.common.businessentities.Role)

Example 2 with Role

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

the class RoleListModel method eventRaised.

@Override
public void eventRaised(Event ev, Object sender, EventArgs args) {
    super.eventRaised(ev, sender, args);
    if (getWindow() != null && sender == ((RoleModel) getWindow()).getIsAdminRole()) {
        if (commandType == CommandType.New) {
            List<ActionGroup> selectedActionGroups = new ArrayList<>();
            selectedActionGroups.add(ActionGroup.LOGIN);
            setAttachedActionGroups(selectedActionGroups);
        } else {
            Role role = getSelectedItem();
            Frontend.getInstance().runQuery(QueryType.GetRoleActionGroupsByRoleId, new IdQueryParameters(role.getId()), new AsyncQuery<QueryReturnValue>(returnValue -> {
                publicAttachedActions = returnValue.getReturnValue();
                setAttachedActionGroups(publicAttachedActions);
            }));
        }
    }
}
Also used : Role(org.ovirt.engine.core.common.businessentities.Role) QueryType(org.ovirt.engine.core.common.queries.QueryType) Inject(com.google.inject.Inject) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) Event(org.ovirt.engine.ui.uicompat.Event) HashMap(java.util.HashMap) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) 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) SelectionTreeNodeModel(org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel) RoleWithActionGroupsParameters(org.ovirt.engine.core.common.action.RoleWithActionGroupsParameters) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) ApplicationGuids(org.ovirt.engine.ui.uicommonweb.auth.ApplicationGuids) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) ActionGroupsToRoleParameter(org.ovirt.engine.core.common.action.ActionGroupsToRoleParameter) RolesOperationsParameters(org.ovirt.engine.core.common.action.RolesOperationsParameters) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) RoleType(org.ovirt.engine.core.common.businessentities.RoleType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) RolesParameterBase(org.ovirt.engine.core.common.action.RolesParameterBase) List(java.util.List) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) Role(org.ovirt.engine.core.common.businessentities.Role) Collections(java.util.Collections) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) ArrayList(java.util.ArrayList)

Example 3 with Role

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

the class RoleListModel method remove.

public void remove() {
    if (getWindow() != null) {
        return;
    }
    ConfirmationModel model = new ConfirmationModel();
    setWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().removeRolesTitle());
    model.setHelpTag(HelpTag.remove_role);
    // $NON-NLS-1$
    model.setHashName("remove_role");
    ArrayList<String> list = new ArrayList<>();
    for (Role role : getSelectedItems()) {
        list.add(role.getName());
    }
    model.setItems(list);
    // $NON-NLS-1$
    UICommand tempVar = UICommand.createDefaultOkUiCommand("OnRemove", this);
    model.getCommands().add(tempVar);
    // $NON-NLS-1$
    UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
    model.getCommands().add(tempVar2);
}
Also used : Role(org.ovirt.engine.core.common.businessentities.Role) ArrayList(java.util.ArrayList) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)

Example 4 with Role

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

the class RoleListModel method setAttachedActionGroups.

void setAttachedActionGroups(List<ActionGroup> attachedActions) {
    Role role = getSelectedItem();
    RoleModel model = (RoleModel) getWindow();
    ArrayList<SelectionTreeNodeModel> selectionTree = RoleTreeView.getRoleTreeView(model.getIsNew() ? false : role.isReadonly(), model.getIsAdminRole().getEntity());
    for (SelectionTreeNodeModel sm : selectionTree) {
        for (SelectionTreeNodeModel smChild : sm.getChildren()) {
            smChild.setParent(sm);
            smChild.setIsSelectedNotificationPrevent(false);
            for (SelectionTreeNodeModel smGrandChild : smChild.getChildren()) {
                smGrandChild.setParent(smChild);
                smGrandChild.setIsSelectedNotificationPrevent(false);
                if (attachedActions.contains(ActionGroup.valueOf(smGrandChild.getTitle()))) {
                    smGrandChild.setIsSelectedNullable(true);
                    smGrandChild.updateParentSelection();
                }
                if (smChild.getChildren().get(0).equals(smGrandChild)) {
                    smGrandChild.updateParentSelection();
                }
            }
        }
    }
    model.setPermissionGroupModels(selectionTree);
}
Also used : Role(org.ovirt.engine.core.common.businessentities.Role) SelectionTreeNodeModel(org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel)

Example 5 with Role

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

the class RoleListModel method syncSearch.

@Override
protected void syncSearch() {
    super.syncSearch();
    QueryParametersBase tempVar = new QueryParametersBase();
    tempVar.setRefresh(getIsQueryFirstTime());
    Frontend.getInstance().runQuery(QueryType.GetAllRoles, tempVar, new AsyncQuery<QueryReturnValue>(returnValue -> {
        ArrayList<Role> filteredList = new ArrayList<>();
        for (Role item : (ArrayList<Role>) returnValue.getReturnValue()) {
            // ignore CONSUME_QUOTA_ROLE in UI
            if (item.getId().equals(ApplicationGuids.quotaConsumer.asGuid())) {
                continue;
            }
            if (getItemsFilter() == null || getItemsFilter() == item.getType()) {
                filteredList.add(item);
            }
        }
        Collections.sort(filteredList, new NameableComparator());
        setItems(filteredList);
    }));
    setIsQueryFirstTime(false);
}
Also used : QueryType(org.ovirt.engine.core.common.queries.QueryType) Inject(com.google.inject.Inject) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) Event(org.ovirt.engine.ui.uicompat.Event) HashMap(java.util.HashMap) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) 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) SelectionTreeNodeModel(org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel) RoleWithActionGroupsParameters(org.ovirt.engine.core.common.action.RoleWithActionGroupsParameters) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) ApplicationGuids(org.ovirt.engine.ui.uicommonweb.auth.ApplicationGuids) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) ActionGroupsToRoleParameter(org.ovirt.engine.core.common.action.ActionGroupsToRoleParameter) RolesOperationsParameters(org.ovirt.engine.core.common.action.RolesOperationsParameters) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) RoleType(org.ovirt.engine.core.common.businessentities.RoleType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) RolesParameterBase(org.ovirt.engine.core.common.action.RolesParameterBase) List(java.util.List) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) Role(org.ovirt.engine.core.common.businessentities.Role) Collections(java.util.Collections) Role(org.ovirt.engine.core.common.businessentities.Role) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ArrayList(java.util.ArrayList) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase)

Aggregations

Role (org.ovirt.engine.core.common.businessentities.Role)28 ArrayList (java.util.ArrayList)8 ActionGroup (org.ovirt.engine.core.common.businessentities.ActionGroup)7 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 Permission (org.ovirt.engine.core.common.businessentities.Permission)4 SelectionTreeNodeModel (org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel)4 ActionGroupsToRoleParameter (org.ovirt.engine.core.common.action.ActionGroupsToRoleParameter)3 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)3 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 PermissionsOperationsParameters (org.ovirt.engine.core.common.action.PermissionsOperationsParameters)3 RoleWithActionGroupsParameters (org.ovirt.engine.core.common.action.RoleWithActionGroupsParameters)3 RolesOperationsParameters (org.ovirt.engine.core.common.action.RolesOperationsParameters)3 RolesParameterBase (org.ovirt.engine.core.common.action.RolesParameterBase)3 DbGroup (org.ovirt.engine.core.common.businessentities.aaa.DbGroup)3 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)3 NameableComparator (org.ovirt.engine.core.common.businessentities.comparators.NameableComparator)3 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)3 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)3 Inject (com.google.inject.Inject)2