Search in sources :

Example 1 with ReconciliationReport

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);
}
Also used : ReconciliationReport(org.apache.syncope.client.console.widgets.reconciliation.ReconciliationReport) ExecTO(org.apache.syncope.common.lib.to.ExecTO) InputStream(java.io.InputStream) Anys(org.apache.syncope.client.console.widgets.reconciliation.Anys) IOException(java.io.IOException) Date(java.util.Date)

Example 2 with ReconciliationReport

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;
}
Also used : ArrayList(java.util.ArrayList) Fragment(org.apache.wicket.markup.html.panel.Fragment) IOException(java.io.IOException) Date(java.util.Date) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) AjaxBootstrapTabbedPanel(de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel) ActionPanel(org.apache.syncope.client.console.wicket.markup.html.form.ActionPanel) DirectoryPanel(org.apache.syncope.client.console.panels.DirectoryPanel) Panel(org.apache.wicket.markup.html.panel.Panel) WizardMgtPanel(org.apache.syncope.client.console.wizards.WizardMgtPanel) ReconciliationReport(org.apache.syncope.client.console.widgets.reconciliation.ReconciliationReport) Anys(org.apache.syncope.client.console.widgets.reconciliation.Anys) AbstractTab(org.apache.wicket.extensions.markup.html.tabs.AbstractTab) ResourceModel(org.apache.wicket.model.ResourceModel) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

IOException (java.io.IOException)2 Date (java.util.Date)2 Anys (org.apache.syncope.client.console.widgets.reconciliation.Anys)2 ReconciliationReport (org.apache.syncope.client.console.widgets.reconciliation.ReconciliationReport)2 AjaxBootstrapTabbedPanel (de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 DirectoryPanel (org.apache.syncope.client.console.panels.DirectoryPanel)1 ActionPanel (org.apache.syncope.client.console.wicket.markup.html.form.ActionPanel)1 WizardMgtPanel (org.apache.syncope.client.console.wizards.WizardMgtPanel)1 ExecTO (org.apache.syncope.common.lib.to.ExecTO)1 AbstractTab (org.apache.wicket.extensions.markup.html.tabs.AbstractTab)1 ITab (org.apache.wicket.extensions.markup.html.tabs.ITab)1 Fragment (org.apache.wicket.markup.html.panel.Fragment)1 Panel (org.apache.wicket.markup.html.panel.Panel)1 ResourceModel (org.apache.wicket.model.ResourceModel)1