예제 #1
0
        private List <Cloth> searchByCombine()
        {
            List <List <Cloth> > clothLists    = new List <List <Cloth> >();
            List <Cloth>         clothesByText = searchByText();

            if (clothesByText == null || clothesByText.Count == 0)
            {
                return(new List <Cloth>());
            }

            clothLists.Add(clothesByText);

            clothLists.Add(searchByPic());

            return(ClothUtil.IntersectClothLists(clothLists));
        }
예제 #2
0
        public override List <Cloth> Search()
        {
            List <Cloth> clothes = null;

            if (clothDao != null)
            {
                clothes = clothDao.FindAll();
            }

            if (null == clothes)
            {
                throw new NullReferenceException("ClothDao are null, or some error happened.");
            }

            TextParam tp     = (TextParam)param;
            string    words  = tp.Words;
            ColorEnum colors = tp.Colors;
            ShapeEnum shapes = tp.Shapes;

            List <List <Cloth> > clothLists = new List <List <Cloth> >();

            if (colors != ColorEnum.NONE)
            {
                List <Cloth> clothesByColor = clothDao.FindAllByColors(colors);
                if (clothesByColor.Count > 0)
                {
                    clothLists.Add(clothesByColor);
                }
                else
                {
                    // empty list
                    return(clothesByColor);
                }
            }


            if (shapes != ShapeEnum.NONE)
            {
                List <Cloth> clothesByShape = clothDao.FindAllByShapes(shapes);
                if (clothesByShape.Count > 0)
                {
                    clothLists.Add(clothesByShape);
                }
                else
                {
                    // empty list
                    return(clothesByShape);
                }
            }


            if (!String.IsNullOrEmpty(words))
            {
                string[]             patterns          = words.Split(new char[] { ',', ' ', '\t' });
                List <List <Cloth> > clothListsByWords = new List <List <Cloth> >();
                foreach (string pattern in patterns)
                {
                    if (!string.IsNullOrEmpty(pattern))
                    {
                        List <Cloth> clothesByPattern = clothDao.FindAllByPattern(pattern);

                        if (clothesByPattern.Count > 0)
                        {
                            clothListsByWords.Add(clothesByPattern);
                        }
                    }
                }
                if (clothListsByWords.Count > 0)
                {
                    clothLists.Add(ClothUtil.UnionClothLists(clothListsByWords));
                }
                else
                {
                    // empty list
                    return(new List <Cloth>());
                }
            }

            return(ClothUtil.IntersectClothLists(clothLists));
        }