Package org.joget.apps.form.model

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


            // get runProcess start form
            PackageActivityForm startForm = appService.viewStartProcessForm(TEST_APP_ID, TEST_APP_VERSION.toString(), TEST_PROCESS_DEF_ID, null, null);
            assertTrue(TEST_FORM_ID.equals(startForm.getFormId()));

            // start process
            FormData data = new FormData();
            data.addRequestParameterValues(AssignmentCompleteButton.DEFAULT_ID, new String[]{AssignmentCompleteButton.DEFAULT_ID});
           
            WorkflowProcessResult result = appService.submitFormToStartProcess(TEST_APP_ID, TEST_APP_VERSION.toString(), TEST_PROCESS_DEF_ID, data, null, null, null);
            processId = result.getProcess().getInstanceId();
            Collection<WorkflowActivity> activityList = result.getActivities();
            assertTrue(activityList != null && activityList.size() == 1);

            // get first activity form
            WorkflowActivity firstActivity = activityList.iterator().next();
            String firstActivityId = firstActivity.getId();
            PackageActivityForm firstForm = appService.viewAssignmentForm(TEST_APP_ID, TEST_APP_VERSION.toString(), firstActivityId, null, null);
            assertTrue(TEST_FORM_ID_1.equals(firstForm.getFormId()));

            // complete first task
            FormData formResult = appService.completeAssignmentForm(TEST_APP_ID, TEST_APP_VERSION.toString(), firstActivityId, null, null);
            assertTrue(formResult.getFormErrors().isEmpty());

            // get assignments
            WorkflowAssignment assignment = workflowManager.getAssignmentByProcess(processId);
            String secondActivityId = assignment.getActivityId();
            PackageActivityForm secondForm = appService.viewAssignmentForm(TEST_APP_ID, TEST_APP_VERSION.toString(), secondActivityId, null, null);
            assertTrue(TEST_FORM_ID_2.equals(secondForm.getFormId()));

            // complete second task
            formResult = appService.completeAssignmentForm(TEST_APP_ID, TEST_APP_VERSION.toString(), secondActivityId, null, null);
            assertTrue(formResult.getFormErrors().isEmpty());

            // complete third task
            assignment = workflowManager.getAssignmentByProcess(processId);
            String thirdActivityId = assignment.getActivityId();
            formResult = appService.completeAssignmentForm(TEST_APP_ID, TEST_APP_VERSION.toString(), thirdActivityId, null, null);
            assertTrue(formResult.getFormErrors().isEmpty());

        } finally {
            // delete form data
            formDataDao.delete(TEST_FORM_ID, TEST_FORM_ID, new String[]{processId});
View Full Code Here


            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);
View Full Code Here

            createFormDefinition(appDef, TEST_FORM_B, TEST_FORM_C, TEST_APP_VERSION);
            createFormDefinition(appDef, TEST_FORM_C, TEST_FORM_C, TEST_APP_VERSION);
            createFormDefinition(appDef, TEST_FORM_D, TEST_FORM_D, TEST_APP_VERSION);

            // add values for reference form E
            FormData dataE = new FormData();
            dataE.addRequestParameterValues("id", new String[]{valueE1});
            dataE.addRequestParameterValues("e1", new String[]{valueE1});
            dataE.addRequestParameterValues("e2", new String[]{valueE1});
            dataE.addRequestParameterValues("e3", new String[]{valueE1});
            appService.submitForm(TEST_APP_ID, TEST_APP_VERSION.toString(), TEST_FORM_E, dataE, true);
            FormData dataE2 = new FormData();
            dataE2.addRequestParameterValues("id", new String[]{valueE2});
            dataE2.addRequestParameterValues("e1", new String[]{valueE2});
            dataE2.addRequestParameterValues("e2", new String[]{valueE2});
            dataE2.addRequestParameterValues("e3", new String[]{valueE2});
            appService.submitForm(TEST_APP_ID, TEST_APP_VERSION.toString(), TEST_FORM_E, dataE2, true);

            // create data to store
            FormData data = new FormData();
           
            // add values for root form D
            String valueD = "d001";
            data.addRequestParameterValues("id", new String[]{valueD});
            data.addRequestParameterValues("d1", new String[]{valueD});
            data.addRequestParameterValues("d2", new String[]{valueD});

            // add values for subform C
            String valueC = "c001";
            data.addRequestParameterValues("formC_testFormC_c1", new String[]{valueC});
            data.addRequestParameterValues("formC_testFormC_c2", new String[]{valueC});
            data.addRequestParameterValues("formC_testFormC_eref", new String[]{valueE1, valueE2});

            // add values for subform B
            String valueB = "b001";
            data.addRequestParameterValues("formC_testFormC_formB_testFormB_b1", new String[]{valueB});
            data.addRequestParameterValues("formC_testFormC_formB_testFormB_b2", new String[]{valueB});

            // add values for subform A
            String valueA = "a001";
            data.addRequestParameterValues("formC_testFormC_formB_testFormB_formA_testFormA_id", new String[]{""}); // empty ID, to be automatically generated
            data.addRequestParameterValues("formC_testFormC_formB_testFormB_formA_testFormA_a1", new String[]{valueA});
            data.addRequestParameterValues("formC_testFormC_formB_testFormB_formA_testFormA_a2", new String[]{valueA});

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

            // load and verify data for form D
View Full Code Here

     * @param includeMetaData true to include metadata required for use in the form builder.
     * @return
     */
    public String previewElement(String json, boolean includeMetaData) {
        Element element = createElementFromJson(StringUtil.decryptContent(json), !includeMetaData);
        FormData formData = new FormData();
        formData.addFormResult(PREVIEW_MODE, "true");
        String html = "";
        try {
            formData = executeFormOptionsBinders(element, formData);
        } catch (Exception ex) {
            LogUtil.error(FormService.class.getName(), ex, "Error executing form option binders");
View Full Code Here

     * @param formDefId
     * @param primaryKeyValue
     * @return
     */
    public String viewForm(Form form, String primaryKeyValue) {
        FormData formData = new FormData();
        formData.setPrimaryKeyValue(primaryKeyValue);
        String html = generateElementHtml(form, formData);
        return html;
    }
View Full Code Here

     * @param formJson
     * @param primaryKeyValue
     * @return
     */
    public String viewFormFromJson(String formJson, String primaryKeyValue) {
        FormData formData = new FormData();
        formData.setPrimaryKeyValue(primaryKeyValue);
        Form form = loadFormFromJson(formJson, formData);
        String html = generateElementHtml(form, formData);
        return html;
    }
View Full Code Here

     * @param formData
     * @param ignoreValidation
     * @return
     */
    public FormData submitForm(Form form, FormData formData, boolean ignoreValidation) {
        FormData updatedFormData = formData;
        updatedFormData = FormUtil.executeElementFormatDataForValidation(form, formData);
        if (!ignoreValidation) {
            updatedFormData = validateFormData(form, formData);
        }
        Map<String, String> errors = updatedFormData.getFormErrors();
        if (!updatedFormData.getStay() && errors == null || errors.isEmpty()) {
            // generate primary key if necessary
            Element primaryElement = FormUtil.findElement(FormUtil.PROPERTY_ID, form, formData);
            if (primaryElement != null) {
                //format data to generate id
                FormUtil.executeElementFormatData(primaryElement, formData);
            }
           
            String primaryKeyValue = form.getPrimaryKeyValue(updatedFormData);
            if (primaryKeyValue == null || primaryKeyValue.trim().length() == 0) {
                // no primary key value specified, generate new primary key value
                primaryKeyValue = UuidGenerator.getInstance().getUuid();
                updatedFormData.setPrimaryKeyValue(primaryKeyValue);
               
                //set to request param
                formData.addRequestParameterValues(FormUtil.PROPERTY_ID, new String[]{primaryKeyValue});
            }
            // no errors, save form data
View Full Code Here

     * @param request
     * @return
     */
    public FormData retrieveFormDataFromRequest(FormData formData, HttpServletRequest request) {
        if (formData == null) {
            formData = new FormData();
        }
        // handle standard parameters
        Enumeration<String> e = request.getParameterNames();
        while (e.hasMoreElements()) {
            String paramName = e.nextElement();
View Full Code Here

        return formData;
    }

    public FormData retrieveFormDataFromRequestMap(FormData formData, Map requestMap) {
        if (formData == null) {
            formData = new FormData();
        }
        // handle standard parameters
        for (String key : (Set<String>) requestMap.keySet()) {
            Object paramValue = requestMap.get(key);
            if (paramValue != null) {
View Full Code Here

     * @param form
     * @param formData
     * @return
     */
    public FormData executeFormActions(Form form, FormData formData) {
        FormData updatedFormData = formData;
        updatedFormData = FormUtil.executeActions(form, form, formData);
        return updatedFormData;
    }
View Full Code Here

TOP

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

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.