Search in sources :

Example 1 with NameableComparator

use of org.ovirt.engine.core.common.businessentities.comparators.NameableComparator 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)

Example 2 with NameableComparator

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

the class ProviderModel method updateDatacentersForExternalProvider.

protected void updateDatacentersForExternalProvider() {
    AsyncDataProvider.getInstance().getDataCenterList(new AsyncQuery<>(new AsyncCallback<List<StoragePool>>() {

        @Override
        public void onSuccess(List<StoragePool> dataCenters) {
            StoragePool prevDataCenter = getPreviousDataCenter(dataCenters);
            Collections.sort(dataCenters, new NameableComparator());
            // any data center
            dataCenters.add(0, null);
            getDataCenter().setItems(dataCenters);
            getDataCenter().setSelectedItem(prevDataCenter);
            if (getDataCenter().getSelectedItem() == null) {
                getProxyHostPropertiesModel().disableProxyHost();
            }
        }

        private StoragePool getPreviousDataCenter(List<StoragePool> dataCenters) {
            Guid previousDataCenterId = getProxyHostPropertiesModel().getLastStoragePoolId();
            for (StoragePool dataCenter : dataCenters) {
                if (dataCenter.getId().equals(previousDataCenterId)) {
                    return dataCenter;
                }
            }
            return null;
        }
    }));
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) ArrayList(java.util.ArrayList) List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid)

Example 3 with NameableComparator

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

the class ImportRepoImageModel method filterStorageDomains.

@Override
protected List<StorageDomain> filterStorageDomains(List<StorageDomain> storageDomains) {
    List<StorageDomain> availableStorageDomains = new ArrayList<>();
    // Filtering out domains that are not active
    for (StorageDomain storageDomainItem : storageDomains) {
        if (Linq.isDataActiveStorageDomain(storageDomainItem)) {
            availableStorageDomains.add(storageDomainItem);
        }
    }
    // Sorting by name
    Collections.sort(availableStorageDomains, new NameableComparator());
    return availableStorageDomains;
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) ArrayList(java.util.ArrayList) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator)

Example 4 with NameableComparator

use of org.ovirt.engine.core.common.businessentities.comparators.NameableComparator 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 5 with NameableComparator

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

the class AffinityLabelListWidget method createItems.

@Override
protected void createItems() {
    List<Label> selectedLabels = getModel().getSelectedItems();
    boolean noLabelsSelected = selectedLabels == null || selectedLabels.isEmpty();
    if (noLabelsSelected) {
        addNoLabelsMessage();
        return;
    }
    itemList.clear();
    Collections.sort(selectedLabels, new NameableComparator());
    selectedLabels.forEach(label -> {
        ItemListItem labelListItem = new ItemListItem();
        labelListItem.init(label.getName());
        labelListItem.getDeactivationAnchor().addClickHandler(event -> {
            getModel().getSelectedItems().remove(label);
            refreshItems();
        });
        itemList.add(labelListItem);
    });
    itemListPanel.add(itemList);
}
Also used : Label(org.ovirt.engine.core.common.businessentities.Label) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator)

Aggregations

NameableComparator (org.ovirt.engine.core.common.businessentities.comparators.NameableComparator)15 ArrayList (java.util.ArrayList)13 List (java.util.List)6 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)5 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)5 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)5 Collections (java.util.Collections)4 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)4 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)4 QueryType (org.ovirt.engine.core.common.queries.QueryType)4 Guid (org.ovirt.engine.core.compat.Guid)4 Frontend (org.ovirt.engine.ui.frontend.Frontend)4 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)4 Arrays (java.util.Arrays)3 HashMap (java.util.HashMap)3 Set (java.util.Set)3 QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)3 AsyncCallback (org.ovirt.engine.ui.frontend.AsyncCallback)3 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)3 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)3