use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-dmn-model by camunda.
the class ExtensionElementsImpl method addExtensionElement.
public <T extends ModelElementInstance> T addExtensionElement(Class<T> extensionElementClass) {
ModelElementInstance extensionElement = modelInstance.newInstance(extensionElementClass);
addChildElement(extensionElement);
return extensionElementClass.cast(extensionElement);
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-dmn-model by camunda.
the class ExtensionElementsImpl method addExtensionElement.
public ModelElementInstance addExtensionElement(String namespaceUri, String localName) {
ModelElementType extensionElementType = modelInstance.registerGenericType(namespaceUri, localName);
ModelElementInstance extensionElement = extensionElementType.newInstance(modelInstance);
addChildElement(extensionElement);
return extensionElement;
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-cmmn-model by camunda.
the class SimpleTest method shouldGetElements.
@Test
@CmmnModelResource
public void shouldGetElements() {
ModelElementInstance modelElementById = cmmnModelInstance.getModelElementById("Case_1");
assertThat(modelElementById).isNotNull();
Collection<Case> caseElements = cmmnModelInstance.getDefinitions().getCases();
assertThat(caseElements).hasSize(1);
Case caseElement = caseElements.iterator().next();
assertThat(caseElement.getId()).isEqualTo("Case_1");
assertThat(caseElement.getName()).isNull();
CasePlanModel casePlanModel = caseElement.getCasePlanModel();
assertThat(casePlanModel).isNotNull();
assertThat(casePlanModel.getId()).isEqualTo("CasePlanModel_1");
Collection<PlanItemDefinition> planItemDefinitions = casePlanModel.getPlanItemDefinitions();
assertThat(planItemDefinitions).hasSize(1);
PlanItemDefinition planItemDefinition = planItemDefinitions.iterator().next();
assertThat(planItemDefinition).isInstanceOf(HumanTask.class);
assertThat(planItemDefinition.getId()).isEqualTo("HumanTask_1");
assertThat(planItemDefinition.getName()).isEqualTo("A HumanTask");
Collection<PlanItem> planItems = casePlanModel.getPlanItems();
PlanItem planItem = planItems.iterator().next();
assertThat(planItem.getId()).isEqualTo("PI_HumanTask_1");
assertThat(planItem.getDefinition()).isEqualTo(planItemDefinition);
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-xml-model by camunda.
the class ElementReferenceImpl method setReferenceTargetElement.
public void setReferenceTargetElement(ModelElementInstanceImpl referenceSourceParentElement, Target referenceTargetElement) {
ModelInstanceImpl modelInstance = referenceSourceParentElement.getModelInstance();
String identifier = referenceTargetAttribute.getValue(referenceTargetElement);
ModelElementInstance existingElement = modelInstance.getModelElementById(identifier);
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 {
Source referenceSourceElement = modelInstance.newInstance(getReferenceSourceElementType());
setReferenceSource(referenceSourceParentElement, referenceSourceElement);
setReferenceIdentifier(referenceSourceElement, identifier);
}
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-xml-model by camunda.
the class IdsElementReferenceCollectionImpl method referencedElementRemoved.
@Override
public void referencedElementRemoved(ModelElementInstance referenceTargetElement, Object referenceIdentifier) {
for (ModelElementInstance referenceSourceElement : findReferenceSourceElements(referenceTargetElement)) {
List<String> referenceIdentifiers = getReferenceIdentifiers(referenceSourceElement);
if (referenceIdentifiers.contains(referenceIdentifier)) {
if (referenceIdentifiers.size() == 1) {
// remove whole element
removeReference(referenceSourceElement, referenceTargetElement);
} else {
// remove only single identifier
referenceIdentifiers.remove(referenceIdentifier);
setReferenceIdentifiers(referenceSourceElement, referenceIdentifiers);
}
}
}
}
Aggregations