/// <summary> /// create a boolean expression. /// </summary> /// <param name="searchEntityUnit"></param> /// <param name="searchPropParent"></param> /// <returns></returns> public SearchPropBoolExpr AddSearchPropBoolExpr(SearchEntity searchEntity, SearchPropBoolExpr boolExprParent, BoolExprOperand leftOrRight, SearchBoolOperator oper) { if (searchEntity == null) { return(null); } if (boolExprParent == null) { return(null); } // check that the criterion does not already exists if (searchEntity.SearchPropRoot != null) { // a criterion already exists! return(null); } // check that the criterion does not already exists if (boolExprParent.GetLeftOrRight(leftOrRight) != null) { return(null); } SearchPropBoolExpr expr = new SearchPropBoolExpr(); expr.Operator = oper; // set the prop operand to the left or to the right boolExprParent.SetLeftOrRight(leftOrRight, expr); return(expr); }
/// <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!"); }
/// <summary> /// create a bool expr as the root expr of the search unit. /// </summary> /// <param name="searchEntityUnit"></param> /// <param name="searchPropParent"></param> /// <returns></returns> public SearchPropBoolExpr AddSearchPropBoolExpr(SearchEntity searchEntity, SearchBoolOperator oper) { if (searchEntity == null) { return(null); } // check that the criterion does not already exists if (searchEntity.SearchPropRoot != null) { // a criterion already exists! return(null); } SearchPropBoolExpr expr = new SearchPropBoolExpr(); expr.Operator = oper; searchEntity.SearchPropRoot = expr; return(expr); }
/// <summary> /// Add a property criterion to a search unit. /// set to the left or to the right operand of the expression. /// </summary> /// <param name="criteria"></param> /// <param name="keyText"></param> /// <returns></returns> public SearchPropCriterionKeyText AddCritPropKeyText(SearchEntity searchEntity, SearchPropBoolExpr boolExprParent, BoolExprOperand leftOrRight, string keyText) { if (searchEntity == null) { return(null); } if (boolExprParent == null) { return(null); } // check the text if (string.IsNullOrWhiteSpace(keyText)) { return(null); } // check that the criterion does not already exists if (boolExprParent.GetLeftOrRight(leftOrRight) != null) { return(null); } SearchPropCriterionKeyText criterionPropKeyText = CreateSearchPropCriterionPropKeyText(keyText); // set the prop operand to the left or to the right boolExprParent.SetLeftOrRight(leftOrRight, criterionPropKeyText); return(criterionPropKeyText); }