• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ModelElementInstance类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.camunda.bpm.model.xml.instance.ModelElementInstance的典型用法代码示例。如果您正苦于以下问题:Java ModelElementInstance类的具体用法?Java ModelElementInstance怎么用?Java ModelElementInstance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ModelElementInstance类属于org.camunda.bpm.model.xml.instance包,在下文中一共展示了ModelElementInstance类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: starting

import org.camunda.bpm.model.xml.instance.ModelElementInstance; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected void starting(Description description) {
  String className = description.getClassName();
  assertThat(className).endsWith("Test");
  className = className.substring(0, className.length() - "Test".length());
  Class<? extends ModelElementInstance> instanceClass;
  try {
    instanceClass = (Class<? extends ModelElementInstance>) Class.forName(className);
  } catch (ClassNotFoundException e) {
    throw new RuntimeException(e);
  }
  modelInstance = Dmn.createEmptyModel();
  model = modelInstance.getModel();
  modelElementType = model.getType(instanceClass);
}
 
开发者ID:camunda,项目名称:camunda-dmn-model,代码行数:17,代码来源:GetDmnModelElementTypeRule.java


示例2: handleEvent

import org.camunda.bpm.model.xml.instance.ModelElementInstance; //导入依赖的package包/类
/**
 * Events aren't reported like SequenceFlows and Activities, so we need
 * special handling. If a sequence flow has an event as the source or the
 * target, we add it to the coverage. It's pretty straight forward if a
 * sequence flow is active, then it's source has been covered anyway and it
 * will most definitely arrive at its target.
 * 
 * @param transitionId
 * @param processDefinition
 * @param repositoryService
 */
private void handleEvent(String transitionId, ProcessDefinition processDefinition,
        RepositoryService repositoryService) {

    final BpmnModelInstance modelInstance = repositoryService.getBpmnModelInstance(processDefinition.getId());

    final ModelElementInstance modelElement = modelInstance.getModelElementById(transitionId);
    if (modelElement.getElementType().getInstanceType() == SequenceFlow.class) {

        final SequenceFlow sequenceFlow = (SequenceFlow) modelElement;

        // If there is an event at the sequence flow source add it to the
        // coverage
        final FlowNode source = sequenceFlow.getSource();
        addEventToCoverage(processDefinition, source);

        // If there is an event at the sequence flow target add it to the
        // coverage
        final FlowNode target = sequenceFlow.getTarget();
        addEventToCoverage(processDefinition, target);

    }

}
 
开发者ID:camunda,项目名称:camunda-bpm-process-test-coverage,代码行数:35,代码来源:PathCoverageExecutionListener.java


示例3: updateAfterReplacement

import org.camunda.bpm.model.xml.instance.ModelElementInstance; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public void updateAfterReplacement() {
  super.updateAfterReplacement();
  Collection<Reference> incomingReferences = getIncomingReferencesByType(SequenceFlow.class);
  for (Reference<?> reference : incomingReferences) {
    for (ModelElementInstance sourceElement : reference.findReferenceSourceElements(this)) {
      String referenceIdentifier = reference.getReferenceIdentifier(sourceElement);

      if (referenceIdentifier != null && referenceIdentifier.equals(getId()) && reference instanceof AttributeReference) {
        String attributeName = ((AttributeReference) reference).getReferenceSourceAttribute().getAttributeName();
        if (attributeName.equals(BPMN_ATTRIBUTE_SOURCE_REF)) {
          getOutgoing().add((SequenceFlow) sourceElement);
        }
        else if (attributeName.equals(BPMN_ATTRIBUTE_TARGET_REF)) {
          getIncoming().add((SequenceFlow) sourceElement);
        }
      }
    }

  }
}
 
开发者ID:camunda,项目名称:camunda-bpmn-model,代码行数:22,代码来源:FlowNodeImpl.java


示例4: performAddOperation

import org.camunda.bpm.model.xml.instance.ModelElementInstance; //导入依赖的package包/类
protected void performAddOperation(ModelElementInstanceImpl referenceSourceParentElement, Target referenceTargetElement) {
  ModelInstanceImpl modelInstance = referenceSourceParentElement.getModelInstance();
  String referenceTargetIdentifier = referenceTargetAttribute.getValue(referenceTargetElement);
  ModelElementInstance existingElement = modelInstance.getModelElementById(referenceTargetIdentifier);

  if (existingElement == null || !existingElement.equals(referenceTargetElement)) {
    throw new ModelReferenceException("Cannot create reference to model element " + referenceTargetElement
      +": element is not part of model. Please connect element to the model first.");
  }
  else {
    Collection<Source> referenceSourceElements = referenceSourceCollection.get(referenceSourceParentElement);
    Source referenceSourceElement = modelInstance.newInstance(referenceSourceType);
    referenceSourceElements.add(referenceSourceElement);
    setReferenceIdentifier(referenceSourceElement, referenceTargetIdentifier);
  }
}
 
开发者ID:camunda,项目名称:camunda-xml-model,代码行数:17,代码来源:ElementReferenceCollectionImpl.java


示例5: testCreateEmptyProcess

import org.camunda.bpm.model.xml.instance.ModelElementInstance; //导入依赖的package包/类
@Test
public void testCreateEmptyProcess() {
  modelInstance = Bpmn.createProcess()
    .done();

  Definitions definitions = modelInstance.getDefinitions();
  assertThat(definitions).isNotNull();
  assertThat(definitions.getTargetNamespace()).isEqualTo(BPMN20_NS);

  Collection<ModelElementInstance> processes = modelInstance.getModelElementsByType(processType);
  assertThat(processes)
    .hasSize(1);

  Process process = (Process) processes.iterator().next();
  assertThat(process.getId()).isNotNull();
}
 
开发者ID:camunda,项目名称:camunda-bpmn-model,代码行数:17,代码来源:ProcessBuilderTest.java


示例6: getReferenceIdentifier

import org.camunda.bpm.model.xml.instance.ModelElementInstance; //导入依赖的package包/类
@Override
public String getReferenceIdentifier(ModelElementInstance referenceSourceElement) {
  // TODO: implement something more robust (CAM-4028)
  String identifier = referenceSourceElement.getAttributeValue("href");
  if (identifier != null) {
    String[] parts = identifier.split("#");
    if (parts.length > 1) {
      return parts[parts.length - 1];
    }
    else {
      return parts[0];
    }
  }
  else {
    return null;
  }
}
 
开发者ID:camunda,项目名称:camunda-xml-model,代码行数:18,代码来源:UriElementReferenceImpl.java


示例7: validate

import org.camunda.bpm.model.xml.instance.ModelElementInstance; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public ValidationResults validate() {

  ValidationResultsCollectorImpl resultsCollector = new ValidationResultsCollectorImpl();

  for (ModelElementValidator validator : validators) {

    Class<? extends ModelElementInstance> elementType = validator.getElementType();
    Collection<? extends ModelElementInstance> modelElementsByType = modelInstanceImpl.getModelElementsByType(elementType);

    for (ModelElementInstance element : modelElementsByType) {

      resultsCollector.setCurrentElement(element);

      try {
        validator.validate(element, resultsCollector);
      }
      catch(RuntimeException e) {
        throw new RuntimeException("Validator " + validator + " threw an exception while validating "+element, e);
      }
    }

  }

  return resultsCollector.getResults();
}
 
开发者ID:camunda,项目名称:camunda-xml-model,代码行数:27,代码来源:ModelInstanceValidator.java


示例8: replaceChildElement

import org.camunda.bpm.model.xml.instance.ModelElementInstance; //导入依赖的package包/类
public void replaceChildElement(ModelElementInstance existingChild, ModelElementInstance newChild) {
  DomElement existingChildDomElement = existingChild.getDomElement();
  DomElement newChildDomElement = newChild.getDomElement();

  // unlink (remove all references) of child elements
  ((ModelElementInstanceImpl) existingChild).unlinkAllChildReferences();

  // update incoming references from old to new child element
  updateIncomingReferences(existingChild, newChild);

  // replace the existing child with the new child in the DOM
  domElement.replaceChild(newChildDomElement, existingChildDomElement);

  // execute after replacement updates
  newChild.updateAfterReplacement();
}
 
开发者ID:camunda,项目名称:camunda-xml-model,代码行数:17,代码来源:ModelElementInstanceImpl.java


示例9: updateIncomingReferences

import org.camunda.bpm.model.xml.instance.ModelElementInstance; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void updateIncomingReferences(ModelElementInstance oldInstance, ModelElementInstance newInstance) {
  String oldId = oldInstance.getAttributeValue("id");
  String newId = newInstance.getAttributeValue("id");

  if (oldId == null || newId == null) {
    return;
  }

  Collection<Attribute<?>> attributes = ((ModelElementTypeImpl) oldInstance.getElementType()).getAllAttributes();
  for (Attribute<?> attribute : attributes) {
    if (attribute.isIdAttribute()) {
      for (Reference<?> incomingReference : attribute.getIncomingReferences()) {
        ((ReferenceImpl<ModelElementInstance>) incomingReference).referencedElementUpdated(newInstance, oldId, newId);
      }
    }
  }

}
 
开发者ID:camunda,项目名称:camunda-xml-model,代码行数:20,代码来源:ModelElementInstanceImpl.java


示例10: getReferenceTargetElement

import org.camunda.bpm.model.xml.instance.ModelElementInstance; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Target getReferenceTargetElement(ModelElementInstanceImpl referenceSourceParentElement) {
  Source referenceSource = getReferenceSource(referenceSourceParentElement);
  if (referenceSource != null) {
    String identifier = getReferenceIdentifier(referenceSource);
    ModelElementInstance referenceTargetElement = referenceSourceParentElement.getModelInstance().getModelElementById(identifier);
    if (referenceTargetElement != null) {
      return (Target) referenceTargetElement;
    }
    else {
      throw new ModelException("Unable to find a model element instance for id " + identifier);
    }
  }
  else {
    return null;
  }
}
 
开发者ID:camunda,项目名称:camunda-xml-model,代码行数:18,代码来源:ElementReferenceImpl.java


示例11: findElementToInsertAfter

import org.camunda.bpm.model.xml.instance.ModelElementInstance; //导入依赖的package包/类
/**
 * Returns the element after which the new element should be inserted in the DOM document.
 *
 * @param elementToInsert  the new element to insert
 * @return the element to insert after or null
 */
private ModelElementInstance findElementToInsertAfter(ModelElementInstance elementToInsert) {
  List<ModelElementType> childElementTypes = elementType.getAllChildElementTypes();
  List<DomElement> childDomElements = domElement.getChildElements();
  Collection<ModelElementInstance> childElements = ModelUtil.getModelElementCollection(childDomElements, modelInstance);

  ModelElementInstance insertAfterElement = null;
  int newElementTypeIndex = ModelUtil.getIndexOfElementType(elementToInsert, childElementTypes);
  for (ModelElementInstance childElement : childElements) {
    int childElementTypeIndex = ModelUtil.getIndexOfElementType(childElement, childElementTypes);
    if (newElementTypeIndex >= childElementTypeIndex) {
      insertAfterElement = childElement;
    }
    else {
      break;
    }
  }
  return insertAfterElement;
}
 
开发者ID:camunda,项目名称:camunda-xml-model,代码行数:25,代码来源:ModelElementInstanceImpl.java


示例12: getReferenceTargetElement

import org.camunda.bpm.model.xml.instance.ModelElementInstance; //导入依赖的package包/类
/**
 * Get the reference target model element instance
 *
 * @param referenceSourceElement the reference source model element instance
 * @return the reference target model element instance or null if not set
 */
@SuppressWarnings("unchecked")
public T getReferenceTargetElement(ModelElementInstance referenceSourceElement) {
  String identifier = getReferenceIdentifier(referenceSourceElement);
  ModelElementInstance referenceTargetElement = referenceSourceElement.getModelInstance().getModelElementById(identifier);
  if (referenceTargetElement != null) {
    try {
      return (T) referenceTargetElement;

    } catch(ClassCastException e) {
      throw new ModelReferenceException("Element " + referenceSourceElement + " references element " + referenceTargetElement + " of wrong type. "
        + "Expecting " + referenceTargetAttribute.getOwningElementType() + " got " + referenceTargetElement.getElementType());
    }
  }
  else {
    return null;
  }
}
 
开发者ID:camunda,项目名称:camunda-xml-model,代码行数:24,代码来源:ReferenceImpl.java


示例13: testModelApiUtf8Bug

import org.camunda.bpm.model.xml.instance.ModelElementInstance; //导入依赖的package包/类
@Test
public void testModelApiUtf8Bug() throws UnsupportedEncodingException {
  BpmnModelInstance modelInstance = Bpmn.readModelFromStream(this.getClass().getResourceAsStream("/umlauts.bpmn"));

  Collection<ModelElementInstance> serviceTasks = modelInstance.getModelElementsByType(modelInstance.getModel().getType(ServiceTask.class));
  assertEquals(1, serviceTasks.size());
  ServiceTask serviceTask = (ServiceTask) serviceTasks.iterator().next();
  serviceTask.setCamundaExpression("#{true}");

  String xmlString = Bpmn.convertToString(modelInstance);
  org.camunda.bpm.engine.repository.Deployment deployment = processEngine().getRepositoryService().createDeployment() //
      .addInputStream("umlauts.bpmn", new ByteArrayInputStream(xmlString.getBytes("UTF-8"))).deploy();

  processEngine().getRepositoryService().deleteDeployment(deployment.getId(), true);
}
 
开发者ID:camunda-consulting,项目名称:camunda-util-demo-data-generator,代码行数:16,代码来源:DemoDataGeneratorTest.java


示例14: buildTask

import org.camunda.bpm.model.xml.instance.ModelElementInstance; //导入依赖的package包/类
@Override
public AbstractTaskBuilder buildTask(AbstractFlowNodeBuilder builder, Map<String, Object> taskData)
{
    final AbstractTaskBuilder taskBuilder = super.buildTask(builder, taskData);

    if (! (taskBuilder instanceof ServiceTaskBuilder)) {
        throw new RuntimeException("only service tasks are supported");
    }

    ServiceTaskBuilder serviceTaskBuilder = (ServiceTaskBuilder) taskBuilder;

    final String taskType = (String) taskData.get("type");
    final Integer retries = (Integer) taskData.get("retries");

    final ServiceTask serviceTask = serviceTaskBuilder.getElement();
    final ExtensionElements extensionElements = serviceTask.getModelInstance().newInstance(ExtensionElements.class);

    final ModelElementInstance taskDefinition = extensionElements.addExtensionElement(TNGP_NAMESPACE, TASK_DEFINITION_ELEMENT);

    taskDefinition.setAttributeValue(TASK_TYPE_ATTRIBUTE, taskType);

    if (retries != null)
    {
        taskDefinition.setAttributeValue(TASK_RETRIES_ATTRIBUTE, String.valueOf(retries));
    }

    serviceTask.setExtensionElements(extensionElements);

    return serviceTaskBuilder;
}
 
开发者ID:sdorokhova,项目名称:simple-workflow,代码行数:31,代码来源:ZeebeTaskFactory.java


示例15: testSimpleModel

import org.camunda.bpm.model.xml.instance.ModelElementInstance; //导入依赖的package包/类
@Test
public void testSimpleModel() throws FileNotFoundException {

    final BpmnModelInstance modelInstance = transformer.transform(ZeebeTransformerTest.class.getResourceAsStream(MODEL_FILENAME));

    ServiceTask serviceTask = modelInstance.getModelElementById("TASK_1");

    final ExtensionElements extensionElements = serviceTask.getExtensionElements();
    assertNotNull(extensionElements);

    List<ModelElementInstance> elements = new ArrayList<ModelElementInstance>(extensionElements.getElements());
    assertEquals(1, elements.size());

    ModelElementInstance taskDefinition = elements.get(0);
    assertEquals(ZeebeTaskFactory.TNGP_NAMESPACE, taskDefinition.getDomElement().getNamespaceURI().toString());
    assertEquals("someType", taskDefinition.getAttributeValue("type"));
    assertTrue(taskDefinition.getDomElement().hasAttribute("retries"));
    assertEquals("3", taskDefinition.getAttributeValue("retries"));

    ServiceTask serviceTask2 = modelInstance.getModelElementById("TASK_2");

    elements = new ArrayList<ModelElementInstance>(serviceTask2.getExtensionElements().getElements());
    assertEquals(1, elements.size());

    taskDefinition = elements.get(0);
    assertEquals(ZeebeTaskFactory.TNGP_NAMESPACE, taskDefinition.getDomElement().getNamespaceURI().toString());
    assertEquals("someOtherType", taskDefinition.getAttributeValue("type"));
    assertFalse(taskDefinition.getDomElement().hasAttribute("retries"));

}
 
开发者ID:sdorokhova,项目名称:simple-workflow,代码行数:31,代码来源:ZeebeTransformerTest.java


示例16: validateUserTasks

import org.camunda.bpm.model.xml.instance.ModelElementInstance; //导入依赖的package包/类
@Test
public void validateUserTasks() {
    BpmnModelInstance modelInstance = Bpmn.readModelFromFile(BPMN_FILE);
    ModelElementType taskType = modelInstance.getModel().getType(Task.class);
    Collection<ModelElementInstance> taskInstances =
            modelInstance.getModelElementsByType(taskType);
    for (ModelElementInstance task : taskInstances) {
        if (task instanceof UserTaskImpl) {
            UserTaskImpl userTask = (UserTaskImpl) task;
            System.out.println(userTask.getId() + "/" + userTask.getName());
        }
    }
}
 
开发者ID:FrVaBe,项目名称:camunda,代码行数:14,代码来源:BpmnValidationTest.java


示例17: validateServiceTasks

import org.camunda.bpm.model.xml.instance.ModelElementInstance; //导入依赖的package包/类
@Test
public void validateServiceTasks() {
    BpmnModelInstance modelInstance = Bpmn.readModelFromFile(BPMN_FILE);
    ModelElementType taskType = modelInstance.getModel().getType(Task.class);
    Collection<ModelElementInstance> taskInstances =
            modelInstance.getModelElementsByType(taskType);
    for (ModelElementInstance task : taskInstances) {
        if (task instanceof ServiceTaskImpl) {
            ServiceTaskImpl serviceTask = (ServiceTaskImpl) task;
            System.out.println(serviceTask.getId() + " / " + serviceTask.getName() + " / "
                    + serviceTask.getCamundaClass());

        }
    }
}
 
开发者ID:FrVaBe,项目名称:camunda,代码行数:16,代码来源:BpmnValidationTest.java


示例18: filterByType

import org.camunda.bpm.model.xml.instance.ModelElementInstance; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <V extends ModelElementInstance> Query<V> filterByType(Class<V> elementClass) {
  List<V> filtered = new ArrayList<V>();
  for (T instance : collection) {
    if (elementClass.isAssignableFrom(instance.getClass())) {
      filtered.add((V) instance);
    }
  }
  return new QueryImpl<V>(filtered);
}
 
开发者ID:camunda,项目名称:camunda-dmn-model,代码行数:11,代码来源:QueryImpl.java


示例19: assertElementIsEqualToId

import org.camunda.bpm.model.xml.instance.ModelElementInstance; //导入依赖的package包/类
protected void assertElementIsEqualToId(DmnModelElementInstance actualElement, String id) {
  assertThat(actualElement).isNotNull();

  ModelElementInstance expectedElement = modelInstance.getModelElementById(id);
  assertThat(expectedElement).isNotNull();

  assertThat(actualElement).isEqualTo(expectedElement);
}
 
开发者ID:camunda,项目名称:camunda-dmn-model,代码行数:9,代码来源:DmnModelTest.java


示例20: isExecutable

import org.camunda.bpm.model.xml.instance.ModelElementInstance; //导入依赖的package包/类
private boolean isExecutable(final ModelElementInstance node) {

        if (node == null) {
            return false;
        }

        if (node instanceof org.camunda.bpm.model.bpmn.instance.Process) {
            return ((org.camunda.bpm.model.bpmn.instance.Process) node).isExecutable();
        }

        return isExecutable(node.getParentElement());
    }
 
开发者ID:camunda,项目名称:camunda-bpm-process-test-coverage,代码行数:13,代码来源:ProcessCoverage.java



注:本文中的org.camunda.bpm.model.xml.instance.ModelElementInstance类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MathUtil类代码示例发布时间:2022-05-22
下一篇:
Java RefreshUserToGroupsMappingsResponsePBImpl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap