Search in sources :

Example 1 with ActionGroup

use of org.ovirt.engine.core.common.businessentities.ActionGroup 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 2 with ActionGroup

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

the class RoleListModel method onReset.

public void onReset() {
    RoleModel model = (RoleModel) getWindow();
    ArrayList<ActionGroup> attachedActions = commandType == CommandType.New ? new ArrayList<ActionGroup>() : publicAttachedActions;
    for (SelectionTreeNodeModel sm : model.getPermissionGroupModels()) {
        for (SelectionTreeNodeModel smChild : sm.getChildren()) {
            for (SelectionTreeNodeModel smGrandChild : smChild.getChildren()) {
                smGrandChild.setIsSelectedNullable(attachedActions.contains(ActionGroup.valueOf(smGrandChild.getTitle())));
            }
        }
    }
}
Also used : SelectionTreeNodeModel(org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup)

Example 3 with ActionGroup

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

the class VmModelBehaviorBase method postInitStorageDomains.

protected void postInitStorageDomains() {
    if (getModel().getDisks() == null) {
        return;
    }
    ActionGroup actionGroup = getModel().isCreateInstanceOnly() ? ActionGroup.CREATE_INSTANCE : ActionGroup.CREATE_VM;
    StoragePool dataCenter = getModel().getSelectedDataCenter();
    AsyncDataProvider.getInstance().getPermittedStorageDomainsByStoragePoolId(new AsyncQuery<>(storageDomains -> {
        ArrayList<StorageDomain> activeStorageDomains = filterStorageDomains(storageDomains);
        boolean provisioning = getModel().getProvisioning().getEntity();
        ArrayList<DiskModel> disks = (ArrayList<DiskModel>) getModel().getDisks();
        activeStorageDomains.sort(new NameableComparator());
        List<DiskModel> diskImages = Linq.filterDisksByType(disks, DiskStorageType.IMAGE);
        for (DiskModel diskModel : diskImages) {
            List<StorageDomain> availableDiskStorageDomains;
            diskModel.getQuota().setItems(getModel().getQuota().getItems());
            List<Guid> storageIds = ((DiskImage) diskModel.getDisk()).getStorageIds();
            // Active storage domains that the disk resides on
            List<StorageDomain> activeDiskStorageDomains = Linq.getStorageDomainsByIds(storageIds, activeStorageDomains);
            // Set target storage domains
            availableDiskStorageDomains = provisioning ? activeStorageDomains : activeDiskStorageDomains;
            availableDiskStorageDomains.sort(new NameableComparator());
            diskModel.getStorageDomain().setItems(availableDiskStorageDomains);
            diskModel.getStorageDomain().setChangeProhibitionReason(constants.noActiveTargetStorageDomainAvailableMsg());
            diskModel.getStorageDomain().setIsChangeable(!availableDiskStorageDomains.isEmpty());
        }
        List<DiskModel> cinderDisks = Linq.filterDisksByType(disks, DiskStorageType.CINDER);
        Collection<StorageDomain> cinderStorageDomains = Linq.filterStorageDomainsByStorageType(storageDomains, StorageType.CINDER);
        initStorageDomainsForCinderDisks(cinderDisks, cinderStorageDomains);
    }), dataCenter.getId(), actionGroup);
}
Also used : UsbPolicy(org.ovirt.engine.core.common.businessentities.UsbPolicy) TemplateWithVersion(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateWithVersion) Arrays(java.util.Arrays) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) VmType(org.ovirt.engine.core.common.businessentities.VmType) InstanceType(org.ovirt.engine.core.common.businessentities.InstanceType) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator) Event(org.ovirt.engine.ui.uicompat.Event) ImagesDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.ImagesDataProvider) VmNumaSupportModel(org.ovirt.engine.ui.uicommonweb.models.hosts.numa.VmNumaSupportModel) QuotaEnforcementTypeEnum(org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Map(java.util.Map) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) Version(org.ovirt.engine.core.compat.Version) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) I18NNameValidation(org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation) StringHelper(org.ovirt.engine.core.compat.StringHelper) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) List(java.util.List) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) LatestVmTemplate(org.ovirt.engine.ui.uicommonweb.models.templates.LatestVmTemplate) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) TimeZoneType(org.ovirt.engine.core.common.TimeZoneType) Guid(org.ovirt.engine.core.compat.Guid) ServerCpu(org.ovirt.engine.core.common.businessentities.ServerCpu) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) IEventListener(org.ovirt.engine.ui.uicompat.IEventListener) HashMap(java.util.HashMap) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ExistingBlankTemplateModelBehavior(org.ovirt.engine.ui.uicommonweb.models.templates.ExistingBlankTemplateModelBehavior) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) HashSet(java.util.HashSet) CpuProfile(org.ovirt.engine.core.common.businessentities.profiles.CpuProfile) Frontend(org.ovirt.engine.ui.frontend.Frontend) NumaSupportModel(org.ovirt.engine.ui.uicommonweb.models.hosts.numa.NumaSupportModel) InstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.InstanceTypeManager) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) Linq(org.ovirt.engine.ui.uicommonweb.Linq) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) Quota(org.ovirt.engine.core.common.businessentities.Quota) VmCommonUtils(org.ovirt.engine.core.common.utils.VmCommonUtils) VM(org.ovirt.engine.core.common.businessentities.VM) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) MigrationSupport(org.ovirt.engine.core.common.businessentities.MigrationSupport) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) ArrayList(java.util.ArrayList) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) Collection(java.util.Collection) List(java.util.List) ArrayList(java.util.ArrayList)

Example 4 with ActionGroup

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

the class AttachActionGroupsToRoleCommandTest method generateParameters.

@Override
protected ActionGroupsToRoleParameter generateParameters() {
    Guid roleId = Guid.newGuid();
    ArrayList<ActionGroup> groups = new ArrayList<>(Arrays.asList(ActionGroup.DELETE_HOST, ActionGroup.CONFIGURE_ENGINE));
    return new ActionGroupsToRoleParameter(roleId, groups);
}
Also used : ActionGroupsToRoleParameter(org.ovirt.engine.core.common.action.ActionGroupsToRoleParameter) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid)

Example 5 with ActionGroup

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

the class DetachActionGroupsFromRoleCommandTest method mockRoleGroups.

/**
 * Mock the action groups remaining on the role AFTER some were detached
 */
private void mockRoleGroups(ActionGroup... groups) {
    List<RoleGroupMap> maps = new ArrayList<>();
    for (ActionGroup group : groups) {
        maps.add(new RoleGroupMap(group, getParams().getRoleId()));
    }
    when(getRoleGroupMapDaoMock().getAllForRole(getParams().getRoleId())).thenReturn(maps);
}
Also used : ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) RoleGroupMap(org.ovirt.engine.core.common.businessentities.RoleGroupMap) ArrayList(java.util.ArrayList)

Aggregations

ActionGroup (org.ovirt.engine.core.common.businessentities.ActionGroup)24 ArrayList (java.util.ArrayList)9 Guid (org.ovirt.engine.core.compat.Guid)8 ActionGroupsToRoleParameter (org.ovirt.engine.core.common.action.ActionGroupsToRoleParameter)6 Role (org.ovirt.engine.core.common.businessentities.Role)6 HashMap (java.util.HashMap)3 List (java.util.List)3 RoleGroupMap (org.ovirt.engine.core.common.businessentities.RoleGroupMap)3 SelectionTreeNodeModel (org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel)3 Collection (java.util.Collection)2 Collections (java.util.Collections)2 Test (org.junit.Test)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 VM (org.ovirt.engine.core.common.businessentities.VM)2 VmBase (org.ovirt.engine.core.common.businessentities.VmBase)2 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)2 NameableComparator (org.ovirt.engine.core.common.businessentities.comparators.NameableComparator)2 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2