Package org.joget.apps.form.model

Examples of org.joget.apps.form.model.FormRow


                if (formDefId != null) {
                    String tableName = appService.getFormTableName(appDef, formDefId);

                    FormDataDao dao = (FormDataDao) ac.getBean("formDataDao");

                    FormRow formRow = dao.load(formDefId, tableName, value.toString());

                    if (formRow != null && formRow.getCustomProperties() != null && formRow.getCustomProperties().get(field) != null) {
                        value = formRow.getCustomProperties().get(field);
                    }
                }
            } catch (Exception e) {
                LogUtil.error(this.getClass().getName(), e, "Get Foreign Key Error!");
            }
View Full Code Here


            // store single row data
            String id = "row1";
            String name = "name";
            String state = "state";
            FormRow row = new FormRow();
            row.setId(id);
            row.setProperty("name", name);
            row.setProperty("state", state);
            FormRowSet rowSet = new FormRowSet();
            rowSet.add(row);
            appService.storeFormData(TEST_APP_ID, TEST_APP_VERSION.toString(), TEST_FORM_ID, rowSet, null);

            // load single row data
            FormRowSet loadedRowSet = appService.loadFormData(TEST_APP_ID, TEST_APP_VERSION.toString(), TEST_FORM_ID, id);
            FormRow loadedRow = loadedRowSet.get(0);
            assertTrue(name.equals(loadedRow.getProperty("name")));
           
            // store updated row data using request
            String updatedName = "updated name";
            String updatedState = "updated state";
            FormData formData = new FormData();
            formData.setPrimaryKeyValue(id);
            formData.addRequestParameterValues("name", new String[] { updatedName });
            formData.addRequestParameterValues("state", new String[] { updatedState });
            appService.submitForm(TEST_APP_ID, TEST_APP_VERSION.toString(), TEST_FORM_ID, formData, false);

            // load updated row data
            loadedRowSet = appService.loadFormData(TEST_APP_ID, TEST_APP_VERSION.toString(), TEST_FORM_ID, id);
            loadedRow = loadedRowSet.get(0);
            assertTrue(updatedName.equals(loadedRow.getProperty("name")) && updatedState.equals(loadedRow.getProperty("state")));
        } finally {
            // delete form data
            formDataDao.delete(TEST_FORM_ID, TEST_FORM_ID, new String[]{"row1"});

            // delete app
View Full Code Here

            // submit form
            appService.submitForm(TEST_APP_ID, TEST_APP_VERSION.toString(), TEST_FORM_D, data, true);

            // load and verify data for form D
            FormRowSet rowSetD = appService.loadFormData(TEST_APP_ID, TEST_APP_VERSION.toString(), TEST_FORM_D, valueD);
            FormRow rowD = rowSetD.iterator().next();
            boolean verifyD = valueD.equals(rowD.get("id")) && valueD.equals(rowD.get("d1")) && valueD.equals(rowD.get("d2"));
            dId = rowD.get("id").toString();
               
            // load and verify data for form C
            String generatedIdForC = (String) rowD.get("cid");
            FormRowSet rowSetC = appService.loadFormData(TEST_APP_ID, TEST_APP_VERSION.toString(), TEST_FORM_C, generatedIdForC);
            FormRow rowC = rowSetC.iterator().next();
            boolean verifyC = generatedIdForC.equals(rowC.get("id")) && valueC.equals(rowC.get("c1")) && generatedIdForC.equals(rowD.get("cid"));
            cId = rowC.get("id").toString();
           
            // load and verify data for form A
            String generatedIdForA = (String) rowC.get("aid");
            FormRowSet rowSetA = appService.loadFormData(TEST_APP_ID, TEST_APP_VERSION.toString(), TEST_FORM_A, generatedIdForA);
            FormRow rowA = rowSetA.iterator().next();
            boolean verifyA = generatedIdForA.equals(rowA.get("id")) && valueA.equals(rowA.get("a1")) && generatedIdForC.equals(rowA.get("bid"));
            aId = rowA.get("id").toString();
           
            // verify form data
            assertTrue(verifyA && verifyC && verifyD);
            
            // load using form data util
View Full Code Here

    }

    @Override
    public FormRowSet formatData(FormData formData) {
        FormRowSet rowSet = null;
        FormRow result = null;

        String customHTML = (String) getProperty("value");

        if (customHTML != null && !customHTML.isEmpty()) {
            Pattern pattern = Pattern.compile("name=\\\"([a-zA-Z0-9_-]*)\\\"");
            Matcher matcher = pattern.matcher(customHTML);

            while (matcher.find()) {
                String name = matcher.group(1);

                //create dummy element object
                Element element = new TextField();
                element.setProperty("id", name);

                //get value from the formData
                String[] values = FormUtil.getElementPropertyValues(element, formData);
                if (values != null && values.length > 0) {
                    // check for empty submission via parameter
                    String[] paramValues = FormUtil.getRequestParameterValues(element, formData);
                    if (paramValues == null || paramValues.length == 0) {
                        values = new String[]{""};
                    }

                    // formulate values
                    String delimitedValue = FormUtil.generateElementPropertyValues(values);

                    if (rowSet == null) {
                        rowSet = new FormRowSet();
                        result = new FormRow();
                        rowSet.add(result);
                    }

                    // set value into Properties and FormRowSet object
                    result.setProperty(name, delimitedValue);
                }
            }
        }
        return rowSet;
    }
View Full Code Here

                if ("true".equalsIgnoreCase(getPropertyString("encryption"))) {
                    value = SecurityUtil.encrypt(value);
                }
               
                // set value into Properties and FormRowSet object
                FormRow result = new FormRow();
                result.setProperty(id, value);
                rowSet = new FormRowSet();
                rowSet.add(result);
            }
        }
View Full Code Here

                // formulate values
                String delimitedValue = FormUtil.generateElementPropertyValues(values);

                // set value into Properties and FormRowSet object
                FormRow result = new FormRow();
                result.setProperty(id, delimitedValue);
                rowSet = new FormRowSet();
                rowSet.add(result);
            }
        }
View Full Code Here

        }
        return null;
    }

    protected FormRow getRow(WorkflowAssignment wfAssignment, String multirowBaseObjectName, Integer rowNumber, Object[] fieldMapping, Map object) {
        FormRow row = new FormRow();

        for (Object o : fieldMapping) {
            Map mapping = (HashMap) o;
            String fieldName = mapping.get("field").toString();
            String jsonObjectName = WorkflowUtil.processVariable(mapping.get("jsonObjectName").toString(), null, wfAssignment, null, null);

            if (multirowBaseObjectName != null) {
                jsonObjectName = jsonObjectName.replace(multirowBaseObjectName, multirowBaseObjectName + "[" + rowNumber + "]");
            }

            String value = (String) getObjectFromMap(jsonObjectName, object);

            if (value == null) {
                value = jsonObjectName;
            }

            if (FormUtil.PROPERTY_ID.equals(fieldName)) {
                row.setId(value);
            } else {
                row.put(fieldName, value);
            }
        }

        if (row.getId() == null || (row.getId() != null && row.getId().trim().length() == 0)) {
            if (multirowBaseObjectName == null) {
                row.setId(wfAssignment.getProcessId());
            } else {
                row.setId(UuidGenerator.getInstance().getUuid());
            }
        }

        Date currentDate = new Date();
        row.setDateModified(currentDate);
        row.setDateCreated(currentDate);

        return row;
    }
View Full Code Here

    @Override
    public FormRowSet load(Element element, String primaryKey, FormData formData) {
        // load form data from DB
        FormRowSet rows = super.load(element, primaryKey, formData);
        if (rows != null) {
            FormRow row = null;
            if (rows.isEmpty()) {
                row = new FormRow();
                rows.add(row);
            } else {
                row = rows.iterator().next();
            }
View Full Code Here

                String processId = formData.getProcessId();
                if (activityId != null || processId != null) {
                    WorkflowManager workflowManager = (WorkflowManager) WorkflowUtil.getApplicationContext().getBean("workflowManager");

                    // recursively find element(s) mapped to workflow variable
                    FormRow row = rows.iterator().next();
                    Map<String, String> variableMap = new HashMap<String, String>();
                    variableMap = storeWorkflowVariables(element, row, variableMap);

                    // save variable values
                    for (Iterator<String> i = variableMap.keySet().iterator(); i.hasNext();) {
View Full Code Here

            // read from request if available.
            boolean continueLoop = true;
            int i = 0;
            while (continueLoop) {
                FormRow row = new FormRow();
                for (String header : headerMap.keySet()) {
                    String paramName = param + "_" + header + "_" + i;
                    String paramValue = formData.getRequestParameter(paramName);
                    if (paramValue != null) {
                        row.setProperty(header, paramValue);
                    }
                }
                i++;
                if (!row.isEmpty()) {
                    if (i == 0) {
                        // reset rowset
                        rowSet = new FormRowSet();
                    }
                    rowSet.add(row);
                } else {
                    // no more rows, stop looping
                    continueLoop = false;
                }
            }

            if (!FormUtil.isFormSubmitted(this, formData)) {
                // load from binder if available
                FormRowSet binderRowSet = formData.getLoadBinderData(this);
                if (binderRowSet != null) {
                    if (!binderRowSet.isMultiRow()) {
                        // parse from String
                        if (!binderRowSet.isEmpty()) {
                            FormRow row = binderRowSet.get(0);
                            String jsonValue = row.getProperty(id);
                            try {
                                rowSet = parseFormRowSetFromJson(jsonValue);
                            } catch (Exception ex) {
                                LogUtil.error(Grid.class.getName(), ex, "Error parsing grid JSON");
                            }
View Full Code Here

TOP

Related Classes of org.joget.apps.form.model.FormRow

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.