Package org.joget.apps.form.model

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


            JSONArray jsonArray = new JSONArray(json);
            for (int i = 0; i < jsonArray.length(); i++) {
                JSONObject jsonRow = (JSONObject) jsonArray.get(i);

                // create row and populate fields
                FormRow row = new FormRow();
                JSONArray fields = jsonRow.names();
                if (fields != null && fields.length() > 0) {
                    for (int k = 0; k < fields.length(); k++) {
                        String fieldName = fields.getString(k);
                        String value = jsonRow.getString(fieldName);
                        row.setProperty(fieldName, value);
                    }
                }
                rowSet.add(row);
            }
        }
View Full Code Here


    protected FormRow internalLoad(String entityName, String tableName, String primaryKey) {
        // get hibernate template
        HibernateTemplate ht = getHibernateTemplate(tableName, tableName, null, ACTION_TYPE_LOAD);

        // load by primary key
        FormRow row = null;
        try {
            row = (FormRow) ht.load(tableName, primaryKey);
        } catch (ObjectRetrievalFailureException e) {
            // not found, ignore
        }
View Full Code Here

       
        // get hibernate template
        HibernateTemplate ht = getHibernateTemplate(tableName, tableName, null, ACTION_TYPE_LOAD);

        // load by primary key
        FormRow row = null;
        try {
            row = (FormRow) ht.load(tableName, primaryKey);
        } catch (ObjectRetrievalFailureException e) {
            // not found, ignore
        }
View Full Code Here

            synchronized(formHibernateTemplateCache) {
                String profile = DynamicDataSourceManager.getCurrentProfile();
                String cacheKey = profile + ";" + entityName + ";" + tableName;
                if (rowSet != null) {
                    for (Iterator<FormRow> i=rowSet.iterator(); i.hasNext();) {
                        FormRow row = i.next();
                        cacheKey += ";" + row.keySet();
                        break;
                    }
                }
                net.sf.ehcache.Element element = formHibernateTemplateCache.get(cacheKey);
                if (element != null) {
View Full Code Here

        Collection<FormStoreBinder> binders = formResult.getStoreBinders();
        for (FormStoreBinder binder : binders) {
            if (binder instanceof FormStoreBinder) {
                FormRowSet rowSet = formResult.getStoreBinderData(binder);
                if (!rowSet.isEmpty()) {
                    FormRow row = rowSet.get(0);
                    formRowId = row.getProperty("FORM_ID"); // TODO: use constant for form ID field
                }
                break;
            }
        }
        return formRowId;
View Full Code Here

        FormRowSet results = null;
        if (form != null) {
            results = new FormRowSet();
            results.setMultiRow(false);
            if (primaryKeyValue != null && primaryKeyValue.trim().length() > 0) {
                FormRow row = (transactional) ? formDataDao.load(form, primaryKeyValue) : formDataDao.loadWithoutTransaction(form, primaryKeyValue);
                if (row != null) {
                    results.add(row);
                }
                LogUtil.debug(getClass().getName(), "  -- Loaded form data row [" + primaryKeyValue + "] for form [" + form.getProperty(FormUtil.PROPERTY_ID) + "] from table [" + form.getProperty(FormUtil.PROPERTY_TABLE_NAME) + "]");
            }
View Full Code Here

                results.addAll(rows);
            }

            // iterate through rows
            for (int i = 0; i < results.size(); i++) {
                FormRow row = results.get(i);
                String rowPrimaryKeyValue = row.getId();

                // set id
                if (rowPrimaryKeyValue == null || rowPrimaryKeyValue.trim().length() == 0) {
                    rowPrimaryKeyValue = primaryKeyValue;
                }
                if (rowPrimaryKeyValue == null || rowPrimaryKeyValue.trim().length() == 0) {
                    // no primary key value specified, generate new primary key value
                    rowPrimaryKeyValue = UuidGenerator.getInstance().getUuid();
                }
                row.setId(rowPrimaryKeyValue);
                if (!rows.isMultiRow() && (primaryKeyValue == null || primaryKeyValue.trim().isEmpty())) {
                    primaryKeyValue = rowPrimaryKeyValue;
                }

                // set meta data
                Date currentDate = new Date();
                row.setDateModified(currentDate);
                Date dateCreated = null;
                FormRowSet loadedRow = loadFormDataWithoutTransaction(form, rowPrimaryKeyValue);
                if (loadedRow != null && loadedRow.iterator().hasNext()) {
                    dateCreated = loadedRow.iterator().next().getDateCreated();
                }
                if (dateCreated == null) {
                    dateCreated = currentDate;
                }
                row.setDateCreated(dateCreated);
            }

            // update DB schema
            formDataDao.updateSchema(form, rows);
           
View Full Code Here

                FormRowSet options = new FormRowSet();
                Object[] objs = (Object[]) property.get(FormUtil.PROPERTY_OPTIONS);

                for (Object o : objs) {
                    Map temp = (HashMap) o;
                    FormRow option = new FormRow();
                    for (String key : (Set<String>) temp.keySet()) {
                        option.setProperty(key, (String) temp.get(key));
                    }
                    options.add(option);
                }
                property.put(FormUtil.PROPERTY_OPTIONS, options);
            }
View Full Code Here

            // get element formatted data
            FormRowSet elementResult = element.formatData(formData);
            if (elementResult != null) {
                if (!elementResult.isMultiRow()) {
                    // get single row
                    FormRow elementRow = elementResult.get(0);

                    // append to consolidated row set
                    if (rowSet.isEmpty()) {
                        rowSet.add(elementRow);
                    } else {
                        FormRow currentRow = rowSet.get(0);
                        currentRow.putAll(elementRow);
                    }
                } else {
                    //if the store binder of this element is null, store as single row in json format
                    if (element.getStoreBinder() == null) {
                        try {
                            // create json object
                            JSONArray jsonArray = new JSONArray();
                            for (FormRow row : elementResult) {
                                JSONObject jsonObject = new JSONObject();
                                for (Map.Entry entry : row.entrySet()) {
                                    String key = (String) entry.getKey();
                                    String value = (String) entry.getValue();
                                    jsonObject.put(key, value);
                                }
                               
                                //File upload is not support when no binder is set.
                               
                                jsonArray.put(jsonObject);
                            }

                            // convert into json string
                            String json = jsonArray.toString();

                            // store in single row FormRowSet
                            String id = element.getPropertyString(FormUtil.PROPERTY_ID);
                            FormRow elementRow = new FormRow();
                            elementRow.put(id, json);

                            // append to consolidated row set
                            if (rowSet.isEmpty()) {
                                rowSet.add(elementRow);
                            } else {
                                FormRow currentRow = rowSet.get(0);
                                currentRow.putAll(elementRow);
                            }
                        } catch (JSONException ex) {
                            LogUtil.error(FormUtil.class.getName(), ex, "");
                        }
                    } else {
View Full Code Here

        if (loadBinder != null) {
            if (recursive) {
                // load form data
                FormRowSet rowSet = formData.getLoadBinderData(e);
                if (rowSet != null && !rowSet.isEmpty()) {
                    FormRow row = rowSet.get(0);
                    boolean useSubMap = !flatten && !(e instanceof Form);
                    if (useSubMap) {
                        // it's data from a different form, so put data into submap
                        Map<String, Object> subMap = new HashMap<String, Object>();
                        for (Iterator i=row.keySet().iterator(); i.hasNext();) {
                            String key = (String)i.next();
                            Object value = row.get(key);
                            subMap.put(key, value.toString());
                        }
                        String elementKey = e.getPropertyString(FormUtil.PROPERTY_ID);
                        data.put(elementKey, subMap);
                        result = subMap;
                    } else {
                        // it's the same as the original form, so put data into original map
                        for (Iterator i=row.keySet().iterator(); i.hasNext();) {
                            String key = (String)i.next();
                            Object value = row.get(key);
                            data.put(key, value.toString());
                        }
                    }
                }
            }
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.