Package org.joget.apps.app.model

Examples of org.joget.apps.app.model.FormDefinition


        FormService formService = (FormService) AppUtil.getApplicationContext().getBean("formService");
        String formDefId = getPropertyString("formDefId");
        if (formDefId != null) {
            if (cachedForm == null || !formDefId.equals(cachedFormDefId)) {
                AppDefinition appDef = AppUtil.getCurrentAppDefinition();
                FormDefinition formDef = formDefinitionDao.loadById(formDefId, appDef);
                if (formDef != null) {
                    String formJson = formDef.getJson();
                   
                    if (formJson != null) {
                        form = (Form) formService.createElementFromJson(formJson, false);
                        cachedFormDefId = formDefId;
                        cachedForm = form;
View Full Code Here


                public Object doInHibernate(Session s) throws HibernateException, SQLException {
                    // get root form
                    Form form = null;
                    FormData formData = new FormData();
                    formData.setPrimaryKeyValue(primaryKeyValue);
                    FormDefinition formDef = formDefinitionDao.loadById(formDefId, appDef);
                    if (formDef != null) {
                        String formJson = formDef.getJson();
                        if (formJson != null) {
                            formJson = AppUtil.processHashVariable(formJson, assignment, StringUtil.TYPE_JSON, null);
                            form = (Form) formService.loadFormFromJson(formJson, formData);
                        }
View Full Code Here

        String formDefId = getPropertyString("formDefId");
        if (formDefId != null && !formDefId.isEmpty()) {
            // load subform
            AppDefinition appDef = AppUtil.getCurrentAppDefinition();
            FormDefinitionDao formDefinitionDao = (FormDefinitionDao) FormUtil.getApplicationContext().getBean("formDefinitionDao");
            FormDefinition formDef = formDefinitionDao.loadById(formDefId, appDef);
            if (formDef != null) {
                json = formDef.getJson();
            }
        }
        if (json != null && json.trim().length() > 0) {
            if (parentFormData != null && parentFormData.getProcessId() != null && !parentFormData.getProcessId().isEmpty()) {
                formData.setProcessId(parentFormData.getProcessId());
View Full Code Here

        }
        return paf;
    }

    protected FormDefinition retrieveFormDefinition(AppDefinition appDef, PackageActivityForm activityForm) {
        FormDefinition formDef = null;
        if (activityForm != null) {
            String formId = activityForm.getFormId();
            if (formId != null && !formId.isEmpty()) {
                formDef = formDefinitionDao.loadById(formId, appDef);
            }
View Full Code Here

    public Collection<String> createFormDefinition(AppDefinition appDefinition, FormDefinition formDefinition) {
        Collection<String> errors = new ArrayList<String>();

        // check for duplicate
        String formId = formDefinition.getId();
        FormDefinition formDef = formDefinitionDao.loadById(formId, appDefinition);
        if (formDef != null) {
            errors.add("console.form.error.label.idExists");
        } else {
            // set app to form
            formDefinition.setAppDefinition(appDefinition);
View Full Code Here

     */
    protected Form loadFormByFormDefId(String appId, String version, String formDefId, FormData formData, WorkflowAssignment wfAssignment) {
        Form form = null;
        try {
            AppDefinition appDef = getAppDefinition(appId, version);
            FormDefinition formDef = formDefinitionDao.loadById(formDefId, appDef);
           
            if (formDef != null && formDef.getJson() != null) {
                String formJson = formDef.getJson();
                formJson = AppUtil.processHashVariable(formJson, wfAssignment, StringUtil.TYPE_JSON, null);
                form = (Form) formService.loadFormFromJson(formJson, formData);
            }
        } catch (Exception e) {
            LogUtil.error(getClass().getName(), e, e.getMessage());
View Full Code Here

        AppDefinition appDef = getAppDefinition(appId, appVersion);
        return getFormTableName(appDef, formDefId);
    }
   
    public String getFormTableName(AppDefinition appDef, String formDefId) {
        FormDefinition formDef = formDefinitionDao.loadById(formDefId, appDef);
        if (formDef != null) {
            return formDef.getTableName();
        }
        return null;
    }
View Full Code Here

    @Override
    public boolean delete(String id, AppDefinition appDef) {
        boolean result = false;
        try {
            FormDefinition obj = super.loadById(id, appDef);

            // detach from app
            if (obj != null) {
                Collection<FormDefinition> list = appDef.getFormDefinitionList();
                if (list != null) {
                    for (FormDefinition object : list) {
                        if (obj.getId().equals(object.getId())) {
                            list.remove(obj);
                            break;
                        }
                    }
                }
                obj.setAppDefinition(null);

                // delete obj
                super.delete(getEntityName(), obj);
                result = true;
               
                // clear from cache
                formColumnCache.remove(obj.getTableName());
            }
        } catch (Exception e) {
            LogUtil.error(getClass().getName(), e, "");
        }
        return result;
View Full Code Here

        }
       
        Form form = null;
        FormDefinitionDao formDefinitionDao = (FormDefinitionDao) AppUtil.getApplicationContext().getBean("formDefinitionDao");
        FormService formService = (FormService) AppUtil.getApplicationContext().getBean("formService");
        FormDefinition formDef = formDefinitionDao.loadById(formId, appDef);
        String formJson = formDef.getJson();

        if (formJson != null) {
            formJson = AppUtil.processHashVariable(formJson, assignment, StringUtil.TYPE_JSON, null);
            form = (Form) formService.loadFormFromJson(formJson, formData);
        }
View Full Code Here

        FormUtil.setFormBuilderActive(true);

        // load form definition
        model.addAttribute("appId", appId);
        AppDefinition appDef = appService.getAppDefinition(appId, version);
        FormDefinition formDef = null;
        if (appDef == null) {
            // TODO: handle invalid app
        } else {
            model.addAttribute("appDefinition", appDef);
            formDef = formDefinitionDao.loadById(formId, appDef);
        }

        if (formDef != null) {
            String formJson = null;
            if (json != null && !json.trim().isEmpty()) {
                // read custom JSON from request
                formJson = json;
            } else {
                // get JSON from form definition
                formJson = formDef.getJson();
            }
            if (formJson != null && formJson.trim().length() > 0) {
                String processedformJson = PropertyUtil.propertiesJsonLoadProcessing(formJson);
               
                try {
                    FormUtil.setProcessedFormJson(processedformJson);
                    String elementHtml = formService.previewElement(formJson);
                    model.addAttribute("elementHtml", elementHtml);
                    model.addAttribute("elementJson", processedformJson);
                } finally {
                    FormUtil.clearProcessedFormJson();
                }
            } else {
                // default empty form
                String tableName = formDef.getTableName();
                if (tableName == null || tableName.isEmpty()) {
                    tableName = formDef.getId();
                }
                String escapedFormName = StringEscapeUtils.escapeJavaScript(formDef.getName());
                String defaultJson = "{className: 'org.joget.apps.form.model.Form',  \"properties\":{ \"id\":\"" + formId + "\", \"name\":\"" + escapedFormName + "\", \"tableName\":\"" + tableName + "\", \"loadBinder\":{ \"className\":\"org.joget.apps.form.lib.WorkflowFormBinder\" }, \"storeBinder\":{ \"className\":\"org.joget.apps.form.lib.WorkflowFormBinder\" } }}";
                String formHtml = formService.previewElement(defaultJson);
                model.addAttribute("elementHtml", formHtml);
            }
        } else {
View Full Code Here

TOP

Related Classes of org.joget.apps.app.model.FormDefinition

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.