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.wizards.any;
20  
21  import java.text.MessageFormat;
22  import java.util.List;
23  import java.util.stream.Collectors;
24  import org.apache.syncope.client.console.panels.ListViewPanel;
25  import org.apache.syncope.client.ui.commons.wicket.markup.html.bootstrap.tabs.Accordion;
26  import org.apache.syncope.common.lib.to.ProvisioningReport;
27  import org.apache.wicket.PageReference;
28  import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
29  import org.apache.wicket.markup.html.WebMarkupContainer;
30  import org.apache.wicket.markup.html.panel.Panel;
31  import org.apache.wicket.model.Model;
32  
33  public class ProvisioningReportsPanel extends Panel {
34  
35      private static final long serialVersionUID = -1450755344104125918L;
36  
37      public ProvisioningReportsPanel(
38              final String id, final List<ProvisioningReport> results, final PageReference pageRef) {
39          super(id);
40  
41          List<ProvisioningReport> success = results.stream().
42                  filter(result -> result.getStatus() == ProvisioningReport.Status.SUCCESS).
43                  collect(Collectors.toList());
44          add(new Accordion("success", List.of(new AbstractTab(
45                  new Model<>(MessageFormat.format(getString("success"), success.size()))) {
46  
47              private static final long serialVersionUID = 1037272333056449378L;
48  
49              @Override
50              public WebMarkupContainer getPanel(final String panelId) {
51                  return new ListViewPanel.Builder<>(ProvisioningReport.class, pageRef).
52                          setItems(success).
53                          withChecks(ListViewPanel.CheckAvailability.NONE).
54                          setCaptionVisible(false).
55                          includes("name", "message").
56                          build(panelId);
57              }
58          }), Model.of(-1)).setOutputMarkupId(true));
59  
60          List<ProvisioningReport> failure = results.stream().
61                  filter(result -> result.getStatus() == ProvisioningReport.Status.FAILURE).
62                  collect(Collectors.toList());
63          add(new Accordion("failure", List.of(new AbstractTab(
64                  new Model<>(MessageFormat.format(getString("failure"), failure.size()))) {
65  
66              private static final long serialVersionUID = 1037272333056449378L;
67  
68              @Override
69              public WebMarkupContainer getPanel(final String panelId) {
70                  return new ListViewPanel.Builder<>(ProvisioningReport.class, pageRef).
71                          setItems(failure).
72                          withChecks(ListViewPanel.CheckAvailability.NONE).
73                          setCaptionVisible(false).
74                          includes("name", "message").
75                          build(panelId);
76              }
77          }), Model.of(-1)).setOutputMarkupId(true));
78  
79          List<ProvisioningReport> ignore = results.stream().
80                  filter(result -> result.getStatus() == ProvisioningReport.Status.IGNORE).
81                  collect(Collectors.toList());
82          add(new Accordion("ignore", List.of(new AbstractTab(
83                  new Model<>(MessageFormat.format(getString("ignore"), ignore.size()))) {
84  
85              private static final long serialVersionUID = 1037272333056449378L;
86  
87              @Override
88              public WebMarkupContainer getPanel(final String panelId) {
89                  return new ListViewPanel.Builder<>(ProvisioningReport.class, pageRef).
90                          setItems(ignore).
91                          withChecks(ListViewPanel.CheckAvailability.NONE).
92                          setCaptionVisible(false).
93                          includes("name", "message").
94                          build(panelId);
95              }
96          }), Model.of(-1)).setOutputMarkupId(true));
97      }
98  }