Search in sources :

Example 1 with EJFormParameter

use of org.entirej.framework.core.data.controllers.EJFormParameter in project rap by entirej.

the class EJRWTApplicationManager method generateReport.

public String generateReport(String reportName, EJParameterList parameterList) {
    if (reportManager == null) {
        reportManager = EJReportFrameworkInitialiser.initialiseFramework("report.ejprop");
    }
    EJReport report;
    if (parameterList == null) {
        report = reportManager.createReport(reportName);
    } else {
        EJReportParameterList list = new EJReportParameterList();
        Collection<EJFormParameter> allParameters = parameterList.getAllParameters();
        for (EJFormParameter parameter : allParameters) {
            EJReportParameter reportParameter = new EJReportParameter(parameter.getName(), parameter.getDataType());
            reportParameter.setValue(parameter.getValue());
            list.addParameter(reportParameter);
        }
        report = reportManager.createReport(reportName, list);
    }
    EJReportRunner reportRunner = reportManager.createReportRunner();
    String output = reportRunner.runReport(report);
    return output;
}
Also used : EJReportParameter(org.entirej.framework.report.data.controllers.EJReportParameter) EJReport(org.entirej.framework.report.EJReport) EJFormParameter(org.entirej.framework.core.data.controllers.EJFormParameter) EJReportParameterList(org.entirej.framework.report.EJReportParameterList) EJReportRunner(org.entirej.framework.report.interfaces.EJReportRunner)

Example 2 with EJFormParameter

use of org.entirej.framework.core.data.controllers.EJFormParameter in project rap by entirej.

the class EJRWTApplicationManager method runReportAsync.

@Override
public void runReportAsync(final String reportName, final EJParameterList parameterList, final EJMessage completedMessage) {
    if (reportManager == null) {
        reportManager = EJReportFrameworkInitialiser.initialiseFramework("report.ejprop");
    }
    final Display display = Display.getDefault();
    final ServerPushSession pushSession = new ServerPushSession();
    Runnable job = new Runnable() {

        @Override
        public void run() {
            try {
                final EJReport report;
                if (parameterList == null) {
                    report = reportManager.createReport(reportName);
                } else {
                    EJReportParameterList list = new EJReportParameterList();
                    Collection<EJFormParameter> allParameters = parameterList.getAllParameters();
                    for (EJFormParameter parameter : allParameters) {
                        EJReportParameter reportParameter = new EJReportParameter(parameter.getName(), parameter.getDataType());
                        reportParameter.setValue(parameter.getValue());
                        list.addParameter(reportParameter);
                    }
                    report = reportManager.createReport(reportName, list);
                }
                EJReportRunner reportRunner = reportManager.createReportRunner();
                final String output = reportRunner.runReport(report);
                if (!display.isDisposed()) {
                    display.asyncExec(new Runnable() {

                        public void run() {
                            String name = report.getName();
                            EJReportParameter reportParameter = null;
                            if (report.hasReportParameter("REPORT_NAME")) {
                                reportParameter = report.getReportParameter("REPORT_NAME");
                            }
                            if (reportParameter != null && reportParameter.getValue() != null && !((String) reportParameter.getValue()).isEmpty()) {
                                name = (String) reportParameter.getValue();
                            } else {
                                if (report.getOutputName() != null && !report.getOutputName().isEmpty()) {
                                    name = report.getOutputName();
                                }
                            }
                            if (completedMessage != null) {
                                handleMessage(completedMessage);
                            }
                            String ext = report.getProperties().getExportType().toString().toLowerCase();
                            report.getProperties().getExportType();
                            if (report.getProperties().getExportType() == EJReportExportType.XLSX_LARGE) {
                                ext = EJReportExportType.XLSX.toString().toLowerCase();
                            }
                            EJRWTImageRetriever.getGraphicsProvider().open(output, String.format("%s.%s", name, ext));
                        }
                    });
                }
            } finally {
                display.asyncExec(new Runnable() {

                    public void run() {
                        pushSession.stop();
                    }
                });
            }
        }
    };
    pushSession.start();
    Thread bgThread = new Thread(job);
    bgThread.setDaemon(true);
    bgThread.start();
}
Also used : EJReportParameter(org.entirej.framework.report.data.controllers.EJReportParameter) EJReport(org.entirej.framework.report.EJReport) EJFormParameter(org.entirej.framework.core.data.controllers.EJFormParameter) EJReportParameterList(org.entirej.framework.report.EJReportParameterList) EJReportRunner(org.entirej.framework.report.interfaces.EJReportRunner) Display(org.eclipse.swt.widgets.Display) ServerPushSession(org.eclipse.rap.rwt.service.ServerPushSession)

Example 3 with EJFormParameter

use of org.entirej.framework.core.data.controllers.EJFormParameter in project rap by entirej.

the class EJRWTComboItemRenderer method connectLOVItems.

private void connectLOVItems() {
    String lovDefName = _rendererProps.getStringProperty(EJRWTComboBoxRendererDefinitionProperties.LOV_DEFINITION_NAME);
    if (lovDefName == null || lovDefName.trim().length() == 0) {
        return;
    }
    String defName = lovDefName;
    EJInternalForm form = _item.getForm();
    if (lovDefName.indexOf('.') != -1) {
        defName = lovDefName.substring(0, lovDefName.indexOf('.'));
    } else {
        EJMessage message = new EJMessage("No LovDefinition item has been chosen for the ComboBox renderer properties on item: " + _itemProperties.getName());
        form.getFrameworkManager().getApplicationManager().getApplicationMessenger().handleMessage(message);
        return;
    }
    if (_item.getBlock().getProperties().isReferenceBlock()) {
        defName = String.format("%s.%s", _item.getBlock().getProperties().getName(), defName);
    }
    EJLovDefinitionProperties lovDef = form.getProperties().getLovDefinitionProperties(defName);
    if (lovDef == null) {
        return;
    }
    Collection<EJItemProperties> allItemProperties = lovDef.getBlockProperties().getAllItemProperties();
    for (EJItemProperties ejItemProperties : allItemProperties) {
        String defaultValue = ejItemProperties.getDefaultQueryValue();
        if (defaultValue == null || defaultValue.trim().length() == 0) {
            continue;
        }
        String paramTypeCode = defaultValue.substring(0, defaultValue.indexOf(':'));
        String paramValue = defaultValue.substring(defaultValue.indexOf(':') + 1);
        final Logger logger = LoggerFactory.getLogger(EJRWTComboItemRenderer.class);
        if ("APP_PARAMETER".equals(paramTypeCode)) {
            EJApplicationLevelParameter param = form.getApplicationLevelParameter(paramValue);
            if (param != null) {
                param.addParameterChangedListener(new ParameterChangedListener() {

                    @Override
                    public void parameterChanged(String parameterName, Object oldValue, Object newValue) {
                        logger.debug("APP_PARAMETER:parameterChanged %s.%s", _item.getBlock().getProperties().getName(), _item.getName());
                        Display.getDefault().asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                _loadComboBoxValues();
                                refreshCombo();
                            }
                        });
                    }
                });
            }
        } else if ("FORM_PARAMETER".equals(paramTypeCode)) {
            EJFormParameter param = form.getFormParameter(paramValue);
            if (param != null) {
                param.addParameterChangedListener(new ParameterChangedListener() {

                    @Override
                    public void parameterChanged(String parameterName, Object oldValue, Object newValue) {
                        logger.debug("FORM_PARAMETER.parameterChanged %s.%s", _item.getBlock().getProperties().getName(), _item.getName());
                        Display.getDefault().asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                _loadComboBoxValues();
                                refreshCombo();
                            }
                        });
                    }
                });
            }
        } else if ("BLOCK_ITEM".equals(paramTypeCode)) {
            final String blockName = paramValue.substring(0, paramValue.indexOf('.'));
            String itemName = paramValue.substring(paramValue.indexOf('.') + 1);
            EJInternalEditableBlock block = form.getBlock(blockName);
            if (block != null) {
                final String itemBlock = _item.getBlock().getProperties().getName();
                _lovInitialiedOnValueSet = true;
                if (!itemBlock.equals(blockName) || _item.getScreenType() == EJScreenType.MAIN) {
                    block.getBlockController().addNewRecordFocusedListener(new EJNewRecordFocusedListener() {

                        @Override
                        public void focusedGained(EJDataRecord focusedRecord) {
                            logger.debug(String.format("BLOCK RECORD Changed %s", blockName));
                            Display.getDefault().asyncExec(new Runnable() {

                                @Override
                                public void run() {
                                    _loadComboBoxValues();
                                    refreshCombo();
                                }
                            });
                        }
                    });
                }
                block.addDataItemValueChangedListener(itemName, new EJDataItemValueChangedListener() {

                    @Override
                    public void dataItemValueChanged(String itemName, EJDataRecord changedRecord, EJScreenType screenType) {
                        if (blockName.equals(itemBlock)) {
                            if (screenType == _item.getScreenType()) {
                                logger.debug(String.format("BLOCK_ITEM.valueChanged %s.%s", blockName, itemName));
                                Display.getDefault().asyncExec(new Runnable() {

                                    @Override
                                    public void run() {
                                        _loadComboBoxValues();
                                        refreshCombo();
                                    }
                                });
                            }
                        } else {
                            if (screenType == EJScreenType.MAIN) {
                                logger.debug(String.format("BLOCK_ITEM.valueChanged %s.%s", blockName, itemName));
                                Display.getDefault().asyncExec(new Runnable() {

                                    @Override
                                    public void run() {
                                        _loadComboBoxValues();
                                        refreshCombo();
                                    }
                                });
                            }
                        }
                    }
                });
            }
        }
    }
    EJLovController lovController = form.getLovController(defName);
    if (lovController == null) {
        return;
    }
}
Also used : EJScreenType(org.entirej.framework.core.enumerations.EJScreenType) EJFormParameter(org.entirej.framework.core.data.controllers.EJFormParameter) Logger(org.slf4j.Logger) EJApplicationLevelParameter(org.entirej.framework.core.data.controllers.EJApplicationLevelParameter) EJLovController(org.entirej.framework.core.data.controllers.EJLovController) EJInternalForm(org.entirej.framework.core.internal.EJInternalForm) EJMessage(org.entirej.framework.core.EJMessage) EJLovDefinitionProperties(org.entirej.framework.core.properties.interfaces.EJLovDefinitionProperties) ParameterChangedListener(org.entirej.framework.core.data.controllers.EJApplicationLevelParameter.ParameterChangedListener) EJDataItemValueChangedListener(org.entirej.framework.core.renderers.eventhandlers.EJDataItemValueChangedListener) EJInternalEditableBlock(org.entirej.framework.core.internal.EJInternalEditableBlock) EJNewRecordFocusedListener(org.entirej.framework.core.renderers.eventhandlers.EJNewRecordFocusedListener) EJItemProperties(org.entirej.framework.core.properties.interfaces.EJItemProperties) EJDataRecord(org.entirej.framework.core.data.EJDataRecord)

Example 4 with EJFormParameter

use of org.entirej.framework.core.data.controllers.EJFormParameter in project rap by entirej.

the class EJRWTApplicationManager method runReport.

public void runReport(String reportName, EJParameterList parameterList) {
    if (reportManager == null) {
        reportManager = EJReportFrameworkInitialiser.initialiseFramework("report.ejprop");
    }
    EJReport report;
    if (parameterList == null) {
        report = reportManager.createReport(reportName);
    } else {
        EJReportParameterList list = new EJReportParameterList();
        Collection<EJFormParameter> allParameters = parameterList.getAllParameters();
        for (EJFormParameter parameter : allParameters) {
            EJReportParameter reportParameter = new EJReportParameter(parameter.getName(), parameter.getDataType());
            reportParameter.setValue(parameter.getValue());
            list.addParameter(reportParameter);
        }
        report = reportManager.createReport(reportName, list);
    }
    EJReportRunner reportRunner = reportManager.createReportRunner();
    String output = reportRunner.runReport(report);
    String name = report.getName();
    EJReportParameter reportParameter = null;
    if (report.hasReportParameter("REPORT_NAME")) {
        reportParameter = report.getReportParameter("REPORT_NAME");
    }
    if (reportParameter != null && reportParameter.getValue() != null && !((String) reportParameter.getValue()).isEmpty()) {
        name = (String) reportParameter.getValue();
    } else {
        if (report.getOutputName() != null && !report.getOutputName().isEmpty()) {
            name = report.getOutputName();
        }
    }
    String ext = report.getProperties().getExportType().toString().toLowerCase();
    report.getProperties().getExportType();
    if (report.getProperties().getExportType() == EJReportExportType.XLSX_LARGE) {
        ext = EJReportExportType.XLSX.toString().toLowerCase();
    }
    EJRWTImageRetriever.getGraphicsProvider().open(output, String.format("%s.%s", name, ext));
}
Also used : EJReportParameter(org.entirej.framework.report.data.controllers.EJReportParameter) EJReport(org.entirej.framework.report.EJReport) EJFormParameter(org.entirej.framework.core.data.controllers.EJFormParameter) EJReportParameterList(org.entirej.framework.report.EJReportParameterList) EJReportRunner(org.entirej.framework.report.interfaces.EJReportRunner)

Aggregations

EJFormParameter (org.entirej.framework.core.data.controllers.EJFormParameter)4 EJReport (org.entirej.framework.report.EJReport)3 EJReportParameterList (org.entirej.framework.report.EJReportParameterList)3 EJReportParameter (org.entirej.framework.report.data.controllers.EJReportParameter)3 EJReportRunner (org.entirej.framework.report.interfaces.EJReportRunner)3 ServerPushSession (org.eclipse.rap.rwt.service.ServerPushSession)1 Display (org.eclipse.swt.widgets.Display)1 EJMessage (org.entirej.framework.core.EJMessage)1 EJDataRecord (org.entirej.framework.core.data.EJDataRecord)1 EJApplicationLevelParameter (org.entirej.framework.core.data.controllers.EJApplicationLevelParameter)1 ParameterChangedListener (org.entirej.framework.core.data.controllers.EJApplicationLevelParameter.ParameterChangedListener)1 EJLovController (org.entirej.framework.core.data.controllers.EJLovController)1 EJScreenType (org.entirej.framework.core.enumerations.EJScreenType)1 EJInternalEditableBlock (org.entirej.framework.core.internal.EJInternalEditableBlock)1 EJInternalForm (org.entirej.framework.core.internal.EJInternalForm)1 EJItemProperties (org.entirej.framework.core.properties.interfaces.EJItemProperties)1 EJLovDefinitionProperties (org.entirej.framework.core.properties.interfaces.EJLovDefinitionProperties)1 EJDataItemValueChangedListener (org.entirej.framework.core.renderers.eventhandlers.EJDataItemValueChangedListener)1 EJNewRecordFocusedListener (org.entirej.framework.core.renderers.eventhandlers.EJNewRecordFocusedListener)1 Logger (org.slf4j.Logger)1