public virtual bool removeChild(ModelElementInstance element) { ModelElementInstanceImpl childElement = (ModelElementInstanceImpl)getChild(element); ModelElementInstanceImpl elementInstanceImpl = (ModelElementInstanceImpl)element; return(elementInstanceImpl.removeChildElement(childElement)); }
public virtual void addChildElement(ModelElementInstance newChild) { ModelUtil.ensureInstanceOf(newChild, typeof(ModelElementInstanceImpl)); ModelElementInstance elementToInsertAfter = findElementToInsertAfter(newChild); insertElementAfter(newChild, elementToInsertAfter); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") private void updateIncomingReferences(org.camunda.bpm.model.xml.instance.ModelElementInstance oldInstance, org.camunda.bpm.model.xml.instance.ModelElementInstance newInstance) private void updateIncomingReferences(ModelElementInstance oldInstance, ModelElementInstance newInstance) { string oldId = oldInstance.getAttributeValue("id"); string newId = newInstance.getAttributeValue("id"); if (string.ReferenceEquals(oldId, null) || string.ReferenceEquals(newId, null)) { return; } //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Collection<org.camunda.bpm.model.xml.type.attribute.Attribute<?>> attributes = ((org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl) oldInstance.getElementType()).getAllAttributes(); ICollection <Attribute <object> > attributes = ((ModelElementTypeImpl)oldInstance.ElementType).AllAttributes; //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: for (org.camunda.bpm.model.xml.type.attribute.Attribute<?> attribute : attributes) foreach (Attribute <object> attribute in attributes) { if (attribute.IdAttribute) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: for (org.camunda.bpm.model.xml.type.reference.Reference<?> incomingReference : attribute.getIncomingReferences()) foreach (Reference <object> incomingReference in attribute.IncomingReferences) { ((ReferenceImpl <ModelElementInstance>)incomingReference).referencedElementUpdated(newInstance, oldId, newId); } } } }
/// <summary> /// Update the reference identifier /// </summary> /// <param name="referenceTargetElement"> the reference target model element instance </param> /// <param name="oldIdentifier"> the old reference identifier </param> /// <param name="newIdentifier"> the new reference identifier </param> public virtual void referencedElementUpdated(ModelElementInstance referenceTargetElement, string oldIdentifier, string newIdentifier) { foreach (ModelElementInstance referenceSourceElement in findReferenceSourceElements(referenceTargetElement)) { updateReference(referenceSourceElement, oldIdentifier, newIdentifier); } }
/// <summary> /// returns the value of the attribute. /// </summary> /// <returns> the value of the attribute. </returns> public virtual T getValue(ModelElementInstance modelElement) { string value; if (string.ReferenceEquals(namespaceUri, null)) { value = modelElement.getAttributeValue(attributeName); } else { value = modelElement.getAttributeValueNs(namespaceUri, attributeName); if (string.ReferenceEquals(value, null)) { string alternativeNamespace = owningElementType.Model.getAlternativeNamespace(namespaceUri); if (!string.ReferenceEquals(alternativeNamespace, null)) { value = modelElement.getAttributeValueNs(alternativeNamespace, attributeName); } } } // default value if (string.ReferenceEquals(value, null) && defaultValue != default(T)) { return(defaultValue); } else { return(convertXmlValueToModelValue(value)); } }
public virtual ModifiableBpmnModelInstance removeFlowNode(string flowNodeId) { FlowNode flowNode = getModelElementById(flowNodeId); ModelElementInstance scope = flowNode.ParentElement; foreach (SequenceFlow outgoingFlow in flowNode.Outgoing) { removeBpmnEdge(outgoingFlow); scope.removeChildElement(outgoingFlow); } foreach (SequenceFlow incomingFlow in flowNode.Incoming) { removeBpmnEdge(incomingFlow); scope.removeChildElement(incomingFlow); } ICollection <Association> associations = scope.getChildElementsByType(typeof(Association)); foreach (Association association in associations) { if (flowNode.Equals(association.Source) || flowNode.Equals(association.Target)) { removeBpmnEdge(association); scope.removeChildElement(association); } } removeBpmnShape(flowNode); scope.removeChildElement(flowNode); return(this); }
protected internal override void removeReference(ModelElementInstance referenceSourceElement, ModelElementInstance referenceTargetElement) { ModelElementInstance parentElement = referenceSourceElement.ParentElement; ICollection <Source> childElementCollection = referenceSourceCollection.get(parentElement); childElementCollection.remove(referenceSourceElement); }
public virtual bool removeChildElement(ModelElementInstance child) { ModelElementInstanceImpl childImpl = (ModelElementInstanceImpl)child; childImpl.unlinkAllReferences(); childImpl.unlinkAllChildReferences(); return(domElement.removeChild(child.DomElement)); }
public virtual ICollection <T> get(ModelElementInstance element) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.model.xml.impl.instance.ModelElementInstanceImpl modelElement = (org.camunda.bpm.model.xml.impl.instance.ModelElementInstanceImpl) element; ModelElementInstanceImpl modelElement = (ModelElementInstanceImpl)element; return(new CollectionAnonymousInnerClass(this, modelElement)); }
public virtual ModelElementInstance addExtensionElement(string namespaceUri, string localName) { ModelElementType extensionElementType = modelInstance.registerGenericType(namespaceUri, localName); ModelElementInstance extensionElement = extensionElementType.newInstance(modelInstance); addChildElement(extensionElement); return(extensionElement); }
public virtual T addExtensionElement <T>(Type extensionElementClass) where T : org.camunda.bpm.model.xml.instance.ModelElementInstance { extensionElementClass = typeof(T); ModelElementInstance extensionElement = modelInstance.newInstance(extensionElementClass); addChildElement(extensionElement); return(extensionElementClass.cast(extensionElement)); }
protected internal override void updateReference(ModelElementInstance referenceSourceElement, string oldIdentifier, string newIdentifier) { string referencingTextContent = getReferenceIdentifier(referenceSourceElement); if (!string.ReferenceEquals(oldIdentifier, null) && oldIdentifier.Equals(referencingTextContent)) { setReferenceIdentifier(referenceSourceElement, newIdentifier); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Override @SuppressWarnings("unchecked") protected void removeReference(org.camunda.bpm.model.xml.instance.ModelElementInstance referenceSourceElement, org.camunda.bpm.model.xml.instance.ModelElementInstance referenceTargetElement) protected internal override void removeReference(ModelElementInstance referenceSourceElement, ModelElementInstance referenceTargetElement) { string identifier = getReferenceIdentifier(referenceSourceElement); IList <string> references = StringUtil.splitListBySeparator(identifier, separator); string identifierToRemove = getTargetElementIdentifier((T)referenceTargetElement); references.Remove(identifierToRemove); identifier = StringUtil.joinList(references, separator); setReferenceIdentifier(referenceSourceElement, identifier); }
private void addExecutionListener(BaseElement element, string eventName) { ExtensionElements extensionElements = element.ModelInstance.newInstance(typeof(ExtensionElements)); ModelElementInstance executionListener = extensionElements.addExtensionElement(CAMUNDA_NS, "executionListener"); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: executionListener.setAttributeValueNs(CAMUNDA_NS, "class", typeof(ModelExecutionContextExecutionListener).FullName); executionListener.setAttributeValueNs(CAMUNDA_NS, "event", eventName); element.ExtensionElements = extensionElements; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void parseModel() public virtual void parseModel() { modelParser = new TestModelParser(); string testXml = this.GetType().Name + ".xml"; Stream testXmlAsStream = this.GetType().getResourceAsStream(testXml); modelInstance = modelParser.parseModelFromStream(testXmlAsStream); wanda = modelInstance.getModelElementById("wanda"); flipper = modelInstance.getModelElementById("flipper"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void getUniqueChildElementByNameNsForAlternativeNs() public virtual void getUniqueChildElementByNameNsForAlternativeNs() { ModelElementInstance hedwig = modelInstance.getModelElementById("hedwig"); assertThat(hedwig, @is(notNullValue())); ModelElementInstance childElementByNameNs = hedwig.getUniqueChildElementByNameNs(TestModelConstants.NEWER_NAMESPACE, "wings"); assertThat(childElementByNameNs, @is(notNullValue())); assertThat(childElementByNameNs.TextContent, @is("wusch")); }
public override bool matches(Node node) { if (!base.matches(node)) { return(false); } ModelElementInstance modelElement = ModelUtil.getModelElement(new DomElementImpl((Element)node), model); return(type.IsAssignableFrom(modelElement.GetType())); }
/// <summary> /// Remove the reference if the target element is removed /// </summary> /// <param name="referenceTargetElement"> the reference target model element instance, which is removed </param> /// <param name="referenceIdentifier"> the identifier of the reference to filter reference source elements </param> public virtual void referencedElementRemoved(ModelElementInstance referenceTargetElement, object referenceIdentifier) { foreach (ModelElementInstance referenceSourceElement in findReferenceSourceElements(referenceTargetElement)) { if (referenceIdentifier.Equals(getReferenceIdentifier(referenceSourceElement))) { removeReference(referenceSourceElement, referenceTargetElement); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void getChildElementsByTypeForAlternativeNs() public virtual void getChildElementsByTypeForAlternativeNs() { ModelElementInstance birdo = modelInstance.getModelElementById("birdo"); assertThat(birdo, @is(notNullValue())); ICollection <Wings> elements = birdo.getChildElementsByType(typeof(Wings)); assertThat(elements.Count, @is(1)); assertThat(elements.GetEnumerator().next().TextContent, @is("zisch")); }
protected internal virtual void resizeSubProcess(BpmnShape innerShape) { BaseElement innerElement = innerShape.BpmnElement; Bounds innerShapeBounds = innerShape.Bounds; ModelElementInstance parent = innerElement.ParentElement; while (parent is SubProcess) { BpmnShape subProcessShape = findBpmnShape((SubProcess)parent); if (subProcessShape != null) { Bounds subProcessBounds = subProcessShape.Bounds; double innerX = innerShapeBounds.getX().Value; double innerWidth = innerShapeBounds.getWidth().Value; double innerY = innerShapeBounds.getY().Value; double innerHeight = innerShapeBounds.getHeight().Value; double subProcessY = subProcessBounds.getY().Value; double subProcessHeight = subProcessBounds.getHeight().Value; double subProcessX = subProcessBounds.getX().Value; double subProcessWidth = subProcessBounds.getWidth().Value; double tmpWidth = innerX + innerWidth + SPACE; double tmpHeight = innerY + innerHeight + SPACE; if (innerY == subProcessY) { subProcessBounds.setY(subProcessY - SPACE); subProcessBounds.setHeight(subProcessHeight + SPACE); } if (tmpWidth >= subProcessX + subProcessWidth) { double newWidth = tmpWidth - subProcessX; subProcessBounds.setWidth(newWidth); } if (tmpHeight >= subProcessY + subProcessHeight) { double newHeight = tmpHeight - subProcessY; subProcessBounds.setHeight(newHeight); } innerElement = (SubProcess)parent; innerShapeBounds = subProcessBounds; parent = innerElement.ParentElement; } else { break; } } }
/// <summary> /// Set new identifier if the type has a String id attribute /// </summary> /// <param name="type"> the type of the model element </param> /// <param name="modelElementInstance"> the model element instance to set the id </param> /// <param name="newId"> new identifier </param> /// <param name="withReferenceUpdate"> true to update id references in other elements, false otherwise </param> public static void setNewIdentifier(ModelElementType type, ModelElementInstance modelElementInstance, string newId, bool withReferenceUpdate) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.camunda.bpm.model.xml.type.attribute.Attribute<?> id = type.getAttribute(ID_ATTRIBUTE_NAME); Attribute <object> id = type.getAttribute(ID_ATTRIBUTE_NAME); if (id != null && id is StringAttribute && id.IdAttribute) { ((StringAttribute)id).setValue(modelElementInstance, newId, withReferenceUpdate); } }
public virtual void removeAttribute(ModelElementInstance modelElement) { if (string.ReferenceEquals(namespaceUri, null)) { modelElement.removeAttribute(attributeName); } else { modelElement.removeAttributeNs(namespaceUri, attributeName); } }
/// <summary> /// Returns the <seealso cref="ModelElementInstanceImpl ModelElement"/> for a DOM element. /// If the model element does not yet exist, it is created and linked to the DOM. /// </summary> /// <param name="domElement"> the child element to create a new <seealso cref="ModelElementInstanceImpl ModelElement"/> for </param> /// <param name="modelInstance"> the <seealso cref="ModelInstanceImpl ModelInstance"/> for which the new <seealso cref="ModelElementInstanceImpl ModelElement"/> is created </param> /// <param name="modelType"> the <seealso cref="ModelElementTypeImpl ModelElementType"/> to create a new <seealso cref="ModelElementInstanceImpl ModelElement"/> for </param> /// <returns> the child model element </returns> public static ModelElementInstance getModelElement(DomElement domElement, ModelInstanceImpl modelInstance, ModelElementTypeImpl modelType) { ModelElementInstance modelElement = domElement.ModelElementInstance; if (modelElement == null) { modelElement = modelType.newInstance(modelInstance, domElement); domElement.ModelElementInstance = modelElement; } return(modelElement); }
protected internal override void setReferenceIdentifier(ModelElementInstance referenceSourceElement, string referenceIdentifier) { if (!string.ReferenceEquals(referenceIdentifier, null) && referenceIdentifier.Length > 0) { base.setReferenceIdentifier(referenceSourceElement, referenceIdentifier); } else { referenceSourceAttribute.removeAttribute(referenceSourceElement); } }
protected internal override void updateReference(ModelElementInstance referenceSourceElement, string oldIdentifier, string newIdentifier) { string referencingIdentifier = getReferenceIdentifier(referenceSourceElement); IList <string> references = StringUtil.splitListBySeparator(referencingIdentifier, separator); if (!string.ReferenceEquals(oldIdentifier, null) && references.Contains(oldIdentifier)) { referencingIdentifier = referencingIdentifier.Replace(oldIdentifier, newIdentifier); setReferenceIdentifier(referenceSourceElement, newIdentifier); } }
public virtual void insertElementAfter(ModelElementInstance elementToInsert, ModelElementInstance insertAfterElement) { if (insertAfterElement == null || insertAfterElement.DomElement == null) { domElement.insertChildElementAfter(elementToInsert.DomElement, null); } else { domElement.insertChildElementAfter(elementToInsert.DomElement, insertAfterElement.DomElement); } }
protected internal override void updateReference(ModelElementInstance referenceSourceElement, string oldIdentifier, string newIdentifier) { IList <string> referenceIdentifiers = getReferenceIdentifiers(referenceSourceElement); if (referenceIdentifiers.Contains(oldIdentifier)) { int index = referenceIdentifiers.IndexOf(oldIdentifier); referenceIdentifiers.Remove(oldIdentifier); referenceIdentifiers.Insert(index, newIdentifier); setReferenceIdentifiers(referenceSourceElement, referenceIdentifiers); } }
public virtual void setValue(ModelElementInstance modelElement, T value, bool withReferenceUpdate) { string xmlValue = convertModelValueToXmlValue(value); if (string.ReferenceEquals(namespaceUri, null)) { modelElement.setAttributeValue(attributeName, xmlValue, isIdAttribute, withReferenceUpdate); } else { modelElement.setAttributeValueNs(namespaceUri, attributeName, xmlValue, isIdAttribute, withReferenceUpdate); } }
protected internal virtual void performAddOperation(ModelElementInstance referenceSourceElement, T referenceTargetElement) { string identifier = getReferenceIdentifier(referenceSourceElement); IList <string> references = StringUtil.splitListBySeparator(identifier, separator); string targetIdentifier = getTargetElementIdentifier(referenceTargetElement); references.Add(targetIdentifier); identifier = StringUtil.joinList(references, separator); setReferenceIdentifier(referenceSourceElement, identifier); }
public virtual void replaceWithElement(ModelElementInstance newElement) { ModelElementInstanceImpl parentElement = (ModelElementInstanceImpl)ParentElement; if (parentElement != null) { parentElement.replaceChildElement(this, newElement); } else { throw new ModelException("Unable to remove replace without parent"); } }