Tabnine Logo
FormRepresentation
Code IndexAdd Tabnine to your IDE (free)

How to use
FormRepresentation
in
org.jbpm.form.builder.services.model

Best Java code snippets using org.jbpm.form.builder.services.model.FormRepresentation (Showing top 16 results out of 315)

origin: org.jbpm/jbpm-form-services

public String saveFormGWT(Map<String, Object> form) throws FormBuilderServiceException {
  FormRepresentation formRep = new FormRepresentation();
  String encode = null;
  try {
    formRep.setDataMap(form);
    encode = saveForm(formRep);
  } catch (FormEncodingException ex) {
    logger.error("Error while saving from (gwt)", ex);
  }
  return encode;
}
origin: org.jbpm/jbpm-form-services

@Override
public String encode(FormRepresentation form) throws FormEncodingException {
  StringBuilder builder = new StringBuilder();
  builder.append("{\n");
  builder.append("  \"name\": ").append(encodeString(form.getName())).append(",\n");
  builder.append("  \"action\": ").append(encodeString(form.getAction())).append(",\n");
  builder.append("  \"processName\": ").append(encodeString(form.getProcessName())).append(",\n");
  builder.append("  \"taskId\": ").append(encodeString(form.getTaskId())).append(",\n");
  builder.append("  \"documentation\": ").append(encodeString(form.getDocumentation())).append(",\n");
  builder.append("  \"enctype\": ").append(encodeString(form.getEnctype())).append(",\n");
  builder.append("  \"lastModified\": \"").append(form.getLastModified()).append("\",\n");
  builder.append("  \"method\": ").append(encodeString(form.getMethod())).append(",\n");
  builder.append("  \"formItems\": ").append(encodeList(form.getFormItems())).append(",\n");
  builder.append("  \"formValidations\": ").append(encodeList(form.getFormValidations())).append(",\n");
  builder.append("  \"inputs\": ").append(encodeInputs(form.getInputs())).append(",\n");
  builder.append("  \"outputs\": ").append(encodeOutputs(form.getOutputs())).append(",\n");
  builder.append("  \"onLoadScripts\": ").append(encodeList(form.getOnLoadScripts())).append(",\n");
  builder.append("  \"onSubmitScripts\": ").append(encodeList(form.getOnSubmitScripts())).append("\n");
  builder.append("}\n");
  return builder.toString();
}

origin: org.jbpm/form-services

/**
 * @param form FormRepresentation with name to be changed
 * @return true if its an update, false if it is an insert
 */
protected boolean updateFormName(FormRepresentation form) {
  if (form.getName() == null || "null".equals(form.getName()) || "".equals(form.getName())) {
    form.setName(FORM_ID_PREFIX + System.currentTimeMillis());
    return false;
  } else if (!form.getName().startsWith(FORM_ID_PREFIX)){
    form.setName(FORM_ID_PREFIX + form.getName());
    return false;
  }
  return true;
}

origin: org.jbpm/jbpm-form-services

@Override
public FormRepresentation decode(String code) throws FormEncodingException {
  FormRepresentation form = new FormRepresentation();
  JsonElement json = new JsonParser().parse(code);
  if (json.isJsonObject()) {
        && jsonObj.get("action").isJsonPrimitive()
        && jsonObj.get("action").getAsJsonPrimitive().isString()) {
      form.setAction(jsonObj.get("action").getAsString());
        && jsonObj.get("documentation").getAsJsonPrimitive()
            .isString()) {
      form.setDocumentation(jsonObj.get("documentation")
          .getAsString());
        && jsonObj.get("enctype").isJsonPrimitive()
        && jsonObj.get("enctype").getAsJsonPrimitive().isString()) {
      form.setEnctype(jsonObj.get("enctype").getAsString());
        && jsonObj.get("lastModified").getAsJsonPrimitive()
            .isString()) {
      form.setLastModified(Double.valueOf(
          jsonObj.get("lastModified").getAsString()).longValue());
    } else if (jsonObj.get("lastModified") != null
        && jsonObj.get("lastModified").getAsJsonPrimitive()
            .isNumber()) {
      form.setLastModified(jsonObj.get("lastModified").getAsNumber()
          .longValue());
origin: org.jbpm/jbpm-form-services

public static FormRepresentation createMockForm(String title, String... params) {
  FormRepresentation form = new FormRepresentation();
  HeaderRepresentation header = new HeaderRepresentation();
  header.setValue(title);
  form.addFormItem(header);
  form.addFormItem(labelParams);
  form.addFormItem(table);
  form.addFormItem(completeButton);
  form.setAction("complete");
  form.setEnctype("multipart/form-data");
  form.setMethod("POST");
  form.setName(title + "AutoForm");
  return form;
origin: org.jbpm/jbpm-form-services

@Override
public void setDataMap(Map<String, Object> dataMap) throws FormEncodingException {
  FormBuilderDTOHelper helper = new FormBuilderDTOHelper(dataMap);
  setName(helper.getString("name"));
  setTaskId(helper.getString("taskId"));
  setProcessName(helper.getString("processName"));
  setAction(helper.getString("action"));
  setMethod(helper.getString("method"));
  setEnctype(helper.getString("enctype"));
origin: org.jbpm/jbpm-form-services

private void abstractTestSaveMenuItemProblem(final Class<?> exceptionType) throws Exception {
  FSMenuService service = createMockedService(exceptionType);
  MenuItemDescription sampleDescription = new MenuItemDescription();
  sampleDescription.setAllowedEvents(new ArrayList<String>());
  sampleDescription.setEffects(new ArrayList<FormEffectDescription>());
  FormItemRepresentation item = MockFormHelper.createMockForm("form", "param1").getFormItems().iterator().next();
  sampleDescription.setItemRepresentationMap(item.getDataMap());
  sampleDescription.setIconUrl("https://www.google.com/images/srpr/logo3w.png");
  sampleDescription.setName("name");
  try {
    service.saveMenuItem("group", sampleDescription);
    fail("saveMenuItem shouldn't succeed");
  } catch (MenuServiceException e) {
    assertNotNull("e shouldn't be null", e);
    Throwable cause = e.getCause();
    assertNotNull("cause shouldn't be null", cause);
    assertTrue("cause should be a " + exceptionType.getName(), cause.getClass().equals(exceptionType));
  }
}
@Test
origin: org.jbpm/form-services

@Override
public FormRepresentation decode(String code) throws FormEncodingException {
  FormRepresentation form = new FormRepresentation();
  JsonElement json = new JsonParser().parse(code);
  if (json.isJsonObject()) {
        && jsonObj.get("action").isJsonPrimitive()
        && jsonObj.get("action").getAsJsonPrimitive().isString()) {
      form.setAction(jsonObj.get("action").getAsString());
        && jsonObj.get("documentation").getAsJsonPrimitive()
            .isString()) {
      form.setDocumentation(jsonObj.get("documentation")
          .getAsString());
        && jsonObj.get("enctype").isJsonPrimitive()
        && jsonObj.get("enctype").getAsJsonPrimitive().isString()) {
      form.setEnctype(jsonObj.get("enctype").getAsString());
        && jsonObj.get("lastModified").getAsJsonPrimitive()
            .isString()) {
      form.setLastModified(Double.valueOf(
          jsonObj.get("lastModified").getAsString()).longValue());
    } else if (jsonObj.get("lastModified") != null
        && jsonObj.get("lastModified").getAsJsonPrimitive()
            .isNumber()) {
      form.setLastModified(jsonObj.get("lastModified").getAsNumber()
          .longValue());
origin: org.jbpm/form-services

public static FormRepresentation createMockForm(String title, String... params) {
  FormRepresentation form = new FormRepresentation();
  HeaderRepresentation header = new HeaderRepresentation();
  header.setValue(title);
  form.addFormItem(header);
  form.addFormItem(labelParams);
  form.addFormItem(table);
  form.addFormItem(completeButton);
  form.setAction("complete");
  form.setEnctype("multipart/form-data");
  form.setMethod("POST");
  form.setName(title + "AutoForm");
  return form;
origin: org.jbpm/form-services

@Override
public void setDataMap(Map<String, Object> dataMap) throws FormEncodingException {
  FormBuilderDTOHelper helper = new FormBuilderDTOHelper(dataMap);
  setName(helper.getString("name"));
  setTaskId(helper.getString("taskId"));
  setProcessName(helper.getString("processName"));
  setAction(helper.getString("action"));
  setMethod(helper.getString("method"));
  setEnctype(helper.getString("enctype"));
origin: org.jbpm/form-services

private void abstractTestSaveMenuItemProblem(final Class<?> exceptionType) throws Exception {
  FSMenuService service = createMockedService(exceptionType);
  MenuItemDescription sampleDescription = new MenuItemDescription();
  sampleDescription.setAllowedEvents(new ArrayList<String>());
  sampleDescription.setEffects(new ArrayList<FormEffectDescription>());
  FormItemRepresentation item = MockFormHelper.createMockForm("form", "param1").getFormItems().iterator().next();
  sampleDescription.setItemRepresentationMap(item.getDataMap());
  sampleDescription.setIconUrl("https://www.google.com/images/srpr/logo3w.png");
  sampleDescription.setName("name");
  try {
    service.saveMenuItem("group", sampleDescription);
    fail("saveMenuItem shouldn't succeed");
  } catch (MenuServiceException e) {
    assertNotNull("e shouldn't be null", e);
    Throwable cause = e.getCause();
    assertNotNull("cause shouldn't be null", cause);
    assertTrue("cause should be a " + exceptionType.getName(), cause.getClass().equals(exceptionType));
  }
}
@Test
origin: org.jbpm/form-services

@Override
public String encode(FormRepresentation form) throws FormEncodingException {
  StringBuilder builder = new StringBuilder();
  builder.append("{\n");
  builder.append("  \"name\": ").append(encodeString(form.getName())).append(",\n");
  builder.append("  \"action\": ").append(encodeString(form.getAction())).append(",\n");
  builder.append("  \"processName\": ").append(encodeString(form.getProcessName())).append(",\n");
  builder.append("  \"taskId\": ").append(encodeString(form.getTaskId())).append(",\n");
  builder.append("  \"documentation\": ").append(encodeString(form.getDocumentation())).append(",\n");
  builder.append("  \"enctype\": ").append(encodeString(form.getEnctype())).append(",\n");
  builder.append("  \"lastModified\": \"").append(form.getLastModified()).append("\",\n");
  builder.append("  \"method\": ").append(encodeString(form.getMethod())).append(",\n");
  builder.append("  \"formItems\": ").append(encodeList(form.getFormItems())).append(",\n");
  builder.append("  \"formValidations\": ").append(encodeList(form.getFormValidations())).append(",\n");
  builder.append("  \"inputs\": ").append(encodeInputs(form.getInputs())).append(",\n");
  builder.append("  \"outputs\": ").append(encodeOutputs(form.getOutputs())).append(",\n");
  builder.append("  \"onLoadScripts\": ").append(encodeList(form.getOnLoadScripts())).append(",\n");
  builder.append("  \"onSubmitScripts\": ").append(encodeList(form.getOnSubmitScripts())).append("\n");
  builder.append("}\n");
  return builder.toString();
}

origin: org.jbpm/form-services

public String saveFormGWT(Map<String, Object> form) throws FormBuilderServiceException {
  FormRepresentation formRep = new FormRepresentation();
  String encode = null;
  try {
    formRep.setDataMap(form);
    encode = saveForm(formRep);
  } catch (FormEncodingException ex) {
    Logger.getLogger(FormBuilderServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
  }
  return encode;
}
origin: org.jbpm/jbpm-form-services

/**
 * @param form FormRepresentation with name to be changed
 * @return true if its an update, false if it is an insert
 */
protected boolean updateFormName(FormRepresentation form) {
  if (form.getName() == null || "null".equals(form.getName()) || "".equals(form.getName())) {
    form.setName(FORM_ID_PREFIX + System.currentTimeMillis());
    return false;
  } else if (!form.getName().startsWith(FORM_ID_PREFIX)){
    form.setName(FORM_ID_PREFIX + form.getName());
    return false;
  }
  return true;
}

origin: org.jbpm/jbpm-form-services

  @Test
  public void testSaveMenuItemEncodingProblem() throws Exception {
    FSMenuService service = createMockedService(null);
    MenuItemDescription sampleDescription = new MenuItemDescription();
    sampleDescription.setAllowedEvents(new ArrayList<String>());
    sampleDescription.setEffects(new ArrayList<FormEffectDescription>());
    FormItemRepresentation item = MockFormHelper.createMockForm("form", "param1").getFormItems().iterator().next();
    sampleDescription.setItemRepresentationMap(item.getDataMap());
    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);
      fail("saveMenuItem shouldn't succeed");
    } catch (MenuServiceException e) {
      assertNotNull("e shouldn't be null", e);
      Throwable cause = e.getCause();
      assertNotNull("cause shouldn't be null", cause);
      assertTrue("cause should be a FormEncodingException", cause instanceof FormEncodingException);
    }
    EasyMock.verify(encoder);
  }
// THIS TEST REQUIRES THE REAL GWT Components so it should be executed in the showcase    
origin: org.jbpm/form-services

  @Test
  public void testSaveMenuItemEncodingProblem() throws Exception {
    FSMenuService service = createMockedService(null);
    MenuItemDescription sampleDescription = new MenuItemDescription();
    sampleDescription.setAllowedEvents(new ArrayList<String>());
    sampleDescription.setEffects(new ArrayList<FormEffectDescription>());
    FormItemRepresentation item = MockFormHelper.createMockForm("form", "param1").getFormItems().iterator().next();
    sampleDescription.setItemRepresentationMap(item.getDataMap());
    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);
      fail("saveMenuItem shouldn't succeed");
    } catch (MenuServiceException e) {
      assertNotNull("e shouldn't be null", e);
      Throwable cause = e.getCause();
      assertNotNull("cause shouldn't be null", cause);
      assertTrue("cause should be a FormEncodingException", cause instanceof FormEncodingException);
    }
    EasyMock.verify(encoder);
  }
// THIS TEST REQUIRES THE REAL GWT Components so it should be executed in the showcase    
org.jbpm.form.builder.services.modelFormRepresentation

Most used methods

  • <init>
  • getFormItems
  • setAction
  • setEnctype
  • setMethod
  • setName
  • addFormItem
  • getAction
  • getDocumentation
  • getEnctype
  • getFormValidations
  • getInputs
  • getFormValidations,
  • getInputs,
  • getLastModified,
  • getMethod,
  • getName,
  • getOnLoadScripts,
  • getOnSubmitScripts,
  • getOutputs,
  • getProcessName,
  • getTaskId

Popular in Java

  • Making http requests using okhttp
  • scheduleAtFixedRate (Timer)
  • startActivity (Activity)
  • getResourceAsStream (ClassLoader)
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • JFileChooser (javax.swing)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now