Ejemplo n.º 1
0
        //private const String queryFindAttributeInstanceByName = "select ai " +
        //    "from ai in class NetBpm.Workflow.Execution.Impl.AttributeInstanceImpl, " +
        //    "     f in class NetBpm.Workflow.Execution.Impl.FlowImpl " +
        //    "where ai.Scope = f.id " + "  and ai.Attribute.Name = ? " +
        //    "  and f.id = ? ";

        private AttributeInstanceImpl FindAttributeInstanceInScope(String attributeName)
        {
            AttributeInstanceImpl attributeInstance = null;
            FlowImpl scope = this._flow;

            while (attributeInstance == null)
            {
                IList       attributes = attributeRepository.FindAttributeInstanceByName(attributeName, scope.Id, _dbSession);
                IEnumerator iter       = attributes.GetEnumerator();
                if (iter.MoveNext())
                {
                    attributeInstance = (AttributeInstanceImpl)iter.Current;
                    if (iter.MoveNext())
                    {
                        throw new NetBpm.Util.DB.DbException("duplicate value");
                    }
                }
                else
                {
                    if (!scope.IsRootFlow())
                    {
                        scope = (FlowImpl)scope.Parent;
                    }
                    else
                    {
                        //throw new RuntimeException( "couldn't find attribute-instance '" + attributeName + "' in scope of flow '" + this.flow + "'" );
                        // log a warning message (indicate that attribute supplied is not defined in attribute-instance in db)
                        log.Warn("couldn't find attribute-instance '" + attributeName + "' in scope of flow '" + this._flow + "'");
                        break;
                    }
                }
            }
            return(attributeInstance);
        }
Ejemplo n.º 2
0
        public virtual Object GetAttribute(String name)
        {
            AttributeInstanceImpl attributeInstance = FindAttributeInstanceInScope(name);

            if (attributeInstance != null)
            {
                // attribute might not be available (a warning should have been logged previosly)
                return(attributeInstance.GetValue());
            }
            return(null);
        }
Ejemplo n.º 3
0
        public void SetAttribute(String name, Object valueObject)
        {
            AttributeInstanceImpl attributeInstance = FindAttributeInstanceInScope(name);

            if (attributeInstance != null)
            {
                // ignore if cannot find attribute instance (warning should have been logged prviously)
                attributeInstance.SetValue(valueObject);
                this.AddLogDetail(new AttributeUpdateImpl(attributeInstance));
            }
        }
Ejemplo n.º 4
0
        public virtual void CreateAttributeInstances(ISet attributes)
        {
            this._attributeInstances = new ListSet();
            IEnumerator iter = attributes.GetEnumerator();

            while (iter.MoveNext())
            {
                AttributeImpl attribute     = (AttributeImpl)iter.Current;
                String        attributeName = attribute.Name;
                log.Debug("creating the attribute " + attribute + " for flow " + this);
                AttributeInstanceImpl attributeInstance = new AttributeInstanceImpl(attribute, this);
                attributeInstance.ValueText = attribute.InitialValue;
                this._attributeInstances.Add(attributeInstance);
            }
        }
Ejemplo n.º 5
0
        //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);
        }
Ejemplo n.º 6
0
        //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;
        }
Ejemplo n.º 7
0
 public virtual void CreateAttributeInstances(ISet attributes)
 {
     this._attributeInstances = new ListSet();
     IEnumerator iter = attributes.GetEnumerator();
     while (iter.MoveNext())
     {
         AttributeImpl attribute = (AttributeImpl) iter.Current;
         String attributeName = attribute.Name;
         log.Debug("creating the attribute " + attribute + " for flow " + this);
         AttributeInstanceImpl attributeInstance = new AttributeInstanceImpl(attribute, this);
         attributeInstance.ValueText = attribute.InitialValue;
         this._attributeInstances.Add(attributeInstance);
     }
 }
Ejemplo n.º 8
0
		public AttributeUpdateImpl(AttributeInstanceImpl attributeInstance)
		{
			this._attribute = attributeInstance.Attribute;
			this._valueText = attributeInstance.ValueText;
		}