protected internal override void RemoveReference(IModelElementInstance referenceSourceElement, IModelElementInstance referenceTargetElement)
        {
            IModelElementInstance parentElement          = referenceSourceElement.ParentElement;
            ICollection <TSource> childElementCollection = _referenceSourceCollection.Get <TSource>(parentElement);

            childElementCollection.Remove((TSource)referenceSourceElement);
        }
示例#2
0
        public virtual T AddExtensionElement <T>(Type extensionElementClass) where T : IModelElementInstance
        {
            IModelElementInstance extensionElement = modelInstance.NewInstance <T>(extensionElementClass);

            AddChildElement(extensionElement);
            return((T)extensionElement);
        }
示例#3
0
        public virtual T NewInstance <T>(IModelElementType type) where T : IModelElementInstance
        {
            IModelElementInstance modelElementInstance = type.NewInstance(this);

            ModelUtil.SetGeneratedUniqueIdentifier(type, modelElementInstance);
            return((T)modelElementInstance);
        }
示例#4
0
        public T AddExtensionElement <T>(IType extensionElementClass) where T : IModelElementInstance
        {
            IModelElementInstance extensionElement = modelInstance.NewInstance <IModelElementInstance>((IModelElementType)extensionElementClass);

            AddChildElement(extensionElement);
            return((T)extensionElement);
        }
示例#5
0
 public ModelValidationResultImpl(IModelElementInstance element, ValidationResultType type, int code, string message)
 {
     this.Element = element;
     this.type    = type;
     this.code    = code;
     this.message = message;
 }
示例#6
0
        /// <summary>
        /// returns the value of the attribute.
        /// </summary>
        /// <returns> the value of the attribute. </returns>
        public virtual T GetValue <T>(IModelElementInstance modelElement)
        {
            string value;

            if (NamespaceUri == null)
            {
                value = modelElement.GetAttributeValue(AttributeName);
            }
            else
            {
                value = modelElement.GetAttributeValueNs(NamespaceUri, AttributeName);
                if (value == null)
                {
                    string alternativeNamespace = _owningElementType.Model.GetAlternativeNamespace(NamespaceUri);
                    if (alternativeNamespace != null)
                    {
                        value = modelElement.GetAttributeValueNs(alternativeNamespace, AttributeName);
                    }
                }
            }

            if ((value == null) && _defaultValue != null)
            {
                return(GetDefaultValue <T>());
            }
            return(ConvertXmlValueToModelValue <T>(value));
        }
示例#7
0
        public virtual bool RemoveChild(IModelElementInstance element)
        {
            IModelElementInstance    childElement        = GetChild(element);
            ModelElementInstanceImpl elementInstanceImpl = (ModelElementInstanceImpl)element;

            return(elementInstanceImpl.RemoveChildElement(childElement));
        }
 public virtual ProcessEngineException CastModelInstanceException(IModelElementInstance instance,
                                                                  string toElement, string type, string @namespace, System.Exception cause)
 {
     return
         (new ProcessEngineException(
              ExceptionMessage("036", "Cannot cast '{0}' to '{1}'. Element is of type '{2}' with namespace '{3}'.",
                               instance, toElement, type, @namespace), cause));
 }
示例#9
0
        public virtual IModelElementInstance AddExtensionElement(string namespaceUri, string localName)
        {
            IModelElementType     extensionElementType = ((ModelInstanceImpl)modelInstance).RegisterGenericType(namespaceUri, localName);
            IModelElementInstance extensionElement     = extensionElementType.NewInstance(modelInstance);

            AddChildElement(extensionElement);
            return(extensionElement);
        }
        protected internal override void UpdateReference(IModelElementInstance referenceSourceElement, string oldIdentifier, string newIdentifier)
        {
            string referencingTextContent = GetReferenceIdentifier(referenceSourceElement);

            if (!string.IsNullOrWhiteSpace(oldIdentifier) && oldIdentifier.Equals(referencingTextContent))
            {
                SetReferenceIdentifier(referenceSourceElement, newIdentifier);
            }
        }
示例#11
0
 public virtual void UpdateIncomingReferences(IModelElementInstance modelElement, string newIdentifier, string oldIdentifier)
 {
     if (_incomingReferences.Count > 0)
     {
         foreach (IReference incomingReference in _incomingReferences)
         {
             ((ReferenceImpl)incomingReference).ReferencedElementUpdated(modelElement, oldIdentifier, newIdentifier);
         }
     }
 }
示例#12
0
 public virtual void UnlinkReference(IModelElementInstance modelElement, object referenceIdentifier)
 {
     if (_incomingReferences.Count > 0)
     {
         foreach (IReference incomingReference in _incomingReferences)
         {
             ((ReferenceImpl)incomingReference).ReferencedElementRemoved(modelElement, referenceIdentifier);
         }
     }
 }
        protected internal override void RemoveReference(IModelElementInstance referenceSourceElement, IModelElementInstance referenceTargetElement)
        {
            string         identifier         = GetReferenceIdentifier(referenceSourceElement);
            IList <string> references         = StringUtil.SplitListBySeparator(identifier, Separator);
            string         identifierToRemove = GetTargetElementIdentifier(referenceTargetElement);

            references.Remove(identifierToRemove);
            identifier = StringUtil.JoinList(references, Separator.ToString());
            SetReferenceIdentifier(referenceSourceElement, identifier);
        }
示例#14
0
        protected internal override void UpdateReference(IModelElementInstance referenceSourceElement, string oldIdentifier, string newIdentifier)
        {
            string referencingAttributeValue = GetReferenceIdentifier(referenceSourceElement);

            //if (!string.ReferenceEquals(oldIdentifier, null) && oldIdentifier.Equals(referencingAttributeValue))
            if (!string.IsNullOrEmpty(oldIdentifier) && oldIdentifier.Equals(referencingAttributeValue))
            {
                SetReferenceIdentifier(referenceSourceElement, newIdentifier);
            }
        }
        private void addExecutionListener(IBaseElement element, string eventName)
        {
            IExtensionElements    extensionElements = element.ModelInstance.NewInstance <IExtensionElements>(typeof(IExtensionElements));
            IModelElementInstance executionListener = extensionElements.AddExtensionElement(BpmnModelConstants.CamundaNs, "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(BpmnModelConstants.CamundaNs, "class", typeof(ModelExecutionContextExecutionListener).FullName);
            executionListener.SetAttributeValueNs(BpmnModelConstants.CamundaNs, "event", eventName);
            element.ExtensionElements = extensionElements;
        }
示例#16
0
            //TODO Input底层可能又问题
            public override bool Matches(XmlNode node)
            {
                if (!base.Matches(node))
                {
                    return(false);
                }
                IModelElementInstance modelElement = ModelUtil.GetModelElement(new DomElementImpl((XmlElement)node), Model);

                return(Type.IsAssignableFrom(modelElement.GetType()));
            }
        protected internal virtual void ResizeSubProcess(IBpmnShape innerShape)
        {
            IBaseElement innerElement     = innerShape.BpmnElement;
            IBounds      innerShapeBounds = innerShape.Bounds;

            IModelElementInstance parent = innerElement.ParentElement;

            while (parent is ISubProcess)
            {
                IBpmnShape subProcessShape = FindBpmnShape((ISubProcess)parent);

                if (subProcessShape != null)
                {
                    IBounds 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     = (ISubProcess)parent;
                    innerShapeBounds = subProcessBounds;
                    parent           = innerElement.ParentElement;
                }
                else
                {
                    break;
                }
            }
        }
        protected internal override void UpdateReference(IModelElementInstance referenceSourceElement, string oldIdentifier, string newIdentifier)
        {
            string         referencingIdentifier = GetReferenceIdentifier(referenceSourceElement);
            IList <string> references            = StringUtil.SplitListBySeparator(referencingIdentifier, Separator);

            if (!string.IsNullOrEmpty(oldIdentifier) && references.Contains(oldIdentifier))
            {
                referencingIdentifier = referencingIdentifier.Replace(oldIdentifier, newIdentifier);
                SetReferenceIdentifier(referenceSourceElement, newIdentifier);
            }
        }
示例#19
0
        //TODO 可能又类型判断错误 设置ModelElementId id.DefaultValue is string
        /// <summary>
        /// Set unique 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>
        public static void SetGeneratedUniqueIdentifier(IModelElementType type, IModelElementInstance modelElementInstance)
        {
            //AttributeBox id = type.GetAttribute("id");
            IAttribute /*<String>*/ id = type.GetAttribute("id");

            //if (id != null && id.ValueType ==typeof(string) && id.IdAttribute)
            if (id != null && id.IdAttribute)
            {
                ((StringAttribute)id).SetValue(modelElementInstance, ModelUtil.GetUniqueIdentifier(type));
            }
        }
示例#20
0
 public virtual void RemoveAttribute(IModelElementInstance modelElement)
 {
     if (string.ReferenceEquals(NamespaceUri, null))
     {
         modelElement.RemoveAttribute(AttributeName);
     }
     else
     {
         modelElement.RemoveAttributeNs(NamespaceUri, AttributeName);
     }
 }
 protected internal override void SetReferenceIdentifier(IModelElementInstance referenceSourceElement, string referenceIdentifier)
 {
     //if (!string.ReferenceEquals(referenceIdentifier, null) && referenceIdentifier.Length > 0)
     if (!string.IsNullOrWhiteSpace(referenceIdentifier))
     {
         base.SetReferenceIdentifier(referenceSourceElement, referenceIdentifier);
     }
     else
     {
         referenceSourceAttribute.RemoveAttribute(referenceSourceElement);
     }
 }
示例#22
0
        //TODO 入口 IModelElementInstance解析
        /// <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>
        /// <returns> the child model element </returns>
        public static IModelElementInstance GetModelElement(IDomElement domElement, IModelInstance modelInstance)
        {
            IModelElementInstance modelElement = domElement.ModelElementInstance;

            if (modelElement == null)
            {
                IModelElementType modelType = GetModelElement(domElement, modelInstance, domElement.NamespaceUri);
                modelElement = ((ModelElementTypeImpl)modelType).NewInstance(modelInstance, domElement);
                domElement.ModelElementInstance = modelElement;
            }
            return(modelElement);
        }
示例#23
0
        public override string GetReferenceIdentifier(IModelElementInstance referenceSourceElement)
        {
            string identifier = base.GetReferenceIdentifier(referenceSourceElement);

            if (string.IsNullOrEmpty(identifier))
            {
                return(null);
            }
            QName qName = QName.ParseQName(identifier);

            return(qName.LocalName);
        }
示例#24
0
        protected internal override void UpdateReference(IModelElementInstance 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);
            }
        }
示例#25
0
        public virtual void SetReferenceTargetElement <T>(IModelElementInstance referenceSourceElement, T referenceTargetElement)
            where T : IModelElementInstance
        {
            IModelInstance        modelInstance             = referenceSourceElement.ModelInstance;
            string                referenceTargetIdentifier = ReferenceTargetAttribute.GetValue <String>(referenceTargetElement);
            IModelElementInstance existingElement           = modelInstance.GetModelElementById(referenceTargetIdentifier);

            if (existingElement == null || existingElement.Id != referenceTargetElement.Id)
            {
                throw new ModelReferenceException("Cannot create reference to model element " + referenceTargetElement + ": element is not part of model. Please connect element to the model first.");
            }
            SetReferenceIdentifier(referenceSourceElement, referenceTargetIdentifier);
        }
        protected internal virtual void PerformAddOperation(IModelElementInstance referenceSourceElement, IModelElementInstance referenceTargetElement)
        {
            string         identifier = GetReferenceIdentifier(referenceSourceElement);
            IList <string> references = StringUtil.SplitListBySeparator(identifier, Separator);

            string targetIdentifier = GetTargetElementIdentifier(referenceTargetElement);

            references.Add(targetIdentifier);

            identifier = StringUtil.JoinList(references, Separator.ToString());

            SetReferenceIdentifier(referenceSourceElement, identifier);
        }
示例#27
0
        public virtual void SetValue <T>(IModelElementInstance modelElement, T value)
        {
            string xmlValue = ConvertModelValueToXmlValue(value);

            if (string.ReferenceEquals(NamespaceUri, null))
            {
                modelElement.SetAttributeValue(AttributeName, xmlValue, IdAttribute);
            }
            else
            {
                modelElement.SetAttributeValueNs(NamespaceUri, AttributeName, xmlValue, IdAttribute);
            }
        }
示例#28
0
        public virtual IFlowNodeBuilder <TE> MoveToNode(string identifier)
        {
            IModelElementInstance instance = modelInstance.GetModelElementById(identifier);

            if (instance != null && instance is IFlowNode)
            {
                return(((IFlowNode)instance).Builder <IFlowNodeBuilder <TE>, TE>());
            }
            else
            {
                throw new BpmnModelException("Flow node not found for id " + identifier);
            }
        }
示例#29
0
        public virtual IActivityBuilder <IActivity> MoveToActivity(string identifier) /*where T : IActivityBuilder*/
        {
            IModelElementInstance instance = modelInstance.GetModelElementById(identifier);

            if (instance != null && instance is IActivity)
            {
                return(((IActivity)instance).Builder <IActivityBuilder <IActivity>, IActivity>());
            }
            else
            {
                throw new BpmnModelException("Activity not found for id " + identifier);
            }
        }
示例#30
0
        public virtual IModelElementInstance GetChild(IModelElementInstance element)
        {
            ModelElementInstanceImpl elementInstanceImpl = (ModelElementInstanceImpl)element;

            IModelElementInstance childElement = elementInstanceImpl.GetUniqueChildElementByType(typeof(T));

            if (childElement != null)
            {
                ModelUtil.EnsureInstanceOf(childElement, typeof(T));
                return((T)childElement);
            }
            return(default(T));
        }