in client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/mapping/AbstractMappingPanel.java [120:385]
public AbstractMappingPanel(
final String id,
final ItemTransformersTogglePanel itemTransformers,
final JEXLTransformersTogglePanel jexlTransformers,
final IModel<List<Item>> model,
final boolean addMappingBtnVisible,
final MappingPurpose defaultPurpose) {
super(id);
setOutputMarkupId(true);
mappingContainer = new WebMarkupContainer("mappingContainer");
mappingContainer.setOutputMarkupId(true);
add(mappingContainer);
mappingContainer.add(new Label("itemTransformersLabel", Model.of()).setVisible(itemTransformers != null));
mappingContainer.add(new Label("jexlTransformersLabel", Model.of()).setVisible(jexlTransformers != null));
connObjectKeyLabel = new Label("connObjectKeyLabel", new ResourceModel("connObjectKey"));
mappingContainer.add(connObjectKeyLabel);
passwordLabel = new Label("passwordLabel", new ResourceModel("password"));
mappingContainer.add(passwordLabel);
purposeLabel = new Label("purposeLabel", new ResourceModel("purpose"));
mappingContainer.add(purposeLabel);
intAttrNameInfo = new Label("intAttrNameInfo", Model.of());
intAttrNameInfo.add(new PopoverBehavior(
Model.of(),
Model.of(getString("intAttrNameInfo.help")
+ "<code>groups[groupName].attribute</code>, "
+ "<code>users[userName].attribute</code>, "
+ "<code>anyObjects[anyObjectName].attribute</code>, "
+ "<code>relationships[relationshipType][anyType].attribute</code> or "
+ "<code>memberships[groupName].attribute</code>"),
new PopoverConfig().withHtml(true).withPlacement(TooltipConfig.Placement.right)) {
private static final long serialVersionUID = -7867802555691605021L;
@Override
protected String createRelAttribute() {
return "intAttrNameInfo";
}
});
mappingContainer.add(intAttrNameInfo);
mandatoryHeader = new WebMarkupContainer("mandatoryHeader");
mandatoryHeader.setOutputMarkupId(true);
mandatoryHeader.add(Constants.getJEXLPopover(this, TooltipConfig.Placement.bottom));
mappingContainer.add(mandatoryHeader);
model.getObject().sort(ITEM_COMPARATOR);
mappings = new ListView<>("mappings", model) {
private static final long serialVersionUID = 4949588177564901031L;
@Override
protected void populateItem(final ListItem<Item> item) {
final Item itemTO = item.getModelObject();
if (itemTO.getPurpose() == null) {
itemTO.setPurpose(defaultPurpose);
}
//--------------------------------
// Internal attribute
// -------------------------------
AjaxTextFieldPanel intAttrName = new AjaxTextFieldPanel(
"intAttrName",
"intAttrName",
new PropertyModel<>(itemTO, "intAttrName"),
false);
intAttrName.setChoices(List.of());
intAttrName.setRequired(true).hideLabel();
item.add(intAttrName);
// -------------------------------
//--------------------------------
// External attribute
// -------------------------------
AjaxTextFieldPanel extAttrName = new AjaxTextFieldPanel(
"extAttrName",
"extAttrName",
new PropertyModel<>(itemTO, "extAttrName"));
extAttrName.setChoices(getExtAttrNames().getObject());
boolean required = !itemTO.isPassword();
extAttrName.setRequired(required).hideLabel();
extAttrName.setEnabled(required);
item.add(extAttrName);
// -------------------------------
//--------------------------------
// JEXL transformers
// -------------------------------
if (jexlTransformers == null) {
item.add(new Label("jexlTransformers").setVisible(false));
} else {
item.add(new JEXLTransformerWidget(
"jexlTransformers", itemTO, jexlTransformers).setRenderBodyOnly(true));
}
// -------------------------------
//--------------------------------
// Mapping item transformers
// -------------------------------
if (itemTransformers == null) {
item.add(new Label("itemTransformers").setVisible(false));
} else {
item.add(new ItemTransformerWidget(
"itemTransformers", itemTO, itemTransformers).setRenderBodyOnly(true));
}
// -------------------------------
//--------------------------------
// Mandatory
// -------------------------------
AjaxTextFieldPanel mandatory = new AjaxTextFieldPanel(
"mandatoryCondition",
"mandatoryCondition",
new PropertyModel<>(itemTO, "mandatoryCondition"));
mandatory.hideLabel();
mandatory.setChoices(List.of("true", "false"));
mandatory.setEnabled(!itemTO.isConnObjectKey());
item.add(mandatory);
// -------------------------------
//--------------------------------
// Connector object key
// -------------------------------
AjaxCheckBoxPanel connObjectKey = new AjaxCheckBoxPanel(
"connObjectKey",
"connObjectKey",
new PropertyModel<>(itemTO, "connObjectKey"), false);
connObjectKey.hideLabel();
item.add(connObjectKey);
// -------------------------------
//--------------------------------
// Password
// -------------------------------
AjaxCheckBoxPanel password = new AjaxCheckBoxPanel(
"password",
"password",
new PropertyModel<>(itemTO, "password"), false);
item.add(password.hideLabel());
// -------------------------------
//--------------------------------
// Purpose
// -------------------------------
WebMarkupContainer purpose = new WebMarkupContainer("purpose");
purpose.setOutputMarkupId(true);
MappingPurposePanel purposeActions = new MappingPurposePanel(
"purposeActions", new PropertyModel<>(itemTO, "purpose"), purpose);
purpose.add(purposeActions.setRenderBodyOnly(true));
item.add(purpose);
// -------------------------------
//--------------------------------
// Remove
// -------------------------------
ActionsPanel<Serializable> actions = new ActionsPanel<>("toRemove", null);
actions.add(new ActionLink<>() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
model.getObject().remove(item.getIndex());
item.getParent().removeAll();
target.add(AbstractMappingPanel.this);
}
}, ActionLink.ActionType.DELETE, StringUtils.EMPTY, true).hideLabel();
item.add(actions);
// -------------------------------
intAttrName.getField().add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
private static final long serialVersionUID = -1107858522700306810L;
@Override
protected void onUpdate(final AjaxRequestTarget target) {
}
});
connObjectKey.getField().add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
private static final long serialVersionUID = -1107858522700306810L;
@Override
protected void onUpdate(final AjaxRequestTarget target) {
if (connObjectKey.getModelObject()) {
itemTO.setMandatoryCondition("true");
mandatory.setModelObject("true");
mandatory.setEnabled(false);
} else {
itemTO.setMandatoryCondition("false");
mandatory.setModelObject("false");
mandatory.setEnabled(true);
}
target.add(mandatory);
}
});
password.getField().add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
private static final long serialVersionUID = -1107858522700306810L;
@Override
protected void onUpdate(final AjaxRequestTarget target) {
extAttrName.setEnabled(!password.getModelObject());
extAttrName.setModelObject(password.getModelObject()
? ConnIdSpecialName.PASSWORD : extAttrName.getModelObject());
extAttrName.setRequired(!password.getModelObject());
target.add(extAttrName);
setConnObjectKey(connObjectKey, password);
target.add(connObjectKey);
}
});
setConnObjectKey(connObjectKey, password);
setAttrNames(intAttrName);
if (hidePassword()) {
password.setVisible(false);
// Changes required by clone ....
extAttrName.setEnabled(true);
if (itemTO.isPassword()) {
// re-enable if and only if cloned object mapping item was a password
intAttrName.setEnabled(true);
}
itemTO.setPassword(false);
}
purpose.setVisible(!hidePurpose());
mandatory.setVisible(!hideMandatory());
connObjectKey.setVisible(!hideConnObjectKey());
}
};
mappings.setReuseItems(true);
mappingContainer.add(mappings);
addMappingBtn = new IndicatingAjaxButton("addMappingBtn") {
private static final long serialVersionUID = -4804368561204623354L;
@Override
protected void onSubmit(final AjaxRequestTarget target) {
model.getObject().add(new Item());
target.add(AbstractMappingPanel.this);
}
};
addMappingBtn.setDefaultFormProcessing(false);
addMappingBtn.setEnabled(addMappingBtnVisible);
mappingContainer.add(addMappingBtn);
}