Package org.apache.syncope.client.to

Examples of org.apache.syncope.client.to.ReportTO


        assertEquals(actual, report);
    }

    @Test
    public void update() {
        ReportTO report = new ReportTO();
        report.setName("testReportForUpdate");
        report.addReportletConf(new UserReportletConf("first"));
        report.addReportletConf(new UserReportletConf("second"));

        report = restTemplate.postForObject(BASE_URL + "report/create", report, ReportTO.class);
        assertNotNull(report);
        assertEquals(2, report.getReportletConfs().size());

        report.addReportletConf(new UserReportletConf("last"));

        ReportTO updated = restTemplate.postForObject(BASE_URL + "report/update", report, ReportTO.class);
        assertNotNull(updated);
        assertEquals(3, updated.getReportletConfs().size());
    }
View Full Code Here


        assertEquals(3, updated.getReportletConfs().size());
    }

    @Test
    public void delete() {
        ReportTO report = new ReportTO();
        report.setName("testReportForDelete");
        report.addReportletConf(new UserReportletConf("first"));
        report.addReportletConf(new UserReportletConf("second"));

        report = restTemplate.postForObject(BASE_URL + "report/create", report, ReportTO.class);
        assertNotNull(report);

        ReportTO deletedReport =
                restTemplate.getForObject(BASE_URL + "report/delete/{reportId}", ReportTO.class, report.getId());
        assertNotNull(deletedReport);

        try {
            restTemplate.getForObject(BASE_URL + "report/read/{reportId}", UserTO.class, report.getId());
View Full Code Here

    }

    @Test
    public void executeAndExport() throws IOException {

        ReportTO reportTO = restTemplate.getForObject(BASE_URL + "report/read/{reportId}", ReportTO.class, 1);
        assertNotNull(reportTO);

        Set<Long> preExecIds = new HashSet<Long>();
        for (ReportExecTO exec : reportTO.getExecutions()) {
            preExecIds.add(exec.getId());
        }

        ReportExecTO execution = restTemplate.postForObject(BASE_URL + "report/execute/{reportId}", null,
                ReportExecTO.class, reportTO.getId());
        assertNotNull(execution);

        int i = 0;
        int maxit = 50;

        do {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
            }

            reportTO = restTemplate.getForObject(BASE_URL + "report/read/{reportId}", ReportTO.class, 1);

            i++;
        } while (preExecIds.size() == reportTO.getExecutions().size() && i < maxit);

        Set<Long> postExecIds = new HashSet<Long>();
        for (ReportExecTO exec : reportTO.getExecutions()) {
            postExecIds.add(exec.getId());
        }

        postExecIds.removeAll(preExecIds);
        assertEquals(1, postExecIds.size());
View Full Code Here

        assertNotNull(export);
        assertFalse(export.isEmpty());
    }

    public void issueSYNCOPE43() {
        ReportTO reportTO = new ReportTO();
        reportTO.setName("issueSYNCOPE43");
        reportTO = restTemplate.postForObject(BASE_URL + "report/create", reportTO, ReportTO.class);
        assertNotNull(reportTO);

        ReportExecTO execution = restTemplate.postForObject(BASE_URL + "report/execute/{reportId}", null,
                ReportExecTO.class, reportTO.getId());
        assertNotNull(execution);

        int i = 0;
        int maxit = 50;

        do {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
            }

            reportTO = restTemplate.getForObject(BASE_URL + "report/read/{reportId}", ReportTO.class, 1);

            i++;
        } while (reportTO.getExecutions().size() == 0 && i < maxit);

        assertEquals(1, reportTO.getExecutions().size());
    }
View Full Code Here

    }

    @Test
    public void testReportletConfImplementations() throws IOException {

        ReportTO report = new ReportTO();
        report.setName("testReportForCreate");
        report.addReportletConf(new UserReportletConf("first"));
        report.addReportletConf(new UserReportletConf("second"));

        ObjectMapper mapper = new ObjectMapper();

        StringWriter writer = new StringWriter();
        mapper.writeValue(writer, report);

        ReportTO actual = mapper.readValue(writer.toString(), ReportTO.class);
        assertEquals(report, actual);
    }
View Full Code Here

            private static final long serialVersionUID = -958724007591692537L;

            @Override
            protected void onSubmit(final AjaxRequestTarget target, final Form form) {
                ReportTO reportTO = (ReportTO) form.getModelObject();
                reportTO.setCronExpression(StringUtils.hasText(reportTO.getCronExpression())
                        ? crontab.getCronExpression()
                        : null);

                try {
                    if (reportTO.getId() > 0) {
                        restClient.update(reportTO);
                    } else {
                        restClient.create(reportTO);
                    }

                    ((BasePage) callerPageRef.getPage()).setModalResult(true);

                    window.close(target);
                } catch (SyncopeClientCompositeErrorException e) {
                    LOG.error("While creating or updating report", e);
                    error(getString("error") + ":" + e.getMessage());
                    target.add(feedbackPanel);
                }
            }

            @Override
            protected void onError(final AjaxRequestTarget target, final Form form) {
                target.add(feedbackPanel);
            }
        };

        if (reportTO.getId() > 0) {
            MetaDataRoleAuthorizationStrategy.authorize(submit, RENDER, xmlRolesReader.getAllAllowedRoles("Reports",
                    "update"));
        } else {
            MetaDataRoleAuthorizationStrategy.authorize(submit, RENDER, xmlRolesReader.getAllAllowedRoles("Reports",
                    "create"));
View Full Code Here

            @Override
            public void populateItem(final Item<ICellPopulator<ReportTO>> cellItem, final String componentId,
                    final IModel<ReportTO> model) {

                final ReportTO reportTO = model.getObject();

                final ActionLinksPanel panel = new ActionLinksPanel(componentId, model);

                panel.add(new ActionLink() {

                    private static final long serialVersionUID = -3722207913631435501L;

                    @Override
                    public void onClick(final AjaxRequestTarget target) {

                        window.setPageCreator(new ModalWindow.PageCreator() {

                            private static final long serialVersionUID = -7834632442532690940L;

                            @Override
                            public Page createPage() {
                                return new ReportModalPage(window, reportTO, Reports.this.getPageReference());
                            }
                        });

                        window.show(target);
                    }
                }, ActionLink.ActionType.EDIT, "Reports", "read");

                panel.add(new ActionLink() {

                    private static final long serialVersionUID = -3722207913631435501L;

                    @Override
                    public void onClick(final AjaxRequestTarget target) {
                        try {
                            reportRestClient.startExecution(reportTO.getId());
                            getSession().info(getString("operation_succeded"));
                        } catch (SyncopeClientCompositeErrorException scce) {
                            error(scce.getMessage());
                        }

                        target.add(getPage().get("feedback"));
                        target.add(reportContainer);
                    }
                }, ActionLink.ActionType.EXECUTE, "Reports", "execute");

                panel.add(new ActionLink() {

                    private static final long serialVersionUID = -3722207913631435501L;

                    @Override
                    public void onClick(final AjaxRequestTarget target) {
                        try {
                            reportRestClient.delete(reportTO.getId());
                            info(getString("operation_succeded"));
                        } catch (SyncopeClientCompositeErrorException scce) {
                            error(scce.getMessage());
                        }
                        target.add(reportContainer);
                        target.add(getPage().get("feedback"));
                    }
                }, ActionLink.ActionType.DELETE, "Reports", "delete");

                cellItem.add(panel);
            }
        });

        final AjaxFallbackDefaultDataTable reportTable = new AjaxFallbackDefaultDataTable("reportTable", columns,
                new ReportProvider(), paginatorRows);

        reportContainer.add(reportTable);
        reportContainer.setOutputMarkupId(true);

        add(reportContainer);

        Form paginatorForm = new Form("paginatorForm");

        MetaDataRoleAuthorizationStrategy.authorize(paginatorForm, RENDER, xmlRolesReader.getAllAllowedRoles("Reports",
                "list"));

        final DropDownChoice rowsChooser = new DropDownChoice("rowsChooser", new PropertyModel(this, "paginatorRows"),
                prefMan.getPaginatorChoices());

        rowsChooser.add(new AjaxFormComponentUpdatingBehavior("onchange") {

            private static final long serialVersionUID = -1107858522700306810L;

            @Override
            protected void onUpdate(final AjaxRequestTarget target) {
                prefMan.set(getRequest(), getResponse(), Constants.PREF_REPORT_PAGINATOR_ROWS,
                        String.valueOf(paginatorRows));
                reportTable.setItemsPerPage(paginatorRows);

                target.add(reportContainer);
            }
        });

        paginatorForm.add(rowsChooser);
        add(paginatorForm);

        AjaxLink createLink = new IndicatingAjaxLink("createLink") {

            private static final long serialVersionUID = -7978723352517770644L;

            @Override
            public void onClick(final AjaxRequestTarget target) {
                window.setPageCreator(new ModalWindow.PageCreator() {

                    private static final long serialVersionUID = -7834632442532690940L;

                    @Override
                    public Page createPage() {
                        return new ReportModalPage(window, new ReportTO(), Reports.this.getPageReference());
                    }
                });

                window.show(target);
            }
View Full Code Here

TOP

Related Classes of org.apache.syncope.client.to.ReportTO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.