Search in sources :

Example 6 with EntityModel

use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.

the class ClusterServiceModel method filterServices.

private void filterServices() {
    VDS selectedVds = hostList.getSelectedItem();
    ServiceType serviceType = serviceTypeList.getSelectedItem();
    ArrayList<EntityModel<GlusterServerService>> list = new ArrayList<>();
    List<GlusterServerService> serviceList = new ArrayList<>(getActualServiceList());
    Collections.sort(serviceList, Comparator.comparing(GlusterServerService::getHostName).thenComparing(g -> g.getServiceType().toString()));
    for (GlusterServerService service : serviceList) {
        if ((selectedVds == null || service.getHostName().equals(selectedVds.getHostName())) && (serviceType == null || service.getServiceType() == serviceType)) {
            list.add(new EntityModel<>(service));
        }
    }
    getServiceList().setItems(list);
}
Also used : ServiceType(org.ovirt.engine.core.common.businessentities.gluster.ServiceType) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) List(java.util.List) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) Comparator(java.util.Comparator) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterServerService(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterServerService(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService) ServiceType(org.ovirt.engine.core.common.businessentities.gluster.ServiceType) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList)

Example 7 with EntityModel

use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.

the class GlusterHookResolveConflictsModel method onSelectedHookSourceChanged.

private void onSelectedHookSourceChanged() {
    EntityModel<GlusterServerHook> selectedItem = getHookSources().getSelectedItem();
    if (selectedItem == null) {
        return;
    }
    GlusterServerHook selectedServer = selectedItem.getEntity();
    getServerHooksList().setSelectedItem(selectedServer);
    if (selectedServer.getStatus() == GlusterHookStatus.MISSING) {
        getContentModel().getContent().setEntity(null);
        getContentModel().getStatus().setEntity(null);
        getContentModel().getMd5Checksum().setEntity(null);
        return;
    }
    getContentModel().getStatus().setEntity(selectedServer.getStatus());
    getContentModel().getMd5Checksum().setEntity(selectedServer.getChecksum());
    if (selectedServer.getContentType() == GlusterHookContentType.TEXT) {
        startProgress();
        AsyncDataProvider.getInstance().getGlusterHookContent(new AsyncQuery<>(content -> {
            getContentModel().getContent().setEntity(content);
            stopProgress();
        }), getGlusterHookEntity().getId(), selectedServer.getServerId());
    } else {
        getContentModel().getContent().setEntity(null);
    }
}
Also used : GlusterHookEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity) GlusterHookStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookStatus) GlusterHookContentType(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookContentType) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) GlusterServerHook(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerHook) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Model(org.ovirt.engine.ui.uicommonweb.models.Model) GlusterServerHook(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerHook)

Example 8 with EntityModel

use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.

the class ExportRepoImageModel method setDiskImages.

public void setDiskImages(List<DiskImage> diskImages) {
    ArrayList<EntityModel> entities = new ArrayList<>();
    for (DiskImage i : diskImages) {
        entities.add(new EntityModel(i));
    }
    setEntities(entities);
}
Also used : EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 9 with EntityModel

use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.

the class VmListModel method initRemoveDisksChecboxesPost.

private void initRemoveDisksChecboxesPost(Guid vmId, List<Disk> disks) {
    EntityModel model = vmsRemoveMap.get(vmId);
    if (disks.isEmpty()) {
        updateRemoveDisksCheckBox(model, false, false, ConstantsManager.getInstance().getConstants().removeVmDisksNoDisksMsg());
        return;
    }
    boolean isOnlySharedDisks = true;
    boolean isSnapshotExists = false;
    for (Disk disk : disks) {
        if (!disk.isShareable()) {
            isOnlySharedDisks = false;
            if (disk.getDiskStorageType() == DiskStorageType.IMAGE) {
                if (((DiskImage) disk).getSnapshots().size() > 1) {
                    isSnapshotExists = true;
                    break;
                }
            }
        }
    }
    if (isSnapshotExists) {
        updateRemoveDisksCheckBox(model, true, false, ConstantsManager.getInstance().getConstants().removeVmDisksSnapshotsMsg());
        return;
    }
    if (isOnlySharedDisks) {
        updateRemoveDisksCheckBox(model, false, false, ConstantsManager.getInstance().getConstants().removeVmDisksAllSharedMsg());
        return;
    }
}
Also used : EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 10 with EntityModel

use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.

the class VmListModel method initRemoveDisksCheckboxes.

private void initRemoveDisksCheckboxes(final Map<Guid, EntityModel> vmsMap) {
    ArrayList<QueryParametersBase> params = new ArrayList<>();
    ArrayList<QueryType> queries = new ArrayList<>();
    for (Entry<Guid, EntityModel> entry : vmsMap.entrySet()) {
        if (entry.getValue().getIsChangable()) {
            // No point in fetching VM disks from ones that already determined
            // is unchangeable since they are already initialized
            params.add(new IdQueryParameters(entry.getKey()));
            queries.add(QueryType.GetAllDisksByVmId);
        }
    }
    // revise when refactoring org.ovirt.engine.ui.Frontend to support runMultipleQuery with a single query
    if (!params.isEmpty()) {
        Frontend.getInstance().runMultipleQueries(queries, params, result -> {
            for (int i = 0; i < result.getReturnValues().size(); i++) {
                if (result.getReturnValues().get(i).getSucceeded()) {
                    Guid vmId = ((IdQueryParameters) result.getParameters().get(i)).getId();
                    initRemoveDisksChecboxesPost(vmId, (List<Disk>) result.getReturnValues().get(i).getReturnValue());
                }
            }
        });
    }
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) Guid(org.ovirt.engine.core.compat.Guid) QueryType(org.ovirt.engine.core.common.queries.QueryType) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Aggregations

EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)105 ArrayList (java.util.ArrayList)56 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)27 List (java.util.List)26 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)23 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)22 ListModel (org.ovirt.engine.ui.uicommonweb.models.ListModel)22 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)22 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)20 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)19 ActionType (org.ovirt.engine.core.common.action.ActionType)18 Frontend (org.ovirt.engine.ui.frontend.Frontend)18 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)17 Guid (org.ovirt.engine.core.compat.Guid)17 PropertyChangedEventArgs (org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs)17 VDS (org.ovirt.engine.core.common.businessentities.VDS)16 QueryType (org.ovirt.engine.core.common.queries.QueryType)16 NoSelectionModel (com.google.gwt.view.client.NoSelectionModel)13 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)13 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)13