/* package private */ internal virtual TransitionImpl GetTransition(String transitionName, StateImpl state, DbSession dbSession) { TransitionImpl transition = null; if ((Object)transitionName != null) { Object[] values = new Object[] { transitionName, state.Id }; IType[] types = new IType[] { DbType.STRING, DbType.LONG }; transition = (TransitionImpl)dbSession.FindOne(queryFindTransitionByName, values, types); } else { ISet leavingTransitions = state.LeavingTransitions; if (leavingTransitions.Count == 1) { IEnumerator transEnum = leavingTransitions.GetEnumerator(); transEnum.MoveNext(); transition = (TransitionImpl)transEnum.Current; } else { throw new SystemException("no transitionName was specified : this is only allowed if the state (" + state.Name + ") has exactly 1 leaving transition (" + leavingTransitions.Count + ")"); } } return transition; }
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 void CheckAccess(IDictionary attributeValues, StateImpl state) { IDictionary fields = new Hashtable(); // first we check if a value is supplied for all required fields IEnumerator iter = state.Fields.GetEnumerator(); log.Debug(iter); while (iter.MoveNext()) { FieldImpl field = (FieldImpl) iter.Current; String attributeName = field.Attribute.Name; fields[attributeName] = field; // if a field is found required and no attribute value is supplied throw // RequiredFieldException log.Debug(field); log.Debug(field.Access); if ((FieldAccessHelper.IsRequired(field.Access)) && (attributeValues == null)) { throw new RequiredFieldException(field); } // OR // if field is found required and attribute value of it is not available // throw RequiredFieldException if ((FieldAccessHelper.IsRequired(field.Access)) && (attributeValues != null) && (!attributeValues.Contains(attributeName))) { throw new RequiredFieldException(field); } } // then we check if the access of all supplied values is writable IList attributeNamesToBeRemoved = new ArrayList(); // store attribute name of attribute to be removed if (attributeValues != null) { iter = attributeValues.GetEnumerator(); while (iter.MoveNext()) { DictionaryEntry entry = (DictionaryEntry) iter.Current; String attributeName = (String) entry.Key; FieldImpl field = (FieldImpl) fields[attributeName]; if ((field != null) && (!FieldAccessHelper.IsWritable(field.Access))) { log.Warn("ignoring attributeValue for unwritable attribute '" + attributeName + "'"); // commented out cause will result in ConcurrentModificationException // instead copy its attribute name and remove later OR do a deep copy of the // attributeValues so there is one set that gets iterated and another that //gets deleted??? //attributeValues.remove( attributeName ); attributeNamesToBeRemoved.Add(attributeName); } } // now removed collected to be removed attribute IEnumerator itr = attributeNamesToBeRemoved.GetEnumerator(); while (itr.MoveNext()) { String an = (String) itr.Current; attributeValues.Remove(an); } } }