Exemplo n.º 1
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.º 2
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();
            }
        }
Exemplo n.º 3
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();
         }
     }
 }
        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 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.º 6
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();
            }
        }