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.policies;
20
21 import java.util.List;
22 import org.apache.syncope.client.console.rest.PolicyRestClient;
23 import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.BooleanPropertyColumn;
24 import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
25 import org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel;
26 import org.apache.syncope.common.lib.policy.AttrReleasePolicyTO;
27 import org.apache.syncope.common.lib.policy.DefaultAttrReleasePolicyConf;
28 import org.apache.syncope.common.lib.types.IdRepoEntitlement;
29 import org.apache.syncope.common.lib.types.PolicyType;
30 import org.apache.wicket.PageReference;
31 import org.apache.wicket.ajax.AjaxRequestTarget;
32 import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy;
33 import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
34 import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
35 import org.apache.wicket.model.IModel;
36 import org.apache.wicket.model.Model;
37 import org.apache.wicket.model.StringResourceModel;
38
39 public class AttrReleasePolicyDirectoryPanel extends PolicyDirectoryPanel<AttrReleasePolicyTO> {
40
41 private static final long serialVersionUID = 4984337552918213290L;
42
43 public AttrReleasePolicyDirectoryPanel(
44 final String id,
45 final PolicyRestClient restClient,
46 final PageReference pageRef) {
47
48 super(id, restClient, PolicyType.ATTR_RELEASE, pageRef);
49
50 AttrReleasePolicyTO defaultItem = new AttrReleasePolicyTO();
51
52 this.addNewItemPanelBuilder(
53 new PolicyModalPanelBuilder<>(PolicyType.ATTR_RELEASE, defaultItem, modal, restClient, pageRef), true);
54 MetaDataRoleAuthorizationStrategy.authorize(addAjaxLink, RENDER, IdRepoEntitlement.POLICY_CREATE);
55
56 initResultTable();
57 }
58
59 @Override
60 protected void addCustomColumnFields(final List<IColumn<AttrReleasePolicyTO, String>> columns) {
61 columns.add(new PropertyColumn<>(new StringResourceModel("order", this), "order", "order"));
62 columns.add(new BooleanPropertyColumn<>(new StringResourceModel("status", this), "status", "status"));
63 }
64
65 @Override
66 protected void addCustomActions(
67 final ActionsPanel<AttrReleasePolicyTO> panel,
68 final IModel<AttrReleasePolicyTO> model) {
69
70 panel.add(new ActionLink<>() {
71
72 private static final long serialVersionUID = -3722207913631435501L;
73
74 @Override
75 public void onClick(final AjaxRequestTarget target, final AttrReleasePolicyTO ignore) {
76 model.setObject(restClient.read(type, model.getObject().getKey()));
77 if (model.getObject().getConf() == null) {
78 model.getObject().setConf(new DefaultAttrReleasePolicyConf());
79 }
80 target.add(policySpecModal.setContent(
81 new AttrReleasePolicyModalPanel(policySpecModal, model, pageRef)));
82 policySpecModal.header(new Model<>(getString("attrReleasePolicyConf.title", model)));
83 policySpecModal.show(true);
84 }
85 }, ActionLink.ActionType.CHANGE_VIEW, IdRepoEntitlement.POLICY_UPDATE);
86 }
87 }