Beispiel #1
0
        /// <summary>
        /// Analyze the CritOptionTextMatch = MatchExact.
        /// </summary>
        /// <param name="propCritKeyTextWork"></param>
        /// <param name="keyText"></param>
        /// <returns></returns>
        private bool AnalyzeTextMatchExact(SearchPropCriterionKeyTextWork propCritKeyTextWork, string keyText)
        {
            if (propCritKeyTextWork.TextSensitive == CritOptionTextSensitive.No)
            {
                if (propCritKeyTextWork.KeyText.Equals(keyText))
                {
                    // ok, match
                    propCritKeyTextWork.PropertyMatch = PropertyMatch.Yes;
                }
                else
                {
                    propCritKeyTextWork.PropertyMatch = PropertyMatch.No;
                }

                return(true);
            }

            if (propCritKeyTextWork.KeyText.Equals(keyText, StringComparison.InvariantCultureIgnoreCase))
            {
                // ok, match
                propCritKeyTextWork.PropertyMatch = PropertyMatch.Yes;
            }
            else
            {
                propCritKeyTextWork.PropertyMatch = PropertyMatch.No;
            }

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// filter according to the key type: string, TextCode or All
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <returns></returns>
        private bool FilterOnKeyType(PropertyKeyBase propertyKeyBase, SearchPropCriterionKeyTextWork propCritKeyTextWork)
        {
            // match all key type: string and TextCode
            if (propCritKeyTextWork.PropKeyTextType == CritOptionPropKeyTextType.AllKeyType)
            {
                return(true);
            }

            // get the type of the prop key
            PropertyKeyString propKeyString = propertyKeyBase as PropertyKeyString;

            if (propKeyString != null)
            {
                if (propCritKeyTextWork.PropKeyTextType == CritOptionPropKeyTextType.KeyStringOnly)
                {
                    return(true);
                }

                return(false);
            }

            // the prop key type is TextCode
            if (propCritKeyTextWork.PropKeyTextType == CritOptionPropKeyTextType.KeyTextCodeOnly)
            {
                return(true);
            }

            return(false);
        }
Beispiel #3
0
        /// <summary>
        /// analyze the criteria properties expression for the entity
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        private bool AnalyzeEntityOnCriteria(SearchEntity searchEntity, Entity entity, SearchEntityResult result)
        {
            // create a work/exec object of the criteria expression
            SearchPropBaseWork searchPropBaseWork = CreateAllSearchPropBaseWork(searchEntity.SearchPropRoot);

            // a bool expr, go inside left and right part
            SearchPropBoolExprWork searchPropBoolExprWork = searchPropBaseWork as SearchPropBoolExprWork;

            if (searchPropBoolExprWork != null)
            {
                // create work object on the left side

                // create work object on the right side

                //return searchPropBoolExprWork;

                // ok, no error
                return(true);
            }

            // a final criterion
            SearchPropCriterionKeyTextWork propCritKeyTextWork = searchPropBaseWork as SearchPropCriterionKeyTextWork;

            if (propCritKeyTextWork != null)
            {
                EntitySearcherPropKeyText searcherPropKeyText = new EntitySearcherPropKeyText(_reposit);
                return(searcherPropKeyText.AnalyzeEntityOnCritKeyText(propCritKeyTextWork, entity, result));
            }

            // TODO: others final criterion type


            // not implemented
            throw new Exception("Search property not yet implemented!");
        }
Beispiel #4
0
        /// <summary>
        /// Process the final criterion: property key text is matching?
        /// </summary>
        /// <param name="propCritKeyTextWork"></param>
        /// <param name="entity"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public bool AnalyzeEntityOnCritKeyText(SearchPropCriterionKeyTextWork propCritKeyTextWork, Entity entity, SearchEntityResult result)
        {
            // scan all properties of the entity to match the criterion: key name
            AnalyzeEntityOnCritKeyText_PropGroup(entity.PropertyRoot, propCritKeyTextWork);
            // todo: rajouter un flag dans le work: Match: yes,no, NotSet

            // todo: si match=true, alors stocker l'entité (l'id) dans le result
            if (propCritKeyTextWork.PropertyMatch == PropertyMatch.Yes)
            {
                result.AddEntity(entity);
            }
            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// match the property with the criterion
        ///
        /// </summary>
        /// <param name="property"></param>
        /// <param name="propCritKeyTextWork"></param>
        /// <returns></returns>
        private bool AnalyzeEntityOnCritKeyText_Prop(Property property, SearchPropCriterionKeyTextWork propCritKeyTextWork)
        {
            string keyText;

            // filter according to the key type: string, TextCode or All
            if (!FilterOnKeyType(property.Key, propCritKeyTextWork))
            {
                // not selected
                return(true);
            }

            // the key can be a string or a textCode
            if (!GetKeyText(property.Key, out keyText))
            {
                // error
                return(false);
            }

            //----case TextMatchExact
            if (propCritKeyTextWork.TextMatch == CritOptionTextMatch.TextMatchExact)
            {
                return(AnalyzeTextMatchExact(propCritKeyTextWork, keyText));
            }

            //----case contains
            //if (propCritKeyTextWork.TextMatch == CritOptionTextMatch.TextMatchContains)
            //{
            //    // todo: +tard
            //    throw new Exception("AnalyzeEntityOnCritKeyText_Prop failure, typeMatch=TextMatchContains not yet implemented");
            //}

            //----case regex
            //if (propCritKeyTextWork.TextMatch == CritOptionTextMatch.TextMatchRegex)
            //{
            //    // todo: +tard
            //    throw new Exception("AnalyzeEntityOnCritKeyText_Prop failure, typeMatch=TextMatchRegex not yet implemented");
            //}

            // error
            throw new Exception("AnalyzeEntityOnCritKeyText_Prop failure, type match not yet implemented.");
        }
Beispiel #6
0
        /// <summary>
        /// Create all work objet matching object, recursivly.
        /// </summary>
        /// <param name="searchPropBase"></param>
        /// <returns></returns>
        private SearchPropBaseWork CreateAllSearchPropBaseWork(SearchPropBase searchPropBase)
        {
            // a bool expr, go inside left and right part
            SearchPropBoolExpr searchPropBoolExpr = searchPropBase as SearchPropBoolExpr;

            if (searchPropBoolExpr != null)
            {
                SearchPropBoolExprWork searchPropBoolExprWork = new SearchPropBoolExprWork();
                searchPropBoolExprWork.SearchPropBaseId = searchPropBoolExpr.Id;
                searchPropBoolExprWork.Operator         = searchPropBoolExpr.Operator;

                // create work object on the left side
                searchPropBoolExprWork.LeftOperand = CreateAllSearchPropBaseWork(searchPropBoolExpr.LeftOperand);

                // create work object on the right side
                searchPropBoolExprWork.RightOperand = CreateAllSearchPropBaseWork(searchPropBoolExpr.RightOperand);

                return(searchPropBoolExprWork);
            }

            // a final criterion
            SearchPropCriterionKeyText propCritKeyText = searchPropBase as SearchPropCriterionKeyText;

            if (propCritKeyText != null)
            {
                SearchPropCriterionKeyTextWork propCritKeyTextWork = new SearchPropCriterionKeyTextWork();
                propCritKeyTextWork.SearchPropBaseId = propCritKeyText.Id;
                propCritKeyTextWork.KeyText          = propCritKeyText.KeyText;
                propCritKeyTextWork.PropChildsScan   = propCritKeyText.PropChildsScan;
                propCritKeyTextWork.PropKeyTextType  = propCritKeyText.PropKeyTextType;
                propCritKeyTextWork.TextMatch        = propCritKeyText.TextMatch;
                propCritKeyTextWork.TextSensitive    = propCritKeyText.TextSensitive;

                return(propCritKeyTextWork);
            }
            // TODO: others final criterion type


            // not implemented
            throw new Exception("Search property not yet implemented!");
        }
Beispiel #7
0
        /// <summary>
        /// Analyze the entity group property, process childs for a keyText criterion.
        /// </summary>
        /// <param name="propertyGroup"></param>
        /// <param name="propCritKeyTextWork"></param>
        /// <returns></returns>
        private bool AnalyzeEntityOnCritKeyText_PropGroup(PropertyGroup propertyGroup, SearchPropCriterionKeyTextWork propCritKeyTextWork)
        {
            // scan childs properties
            foreach (PropertyBase propertyBase in propertyGroup.ListProperty)
            {
                // is the prop child a group?
                PropertyGroup propertyGroupChild = propertyBase as PropertyGroup;
                if (propertyGroupChild != null)
                {
                    // analyze childs,if a property match, stops the process
                    AnalyzeEntityOnCritKeyText_PropGroup(propertyGroupChild, propCritKeyTextWork);
                    // a property matching the criterion has been found!
                    if (propCritKeyTextWork.PropertyMatch == PropertyMatch.Yes)
                    {
                        return(true);
                    }

                    // process the property child
                    continue;
                }

                // the property child is a final property
                Property propertyChild = propertyBase as Property;
                AnalyzeEntityOnCritKeyText_Prop(propertyChild, propCritKeyTextWork);
                // a property matching the criterion has been found!
                if (propCritKeyTextWork.PropertyMatch == PropertyMatch.Yes)
                {
                    return(true);
                }
            }
            // no error
            return(true);
        }