Example #1
0
 public FilterProvider(
     IFilterParser <TEntity> filterParser,
     IExpressionProvider <TEntity> expressionProvider)
 {
     FilterParser       = filterParser;
     ExpressionProvider = expressionProvider;
 }
Example #2
0
 public override void InitializeComponent(ICore core)
 {
     if (core != null)
     {
         this.FilterParser = core.Components.FilterParser;
     }
     base.InitializeComponent(core);
 }
 private void InitializeFakeObjects()
 {
     _schemaStoreStub             = new Mock <ISchemaStore>();
     _commonAttributesFactoryStub = new Mock <ICommonAttributesFactory>();
     _filterParser   = new FilterParser();
     _requestParser  = new RepresentationRequestParser(_schemaStoreStub.Object);
     _responseParser = new RepresentationResponseParser(_schemaStoreStub.Object, _commonAttributesFactoryStub.Object, null);
 }
Example #4
0
 public override void InitializeComponent(ICore core)
 {
     this.Core                    = core;
     this.LibraryManager          = core.Managers.Library;
     this.LibraryHierarchyBrowser = core.Components.LibraryHierarchyBrowser;
     this.FilterParser            = core.Components.FilterParser;
     base.InitializeComponent(core);
 }
Example #5
0
 public QueryParser(IWebFilterConverter <TEntity> webFilterConverter, IPagingParser pagingParser, IFilterParser filterParser, IFieldsParser fieldsParser, IOrderByParser orderByParser, ITypeFilterParser <TEntity> typeFilterParser)
 {
     _webFilterConverter = webFilterConverter ?? throw new ArgumentNullException(nameof(webFilterConverter));
     _pagingParser       = pagingParser ?? throw new ArgumentNullException(nameof(pagingParser));
     _filterParser       = filterParser ?? throw new ArgumentNullException(nameof(filterParser));
     _fieldsParser       = fieldsParser ?? throw new ArgumentNullException(nameof(fieldsParser));
     _orderByParser      = orderByParser ?? throw new ArgumentNullException(nameof(orderByParser));
     _typeFilterParser   = typeFilterParser ?? throw new ArgumentNullException(nameof(typeFilterParser));
 }
Example #6
0
        public AgentsController(ILogger <AgentsController> logger, IStringLocalizer <AgentsController> localizer,
                                IServiceProvider serviceProvider) : base(logger, localizer, serviceProvider)
        {
            _db = serviceProvider.GetRequiredService <ApplicationContext>();
            _metadataProvider = serviceProvider.GetRequiredService <IModelMetadataProvider>();
            _tenantInfo       = serviceProvider.GetRequiredService <ITenantUserInfoAccessor>();
            _filterParser     = serviceProvider.GetRequiredService <IFilterParser>();

            _logger    = logger;
            _localizer = localizer;
        }
        /// <summary>
        /// Webページをインデックス化
        /// </summary>
        /// <param name="wc"></param>
        /// <param name="indexWriter"></param>
        /// <param name="threadName"></param>
        /// <returns></returns>
        private bool AddWebDocument(WebContents wc, IndexWriter indexWriter, string threadName)
        {
            string extension = wc.Extention;

            //ドキュメント追加
            Document doc = new Document();

            if (extension.ToLower() == ".html" ||
                extension.ToLower() == ".htm" ||
                extension.ToLower() == "")
            {
                if (wc.Contents.Length > 0)
                {
                    if (_txtExtractMode == TextExtractModes.Tika)
                    {
                        byte[] data = System.Text.Encoding.Unicode.GetBytes(wc.Contents);
                        _parser.parse(new java.io.ByteArrayInputStream(data), _handler, _metadata, new ParseContext());
                        string content = _handler.toString();
                        doc.Add(new Field(Content, content, _hilightFieldType));
                    }
                    else
                    {
                        doc.Add(new Field(Content, IFilterParser.Parse(wc.Contents), _hilightFieldType));
                    }
                }
            }
            else
            {
                //FIXME ダウンロードしてインデックス化
                //バイト数セット
                //インデックス後削除
            }

            doc.Add(new StringField(Path, wc.Url, FieldStore.YES));
            doc.Add(new StringField(Title, wc.Title, FieldStore.YES));
            doc.Add(new StringField(Extension, extension.ToLower(), FieldStore.YES));
            long l = long.Parse(wc.UpdateDate.ToString("yyyyMMddHHmmss"));

            doc.Add(new LongPoint(UpdateDate, l));
            doc.Add(new StoredField(UpdateDate, l));
            //doc.Add(new StringField(UpdateDate,
            //    DateTools.DateToString(_sdf.parse(wc.UpdateDate.ToString("yyyy/MM/dd")), DateToolsResolution.DAY),
            //    FieldStore.YES));
            indexWriter.AddDocument(doc);

            return(true);
        }
 public UpdateRepresentationAction(
     IRepresentationRequestParser requestParser,
     IRepresentationStore representationStore,
     IApiResponseFactory apiResponseFactory,
     IRepresentationResponseParser responseParser,
     IParametersValidator parametersValidator,
     IErrorResponseFactory errorResponseFactory,
     IFilterParser filterParser)
 {
     _requestParser        = requestParser;
     _representationStore  = representationStore;
     _apiResponseFactory   = apiResponseFactory;
     _responseParser       = responseParser;
     _parametersValidator  = parametersValidator;
     _errorResponseFactory = errorResponseFactory;
     _filterParser         = filterParser;
 }
 public QueryBuilderDependencies(
     IProcessHandler processHandler,
     IDbConnection context,
     INamingStrategyService namingStrategyService,
     IFilterParser <T> filterParser,
     Lazy <IJoinHandler> joinHandler,
     Lazy <ISortHandler> sortHandler,
     Lazy <IPropertyParser> propertyParser
     )
 {
     ProcessHandler = processHandler;
     Context        = context;
     NamingStrategy = namingStrategyService;
     FilterParser   = filterParser;
     JoinHandler    = joinHandler;
     SortHandler    = sortHandler;
     PropertyParser = propertyParser;
 }
Example #10
0
        private static IDictionary <string, IFilterParser> CreateOperatorParsers(IFilterParser rootParser)
        {
            var result = new Dictionary <string, IFilterParser>();

            result.Add(Operators.Eq, new EqualFilterParser());
            result.Add(Operators.Ne, new NotEqualFilterParser());
            result.Add(Operators.Gt, new GreaterThanFilterParser());
            result.Add(Operators.Gte, new GreaterThanOrEqualFilterParser());
            result.Add(Operators.Lt, new LessThanFilterParser());
            result.Add(Operators.Lte, new LessThanOrEqualFilterParser());

            result.Add(Operators.And, new AndFilterParser(rootParser));
            result.Add(Operators.Or, new OrFilterParser(rootParser));
            result.Add(Operators.Nor, new NotOrFilterParser(rootParser));
            result.Add(Operators.Not, new NotFilterParser(rootParser));

            return(result);
        }
Example #11
0
 private void InitializeFakeObjects()
 {
     _requestParserStub          = new Mock <IRepresentationRequestParser>();
     _representationStoreStub    = new Mock <IRepresentationStore>();
     _apiResponseFactoryStub     = new Mock <IApiResponseFactory>();
     _responseParserStub         = new Mock <IRepresentationResponseParser>();
     _parametersValidatorStub    = new Mock <IParametersValidator>();
     _errorResponseFactoryStub   = new Mock <IErrorResponseFactory>();
     _filterParser               = new FilterParser();
     _updateRepresentationAction = new UpdateRepresentationAction(
         _requestParserStub.Object,
         _representationStoreStub.Object,
         _apiResponseFactoryStub.Object,
         _responseParserStub.Object,
         _parametersValidatorStub.Object,
         _errorResponseFactoryStub.Object,
         _filterParser);
 }
Example #12
0
 public CoreQueryBuilderDependencies(
     IProcessHandler processHandler,
     IDbConnection context,
     Lazy <IServiceProvider> serviceProvider,
     INamingStrategyService namingStrategyService,
     IFilterParser <T> filterParser,
     Lazy <IJoinHandler> joinHandler,
     Lazy <ISortHandler> sortHandler,
     Lazy <IPropertyParser> propertyParser
     ) : base(
         processHandler,
         context,
         namingStrategyService,
         filterParser,
         joinHandler,
         sortHandler,
         propertyParser)
 {
     ServiceProvider = serviceProvider;
 }
 public AutofacQueryBuilderDependencies(
     IProcessHandler processHandler,
     IDbConnection context,
     Lazy <ILifetimeScope> scope,
     INamingStrategyService namingStrategyService,
     IFilterParser <T> filterParser,
     Lazy <IJoinHandler> joinHandler,
     Lazy <ISortHandler> sortHandler,
     Lazy <IPropertyParser> propertyParser
     ) : base(
         processHandler,
         context,
         namingStrategyService,
         filterParser,
         joinHandler,
         sortHandler,
         propertyParser)
 {
     Scope = scope;
 }
        /// <summary>
        /// 指定したテキスト抽出器でテキスト化したものをインデックス化
        /// テキスト抽出器の種類は以下のとおり
        ///  ・Apache Tika
        ///  ・IFilter
        /// </summary>
        /// <param name="path"></param>
        /// <param name="indexWriter"></param>
        private bool AddDocument(string path, IndexWriter indexWriter, string threadName, Dictionary <string, DocInfo> docDic)
        {
            string   filename  = System.IO.Path.GetFileName(path);
            string   extension = System.IO.Path.GetExtension(path);
            FileInfo fi        = new FileInfo(path);

            if (extension == "" ||
                !_targetExtensionDic.ContainsKey(extension.ToLower()))
            {
                //拡張子なし or 対象拡張子外
                AppObject.Logger.Info(threadName + ":" + "Out of target extension. Skipped: " + path);
                Interlocked.Increment(ref _skippedCount);

                return(false);
            }
            if (extension.ToLower() != ".mp4" && fi.Length > this.FileSizeLimit)
            {
                //サイズオーバー(mp4は対象外)
                AppObject.Logger.Info(threadName + ":" + "File size over. Skipped: " + path);
                Interlocked.Increment(ref _skippedCount);

                return(false);
            }
            //存在するドキュメントか?
            if (docDic != null && docDic.ContainsKey(path))
            {
                DocInfo di = docDic[path];
                di.Exists    = true;
                docDic[path] = di;
                //更新日時チェック(秒単位で比較)
                if (di.UpdateDate < DateTimeUtil.Truncate(fi.LastWriteTime, TimeSpan.FromSeconds(1)))
                {
                    //更新されている場合Delete+Insert
                    Term t = new Term(LuceneIndexBuilder.Path, di.Path);
                    indexWriter.DeleteDocuments(t);
                }
                else
                {
                    //更新されていない。
                    AppObject.Logger.Info(threadName + ":" + "No updated. Skipped: " + path);
                    Interlocked.Increment(ref _skippedCount);

                    return(false);
                }
            }

            //ドキュメント追加
            Document doc = new Document();

            if (extension.ToLower() == ".md")
            {
                //Markdown形式
                string content = ReadToString(path);
                doc.Add(new Field(Content, content, _hilightFieldType));
            }
            else if (extension.ToLower() == ".txt")
            {
                //TXTファイル
                var sjis = Encoding.GetEncoding("Shift_JIS");
                if (FileUtil.GetTextEncoding(path) == sjis)
                {
                    string content = "";
                    using (var reader = new StreamReader(path, sjis)) {
                        content = reader.ReadToEnd();
                    }
                    doc.Add(new Field(Content, content, _hilightFieldType));
                }
                else
                {
                    if (_txtExtractMode == TextExtractModes.Tika)
                    {
                        var content = _txtExtractor.Extract(path);
                        doc.Add(new Field(Content, content.Text, _hilightFieldType));
                    }
                    else
                    {
                        doc.Add(new Field(Content, IFilterParser.Parse(path), _hilightFieldType));
                    }
                }
            }
            else
            {
                if (_txtExtractMode == TextExtractModes.Tika)
                {
                    var content = _txtExtractor.Extract(path);
                    doc.Add(new Field(Content, content.Text, _hilightFieldType));
                }
                else
                {
                    doc.Add(new Field(Content, IFilterParser.Parse(path), _hilightFieldType));
                }
            }

            doc.Add(new StringField(Path, path, FieldStore.YES));
            doc.Add(new StringField(Title, filename.ToLower(), FieldStore.YES));
            doc.Add(new StringField(Extension, extension.ToLower(), FieldStore.YES));
            //NOTE:Date型のFieldは存在しないのでlongで保持
            long l = long.Parse(fi.LastWriteTime.ToString("yyyyMMddHHmmss"));

            doc.Add(new LongPoint(UpdateDate, l));
            doc.Add(new StoredField(UpdateDate, l));
            //doc.Add(new StringField(UpdateDate,
            //    DateTools.DateToString(_sdf.parse(fi.LastWriteTime.ToString("yyyy/MM/dd")), DateToolsResolution.DAY),
            //    FieldStore.YES));
            indexWriter.AddDocument(doc);

            return(true);
        }
 public NotOrFilterParser(IFilterParser rootFilterParser)
     : base(rootFilterParser)
 {
 }
Example #16
0
 public ProductsController(IProductRepository productRepository, IFilterParser <Product> filterParser)
 {
     _productRepository = productRepository;
     _filterParser      = filterParser;
 }
 public override void InitializeComponent(ICore core)
 {
     this.FilterParser = core.Components.FilterParser;
     this.FilterParser.Register(this);
     base.InitializeComponent(core);
 }
 private void InitializeFakeObjects()
 {
     _filterParser = new FilterParser();
 }
Example #19
0
 protected AggregatorFilterParserBase(IFilterParser rootFilterParser)
 {
     _rootFilterParser = rootFilterParser;
 }
Example #20
0
 public EventAggregateRepository(EventStoreContext context, IFilterParser filterParser)
 {
     _context      = context;
     _filterParser = filterParser;
 }
Example #21
0
 public NotFilterParser(IFilterParser rootFilterParser)
 {
     _rootFilterParser = rootFilterParser;
 }
Example #22
0
 public SearchParameterParser(IFilterParser filterParser)
 {
     _filterParser = filterParser;
 }
        public static IEnumerable <T> Filter <T>(this IEnumerable <T> source, IFilterParser parser, string filter)
        {
            var pred = parser.Parse <T>("x", filter);

            return(source.Where(pred.Compile() as Func <T, bool>));
        }
        // Dynamically build SQL where clause.
        // See: https://stackoverflow.com/a/39183597
        public static IQueryable <T> Filter <T>(this IQueryable <T> source, IFilterParser parser, string filter)
        {
            var pred = parser.Parse <T>("x", filter);

            return(source.Where(pred as Expression <Func <T, bool> >));
        }
        public FakeMongoCollection(BsonDocumentCollection documents)
        {
            _documents = documents;

            _filterParser = FilterParser.Instance;
        }
Example #26
0
 public AndFilterParser(IFilterParser rootFilterParser)
     : base(rootFilterParser)
 {
 }
Example #27
0
 public StudentRecordRepository(PacBillContext context, ILogger <StudentRecordRepository> logger)
 {
     _context = context;
     _parser  = new FilterParser();
     _logger  = logger;
 }