Package org.activiti.bpmn.model

Examples of org.activiti.bpmn.model.FormProperty


    assertTrue(userTask.getCustomUserIdentityLinks().get("manager").contains("fozzie"));
    assertTrue(userTask.getCustomUserIdentityLinks().get("manager").contains("gonzo"));
   
    List<FormProperty> formProperties = userTask.getFormProperties();
    assertEquals(2, formProperties.size());
    FormProperty formProperty = formProperties.get(0);
    assertEquals("formId", formProperty.getId());
    assertEquals("formName", formProperty.getName());
    assertEquals("string", formProperty.getType());
    assertEquals("variable", formProperty.getVariable());
    assertEquals("${expression}", formProperty.getExpression());
    formProperty = formProperties.get(1);
    assertEquals("formId2", formProperty.getId());
    assertEquals("anotherName", formProperty.getName());
    assertEquals("long", formProperty.getType());
    assertTrue(StringUtils.isEmpty(formProperty.getVariable()));
    assertTrue(StringUtils.isEmpty(formProperty.getExpression()));
   
    List<ActivitiListener> listeners = userTask.getTaskListeners();
    assertEquals(3, listeners.size());
    ActivitiListener listener = (ActivitiListener) listeners.get(0);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType()));
View Full Code Here


    assertEquals("startDoc", startEvent.getDocumentation());
   
    List<FormProperty> formProperties = startEvent.getFormProperties();
    assertEquals(2, formProperties.size());
   
    FormProperty formProperty = formProperties.get(0);
    assertEquals("startFormProp1", formProperty.getId());
    assertEquals("startFormProp1", formProperty.getName());
    assertEquals("string", formProperty.getType());
   
    formProperty = formProperties.get(1);
    assertEquals("startFormProp2", formProperty.getId());
    assertEquals("startFormProp2", formProperty.getName());
    assertEquals("boolean", formProperty.getType());

  }
View Full Code Here

  protected List<FormProperty> convertProperties(FormDefinition formDefinition) {
   
    List<FormProperty> formProperties = new ArrayList<FormProperty>();
   
    for (FormPropertyDefinition propertyDefinition : formDefinition.getFormPropertyDefinitions()) {
      FormProperty formProperty = new FormProperty();
      formProperties.add(formProperty);
     
      formProperty.setId(propertyDefinition.getName());
      formProperty.setName(propertyDefinition.getName());
      formProperty.setRequired(propertyDefinition.isMandatory());
     
      String type = null;
      if (propertyDefinition instanceof NumberPropertyDefinition) {
        type = "long";
      } else if (propertyDefinition instanceof DatePropertyDefinition) {
        type = "date";
      } else if (propertyDefinition instanceof ListPropertyDefinition) {
       
        type = "enum";
        ListPropertyDefinition listDefinition = (ListPropertyDefinition) propertyDefinition;
       
        if (!listDefinition.getEntries().isEmpty()) {
          List<FormValue> formValues = new ArrayList<FormValue>(listDefinition.getEntries().size());
          for (ListPropertyEntry entry : listDefinition.getEntries()) {
            FormValue formValue = new FormValue();
            // We're using same value for id and name for the moment
            formValue.setId(entry.getValue());
            formValue.setName(entry.getName());
            formValues.add(formValue);
          }
          formProperty.setFormValues(formValues);
        }
      } else {
        // Fallback to simple text
        type = "string";
      }
      formProperty.setType(type);
    }
   
    return formProperties;
  }
View Full Code Here

      if (itemsArrayNode != null) {
        for (JsonNode formNode : itemsArrayNode) {
          JsonNode formIdNode = formNode.get(PROPERTY_FORM_ID);
          if (formIdNode != null && StringUtils.isNotEmpty(formIdNode.asText())) {
           
            FormProperty formProperty = new FormProperty();
            formProperty.setId(formIdNode.asText());
            formProperty.setName(getValueAsString(PROPERTY_FORM_NAME, formNode));
            formProperty.setType(getValueAsString(PROPERTY_FORM_TYPE, formNode));
            formProperty.setExpression(getValueAsString(PROPERTY_FORM_EXPRESSION, formNode));
            formProperty.setVariable(getValueAsString(PROPERTY_FORM_VARIABLE, formNode));
            readWriteReqNode = getValueAsString(PROPERTY_FORM_REQUIRED, formNode);
            if (PROPERTY_VALUE_YES.equalsIgnoreCase(readWriteReqNode))
              formProperty.setRequired(true);
            readWriteReqNode = getValueAsString(PROPERTY_FORM_READABLE, formNode);
            if (PROPERTY_VALUE_NO.equalsIgnoreCase(readWriteReqNode))
              formProperty.setReadable(false);
            readWriteReqNode = getValueAsString(PROPERTY_FORM_WRITEABLE, formNode);
            if (PROPERTY_VALUE_NO.equalsIgnoreCase(readWriteReqNode))
                formProperty.setWriteable(false);
           
            formValuesNode = formNode.get(PROPERTY_FORM_FORM_VALUES);
            if (formValuesNode != null && StringUtils.isNotEmpty(formValuesNode.asText()) && !("undefined".equals(formValuesNode.asText()))) {
              if (formValuesNode.isValueNode()) {
                try {
                  formValuesNode = objectMapper.readTree(formValuesNode.asText());
                } catch (Exception e) {
                  LOGGER.info("Form properties values node can not be read", e);
                }
              }
              formValuesArrayNode = formValuesNode.get(EDITOR_PROPERTIES_GENERAL_ITEMS);
              List<FormValue> formValues = new ArrayList<FormValue>();
              for (JsonNode valueNode : formValuesArrayNode) {
                JsonNode valueIdNode = valueNode.get(PROPERTY_FORM_FORM_VALUE_ID);
                if (valueIdNode != null && StringUtils.isNotEmpty(valueIdNode.asText())) {
                  FormValue formValue = new FormValue();
                  formValue.setId(valueIdNode.asText());
                  formValue.setName(getValueAsString(PROPERTY_FORM_FORM_VALUE_NAME, valueNode));
                  formValues.add(formValue);
                }
              }
              formProperty.setFormValues(formValues);
            }
           
            if (element instanceof StartEvent) {
              ((StartEvent) element).getFormProperties().add(formProperty);
            } else if (element instanceof UserTask) {
View Full Code Here

    assertTrue(userTask.getCustomGroupIdentityLinks().get("businessAdministrator").contains("management"));
   
   
    List<FormProperty> formProperties = userTask.getFormProperties();
    assertEquals(3, formProperties.size());
    FormProperty formProperty = formProperties.get(0);
    assertEquals("formId", formProperty.getId());
    assertEquals("formName", formProperty.getName());
    assertEquals("string", formProperty.getType());
    assertEquals("variable", formProperty.getVariable());
    assertEquals("${expression}", formProperty.getExpression());
    formProperty = formProperties.get(1);
    assertEquals("formId2", formProperty.getId());
    assertEquals("anotherName", formProperty.getName());
    assertEquals("long", formProperty.getType());
    assertTrue(StringUtils.isEmpty(formProperty.getVariable()));
    assertTrue(StringUtils.isEmpty(formProperty.getExpression()));
    formProperty = formProperties.get(2);
    assertEquals("formId3", formProperty.getId());
    assertEquals("enumName", formProperty.getName());
    assertEquals("enum", formProperty.getType());
    assertTrue(StringUtils.isEmpty(formProperty.getVariable()));
    assertTrue(StringUtils.isEmpty(formProperty.getExpression()));
    assertEquals(2, formProperty.getFormValues().size());
   
    List<ActivitiListener> listeners = userTask.getTaskListeners();
    assertEquals(3, listeners.size());
    ActivitiListener listener = listeners.get(0);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType()));
View Full Code Here

    addFlowElement(conversion, selectPeopleUserTask, true);
    processElements.put(SELECT_PEOPLE_USER_TASK, selectPeopleUserTask);
   
    // TODO: work out form such that it can be used in Activiti Explorer, ie. add correct form properties
    // The following is just a a bit of a dummy form property
    FormProperty feedbackProvidersProperty = new FormProperty();
    feedbackProvidersProperty.setId(VARIABLE_FEEDBACK_PROVIDERS);
    feedbackProvidersProperty.setName("Who needs to provide feedback?");
    feedbackProvidersProperty.setRequired(true);
    feedbackProvidersProperty.setType("string"); // TODO: we need some kind of 'people' property type here
   
    selectPeopleUserTask.setFormProperties(Arrays.asList(feedbackProvidersProperty));
   
    // When the list of feedback providers is fixed up front, we need to add a script listener
    // that injects these variables into the process (instead of having it provided by the end user in a form)
View Full Code Here

        formDefinition.addFormProperty(reason);

        List<FormProperty> properties = converter.convertProperties(formDefinition);
        assertTrue(properties.size() == 2);

        FormProperty firstProperty = properties.get(0);
        assertNotNull(firstProperty);
        assertEquals("Approval", firstProperty.getName());
        assertEquals("enum", firstProperty.getType());

        // Assert the values are set
        List<FormValue> values = firstProperty.getFormValues();
        assertTrue(values.size() == 2);

        FormValue firstValue = values.get(0);
        assertEquals("Approve", firstValue.getName());
        assertEquals("true", firstValue.getId());

        FormValue secondValue = values.get(1);
        assertEquals("Reject", secondValue.getName());
        assertEquals("false", secondValue.getId());

        // Now confirm the second property, a non list property, is well formed as well.
        FormProperty secondProperty = properties.get(1);
        assertNotNull(secondProperty);
        assertTrue(secondProperty.getFormValues().isEmpty());
        assertEquals("Reason", secondProperty.getName());
        assertEquals("string", secondProperty.getType());
    }
View Full Code Here

 
  public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
   
    if (parentElement instanceof UserTask == false && parentElement instanceof StartEvent == false) return;
   
    FormProperty property = new FormProperty();
    BpmnXMLUtil.addXMLLocation(property, xtr);
    property.setId(xtr.getAttributeValue(null, ATTRIBUTE_FORM_ID));
    property.setName(xtr.getAttributeValue(null, ATTRIBUTE_FORM_NAME));
    property.setType(xtr.getAttributeValue(null, ATTRIBUTE_FORM_TYPE));
    property.setVariable(xtr.getAttributeValue(null, ATTRIBUTE_FORM_VARIABLE));
    property.setExpression(xtr.getAttributeValue(null, ATTRIBUTE_FORM_EXPRESSION));
    property.setDefaultExpression(xtr.getAttributeValue(null, ATTRIBUTE_FORM_DEFAULT));
    property.setDatePattern(xtr.getAttributeValue(null, ATTRIBUTE_FORM_DATEPATTERN));
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_FORM_REQUIRED))) {
      property.setRequired(Boolean.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_FORM_REQUIRED)));
    }
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_FORM_READABLE))) {
      property.setReadable(Boolean.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_FORM_READABLE)));
    }
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_FORM_WRITABLE))) {
      property.setWriteable(Boolean.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_FORM_WRITABLE)));
    }
   
    boolean readyWithFormProperty = false;
    try {
      while (readyWithFormProperty == false && xtr.hasNext()) {
        xtr.next();
        if (xtr.isStartElement() && ELEMENT_VALUE.equalsIgnoreCase(xtr.getLocalName())) {
          FormValue value = new FormValue();
          BpmnXMLUtil.addXMLLocation(value, xtr);
          value.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID));
          value.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
          property.getFormValues().add(value);

        } else if (xtr.isEndElement() && getElementName().equalsIgnoreCase(xtr.getLocalName())) {
          readyWithFormProperty = true;
        }
      }
View Full Code Here

    assertTrue(userTask.getCandidateGroups().contains("management"));
    assertTrue(userTask.getCandidateGroups().contains("sales"));
   
    List<FormProperty> formProperties = userTask.getFormProperties();
    assertEquals(2, formProperties.size());
    FormProperty formProperty = formProperties.get(0);
    assertEquals("formId", formProperty.getId());
    assertEquals("formName", formProperty.getName());
    assertEquals("string", formProperty.getType());
    assertEquals("variable", formProperty.getVariable());
    assertEquals("${expression}", formProperty.getExpression());
    formProperty = formProperties.get(1);
    assertEquals("formId2", formProperty.getId());
    assertEquals("anotherName", formProperty.getName());
    assertEquals("long", formProperty.getType());
    assertTrue(StringUtils.isEmpty(formProperty.getVariable()));
    assertTrue(StringUtils.isEmpty(formProperty.getExpression()));
   
    List<ActivitiListener> listeners = userTask.getTaskListeners();
    assertEquals(3, listeners.size());
    ActivitiListener listener = (ActivitiListener) listeners.get(0);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType()));
View Full Code Here

            String readable = item.getText(8);
            String writeable = item.getText(9);
            String formValues = item.getText(10);
            if(id != null && id.length() > 0) {
             
              FormProperty newFormProperty = new FormProperty();
              newFormProperty.setId(id);
              newFormProperty.setName(name);
              newFormProperty.setType(type);
              newFormProperty.setExpression(expression);
              newFormProperty.setVariable(variable);
              newFormProperty.setDefaultExpression(defaultExpression);
              newFormProperty.setDatePattern(datePattern);
              if(StringUtils.isNotEmpty(required)) {
                newFormProperty.setRequired(Boolean.valueOf(required.toLowerCase()));
              }
              if(StringUtils.isNotEmpty(readable)) {
                newFormProperty.setReadable(Boolean.valueOf(readable.toLowerCase()));
              }
              if(StringUtils.isNotEmpty(writeable)) {
                newFormProperty.setWriteable(Boolean.valueOf(writeable.toLowerCase()));
              }
             
              List<FormValue> formValueList = new ArrayList<FormValue>();
              if(formValues != null && formValues.length() > 0) {
                String[] formValueArray = formValues.split(";");
                if(formValueArray != null) {
                  for(String formValue : formValueArray) {
                    FormValue formValueObj = new FormValue();
                    formValueObj.setId(formValue.substring(0, formValue.lastIndexOf(":")));
                    formValueObj.setName(formValue.substring(formValue.lastIndexOf(":") + 1));
                    formValueList.add(formValueObj);
                  }
                }
              }
              newFormProperty.getFormValues().addAll(formValueList);
             
              newFormList.add(newFormProperty);
            }
          }
          setFormProperties(bo, newFormList);
View Full Code Here

TOP

Related Classes of org.activiti.bpmn.model.FormProperty

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.