public IActivityForm GetActivityForm(String authenticatedActorId, Int64 flowId, DbSession dbSession, IOrganisationService organisationComponent) { IActivityForm activityForm = null; // First check if the actor is allowed to get this form authorizationHelper.CheckGetActivityForm(authenticatedActorId, flowId, dbSession); FlowImpl flow = (FlowImpl)dbSession.Load(typeof(FlowImpl), flowId); StateImpl state = (StateImpl)flow.Node; // create an executionContext for easy attributeValue retrieval ExecutionContextImpl executionContext = new ExecutionContextImpl(null, flow, dbSession, organisationComponent); // create a convenient map from the attribute-names to the fields IList fields = fieldRepository.FindFieldsByState(state.Id, dbSession); IDictionary attributeValues = new Hashtable(); IEnumerator iter = fields.GetEnumerator(); while (iter.MoveNext()) { FieldImpl field = (FieldImpl)iter.Current; if (FieldAccessHelper.IsReadable(field.Access) || FieldAccessHelper.IsWritable(field.Access)) { // activity form contains only readable or writeable fields String attributeName = field.Attribute.Name; if (executionContext.GetAttribute(attributeName) != null) { // attribute might not exist (this will cause a warning already being logged previusly) attributeValues[attributeName] = executionContext.GetAttribute(attributeName); } } } activityForm = new ActivityFormImpl(flow, fields, attributeValues); return(activityForm); }