Search in sources :

Example 1 with DashboardException

use of io.jmix.dashboardsui.DashboardException in project jmix by jmix-framework.

the class PersistentDashboardEdit method uploadJson.

protected void uploadJson() {
    try (InputStream fileContent = importJsonField.getFileContent()) {
        String json = IOUtils.toString(Objects.requireNonNull(fileContent), UTF_8);
        DashboardModel newDashboardModel = metadata.create(DashboardModel.class);
        BeanUtils.copyProperties(converter.dashboardFromJson(json), newDashboardModel);
        dashboardDc.setItem(newDashboardModel);
        initParametersFragment();
        initPaletteFragment();
        canvasFragment.updateLayout(newDashboardModel);
    } catch (Exception e) {
        throw new DashboardException("Cannot import data from a file", e);
    }
}
Also used : InputStream(java.io.InputStream) DashboardModel(io.jmix.dashboards.model.DashboardModel) DashboardException(io.jmix.dashboardsui.DashboardException) DashboardException(io.jmix.dashboardsui.DashboardException)

Aggregations

DashboardModel (io.jmix.dashboards.model.DashboardModel)1 DashboardException (io.jmix.dashboardsui.DashboardException)1 InputStream (java.io.InputStream)1