Search in sources :

Example 81 with QueryReturnValue

use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.

the class GlusterVolumeGeoRepCreateModel method getVolumesForForceSessionCreate.

public void getVolumesForForceSessionCreate() {
    GlusterVolumeGeoRepCreateModel.this.startProgress(constants.fetchingDataMessage());
    // $NON-NLS-1$
    SearchParameters volumesSearchParameters = new SearchParameters("Volumes:", SearchType.GlusterVolume, false);
    volumesSearchParameters.setRefresh(true);
    Frontend.getInstance().runQuery(QueryType.Search, volumesSearchParameters, new AsyncQuery<QueryReturnValue>(returnValue -> showAvailableVolumes(returnValue)));
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) QueryType(org.ovirt.engine.core.common.queries.QueryType) EnumTranslator(org.ovirt.engine.ui.uicompat.EnumTranslator) Guid(org.ovirt.engine.core.compat.Guid) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) IEventListener(org.ovirt.engine.ui.uicompat.IEventListener) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) HashSet(java.util.HashSet) Frontend(org.ovirt.engine.ui.frontend.Frontend) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Pair(org.ovirt.engine.core.common.utils.Pair) Model(org.ovirt.engine.ui.uicommonweb.models.Model) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) Collection(java.util.Collection) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) List(java.util.List) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) GlusterGeoRepNonEligibilityReason(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepNonEligibilityReason) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue)

Example 82 with QueryReturnValue

use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.

the class GlusterVolumeGeoRepCreateModel method getEligibleVolumes.

public void getEligibleVolumes() {
    this.startProgress(constants.fetchingDataMessage());
    Frontend.getInstance().runQuery(QueryType.GetGlusterGeoReplicationEligibleVolumes, new IdQueryParameters(masterVolume.getId()), new AsyncQuery<QueryReturnValue>(returnValue -> showAvailableVolumes(returnValue)));
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) QueryType(org.ovirt.engine.core.common.queries.QueryType) EnumTranslator(org.ovirt.engine.ui.uicompat.EnumTranslator) Guid(org.ovirt.engine.core.compat.Guid) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) IEventListener(org.ovirt.engine.ui.uicompat.IEventListener) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) HashSet(java.util.HashSet) Frontend(org.ovirt.engine.ui.frontend.Frontend) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Pair(org.ovirt.engine.core.common.utils.Pair) Model(org.ovirt.engine.ui.uicommonweb.models.Model) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) Collection(java.util.Collection) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) List(java.util.List) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) GlusterGeoRepNonEligibilityReason(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepNonEligibilityReason) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters)

Example 83 with QueryReturnValue

use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.

the class DiskVmListModel method syncSearch.

@Override
protected void syncSearch() {
    Disk disk = getEntity();
    if (disk == null) {
        return;
    }
    IdQueryParameters getVmsByDiskGuidParameters = new IdQueryParameters(disk.getId());
    getVmsByDiskGuidParameters.setRefresh(getIsQueryFirstTime());
    Frontend.getInstance().runQuery(QueryType.GetVmsByDiskGuid, getVmsByDiskGuidParameters, new AsyncQuery<QueryReturnValue>(returnValue -> {
        diskVmMap = returnValue.getReturnValue();
        ArrayList<VM> vmList = new ArrayList<>();
        ArrayList<VM> pluggedList = (ArrayList<VM>) diskVmMap.get(true);
        ArrayList<VM> unPluggedList = (ArrayList<VM>) diskVmMap.get(false);
        if (pluggedList != null) {
            vmList.addAll(pluggedList);
        }
        if (unPluggedList != null) {
            vmList.addAll(unPluggedList);
        }
        setItems(vmList);
    }));
    setIsQueryFirstTime(false);
}
Also used : QueryType(org.ovirt.engine.core.common.queries.QueryType) Frontend(org.ovirt.engine.ui.frontend.Frontend) VM(org.ovirt.engine.core.common.businessentities.VM) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) HashMap(java.util.HashMap) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Example 84 with QueryReturnValue

use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.

the class EventListModel method refreshModel.

protected void refreshModel() {
    AsyncQuery<QueryReturnValue> query = new AsyncQuery<>(returnValue -> {
        List<AuditLog> newEvents = returnValue.getReturnValue();
        List<AuditLog> currentEvents = (List<AuditLog>) getItems();
        if (isDisplayEventsOnly()) {
            newEvents = newEvents.stream().filter(e -> e.getSeverity() != AuditLogSeverity.ALERT).collect(Collectors.toList());
        }
        if (!newEvents.isEmpty() && currentEvents != null && (currentEvents.isEmpty() || !currentEvents.get(0).equals(newEvents.get(0)))) {
            // We received some new events, tell the active models to update.
            RefreshActiveModelEvent.fire(EventListModel.this, false);
        }
        EventListModel.this.setItems(newEvents);
        EventListModel.this.setLastEvent(Linq.firstOrNull(newEvents));
    });
    SearchParameters params = new SearchParameters(applySortOptions(getSearchString()), SearchType.AuditLog, isCaseSensitiveSearch());
    params.setMaxCount(getSearchPageSize());
    params.setRefresh(false);
    Frontend.getInstance().runQuery(QueryType.Search, params, query);
}
Also used : SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) List(java.util.List) AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog)

Example 85 with QueryReturnValue

use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.

the class TaskListModel method updateSingleTask.

public boolean updateSingleTask(final String guidOrCorrelationId) {
    if (!detailedTaskMap.containsKey(guidOrCorrelationId)) {
        detailedTaskMap.put(guidOrCorrelationId, null);
        if (guidOrCorrelationId.startsWith(WEBADMIN)) {
            GetJobsByCorrelationIdQueryParameters parameters = new GetJobsByCorrelationIdQueryParameters();
            parameters.setCorrelationId(guidOrCorrelationId);
            Frontend.getInstance().runQuery(QueryType.GetJobsByCorrelationId, parameters, new AsyncQuery<QueryReturnValue>(returnValue -> {
                ArrayList<Job> retTasks = returnValue.getReturnValue();
                ArrayList<Job> taskList = (ArrayList<Job>) getItems();
                ArrayList<Job> newTaskList = new ArrayList<>();
                for (Job task : taskList) {
                    if (task.getCorrelationId().equals(guidOrCorrelationId)) {
                        detailedTaskMap.put(guidOrCorrelationId, task);
                        task.setStatus(JobExecutionStatus.FINISHED);
                        for (Job job : retTasks) {
                            Step step = new Step();
                            step.setId(job.getId());
                            step.setDescription(job.getDescription());
                            step.setCorrelationId(job.getCorrelationId());
                            step.setStartTime(job.getStartTime());
                            step.setEndTime(job.getEndTime());
                            step.setStatus(job.getStatus());
                            step.setSteps(job.getSteps());
                            if (!task.getStatus().equals(JobExecutionStatus.FINISHED) && !job.getStatus().equals(JobExecutionStatus.FINISHED)) {
                                task.setStatus(job.getStatus());
                            }
                            if (task.getLastUpdateTime() == null || (task.getLastUpdateTime().before(job.getLastUpdateTime()) && !task.getLastUpdateTime().equals(job.getLastUpdateTime()))) {
                                task.setLastUpdateTime(job.getEndTime());
                            }
                            Date tempDate = task.getLastUpdateTime();
                            if (task.getStartTime() == null || task.getStartTime().after(job.getStartTime())) {
                                task.setStartTime(job.getStartTime());
                            }
                            if (task.getEndTime() != null && (task.getEndTime() == null || task.getEndTime().before(job.getEndTime()))) {
                                task.setEndTime(job.getEndTime());
                            }
                            task.addStep(step);
                            task.setLastUpdateTime(tempDate);
                        }
                    }
                    newTaskList.add(task);
                }
                setItems(newTaskList);
            }));
        } else {
            IdQueryParameters parameters = new IdQueryParameters(new Guid(guidOrCorrelationId));
            Frontend.getInstance().runQuery(QueryType.GetJobByJobId, parameters, new AsyncQuery<QueryReturnValue>(returnValue -> {
                Job retTask = returnValue.getReturnValue();
                if (retTask == null) {
                    return;
                }
                detailedTaskMap.put(retTask.getId().toString(), retTask);
                ArrayList<Job> taskList = (ArrayList<Job>) getItems();
                ArrayList<Job> newTaskList = new ArrayList<>();
                for (Job task : taskList) {
                    if (task.getId().equals(retTask.getId())) {
                        newTaskList.add(retTask);
                    } else {
                        newTaskList.add(task);
                    }
                }
                setItems(newTaskList);
            }));
        }
        return false;
    }
    return true;
}
Also used : GetJobsByOffsetQueryParameters(org.ovirt.engine.core.common.queries.GetJobsByOffsetQueryParameters) JobExecutionStatus(org.ovirt.engine.core.common.job.JobExecutionStatus) QueryType(org.ovirt.engine.core.common.queries.QueryType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Date(java.util.Date) Job(org.ovirt.engine.core.common.job.Job) Guid(org.ovirt.engine.core.compat.Guid) HashMap(java.util.HashMap) Random(java.util.Random) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) GetJobsByCorrelationIdQueryParameters(org.ovirt.engine.core.common.queries.GetJobsByCorrelationIdQueryParameters) Frontend(org.ovirt.engine.ui.frontend.Frontend) List(java.util.List) Map(java.util.Map) Step(org.ovirt.engine.core.common.job.Step) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) GetJobsByCorrelationIdQueryParameters(org.ovirt.engine.core.common.queries.GetJobsByCorrelationIdQueryParameters) GetJobsByCorrelationIdQueryParameters(org.ovirt.engine.core.common.queries.GetJobsByCorrelationIdQueryParameters) ArrayList(java.util.ArrayList) Step(org.ovirt.engine.core.common.job.Step) Guid(org.ovirt.engine.core.compat.Guid) Job(org.ovirt.engine.core.common.job.Job) Date(java.util.Date)

Aggregations

QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)265 ArrayList (java.util.ArrayList)123 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)97 QueryType (org.ovirt.engine.core.common.queries.QueryType)85 List (java.util.List)74 Guid (org.ovirt.engine.core.compat.Guid)66 Frontend (org.ovirt.engine.ui.frontend.Frontend)64 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)54 VM (org.ovirt.engine.core.common.businessentities.VM)49 QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)47 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)42 HashMap (java.util.HashMap)40 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)39 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)39 Test (org.junit.Test)38 Collection (java.util.Collection)34 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)33 Map (java.util.Map)31 ActionType (org.ovirt.engine.core.common.action.ActionType)31 VDS (org.ovirt.engine.core.common.businessentities.VDS)31