Package org.joget.apps.app.service

Examples of org.joget.apps.app.service.AppService


        return "userview/plugin/runProcess.jsp";
    }

    private void viewProcess() {
        ApplicationContext ac = AppUtil.getApplicationContext();
        AppService appService = (AppService) ac.getBean("appService");
        FormService formService = (FormService) ac.getBean("formService");

        WorkflowProcess process = appService.getWorkflowProcessForApp(getRequestParameterString("appId"), getRequestParameterString("appVersion"), getPropertyString("processDefId"));
        setProperty("process", process);

        if (isUnauthorized(process.getId())) {
            // check for start mapped form
            String formUrl = getUrl() + "?_action=start";
            FormData formData = new FormData();
            formData = formService.retrieveFormDataFromRequestMap(formData, getRequestParameters());

            String primaryKey = getRequestParameterString("recordId");
            if (primaryKey != null && primaryKey.trim().length() > 0) {
                formData.setPrimaryKeyValue(primaryKey);
            }

            if (getPropertyString("keyName") != null && getPropertyString("keyName").trim().length() > 0 && getKey() != null) {
                formData.addRequestParameterValues(getPropertyString("keyName"), new String[]{getKey()});
            }

            PackageActivityForm startFormDef = appService.viewStartProcessForm(getRequestParameterString("appId"), getRequestParameterString("appVersion"), getPropertyString("processDefId"), formData, formUrl);
            if (startFormDef != null && (startFormDef.getForm() != null || PackageActivityForm.ACTIVITY_FORM_TYPE_EXTERNAL.equals(startFormDef.getType()))) {
                Form startForm = startFormDef.getForm();

                // generate form HTML
                String formHtml = formService.retrieveFormHtml(startForm, formData);
                AppDefinition appDef = appService.getAppDefinition(getRequestParameterString("appId"), getRequestParameterString("appVersion"));

                // show form
                setProperty("headerTitle", process.getName());
                setProperty("view", "formView");
                setProperty("formHtml", formHtml);
View Full Code Here


        }
    }

    private void startProcess() {
        ApplicationContext ac = AppUtil.getApplicationContext();
        AppService appService = (AppService) ac.getBean("appService");
        FormService formService = (FormService) ac.getBean("formService");

        WorkflowProcess process = appService.getWorkflowProcessForApp(getRequestParameterString("appId"), getRequestParameterString("appVersion"), getPropertyString("processDefId"));
        setProperty("process", process);

        if (isUnauthorized(process.getId())) {
            // extract form values from request
            FormData formData = new FormData();

            String recordId = getRequestParameterString("recordId");
            if (recordId != null && recordId.trim().length() == 0) {
                recordId = null;
            }

            formData = formService.retrieveFormDataFromRequestMap(formData, getRequestParameters());

            if (getPropertyString("keyName") != null && getPropertyString("keyName").trim().length() > 0 && getKey() != null) {
                formData.addRequestParameterValues(getPropertyString("keyName"), new String[]{getKey()});
            }

            // get workflow variables
            Map<String, String> variableMap = AppUtil.retrieveVariableDataFromMap(getRequestParameters());
            String formUrl = getUrl() + "?_action=start";
            WorkflowProcessResult result = appService.submitFormToStartProcess(getRequestParameterString("appId"), getRequestParameterString("appVersion"), getPropertyString("processDefId"), formData, variableMap, recordId, formUrl);
            PackageActivityForm startFormDef = appService.viewStartProcessForm(getRequestParameterString("appId"), getRequestParameterString("appVersion"), getPropertyString("processDefId"), formData, formUrl);
            if (startFormDef != null && (startFormDef.getForm() != null || PackageActivityForm.ACTIVITY_FORM_TYPE_EXTERNAL.equals(startFormDef.getType()))) {
                if (result == null) {
                    // validation error, get form
                    Form startForm = startFormDef.getForm();

                    // generate form HTML
                    String formHtml = formService.retrieveFormErrorHtml(startForm, formData);
                    AppDefinition appDef = appService.getAppDefinition(getRequestParameterString("appId"), getRequestParameterString("appVersion"));

                    // show form
                    setProperty("headerTitle", process.getName());
                    setProperty("view", "formView");
                    setProperty("formHtml", formHtml);
View Full Code Here

    protected ReportWorkflowProcessInstance updateProcessData(WorkflowProcess wfProcess, WorkflowProcess wfTrackProcess, String appId, String appVersion) {
        String processInstanceId = wfProcess.getInstanceId();

        WorkflowManager workflowManager = (WorkflowManager) AppUtil.getApplicationContext().getBean("workflowManager");
        ReportManager reportManager = (ReportManager) AppUtil.getApplicationContext().getBean("reportManager");
        AppService appService = (AppService) AppUtil.getApplicationContext().getBean("appService");

        if (wfTrackProcess != null) {
            ReportWorkflowProcessInstance pInstance = reportManager.getReportWorkflowProcessInstance(processInstanceId);
            if (pInstance == null) {
                pInstance = new ReportWorkflowProcessInstance();
                pInstance.setInstanceId(processInstanceId);

                //get app
                AppDefinition appDef = appService.getAppDefinition(appId, appVersion);
                ReportApp reportApp = reportManager.getReportApp(appId, appVersion, appDef.getName());

                //get package
                ReportWorkflowPackage reportPackage = reportManager.getReportWorkflowPackage(reportApp, wfProcess.getPackageId(), wfProcess.getVersion(), wfProcess.getName());
View Full Code Here

    }

    protected DataList getDataList() throws BeansException {
        // get datalist
        ApplicationContext ac = AppUtil.getApplicationContext();
        AppService appService = (AppService) ac.getBean("appService");
        DataListService dataListService = (DataListService) ac.getBean("dataListService");
        DatalistDefinitionDao datalistDefinitionDao = (DatalistDefinitionDao) ac.getBean("datalistDefinitionDao");
        String id = getPropertyString("datalistId");
        AppDefinition appDef = appService.getAppDefinition(getRequestParameterString("appId"), getRequestParameterString("appVersion"));
        DatalistDefinition datalistDefinition = datalistDefinitionDao.loadById(id, appDef);
        DataList dataList = dataListService.fromJson(datalistDefinition.getJson());
       
        if (getPropertyString(Userview.USERVIEW_KEY_NAME) != null && getPropertyString(Userview.USERVIEW_KEY_NAME).trim().length() > 0) {
            dataList.addBinderProperty(Userview.USERVIEW_KEY_NAME, getPropertyString(Userview.USERVIEW_KEY_NAME));
View Full Code Here

    }

    private void assignmentView() {
        String activityId = getRequestParameterString("activityId");
        ApplicationContext ac = AppUtil.getApplicationContext();
        AppService appService = (AppService) ac.getBean("appService");
        FormService formService = (FormService) ac.getBean("formService");
        WorkflowManager workflowManager = (WorkflowManager) ac.getBean("workflowManager");

        if (isAssignmentExist(activityId)) {
            try {
                WorkflowAssignment assignment = workflowManager.getAssignment(activityId);
                // set process instance ID as primary key
                FormData formData = new FormData();

                formData = formService.retrieveFormDataFromRequestMap(formData, getRequestParameters());

                if (getPropertyString("keyName") != null && getPropertyString("keyName").trim().length() > 0 && getKey() != null) {
                    formData.addRequestParameterValues(getPropertyString("keyName"), new String[]{getKey()});
                }

                // get form
                String formUrl = getUrl() + "?_action=assignmentSubmit&activityId=" + activityId;
                PackageActivityForm activityForm = appService.viewAssignmentForm(getRequestParameterString("appId"), getRequestParameterString("appVersion"), activityId, formData, formUrl);
                Form form = activityForm.getForm();
                AppDefinition appDef = appService.getAppDefinition(getRequestParameterString("appId"), getRequestParameterString("appVersion"));

                // generate form HTML
                String formHtml = formService.retrieveFormHtml(form, formData);

                // show form
View Full Code Here

        }
    }

    private void assignmentSubmit() {
        ApplicationContext ac = AppUtil.getApplicationContext();
        AppService appService = (AppService) ac.getBean("appService");
        FormService formService = (FormService) ac.getBean("formService");
        WorkflowManager workflowManager = (WorkflowManager) ac.getBean("workflowManager");
        String activityId = getRequestParameterString("activityId");
        if (isAssignmentExist(activityId)) {
            try {
                WorkflowAssignment assignment = workflowManager.getAssignment(activityId);
                // set process instance ID as primary key
                FormData formData = new FormData();
                formData = formService.retrieveFormDataFromRequestMap(formData, getRequestParameters());
                String processId = assignment.getProcessId();

                // get form
                String formUrl = getUrl() + "?_action=assignmentSubmit&activityId=" + activityId;
                PackageActivityForm activityForm = appService.viewAssignmentForm(getRequestParameterString("appId"), getRequestParameterString("appVersion"), activityId, formData, formUrl);
                Form form = activityForm.getForm();

                // submit form
                FormData formResult = formService.executeFormActions(form, formData);

                // check for validation errors
                if (formResult.getFormResult(AssignmentWithdrawButton.DEFAULT_ID) != null) {
                    // withdraw assignment
                    workflowManager.assignmentWithdraw(activityId);
                } else if (formResult.getFormResult(AssignmentCompleteButton.DEFAULT_ID) != null) {
                    // complete assignment
                    Map<String, String> variableMap = AppUtil.retrieveVariableDataFromMap(getRequestParameters());
                    formResult = appService.completeAssignmentForm(form, assignment, formData, variableMap);

                    Map<String, String> errors = formResult.getFormErrors();
                    if (!formResult.getStay() && errors.isEmpty() && activityForm.isAutoContinue()) {
                        setAlertMessage(getPropertyString("messageShowAfterComplete"));
                        // redirect to next activity if available
View Full Code Here

     */
    protected String getTableName(String formDefId) {
        String tableName = null;
        AppDefinition appDef = AppUtil.getCurrentAppDefinition();
        if (appDef != null && formDefId != null) {
            AppService appService = (AppService) AppUtil.getApplicationContext().getBean("appService");
            tableName = appService.getFormTableName(appDef, formDefId);
        }
        return tableName;
    }
View Full Code Here

    @Override
    public FormRowSet load(Element element, String primaryKey, FormData formData) {
       
        FormRowSet results = null;
        if (primaryKey != null && primaryKey.trim().length() > 0) {
            AppService appService = (AppService) FormUtil.getApplicationContext().getBean("appService");
            Form form = FormUtil.findRootForm(element);
            form = findFormForLoadBinder(form);
            if (form == null) {
                form = FormUtil.findRootForm(element);
            }
            if (form != null) {
                results = appService.loadFormDataWithoutTransaction(form, primaryKey);

            }
        }
        return results;
    }
View Full Code Here

            if (form == null) {
                return rows;
            }

            // store form data
            AppService appService = (AppService) FormUtil.getApplicationContext().getBean("appService");
            String primaryKeyValue = form.getPrimaryKeyValue(formData);
            rows = appService.storeFormData(form, rows, primaryKeyValue);
        }
        return rows;
    }
View Full Code Here

    }
   
    public static String getSelectedFormHtml(String formId, String primaryKey, AppDefinition appDef, WorkflowAssignment assignment, Boolean hideEmpty) {
        String html = "";

        AppService appService = (AppService) AppUtil.getApplicationContext().getBean("appService");
        FormData formData = new FormData();
        if (primaryKey != null && !primaryKey.isEmpty()) {
            formData.setPrimaryKeyValue(primaryKey);
        } else if (assignment != null) {
            formData.setPrimaryKeyValue(appService.getOriginProcessId(assignment.getProcessId()));
        }
        if (assignment != null) {
            formData.setProcessId(assignment.getProcessId());
        }
       
View Full Code Here

TOP

Related Classes of org.joget.apps.app.service.AppService

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.