public void Load()
        {
            var autoIndex = Convert.ToInt16(_process.MasterEntity == null ? 0 : new Fields(_process.MasterEntity.Fields, _process.MasterEntity.CalculatedFields).Count + 1);

            foreach (var f in _calculatedFields)
            {
                var field = new FieldReader(_process, _process.MasterEntity, false).Read(f);

                if (field.Index.Equals(short.MaxValue))
                {
                    field.Index = autoIndex;
                }

                field.Input        = false;
                field.IsCalculated = true;
                field.Index        = field.Index == 0 ? autoIndex : field.Index;
                _process.CalculatedFields.Add(field);

                foreach (var t in f.Transforms)
                {
                    var factory    = new TransformOperationFactory(_process, string.Empty);
                    var parameters = new ProcessTransformParametersReader(_process, new DefaultFactory(_process.Logger)).Read(t);
                    var operation  = factory.Create(field, t, parameters);

                    _process.TransformOperations.Add(operation);
                    foreach (var parameter in parameters)
                    {
                        _process.Parameters[parameter.Key] = parameter.Value;
                    }
                }

                autoIndex++;
            }
        }
        public void Load() {

            var autoIndex = Convert.ToInt16(_process.MasterEntity == null ? 0 : new Fields(_process.MasterEntity.Fields, _process.MasterEntity.CalculatedFields).Count + 1);

            foreach (var f in _calculatedFields) {
                var field = new FieldReader(_process, _process.MasterEntity, false).Read(f);

                if (field.Index.Equals(short.MaxValue)) {
                    field.Index = autoIndex;
                }

                field.Input = false;
                field.IsCalculated = true;
                field.Index = field.Index == 0 ? autoIndex : field.Index;
                _process.CalculatedFields.Add(field);

                foreach (var t in f.Transforms) {

                    var factory = new TransformOperationFactory(_process, string.Empty);
                    var parameters = new ProcessTransformParametersReader(_process, new DefaultFactory(_process.Logger)).Read(t);
                    var operation = factory.Create(field, t, parameters);

                    _process.TransformOperations.Add(operation);
                    foreach (var parameter in parameters) {
                        _process.Parameters[parameter.Key] = parameter.Value;
                    }
                }

                autoIndex++;
            }
        }
Esempio n. 3
0
        public void Load()
        {
            foreach (var entityElement in _entities)
            {
                var entity  = _process.Entities.First(e => e.Alias == entityElement.Alias);
                var factory = new TransformOperationFactory(_process, entity.Name);

                //fields can have prefixes and are limited to literal parameters (parameters with name and value provided in configuration)
                foreach (var f in entityElement.Fields)
                {
                    var alias = Common.GetAlias(f, true, entityElement.Prefix);
                    var field = _process.GetField(entity.Alias, alias);

                    if (entity.TrimAll && field.Input && field.SimpleType.Equals("string"))
                    {
                        field.Transforms.Insert(0, "trim");
                        entity.OperationsAfterAggregation.Add(new TrimOperation(field.Alias, field.Alias, " "));
                    }

                    foreach (var t in f.Transforms)
                    {
                        field.Transforms.Add(t.Method.ToLower());
                        var reader = new FieldParametersReader(new DefaultFactory(_process.Logger));
                        if (t.BeforeAggregation)
                        {
                            entity.OperationsBeforeAggregation.Add(factory.Create(field, t, reader.Read(t)));
                        }
                        if (t.AfterAggregation)
                        {
                            entity.OperationsAfterAggregation.Add(factory.Create(field, t, reader.Read(t)));
                        }
                        AddBranches(t.Branches, entity, field, reader);
                    }
                }

                // calculated fields do not have prefixes, and have access to all or some of an entity's parameters
                foreach (var cf in entityElement.CalculatedFields)
                {
                    var field = _process.GetField(entity.Alias, cf.Alias);

                    foreach (var t in cf.Transforms)
                    {
                        var reader = new EntityTransformParametersReader(entity, _process.Logger);

                        if (t.BeforeAggregation)
                        {
                            entity.OperationsBeforeAggregation.Add(factory.Create(field, t, reader.Read(t)));
                        }
                        if (t.AfterAggregation)
                        {
                            entity.OperationsAfterAggregation.Add(factory.Create(field, t, reader.Read(t)));
                        }
                        AddBranches(t.Branches, entity, field, reader);
                    }
                }
            }
        }
        public void Load() {
            foreach (var entityElement in _entities) {

                var entity = _process.Entities.First(e => e.Alias == entityElement.Alias);
                var factory = new TransformOperationFactory(_process, entity.Name);

                //fields can have prefixes and are limited to literal parameters (parameters with name and value provided in configuration)
                foreach (var f in entityElement.Fields) {

                    var alias = Common.GetAlias(f, true, entityElement.Prefix);
                    var field = _process.GetField(entity.Alias, alias);

                    if (entity.TrimAll && field.Input && field.SimpleType.Equals("string")) {
                        field.Transforms.Insert(0, "trim");
                        entity.OperationsAfterAggregation.Add(new TrimOperation(field.Alias, field.Alias, " "));
                    }

                    foreach (var t in f.Transforms) {
                        field.Transforms.Add(t.Method.ToLower());
                        var reader = new FieldParametersReader(new DefaultFactory(_process.Logger));
                        if (t.BeforeAggregation) {
                            entity.OperationsBeforeAggregation.Add(factory.Create(field, t, reader.Read(t)));
                        }
                        if (t.AfterAggregation) {
                            entity.OperationsAfterAggregation.Add(factory.Create(field, t, reader.Read(t)));
                        }
                        AddBranches(t.Branches, entity, field, reader);
                    }
                }

                // calculated fields do not have prefixes, and have access to all or some of an entity's parameters
                foreach (var cf in entityElement.CalculatedFields) {

                    var field = _process.GetField(entity.Alias, cf.Alias);

                    foreach (var t in cf.Transforms) {
                        var reader = new EntityTransformParametersReader(entity, _process.Logger);

                        if (t.BeforeAggregation) {
                            entity.OperationsBeforeAggregation.Add(factory.Create(field, t, reader.Read(t)));
                        }
                        if (t.AfterAggregation) {
                            entity.OperationsAfterAggregation.Add(factory.Create(field, t, reader.Read(t)));
                        }
                        AddBranches(t.Branches, entity, field, reader);
                    }
                }
            }
        }
        private void AddBranches(IEnumerable<TflBranch> branches, Entity entity, Field field, ITransformParametersReader reader) {
            foreach (var branch in branches) {
                foreach (var transform in branch.Transforms) {

                    Field f;
                    transform.RunField = branch.RunField;
                    transform.RunType = _process.TryGetField(entity.Name, transform.RunField, out f) ? f.SimpleType : "boolean";
                    transform.RunOperator = branch.RunOperator;
                    transform.RunValue = branch.RunValue;

                    var operation = new TransformOperationFactory(_process, entity.Name).Create(field, transform, reader.Read(transform));
                    entity.OperationsAfterAggregation.Add(operation);
                    if (transform.Branches.Count > 0) {
                        AddBranches(transform.Branches, entity, field, reader);
                    }
                }
            }
        }
Esempio n. 6
0
        private void AddBranches(IEnumerable <TflBranch> branches, Entity entity, Field field, ITransformParametersReader reader)
        {
            foreach (var branch in branches)
            {
                foreach (var transform in branch.Transforms)
                {
                    Field f;
                    transform.RunField    = branch.RunField;
                    transform.RunType     = _process.TryGetField(entity.Name, transform.RunField, out f) ? f.SimpleType : "boolean";
                    transform.RunOperator = branch.RunOperator;
                    transform.RunValue    = branch.RunValue;

                    var operation = new TransformOperationFactory(_process, entity.Name).Create(field, transform, reader.Read(transform));
                    entity.OperationsAfterAggregation.Add(operation);
                    if (transform.Branches.Count > 0)
                    {
                        AddBranches(transform.Branches, entity, field, reader);
                    }
                }
            }
        }