public virtual void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext 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) { // 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, 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, ProcessDefinitionBuildContext 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 override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext 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 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 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 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 override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext 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 override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext 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); 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 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 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); 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); 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 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 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 void ReadProcessDataTest() { XmlElement xmlElement = helloWorld1(); ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl(); ProcessDefinitionBuildContext processDefinitionBuilder = new ProcessDefinitionBuildContext(processDefinition, null, null); processDefinition.ReadProcessData(xmlElement, processDefinitionBuilder); Assert.AreEqual("Hello world 1", processDefinition.Name); Assert.AreEqual("This is the simples process.", processDefinition.Description); Assert.IsNotNull(processDefinition.StartState); Assert.AreEqual("start",processDefinition.StartState.Name); Assert.IsNotNull(processDefinition.EndState); Assert.AreEqual("end",processDefinition.EndState.Name); //activity-state在Nodes裏面,以後再換掉 }
public virtual void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext 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 virtual void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext 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 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 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 virtual void ReadWebData(XmlElement xmlElement, ProcessDefinitionBuildContext 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 virtual void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext 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); 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 override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext 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 DeployProcessArchive(Stream processArchiveStream, DbSession dbSession) { log.Debug("reading process archive..."); // construct an empty process definition ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl(); // Then save the process definition // This is done so hibernate will assign an id to this object. dbSession.Save(processDefinition); IDictionary<string, byte[]> entries = null; entries = ZipUtility.ReadEntries(processArchiveStream); ProcessDefinitionBuildContext processDefinitionBuilder = new ProcessDefinitionBuildContext(processDefinition, entries, dbSession); try { if (!entries.ContainsKey("processdefinition.xml")) { processDefinitionBuilder.AddError("entry '" + "processdefinition.xml" + "' found not found in the process archive"); throw new SystemException("entry '" + "processdefinition.xml" + "' found not found in the process archive"); } // parse the processdefinition.xml XmlElement xmlElement = getXmlElementFromBytes(entries["processdefinition.xml"]); // build the object model from the xml processDefinitionBuilder.PushScope("in processdefinition.xml"); processDefinition.ReadProcessData(xmlElement, processDefinitionBuilder); processDefinition.Version = GetVersionNr(processDefinitionBuilder, processDefinition.Name); processDefinition.ClassFiles = GetAssemblyFiles(processDefinitionBuilder, processDefinition); processDefinitionBuilder.PopScope(); // resolve all forward references processDefinitionBuilder.ResolveReferences(); processDefinition.Validate(processDefinitionBuilder); if (processDefinitionBuilder.HasErrors()) { throw new NpdlException(processDefinitionBuilder.Errors); } // read the optional web-interface information if (entries.ContainsKey("web/webinterface.xml")) { log.Debug("processing webinterface.xml..."); xmlElement = getXmlElementFromBytes(entries["web/webinterface.xml"]); processDefinitionBuilder.PushScope("in webinterface.xml"); processDefinition.ReadWebData(xmlElement, processDefinitionBuilder); processDefinitionBuilder.PopScope(); } else { log.Debug("no web/webinterface.xml was supplied"); } processDefinitionRepository.Save(processDefinition, dbSession); } catch (SystemException e) { log.Error("xml parsing error :", e); processDefinitionBuilder.AddError(e.GetType().FullName + " : " + e.Message); processDefinitionBuilder.AddError("couldn't continue to parse the process archive"); throw new NpdlException(processDefinitionBuilder.Errors); } }
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 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); }
private Int32 GetVersionNr(ProcessDefinitionBuildContext creationContext,string name) { int newVersion = 1; IEnumerator iter = creationContext.DbSession.Iterate(queryFindVersionNumbers, name, DbType.STRING).GetEnumerator(); if (iter.MoveNext()) { Int32 highestVersionNumber = (Int32)iter.Current; if ((Object)highestVersionNumber != null) { newVersion = highestVersionNumber + 1; } } if (iter.MoveNext()) { throw new NetBpm.Util.DB.DbException("duplicate value"); } return newVersion; }
public virtual ISet GetAssemblyFiles(ProcessDefinitionBuildContext creationContext,IProcessDefinition processDefinition) { ISet classFiles = new HashedSet(); IDictionary<string, byte[]> entries = creationContext.Entries; IEnumerator iter = entries.Keys.GetEnumerator(); while (iter.MoveNext()) { String entryName = (String)iter.Current; if ((entryName.StartsWith("lib")) && (entryName.EndsWith(".dll"))) { if (log.IsDebugEnabled) { log.Debug("attaching assembly file " + entryName); } byte[] classBytes = (byte[])entries[entryName]; if (log.IsDebugEnabled) { log.Debug("found assembly " + entryName); } Assembly assemply = Assembly.Load(classBytes); if (log.IsDebugEnabled) { log.Debug("attaching assembly name: " + assemply.GetName().Name + " Version:" + assemply.GetName().Version.ToString()); } AssemblyFileImpl assemblyFile = new AssemblyFileImpl(); assemblyFile.FileName = entryName; assemblyFile.Bytes = classBytes; assemblyFile.AssemblyName = assemply.GetName().Name; assemblyFile.AssemblyVersion = assemply.GetName().Version.ToString(); assemblyFile.ProcessDefinition = processDefinition; classFiles.Add(assemblyFile); } } return classFiles; }
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 override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext) { creationContext.DefinitionObject = this; base.ReadProcessData(xmlElement, creationContext); creationContext.DefinitionObject = null; }
public override void ReadWebData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext) { base.ReadWebData(xmlElement, creationContext); }
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); } }