Search in sources :

Example 1 with GetJobsByCorrelationIdQueryParameters

use of org.ovirt.engine.core.common.queries.GetJobsByCorrelationIdQueryParameters 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

ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Random (java.util.Random)1 Job (org.ovirt.engine.core.common.job.Job)1 JobExecutionStatus (org.ovirt.engine.core.common.job.JobExecutionStatus)1 Step (org.ovirt.engine.core.common.job.Step)1 GetJobsByCorrelationIdQueryParameters (org.ovirt.engine.core.common.queries.GetJobsByCorrelationIdQueryParameters)1 GetJobsByOffsetQueryParameters (org.ovirt.engine.core.common.queries.GetJobsByOffsetQueryParameters)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)1 QueryType (org.ovirt.engine.core.common.queries.QueryType)1 Guid (org.ovirt.engine.core.compat.Guid)1 Frontend (org.ovirt.engine.ui.frontend.Frontend)1 SearchableListModel (org.ovirt.engine.ui.uicommonweb.models.SearchableListModel)1