Example usage for org.apache.wicket.util.string StringValue toOptionalLong

List of usage examples for org.apache.wicket.util.string StringValue toOptionalLong

Introduction

In this page you can find the example usage for org.apache.wicket.util.string StringValue toOptionalLong.

Prototype

public final Long toOptionalLong() throws StringValueConversionException 

Source Link

Document

Convert to object types, returning null if text is null or empty.

Usage

From source file:eu.uqasar.web.dashboard.DashboardEditPage.java

License:Apache License

/**
 * /*w  ww  .  ja  v  a 2  s.  co m*/
 * @param idParam
 */
private void loadDashboard(final StringValue idParam) {
    // Create a new dashboard, if no ID is provided 
    if (idParam.isEmpty()) {
        setPageTitle(new StringResourceModel("page.create.title", this, null));
        add(new Label("header", new StringResourceModel("form.create.header", this, null)));
        String id = String.valueOf(new Date().getTime());
        String title = "Dashboard-" + UQasar.getSession().getLoggedInUser().getUserName() + "-" + id;
        dashboard = new DbDashboard(id, title);
    } else {
        setPageTitle(new StringResourceModel("page.edit.title", this, null));
        add(new Label("header", new StringResourceModel("form.edit.header", this, null)));
        // set the item we got from previous page
        try {
            dashboard = dashboardService.getById(idParam.toOptionalLong());
        } catch (Exception e) {
            throw new RestartResponseException(AboutPage.class);
        }
    }
}

From source file:eu.uqasar.web.dashboard.DashboardSharePage.java

License:Apache License

/**
 * Attempt to load the dashboard by its ID
 * @param idParam/*from www. ja  v a  2 s  .  c  o m*/
 */
private void loadDashboard(final StringValue idParam) {
    if (!idParam.isEmpty()) {
        try {
            dashboard = dashboardService.getById(idParam.toOptionalLong());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:eu.uqasar.web.pages.adapterdata.AdapterAddEditPage.java

License:Apache License

/**
 * /* ww  w .  j ava  2 s  .c om*/
 * @param idParam
 */
private void loadAdapter(final StringValue idParam) {
    if (idParam.isEmpty()) {
        setPageTitle(new StringResourceModel("page.create.title", this, null));
        add(new Label("header", new StringResourceModel("form.create.header", this, null)));
        adapterSettings = new AdapterSettings();
    } else {

        adapterSettings = adapterSettingsService.getById(idParam.toOptionalLong());
        if (adapterSettings == null) {
            throw new EntityNotFoundException(AdapterSettings.class, idParam.toOptionalString());
        }

        setPageTitle(new StringResourceModel("page.edit.title", this, null));
        add(new Label("header", new StringResourceModel("form.edit.header", this, null)));
    }
}

From source file:eu.uqasar.web.pages.adapterdata.CubeAnalysisDataManagementEditPage.java

License:Apache License

/**
 * /*from   w w  w  .  j  a  v a2s.  c  o m*/
 * @param idParam
 */
private void loadTableEntity(final StringValue idParam) {
    if (idParam.isEmpty()) {
        setPageTitle(new StringResourceModel("page.create.title", this, null));
        add(new Label("header", new StringResourceModel("form.create.header", this, null)));
        tableEntity = new CubesMetricMeasurement();

    } else {
        setPageTitle(new StringResourceModel("page.edit.title", this, null));
        add(new Label("header", new StringResourceModel("form.edit.header", this, null)));
        // set the tableEntity we got from previous page
        try {
            tableEntity = cubesService.getById(idParam.toOptionalLong());

        } catch (Exception e) {
            throw new RestartResponseException(AboutPage.class);
        }
    }
}

From source file:eu.uqasar.web.pages.adapterdata.IssueTrackerDataManagementEditPage.java

License:Apache License

/**
 * /*from   w  w w .  j  a v  a2s.c  o m*/
 * @param idParam
 */
private void loadTableEntity(final StringValue idParam) {
    if (idParam.isEmpty()) {
        setPageTitle(new StringResourceModel("page.create.title", this, null));
        add(new Label("header", new StringResourceModel("form.create.header", this, null)));
        tableEntity = new JiraMetricMeasurement();

    } else {
        setPageTitle(new StringResourceModel("page.edit.title", this, null));
        add(new Label("header", new StringResourceModel("form.edit.header", this, null)));
        // set the tableEntity we got from previous page
        try {
            tableEntity = jiraService.getById(idParam.toOptionalLong());

        } catch (Exception e) {
            throw new RestartResponseException(AboutPage.class);
        }
    }
}

From source file:eu.uqasar.web.pages.adapterdata.JenkinsDataManagementEditPage.java

License:Apache License

/**
 * //from w  ww . j  a va2 s.co  m
 * @param idParam
 */
private void loadTableEntity(final StringValue idParam) {
    if (idParam.isEmpty()) {
        setPageTitle(new StringResourceModel("page.create.title", this, null));
        add(new Label("header", new StringResourceModel("form.create.header", this, null)));
        tableEntity = new JenkinsMetricMeasurement();

    } else {
        setPageTitle(new StringResourceModel("page.edit.title", this, null));
        add(new Label("header", new StringResourceModel("form.edit.header", this, null)));
        // set the tableEntity we got from previous page
        try {
            tableEntity = jenkinsService.getById(idParam.toOptionalLong());

        } catch (Exception e) {
            throw new RestartResponseException(AboutPage.class);
        }
    }
}

From source file:eu.uqasar.web.pages.adapterdata.StaticAnalysisDataManagementEditPage.java

License:Apache License

/**
 * /*from   ww w . j a va  2s  .  co  m*/
 * @param idParam
 */
private void loadTableEntity(final StringValue idParam) {
    if (idParam.isEmpty()) {
        setPageTitle(new StringResourceModel("page.create.title", this, null));
        add(new Label("header", new StringResourceModel("form.create.header", this, null)));
        tableEntity = new SonarMetricMeasurement();

    } else {
        setPageTitle(new StringResourceModel("page.edit.title", this, null));
        add(new Label("header", new StringResourceModel("form.edit.header", this, null)));
        // set the tableEntity we got from previous page
        try {
            tableEntity = sonarService.getById(idParam.toOptionalLong());

        } catch (Exception e) {
            throw new RestartResponseException(AboutPage.class);
        }
    }
}

From source file:eu.uqasar.web.pages.adapterdata.TestFrameworkDataManagementEditPage.java

License:Apache License

/**
 * //  www.  j a v a  2s.c  om
 * @param idParam
 */
private void loadTableEntity(final StringValue idParam) {
    if (idParam.isEmpty()) {
        setPageTitle(new StringResourceModel("page.create.title", this, null));
        add(new Label("header", new StringResourceModel("form.create.header", this, null)));
        tableEntity = new TestLinkMetricMeasurement();

    } else {
        setPageTitle(new StringResourceModel("page.edit.title", this, null));
        add(new Label("header", new StringResourceModel("form.edit.header", this, null)));
        // set the tableEntity we got from previous page
        try {
            tableEntity = testLinkService.getById(idParam.toOptionalLong());

        } catch (Exception e) {
            throw new RestartResponseException(AboutPage.class);
        }
    }
}

From source file:eu.uqasar.web.pages.admin.settings.platform.PlatformSettingsAddEditPage.java

License:Apache License

/**
 * //from  www. j  ava 2s .  com
 * @param idParam
 */
private void loadSettings(final StringValue idParam) {
    if (idParam.isEmpty()) {
        setPageTitle(new StringResourceModel("page.create.title", this, null));
        add(new Label("header", new StringResourceModel("form.create.header", this, null)));
        platformSettings = new PlatformSettings();
    } else {
        platformSettings = platformSettingsService.getById(idParam.toOptionalLong());
        if (platformSettings == null) {
            throw new EntityNotFoundException(PlatformSettings.class, idParam.toOptionalString());
        }

        setPageTitle(new StringResourceModel("page.edit.title", this, null));
        add(new Label("header", new StringResourceModel("form.edit.header", this, null)));
    }
}

From source file:eu.uqasar.web.pages.analytic.drilldown.AnalysisDrilldown.java

License:Apache License

public AnalysisDrilldown(PageParameters parameters) {
    super(parameters);

    //TODO: add support for new Analysis
    StringValue id = parameters.get("analysis-id");
    analysis = analyticService.getById(id.toOptionalLong());

    // Prepares the String for the REST Query
    prepareQuery();//w  w w.  ja v a 2 s. co m

    // The query is single sent to Cubes Server and JSON is stored into String to be parsed
    cubesJSON = getJSON(query);

    // Add the title of the headers
    headerLabel = getHeaders();

    // Add the data to be shown in the table
    dataResults = getDataFromDimension(cubesJSON);

    // Analysis name
    add(new Label("name", new PropertyModel<String>(analysis, "name")));

    // Analysis description
    add(new Label("description", new PropertyModel<String>(analysis, "description")));

    // Add a link to JSON in order to test the Query
    add(linkToJSON());

    // Add the form to add/remove drilldown elements
    form = new Form<>("form");

    // Add the dimension selector 
    form.add(new Select2MultiChoice<>("dimensionSelector",
            new PropertyModel<Collection<Dimensions>>(analysis, "dimensions"), new DimensionProvider()));

    // Add the button to Submit the form with the Dimension changes
    Button saveButton = new Button("save", new StringResourceModel("button.save", this, null));

    saveButton.add(new AjaxFormSubmitBehavior(form, "onclick") {
        private static final long serialVersionUID = 4973315405621990914L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            super.onEvent(target);
            setResponsePage(AnalysisDrilldown.class, BaseTreePage.forAnalysis(analysis));
        }

    });
    form.add(saveButton);

    add(form);

    // // TableOfResults, add header for the table
    RepeatingView headers = new RepeatingView("headers");
    for (String label : headerLabel) {
        headers.add(new Label(headers.newChildId(), label));
    }
    add(headers);

    // TableOfResults, add the part of the table that show data
    add(new ListView<String>("contentlist", dataResults) {
        private static final long serialVersionUID = -9149319929661254397L;

        @Override
        protected void populateItem(ListItem<String> colData) {
            final String string = colData.getModelObject();
            RepeatingView repeatingView = new RepeatingView("data");

            for (String label : headerLabel) {
                try {
                    JSONObject json = new JSONObject(string);
                    repeatingView.add(new Label(repeatingView.newChildId(), json.getString(label)));
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
            colData.add(repeatingView);
        }
    });

}