Search in sources :

Example 31 with AsyncQuery

use of org.ovirt.engine.ui.frontend.AsyncQuery in project ovirt-engine by oVirt.

the class AddClusterRM method prepare1.

public void prepare1() {
    EnlistmentContext enlistmentContext = (EnlistmentContext) context.enlistment.getContext();
    HostListModel<?> model = enlistmentContext.getModel();
    ConfigureLocalStorageModel configureModel = (ConfigureLocalStorageModel) model.getWindow();
    ClusterModel clusterModel = configureModel.getCluster();
    String clusterName = clusterModel.getName().getEntity();
    if (!StringHelper.isNullOrEmpty(clusterName)) {
        AsyncDataProvider.getInstance().getClusterListByName(new AsyncQuery<>(returnValue -> {
            context.clusterFoundByName = Linq.firstOrNull(returnValue);
            prepare2();
        }), clusterName);
    } else {
        prepare2();
    }
}
Also used : ClusterModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel) ClusterModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel) IEnlistmentNotification(org.ovirt.engine.ui.uicompat.IEnlistmentNotification) Linq(org.ovirt.engine.ui.uicommonweb.Linq) Guid(org.ovirt.engine.core.compat.Guid) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) StringHelper(org.ovirt.engine.core.compat.StringHelper) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ClusterOperationParameters(org.ovirt.engine.core.common.action.ClusterOperationParameters) Objects(java.util.Objects) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) Enlistment(org.ovirt.engine.ui.uicompat.Enlistment) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ManagementNetworkOnClusterOperationParameters(org.ovirt.engine.core.common.action.ManagementNetworkOnClusterOperationParameters) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) Version(org.ovirt.engine.core.compat.Version) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)

Example 32 with AsyncQuery

use of org.ovirt.engine.ui.frontend.AsyncQuery in project ovirt-engine by oVirt.

the class AddDataCenterRM method rollback1.

public void rollback1() {
    Enlistment enlistment = context.enlistment;
    EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext();
    if (enlistmentContext.getDataCenterId() != null) {
        AsyncDataProvider.getInstance().getDataCenterById(new AsyncQuery<>(returnValue -> {
            context.dataCenterFoundById = returnValue;
            rollback2();
        }), enlistmentContext.getDataCenterId());
    } else {
        rollback3();
    }
}
Also used : ClusterParametersBase(org.ovirt.engine.core.common.action.ClusterParametersBase) StoragePoolParametersBase(org.ovirt.engine.core.common.action.StoragePoolParametersBase) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) IEnlistmentNotification(org.ovirt.engine.ui.uicompat.IEnlistmentNotification) Linq(org.ovirt.engine.ui.uicommonweb.Linq) Guid(org.ovirt.engine.core.compat.Guid) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) StringHelper(org.ovirt.engine.core.compat.StringHelper) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) StoragePoolManagementParameter(org.ovirt.engine.core.common.action.StoragePoolManagementParameter) Objects(java.util.Objects) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Enlistment(org.ovirt.engine.ui.uicompat.Enlistment) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) DataCenterModel(org.ovirt.engine.ui.uicommonweb.models.datacenters.DataCenterModel) VDS(org.ovirt.engine.core.common.businessentities.VDS) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) Enlistment(org.ovirt.engine.ui.uicompat.Enlistment)

Example 33 with AsyncQuery

use of org.ovirt.engine.ui.frontend.AsyncQuery in project ovirt-engine by oVirt.

the class AddDataCenterRM method prepare1.

private void prepare1() {
    EnlistmentContext enlistmentContext = (EnlistmentContext) context.enlistment.getContext();
    HostListModel<?> model = enlistmentContext.getModel();
    ConfigureLocalStorageModel configureModel = (ConfigureLocalStorageModel) model.getWindow();
    DataCenterModel dataCenterModel = configureModel.getDataCenter();
    String dataCenterName = dataCenterModel.getName().getEntity();
    if (!StringHelper.isNullOrEmpty(dataCenterName)) {
        AsyncDataProvider.getInstance().getDataCenterListByName(new AsyncQuery<>(returnValue -> {
            context.dataCenterFoundByName = Linq.firstOrNull(returnValue);
            prepare2();
        }), dataCenterName);
    } else {
        prepare2();
    }
}
Also used : ClusterParametersBase(org.ovirt.engine.core.common.action.ClusterParametersBase) StoragePoolParametersBase(org.ovirt.engine.core.common.action.StoragePoolParametersBase) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) IEnlistmentNotification(org.ovirt.engine.ui.uicompat.IEnlistmentNotification) Linq(org.ovirt.engine.ui.uicommonweb.Linq) Guid(org.ovirt.engine.core.compat.Guid) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) StringHelper(org.ovirt.engine.core.compat.StringHelper) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) StoragePoolManagementParameter(org.ovirt.engine.core.common.action.StoragePoolManagementParameter) Objects(java.util.Objects) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Enlistment(org.ovirt.engine.ui.uicompat.Enlistment) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) DataCenterModel(org.ovirt.engine.ui.uicommonweb.models.datacenters.DataCenterModel) VDS(org.ovirt.engine.core.common.businessentities.VDS) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) DataCenterModel(org.ovirt.engine.ui.uicommonweb.models.datacenters.DataCenterModel)

Example 34 with AsyncQuery

use of org.ovirt.engine.ui.frontend.AsyncQuery in project ovirt-engine by oVirt.

the class NewTemplateVmModelBehavior method initialize.

@Override
public void initialize() {
    super.initialize();
    getModel().getVmInitEnabled().setEntity(vm.getVmInit() != null);
    getModel().getVmInitModel().init(vm.getStaticData());
    getModel().getVmType().setIsChangeable(true);
    getModel().getCopyPermissions().setIsAvailable(true);
    DisksAllocationModel disksAllocationModel = getModel().getDisksAllocationModel();
    disksAllocationModel.setIsVolumeFormatAvailable(true);
    disksAllocationModel.setIsVolumeFormatChangeable(true);
    disksAllocationModel.setIsAliasChangable(true);
    disksAllocationModel.setContainer(getModel());
    disksAllocationModel.setIsThinProvisioning(false);
    AsyncDataProvider.getInstance().getDataCenterById(new AsyncQuery<>(dataCenter -> {
        if (dataCenter == null) {
            disableNewTemplateModel(ConstantsManager.getInstance().getConstants().dataCenterIsNotAccessibleMsg());
        } else {
            AsyncDataProvider.getInstance().getClusterListByService(new AsyncQuery<>(clusters -> {
                List<Cluster> filteredClusters = AsyncDataProvider.getInstance().filterByArchitecture(clusters, vm.getClusterArch());
                getModel().setDataCentersAndClusters(getModel(), Arrays.asList(dataCenter), filteredClusters, vm.getClusterId());
                initTemplate();
            }), true, false);
            AsyncDataProvider.getInstance().isSoundcardEnabled(new AsyncQuery<>(returnValue -> getModel().getIsSoundcardEnabled().setEntity(returnValue)), vm.getId());
        }
    }), vm.getStoragePoolId());
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) Arrays(java.util.Arrays) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) Linq(org.ovirt.engine.ui.uicommonweb.Linq) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) Collections(java.util.Collections) CommonVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommonVmBaseToUnitBuilder) DisksAllocationModel(org.ovirt.engine.ui.uicommonweb.models.storage.DisksAllocationModel) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) DisksAllocationModel(org.ovirt.engine.ui.uicommonweb.models.storage.DisksAllocationModel)

Example 35 with AsyncQuery

use of org.ovirt.engine.ui.frontend.AsyncQuery in project ovirt-engine by oVirt.

the class ProfileBehavior method initProfiles.

public void initProfiles(final Guid clusterId, final Guid dcId, final AsyncQuery<List<VnicProfileView>> profilesQuery) {
    AsyncQuery<QueryReturnValue> networksQuery = new AsyncQuery<>(response -> {
        clusterNetworks = response.getReturnValue();
        managementNetworkName = clusterNetworks.stream().filter(n -> n.getCluster().isManagement()).map(Network::getName).findFirst().orElse(null);
        profilesQuery.converterCallback = returnValue -> {
            List<VnicProfileView> vnicProfiles = new ArrayList<>();
            vnicProfiles.add(VnicProfileView.EMPTY);
            if (returnValue == null) {
                return vnicProfiles;
            }
            for (VnicProfileView vnicProfile : (List<VnicProfileView>) returnValue) {
                Network network = findNetworkById(vnicProfile.getNetworkId());
                if (network != null) {
                    vnicProfiles.add(vnicProfile);
                }
            }
            Collections.sort(vnicProfiles, Linq.VnicProfileViewComparator);
            return vnicProfiles;
        };
        AsyncDataProvider.getInstance().getVnicProfilesByDcId(profilesQuery, dcId);
    });
    Frontend.getInstance().runQuery(QueryType.GetAllVmNetworksByClusterId, new IdQueryParameters(clusterId), networksQuery);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) Network(org.ovirt.engine.core.common.businessentities.network.Network) VnicProfileView(org.ovirt.engine.core.common.businessentities.network.VnicProfileView) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

AsyncQuery (org.ovirt.engine.ui.frontend.AsyncQuery)35 List (java.util.List)25 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)24 Guid (org.ovirt.engine.core.compat.Guid)24 Frontend (org.ovirt.engine.ui.frontend.Frontend)24 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)24 ArrayList (java.util.ArrayList)22 VmBase (org.ovirt.engine.core.common.businessentities.VmBase)21 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)21 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)20 QueryType (org.ovirt.engine.core.common.queries.QueryType)20 Collection (java.util.Collection)19 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)19 Linq (org.ovirt.engine.ui.uicommonweb.Linq)19 BuilderExecutor (org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor)18 Arrays (java.util.Arrays)17 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)17 StringHelper (org.ovirt.engine.core.compat.StringHelper)17 VDS (org.ovirt.engine.core.common.businessentities.VDS)16 Collections (java.util.Collections)15