in client/idm/console/src/main/java/org/apache/syncope/client/console/panels/ConnObjectListViewPanel.java [110:287]
protected ConnObjectListViewPanel(
final String id,
final ResourceTO resource,
final String anyType,
final PageReference pageRef) {
super(id);
this.anyType = anyType;
this.resource = resource;
this.pageRef = pageRef;
final Model<Integer> model = Model.of(-1);
final StringResourceModel res = new StringResourceModel("search.result", this, new Model<>(anyType));
final Accordion accordion = new Accordion("accordionPanel", List.of(new AbstractTab(res) {
private static final long serialVersionUID = 1037272333056449377L;
@Override
public WebMarkupContainer getPanel(final String panelId) {
searchPanel = getSearchPanel(panelId, anyType);
return searchPanel;
}
}), model) {
private static final long serialVersionUID = 6581261306163L;
@Override
protected Component newTitle(final String markupId, final ITab tab, final Accordion.State state) {
return new AjaxLink<Integer>(markupId) {
private static final long serialVersionUID = 6584438659172L;
@Override
protected void onComponentTag(final ComponentTag tag) {
super.onComponentTag(tag);
tag.put("style", "color: #337ab7");
}
@Override
public void onClick(final AjaxRequestTarget target) {
model.setObject(model.getObject() == 0 ? -1 : 0);
}
}.setBody(res);
}
};
accordion.setOutputMarkupId(true);
add(accordion.setEnabled(true).setVisible(true));
List<ConnObject> listOfItems = reloadItems(resource.getKey(), anyType, null, null);
ListViewPanel.Builder<ConnObject> builder = new ListViewPanel.Builder<>(
ConnObject.class, pageRef) {
private static final long serialVersionUID = -8251750413385566738L;
@Override
protected Component getValueComponent(final String key, final ConnObject bean) {
if (StringUtils.equals(key, STATUS)) {
ReconStatus status;
try {
status = reconciliationRestClient.status(
new ReconQuery.Builder(anyType, resource.getKey()).fiql(bean.getFiql()).build());
} catch (Exception e) {
LOG.error("While requesting for reconciliation status of {} {} with FIQL '{}'",
anyType, resource.getKey(), bean.getFiql(), e);
status = new ReconStatus();
}
return status.getOnSyncope() == null
? StatusUtils.getLabel("field", "notfound icon", "Not found", Constants.NOT_FOUND_ICON)
: new Label("field", Model.of()).add(new PopoverBehavior(
Model.of(),
Model.of(status.getAnyKey()),
new PopoverConfig().
withTitle(status.getMatchType() == MatchType.LINKED_ACCOUNT
? MatchType.LINKED_ACCOUNT.name() + ", " + AnyTypeKind.USER
: status.getAnyTypeKind().name()).
withPlacement(TooltipConfig.Placement.left)) {
private static final long serialVersionUID = -7867802555691605021L;
@Override
protected String createRelAttribute() {
return "field";
}
@Override
public void onComponentTag(final Component component, final ComponentTag tag) {
super.onComponentTag(component, tag);
tag.put("class", Constants.ACTIVE_ICON);
}
});
} else {
Optional<Attr> attr = bean.getAttrs().stream().
filter(object -> object.getSchema().equals(key)).findAny();
return attr.filter(a -> !a.getValues().isEmpty()).
map(a -> (Component) new CollectionPanel("field", a.getValues())).
orElseGet(() -> new Label("field", StringUtils.EMPTY));
}
}
};
builder.setReuseItem(false);
builder.addAction(new ActionLink<>() {
private static final long serialVersionUID = 7511002881490248598L;
@Override
public void onClick(final AjaxRequestTarget target, final ConnObject modelObject) {
viewConnObject(modelObject, target);
}
}, ActionLink.ActionType.VIEW, IdMEntitlement.RESOURCE_GET_CONNOBJECT).
setItems(listOfItems).
includes(ConnIdSpecialName.UID,
ConnIdSpecialName.NAME,
ConnIdSpecialName.ENABLE).
withChecks(ListViewPanel.CheckAvailability.NONE).
setReuseItem(false);
if (!StringUtils.equals(anyType, SyncopeConstants.REALM_ANYTYPE)) {
builder.addAction(new ActionLink<>() {
private static final long serialVersionUID = 6377238742125L;
@Override
public void onClick(final AjaxRequestTarget target, final ConnObject modelObject) {
try {
ReconStatus status = reconciliationRestClient.status(
new ReconQuery.Builder(anyType, resource.getKey()).fiql(modelObject.getFiql()).build());
pullConnObject(
modelObject.getFiql(),
target,
resource.getKey(),
anyType,
status.getRealm(),
StringUtils.isNotBlank(status.getAnyKey()),
pageRef);
} catch (Exception e) {
LOG.error("While puling single object {} {} with FIQL '{}'",
anyType, resource.getKey(), modelObject.getFiql(), e);
SyncopeConsoleSession.get().onException(e);
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}
}, ActionLink.ActionType.RECONCILIATION_PULL, IdRepoEntitlement.TASK_EXECUTE);
builder.includes(STATUS);
}
add(builder.build("objs"));
arrows = new WebMarkupContainer("arrows");
add(arrows.setOutputMarkupId(true));
arrows.add(new AjaxLink<Serializable>("next") {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target) {
List<ConnObject> listOfItems = reloadItems(resource.getKey(), anyType, nextPageCookie, getFiql());
target.add(arrows);
send(ConnObjectListViewPanel.this, Broadcast.DEPTH, new ListViewReload<>(listOfItems, target));
}
@Override
public boolean isVisible() {
return nextPageCookie != null;
}
});
}