Esempio n. 1
0
        public DataFlowOperator Operator(DataFlowOpInitializeContext context)
        {
            var container = context.Container;
            var adapterInputSourceValue = DataFlowParameterResolution.ResolveOptionalInstance <AdapterInputSource>(
                "adapterInputSource",
                AdapterInputSource,
                context);
            var fileName = DataFlowParameterResolution.ResolveWithDefault <string>(
                "file",
                File,
                null,
                context);

            if (adapterInputSourceValue == null)
            {
                if (fileName != null)
                {
                    adapterInputSourceValue = new AdapterInputSource(container, new FileInfo(fileName));
                }
                else
                {
                    throw new EPException("Failed to find required parameter, either the file or the adapterInputSource parameter is required");
                }
            }

            var formatValue = DataFlowParameterResolution.ResolveStringOptional("format", Format, context);

            switch (formatValue)
            {
            case null:
            case "csv": {
                var hasHeaderLineFlag = DataFlowParameterResolution.ResolveWithDefault <bool?>(
                    "hasHeaderLine",
                    HasHeaderLine,
                    false,
                    context);
                var hasTitleLineFlag = DataFlowParameterResolution.ResolveWithDefault <bool?>(
                    "hasTitleLine",
                    HasTitleLine,
                    false,
                    context);
                var numLoopsValue = DataFlowParameterResolution.ResolveWithDefault <int?>(
                    "numLoops",
                    NumLoops,
                    null,
                    context);
                var dateFormatValue = DataFlowParameterResolution.ResolveStringOptional(
                    "dateFormat",
                    DateFormat,
                    context);

                return(new FileSourceCSV(
                           this,
                           context,
                           adapterInputSourceValue,
                           hasHeaderLineFlag ?? false,
                           hasTitleLineFlag ?? false,
                           numLoopsValue,
                           PropertyNames,
                           dateFormatValue));
            }

            case "line": {
                var propertyNameLineValue = DataFlowParameterResolution.ResolveStringOptional("propertyNameLine", PropertyNameLine, context);
                var propertyNameFileValue = DataFlowParameterResolution.ResolveStringOptional("propertyNameFile", PropertyNameFile, context);
                return(new FileSourceLineUnformatted(this, context, adapterInputSourceValue, fileName, propertyNameLineValue, propertyNameFileValue));
            }

            default:
                throw new ArgumentException("Unrecognized file format '" + formatValue + "'");
            }
        }
Esempio n. 2
0
 public DataFlowOperator Operator(DataFlowOpInitializeContext context)
 {
     var collectorInstance = DataFlowParameterResolution.ResolveOptionalInstance<EPDataFlowEventBeanCollector>(
         "collector", Collector, context);
     return new EventBusSourceOp(this, context.AgentInstanceContext, collectorInstance);
 }