Package org.jbpm.formapi.shared.form

Examples of org.jbpm.formapi.shared.form.FormRepresentationEncoder


        sampleDescription.setAllowedEvents(new ArrayList<String>());
        sampleDescription.setEffects(new ArrayList<FormEffectDescription>());
        FormItemRepresentation item = RESTAbstractTest.createMockForm("form", "param1").getFormItems().iterator().next();
        sampleDescription.setItemRepresentation(item);
        sampleDescription.setName("name");
        FormRepresentationEncoder encoder = EasyMock.createMock(FormRepresentationEncoder.class);
        FormEncodingException exception = new FormEncodingException();
        @SuppressWarnings("unchecked")
        Map<String, List<MenuItemDescription>> anyObject = EasyMock.anyObject(Map.class);
        EasyMock.expect(encoder.encodeMenuItemsMap(anyObject)).andThrow(exception).once();
        FormEncodingFactory.register(encoder, FormEncodingFactory.getDecoder());
       
        EasyMock.replay(encoder);
        try {
            service.saveMenuItem("group", sampleDescription);
View Full Code Here


import org.jbpm.formapi.shared.form.FormRepresentationEncoder;

public class FormEncodingServerFactoryTest extends TestCase {

    public void testComplexFormDecoding() throws Exception {
        FormRepresentationEncoder encoder = FormEncodingServerFactory.getEncoder();
        FormRepresentationDecoder decoder = FormEncodingServerFactory.getDecoder();
        FormEncodingFactory.register(encoder, decoder);
       
        URL url = getClass().getResource("/org/jbpm/formapi/shared/form/testComplexFormDecoding.json");
        String json = FileUtils.readFileToString(new File(url.getFile()));
       
        assertNotNull("json shouldn't be null", json);
        assertNotSame("json shouldn't be empty", "", json);
       
       
        FormRepresentation form = decoder.decode(json);
        assertNotNull("form shouldn't be null", form);
        String json2 = encoder.encode(form);
        FormRepresentation form2 = decoder.decode(json2);
        assertNotNull("json2 shouldn't be null", json2);
        assertNotSame("json2 shouldn't be empty", "", json2);
       
        assertNotNull("form2 shouldn't be null", form2);
View Full Code Here

    public void testComplexFormDecoding() throws Exception {
        String json = JSON;
        assertNotNull("json shouldn't be null", json);
        assertNotSame("json shouldn't be empty", "", json);
       
        FormRepresentationEncoder encoder = FormEncodingClientFactory.getEncoder();
        FormRepresentationDecoder decoder = FormEncodingClientFactory.getDecoder();
       
        FormRepresentation form = decoder.decode(json);
        assertNotNull("form shouldn't be null", form);
        String json2 = encoder.encode(form);
        FormRepresentation form2 = decoder.decode(json2);
        assertNotNull("json2 shouldn't be null", json2);
        assertNotSame("json2 shouldn't be empty", "", json2);
       
        assertNotNull("form2 shouldn't be null", form2);
View Full Code Here

        String profile = request.getParameter("profile");
        String usr = request.getParameter("usr");
        String pwd = request.getParameter("pwd");
        TaskDefinitionService taskService = createTaskService(request, usr, pwd);
        FormDefinitionService formService = createFormService(request, usr, pwd);
        FormRepresentationEncoder encoder = FormEncodingFactory.getEncoder();
        JsonObject json = new JsonObject();
        json.addProperty("embedded", profile);
        try {
            if (profile != null && "guvnor".equals(profile)) {
                String uuid = request.getParameter("uuid");
                String packageName = taskService.getContainingPackage(uuid);
                FormRepresentation form = formService.getFormByUUID(packageName, uuid);
                json.addProperty("uuid", uuid);
                json.addProperty("packageName", packageName);
                if (form != null) {
                    json.addProperty("formjson", encoder.encode(form));
                }
            }else {
                throw new Exception("Unknown profile for GET: " + profile);
            }
            request.setAttribute("jsonData", new Gson().toJson(json));
View Full Code Here

        String profile = request.getParameter("profile");
        String usr = request.getParameter("usr");
        String pwd = request.getParameter("pwd");
        TaskDefinitionService taskService = createTaskService(request, usr, pwd);
        FormDefinitionService formService = createFormService(request, usr, pwd);
        FormRepresentationEncoder encoder = FormEncodingFactory.getEncoder();
        JsonObject json = new JsonObject();
        json.addProperty("embedded", profile);
        try {
            if ( profile != null && "designer".equals(profile)) {
                String userTask = request.getParameter("userTask");
                String processName = request.getParameter("processName");
                String bpmn2Process = IOUtils.toString(request.getReader());
                TaskRef task = taskService.getBPMN2Task(bpmn2Process, processName, userTask);
                if (task != null) {
                    //get associated form if it exists
                    FormRepresentation form = formService.getAssociatedForm(task.getPackageName(), task);
                    if (form != null) {
                        json.addProperty("formjson", encoder.encode(form));
                    }
                    json.add("task", toJsonObject(task));
                    json.addProperty("packageName", task.getPackageName());
                }
            } else {
View Full Code Here

    public FormItemDefDTO() {
        // jaxb needs a default constructor
    }
   
    public FormItemDefDTO(String formItemId, FormItemRepresentation formItem) throws FormEncodingException {
        FormRepresentationEncoder encoder = FormEncodingFactory.getEncoder();
        this._formItemId = formItemId;
        this._json = encoder.encode(formItem);
    }
View Full Code Here

    public FormDefDTO() {
        // jaxb needs a default constructor
    }
   
    public FormDefDTO(FormRepresentation form) throws FormEncodingException {
        FormRepresentationEncoder encoder = FormEncodingFactory.getEncoder();
        this._json = encoder.encode(form);
    }
View Full Code Here

            }
        });
    }
   
    protected void exportForm(FormRepresentation form) {
        FormRepresentationEncoder encoder = FormEncodingFactory.getEncoder();
        try {
            String formAsJson = encoder.encode(form);
            setClientExportForm(formAsJson);
        } catch (FormEncodingException e) {
            bus.fireEvent(new NotificationEvent(Level.ERROR, i18n.CouldntExportAsJson(), e));
        }
    }
View Full Code Here

     * @throws FormEncodingException in case of error parsing the form representation
     */
    public String asXml(FormRepresentation form, Map<String, Object> inputs) throws FormEncodingException {
        StringBuilder builder = new StringBuilder();
        builder.append("<formPreview>");
        FormRepresentationEncoder encoder = FormEncodingFactory.getEncoder();
        String json = encoder.encode(form);
        builder.append("<representation><![CDATA[").append(json).append("]]></representation>");
        if (inputs != null) {
            for (Map.Entry<String, Object> entry : inputs.entrySet()) {
                String key = entry.getKey();
                Object obj = entry.getValue();
View Full Code Here

        return retval;
    }
   
    private void writeMenuItems(Map<String, List<MenuItemDescription>> items) throws MenuServiceException {
        try {
            FormRepresentationEncoder encoder = FormEncodingFactory.getEncoder();
            String json = encoder.encodeMenuItemsMap(items);
            URL url = asURL("/menuItems.json");
            writeToURL(url, json);
        } catch (FormEncodingException e) {
            throw new MenuServiceException("Problem transforming menu items to json", e);
        } catch (URISyntaxException e) {
View Full Code Here

TOP

Related Classes of org.jbpm.formapi.shared.form.FormRepresentationEncoder

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.