use of org.apache.syncope.client.console.widgets.reconciliation.ReconciliationReport in project syncope by apache.
the class ReconciliationWidget method parseReconciliationReportExec.
private Pair<List<ProgressBean>, ReconciliationReport> parseReconciliationReportExec() throws IOException {
List<ProgressBean> beans = Collections.emptyList();
ReconciliationReport report = null;
Optional<ExecTO> exec = Optional.empty();
if (SyncopeConsoleSession.get().owns(StandardEntitlement.REPORT_LIST)) {
exec = restClient.listRecentExecutions(ROWS).stream().filter(e -> reconciliationReportKey.equals(e.getRefKey())).findAny();
}
if (!exec.isPresent()) {
LOG.error("Could not find the last execution of reconciliation report");
} else {
Object entity = restClient.exportExecutionResult(exec.get().getKey(), ReportExecExportFormat.XML).getEntity();
if (entity instanceof InputStream) {
try {
report = ReconciliationReportParser.parse(exec.get().getEnd(), (InputStream) entity);
beans = new ArrayList<>();
ProgressBean progressBean = new ProgressBean();
progressBean.setText(getString("users"));
progressBean.setTotal(report.getUsers().getTotal());
progressBean.setFraction(report.getUsers().getTotal() - report.getUsers().getAnys().size());
progressBean.setCssClass("progress-bar-yellow");
beans.add(progressBean);
progressBean = new ProgressBean();
progressBean.setText(getString("groups"));
progressBean.setTotal(report.getGroups().getTotal());
progressBean.setFraction(report.getGroups().getTotal() - report.getGroups().getAnys().size());
progressBean.setCssClass("progress-bar-red");
beans.add(progressBean);
int i = 0;
for (Anys anys : report.getAnyObjects()) {
progressBean = new ProgressBean();
progressBean.setText(anys.getAnyType());
progressBean.setTotal(anys.getTotal());
progressBean.setFraction(anys.getTotal() - anys.getAnys().size());
progressBean.setCssClass("progress-bar-" + (i % 2 == 0 ? "green" : "aqua"));
beans.add(progressBean);
i++;
}
} catch (Exception e) {
LOG.error("Could not parse the last execution available of reconciliation report", e);
}
}
}
return Pair.of(beans, report == null ? new ReconciliationReport(new Date()) : report);
}
use of org.apache.syncope.client.console.widgets.reconciliation.ReconciliationReport in project syncope by apache.
the class ReconciliationWidget method buildExecFragment.
private Fragment buildExecFragment() {
Fragment execFragment = new Fragment("reportResult", "execFragment", this);
execFragment.setOutputMarkupId(true);
Pair<List<ProgressBean>, ReconciliationReport> execResult;
try {
execResult = parseReconciliationReportExec();
} catch (Exception e) {
LOG.error("Could not parse the reconciliation report result", e);
execResult = Pair.of(Collections.<ProgressBean>emptyList(), new ReconciliationReport(new Date()));
}
final List<ProgressBean> progressBeans = execResult.getLeft();
final ReconciliationReport report = execResult.getRight();
List<ITab> tabs = new ArrayList<>();
tabs.add(new AbstractTab(new ResourceModel("summary")) {
private static final long serialVersionUID = -6815067322125799251L;
@Override
public Panel getPanel(final String panelId) {
return new ProgressesPanel(panelId, report.getRun(), progressBeans);
}
});
tabs.add(new AbstractTab(Model.of(AnyTypeKind.USER.name())) {
private static final long serialVersionUID = -6815067322125799251L;
@Override
public Panel getPanel(final String panelId) {
return new AnysReconciliationPanel(panelId, report.getUsers(), pageRef);
}
});
tabs.add(new AbstractTab(Model.of(AnyTypeKind.GROUP.name())) {
private static final long serialVersionUID = -6815067322125799251L;
@Override
public Panel getPanel(final String panelId) {
return new AnysReconciliationPanel(panelId, report.getGroups(), pageRef);
}
});
for (final Anys anys : report.getAnyObjects()) {
tabs.add(new AbstractTab(Model.of(anys.getAnyType())) {
private static final long serialVersionUID = -6815067322125799251L;
@Override
public Panel getPanel(final String panelId) {
return new AnysReconciliationPanel(panelId, anys, pageRef);
}
});
}
execFragment.add(new AjaxBootstrapTabbedPanel<>("execResult", tabs));
return execFragment;
}
Aggregations