//private const String queryFieldsByState = "select f from f in class NetBpm.Workflow.Definition.Impl.FieldImpl " + // "where f.State.Id = ? " + // "order by f.Index"; public IActivityForm GetStartForm(String authenticatedActorId, Int64 processDefinitionId, DbSession dbSession, IOrganisationService organisationComponent) { IActivityForm activityForm = null; // First check if the actor is allowed to get this form authorizationHelper.CheckGetStartForm(authenticatedActorId, processDefinitionId, dbSession); ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl)dbSession.Load(typeof(ProcessDefinitionImpl), processDefinitionId); StartStateImpl startState = (StartStateImpl)processDefinition.StartState; // create a convenient map from the attribute-names to the fields IList fields = fieldRepository.FindFieldsByState(startState.Id, dbSession); IDictionary attributeValues = new Hashtable(); IEnumerator iter = fields.GetEnumerator(); while (iter.MoveNext()) { FieldImpl field = (FieldImpl)iter.Current; // if the attribute has an initial value AttributeImpl attribute = (AttributeImpl)field.Attribute; String attributeName = attribute.Name; String initialValue = attribute.InitialValue; if ((Object)initialValue != null && (FieldAccessHelper.IsReadable(field.Access) || FieldAccessHelper.IsWritable(field.Access))) { // start form contains only fields that are readable or writable // get it and store it in the attributeValues AttributeInstanceImpl attributeInstance = new AttributeInstanceImpl(); attributeInstance.Attribute = attribute; attributeInstance.ValueText = initialValue; attributeValues[attributeName] = attributeInstance.GetValue(); } } activityForm = new ActivityFormImpl(processDefinition, fields, attributeValues); return(activityForm); }
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); }
//private const String queryFieldsByState = "select f from f in class NetBpm.Workflow.Definition.Impl.FieldImpl " + // "where f.State.Id = ? " + // "order by f.Index"; public IActivityForm GetStartForm(String authenticatedActorId, Int64 processDefinitionId, DbSession dbSession, IOrganisationService organisationComponent) { IActivityForm activityForm = null; // First check if the actor is allowed to get this form authorizationHelper.CheckGetStartForm(authenticatedActorId, processDefinitionId, dbSession); ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) dbSession.Load(typeof (ProcessDefinitionImpl), processDefinitionId); StartStateImpl startState = (StartStateImpl) processDefinition.StartState; // create a convenient map from the attribute-names to the fields IList fields = fieldRepository.FindFieldsByState(startState.Id, dbSession); IDictionary attributeValues = new Hashtable(); IEnumerator iter = fields.GetEnumerator(); while (iter.MoveNext()) { FieldImpl field = (FieldImpl) iter.Current; // if the attribute has an initial value AttributeImpl attribute = (AttributeImpl) field.Attribute; String attributeName = attribute.Name; String initialValue = attribute.InitialValue; if ((Object) initialValue != null && (FieldAccessHelper.IsReadable(field.Access) || FieldAccessHelper.IsWritable(field.Access))) { // start form contains only fields that are readable or writable // get it and store it in the attributeValues AttributeInstanceImpl attributeInstance = new AttributeInstanceImpl(); attributeInstance.Attribute = attribute; attributeInstance.ValueText = initialValue; attributeValues[attributeName] = attributeInstance.GetValue(); } } activityForm = new ActivityFormImpl(processDefinition, fields, attributeValues); return activityForm; }
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; }