in client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/any/ConnObjectPanel.java [53:135]
public ConnObjectPanel(
final String id,
final Pair<IModel<?>, IModel<?>> titles,
final Pair<ConnObject, ConnObject> connObjectTOs,
final boolean hideLeft) {
super(id);
final IModel<List<String>> formProps = new LoadableDetachableModel<>() {
private static final long serialVersionUID = 5275935387613157437L;
@Override
protected List<String> load() {
List<Attr> right = new ArrayList<>(connObjectTOs == null || connObjectTOs.getRight() == null
? List.of()
: connObjectTOs.getRight().getAttrs());
List<Attr> left = new ArrayList<>(connObjectTOs == null || connObjectTOs.getLeft() == null
? List.of()
: connObjectTOs.getLeft().getAttrs());
List<String> schemas = ListUtils.sum(right.stream().map(Attr::getSchema).collect(Collectors.toList()),
left.stream().map(Attr::getSchema).collect(Collectors.toList()));
Collections.sort(schemas);
return schemas;
}
};
add(new Label("leftTitle", titles.getLeft()).setOutputMarkupPlaceholderTag(true).setVisible(!hideLeft));
add(new Label("rightTitle", titles.getRight()));
final Map<String, Attr> leftProfile = connObjectTOs == null || connObjectTOs.getLeft() == null
? null
: EntityTOUtils.buildAttrMap(connObjectTOs.getLeft().getAttrs());
final Map<String, Attr> rightProfile = connObjectTOs == null || connObjectTOs.getRight() == null
? null
: EntityTOUtils.buildAttrMap(connObjectTOs.getRight().getAttrs());
ListView<String> propView = new ListView<>("propView", formProps) {
private static final long serialVersionUID = 3109256773218160485L;
@Override
protected void populateItem(final ListItem<String> item) {
final String prop = item.getModelObject();
final Fragment valueFragment;
final Attr left = Optional.ofNullable(leftProfile)
.map(stringAttrMap -> stringAttrMap.get(prop)).orElse(null);
final Attr right = Optional.ofNullable(rightProfile)
.map(profile -> profile.get(prop)).orElse(null);
valueFragment = new Fragment("value", "doubleValue", ConnObjectPanel.this);
valueFragment.add(getValuePanel("leftAttribute", prop, left).
setOutputMarkupPlaceholderTag(true).setVisible(!hideLeft));
valueFragment.add(getValuePanel("rightAttribute", prop, right));
if (left == null || right == null
|| (CollectionUtils.isNotEmpty(right.getValues())
&& CollectionUtils.isEmpty(left.getValues()))
|| (CollectionUtils.isEmpty(right.getValues())
&& CollectionUtils.isNotEmpty(left.getValues()))
|| (CollectionUtils.isNotEmpty(right.getValues())
&& CollectionUtils.isNotEmpty(left.getValues())
&& right.getValues().size() != left.getValues().size())
|| (CollectionUtils.isNotEmpty(right.getValues())
&& CollectionUtils.isNotEmpty(left.getValues())
&& !right.getValues().equals(left.getValues()))) {
valueFragment.add(new Behavior() {
private static final long serialVersionUID = 3109256773218160485L;
@Override
public void onComponentTag(final Component component, final ComponentTag tag) {
tag.put("class", "highlight");
}
});
}
item.add(valueFragment);
}
};
add(propView);
}