org.camunda.bpm.model.bpmn.instance.ConditionExpression Java Examples

The following examples show how to use org.camunda.bpm.model.bpmn.instance.ConditionExpression. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BpmnProcessModelCustomizer.java    From wecube-platform with Apache License 2.0 6 votes vote down vote up
protected void enhanceSequenceFlow(SequenceFlow sf) {
    FlowNode srcFlowNode = sf.getSource();

    if (sf.getConditionExpression() == null && "exclusiveGateway".equals(srcFlowNode.getElementType().getTypeName())
            && srcFlowNode.getOutgoing().size() >= 2) {
        String sfName = sf.getName();
        if (StringUtils.isBlank(sfName)) {
            log.warn("the name of squence flow {} is blank.", sf.getId());
            throw new BpmnCustomizationException(String.format("The name of sequence flow %s cannot be blank.", sf.getId()));
        }

        List<SubProcess> preSubProcesses = srcFlowNode.getPreviousNodes().filterByType(SubProcess.class).list();
        if (preSubProcesses.size() == 1) {
            log.debug("to add condition,sequenceFlowId={}", sf.getId());
            SubProcess preSubProcess = preSubProcesses.get(0);
            ConditionExpression okCon = sf.getModelInstance().newInstance(ConditionExpression.class);
            okCon.setType(FORMAL_EXPR_TYPE);
            okCon.setTextContent(
                    String.format("${ subProcRetCode_%s == '%s' }", preSubProcess.getId(), sfName.trim()));
            sf.builder().condition(okCon).done();
        }

        
    }
}
 
Example #2
Source File: ConditionExpressionImpl.java    From camunda-bpmn-model with Apache License 2.0 6 votes vote down vote up
public static void registerType(ModelBuilder modelBuilder) {
  ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(ConditionExpression.class, BPMN_ELEMENT_CONDITION_EXPRESSION)
    .namespaceUri(BPMN20_NS)
    .extendsType(FormalExpression.class)
    .instanceProvider(new ModelTypeInstanceProvider<ConditionExpression>() {
      public ConditionExpression newInstance(ModelTypeInstanceContext instanceContext) {
        return new ConditionExpressionImpl(instanceContext);
      }
    });

  typeAttribute = typeBuilder.stringAttribute(XSI_ATTRIBUTE_TYPE)
    .namespace(XSI_NS)
    .defaultValue("tFormalExpression")
    .build();

  camundaResourceAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_RESOURCE)
    .namespace(CAMUNDA_NS)
    .build();

  typeBuilder.build();
}
 
Example #3
Source File: ConditionExpressionImpl.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public static void registerType(ModelBuilder modelBuilder) {
  ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(ConditionExpression.class, BPMN_ELEMENT_CONDITION_EXPRESSION)
    .namespaceUri(BPMN20_NS)
    .extendsType(FormalExpression.class)
    .instanceProvider(new ModelTypeInstanceProvider<ConditionExpression>() {
      public ConditionExpression newInstance(ModelTypeInstanceContext instanceContext) {
        return new ConditionExpressionImpl(instanceContext);
      }
    });

  typeAttribute = typeBuilder.stringAttribute(XSI_ATTRIBUTE_TYPE)
    .namespace(XSI_NS)
    .defaultValue("tFormalExpression")
    .build();

  camundaResourceAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_RESOURCE)
    .namespace(CAMUNDA_NS)
    .build();

  typeBuilder.build();
}
 
Example #4
Source File: SequenceFlowImpl.java    From camunda-bpmn-model with Apache License 2.0 5 votes vote down vote up
public static void registerType(ModelBuilder modelBuilder) {
  ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(SequenceFlow.class, BPMN_ELEMENT_SEQUENCE_FLOW)
    .namespaceUri(BPMN20_NS)
    .extendsType(FlowElement.class)
    .instanceProvider(new ModelTypeInstanceProvider<SequenceFlow>() {
      public SequenceFlow newInstance(ModelTypeInstanceContext instanceContext) {
        return new SequenceFlowImpl(instanceContext);
      }
    });

  sourceRefAttribute = typeBuilder.stringAttribute(BPMN_ATTRIBUTE_SOURCE_REF)
    .required()
    .idAttributeReference(FlowNode.class)
    .build();

  targetRefAttribute = typeBuilder.stringAttribute(BPMN_ATTRIBUTE_TARGET_REF)
    .required()
    .idAttributeReference(FlowNode.class)
    .build();

  isImmediateAttribute = typeBuilder.booleanAttribute(BPMN_ATTRIBUTE_IS_IMMEDIATE)
    .build();

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

  conditionExpressionCollection = sequenceBuilder.element(ConditionExpression.class)
    .build();

  typeBuilder.build();
}
 
Example #5
Source File: SequenceFlowImpl.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void registerType(ModelBuilder modelBuilder) {
  ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(SequenceFlow.class, BPMN_ELEMENT_SEQUENCE_FLOW)
    .namespaceUri(BPMN20_NS)
    .extendsType(FlowElement.class)
    .instanceProvider(new ModelTypeInstanceProvider<SequenceFlow>() {
      public SequenceFlow newInstance(ModelTypeInstanceContext instanceContext) {
        return new SequenceFlowImpl(instanceContext);
      }
    });

  sourceRefAttribute = typeBuilder.stringAttribute(BPMN_ATTRIBUTE_SOURCE_REF)
    .required()
    .idAttributeReference(FlowNode.class)
    .build();

  targetRefAttribute = typeBuilder.stringAttribute(BPMN_ATTRIBUTE_TARGET_REF)
    .required()
    .idAttributeReference(FlowNode.class)
    .build();

  isImmediateAttribute = typeBuilder.booleanAttribute(BPMN_ATTRIBUTE_IS_IMMEDIATE)
    .build();

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

  conditionExpressionCollection = sequenceBuilder.element(ConditionExpression.class)
    .build();

  typeBuilder.build();
}
 
Example #6
Source File: SequenceFlowImpl.java    From camunda-bpmn-model with Apache License 2.0 4 votes vote down vote up
public ConditionExpression getConditionExpression() {
  return conditionExpressionCollection.getChild(this);
}
 
Example #7
Source File: SequenceFlowImpl.java    From camunda-bpmn-model with Apache License 2.0 4 votes vote down vote up
public void setConditionExpression(ConditionExpression conditionExpression) {
  conditionExpressionCollection.setChild(this, conditionExpression);
}
 
Example #8
Source File: SequenceFlowImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public ConditionExpression getConditionExpression() {
  return conditionExpressionCollection.getChild(this);
}
 
Example #9
Source File: SequenceFlowImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void setConditionExpression(ConditionExpression conditionExpression) {
  conditionExpressionCollection.setChild(this, conditionExpression);
}
 
Example #10
Source File: AbstractSequenceFlowBuilder.java    From camunda-bpmn-model with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the condition for this sequence flow.
 *
 * @param conditionExpression  the condition expression for this sequence flow
 * @return the builder object
 */
public B condition(ConditionExpression conditionExpression) {
  element.setConditionExpression(conditionExpression);
  return myself;
}
 
Example #11
Source File: AbstractSequenceFlowBuilder.java    From camunda-bpm-platform with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the condition for this sequence flow.
 *
 * @param conditionExpression  the condition expression for this sequence flow
 * @return the builder object
 */
public B condition(ConditionExpression conditionExpression) {
  element.setConditionExpression(conditionExpression);
  return myself;
}