Ejemplo n.º 1
0
        public IParameters Read(TflTransform transform)
        {
            var parameters = new Parameters.Parameters(_defaultFactory);
            var fields     = new Fields(_process.OutputFields(), _process.CalculatedFields.WithoutOutput());

            foreach (var p in transform.Parameters)
            {
                if (!string.IsNullOrEmpty(p.Field))
                {
                    if (fields.FindByParamater(p).Any())
                    {
                        var field = fields.FindByParamater(p).Last();
                        var name  = string.IsNullOrEmpty(p.Name) ? field.Alias : p.Name;
                        parameters.Add(field.Alias, name, null, field.Type);
                    }
                    else
                    {
                        _process.Logger.Warn("A {0} transform references {1}, but I can't find the definition for {1}.\r\nYou may need to define the entity attribute in the parameter element.\r\nOr, set the output attribute to true in the field element. Process transforms rely on fields being output.\r\nOne other possibility is that the participates in a relationship with another field with the same name and Transformalize doesn't know which one you want.  If that's the case, you have to alias one of them.", transform.Method, p.Field);
                        var name = p.Name.Equals(string.Empty) ? p.Field : p.Name;
                        parameters.Add(p.Field, name, p.HasValue() ? p.Value : null, p.Type);
                    }
                }
                else
                {
                    var parameter = new Parameter(p.Name, p.Value)
                    {
                        SimpleType           = Common.ToSimpleType(p.Type),
                        ValueReferencesField = p.HasValue() && fields.Find(p.Value).Any()
                    };
                    parameters.Add(p.Name, parameter);
                }
            }

            return(parameters);
        }
Ejemplo n.º 2
0
 //constructor
 public Process(string name, ILogger logger)
 {
     View                = Common.DefaultValue;
     Star                = Common.DefaultValue;
     Connections         = new Connections();
     PipelineThreading   = PipelineThreading.MultiThreaded;
     Enabled             = true;
     TransformOperations = new List <IOperation>();
     Parallel            = true;
     LogRows             = 10000;
     Complete            = false;
     Logger              = logger;
     Name                = name;
     DataSets            = new Dictionary <string, List <Row> >();
     Parameters          = new Parameters.Parameters(new DefaultFactory(logger));
     Runner              = new NullRunner();
 }
Ejemplo n.º 3
0
        public Template(Process process, TflTemplate element, Contents contents)
        {
            Parameters  = new Parameters.Parameters(new DefaultFactory(process.Logger));
            Cache       = element.Cache;
            Enabled     = element.Enabled;
            Engine      = element.Engine;
            Name        = element.Name;
            ContentType = element.ContentType.Equals("raw") ? Encoding.Raw : Encoding.Html;
            Contents    = contents;

            _process = process;

            _renderedTemplateFile          = GetFileName(RENDERED_TEMPLATE_CACHE_FOLDER);
            _renderedTemplateContentExists = TryRead(_renderedTemplateFile, out _renderedTemplateContent);

            _templateFile          = GetFileName(TEMPLATE_CACHE_FOLDER);
            _templateContentExists = TryRead(_templateFile, out _templateContent);
        }
Ejemplo n.º 4
0
        public IParameters Read(TflTransform transform)
        {
            var parameters = new Parameters.Parameters(_defaultFactory);

            foreach (var p in transform.Parameters)
            {
                if (string.IsNullOrEmpty(p.Name))
                {
                    return(new Parameters.Parameters(_defaultFactory));
                }

                var value = p.HasValue() ? p.Value : null;
                var alias = p.HasValue() ? p.Name : p.Field;
                parameters.Add(alias, p.Name, value, p.Type);
            }

            return(parameters);
        }
        public IParameters Read(TflTransform transform)
        {
            var parameters = new Parameters.Parameters(new DefaultFactory(_logger));

            foreach (var p in transform.Parameters)
            {
                if (string.IsNullOrEmpty(p.Field) && (string.IsNullOrEmpty(p.Name) || string.IsNullOrEmpty(p.Value)))
                {
                    throw new TransformalizeException(_logger, "The entity {0} has a {1} transform parameter without a field attribute, or name and value attributes.  Entity parameters require one or the other.", _entity.Alias, transform.Method);
                }

                var fields = new Fields(_entity.Fields, _entity.CalculatedFields);
                if (!string.IsNullOrEmpty(p.Field))
                {
                    if (fields.FindByParamater(p).Any())
                    {
                        var field = fields.FindByParamater(p).Last();
                        var name  = string.IsNullOrEmpty(p.Name) ? field.Alias : p.Name;
                        parameters.Add(field.Alias, name, null, field.Type);
                    }
                    else
                    {
                        if (!p.Field.StartsWith("Tfl"))
                        {
                            _logger.EntityWarn(_entity.Name, "The entity {0} has a {1} transform parameter that references field {2}.  This field hasn't been defined yet in {0}.", _entity.Alias, transform.Method, p.Field);
                        }
                        var name = string.IsNullOrEmpty(p.Name) ? p.Field : p.Name;
                        parameters.Add(p.Field, name, p.HasValue() ? p.Value : null, "System.String");
                    }
                }
                else
                {
                    var parameter = new Parameter(p.Name, p.Value)
                    {
                        SimpleType           = Common.ToSimpleType(p.Type),
                        ValueReferencesField = p.HasValue() && fields.Find(p.Value).Any()
                    };
                    parameters.Add(p.Name, parameter);
                }
            }

            return(parameters);
        }