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.status;
20
21 import java.util.List;
22 import java.util.stream.Collectors;
23 import org.apache.syncope.client.console.commons.DirectoryDataProvider;
24 import org.apache.syncope.client.console.panels.DirectoryPanel;
25 import org.apache.syncope.client.console.panels.MultilevelPanel;
26 import org.apache.syncope.client.console.rest.AbstractAnyRestClient;
27 import org.apache.syncope.client.console.rest.AnyTypeRestClient;
28 import org.apache.syncope.client.ui.commons.Constants;
29 import org.apache.syncope.client.ui.commons.markup.html.form.AjaxDropDownChoicePanel;
30 import org.apache.syncope.client.ui.commons.status.StatusBean;
31 import org.apache.syncope.common.lib.to.Provision;
32 import org.apache.syncope.common.lib.to.ResourceTO;
33 import org.apache.wicket.PageReference;
34 import org.apache.wicket.ajax.AjaxRequestTarget;
35 import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
36 import org.apache.wicket.model.Model;
37
38 public class ResourceStatusModal extends StatusModal<ResourceTO> {
39
40 private static final long serialVersionUID = 1066124171682570080L;
41
42 private Model<String> typeModel = new Model<>();
43
44 public ResourceStatusModal(
45 final PageReference pageRef,
46 final ResourceTO resource) {
47
48 super(pageRef, resource, null, false);
49
50 List<String> availableAnyTypes = resource.getProvisions().stream().
51 map(Provision::getAnyType).
52 sorted(AnyTypeRestClient.KEY_COMPARATOR).
53 collect(Collectors.toList());
54
55 AjaxDropDownChoicePanel<String> anyTypes =
56 new AjaxDropDownChoicePanel<>("anyTypes", "anyTypes", typeModel, false);
57 anyTypes.setChoices(availableAnyTypes);
58 anyTypes.hideLabel();
59 add(anyTypes);
60
61 anyTypes.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
62
63 private static final long serialVersionUID = -1107858522700306810L;
64
65 @Override
66 protected void onUpdate(final AjaxRequestTarget target) {
67 ResourceStatusDirectoryPanel.class.cast(directoryPanel).
68 updateResultTable(typeModel.getObject(), target);
69 }
70 });
71 }
72
73 @Override
74 protected DirectoryPanel<
75 StatusBean, StatusBean, DirectoryDataProvider<StatusBean>, AbstractAnyRestClient<?>> getStatusDirectoryPanel(
76 final MultilevelPanel mlp,
77 final PageReference pageReference,
78 final ResourceTO entity,
79 final String itemKeyFieldName,
80 final boolean statusOnly) {
81
82 return new ResourceStatusDirectoryPanel(mlp, pageReference, null, entity);
83 }
84 }