1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.client.console.tasks;
20
21 import java.util.ArrayList;
22 import java.util.List;
23 import org.apache.commons.lang3.tuple.Pair;
24 import org.apache.syncope.client.console.panels.MultilevelPanel;
25 import org.apache.syncope.client.console.rest.CommandRestClient;
26 import org.apache.syncope.client.console.rest.TaskRestClient;
27 import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.BooleanPropertyColumn;
28 import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
29 import org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel;
30 import org.apache.syncope.common.lib.to.MacroTaskTO;
31 import org.apache.syncope.common.lib.types.IdRepoEntitlement;
32 import org.apache.syncope.common.lib.types.TaskType;
33 import org.apache.wicket.PageReference;
34 import org.apache.wicket.ajax.AjaxRequestTarget;
35 import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
36 import org.apache.wicket.model.IModel;
37 import org.apache.wicket.model.Model;
38 import org.apache.wicket.model.ResourceModel;
39 import org.apache.wicket.model.StringResourceModel;
40 import org.apache.wicket.spring.injection.annot.SpringBean;
41
42 public class MacroTaskDirectoryPanel extends SchedTaskDirectoryPanel<MacroTaskTO> {
43
44 private static final long serialVersionUID = -6247673131495530094L;
45
46 @SpringBean
47 protected CommandRestClient commandRestClient;
48
49 public MacroTaskDirectoryPanel(
50 final TaskRestClient restClient,
51 final MultilevelPanel mlp,
52 final PageReference pageRef) {
53
54 super(MultilevelPanel.FIRST_LEVEL_ID, restClient, null, mlp, TaskType.MACRO, new MacroTaskTO(), pageRef, true);
55 }
56
57 @Override
58 protected List<IColumn<MacroTaskTO, String>> getFieldColumns() {
59 List<IColumn<MacroTaskTO, String>> columns = new ArrayList<>();
60
61 columns.addAll(getHeadingFieldColumns());
62
63 columns.add(new BooleanPropertyColumn<>(
64 new ResourceModel("continueOnError"), "continueOnError", "continueOnError"));
65 columns.add(new BooleanPropertyColumn<>(
66 new ResourceModel("saveExecs"), "saveExecs", "saveExecs"));
67
68 columns.addAll(getTrailingFieldColumns());
69
70 return columns;
71 }
72
73 @Override
74 protected void viewTaskExecs(final MacroTaskTO taskTO, final AjaxRequestTarget target) {
75 multiLevelPanelRef.next(
76 new StringResourceModel("task.view", this, new Model<>(Pair.of(null, taskTO))).getObject(),
77 new TaskExecutionDetails<>(taskTO, pageRef),
78 target);
79 }
80
81 @Override
82 protected void addFurtherActions(final ActionsPanel<MacroTaskTO> panel, final IModel<MacroTaskTO> model) {
83 panel.add(new ActionLink<>() {
84
85 private static final long serialVersionUID = -3722207913631435501L;
86
87 @Override
88 public void onClick(final AjaxRequestTarget target, final MacroTaskTO ignore) {
89 target.add(modal.setContent(new CommandComposeDirectoryPanel(
90 commandRestClient, modal, model.getObject().getKey(), pageRef)));
91
92 modal.header(new StringResourceModel(
93 "command.conf", MacroTaskDirectoryPanel.this, Model.of(model.getObject())));
94 modal.show(true);
95 }
96 }, ActionLink.ActionType.COMPOSE, IdRepoEntitlement.TASK_UPDATE);
97 }
98 }