Example #1
0
        protected virtual IList GetResultList(IList results)
        {
            var resultCollections = new List <object>(resultCollectionGenericType.Count);

            for (int i = 0; i < criteriaQueries.Count; i++)
            {
                if (resultCollectionGenericType[i] == typeof(object))
                {
                    resultCollections.Add(new List <object>());
                }
                else
                {
                    resultCollections.Add(Activator.CreateInstance(typeof(List <>).MakeGenericType(resultCollectionGenericType[i])));
                }
            }

            for (int i = 0; i < loaders.Count; i++)
            {
                CriteriaLoader loader        = loaders[i];
                var            resultList    = loader.GetResultList((IList)results[i], parameters[i].ResultTransformer);
                var            criteriaIndex = loaderCriteriaMap[i];
                ArrayHelper.AddAll((IList)resultCollections[criteriaIndex], resultList);
            }

            if (resultTransformer != null)
            {
                for (int i = 0; i < results.Count; i++)
                {
                    resultCollections[i] = resultTransformer.TransformList((IList)resultCollections[i]);
                }
            }

            return(resultCollections);
        }
Example #2
0
        public override IList GetResultList(IList results, IResultTransformer resultTransformer)
        {
            // meant to handle dynamic instantiation queries...
            HolderInstantiator holderInstantiator = HolderInstantiator.GetHolderInstantiator(_selectNewTransformer,
                                                                                             resultTransformer,
                                                                                             _queryReturnAliases);

            if (holderInstantiator.IsRequired)
            {
                for (int i = 0; i < results.Count; i++)
                {
                    var    row    = (Object[])results[i];
                    Object result = holderInstantiator.Instantiate(row);
                    results[i] = result;
                }

                if (!HasSelectNew && resultTransformer != null)
                {
                    return(resultTransformer.TransformList(results));
                }
                else
                {
                    return(results);
                }
            }
            else
            {
                return(results);
            }
        }
Example #3
0
        public override IList GetResultList(IList results, IResultTransformer resultTransformer)
        {
            // meant to handle dynamic instantiation queries...
            var transformer = _selectNewTransformer ?? resultTransformer;

            if (transformer != null)
            {
                for (int i = 0; i < results.Count; i++)
                {
                    var    row    = (object[])results[i];
                    object result = transformer.TransformTuple(row, _queryReturnAliases);
                    results[i] = result;
                }

                if (!HasSelectNew && resultTransformer != null)
                {
                    return(resultTransformer.TransformList(results));
                }
                else
                {
                    return(results);
                }
            }
            else
            {
                return(results);
            }
        }
Example #4
0
        protected virtual IList GetResultList(IList results)
        {
            for (int i = 0, len = results.Count; i < len; ++i)
            {
                IList              subList            = (IList)results[i];
                QueryParameters    parameter          = Parameters[i];
                HolderInstantiator holderInstantiator = GetHolderInstantiator(parameter);
                if (holderInstantiator.IsRequired)
                {
                    for (int j = 0; j < subList.Count; j++)
                    {
                        object[] row = subList[j] as object[] ?? new[] { subList[j] };
                        subList[j] = holderInstantiator.Instantiate(row);
                    }

                    IResultTransformer transformer =
                        holderInstantiator.ResultTransformer;
                    if (transformer != null)
                    {
                        results[i] = transformer.TransformList(subList);
                    }
                }
            }
            return(results);
        }
Example #5
0
        protected virtual IList GetResultList(IList results)
        {
            for (int i = 0; i < loaders.Count; i++)
            {
                CriteriaLoader loader = loaders[i];
                results[i] = loader.GetResultList((IList)results[i], parameters[i].ResultTransformer);
                IList tmpResults;
                if (resultCollectionGenericType[i] == typeof(object))
                {
                    tmpResults = new ArrayList();
                }
                else
                {
                    tmpResults = (IList)Activator.CreateInstance(typeof(List <>).MakeGenericType(resultCollectionGenericType[i]));
                }
                ArrayHelper.AddAll(tmpResults, (IList)results[i]);

                results[i] = tmpResults;
            }
            if (resultTransformer != null)
            {
                for (int i = 0; i < results.Count; i++)
                {
                    results[i] = resultTransformer.TransformList((IList)results[i]);
                }
            }
            return(results);
        }
        public override void List(IList list)
        {
            if (list == null)
            {
                throw new ArgumentNullException(nameof(list));
            }

            using (new SessionIdLoggingContext(Session.SessionId))
            {
                // Find the directories
                IndexSearcher searcher = BuildSearcher();

                if (searcher == null)
                {
                    return;
                }

                try
                {
                    IList <EntityInfo> infos  = ExtractEntityInfos(searcher);
                    ISession           sess   = (ISession)Session;
                    ILoader            loader = GetLoader(sess);
                    IList entities            = loader.Load(infos.ToArray());
                    foreach (object entity in entities)
                    {
                        list.Add(entity);
                    }

                    if (entities.Count != infos.Count)
                    {
                        log.Warn("Lucene index contains infos about {0} entities, but were found in the database. Rebuild the index.", infos.Count, entities.Count);
                    }

                    if (resultTransformer == null || loader is ProjectionLoader)
                    {
                        // stay consistent with transformTuple which can only be executed during a projection
                    }
                    else
                    {
                        IList tempList = resultTransformer.TransformList(list);
                        list.Clear();
                        foreach (object entity in tempList)
                        {
                            list.Add(entity);
                        }
                    }
                }
                catch (IOException e)
                {
                    throw new HibernateException("Unable to query Lucene index", e);
                }
                finally
                {
                    CloseSearcher(searcher);
                }
            }
        }
 public override IList GetResultList(IList results, IResultTransformer customResultTransformer)
 {
     if (customResultTransformer == null)
     {
         // apply the defaut transformer of criteria aka RootEntityResultTransformer
         return(results);
     }
     for (int i = 0; i < results.Count; i++)
     {
         var    row    = results[i] as object[] ?? new object[] { results[i] };
         object result = customResultTransformer.TransformTuple(row, translator.HasProjection ? translator.ProjectedAliases : userAliases);
         results[i] = result;
     }
     return(customResultTransformer.TransformList(results));
 }
Example #8
0
        private IList GetTransformedResults(IList source)
        {
            if (resultTransformer == null)
            {
                return(source);
            }

            //MultiCriteria does not call TransformTuple here
            for (var j = 0; j < source.Count; j++)
            {
                var row = source[j] as object[] ?? new[] { source[j] };
                source[j] = resultTransformer.TransformTuple(row, null);
            }

            return(resultTransformer.TransformList(source));
        }
Example #9
0
        public override IList GetResultList(IList results, IResultTransformer resultTransformer)
        {
            // meant to handle dynamic instantiation queries...(Copy from QueryLoader)
            var returnAliases = ReturnAliasesForTransformer;

            if (resultTransformer != null)
            {
                for (var i = 0; i < results.Count; i++)
                {
                    var row = (object[])results[i];
                    results[i] = resultTransformer.TransformTuple(row, returnAliases);
                }

                return(resultTransformer.TransformList(results));
            }

            return(results);
        }
Example #10
0
        public IList <T> ExecuteQuery <T>(string queryString, IDictionary <string, object> parameters, int start, int max, IResultTransformer resultTransformer) where T : DomainEntity
        {
            IQuery query = Session.CreateQuery(queryString);

            query = AddParams(query, parameters);
            query = Limit(query, start, max);
            IList <T> result;

            if (resultTransformer != null)
            {
                result = (IList <T>)resultTransformer.TransformList(query.List());
            }
            else
            {
                result = query.List <T>();
            }

            return(result);
        }
Example #11
0
        public override IList GetResultList(IList results, IResultTransformer resultTransformer)
        {
            // meant to handle dynamic instantiation queries...(Copy from QueryLoader)
            HolderInstantiator holderInstantiator =
                HolderInstantiator.GetHolderInstantiator(null, resultTransformer, ReturnAliasesForTransformer);

            if (holderInstantiator.IsRequired)
            {
                for (int i = 0; i < results.Count; i++)
                {
                    object[] row    = (object[])results[i];
                    object   result = holderInstantiator.Instantiate(row);
                    results[i] = result;
                }

                return(resultTransformer.TransformList(results));
            }
            else
            {
                return(results);
            }
        }
Example #12
0
 protected virtual IList GetResultList(IList results)
 {
     if (resultTransformer != null)
     {
         for (int i = 0; i < results.Count; i++)
         {
             results[i] = resultTransformer.TransformList((IList)results[i]);
         }
     }
     else
     {
         for (int i = 0; i < results.Count; i++)
         {
             CriteriaImpl critImp = criteriaQueries[i] as CriteriaImpl;
             if (critImp == null || critImp.ResultTransformer == null)
             {
                 continue;
             }
             results[i] = critImp.ResultTransformer.TransformList((IList)results[i]);
         }
     }
     return(results);
 }
		public override IList GetResultList(IList results, IResultTransformer resultTransformer)
		{
			HolderInstantiator holderInstantiator =
				HolderInstantiator.CreateClassicHolderInstantiator(holderConstructor, resultTransformer);

			if (holderInstantiator.IsRequired)
			{
				for (int i = 0; i < results.Count; i++)
				{
					object[] row = (object[]) results[i];
					results[i] = holderInstantiator.Instantiate(row);
				}

				if (holderConstructor == null && resultTransformer != null)
				{
					return resultTransformer.TransformList(results);
				}
			}

			return results;
		}
		public override IList GetResultList(IList results, IResultTransformer customResultTransformer)
		{
			if (customResultTransformer == null)
			{
				// apply the defaut transformer of criteria aka RootEntityResultTransformer
				return results;
			}
			for (int i = 0; i < results.Count; i++)
			{
				var row = results[i] as object[] ?? new object[] { results[i] };
				object result = customResultTransformer.TransformTuple(row, translator.HasProjection ? translator.ProjectedAliases : userAliases);
				results[i] = result;
			}
			return customResultTransformer.TransformList(results);
		}
Example #15
0
        protected override IList GetResultList(IList results, IResultTransformer resultTransformer)
        {
            // meant to handle dynamic instantiation queries...(Copy from QueryLoader)
            HolderInstantiator holderInstantiator = HolderInstantiator.GetHolderInstantiator(
                null,
                resultTransformer,
                ReturnAliasesForTransformer
                );
            if (holderInstantiator.IsRequired)
            {
                for (int i = 0; i < results.Count; i++)
                {
                    object[] row = (object[]) results[i];
                    object result = holderInstantiator.Instantiate(row);
                    results[i] = result;
                }

                return resultTransformer.TransformList(results);
            }
            else
            {
                return results;
            }
        }
Example #16
0
		public override IList GetResultList(IList results, IResultTransformer resultTransformer)
		{
			// meant to handle dynamic instantiation queries...
			HolderInstantiator holderInstantiator = HolderInstantiator.GetHolderInstantiator(_selectNewTransformer,
			                                                                                 resultTransformer,
			                                                                                 _queryReturnAliases);
			if (holderInstantiator.IsRequired)
			{
				for (int i = 0; i < results.Count; i++)
				{
					var row = (Object[]) results[i];
					Object result = holderInstantiator.Instantiate(row);
					results[i] = result;
				}

				if (!HasSelectNew && resultTransformer != null)
				{
					return resultTransformer.TransformList(results);
				}
				else
				{
					return results;
				}
			}
			else
			{
				return results;
			}
		}
Example #17
0
 // convert to DISTINCT list with populated Fields
 public IList TransformList(IList collection)
 {
     return(_baseTransformer.TransformList(collection));
 }