Exemplo n.º 1
0
 public static void WriteDefaultAttribute(string attributeName, string value, XMLStreamWriter xtw)
 {
     if (!string.IsNullOrWhiteSpace(value) && !"null".Equals(value, StringComparison.CurrentCultureIgnoreCase))
     {
         xtw.WriteAttribute(attributeName, value);
     }
 }
Exemplo n.º 2
0
        public static void WriteRootElement(BpmnModel model, XMLStreamWriter xtw, string encoding)
        {
            xtw.WriteStartDocument(encoding, "1.0");

            // start definitions root element
            xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_DEFINITIONS, BpmnXMLConstants.BPMN2_NAMESPACE);
            xtw.DefaultNamespace = BpmnXMLConstants.BPMN2_NAMESPACE;
            xtw.WriteDefaultNamespace(BpmnXMLConstants.BPMN2_NAMESPACE);
            xtw.WriteNamespace(BpmnXMLConstants.XSI_PREFIX, BpmnXMLConstants.XSI_NAMESPACE);
            xtw.WriteNamespace(BpmnXMLConstants.XSD_PREFIX, BpmnXMLConstants.SCHEMA_NAMESPACE);
            xtw.WriteNamespace(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE);
            xtw.WriteNamespace(BpmnXMLConstants.BPMNDI_PREFIX, BpmnXMLConstants.BPMNDI_NAMESPACE);
            xtw.WriteNamespace(BpmnXMLConstants.OMGDC_PREFIX, BpmnXMLConstants.OMGDC_NAMESPACE);
            xtw.WriteNamespace(BpmnXMLConstants.OMGDI_PREFIX, BpmnXMLConstants.OMGDI_NAMESPACE);
            foreach (string prefix in model.Namespaces.Keys)
            {
                if (!defaultNamespaces.Contains(prefix) && !string.IsNullOrWhiteSpace(prefix))
                {
                    xtw.WriteNamespace(prefix, model.Namespaces[prefix]);
                }
            }
            xtw.WriteAttribute(BpmnXMLConstants.TYPE_LANGUAGE_ATTRIBUTE, BpmnXMLConstants.SCHEMA_NAMESPACE);
            xtw.WriteAttribute(BpmnXMLConstants.EXPRESSION_LANGUAGE_ATTRIBUTE, BpmnXMLConstants.XPATH_NAMESPACE);
            if (!string.IsNullOrWhiteSpace(model.TargetNamespace))
            {
                xtw.WriteAttribute(BpmnXMLConstants.TARGET_NAMESPACE_ATTRIBUTE, model.TargetNamespace);
            }
            else
            {
                xtw.WriteAttribute(BpmnXMLConstants.TARGET_NAMESPACE_ATTRIBUTE, BpmnXMLConstants.PROCESS_NAMESPACE);
            }

            //BpmnXMLUtil.WriteCustomAttributes(model.DefinitionsAttributes.Values, xtw, model.Namespaces, defaultAttributes);
        }
Exemplo n.º 3
0
        public static void WriteLanes(Process process, XMLStreamWriter xtw)
        {
            if (process.Lanes.Count > 0)
            {
                xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_LANESET, BpmnXMLConstants.BPMN2_NAMESPACE);
                xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_ID, "laneSet_" + process.Id);
                foreach (Lane lane in process.Lanes)
                {
                    xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_LANE, BpmnXMLConstants.BPMN2_NAMESPACE);
                    xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_ID, lane.Id);

                    if (!string.IsNullOrWhiteSpace(lane.Name))
                    {
                        xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, lane.Name);
                    }

                    bool didWriteExtensionStartElement = BpmnXMLUtil.WriteExtensionElements(lane, false, xtw);
                    if (didWriteExtensionStartElement)
                    {
                        xtw.WriteEndElement();
                    }

                    foreach (string flowNodeRef in lane.FlowReferences)
                    {
                        xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_FLOWNODE_REF, BpmnXMLConstants.BPMN2_NAMESPACE);
                        xtw.WriteCharacters(flowNodeRef);
                        xtw.WriteEndElement();
                    }

                    xtw.WriteEndElement();
                }
                xtw.WriteEndElement();
            }
        }
        public static void WriteFailedJobRetryCount(Activity activity, XMLStreamWriter xtw)
        {
            string failedJobRetryCycle = activity.FailedJobRetryTimeCycleValue;

            if (!(failedJobRetryCycle is null))
            {
                if (!string.IsNullOrWhiteSpace(failedJobRetryCycle))
                {
                    xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.FAILED_JOB_RETRY_TIME_CYCLE, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE);
                    xtw.WriteCharacters(failedJobRetryCycle);
                    xtw.WriteEndElement();
                }
            }
        }
Exemplo n.º 5
0
        public static void WritePools(BpmnModel model, XMLStreamWriter xtw)
        {
            if ((model.Pools?.Count).GetValueOrDefault() > 0)
            {
                xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_COLLABORATION, BpmnXMLConstants.BPMN2_NAMESPACE);
                xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_ID, "Collaboration");
                foreach (Pool pool in model.Pools)
                {
                    xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_PARTICIPANT, BpmnXMLConstants.BPMN2_NAMESPACE);
                    xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_ID, pool.Id);
                    if (!string.IsNullOrWhiteSpace(pool.Name))
                    {
                        xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, pool.Name);
                    }
                    if (!string.IsNullOrWhiteSpace(pool.ProcessRef))
                    {
                        xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_PROCESS_REF, pool.ProcessRef);
                    }
                    xtw.WriteEndElement();
                }

                foreach (MessageFlow messageFlow in model.MessageFlows.Values)
                {
                    xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_MESSAGE_FLOW, BpmnXMLConstants.BPMN2_NAMESPACE);
                    xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_ID, messageFlow.Id);
                    if (!string.IsNullOrWhiteSpace(messageFlow.Name))
                    {
                        xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, messageFlow.Name);
                    }
                    if (!string.IsNullOrWhiteSpace(messageFlow.SourceRef))
                    {
                        xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_FLOW_SOURCE_REF, messageFlow.SourceRef);
                    }
                    if (!string.IsNullOrWhiteSpace(messageFlow.TargetRef))
                    {
                        xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_FLOW_TARGET_REF, messageFlow.TargetRef);
                    }
                    if (!string.IsNullOrWhiteSpace(messageFlow.MessageRef))
                    {
                        xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_MESSAGE_REF, messageFlow.MessageRef);
                    }
                    xtw.WriteEndElement();
                }

                xtw.WriteEndElement();
            }
        }
Exemplo n.º 6
0
        public static void WriteProcess(Process process, XMLStreamWriter xtw)
        {
            // start process element
            xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_PROCESS, BpmnXMLConstants.BPMN2_NAMESPACE);
            xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_ID, process.Id);

            if (!string.IsNullOrWhiteSpace(process.Name))
            {
                xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, process.Name);
            }

            xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_PROCESS_EXECUTABLE, process.Executable ? "true" : "false");

            if (process.CandidateStarterUsers.Count > 0)
            {
                xtw.WriteAttribute(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_PROCESS_CANDIDATE_USERS, BpmnXMLUtil.ConvertToDelimitedString(process.CandidateStarterUsers));
            }

            if (process.CandidateStarterGroups.Count > 0)
            {
                xtw.WriteAttribute(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_PROCESS_CANDIDATE_GROUPS, BpmnXMLUtil.ConvertToDelimitedString(process.CandidateStarterGroups));
            }

            // write custom attributes
            BpmnXMLUtil.WriteCustomAttributes(process.Attributes.Values, xtw, defaultProcessAttributes);

            if (!string.IsNullOrWhiteSpace(process.Documentation))
            {
                xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_DOCUMENTATION, BpmnXMLConstants.BPMN2_NAMESPACE);
                xtw.WriteCharacters(process.Documentation);
                xtw.WriteEndElement();
            }

            bool didWriteExtensionStartElement = ActivitiListenerExport.WriteListeners(process, false, xtw);

            didWriteExtensionStartElement = BpmnXMLUtil.WriteExtensionElements(process, didWriteExtensionStartElement, xtw);

            if (didWriteExtensionStartElement)
            {
                // closing extensions element
                xtw.WriteEndElement();
            }

            LaneExport.WriteLanes(process, xtw);
        }
Exemplo n.º 7
0
 public static void WriteMultiInstance(Activity activity, XMLStreamWriter xtw)
 {
     if (activity.LoopCharacteristics != null)
     {
         MultiInstanceLoopCharacteristics multiInstanceObject = activity.LoopCharacteristics;
         if (!string.IsNullOrWhiteSpace(multiInstanceObject.LoopCardinality) || !string.IsNullOrWhiteSpace(multiInstanceObject.InputDataItem) || !string.IsNullOrWhiteSpace(multiInstanceObject.CompletionCondition))
         {
             xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_MULTIINSTANCE, BpmnXMLConstants.BPMN2_NAMESPACE);
             BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_MULTIINSTANCE_SEQUENTIAL, multiInstanceObject.Sequential ? "true" : "false", xtw);
             if (!string.IsNullOrWhiteSpace(multiInstanceObject.InputDataItem))
             {
                 BpmnXMLUtil.WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_MULTIINSTANCE_COLLECTION, multiInstanceObject.InputDataItem, xtw);
             }
             if (!string.IsNullOrWhiteSpace(multiInstanceObject.ElementVariable))
             {
                 BpmnXMLUtil.WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_MULTIINSTANCE_VARIABLE, multiInstanceObject.ElementVariable, xtw);
             }
             if (!string.IsNullOrWhiteSpace(multiInstanceObject.LoopCardinality))
             {
                 xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_MULTIINSTANCE_CARDINALITY, BpmnXMLConstants.BPMN2_NAMESPACE);
                 xtw.WriteCharacters(multiInstanceObject.LoopCardinality);
                 xtw.WriteEndElement();
             }
             if (!string.IsNullOrWhiteSpace(multiInstanceObject.CompletionCondition))
             {
                 xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_MULTIINSTANCE_CONDITION, BpmnXMLConstants.BPMN2_NAMESPACE);
                 xtw.WriteCharacters(multiInstanceObject.CompletionCondition);
                 xtw.WriteEndElement();
             }
             xtw.WriteEndElement();
         }
         else
         {
             xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_MULTIINSTANCE, BpmnXMLConstants.BPMN2_NAMESPACE);
             BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_MULTIINSTANCE_SEQUENTIAL, multiInstanceObject.Sequential ? "true" : "false", xtw);
             xtw.WriteEndElement();
         }
     }
 }
Exemplo n.º 8
0
        public static void WriteDataStores(BpmnModel model, XMLStreamWriter xtw)
        {
            foreach (DataStore dataStore in model.DataStores.Values)
            {
                xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_DATA_STORE, BpmnXMLConstants.BPMN2_NAMESPACE);
                xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_ID, dataStore.Id);
                xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, dataStore.Name);
                if (!string.IsNullOrWhiteSpace(dataStore.ItemSubjectRef))
                {
                    xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_ITEM_SUBJECT_REF, dataStore.ItemSubjectRef);
                }

                if (!string.IsNullOrWhiteSpace(dataStore.DataState))
                {
                    xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_DATA_STATE, BpmnXMLConstants.BPMN2_NAMESPACE);
                    xtw.WriteCharacters(dataStore.DataState);
                    xtw.WriteEndElement();
                }

                xtw.WriteEndElement();
            }
        }
Exemplo n.º 9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void marshallAsElement(org.jboss.as.controller.AttributeDefinition attribute, org.jboss.dmr.ModelNode resourceModel, boolean marshallDefault, javax.xml.stream.XMLStreamWriter writer) throws javax.xml.stream.XMLStreamException
            public override void marshallAsElement(AttributeDefinition attribute, ModelNode resourceModel, bool marshallDefault, XMLStreamWriter writer)
            {
                resourceModel = resourceModel.get(attribute.XmlName);
                writer.writeStartElement(attribute.Name);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<org.jboss.dmr.Property> properties = resourceModel.asPropertyList();
                IList <Property> properties = resourceModel.asPropertyList();

                foreach (Property property in properties)
                {
                    writer.writeStartElement([email protected]);
                    writer.writeAttribute([email protected], property.Name);
                    writer.writeCharacters(property.Value.asString());
                    writer.writeEndElement();
                }
                writer.writeEndElement();
            }
Exemplo n.º 10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void marshallAsElement(org.jboss.as.controller.AttributeDefinition attribute, org.jboss.dmr.ModelNode resourceModel, boolean marshallDefault, javax.xml.stream.XMLStreamWriter writer) throws javax.xml.stream.XMLStreamException
            public override void marshallAsElement(AttributeDefinition attribute, ModelNode resourceModel, bool marshallDefault, XMLStreamWriter writer)
            {
                if (attribute is ObjectListAttributeDefinition)
                {
                    attribute = getValueType(attribute, typeof(ObjectListAttributeDefinition));
                }

                if (!(attribute is ObjectTypeAttributeDefinition))
                {
                    throw new XMLStreamException(string.Format("Attribute of class {0} is expected, but {1} received", "ObjectTypeAttributeDefinition", attribute.GetType().Name));
                }

                AttributeDefinition[] valueTypes;
                valueTypes = CustomMarshaller.getValueTypes(attribute, typeof(ObjectTypeAttributeDefinition));

                writer.writeStartElement(attribute.XmlName);
                foreach (AttributeDefinition valueType in valueTypes)
                {
                    valueType.marshallAsElement(resourceModel, marshallDefault, writer);
                }
                writer.writeEndElement();
            }
        public static void WriteSignalsAndMessages(BpmnModel model, XMLStreamWriter xtw)
        {
            foreach (Process process in model.Processes)
            {
                foreach (FlowElement flowElement in process.FindFlowElementsOfType <Event>())
                {
                    Event @event = (Event)flowElement;
                    if (@event.EventDefinitions.Count > 0)
                    {
                        EventDefinition eventDefinition = @event.EventDefinitions[0];
                        if (eventDefinition is SignalEventDefinition signalEvent)
                        {
                            if (!string.IsNullOrWhiteSpace(signalEvent.SignalRef))
                            {
                                if (!model.ContainsSignalId(signalEvent.SignalRef))
                                {
                                    Signal signal = new Signal(signalEvent.SignalRef, signalEvent.SignalRef);
                                    model.AddSignal(signal);
                                }
                            }
                        }
                        else if (eventDefinition is MessageEventDefinition messageEvent)
                        {
                            if (!string.IsNullOrWhiteSpace(messageEvent.MessageRef))
                            {
                                if (!model.ContainsMessageId(messageEvent.MessageRef))
                                {
                                    Message message = new Message(messageEvent.MessageRef, messageEvent.MessageRef, null);
                                    model.AddMessage(message);
                                }
                            }
                        }
                    }
                }
            }

            foreach (Signal signal in model.Signals)
            {
                xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_SIGNAL, BpmnXMLConstants.BPMN2_NAMESPACE);
                xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_ID, signal.Id);
                xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, signal.Name);
                if (signal.Scope != null)
                {
                    xtw.WriteAttribute(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_SCOPE, signal.Scope);
                }
                xtw.WriteEndElement();
            }

            foreach (Message message in model.Messages)
            {
                xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_MESSAGE, BpmnXMLConstants.BPMN2_NAMESPACE);
                string messageId = message.Id;
                // remove the namespace from the message id if set
                if (model.TargetNamespace != null && messageId.StartsWith(model.TargetNamespace, StringComparison.Ordinal))
                {
                    messageId = messageId.Replace(model.TargetNamespace, "");
                    messageId = messageId.ReplaceFirst(":", "");
                }
                else
                {
                    foreach (string prefix in model.Namespaces.Keys)
                    {
                        string @namespace = model.GetNamespace(prefix);
                        if (messageId.StartsWith(@namespace, StringComparison.Ordinal))
                        {
                            messageId = messageId.Replace(model.TargetNamespace, "");
                            messageId = prefix + messageId;
                        }
                    }
                }
                xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_ID, messageId);
                if (!string.IsNullOrWhiteSpace(message.Name))
                {
                    xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, message.Name);
                }
                if (!string.IsNullOrWhiteSpace(message.ItemRef))
                {
                    // replace the namespace by the right prefix
                    string itemRef = message.ItemRef;
                    foreach (string prefix in model.Namespaces.Keys)
                    {
                        string @namespace = model.GetNamespace(prefix);
                        if (itemRef.StartsWith(@namespace, StringComparison.Ordinal))
                        {
                            if (prefix.Length == 0)
                            {
                                itemRef = itemRef.Replace(@namespace + ":", "");
                            }
                            else
                            {
                                itemRef = itemRef.Replace(@namespace, prefix);
                            }
                            break;
                        }
                    }
                    xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_ITEM_REF, itemRef);
                }
                xtw.WriteEndElement();
            }
        }
Exemplo n.º 12
0
 protected void doExportAsKML(XMLStreamWriter xmlWriter) throws IOException, XMLStreamException
Exemplo n.º 13
0
 public static bool WriteExtensionElements(BaseElement baseElement, bool didWriteExtensionStartElement, XMLStreamWriter xtw)
 {
     return(WriteExtensionElements(baseElement, didWriteExtensionStartElement, null, xtw));
 }
Exemplo n.º 14
0
 public static void WriteQualifiedAttribute(string attributeName, string value, XMLStreamWriter xtw)
 {
     if (!string.IsNullOrWhiteSpace(value))
     {
         xtw.WriteAttribute(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, attributeName, value);
     }
 }
Exemplo n.º 15
0
        protected internal static bool WriteEventListeners(IList <EventListener> eventListeners, bool didWriteExtensionStartElement, XMLStreamWriter xtw)
        {
            if (eventListeners != null && eventListeners.Count > 0)
            {
                foreach (EventListener eventListener in eventListeners)
                {
                    if (!didWriteExtensionStartElement)
                    {
                        xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EXTENSIONS, BpmnXMLConstants.BPMN2_NAMESPACE);
                        didWriteExtensionStartElement = true;
                    }

                    xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ELEMENT_EVENT_LISTENER, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE);
                    BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_LISTENER_EVENTS, eventListener.Events, xtw);
                    BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_LISTENER_ENTITY_TYPE, eventListener.EntityType, xtw);

                    if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.Equals(eventListener.ImplementationType))
                    {
                        BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_LISTENER_CLASS, eventListener.Implementation, xtw);
                    }
                    else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.Equals(eventListener.ImplementationType))
                    {
                        BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_LISTENER_DELEGATEEXPRESSION, eventListener.Implementation, xtw);
                    }
                    else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_SIGNAL_EVENT.Equals(eventListener.ImplementationType))
                    {
                        BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_SIGNAL_EVENT_NAME, eventListener.Implementation, xtw);
                        BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_EVENT_TYPE, BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_EVENT_TYPE_SIGNAL, xtw);
                    }
                    else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_GLOBAL_SIGNAL_EVENT.Equals(eventListener.ImplementationType))
                    {
                        BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_SIGNAL_EVENT_NAME, eventListener.Implementation, xtw);
                        BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_EVENT_TYPE, BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_EVENT_TYPE_GLOBAL_SIGNAL, xtw);
                    }
                    else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_MESSAGE_EVENT.Equals(eventListener.ImplementationType))
                    {
                        BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_MESSAGE_EVENT_NAME, eventListener.Implementation, xtw);
                        BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_EVENT_TYPE, BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_EVENT_TYPE_MESSAGE, xtw);
                    }
                    else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_ERROR_EVENT.Equals(eventListener.ImplementationType))
                    {
                        BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_ERROR_EVENT_CODE, eventListener.Implementation, xtw);
                        BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_EVENT_TYPE, BpmnXMLConstants.ATTRIBUTE_LISTENER_THROW_EVENT_TYPE_ERROR, xtw);
                    }

                    xtw.WriteEndElement();
                }
            }

            return(didWriteExtensionStartElement);
        }
Exemplo n.º 16
0
 /// <summary>
 /// write attributes to xtw (except blacklisted)
 /// </summary>
 /// <param name="attributes"> </param>
 /// <param name="xtw"> </param>
 /// <param name="blackLists"> </param>
 public static void WriteCustomAttributes(ICollection <IList <ExtensionAttribute> > attributes, XMLStreamWriter xtw, IDictionary <string, string> namespaceMap, params IList <ExtensionAttribute>[] blackLists)
 {
     foreach (IList <ExtensionAttribute> attributeList in attributes)
     {
         if (attributeList != null && attributeList.Count > 0)
         {
             foreach (ExtensionAttribute attribute in attributeList)
             {
                 if (!IsBlacklisted(attribute, blackLists))
                 {
                     if (attribute.NamespacePrefix == null)
                     {
                         if (attribute.Namespace == null)
                         {
                             xtw.WriteAttribute(attribute.Name, attribute.Value);
                         }
                         else
                         {
                             xtw.WriteAttribute(attribute.Namespace, attribute.Name, attribute.Value);
                         }
                     }
                     else
                     {
                         if (!namespaceMap.ContainsKey(attribute.Name))
                         {
                             namespaceMap[attribute.Name] = attribute.Namespace;
                             xtw.WriteNamespace(attribute.NamespacePrefix, attribute.Namespace);
                         }
                         xtw.WriteAttribute(attribute.NamespacePrefix, attribute.Namespace, attribute.Name, attribute.Value);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 17
0
        public static bool WriteFieldExtensions(IList <FieldExtension> fieldExtensionList, bool didWriteExtensionStartElement, XMLStreamWriter xtw)
        {
            foreach (FieldExtension fieldExtension in fieldExtensionList)
            {
                if (!string.IsNullOrWhiteSpace(fieldExtension.FieldName))
                {
                    if (!string.IsNullOrWhiteSpace(fieldExtension.StringValue) || !string.IsNullOrWhiteSpace(fieldExtension.Expression))
                    {
                        if (!didWriteExtensionStartElement)
                        {
                            xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EXTENSIONS, BpmnXMLConstants.BPMN2_NAMESPACE);
                            didWriteExtensionStartElement = true;
                        }

                        xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ELEMENT_FIELD, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE);
                        BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FIELD_NAME, fieldExtension.FieldName, xtw);

                        if (!string.IsNullOrWhiteSpace(fieldExtension.StringValue))
                        {
                            xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ELEMENT_FIELD_STRING, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE);
                            xtw.WriteCharacters(fieldExtension.StringValue);
                        }
                        else
                        {
                            xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ATTRIBUTE_FIELD_EXPRESSION, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE);
                            xtw.WriteCharacters(fieldExtension.Expression);
                        }
                        xtw.WriteEndElement();
                        xtw.WriteEndElement();
                    }
                }
            }
            return(didWriteExtensionStartElement);
        }
Exemplo n.º 18
0
        public static bool WriteListeners(BaseElement element, bool didWriteExtensionStartElement, XMLStreamWriter xtw)
        {
            if (element is IHasExecutionListeners)
            {
                didWriteExtensionStartElement = WriteListeners(BpmnXMLConstants.ELEMENT_EXECUTION_LISTENER, ((IHasExecutionListeners)element).ExecutionListeners, didWriteExtensionStartElement, xtw);
            }
            // In case of a usertaks, also add task-listeners
            if (element is UserTask)
            {
                didWriteExtensionStartElement = WriteListeners(BpmnXMLConstants.ELEMENT_TASK_LISTENER, ((UserTask)element).TaskListeners, didWriteExtensionStartElement, xtw);
            }

            // In case of a process-element, write the event-listeners
            if (element is Process)
            {
                didWriteExtensionStartElement = WriteEventListeners(((Process)element).EventListeners, didWriteExtensionStartElement, xtw);
            }

            return(didWriteExtensionStartElement);
        }
Exemplo n.º 19
0
        public static bool WriteExtensionElements(BaseElement baseElement, bool didWriteExtensionStartElement, IDictionary <string, string> namespaceMap, XMLStreamWriter xtw)
        {
            if (baseElement.ExtensionElements.Count > 0)
            {
                if (!didWriteExtensionStartElement)
                {
                    xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EXTENSIONS, BpmnXMLConstants.BPMN2_NAMESPACE);
                    didWriteExtensionStartElement = true;
                }

                if (namespaceMap == null)
                {
                    namespaceMap = new Dictionary <string, string>();
                }

                foreach (IList <ExtensionElement> extensionElements in baseElement.ExtensionElements.Values)
                {
                    foreach (ExtensionElement extensionElement in extensionElements)
                    {
                        WriteExtensionElement(extensionElement, namespaceMap, xtw);
                    }
                }
            }
            return(didWriteExtensionStartElement);
        }
Exemplo n.º 20
0
        protected internal static void WriteExtensionElement(ExtensionElement extensionElement, IDictionary <string, string> namespaceMap, XMLStreamWriter xtw)
        {
            if (!string.IsNullOrWhiteSpace(extensionElement.Name))
            {
                IDictionary <string, string> localNamespaceMap = new Dictionary <string, string>();
                if (!string.IsNullOrWhiteSpace(extensionElement.Namespace))
                {
                    if (!string.IsNullOrWhiteSpace(extensionElement.NamespacePrefix))
                    {
                        xtw.WriteStartElement(extensionElement.NamespacePrefix, extensionElement.Name, extensionElement.Namespace);

                        if (!namespaceMap.ContainsKey(extensionElement.NamespacePrefix) || !namespaceMap[extensionElement.NamespacePrefix].Equals(extensionElement.Namespace))
                        {
                            xtw.WriteNamespace(extensionElement.NamespacePrefix, extensionElement.Namespace);
                            namespaceMap[extensionElement.NamespacePrefix]      = extensionElement.Namespace;
                            localNamespaceMap[extensionElement.NamespacePrefix] = extensionElement.Namespace;
                        }
                    }
                    else
                    {
                        xtw.WriteStartElement(extensionElement.Namespace, extensionElement.Name);
                    }
                }
                else
                {
                    xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, extensionElement.Name, BpmnXMLConstants.BPMN2_NAMESPACE);
                }

                foreach (IList <ExtensionAttribute> attributes in extensionElement.Attributes.Values)
                {
                    foreach (ExtensionAttribute attribute in attributes)
                    {
                        if (!string.IsNullOrWhiteSpace(attribute.Name) && attribute.Value != null)
                        {
                            if (!string.IsNullOrWhiteSpace(attribute.Namespace))
                            {
                                if (!string.IsNullOrWhiteSpace(attribute.NamespacePrefix))
                                {
                                    if (!namespaceMap.ContainsKey(attribute.NamespacePrefix) || !namespaceMap[attribute.NamespacePrefix].Equals(attribute.Namespace))
                                    {
                                        xtw.WriteNamespace(attribute.NamespacePrefix, attribute.Namespace);
                                        namespaceMap[attribute.NamespacePrefix] = attribute.Namespace;
                                    }

                                    xtw.WriteAttribute(attribute.NamespacePrefix, attribute.Namespace, attribute.Name, attribute.Value);
                                }
                                else
                                {
                                    xtw.WriteAttribute(attribute.Namespace, attribute.Name, attribute.Value);
                                }
                            }
                            else
                            {
                                xtw.WriteAttribute(attribute.Name, attribute.Value);
                            }
                        }
                    }
                }

                if (extensionElement.ElementText != null)
                {
                    xtw.WriteCData(extensionElement.ElementText);
                }
                else
                {
                    foreach (IList <ExtensionElement> childElements in extensionElement.ChildElements.Values)
                    {
                        foreach (ExtensionElement childElement in childElements)
                        {
                            WriteExtensionElement(childElement, namespaceMap, xtw);
                        }
                    }
                }

                foreach (string prefix in localNamespaceMap.Keys)
                {
                    namespaceMap.Remove(prefix);
                }

                xtw.WriteEndElement();
            }
        }
Exemplo n.º 21
0
        public static void WriteBPMNDI(BpmnModel model, XMLStreamWriter xtw)
        {
            // BPMN DI information
            xtw.WriteStartElement(BpmnXMLConstants.BPMNDI_PREFIX, BpmnXMLConstants.ELEMENT_DI_DIAGRAM, BpmnXMLConstants.BPMNDI_NAMESPACE);

            string processId;

            if ((model.Pools?.Count).GetValueOrDefault() > 0)
            {
                processId = "Collaboration";
            }
            else
            {
                processId = model.MainProcess.Id;
            }

            xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_ID, "BPMNDiagram_" + processId);

            xtw.WriteStartElement(BpmnXMLConstants.BPMNDI_PREFIX, BpmnXMLConstants.ELEMENT_DI_PLANE, BpmnXMLConstants.BPMNDI_NAMESPACE);
            xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_DI_BPMNELEMENT, processId);
            xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_ID, "BPMNPlane_" + processId);

            foreach (string elementId in model.LocationMap.Keys)
            {
                if (model.GetFlowElement(elementId) != null || model.GetArtifact(elementId) != null || model.GetPool(elementId) != null || model.GetLane(elementId) != null)
                {
                    xtw.WriteStartElement(BpmnXMLConstants.BPMNDI_PREFIX, BpmnXMLConstants.ELEMENT_DI_SHAPE, BpmnXMLConstants.BPMNDI_NAMESPACE);
                    xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_DI_BPMNELEMENT, elementId);
                    xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_ID, "BPMNShape_" + elementId);

                    GraphicInfo graphicInfo = model.GetGraphicInfo(elementId);
                    FlowElement flowElement = model.GetFlowElement(elementId);
                    if (flowElement is SubProcess && graphicInfo.Expanded != null)
                    {
                        xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_DI_IS_EXPANDED, graphicInfo.Expanded.ToString());
                    }

                    xtw.WriteStartElement(BpmnXMLConstants.OMGDC_PREFIX, BpmnXMLConstants.ELEMENT_DI_BOUNDS, BpmnXMLConstants.OMGDC_NAMESPACE);
                    xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_DI_HEIGHT, "" + graphicInfo.Height);
                    xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_DI_WIDTH, "" + graphicInfo.Width);
                    xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_DI_X, "" + graphicInfo.X);
                    xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_DI_Y, "" + graphicInfo.Y);
                    xtw.WriteEndElement();

                    xtw.WriteEndElement();
                }
            }

            foreach (string elementId in model.FlowLocationMap.Keys)
            {
                if (model.GetFlowElement(elementId) != null || model.GetArtifact(elementId) != null || model.GetMessageFlow(elementId) != null)
                {
                    xtw.WriteStartElement(BpmnXMLConstants.BPMNDI_PREFIX, BpmnXMLConstants.ELEMENT_DI_EDGE, BpmnXMLConstants.BPMNDI_NAMESPACE);
                    xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_DI_BPMNELEMENT, elementId);
                    xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_ID, "BPMNEdge_" + elementId);

                    IList <GraphicInfo> graphicInfoList = model.GetFlowLocationGraphicInfo(elementId) ?? new List <GraphicInfo>();
                    foreach (GraphicInfo graphicInfo in graphicInfoList)
                    {
                        xtw.WriteStartElement(BpmnXMLConstants.OMGDI_PREFIX, BpmnXMLConstants.ELEMENT_DI_WAYPOINT, BpmnXMLConstants.OMGDI_NAMESPACE);
                        xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_DI_X, "" + graphicInfo.X);
                        xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_DI_Y, "" + graphicInfo.Y);
                        xtw.WriteEndElement();
                    }

                    GraphicInfo labelGraphicInfo = model.GetLabelGraphicInfo(elementId);
                    if (labelGraphicInfo != null)
                    {
                        FlowElement flowElement = model.GetFlowElement(elementId);
                        MessageFlow messageFlow = null;
                        if (flowElement == null)
                        {
                            messageFlow = model.GetMessageFlow(elementId);
                        }

                        bool hasName = false;
                        if (flowElement != null && !string.IsNullOrWhiteSpace(flowElement.Name))
                        {
                            hasName = true;
                        }
                        else if (messageFlow != null && !string.IsNullOrWhiteSpace(messageFlow.Name))
                        {
                            hasName = true;
                        }

                        if (labelGraphicInfo != null && hasName)
                        {
                            xtw.WriteStartElement(BpmnXMLConstants.BPMNDI_PREFIX, BpmnXMLConstants.ELEMENT_DI_LABEL, BpmnXMLConstants.BPMNDI_NAMESPACE);
                            xtw.WriteStartElement(BpmnXMLConstants.OMGDC_PREFIX, BpmnXMLConstants.ELEMENT_DI_BOUNDS, BpmnXMLConstants.OMGDC_NAMESPACE);
                            xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_DI_HEIGHT, "" + labelGraphicInfo.Height);
                            xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_DI_WIDTH, "" + labelGraphicInfo.Width);
                            xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_DI_X, "" + labelGraphicInfo.X);
                            xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_DI_Y, "" + labelGraphicInfo.Y);
                            xtw.WriteEndElement();
                            xtw.WriteEndElement();
                        }
                    }

                    xtw.WriteEndElement();
                }
            }

            // end BPMN DI elements
            xtw.WriteEndElement();
            xtw.WriteEndElement();
        }
Exemplo n.º 22
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void marshallAsElement(org.jboss.as.controller.AttributeDefinition attribute, org.jboss.dmr.ModelNode resourceModel, boolean marshallDefault, javax.xml.stream.XMLStreamWriter writer) throws javax.xml.stream.XMLStreamException
            public override void marshallAsElement(AttributeDefinition attribute, ModelNode resourceModel, bool marshallDefault, XMLStreamWriter writer)
            {
                Debug.Assert(attribute is ObjectListAttributeDefinition);
                ObjectListAttributeDefinition list = ((ObjectListAttributeDefinition)attribute);

                ObjectTypeAttributeDefinition objectType = (ObjectTypeAttributeDefinition)CustomMarshaller.getValueType(list, typeof(ObjectListAttributeDefinition));

                AttributeDefinition[] valueTypes = CustomMarshaller.getValueTypes(list, typeof(ObjectTypeAttributeDefinition));

                if (resourceModel.hasDefined(attribute.Name))
                {
                    writer.writeStartElement(attribute.XmlName);
                    foreach (ModelNode element in resourceModel.get(attribute.Name).asList())
                    {
                        writer.writeStartElement(objectType.XmlName);
                        foreach (AttributeDefinition valueType in valueTypes)
                        {
                            valueType.AttributeMarshaller.marshallAsElement(valueType, element, false, writer);
                        }
                        writer.writeEndElement();
                    }
                    writer.writeEndElement();
                }
            }
Exemplo n.º 23
0
        private static bool WriteListeners(string xmlElementName, IList <ActivitiListener> listenerList, bool didWriteExtensionStartElement, XMLStreamWriter xtw)
        {
            if (listenerList != null)
            {
                foreach (ActivitiListener listener in listenerList)
                {
                    if (!string.IsNullOrWhiteSpace(listener.Event))
                    {
                        if (!didWriteExtensionStartElement)
                        {
                            xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EXTENSIONS, BpmnXMLConstants.BPMN2_NAMESPACE);
                            didWriteExtensionStartElement = true;
                        }

                        xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, xmlElementName, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE);
                        BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_LISTENER_EVENT, listener.Event, xtw);

                        if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.Equals(listener.ImplementationType))
                        {
                            BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_LISTENER_CLASS, listener.Implementation, xtw);
                        }
                        else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.Equals(listener.ImplementationType))
                        {
                            BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_LISTENER_EXPRESSION, listener.Implementation, xtw);
                        }
                        else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.Equals(listener.ImplementationType))
                        {
                            BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_LISTENER_DELEGATEEXPRESSION, listener.Implementation, xtw);
                        }

                        BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_LISTENER_ON_TRANSACTION, listener.OnTransaction, xtw);

                        if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.Equals(listener.CustomPropertiesResolverImplementationType))
                        {
                            BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_CLASS, listener.CustomPropertiesResolverImplementation, xtw);
                        }
                        else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.Equals(listener.CustomPropertiesResolverImplementationType))
                        {
                            BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_EXPRESSION, listener.CustomPropertiesResolverImplementation, xtw);
                        }
                        else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.Equals(listener.CustomPropertiesResolverImplementationType))
                        {
                            BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_DELEGATEEXPRESSION, listener.CustomPropertiesResolverImplementation, xtw);
                        }

                        FieldExtensionExport.WriteFieldExtensions(listener.FieldExtensions, true, xtw);

                        xtw.WriteEndElement();
                    }
                }
            }
            return(didWriteExtensionStartElement);
        }
Exemplo n.º 24
0
 /**
  * Export ShapeAttributes as KML Pair element in a StyleMap. This method assumes that the StyleMap tag has already
  * been written; it writes the Pair tag.
  *
  * @param xmlWriter  Writer to receive the Style element.
  * @param styleType  The type of style: normal or highlight. Value should match either {@link KMLConstants#NORMAL}
  *                   or {@link KMLConstants#HIGHLIGHT}
  * @param attributes Attributes to export. The method takes no action if this parameter is null.
  *
  * @throws javax.xml.stream.XMLStreamException
  *                             if exception occurs writing XML.
  * @throws java.io.IOException if exception occurs exporting data.
  */
 public static void exportAttributesAsKML(XMLStreamWriter xmlWriter, String styleType, ShapeAttributes attributes)
Exemplo n.º 25
0
 public static void WriteCustomAttributes(ICollection <IList <ExtensionAttribute> > attributes, XMLStreamWriter xtw, params IList <ExtensionAttribute>[] blackLists)
 {
     WriteCustomAttributes(attributes, xtw, new Dictionary <string, string>(), blackLists);
 }