-
Notifications
You must be signed in to change notification settings - Fork 188
/
PageTask.java
600 lines (501 loc) · 24.7 KB
/
PageTask.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
package com.evolveum.midpoint.web.page.admin.server;
import java.io.InputStream;
import java.util.Collection;
import java.util.Collections;
import com.evolveum.midpoint.gui.impl.prism.PrismPropertyValueWrapper;
import com.evolveum.midpoint.gui.impl.prism.PrismReferenceValueWrapperImpl;
import com.evolveum.midpoint.gui.impl.prism.PrismReferenceWrapper;
import com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipal;
import com.evolveum.midpoint.model.api.util.ModelContextUtil;
import com.evolveum.midpoint.prism.Referencable;
import com.evolveum.midpoint.schema.ObjectDeltaOperation;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.web.security.util.SecurityUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.wicket.Page;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import com.evolveum.midpoint.gui.api.GuiStyleConstants;
import com.evolveum.midpoint.gui.api.prism.PrismObjectWrapper;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.gui.impl.prism.PrismPropertyWrapper;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.report.api.ReportConstants;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.MiscUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.application.AuthorizationAction;
import com.evolveum.midpoint.web.application.PageDescriptor;
import com.evolveum.midpoint.web.application.Url;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.AjaxDownloadBehaviorFromStream;
import com.evolveum.midpoint.web.component.AjaxIconButton;
import com.evolveum.midpoint.web.component.ObjectSummaryPanel;
import com.evolveum.midpoint.web.component.objectdetails.AbstractObjectMainPanel;
import com.evolveum.midpoint.web.component.refresh.Refreshable;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.page.admin.PageAdminObjectDetails;
import com.evolveum.midpoint.web.page.admin.reports.PageCreatedReports;
import com.evolveum.midpoint.web.util.OnePageParameterEncoder;
import com.evolveum.midpoint.web.util.TaskOperationUtils;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
@PageDescriptor(
urls = {
@Url(mountUrl = "/admin/task", matchUrlForSecurity = "/admin/task")
},
encoder = OnePageParameterEncoder.class,
action = {
@AuthorizationAction(actionUri = AuthorizationConstants.AUTZ_UI_USERS_ALL_URL,
label = "PageAdminUsers.auth.usersAll.label",
description = "PageAdminUsers.auth.usersAll.description"),
@AuthorizationAction(actionUri = AuthorizationConstants.AUTZ_UI_USER_URL,
label = "PageUser.auth.user.label",
description = "PageUser.auth.user.description")
})
public class PageTask extends PageAdminObjectDetails<TaskType> implements Refreshable {
private static final long serialVersionUID = 1L;
private static final transient Trace LOGGER = TraceManager.getTrace(PageTask.class);
private static final String DOT_CLASS = PageTask.class.getName() + ".";
protected static final String OPERATION_EXECUTE_TASK_CHANGES = DOT_CLASS + "executeTaskChanges";
private static final String OPERATION_LOAD_REPORT_OUTPUT = DOT_CLASS + "loadReport";
private static final int REFRESH_INTERVAL = 2000;
private Boolean refreshEnabled;
private TaskTabsVisibility taskTabsVisibility;
public PageTask() {
initialize(null);
}
public PageTask(PageParameters parameters) {
getPageParameters().overwriteWith(parameters);
initialize(null);
}
public PageTask(final PrismObject<TaskType> taskToEdit) {
initialize(taskToEdit);
}
public PageTask(final PrismObject<TaskType> taskToEdit, boolean isNewObject) {
initialize(taskToEdit, isNewObject);
}
@Override
public Class<TaskType> getCompileTimeClass() {
return TaskType.class;
}
@Override
protected TaskType createNewObject() {
return new TaskType();
}
@Override
protected ObjectSummaryPanel<TaskType> createSummaryPanel(IModel<TaskType> summaryModel) {
return new TaskSummaryPanel(ID_SUMMARY_PANEL, summaryModel, this, this);
}
@Override
protected Collection<SelectorOptions<GetOperationOptions>> buildGetOptions() {
//TODO use full options as defined in TaskDtoProviderOptions.fullOptions()
return getOperationOptionsBuilder()
// retrieve
.item(TaskType.F_SUBTASK_REF).retrieve()
.item(TaskType.F_NODE_AS_OBSERVED).retrieve()
.item(TaskType.F_NEXT_RUN_START_TIMESTAMP).retrieve()
.item(TaskType.F_NEXT_RETRY_TIMESTAMP).retrieve()
.item(TaskType.F_RESULT).retrieve() // todo maybe only when it is to be displayed
.build();
}
protected void initOperationalButtons(RepeatingView repeatingView) {
super.initOperationalButtons(repeatingView);
createSuspendButton(repeatingView);
createResumeButton(repeatingView);
createRunNowButton(repeatingView);
createManageLivesyncTokenButton(repeatingView);
createDownloadReportButton(repeatingView);
createCleanupPerformanceButton(repeatingView);
createCleanupResultsButton(repeatingView);
createRefreshNowIconButton(repeatingView);
createResumePauseButton(repeatingView);
// AjaxIconButton cleanupErrors = new AjaxIconButton(repeatingView.newChildId(), new Model<>(GuiStyleConstants.CLASS_ICON_TRASH),
// createStringResource("operationalButtonsPanel.cleanupErrors")) {
//
// @Override
// public void onClick(AjaxRequestTarget target) {
// refresh(target);
// }
// };
// cleanupErrors.add(AttributeAppender.append("class", "btn btn-default btn-margin-left btn-sm"));
// cleanupErrors.add(new VisibleBehaviour(this::isNotRunning));
// repeatingView.add(cleanupErrors);
setOutputMarkupId(true);
final Label status = new Label(repeatingView.newChildId(), this::createRefreshingLabel);
status.setOutputMarkupId(true);
repeatingView.add(status);
}
private void createSuspendButton(RepeatingView repeatingView) {
AjaxButton suspend = new AjaxButton(repeatingView.newChildId(), createStringResource("pageTaskEdit.button.suspend")) {
@Override
public void onClick(AjaxRequestTarget target) {
String taskOid = getObjectWrapper().getOid();
OperationResult result = TaskOperationUtils.suspendPerformed(getTaskService(), Collections.singletonList(taskOid), PageTask.this);
afterOperation(target, result);
}
};
suspend.add(new VisibleBehaviour(() -> WebComponentUtil.canSuspendTask(getTask(), PageTask.this)));
suspend.add(AttributeAppender.append("class", "btn-danger"));
repeatingView.add(suspend);
}
private void createResumeButton(RepeatingView repeatingView) {
AjaxButton resume = new AjaxButton(repeatingView.newChildId(), createStringResource("pageTaskEdit.button.resume")) {
@Override
public void onClick(AjaxRequestTarget target) {
String oid = getObjectWrapper().getOid();
OperationResult result = TaskOperationUtils.resumePerformed(getTaskService(), Collections.singletonList(oid), PageTask.this);
afterOperation(target, result);
}
};
resume.add(AttributeAppender.append("class", "btn-primary"));
resume.add(new VisibleBehaviour(() -> WebComponentUtil.canResumeTask(getTask(), PageTask.this)));
repeatingView.add(resume);
}
private void createRunNowButton(RepeatingView repeatingView) {
AjaxButton runNow = new AjaxButton(repeatingView.newChildId(), createStringResource("pageTaskEdit.button.runNow")) {
@Override
public void onClick(AjaxRequestTarget target) {
String oid = getObjectWrapper().getOid();
refreshEnabled = Boolean.TRUE;
OperationResult result = TaskOperationUtils.runNowPerformed(getTaskService(), Collections.singletonList(oid), PageTask.this);
afterOperation(target, result);
}
};
runNow.add(AttributeAppender.append("class", "btn-success"));
runNow.add(new VisibleBehaviour(() -> WebComponentUtil.canRunNowTask(getTask(), PageTask.this)));
repeatingView.add(runNow);
}
private void createManageLivesyncTokenButton(RepeatingView repeatingView) {
AjaxButton manageLivesyncToken = new AjaxButton(repeatingView.newChildId(), createStringResource("PageTask.livesync.token")) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
LivesyncTokenEditorPanel tokenEditor = new LivesyncTokenEditorPanel(PageTask.this.getMainPopupBodyId(), getObjectModel()) {
@Override
protected void saveTokenPerformed(ObjectDelta<TaskType> tokenDelta, AjaxRequestTarget target) {
saveTaskChanges(target, tokenDelta);
}
};
tokenEditor.setOutputMarkupId(true);
PageTask.this.showMainPopup(tokenEditor, ajaxRequestTarget);
}
};
manageLivesyncToken.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return WebComponentUtil.isLiveSync(getTask()) && isNotRunning() && getTask().asPrismObject().findProperty(LivesyncTokenEditorPanel.PATH_TOKEN) != null;
}
@Override
public boolean isEnabled() {
return isNotRunning();
}
});
manageLivesyncToken.add(AttributeAppender.append("class", "btn-default"));
manageLivesyncToken.setOutputMarkupId(true);
repeatingView.add(manageLivesyncToken);
}
private void createDownloadReportButton(RepeatingView repeatingView) {
final AjaxDownloadBehaviorFromStream ajaxDownloadBehavior = new AjaxDownloadBehaviorFromStream() {
private static final long serialVersionUID = 1L;
@Override
protected InputStream initStream() {
ReportOutputType reportObject = getReportOutput();
if (reportObject != null) {
return PageCreatedReports.createReport(reportObject, this, PageTask.this);
} else {
return null;
}
}
@Override
public String getFileName() {
ReportOutputType reportObject = getReportOutput();
return PageCreatedReports.getReportFileName(reportObject);
}
};
add(ajaxDownloadBehavior);
AjaxButton download = new AjaxButton(repeatingView.newChildId(), createStringResource("PageTask.download.report")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
ajaxDownloadBehavior.initiate(target);
}
};
download.add(new VisibleBehaviour(() -> isDownloadReportVisible()));
download.add(AttributeAppender.append("class", "btn-primary"));
repeatingView.add(download);
}
private boolean isDownloadReportVisible() {
return WebComponentUtil.isReport(getTask())
&& getReportOutputProperty() != null;
}
private ReportOutputType getReportOutput() {
PrismProperty<String> reportOutput = getReportOutputProperty();
if (reportOutput == null) {
return null;
}
String reportOutputOid = reportOutput.getRealValue();
if (reportOutputOid == null) {
return null;
}
Task opTask = createSimpleTask(OPERATION_LOAD_REPORT_OUTPUT);
OperationResult result = opTask.getResult();
PrismObject<ReportOutputType> report = WebModelServiceUtils.loadObject(ReportOutputType.class, reportOutputOid, this, opTask, result);
if (report == null) {
return null;
}
result.computeStatusIfUnknown();
showResult(result, false);
return report.asObjectable();
}
private PrismProperty<String> getReportOutputProperty() {
PrismObject<TaskType> task = getTask().asPrismObject();
return task.findProperty(ItemPath.create(TaskType.F_EXTENSION, ReportConstants.REPORT_OUTPUT_OID_PROPERTY_NAME));
}
private void createRefreshNowIconButton(RepeatingView repeatingView) {
AjaxIconButton refreshNow = new AjaxIconButton(repeatingView.newChildId(), new Model<>("fa fa-refresh"), createStringResource("autoRefreshPanel.refreshNow")) {
@Override
public void onClick(AjaxRequestTarget target) {
refresh(target);
}
};
refreshNow.add(AttributeAppender.append("class", "btn btn-default btn-sm"));
repeatingView.add(refreshNow);
}
private void createResumePauseButton(RepeatingView repeatingView) {
AjaxIconButton resumePauseRefreshing = new AjaxIconButton(repeatingView.newChildId(), (IModel<String>) this::createResumePauseButtonLabel, createStringResource("autoRefreshPanel.resumeRefreshing")) {
@Override
public void onClick(AjaxRequestTarget target) {
refreshEnabled = !isRefreshEnabled();
refresh(target);
}
};
resumePauseRefreshing.add(AttributeAppender.append("class", "btn btn-default btn-margin-left btn-sm"));
repeatingView.add(resumePauseRefreshing);
}
private void createCleanupPerformanceButton(RepeatingView repeatingView) {
AjaxIconButton cleanupPerformance = new AjaxIconButton(repeatingView.newChildId(), new Model<>(GuiStyleConstants.CLASS_ICON_TRASH),
createStringResource("operationalButtonsPanel.cleanupEnvironmentalPerformance")) {
@Override
public void onClick(AjaxRequestTarget target) {
try {
getObjectWrapper().findProperty(ItemPath.create(TaskType.F_OPERATION_STATS,
OperationStatsType.F_ENVIRONMENTAL_PERFORMANCE_INFORMATION)).getValue().setRealValue(null);
} catch (SchemaException e){
LOGGER.error("Cannot clear task results: {}", e.getMessage());
}
saveTaskChanges(target);
}
};
cleanupPerformance.add(AttributeAppender.append("class", "btn btn-default btn-margin-left btn-sm"));
cleanupPerformance.add(new VisibleBehaviour(this::isNotRunning));
repeatingView.add(cleanupPerformance);
}
private void createCleanupResultsButton(RepeatingView repeatingView) {
AjaxIconButton cleanupResults = new AjaxIconButton(repeatingView.newChildId(), new Model<>(GuiStyleConstants.CLASS_ICON_TRASH),
createStringResource("operationalButtonsPanel.cleanupResults")) {
@Override
public void onClick(AjaxRequestTarget target) {
try {
getObjectWrapper().findProperty(TaskType.F_RESULT).getValue().setRealValue(null);
getObjectWrapper().findProperty(TaskType.F_RESULT_STATUS).getValue().setRealValue(null);
} catch (SchemaException e){
LOGGER.error("Cannot clear task results: {}", e.getMessage());
}
saveTaskChanges(target);
refresh(target);
}
};
cleanupResults.add(new VisibleBehaviour(this::isNotRunning));
cleanupResults.add(AttributeAppender.append("class", "btn btn-default btn-margin-left btn-sm"));
repeatingView.add(cleanupResults);
}
private void saveTaskChanges(AjaxRequestTarget target) {
try {
ObjectDelta<TaskType> taskDelta = getObjectWrapper().getObjectDelta();
saveTaskChanges(target, taskDelta);
} catch (SchemaException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Cannot get task delta.", e);
getSession().error("Cannot save changes, there were problems with computing changes: " + e.getMessage());
target.add(getFeedbackPanel());
}
}
private void saveTaskChanges(AjaxRequestTarget target, ObjectDelta<TaskType> taskDelta){
if (taskDelta.isEmpty()) {
getSession().warn("Nothing to save, no changes were made.");
return;
}
OperationResult result = new OperationResult(OPERATION_EXECUTE_TASK_CHANGES);
Task task = createSimpleTask(OPERATION_EXECUTE_TASK_CHANGES);
try {
taskDelta.revive(getPrismContext()); //do we need revive here?
getModelService().executeChanges(MiscUtil.createCollection(taskDelta), null, task, result);
result.computeStatus();
getObjectModel().reset();
} catch (Exception e) {
LoggingUtils.logUnexpectedException(LOGGER, "Cannot save tasks changes", e);
result.recordFatalError("Cannot save tasks changes, " + e.getMessage(), e);
}
afterOperation(target, result);
}
private void afterOperation(AjaxRequestTarget target, OperationResult result) {
showResult(result);
getObjectModel().reset();
refresh(target);
}
public void saveAndRunPerformed(AjaxRequestTarget target) {
PrismObjectWrapper<TaskType> taskWrapper = getObjectWrapper();
try {
PrismPropertyWrapper<TaskExecutionStatusType> executionStatus = taskWrapper.findProperty(ItemPath.create(TaskType.F_EXECUTION_STATUS));
executionStatus.getValue().setRealValue(TaskExecutionStatusType.RUNNABLE);
setupOwner(taskWrapper);
setupRecurrence(taskWrapper);
} catch (SchemaException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Error while finishing task settings.", e);
target.add(getFeedbackPanel());
return;
}
if (!checkScheduleFilledForReccurentTask(taskWrapper)) {
getSession().error("Cannot run recurring task without setting scheduling for it.");
target.add(getFeedbackPanel());
return;
}
super.savePerformed(target);
}
private void setupOwner(PrismObjectWrapper<TaskType> taskWrapper) throws SchemaException {
PrismReferenceWrapper<Referencable> taskOwner = taskWrapper.findReference(ItemPath.create(TaskType.F_OWNER_REF));
if (taskOwner == null) {
return;
}
PrismReferenceValueWrapperImpl<Referencable> taskOwnerValue = taskOwner.getValue();
if (taskOwnerValue == null){
return;
}
if (taskOwnerValue.getNewValue() == null || taskOwnerValue.getNewValue().isEmpty()) {
GuiProfiledPrincipal guiPrincipal = SecurityUtils.getPrincipalUser();
if (guiPrincipal == null) {
//BTW something very strange must happened
return;
}
FocusType focus = guiPrincipal.getFocus();
taskOwnerValue.setRealValue(ObjectTypeUtil.createObjectRef(focus, SchemaConstants.ORG_DEFAULT));
}
}
private void setupRecurrence(PrismObjectWrapper<TaskType> taskWrapper) throws SchemaException {
PrismPropertyWrapper<TaskRecurrenceType> recurrenceWrapper = taskWrapper.findProperty(ItemPath.create(TaskType.F_RECURRENCE));
if (recurrenceWrapper == null) {
return;
}
PrismPropertyValueWrapper<TaskRecurrenceType> recurrenceWrapperValue = recurrenceWrapper.getValue();
if (recurrenceWrapperValue == null) {
return;
}
if (recurrenceWrapperValue.getNewValue() == null || recurrenceWrapperValue.getNewValue().isEmpty()) {
recurrenceWrapperValue.setRealValue(TaskRecurrenceType.SINGLE);
}
}
@Override
public void finishProcessing(AjaxRequestTarget target, Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas, boolean returningFromAsync, OperationResult result) {
if (isPreviewRequested()) {
super.finishProcessing(target, executedDeltas, returningFromAsync, result);
return;
}
if (result.isSuccess() && executedDeltas != null) {
//TODO change to inProgress result, so there is a link to existing task
String taskOid = ObjectDeltaOperation.findFocusDeltaOidInCollection(executedDeltas);
if (taskOid != null) {
result.recordInProgress();
result.setBackgroundTaskOid(taskOid);
}
}
super.finishProcessing(target, executedDeltas, returningFromAsync, result);
}
private boolean checkScheduleFilledForReccurentTask(PrismObjectWrapper<TaskType> taskWrapper) {
PrismObject<TaskType> task = taskWrapper.getObject();
PrismProperty<TaskRecurrenceType> recurrenceType = task.findProperty(ItemPath.create(TaskType.F_RECURRENCE));
if (recurrenceType == null) {
return true;
}
TaskRecurrenceType recurenceValue = recurrenceType.getRealValue();
if (recurenceValue == null || TaskRecurrenceType.SINGLE == recurenceValue) {
return true;
}
ScheduleType schedule = task.asObjectable().getSchedule();
//if schedule is not set and task is recurring, show warning.
return schedule.getCronLikePattern() != null || schedule.getEarliestStartTime() != null
|| schedule.getInterval() != null || schedule.getLatestFinishTime() != null
|| schedule.getLatestStartTime() != null || schedule.getMisfireAction() != null;
}
private String createRefreshingLabel() {
if (isRefreshEnabled()) {
return createStringResource("autoRefreshPanel.refreshingEach", getRefreshInterval() / 1000).getString();
} else {
return createStringResource("autoRefreshPanel.noRefreshing").getString();
}
}
private String createResumePauseButtonLabel() {
if (isRefreshEnabled()) {
return "fa fa-pause";
}
return "fa fa-play";
}
@Override
protected AbstractObjectMainPanel<TaskType> createMainPanel(String id) {
taskTabsVisibility = new TaskTabsVisibility();
taskTabsVisibility.computeAll(this, getObjectWrapper());
return new TaskMainPanel(id, getObjectModel(), this);
}
TaskType getTask(){
return getObjectWrapper().getObject().asObjectable();
}
@Override
protected Class<? extends Page> getRestartResponsePage() {
return PageTasks.class;
}
@Override
public void continueEditing(AjaxRequestTarget target) {
}
@Override
public int getRefreshInterval() {
return REFRESH_INTERVAL;
}
private boolean isNotRunning(){
return !WebComponentUtil.isRunningTask(getTask());
}
public boolean isRefreshEnabled() {
if (refreshEnabled == null) {
return WebComponentUtil.isRunningTask(getTask());
}
return refreshEnabled;
}
@Override
public void refresh(AjaxRequestTarget target) {
TaskTabsVisibility taskTabsVisibilityNew = new TaskTabsVisibility();
taskTabsVisibilityNew.computeAll(this, getObjectWrapper());
boolean soft = false;
if (taskTabsVisibilityNew.equals(taskTabsVisibility)) {
soft = true;
}
taskTabsVisibility = taskTabsVisibilityNew;
super.refresh(target, soft);
}
public TaskTabsVisibility getTaskTabVisibilty() {
return taskTabsVisibility;
}
}