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) { 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 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 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); } }