Ejemplo n.º 1
0
        private void IndexModuleData(LuceneController lc, int moduleId, OpenContentSettings settings)
        {
            bool index = false;

            if (settings.TemplateAvailable)
            {
                index = settings.Manifest.Index;
            }
            FieldConfig indexConfig = null;

            if (index)
            {
                indexConfig = OpenContentUtils.GetIndexConfig(settings.Template);
            }

            if (settings.IsOtherModule)
            {
                moduleId = settings.ModuleId;
            }

            lc.Store.Delete(new TermQuery(new Term("$type", OpenContentInfo.GetScope(moduleId, settings.Template.Collection))));
            OpenContentController occ = new OpenContentController();

            foreach (var item in occ.GetContents(moduleId, settings.Template.Collection))
            {
                lc.Add(item, indexConfig);
            }
        }
        public virtual IDataItems GetAll(DataSourceContext context, Select selectQuery)
        {
            if (selectQuery == null)
            {
                return(GetAll(context));
            }

            SelectQueryDefinition def  = BuildQuery(context, selectQuery);
            OpenContentController ctrl = new OpenContentController(context.PortalId);
            SearchResults         docs = LuceneController.Instance.Search(OpenContentInfo.GetScope(GetModuleId(context), context.Collection), def.Filter, def.Query, def.Sort, def.PageSize, def.PageIndex);

            int total    = docs.TotalResults;
            var dataList = new List <IDataItem>();

            foreach (string item in docs.ids)
            {
                var content = ctrl.GetContent(int.Parse(item));
                if (content != null)
                {
                    dataList.Add(CreateDefaultDataItem(content));
                }
                else
                {
                    App.Services.Logger.Debug($"OpenContentDataSource.GetAll() ContentItem not found [{item}]");
                }
            }
            return(new DefaultDataItems()
            {
                Items = dataList,
                Total = total,
                DebugInfo = def.Filter + " - " + def.Query + " - " + def.Sort
            });
        }
Ejemplo n.º 3
0
        public void Reindex(DataSourceContext context)
        {
            string scope              = OpenContentInfo.GetScope(context.ModuleId, context.Collection);
            var    indexConfig        = OpenContentUtils.GetIndexConfig(new FolderUri(context.TemplateFolder), context.Collection); //todo index is being build from schema & options. But they should be provided by the provider, not directly from the files
            OpenContentController occ = new OpenContentController(context.PortalId);

            LuceneController.Instance.ReIndexModuleData(occ.GetContents(context.ModuleId, context.Collection), indexConfig, scope);
        }