public override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext) { // the fork and join are created in the parent block but we'll add them // also as referencable objects to this block's scope a few lines below _parentBlock = creationContext.ProcessBlock; this._join = new JoinImpl(); this._fork = new ForkImpl(); creationContext.ProcessBlock = this; base.ReadProcessData(xmlElement, creationContext); XmlElement joinElement = xmlElement.GetChildElement("join"); creationContext.Check((joinElement != null), "element join is missing"); XmlElement forkElement = xmlElement.GetChildElement("fork"); creationContext.Check((joinElement != null), "element fork is missing"); ((JoinImpl) this._join).ReadProcessData(joinElement, creationContext); ((ForkImpl) this._fork).ReadProcessData(forkElement, creationContext); creationContext.ProcessBlock = _parentBlock; this._nodes.Add(_join); this._nodes.Add(_fork); // add the fork and join as referencable objects in the proper scope creationContext.AddReferencableObject(_fork.Name, _parentBlock, typeof (INode), _fork); creationContext.AddReferencableObject(_join.Name, this, typeof (INode), _join); }
public override void ReadProcessData(XmlElement xmlElement, CreationContext creationContext) { base.ReadProcessData(xmlElement, creationContext); // get the process definition for that name String subProcessDefinitionName = xmlElement.GetProperty("process"); creationContext.Check(((Object) subProcessDefinitionName != null), "process is missing in the process state : " + subProcessDefinitionName); DbSession dbSession = creationContext.DbSession; dbSession.SaveOrUpdate(this._processDefinition); try { this._subProcess = (ProcessDefinitionImpl) dbSession.FindOne(queryFindProcessDefinitionByName, subProcessDefinitionName, DbType.STRING); } catch (SystemException e) { creationContext.AddError("process '" + subProcessDefinitionName + "' was not deployed while it is referenced in a process-state. Exception: " + e.Message); } // parse the processInvokerDelegation creationContext.DelegatingObject = this; this._processInvokerDelegation = new DelegationImpl(); XmlElement invocationElement = xmlElement.GetChildElement("process-invocation"); creationContext.Check((invocationElement != null), "process-invocation is missing in the process-state : " + xmlElement); this._processInvokerDelegation.ReadProcessData(invocationElement, creationContext); creationContext.DelegatingObject = null; // parse the actorExpression this._actorExpression = xmlElement.GetProperty("actor-expression"); creationContext.Check(((Object) _actorExpression != null), "actor-expression is missing in the process-state : " + xmlElement); }
public void ReadProcessData(XmlElement xmlElement, CreationContext creationContext) { DefinitionObjectImpl definitionObject = creationContext.DefinitionObject; // first make sure the definitionObject has got an id DbSession dbSession = creationContext.DbSession; dbSession.SaveOrUpdate(definitionObject); // store the reference link to the definitionObject this._definitionObjectId = definitionObject.Id; log.Debug("adding action : "); log.Debug(" definitionObjectId: " + _definitionObjectId); log.Debug(" definitionObject: " + definitionObject); this._eventType = EventTypeHelper.fromText(xmlElement.GetAttribute("event")); log.Debug("action on eventType '" + _eventType + "' and definitionObject " + creationContext.DefinitionObject); // reading the action delegation creationContext.DelegatingObject = this; this._actionDelegation = new DelegationImpl(); this._actionDelegation.ReadProcessData(xmlElement, creationContext); creationContext.DelegatingObject = null; dbSession.SaveOrUpdate(this); }
public override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext) { base.ReadProcessData(xmlElement, creationContext); creationContext.DelegatingObject = this; this._decisionDelegation = new DelegationImpl(); this._decisionDelegation.ReadProcessData(xmlElement, creationContext); creationContext.DelegatingObject = null; }
public override void ReadProcessData(XmlElement xmlElement, CreationContext creationContext) { DefinitionObjectImpl parent = creationContext.DefinitionObject; creationContext.DefinitionObject = this; base.ReadProcessData(xmlElement, creationContext); creationContext.DefinitionObject = parent; this._from = creationContext.Node; creationContext.AddUnresolvedReference(this, xmlElement.GetProperty("to"), creationContext.TransitionDestinationScope, "to", typeof (INode)); }
public virtual void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext) { this._processDefinition = creationContext.ProcessDefinition; Type delegatingObjectClass = creationContext.DelegatingObject.GetType(); if (delegatingObjectClass == typeof (AttributeImpl)) { String type = xmlElement.GetProperty("type"); if ((Object) type != null) { this._className = ((String) attributeTypes[type]); string suportedTypes = "supported types: "; foreach (Object o in attributeTypes.Keys) { suportedTypes += o.ToString() + " ,"; } creationContext.Check(((Object) this._className != null), "attribute type '" + type + "' is not supported. " + suportedTypes +" !"); } else { this._className = xmlElement.GetProperty("serializer"); creationContext.Check(((Object) this._className != null), "for an attribute, you must specify either a type or a serializer"); } } else if (delegatingObjectClass == typeof (FieldImpl)) { this._className = xmlElement.GetProperty("class"); creationContext.Check(((Object) this._className != null), "no class specified for a delegation : " + xmlElement); } else { this._className = xmlElement.GetProperty("handler"); creationContext.Check(((Object) this._className != null), "no handler specified for a delegation : " + xmlElement); } log.Debug("parsing delegation for tag '" + xmlElement.Name + "' : " + this._className); // parse the exception handler String exceptionHandlerText = xmlElement.GetAttribute("on-exception"); if ((Object) exceptionHandlerText != null) { _exceptionHandlingType = ExceptionHandlingTypeHelper.FromText(exceptionHandlerText); creationContext.Check((_exceptionHandlingType != 0), "unknown exception handler '" + exceptionHandlerText + "' in delegation " + xmlElement); } // create the configuration string XmlElement configurationXml = new XmlElement("cfg"); IEnumerator iter = xmlElement.GetChildElements("parameter").GetEnumerator(); while (iter.MoveNext()) { configurationXml.AddChild((XmlElement) iter.Current); } _configuration = configurationXml.ToString(); }
public override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext) { base.ReadProcessData(xmlElement, creationContext); if ((Object) xmlElement.GetAttribute("handler") != null) { creationContext.DelegatingObject = this; this._forkDelegation = new DelegationImpl(); this._forkDelegation.ReadProcessData(xmlElement, creationContext); creationContext.DelegatingObject = null; } }
public override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext) { base.ReadProcessData(xmlElement, creationContext); this._scope = creationContext.ProcessBlock; this._initialValue = xmlElement.GetProperty("initial-value"); creationContext.DelegatingObject = this; this._serializerDelegation = new DelegationImpl(); this._serializerDelegation.ReadProcessData(xmlElement, creationContext); creationContext.DelegatingObject = null; creationContext.AddReferencableObject(_name, (ProcessBlockImpl) this._scope, typeof (IAttribute), this); }
public void AddChild(XmlElement child) { String childName = child.Name; IList namedChildren = (IList) _children[childName]; if (namedChildren == null) { namedChildren = new ArrayList(); _children[childName] = namedChildren; } namedChildren.Add(child); _content.Add(child); }
public override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext) { base.ReadProcessData(xmlElement, creationContext); XmlElement assignmentElement = xmlElement.GetChildElement("assignment"); if (assignmentElement != null) { creationContext.DelegatingObject = this; this._assignmentDelegation = new DelegationImpl(); this._assignmentDelegation.ReadProcessData(assignmentElement, creationContext); creationContext.DelegatingObject = null; } this._actorRoleName = xmlElement.GetProperty("role"); }
public void ReadProcessData(XmlElement xmlElement, CreationContext creationContext) { String attributeName = xmlElement.GetProperty("attribute"); creationContext.Check(((Object) attributeName != null), "attribute is a required property in element field : " + xmlElement); log.Debug("parsing field for attribute '" + attributeName); creationContext.AddUnresolvedReference(this, attributeName, creationContext.ProcessBlock, "attribute", typeof (IAttribute)); this._state = creationContext.State; String accessText = xmlElement.GetProperty("access"); creationContext.Check(((Object) accessText != null), "access is a required property in element field : " + xmlElement); this._access = FieldAccessHelper.fromText(accessText); }
public override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext) { base.ReadProcessData(xmlElement, creationContext); creationContext.State = this; this._fields = new ListSet(); IEnumerator iter = xmlElement.GetChildElements("field").GetEnumerator(); while (iter.MoveNext()) { FieldImpl field = new FieldImpl(); field.ReadProcessData((XmlElement) iter.Current, creationContext); _fields.Add(field); } creationContext.State = null; }
public virtual void ReadProcessData(XmlElement xmlElement, CreationContext creationContext) { this._name = xmlElement.GetProperty("name"); log.Debug("parsing '" + xmlElement.Name + "' with name '" + _name + "'"); this._description = xmlElement.GetProperty("description"); this._processDefinition = creationContext.ProcessDefinition; IEnumerator iter = xmlElement.GetChildElements("action").GetEnumerator(); while (iter.MoveNext()) { creationContext.DefinitionObject = this; XmlElement actionElement = (XmlElement) iter.Current; ActionImpl action = new ActionImpl(); action.ReadProcessData(actionElement, creationContext); creationContext.DefinitionObject = null; } }
public void ReadWebData(XmlElement xmlElement, CreationContext creationContext) { this._name = xmlElement.GetProperty("name"); this._description = xmlElement.GetProperty("description"); this._index = creationContext.Index; log.Debug("paring web information for field " + _name); creationContext.DelegatingObject = this; XmlElement formatterElement = xmlElement.GetChildElement("htmlformatter"); if (formatterElement != null) { this._htmlFormatterDelegation = new DelegationImpl(); this._htmlFormatterDelegation.ReadProcessData(formatterElement, creationContext); } creationContext.DelegatingObject = null; }
public override void ReadProcessData(XmlElement xmlElement, CreationContext creationContext) { base.ReadProcessData(xmlElement, creationContext); this._arrivingTransitions = new ListSet(); this._leavingTransitions = new ListSet(); this._processBlock = creationContext.ProcessBlock; creationContext.Node = this; this.TransitionDestinationScope = creationContext; IEnumerator iter = xmlElement.GetChildElements("transition").GetEnumerator(); while (iter.MoveNext()) { XmlElement transitionElement = (XmlElement) iter.Current; TransitionImpl transition = new TransitionImpl(); transition.ReadProcessData(transitionElement, creationContext); _leavingTransitions.Add(transition); } creationContext.TransitionDestinationScope = null; creationContext.Node = null; creationContext.AddReferencableObject(_name, (ProcessBlockImpl) this._processBlock, typeof (INode), this); }
public void TestXmlParser() { XmlTextReader exampleXml = new XmlTextReader( TestHelper.GetExampleDir() + "process\\holiday\\processdefinition.xml"); XmlParser xmlParser = new XmlParser(exampleXml); XmlElement element = xmlParser.Parse(); XmlElement startstate = element.GetChildElement("start-state"); Assert.IsNotNull(startstate); Assert.IsNotNull(startstate.GetAttribute("name")); XmlElement endstate = element.GetChildElement("end-state"); Assert.IsNotNull(endstate); Assert.IsNotNull(endstate.GetAttribute("name")); IList pdattr = element.GetChildElements("attribute"); Assert.IsNotNull(pdattr); Assert.IsTrue(pdattr.Count > 1); }
public override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext) { this._nodes = new ListSet(); this._attributes = new ListSet(); this._childBlocks = new ListSet(); base.ReadProcessData(xmlElement, creationContext); IEnumerator iter = xmlElement.GetChildElements("attribute").GetEnumerator(); while (iter.MoveNext()) { AttributeImpl attribute = new AttributeImpl(); attribute.ReadProcessData((XmlElement) iter.Current, creationContext); _attributes.Add(attribute); } iter = xmlElement.GetChildElements("activity-state").GetEnumerator(); while (iter.MoveNext()) { ActivityStateImpl activityState = new ActivityStateImpl(); activityState.ReadProcessData((XmlElement) iter.Current, creationContext); _nodes.Add(activityState); } iter = xmlElement.GetChildElements("process-state").GetEnumerator(); while (iter.MoveNext()) { ProcessStateImpl processState = new ProcessStateImpl(); processState.ReadProcessData((XmlElement) iter.Current, creationContext); _nodes.Add(processState); } iter = xmlElement.GetChildElements("decision").GetEnumerator(); while (iter.MoveNext()) { DecisionImpl decision = new DecisionImpl(); decision.ReadProcessData((XmlElement) iter.Current, creationContext); _nodes.Add(decision); } iter = xmlElement.GetChildElements("concurrent-block").GetEnumerator(); while (iter.MoveNext()) { ConcurrentBlockImpl concurrentBlock = new ConcurrentBlockImpl(); concurrentBlock.ReadProcessData((XmlElement) iter.Current, creationContext); _childBlocks.Add(concurrentBlock); } }
public override void ReadWebData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext) { base.ReadWebData(xmlElement, creationContext); }
public override void ReadProcessData(XmlElement xmlElement, CreationContext creationContext) { base.ReadProcessData(xmlElement, creationContext); }
public override void ReadProcessData(XmlElement xmlElement, CreationContext creationContext) { creationContext.DefinitionObject = this; base.ReadProcessData(xmlElement, creationContext); creationContext.DefinitionObject = null; }
public virtual void ReadWebData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext) { // first read the image XmlElement imageElement = xmlElement.GetChildElement("image"); creationContext.Check((imageElement != null), "element image is missing"); // reading the image-file String imageFileName = imageElement.GetProperty("name"); creationContext.Check(((Object) imageFileName != null), "image name is missing"); this._image = (byte[]) creationContext.Entries[imageFileName]; if (this._image == null) { creationContext.AddError("couldn't find image file '" + imageFileName + "' in the process archive. (make sure the specified path is relative to the archive-root)"); } this._imageMimeType = imageElement.GetProperty("mime-type"); creationContext.Check(((Object) _imageMimeType != null), "image mime-type is missing"); try { _imageHeight = Int32.Parse(imageElement.GetProperty("height")); creationContext.Check(((Object) _imageHeight != null), "image height is missing"); _imageWidth = Int32.Parse(imageElement.GetProperty("width")); creationContext.Check(((Object) _imageWidth != null), "image width is missing"); } catch (FormatException e) { creationContext.AddError("image height or width contains unparsable numbers : height=\"" + imageElement.GetProperty("height") + "\" width=\"" + imageElement.GetProperty("width") + "\". Exception: " + e.Message); } DbSession dbSession = creationContext.DbSession; // then the activity-states IEnumerator iter = xmlElement.GetChildElements("activity-state").GetEnumerator(); while (iter.MoveNext()) { XmlElement activityStateElement = (XmlElement) iter.Current; String activityStateName = activityStateElement.GetProperty("name"); creationContext.Check(((Object) activityStateName != null), "property name in activity state is missing"); Object[] values = new Object[] {activityStateName, _id}; IType[] types = new IType[] {DbType.STRING, DbType.LONG}; StateImpl state = null; try { state = (StateImpl) dbSession.FindOne(queryFindState, values, types); } catch (DbException e) { creationContext.AddError("activity-state '" + activityStateName + "' was referenced from the webinterface.xml but not defined in the processdefinition.xml. Exception:" + e.Message); } state.ReadWebData(activityStateElement, creationContext); } }
public virtual void ReadWebData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext) { XmlElement coordinatesXmlElement = xmlElement.GetChildElement("image-coordinates"); if (coordinatesXmlElement != null) { try { _x1 = Int32.Parse(coordinatesXmlElement.GetProperty("x1")); _y1 = Int32.Parse(coordinatesXmlElement.GetProperty("y1")); _x2 = Int32.Parse(coordinatesXmlElement.GetProperty("x2")); _y2 = Int32.Parse(coordinatesXmlElement.GetProperty("y2")); creationContext.Check((((Object) _x1 != null) && ((Object) _y1 != null) && ((Object) _x2 != null) && ((Object) _y2 != null)), "at least one of the image-coordinates (x1,y1,x2,y2) is missing : " + xmlElement); } catch (FormatException e) { creationContext.AddError("at least one of the image-coordinates is not parsable : " + xmlElement + " exception:" + e.Message); } } DbSession dbSession = creationContext.DbSession; creationContext.State = this; creationContext.Index = 0; IEnumerator iter = xmlElement.GetChildElements("field").GetEnumerator(); while (iter.MoveNext()) { XmlElement fieldElement = (XmlElement) iter.Current; String attributeName = fieldElement.GetProperty("attribute"); FieldImpl field = null; Object[] values = new Object[] {_id, attributeName}; IType[] types = new IType[] {DbType.LONG, DbType.STRING}; IList fields = dbSession.Find(queryFindFieldByActivityStateAndAttributeName, values, types); if (fields.Count == 1) { field = (FieldImpl) fields[0]; } else { values = new Object[] {_processBlock.Id, attributeName}; types = new IType[] {DbType.LONG, DbType.STRING}; AttributeImpl attribute = (AttributeImpl) dbSession.FindOne(queryFindAttibuteByName, values, types); field = new FieldImpl(); field.Access = FieldAccess.READ_WRITE; field.State = this; field.Attribute = attribute; this._fields.Add(field); } field.ReadWebData(fieldElement, creationContext); creationContext.IncrementIndex(); } }
public XmlElement helloWorld1() { /* <?xml version="1.0"?> <process-definition> <name>Hello world 1</name> <description>This is the simples process.</description> <start-state name="start"> <transition to="first activity state" /> </start-state> <end-state name="end" /> <activity-state name="first activity state"> <description>this is the first state</description> <assignment handler="NetBpm.Workflow.Delegation.Impl.Assignment.AssignmentExpressionResolver, NetBpm"> <parameter name="expression">processInitiator</parameter> </assignment> <transition to="end" /> </activity-state> </process-definition> */ #region create Xml XmlElement xmlElement = new XmlElement("process-definition"); XmlElement nameElement = new XmlElement("name"); nameElement.Content.Add("Hello world 1"); XmlElement descriptionElement = new XmlElement("description"); descriptionElement.Content.Add("This is the simples process."); XmlElement startStateElement = new XmlElement("start-state"); startStateElement.Attributes.Add("name", "start"); XmlElement transitionElement = new XmlElement("transition"); transitionElement.Attributes.Add("to", "first activity state"); startStateElement.AddChild(transitionElement); XmlElement endStateElement = new XmlElement("end-state"); endStateElement.Attributes.Add("name", "end"); XmlElement activityStateElement = new XmlElement("activity-state"); activityStateElement.Attributes.Add("name", "first activity state"); XmlElement activityStateDescriptionElement = new XmlElement("description"); activityStateDescriptionElement.Content.Add("this is the first state"); XmlElement assignmentElement = new XmlElement("assignment"); assignmentElement.Attributes.Add("handler", "NetBpm.Workflow.Delegation.Impl.Assignment.AssignmentExpressionResolver, NetBpm"); XmlElement parameterElement = new XmlElement("parameter"); parameterElement.Attributes.Add("name", "expression"); parameterElement.Content.Add("processInitiator"); assignmentElement.AddChild(parameterElement); XmlElement activityStateTransitionElement = new XmlElement("transition"); activityStateTransitionElement.Attributes.Add("to", "end"); activityStateElement.AddChild(activityStateDescriptionElement); activityStateElement.AddChild(assignmentElement); activityStateElement.AddChild(activityStateTransitionElement); xmlElement.AddChild(nameElement); xmlElement.AddChild(descriptionElement); xmlElement.AddChild(startStateElement); xmlElement.AddChild(endStateElement); xmlElement.AddChild(activityStateElement); #endregion return xmlElement; }
public override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext) { this._endState = new EndStateImpl(); this._startState = new StartStateImpl(); // read the process-block contents, the start- and the end-state creationContext.ProcessBlock = this; base.ReadProcessData(xmlElement, creationContext); XmlElement startElement = xmlElement.GetChildElement("start-state"); creationContext.Check((startElement != null), "element start-state is missing"); XmlElement endElement = xmlElement.GetChildElement("end-state"); creationContext.Check((endElement != null), "element end-state is missing"); _startState.ReadProcessData(startElement, creationContext); _endState.ReadProcessData(endElement, creationContext); creationContext.ProcessBlock = null; // add the start & end state to the nodes of this process definition this._nodes.Add(_startState); this._nodes.Add(_endState); // add the end state as referencable object creationContext.AddReferencableObject(this._endState.Name, this, typeof (INode), this._endState); // read the optional authorization handler XmlElement authorizationElement = xmlElement.GetChildElement("authorization"); if (authorizationElement != null) { creationContext.DelegatingObject = this; this.authorizationDelegation = new DelegationImpl(); this.authorizationDelegation.ReadProcessData(authorizationElement, creationContext); creationContext.DelegatingObject = null; } // read the optional responsible for this process definition this._responsibleUserName = xmlElement.GetProperty("responsible"); // calculate the version of this process definition //todo 這行應該移到ProcessDefinitionService //this._version = GetVersionNr(creationContext); // attach the class files to this process definitions //todo 這行應該移到ProcessDefinitionService //this._classFiles = GetAssemblyFiles(creationContext); }
public void RemoveXmlElement(XmlElement delegateXmlElement) { IList namedChildren = (IList) _children[delegateXmlElement.Name]; namedChildren.Remove(delegateXmlElement); _content.Remove(delegateXmlElement); }
private Object GetObject(XmlElement xmlElement) { Object object_Renamed = null; String className = xmlElement.GetProperty("class"); if (((Object) className == null) || ("java.lang.String".Equals(className))) { object_Renamed = GetText(xmlElement); } else if ("java.util.List".Equals(className)) { object_Renamed = GetList(xmlElement); } else if ("java.util.Map".Equals(className)) { object_Renamed = GetMap(xmlElement); } else { log.Error("Error getting object->@portme"); //@portme /* try { Type clazz = Type.GetType(className); System.Reflection.ConstructorInfo constructor = clazz.GetConstructor(constructorArgumentTypes); object_Renamed = constructor.newInstance(new Object[]{xmlElement.getContentString()}); } catch (System.Exception t) { log.Error("Error getting object", t); }*/ } return object_Renamed; }
private IDictionary GetMap(XmlElement xmlElement) { IDictionary map = new Hashtable(); IList elementXmlElements = xmlElement.GetChildElements("entry"); IEnumerator iter = elementXmlElements.GetEnumerator(); while (iter.MoveNext()) { XmlElement entryXmlElement = (XmlElement) iter.Current; // get the key XmlElement key = entryXmlElement.GetChildElement("key"); if (key == null) throw new SystemException("an <entry> must contain exactly one <key> sub-element"); // get the value XmlElement valueObject = entryXmlElement.GetChildElement("value"); if (valueObject == null) throw new SystemException("an <entry> must contain exactly one <value> sub-element"); map[GetObject(key)] = GetObject(valueObject); } return map; }
private IList GetList(XmlElement xmlElement) { IList list = new ArrayList(); IList elementXmlElements = xmlElement.GetChildElements("element"); IEnumerator iter = elementXmlElements.GetEnumerator(); while (iter.MoveNext()) { list.Add(GetObject((XmlElement) iter.Current)); } return list; }
private String GetText(XmlElement xmlElement) { return xmlElement.GetContentString().Trim(); }