org.camunda.bpm.model.cmmn.instance.CmmnElement Java Examples

The following examples show how to use org.camunda.bpm.model.cmmn.instance.CmmnElement. 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: HumanTaskItemHandler.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void initializeTaskListeners(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, TaskDefinition taskDefinition) {
  HumanTask humanTask = getDefinition(element);

  List<CamundaTaskListener> listeners = queryExtensionElementsByClass(humanTask, CamundaTaskListener.class);

  for (CamundaTaskListener listener : listeners) {
    TaskListener taskListener = initializeTaskListener(element, activity, context, listener);

    String eventName = listener.getCamundaEvent();
    if (eventName != null) {
      taskDefinition.addTaskListener(eventName, taskListener);

    } else {
      taskDefinition.addTaskListener(TaskListener.EVENTNAME_CREATE, taskListener);
      taskDefinition.addTaskListener(TaskListener.EVENTNAME_ASSIGNMENT, taskListener);
      taskDefinition.addTaskListener(TaskListener.EVENTNAME_COMPLETE, taskListener);
      taskDefinition.addTaskListener(TaskListener.EVENTNAME_UPDATE, taskListener);
      taskDefinition.addTaskListener(TaskListener.EVENTNAME_DELETE, taskListener);
    }
  }
}
 
Example #2
Source File: ItemHandler.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void initializeExitCriterias(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
  Collection<Sentry> exitCriterias = getExitCriterias(element);

  if (!exitCriterias.isEmpty()) {
    CmmnActivity parent = activity.getParent();
    if (parent != null) {
      for (Sentry sentry : exitCriterias) {
        String sentryId = sentry.getId();
        CmmnSentryDeclaration sentryDeclaration = parent.getSentry(sentryId);
        if (sentryDeclaration != null) {
          activity.addExitCriteria(sentryDeclaration);
        }
      }
    }
  }
}
 
Example #3
Source File: ApplicabilityRuleImpl.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(ApplicabilityRule.class, CMMN_ELEMENT_APPLICABILITY_RULE)
      .namespaceUri(CMMN11_NS)
      .extendsType(CmmnElement.class)
      .instanceProvider(new ModelTypeInstanceProvider<ApplicabilityRule>() {
        public ApplicabilityRule newInstance(ModelTypeInstanceContext instanceContext) {
          return new ApplicabilityRuleImpl(instanceContext);
        }
      });

  nameAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_NAME)
      .build();

  contextRefAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_CONTEXT_REF)
      .idAttributeReference(CaseFileItem.class)
      .build();

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

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

  typeBuilder.build();
}
 
Example #4
Source File: ItemHandler.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void initializeRepetitionRule(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
  PlanItemControl itemControl = getItemControl(element);
  PlanItemControl defaultControl = getDefaultControl(element);

  RepetitionRule repetitionRule = null;
  if (itemControl != null) {
    repetitionRule = itemControl.getRepetitionRule();
  }
  if (repetitionRule == null && defaultControl != null) {
    repetitionRule = defaultControl.getRepetitionRule();
  }

  if (repetitionRule != null) {
    ConditionExpression condition = repetitionRule.getCondition();
    CaseControlRule caseRule = initializeCaseControlRule(condition, context);
    activity.setProperty(PROPERTY_REPETITION_RULE, caseRule);

    List<String> events = Arrays.asList(TERMINATE, COMPLETE);
    String repeatOnStandardEvent = repetitionRule.getCamundaRepeatOnStandardEvent();
    if (repeatOnStandardEvent != null && !repeatOnStandardEvent.isEmpty()) {
      events = Arrays.asList(repeatOnStandardEvent);
    }
    activity.getProperties().set(CmmnProperties.REPEAT_ON_STANDARD_EVENTS, events);
  }
}
 
Example #5
Source File: ItemHandler.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected String getName(CmmnElement element) {
  String name = null;
  if (isPlanItem(element)) {
    PlanItem planItem = (PlanItem) element;
    name = planItem.getName();
  }

  if (name == null || name.isEmpty()) {
    PlanItemDefinition definition = getDefinition(element);
    if (definition != null) {
      name = definition.getName();
    }
  }

  return name;
}
 
Example #6
Source File: AssociationImpl.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(Association.class, CMMN_ELEMENT_ASSOCIATION)
    .namespaceUri(CMMN11_NS)
    .extendsType(Artifact.class)
    .instanceProvider(new ModelTypeInstanceProvider<Association>() {
      public Association newInstance(ModelTypeInstanceContext instanceContext) {
        return new AssociationImpl(instanceContext);
      }
    });

  sourceRefAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_SOURCE_REF)
    .idAttributeReference(CmmnElement.class)
    .build();

  targetRefAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_TARGET_REF)
    .idAttributeReference(CmmnElement.class)
    .build();

  associationDirectionAttribute = typeBuilder.enumAttribute(CMMN_ATTRIBUTE_ASSOCIATION_DIRECTION, AssociationDirection.class)
    .build();

  typeBuilder.build();
}
 
Example #7
Source File: ParameterMappingImpl.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(ParameterMapping.class, CMMN_ELEMENT_PARAMETER_MAPPING)
      .extendsType(CmmnElement.class)
      .namespaceUri(CMMN11_NS)
      .instanceProvider(new ModelTypeInstanceProvider<ParameterMapping>() {
        public ParameterMapping newInstance(ModelTypeInstanceContext instanceContext) {
          return new ParameterMappingImpl(instanceContext);
        }
      });

  sourceRefAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_SOURCE_REF)
      .idAttributeReference(Parameter.class)
      .build();

  targetRefAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_TARGET_REF)
      .idAttributeReference(Parameter.class)
      .build();

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

  transformationChild = sequenceBuilder.element(TransformationExpression.class)
      .build();

  typeBuilder.build();
}
 
Example #8
Source File: CallingTaskItemHandler.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void initializeCallableElement(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
  Deployment deployment = context.getDeployment();
  String deploymentId = null;
  if (deployment != null) {
    deploymentId = deployment.getId();
  }

  BaseCallableElement callableElement = createCallableElement();
  callableElement.setDeploymentId(deploymentId);

  // set callableElement on behavior
  CallingTaskActivityBehavior behavior = (CallingTaskActivityBehavior) activity.getActivityBehavior();
  behavior.setCallableElement(callableElement);

  // definition key
  initializeDefinitionKey(element, activity, context, callableElement);

  // binding
  initializeBinding(element, activity, context, callableElement);

  // version
  initializeVersion(element, activity, context, callableElement);

  // tenant-id
  initializeTenantId(element, activity, context, callableElement);
}
 
Example #9
Source File: ItemHandler.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void initializeVariableListeners(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
  PlanItemDefinition definition = getDefinition(element);

  List<CamundaVariableListener> listeners = queryExtensionElementsByClass(definition, CamundaVariableListener.class);

  for (CamundaVariableListener listener : listeners) {
    CaseVariableListener variableListener = initializeVariableListener(element, activity, context, listener);

    String eventName = listener.getCamundaEvent();
    if(eventName != null) {
      activity.addVariableListener(eventName, variableListener);

    } else {
      for (String event : DEFAULT_VARIABLE_EVENTS) {
        activity.addVariableListener(event, variableListener);
      }
    }
  }
}
 
Example #10
Source File: ItemHandler.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void initializeEntryCriterias(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
  Collection<Sentry> entryCriterias = getEntryCriterias(element);

  if (!entryCriterias.isEmpty()) {
    CmmnActivity parent = activity.getParent();
    if (parent != null) {
      for (Sentry sentry : entryCriterias) {
        String sentryId = sentry.getId();
        CmmnSentryDeclaration sentryDeclaration = parent.getSentry(sentryId);
        if (sentryDeclaration != null) {
          activity.addEntryCriteria(sentryDeclaration);
        }
      }
    }
  }
}
 
Example #11
Source File: SentryImpl.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(Sentry.class, CMMN_ELEMENT_SENTRY)
      .extendsType(CmmnElement.class)
      .namespaceUri(CMMN11_NS)
      .instanceProvider(new ModelTypeInstanceProvider<Sentry>() {
        public Sentry newInstance(ModelTypeInstanceContext instanceContext) {
          return new SentryImpl(instanceContext);
        }
      });

  nameAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_NAME)
      .build();

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

  onPartCollection = sequenceBuilder.elementCollection(OnPart.class)
      .build();

  ifPartChild = sequenceBuilder.element(IfPart.class)
      .build();

  typeBuilder.build();
}
 
Example #12
Source File: CaseFileImpl.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(CaseFile.class, CMMN_ELEMENT_CASE_FILE)
      .namespaceUri(CMMN11_NS)
      .extendsType(CmmnElement.class)
      .instanceProvider(new ModelTypeInstanceProvider<CaseFile>() {
        public CaseFile newInstance(ModelTypeInstanceContext instanceContext) {
          return new CaseFileImpl(instanceContext);
        }
      });

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

  caseFileItemCollection = sequenceBuilder.elementCollection(CaseFileItem.class)
      .build();

  typeBuilder.build();
}
 
Example #13
Source File: RequiredRuleImpl.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(RequiredRule.class, CMMN_ELEMENT_REQUIRED_RULE)
      .namespaceUri(CMMN11_NS)
      .extendsType(CmmnElement.class)
      .instanceProvider(new ModelTypeInstanceProvider<RequiredRule>() {
        public RequiredRule newInstance(ModelTypeInstanceContext instanceContext) {
          return new RequiredRuleImpl(instanceContext);
        }
      });

  nameAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_NAME)
      .build();

  contextRefAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_CONTEXT_REF)
      .idAttributeReference(CaseFileItem.class)
      .build();

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

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

  typeBuilder.build();
}
 
Example #14
Source File: ManualActivationRuleImpl.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(ManualActivationRule.class, CMMN_ELEMENT_MANUAL_ACTIVATION_RULE)
      .namespaceUri(CMMN11_NS)
      .extendsType(CmmnElement.class)
      .instanceProvider(new ModelTypeInstanceProvider<ManualActivationRule>() {
        public ManualActivationRule newInstance(ModelTypeInstanceContext instanceContext) {
          return new ManualActivationRuleImpl(instanceContext);
        }
      });

  nameAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_NAME)
      .build();

  contextRefAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_CONTEXT_REF)
      .idAttributeReference(CaseFileItem.class)
      .build();

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

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

  typeBuilder.build();
}
 
Example #15
Source File: PlanItemControlImpl.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(PlanItemControl.class, CMMN_ELEMENT_PLAN_ITEM_CONTROL)
      .namespaceUri(CMMN11_NS)
      .extendsType(CmmnElement.class)
      .instanceProvider(new ModelTypeInstanceProvider<PlanItemControl>() {
        public PlanItemControl newInstance(ModelTypeInstanceContext instanceContext) {
          return new PlanItemControlImpl(instanceContext);
        }
      });

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

  repetitionRuleChild = sequenceBuilder.element(RepetitionRule.class)
      .build();

  requiredRuleChild = sequenceBuilder.element(RequiredRule.class)
      .build();

  manualActivationRuleChild = sequenceBuilder.element(ManualActivationRule.class)
      .build();

  typeBuilder.build();
}
 
Example #16
Source File: ItemHandler.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected ExecutableScript initializeScript(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, CamundaScript script) {
  String language = script.getCamundaScriptFormat();
  String resource = script.getCamundaResource();
  String source = script.getTextContent();

  if (language == null) {
    language = ScriptingEngines.DEFAULT_SCRIPTING_LANGUAGE;
  }

  try {
    return ScriptUtil.getScript(language, source, resource, context.getExpressionManager());
  }
  catch (ProcessEngineException e) {
    // ignore
    return null;
  }
}
 
Example #17
Source File: IfPartImpl.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(IfPart.class, CMMN_ELEMENT_IF_PART)
      .namespaceUri(CMMN11_NS)
      .extendsType(CmmnElement.class)
      .instanceProvider(new ModelTypeInstanceProvider<IfPart>() {
        public IfPart newInstance(ModelTypeInstanceContext instanceContext) {
          return new IfPartImpl(instanceContext);
        }
      });

  contextRefAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_CONTEXT_REF)
      .idAttributeReference(CaseFileItem.class)
      .build();

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

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

  typeBuilder.build();
}
 
Example #18
Source File: HumanTaskItemHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void initializeTaskDefinitionName(CmmnElement element, TaskDefinition taskDefinition, CmmnHandlerContext context) {
  String name = getName(element);
  if (name == null) {
    HumanTask definition = getDefinition(element);
    name = definition.getName();
  }

  if (name != null) {
    ExpressionManager expressionManager = context.getExpressionManager();
    Expression nameExpression = expressionManager.createExpression(name);
    taskDefinition.setNameExpression(nameExpression);
  }

}
 
Example #19
Source File: ItemHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public CmmnActivity handleElement(CmmnElement element, CmmnHandlerContext context) {
  // create a new activity
  CmmnActivity newActivity = createActivity(element, context);

  // initialize activity
  initializeActivity(element, newActivity, context);

  return newActivity;
}
 
Example #20
Source File: HumanTaskItemHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void initializeTaskDefinitionFollowUpDate(CmmnElement element, TaskDefinition taskDefinition, CmmnHandlerContext context) {
  HumanTask definition = getDefinition(element);

  String followUpDate = definition.getCamundaFollowUpDate();
  if (followUpDate != null) {
    ExpressionManager expressionManager = context.getExpressionManager();
    Expression followUpDateExpression = expressionManager.createExpression(followUpDate);
    taskDefinition.setFollowUpDateExpression(followUpDateExpression);
  }
}
 
Example #21
Source File: ItemHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void initializeDescription(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
  String description = getDesciption(element);
  if (description == null) {
    description = getDocumentation(element);
  }
  activity.setProperty(PROPERTY_ACTIVITY_DESCRIPTION, description);
}
 
Example #22
Source File: DecisionTaskItemHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void initializeDecisionTableResultMapper(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
  DecisionTask decisionTask = getDefinition(element);
  DmnDecisionTaskActivityBehavior behavior = getActivityBehavior(activity);
  String mapper = decisionTask.getCamundaMapDecisionResult();
  DecisionResultMapper decisionResultMapper = getDecisionResultMapperForName(mapper);
  behavior.setDecisionTableResultMapper(decisionResultMapper);
}
 
Example #23
Source File: HumanTaskItemHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected TaskDefinition createTaskDefinition(CmmnElement element, CmmnHandlerContext context) {
  Deployment deployment = context.getDeployment();
  String deploymentId = deployment.getId();

  // at the moment a default task form handler is only supported,
  // custom task form handler are not supported.
  DefaultTaskFormHandler taskFormHandler = new DefaultTaskFormHandler();
  taskFormHandler.setDeploymentId(deploymentId);

  // create new taskDefinition
  TaskDefinition taskDefinition = new TaskDefinition(taskFormHandler);

  // the plan item id will be handled as taskDefinitionKey
  String taskDefinitionKey = element.getId();
  taskDefinition.setKey(taskDefinitionKey);

  // name
  initializeTaskDefinitionName(element, taskDefinition, context);
  // dueDate
  initializeTaskDefinitionDueDate(element, taskDefinition, context);
  // followUp
  initializeTaskDefinitionFollowUpDate(element, taskDefinition, context);
  // priority
  initializeTaskDefinitionPriority(element, taskDefinition, context);
  // assignee
  initializeTaskDefinitionAssignee(element, taskDefinition, context);
  // candidateUsers
  initializeTaskDefinitionCandidateUsers(element, taskDefinition, context);
  // candidateGroups
  initializeTaskDefinitionCandidateGroups(element, taskDefinition, context);
  // formKey
  initializeTaskDefinitionFormKey(element, taskDefinition, context);
  // description
  initializeTaskDescription(element, taskDefinition, context);

  return taskDefinition;
}
 
Example #24
Source File: HumanTaskItemHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void initializeTaskDefinitionFormKey(CmmnElement element, TaskDefinition taskDefinition, CmmnHandlerContext context) {
  HumanTask definition = getDefinition(element);

  String formKey = definition.getCamundaFormKey();
  if (formKey != null) {
    ExpressionManager expressionManager = context.getExpressionManager();
    Expression formKeyExpression = expressionManager.createExpression(formKey);
    taskDefinition.setFormKey(formKeyExpression);
  }
}
 
Example #25
Source File: ItemHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected CaseVariableListener initializeVariableListener(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, CamundaVariableListener listener) {
  Collection<CamundaField> fields = listener.getCamundaFields();
  List<FieldDeclaration> fieldDeclarations = initializeFieldDeclarations(element, activity, context, fields);

  ExpressionManager expressionManager = context.getExpressionManager();

  String className = listener.getCamundaClass();
  String expression = listener.getCamundaExpression();
  String delegateExpression = listener.getCamundaDelegateExpression();
  CamundaScript scriptElement = listener.getCamundaScript();

  CaseVariableListener variableListener = null;
  if (className != null) {
    variableListener = new ClassDelegateCaseVariableListener(className, fieldDeclarations);

  } else if (expression != null) {
    Expression expressionExp = expressionManager.createExpression(expression);
    variableListener = new ExpressionCaseVariableListener(expressionExp);

  } else if (delegateExpression != null) {
    Expression delegateExp = expressionManager.createExpression(delegateExpression);
    variableListener = new DelegateExpressionCaseVariableListener(delegateExp, fieldDeclarations);

  } else if (scriptElement != null) {
    ExecutableScript executableScript = initializeScript(element, activity, context, scriptElement);
    if (executableScript != null) {
      variableListener = new ScriptCaseVariableListener(executableScript);
    }
  }

  return variableListener;
}
 
Example #26
Source File: ItemHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void initializeActivityType(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
  PlanItemDefinition definition = getDefinition(element);

  String activityType = null;
  if (definition != null) {
    ModelElementType elementType = definition.getElementType();
    if (elementType != null) {
      activityType = elementType.getTypeName();
    }
  }

  activity.setProperty(PROPERTY_ACTIVITY_TYPE, activityType);
}
 
Example #27
Source File: PlanItemImpl.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(PlanItem.class, CMMN_ELEMENT_PLAN_ITEM)
      .namespaceUri(CMMN11_NS)
      .extendsType(CmmnElement.class)
      .instanceProvider(new ModelTypeInstanceProvider<PlanItem>() {
        public PlanItem newInstance(ModelTypeInstanceContext instanceContext) {
          return new PlanItemImpl(instanceContext);
        }
      });

  nameAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_NAME)
      .build();

  planItemDefinitionRefAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_DEFINITION_REF)
      .idAttributeReference(PlanItemDefinition.class)
      .build();

  entryCriteriaRefCollection = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_ENTRY_CRITERIA_REFS)
      .namespace(CMMN10_NS)
      .idAttributeReferenceCollection(Sentry.class, CmmnAttributeElementReferenceCollection.class)
      .build();

  exitCriteriaRefCollection = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_EXIT_CRITERIA_REFS)
      .namespace(CMMN10_NS)
      .idAttributeReferenceCollection(Sentry.class, CmmnAttributeElementReferenceCollection.class)
      .build();

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

  itemControlChild = sequenceBuilder.element(ItemControl.class)
      .build();

  entryCriterionCollection = sequenceBuilder.elementCollection(EntryCriterion.class)
      .build();

  exitCriterionCollection = sequenceBuilder.elementCollection(ExitCriterion.class)
      .build();

  typeBuilder.build();
}
 
Example #28
Source File: SentryHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected <V extends ModelElementInstance> List<V> queryExtensionElementsByClass(CmmnElement element, Class<V> cls) {
  ExtensionElements extensionElements = element.getExtensionElements();

  if (extensionElements != null) {
    Query<ModelElementInstance> query = extensionElements.getElementsQuery();
    return query.filterByType(cls).list();

  } else {
    return new ArrayList<V>();
  }
}
 
Example #29
Source File: ItemHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected CaseExecutionListener initializeCaseExecutionListener(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, CamundaCaseExecutionListener listener) {
  Collection<CamundaField> fields = listener.getCamundaFields();
  List<FieldDeclaration> fieldDeclarations = initializeFieldDeclarations(element, activity, context, fields);

  ExpressionManager expressionManager = context.getExpressionManager();

  CaseExecutionListener caseExecutionListener = null;

  String className = listener.getCamundaClass();
  String expression = listener.getCamundaExpression();
  String delegateExpression = listener.getCamundaDelegateExpression();
  CamundaScript scriptElement = listener.getCamundaScript();

  if (className != null) {
    caseExecutionListener = new ClassDelegateCaseExecutionListener(className, fieldDeclarations);

  } else if (expression != null) {
    Expression expressionExp = expressionManager.createExpression(expression);
    caseExecutionListener = new ExpressionCaseExecutionListener(expressionExp);

  } else if (delegateExpression != null) {
    Expression delegateExp = expressionManager.createExpression(delegateExpression);
    caseExecutionListener = new DelegateExpressionCaseExecutionListener(delegateExp, fieldDeclarations);

  } else if (scriptElement != null) {
    ExecutableScript executableScript = initializeScript(element, activity, context, scriptElement);
    if (executableScript != null) {
      caseExecutionListener = new ScriptCaseExecutionListener(executableScript);
    }
  }

  return caseExecutionListener;
}
 
Example #30
Source File: CriterionImpl.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(Criterion.class, CMMN_ELEMENT_CRITERION)
      .extendsType(CmmnElement.class)
      .namespaceUri(CMMN11_NS)
      .abstractType();

  nameAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_NAME)
      .build();

  sentryRefAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_SENTRY_REF)
      .idAttributeReference(Sentry.class)
      .build();

  typeBuilder.build();
}