public virtual void ValidateModel(XMLStreamReader xmlStreamReader) { Schema schema = CreateSchema(); //Validator validator = schema.newValidator(); //validator.validate(new StAXSource(xmlStreamReader)); }
protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model) { BoundaryEvent boundaryEvent = new BoundaryEvent(); BpmnXMLUtil.AddXMLLocation(boundaryEvent, xtr); if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_BOUNDARY_CANCELACTIVITY))) { string cancelActivity = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_BOUNDARY_CANCELACTIVITY); if (BpmnXMLConstants.ATTRIBUTE_VALUE_FALSE.Equals(cancelActivity, StringComparison.CurrentCultureIgnoreCase)) { boundaryEvent.CancelActivity = false; } } boundaryEvent.AttachedToRefId = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_BOUNDARY_ATTACHEDTOREF); ParseChildElements(XMLElementName, boundaryEvent, model, xtr); // Explicitly set cancel activity to false for error boundary events if (boundaryEvent.EventDefinitions.Count == 1) { EventDefinition eventDef = boundaryEvent.EventDefinitions[0]; if (eventDef is ErrorEventDefinition) { boundaryEvent.CancelActivity = false; } } return(boundaryEvent); }
protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model) { string formKey = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_FORM_FORMKEY); StartEvent startEvent = null; if (!string.IsNullOrWhiteSpace(formKey) && model.StartEventFormTypes != null && model.StartEventFormTypes.Contains(formKey)) { startEvent = new AlfrescoStartEvent(); } if (startEvent == null) { startEvent = new StartEvent(); } BpmnXMLUtil.AddXMLLocation(startEvent, xtr); startEvent.Initiator = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_EVENT_START_INITIATOR); bool interrupting = true; string interruptingAttribute = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_EVENT_START_INTERRUPTING); if (BpmnXMLConstants.ATTRIBUTE_VALUE_FALSE.Equals(interruptingAttribute, StringComparison.OrdinalIgnoreCase)) { interrupting = false; } startEvent.Interrupting = interrupting; startEvent.FormKey = formKey; ParseChildElements(XMLElementName, startEvent, model, xtr); return(startEvent); }
protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model) { EventGateway gateway = new EventGateway(); BpmnXMLUtil.AddXMLLocation(gateway, xtr); ParseChildElements(XMLElementName, gateway, model, xtr); return(gateway); }
protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model) { DataStoreReference dataStoreRef = new DataStoreReference(); BpmnXMLUtil.AddXMLLocation(dataStoreRef, xtr); ParseChildElements(XMLElementName, dataStoreRef, model, xtr); return(dataStoreRef); }
protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model) { ReceiveTask receiveTask = new ReceiveTask(); BpmnXMLUtil.AddXMLLocation(receiveTask, xtr); ParseChildElements(XMLElementName, receiveTask, model, xtr); return(receiveTask); }
protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model) { EndEvent endEvent = new EndEvent(); BpmnXMLUtil.AddXMLLocation(endEvent, xtr); ParseChildElements(XMLElementName, endEvent, model, xtr); return(endEvent); }
protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model) { TextAnnotation textAnnotation = new TextAnnotation(); BpmnXMLUtil.AddXMLLocation(textAnnotation, xtr); textAnnotation.TextFormat = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_TEXTFORMAT); ParseChildElements(XMLElementName, textAnnotation, childParserMap, model, xtr); return(textAnnotation); }
protected internal virtual bool ParseAsync(XMLStreamReader xtr) { bool async = false; string asyncString = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_ACTIVITY_ASYNCHRONOUS); if (BpmnXMLConstants.ATTRIBUTE_VALUE_TRUE.Equals(asyncString, StringComparison.CurrentCultureIgnoreCase)) { async = true; } return(async); }
protected internal virtual bool ParseNotExclusive(XMLStreamReader xtr) { bool notExclusive = false; string exclusiveString = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_ACTIVITY_EXCLUSIVE); if (BpmnXMLConstants.ATTRIBUTE_VALUE_FALSE.Equals(exclusiveString, StringComparison.CurrentCultureIgnoreCase)) { notExclusive = true; } return(notExclusive); }
protected internal virtual bool ParseForCompensation(XMLStreamReader xtr) { bool isForCompensation = false; string compensationString = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ACTIVITY_ISFORCOMPENSATION); if (BpmnXMLConstants.ATTRIBUTE_VALUE_TRUE.Equals(compensationString, StringComparison.CurrentCultureIgnoreCase)) { isForCompensation = true; } return(isForCompensation); }
protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model) { CallActivity callActivity = new CallActivity(); BpmnXMLUtil.AddXMLLocation(callActivity, xtr); callActivity.CalledElement = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_CALL_ACTIVITY_CALLEDELEMENT); callActivity.BusinessKey = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_CALL_ACTIVITY_BUSINESS_KEY); bool.TryParse(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_CALL_ACTIVITY_INHERIT_BUSINESS_KEY), out callActivity.inheritBusinessKey); bool.TryParse(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_CALL_ACTIVITY_INHERITVARIABLES), out callActivity.inheritVariables); ParseChildElements(XMLElementName, callActivity, childParserMap, model, xtr); return(callActivity); }
protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model) { string formKey = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_FORM_FORMKEY); UserTask userTask = null; if (!string.IsNullOrWhiteSpace(formKey)) { if (model.UserTaskFormTypes != null && model.UserTaskFormTypes.Contains(formKey)) { userTask = new AlfrescoUserTask(); } } if (userTask == null) { userTask = new UserTask(); } BpmnXMLUtil.AddXMLLocation(userTask, xtr); userTask.DueDate = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_DUEDATE); userTask.BusinessCalendarName = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_BUSINESS_CALENDAR_NAME); userTask.Category = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_CATEGORY); userTask.FormKey = formKey; userTask.Assignee = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_ASSIGNEE); userTask.Owner = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_OWNER); userTask.Priority = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_PRIORITY); if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_CANDIDATEUSERS))) { string expression = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_CANDIDATEUSERS); (userTask.CandidateUsers as List <string>).AddRange(ParseDelimitedList(expression)); } if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_CANDIDATEGROUPS))) { string expression = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_CANDIDATEGROUPS); (userTask.CandidateGroups as List <string>).AddRange(ParseDelimitedList(expression)); } userTask.ExtensionId = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_EXTENSIONID); if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_SKIP_EXPRESSION))) { string expression = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_USER_SKIP_EXPRESSION); userTask.SkipExpression = expression; } BpmnXMLUtil.AddCustomAttributes(xtr, userTask, defaultElementAttributes, defaultActivityAttributes, defaultUserTaskAttributes); ParseChildElements(XMLElementName, userTask, childParserMap, model, xtr); return(userTask); }
public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) { string resourceElement = XMLStreamReaderUtil.moveDown(xtr); if (!string.IsNullOrWhiteSpace(resourceElement) && BpmnXMLConstants.ELEMENT_RESOURCE_ASSIGNMENT.Equals(resourceElement)) { string expression = XMLStreamReaderUtil.moveDown(xtr); if (!string.IsNullOrWhiteSpace(expression) && BpmnXMLConstants.ELEMENT_FORMAL_EXPRESSION.Equals(expression)) { ((UserTask)parentElement).Assignee = xtr.ElementText; } } }
protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model) { SequenceFlow sequenceFlow = new SequenceFlow(); BpmnXMLUtil.AddXMLLocation(sequenceFlow, xtr); sequenceFlow.SourceRef = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FLOW_SOURCE_REF); sequenceFlow.TargetRef = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FLOW_TARGET_REF); sequenceFlow.Name = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME); sequenceFlow.SkipExpression = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FLOW_SKIP_EXPRESSION); ParseChildElements(XMLElementName, sequenceFlow, model, xtr); return(sequenceFlow); }
protected internal virtual ExtensionElement ParseExtensionElement(XMLStreamReader xtr) { ExtensionElement extensionElement = new ExtensionElement { Name = xtr.LocalName }; if (!string.IsNullOrWhiteSpace(xtr.NamespaceURI)) { extensionElement.Namespace = xtr.NamespaceURI; } if (!string.IsNullOrWhiteSpace(xtr.Prefix)) { extensionElement.NamespacePrefix = xtr.Prefix; } BpmnXMLUtil.AddCustomAttributes(xtr, extensionElement, defaultElementAttributes); bool readyWithExtensionElement = false; while (!readyWithExtensionElement && xtr.HasNext()) { //xtr.next(); if (xtr.NodeType == XmlNodeType.CDATA) { if (!string.IsNullOrWhiteSpace(xtr.Value?.Trim())) { extensionElement.ElementText = xtr.Value?.Trim(); } } else if (xtr.IsStartElement()) { ExtensionElement childExtensionElement = ParseExtensionElement(xtr); extensionElement.AddChildElement(childExtensionElement); } else if (xtr.EndElement && string.Compare(extensionElement.Name, xtr.LocalName, true) == 0) { readyWithExtensionElement = true; } if (xtr.IsEmptyElement && string.Compare(extensionElement.Name, xtr.LocalName, true) == 0) { readyWithExtensionElement = true; } } return(extensionElement); }
protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model) { ServiceTask serviceTask = new ServiceTask(); BpmnXMLUtil.AddXMLLocation(serviceTask, xtr); if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_CLASS))) { serviceTask.ImplementationType = ImplementationType.IMPLEMENTATION_TYPE_CLASS; serviceTask.Implementation = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_CLASS); } else if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_EXPRESSION))) { serviceTask.ImplementationType = ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION; serviceTask.Implementation = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_EXPRESSION); } else if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_DELEGATEEXPRESSION))) { serviceTask.ImplementationType = ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION; serviceTask.Implementation = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_DELEGATEEXPRESSION); } else if ("##WebService".Equals(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_TASK_IMPLEMENTATION))) { serviceTask.ImplementationType = ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE; serviceTask.OperationRef = ParseOperationRef(xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_TASK_OPERATION_REF), model); } else { serviceTask.Implementation = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_TASK_IMPLEMENTATION); } serviceTask.ResultVariableName = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_RESULTVARIABLE); if (string.IsNullOrWhiteSpace(serviceTask.ResultVariableName)) { serviceTask.ResultVariableName = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, "resultVariable"); } serviceTask.Type = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TYPE); serviceTask.ExtensionId = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_EXTENSIONID); if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_SKIP_EXPRESSION))) { serviceTask.SkipExpression = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_SKIP_EXPRESSION); } ParseChildElements(XMLElementName, serviceTask, model, xtr); return(serviceTask); }
protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model) { BusinessRuleTask businessRuleTask = new BusinessRuleTask(); BpmnXMLUtil.AddXMLLocation(businessRuleTask, xtr); businessRuleTask.InputVariables = ParseDelimitedList(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_RULE_VARIABLES_INPUT)); businessRuleTask.RuleNames = ParseDelimitedList(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_RULE_RULES)); businessRuleTask.ResultVariableName = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_RULE_RESULT_VARIABLE); businessRuleTask.ClassName = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_RULE_CLASS); string exclude = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_RULE_EXCLUDE); if (BpmnXMLConstants.ATTRIBUTE_VALUE_TRUE.Equals(exclude, StringComparison.CurrentCultureIgnoreCase)) { businessRuleTask.Exclude = true; } ParseChildElements(XMLElementName, businessRuleTask, model, xtr); return(businessRuleTask); }
protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model) { ScriptTask scriptTask = new ScriptTask(); BpmnXMLUtil.AddXMLLocation(scriptTask, xtr); scriptTask.ScriptFormat = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_TASK_SCRIPT_FORMAT); scriptTask.ResultVariable = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SCRIPT_RESULTVARIABLE); if (string.IsNullOrWhiteSpace(scriptTask.ResultVariable)) { scriptTask.ResultVariable = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_RESULTVARIABLE); } string autoStoreVariables = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SCRIPT_AUTO_STORE_VARIABLE); if (!string.IsNullOrWhiteSpace(autoStoreVariables)) { scriptTask.AutoStoreVariables = Convert.ToBoolean(autoStoreVariables); } ParseChildElements(XMLElementName, scriptTask, childParserMap, model, xtr); return(scriptTask); }
public static string moveDown(XMLStreamReader xtr) { try { while (xtr.HasNext()) { //xtr.next(); if (xtr.IsStartElement()) { return(xtr.LocalName); } } } catch (Exception e) { logger.LogWarning(e, "Error while moving down in XML document"); } return(null); }
protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model) { Association association = new Association(); BpmnXMLUtil.AddXMLLocation(association, xtr); association.SourceRef = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FLOW_SOURCE_REF); association.TargetRef = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_FLOW_TARGET_REF); association.Id = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID); string asociationDirectionString = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ASSOCIATION_DIRECTION); if (!string.IsNullOrWhiteSpace(asociationDirectionString)) { AssociationDirection associationDirection = AssociationDirection.ValueOf(asociationDirectionString.ToUpper()); association.AssociationDirection = associationDirection; } ParseChildElements(XMLElementName, association, model, xtr); return(association); }
public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) { string source = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_IOPARAMETER_SOURCE); string sourceExpression = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_IOPARAMETER_SOURCE_EXPRESSION); string target = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_IOPARAMETER_TARGET); if ((!string.IsNullOrWhiteSpace(source) || !string.IsNullOrWhiteSpace(sourceExpression)) && !string.IsNullOrWhiteSpace(target)) { IOParameter parameter = new IOParameter(); if (!string.IsNullOrWhiteSpace(sourceExpression)) { parameter.SourceExpression = sourceExpression; } else { parameter.Source = source; } parameter.Target = target; ((CallActivity)parentElement).OutParameters.Add(parameter); } }
public static bool MoveToEndOfElement(XMLStreamReader xtr, string elementName) { try { while (xtr.HasNext()) { //xtr.next(); if (xtr.IsEmptyElement || xtr.EndElement) { if (xtr.LocalName == elementName) { return(true); } } } } catch (Exception e) { logger.LogWarning(e, $"Error while moving to end of element {elementName}"); } return(false); }
protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model) { SendTask sendTask = new SendTask(); BpmnXMLUtil.AddXMLLocation(sendTask, xtr); //sendTask.Type = xtr.getAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TYPE); if (!string.IsNullOrWhiteSpace(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_CLASS))) { sendTask.ImplementationType = ImplementationType.IMPLEMENTATION_TYPE_CLASS; sendTask.Implementation = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_TASK_SERVICE_CLASS); } //if ("##WebService".Equals(xtr.getAttributeValue(BpmnXMLConstants.ATTRIBUTE_TASK_IMPLEMENTATION))) //{ // sendTask.ImplementationType = ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE; // sendTask.OperationRef = parseOperationRef(xtr.getAttributeValue(BpmnXMLConstants.ATTRIBUTE_TASK_OPERATION_REF), model); //} ParseChildElements(XMLElementName, sendTask, model, xtr); return(sendTask); }
public virtual void ConvertToBpmnModel(XMLStreamReader xtr, BpmnModel model, Process activeProcess, IList <SubProcess> activeSubProcessList) { string elementId = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_ID); string elementName = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME); bool async = ParseAsync(xtr); bool notExclusive = ParseNotExclusive(xtr); string defaultFlow = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DEFAULT); bool isForCompensation = ParseForCompensation(xtr); BaseElement parsedElement = ConvertXMLToElement(xtr, model); if (parsedElement is Artifact currentArtifact) { currentArtifact.Id = elementId; if (activeSubProcessList.Count > 0) { activeSubProcessList[activeSubProcessList.Count - 1].AddArtifact(currentArtifact); } else { activeProcess.AddArtifact(currentArtifact); } } if (parsedElement is FlowElement currentFlowElement) { currentFlowElement.Id = elementId; currentFlowElement.Name = elementName; if (currentFlowElement is FlowNode flowNode) { flowNode.Asynchronous = async; flowNode.NotExclusive = notExclusive; if (currentFlowElement is Activity activity) { activity.ForCompensation = isForCompensation; if (!string.IsNullOrWhiteSpace(defaultFlow)) { activity.DefaultFlow = defaultFlow; } } if (currentFlowElement is Gateway gateway) { if (!string.IsNullOrWhiteSpace(defaultFlow)) { gateway.DefaultFlow = defaultFlow; } } } if (currentFlowElement is DataObject) { if (activeSubProcessList.Count > 0) { SubProcess subProcess = activeSubProcessList[activeSubProcessList.Count - 1]; subProcess.DataObjects.Add((ValuedDataObject)parsedElement); } else { activeProcess.DataObjects.Add((ValuedDataObject)parsedElement); } } if (activeSubProcessList.Count > 0) { SubProcess subProcess = activeSubProcessList[activeSubProcessList.Count - 1]; subProcess.AddFlowElement(currentFlowElement); } else { activeProcess.AddFlowElement(currentFlowElement); } } }
public override void ParseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) { string identityLinkType = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_NAME); // the attribute value may be unqualified if (identityLinkType is null) { identityLinkType = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_NAME); } if (identityLinkType is null) { return; } string resourceElement = XMLStreamReaderUtil.moveDown(xtr); if (!string.IsNullOrWhiteSpace(resourceElement) && BpmnXMLConstants.ELEMENT_RESOURCE_ASSIGNMENT.Equals(resourceElement)) { string expression = XMLStreamReaderUtil.moveDown(xtr); if (!string.IsNullOrWhiteSpace(expression) && BpmnXMLConstants.ELEMENT_FORMAL_EXPRESSION.Equals(expression)) { IList <string> assignmentList = CommaSplitter.SplitCommas(xtr.ElementText); for (var idx = 0; idx < assignmentList.Count; idx++) { string assignmentValue = assignmentList[idx]; if (assignmentValue is null) { continue; } assignmentValue = assignmentList[idx] = assignmentValue.Trim(); if (assignmentValue.Length == 0) { continue; } string userPrefix = "user("; string groupPrefix = "group("; if (assignmentValue.StartsWith(userPrefix, StringComparison.Ordinal)) { assignmentValue = assignmentList[idx] = StringHelper.SubstringSpecial(assignmentValue, userPrefix.Length, assignmentValue.Length - 1).Trim(); ((UserTask)parentElement).AddCustomUserIdentityLink(assignmentValue, identityLinkType); } else if (assignmentValue.StartsWith(groupPrefix, StringComparison.Ordinal)) { assignmentValue = assignmentList[idx] = StringHelper.SubstringSpecial(assignmentValue, groupPrefix.Length, assignmentValue.Length - 1).Trim(); ((UserTask)parentElement).AddCustomGroupIdentityLink(assignmentValue, identityLinkType); } else { ((UserTask)parentElement).AddCustomGroupIdentityLink(assignmentValue, identityLinkType); } } } } }
protected internal virtual void ParseChildElements(string elementName, BaseElement parentElement, IDictionary <string, BaseChildElementParser> additionalParsers, BpmnModel model, XMLStreamReader xtr) { IDictionary <string, BaseChildElementParser> childParsers = new Dictionary <string, BaseChildElementParser>(); if (additionalParsers != null) { childParsers.PutAll(additionalParsers); } BpmnXMLUtil.ParseChildElements(elementName, parentElement, xtr, childParsers, model); }
// To BpmnModel converter convenience methods protected internal virtual void ParseChildElements(string elementName, BaseElement parentElement, BpmnModel model, XMLStreamReader xtr) { ParseChildElements(elementName, parentElement, null, model, xtr); }
protected internal abstract BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model);
protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model) { ValuedDataObject dataObject = null; ItemDefinition itemSubjectRef = new ItemDefinition(); string structureRef = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DATA_ITEM_REF); if (!string.IsNullOrWhiteSpace(structureRef) && structureRef.Contains(":")) { string dataType = structureRef.Substring(structureRef.IndexOf(':') + 1); if (dataType.Equals("string")) { dataObject = new StringDataObject(); } else if (dataType.Equals("int")) { dataObject = new IntegerDataObject(); } else if (dataType.Equals("long")) { dataObject = new LongDataObject(); } else if (dataType.Equals("double")) { dataObject = new DoubleDataObject(); } else if (dataType.Equals("boolean")) { dataObject = new BooleanDataObject(); } else if (dataType.Equals("datetime")) { dataObject = new DateDataObject(); } else { logger.LogError($"Error converting {xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DATA_NAME)}, invalid data type: {dataType}"); } } else { // use String as default type dataObject = new StringDataObject(); structureRef = "xsd:string"; } if (dataObject != null) { dataObject.Id = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DATA_ID); dataObject.Name = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_DATA_NAME); BpmnXMLUtil.AddXMLLocation(dataObject, xtr); itemSubjectRef.StructureRef = structureRef; dataObject.ItemSubjectRef = itemSubjectRef; ParseChildElements(XMLElementName, dataObject, model, xtr); dataObject.ExtensionElements.TryGetValue("value", out IList <ExtensionElement> valuesElement); if (valuesElement != null && valuesElement.Count > 0) { ExtensionElement valueElement = valuesElement[0]; if (!string.IsNullOrWhiteSpace(valueElement.ElementText)) { if (dataObject is DateDataObject) { try { dataObject.Value = DateTime.Parse(valueElement.ElementText, new DateTimeFormatInfo() { FullDateTimePattern = sdf }); } catch (Exception e) { logger.LogError(e, $"Error converting {dataObject.Name} \r\n {e.Message}"); } } else { dataObject.Value = valueElement.ElementText; } } // remove value element dataObject.ExtensionElements.Remove("value"); } } return(dataObject); }