View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
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  }