/// <summary>
		/// Builds and executes the query.
		/// </summary>
		/// <param name="context">The request context.</param>
		/// <param name="arguments">The arguments from which to build the query.</param>
		/// <param name="repository">The <see cref="IRepository"/>.</param>
		/// <param name="parser">The <see cref="IQueryParser"/>.</param>
		/// <returns>Returns the result.</returns>
		protected override Record Retrieve(IMansionContext context, IPropertyBag arguments, IRepository repository, IQueryParser parser)
		{
			// parse the query
			var query = parser.Parse(context, arguments);

			// execute and return the result
			return repository.RetrieveSingle(context, query);
		}
		/// <summary>
		/// Builds and executes the query.
		/// </summary>
		/// <param name="context">The request context.</param>
		/// <param name="arguments">The arguments from which to build the query.</param>
		/// <param name="repository">The <see cref="IRepository"/>.</param>
		/// <param name="parser">The <see cref="IQueryParser"/>.</param>
		/// <returns>Returns the <see cref="RecordSet"/>.</returns>
		protected override RecordSet Retrieve(IMansionContext context, IPropertyBag arguments, IRepository repository, IQueryParser parser)
		{
			// parse them into a query
			var query = parser.Parse(context, arguments);

			// execute the query
			return searcher.Search(context, query);
		}
		/// <summary>
		/// </summary>
		/// <param name="parser"></param>
		protected RetrieveRecordBaseTag(IQueryParser parser)
		{
			// validate arguments
			if (parser == null)
				throw new ArgumentNullException("parser");

			// set value
			this.parser = parser;
		}
		/// <summary>
		/// </summary>
		/// <param name="searcher"></param>
		/// <param name="parser"> </param>
		public SearchTag(Searcher searcher, IQueryParser parser) : base(parser)
		{
			// validate arguments
			if (searcher == null)
				throw new ArgumentNullException("searcher");

			// set values
			this.searcher = searcher;
		}
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parser"></param>
        /// <param name="portalService"></param>
        /// <exception cref="ArgumentNullException"></exception>
        public RetrieveTemplatePageNodeTag(IQueryParser parser, IPortalService portalService)
            : base(parser)
        {
            // validate arguments
            if (portalService == null)
                throw new ArgumentNullException("portalService");

            // set values
            this.portalService = portalService;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parser"></param>
        /// <param name="nodeUrlService"></param>
        /// <exception cref="ArgumentNullException"></exception>
        public RetrieveNodeByUrlTag(IQueryParser parser, INodeUrlService nodeUrlService)
            : base(parser)
        {
            // validate arguments
            if (nodeUrlService == null)
                throw new ArgumentNullException("nodeUrlService");

            // set values
            this.nodeUrlService = nodeUrlService;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parser"></param>
        /// <param name="typeService"></param>
        /// <exception cref="ArgumentNullException"></exception>
        public RetrieveLayoutNodeTag(IQueryParser parser, ITypeService typeService)
            : base(parser)
        {
            // validate arguments
            if (typeService == null)
                throw new ArgumentNullException("typeService");

            // set values
            this.typeService = typeService;
        }
    public void SetUp()
    {
      _mockRepository = new MockRepository();
      _queryParserMock = _mockRepository.StrictMock<IQueryParser> ();
      _executorMock = _mockRepository.StrictMock<IQueryExecutor> ();

      _queryProvider = new TestQueryProvider (_queryParserMock, _executorMock);
    
      _queryableWithDefaultParser = new TestQueryable<Cook> (QueryParser.CreateDefault(), _executorMock);
      _fakeQueryModel = ExpressionHelper.CreateQueryModel<Cook> ();
    }
        /// <summary>
        /// Builds and executes the query.
        /// </summary>
        /// <param name="context">The request context.</param>
        /// <param name="arguments">The arguments from which to build the query.</param>
        /// <param name="repository">The <see cref="IRepository"/>.</param>
        /// <param name="parser">The <see cref="IQueryParser"/>.</param>
        /// <returns>Returns the result.</returns>
        protected override Record Retrieve(IMansionContext context, IPropertyBag arguments, IRepository repository, IQueryParser parser)
        {
            // get the node
            var contentNode = GetRequiredAttribute<Node>(context, "source");
            var siteNode = GetRequiredAttribute<Node>(context, "siteNode");

            // resolve the template page node
            Node templatePageNode;
            portalService.TryResolveTemplatePage(context, siteNode, contentNode, out templatePageNode);
            return templatePageNode;
        }
		/// <summary>
		/// Builds and executes the query.
		/// </summary>
		/// <param name="context">The request context.</param>
		/// <param name="arguments">The arguments from which to build the query.</param>
		/// <param name="repository">The <see cref="IRepository"/>.</param>
		/// <param name="parser">The <see cref="IQueryParser"/>.</param>
		/// <returns>Returns the result.</returns>
		protected override Record Retrieve(IMansionContext context, IPropertyBag arguments, IRepository repository, IQueryParser parser)
		{
			// parse the query
			var query = parser.Parse(context, arguments);

			// make sure a child of clause is specified
			if (!query.HasSpecification<ChildOfSpecification>())
				throw new InvalidOperationException("The parent node was not specified.");

			// execute the query
			return repository.RetrieveSingleNode(context, query);
		}
        /// <summary>
        /// Builds and executes the query.
        /// </summary>
        /// <param name="context">The request context.</param>
        /// <param name="arguments">The arguments from which to build the query.</param>
        /// <param name="repository">The <see cref="IRepository"/>.</param>
        /// <param name="parser">The <see cref="IQueryParser"/>.</param>
        /// <returns>Returns the <see cref="RecordSet"/>.</returns>
        protected override RecordSet Retrieve(IMansionContext context, IPropertyBag arguments, IRepository repository, IQueryParser parser)
        {
            // get the node
            var sourceNode = GetRequiredAttribute<Node>(context, "source");

            // retrieve the block nodes
            return repository.RetrieveNodeset(context, new PropertyBag
                                                       {
                                                       	{"baseType", "Block"},
                                                       	{"parentSource", sourceNode},
                                                       	{"status", NodeStatus.Published}
                                                       });
        }
Beispiel #12
0
        // Not best solution but done for simplicity
        // Read first idea in Service project that would allow to avoid this hack
        public void Init(IQueryParser parser, IFileIndexer indexer)
        {
            if (parser == null)
                throw new ArgumentNullException("parser");

            if (indexer == null)
                throw new ArgumentNullException("indexer");

            if (_parser != null || _indexer != null)
                throw new InvalidOperationException("Cannot initialize index more than one time.");

            _parser = parser;
            _indexer = indexer;
        }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="typeService"></param>
		/// <param name="parser"> </param>
		/// <param name="repository"></param>
		/// <exception cref="ArgumentNullException"></exception>
		public SyncTablesTag(ITypeService typeService, IQueryParser parser, SqlServerRepository repository)
		{
			// validate arguments
			if (typeService == null)
				throw new ArgumentNullException("typeService");
			if (parser == null)
				throw new ArgumentNullException("parser");
			if (repository == null)
				throw new ArgumentNullException("repository");

			// set values
			this.typeService = typeService;
			this.parser = parser;
			this.repository = repository;
		}
        /// <summary>
        /// Builds and executes the query.
        /// </summary>
        /// <param name="context">The request context.</param>
        /// <param name="arguments">The arguments from which to build the query.</param>
        /// <param name="repository">The <see cref="IRepository"/>.</param>
        /// <param name="parser">The <see cref="IQueryParser"/>.</param>
        /// <returns>Returns the result.</returns>
        protected override Record Retrieve(IMansionContext context, IPropertyBag arguments, IRepository repository, IQueryParser parser)
        {
            // get the node
            var contentNode = GetRequiredAttribute<Node>(context, "source");

            //  get the page type
            var pageType = typeService.Load(context, "Page");

            // find the closest node pointer of type Page
            var pageNodePointer = contentNode.Pointer.HierarchyReverse.FirstOrDefault(x => typeService.Load(context, x.Type).IsAssignable(pageType));
            if (pageNodePointer == null)
                throw new InvalidOperationException(string.Format("Node '{0}' does not have a parent which is a Page", contentNode.Pointer.StructureString));

            // retrieve and return the parent node
            return repository.RetrieveSingleNode(context, new PropertyBag {{"id", pageNodePointer.Id}});
        }
		/// <summary>
		/// Builds and executes the query.
		/// </summary>
		/// <param name="context">The request context.</param>
		/// <param name="arguments">The arguments from which to build the query.</param>
		/// <param name="repository">The <see cref="IRepository"/>.</param>
		/// <param name="parser">The <see cref="IQueryParser"/>.</param>
		/// <returns>Returns the result.</returns>
		protected override Record Retrieve(IMansionContext context, IPropertyBag arguments, IRepository repository, IQueryParser parser)
		{
			// parse the query
			var query = parser.Parse(context, arguments);

			// make sure a child of clause is specified
			var parentOfSpecifications = query.Components.OfType<SpecificationQueryComponent>().Select(component => component.Specification).OfType<ParentOfSpecification>().ToArray();
			if (!parentOfSpecifications.Any())
				throw new InvalidOperationException("The child node was not specified.");

			// if there is a parent of specification for depth 0 it means a parent of the root node is queried, which does not exist
			if (parentOfSpecifications.Any(candidate => candidate.ChildPointer.Depth == 1))
				return null;

			// execute the query
			return repository.RetrieveSingleNode(context, query);
		}
        /// <summary>
        /// Builds and executes the query.
        /// </summary>
        /// <param name="context">The <see cref="IMansionContext"/>.</param>
        /// <param name="arguments">The arguments from which to build the query.</param>
        /// <param name="repository">The <see cref="IRepository"/>.</param>
        /// <param name="parser">The <see cref="IQueryParser"/>.</param>
        /// <returns>Returns the result.</returns>
        protected override Record Retrieve(IMansionContext context, IPropertyBag arguments, IRepository repository, IQueryParser parser)
        {
            // get the url
            Url url;
            if (!arguments.TryGet(context, "url", out url))
                url = context.Cast<IMansionWebContext>().Request.RequestUrl;

            // parse the query
            var query = parser.Parse(context, new PropertyBag
                                              {
                                              	{"baseType", "Site"},
                                              	{"hostHeaders", url.HostName}
                                              });

            // execute the query
            return repository.RetrieveSingleNode(context, query);
        }
        /// <summary>
        /// Builds and executes the query.
        /// </summary>
        /// <param name="context">The <see cref="IMansionContext"/>.</param>
        /// <param name="arguments">The arguments from which to build the query.</param>
        /// <param name="repository">The <see cref="IRepository"/>.</param>
        /// <param name="parser">The <see cref="IQueryParser"/>.</param>
        /// <returns>Returns the result.</returns>
        protected override Record Retrieve(IMansionContext context, IPropertyBag arguments, IRepository repository, IQueryParser parser)
        {
            // get the url
            Url url;
            if (!arguments.TryGet(context, "url", out url))
                url = context.Cast<IMansionWebContext>().Request.RequestUrl;

            // parse the URL for identifiers
            IPropertyBag queryAttributes;
            if (!nodeUrlService.TryExtractQueryParameters(context.Cast<IMansionWebContext>(), url, out queryAttributes))
                return null;

            // parse the query
            var query = parser.Parse(context, queryAttributes);

            // execute the query
            return repository.RetrieveSingleNode(context, query);
        }
        /// <summary>
        /// Builds and executes the query.
        /// </summary>
        /// <param name="context">The request context.</param>
        /// <param name="arguments">The arguments from which to build the query.</param>
        /// <param name="repository">The <see cref="IRepository"/>.</param>
        /// <param name="parser">The <see cref="IQueryParser"/>.</param>
        /// <returns>Returns the result.</returns>
        protected override Record Retrieve(IMansionContext context, IPropertyBag arguments, IRepository repository, IQueryParser parser)
        {
            // get the node
            var contentNode = GetRequiredAttribute<Node>(context, "source");

            // check if this node defines a theme
            string theme;
            if (contentNode.TryGet(context, "theme", out theme) && !string.IsNullOrEmpty(theme))
                return contentNode;

            // retrieve the parents of the current node
            var parentNodeset = repository.RetrieveNodeset(context, parser.Parse(context, new PropertyBag
                                                                                          {
                                                                                          	{"childSource", contentNode},
                                                                                          	{"baseType", "Page"},
                                                                                          	{"depth", "any"},
                                                                                          	{"sort", "depth DESC"}
                                                                                          }));

            return parentNodeset.Nodes.FirstOrDefault(parent => parent.TryGet(context, "theme", out theme) && !string.IsNullOrEmpty(theme));
        }
 public void SetUp ()
 {
   _parserStub = MockRepository.GenerateStub<IQueryParser> ();
   _executorStub = MockRepository.GenerateStub<IQueryExecutor> ();
 }
 /// <summary>
 /// </summary>
 /// <param name="parser"></param>
 public RetrieveBlockNodesetTag(IQueryParser parser)
     : base(parser)
 {
 }
		/// <summary>
		/// </summary>
		/// <param name="parser"></param>
		public RetrieveParentNodesetTag(IQueryParser parser) : base(parser)
		{
		}
 /// <summary>
 /// </summary>
 /// <param name="parser"></param>
 public RetrieveSiteNodeTag(IQueryParser parser)
     : base(parser)
 {
 }
		/// <summary>
		/// </summary>
		/// <param name="parser"></param>
		public FetchNodeTag(IQueryParser parser) : base(parser)
		{
		}
 public QueryProcessor(ICommandRunner commandRunner, IQueryParser queryParser)
 {
     _commandRunner = commandRunner;
     _queryParser = queryParser;
 }
		/// <summary>
		/// </summary>
		/// <param name="parser"></param>
		public RetrieveChildNodeTag(IQueryParser parser) : base(parser)
		{
		}
Beispiel #26
0
 public Starter(IQueryParser queryParser, IModelsStarter _modelsStarter)
 {
     this.queryParser = queryParser;
     this._modelsStarter = _modelsStarter;
 }
 protected IQueryParser GetEngine(IDbCommand actual)
 {
     if (engine == null)
         engine = new QueryEngineFactory().GetParser(actual);
     return engine;
 }
		/// <summary>
		/// Builds and executes the query.
		/// </summary>
		/// <param name="context">The request context.</param>
		/// <param name="arguments">The arguments from which to build the query.</param>
		/// <param name="repository">The <see cref="IRepository"/>.</param>
		/// <param name="parser">The <see cref="IQueryParser"/>.</param>
		/// <returns>Returns the result.</returns>
		protected abstract Record Retrieve(IMansionContext context, IPropertyBag arguments, IRepository repository, IQueryParser parser);
		/// <summary>
		/// </summary>
		/// <param name="parser"></param>
		public RetrieveRecordTag(IQueryParser parser) : base(parser)
		{
		}
		/// <summary>
		/// Builds and executes the query.
		/// </summary>
		/// <param name="context">The request context.</param>
		/// <param name="arguments">The arguments from which to build the query.</param>
		/// <param name="repository">The <see cref="IRepository"/>.</param>
		/// <param name="parser">The <see cref="IQueryParser"/>.</param>
		/// <returns>Returns the result.</returns>
		protected override Record Retrieve(IMansionContext context, IPropertyBag arguments, IRepository repository, IQueryParser parser)
		{
			return GetAttribute<Node>(context, "source");
		}