private void TransformContentListFieldSingleId(Predicate pred) { //#String_0 -> #Text1 if (!pred.LeftOperand.StartsWith("#")) return; foreach (var fs in this.SystemContext.GetAvailableFields()) { if (!fs.Name.StartsWith("#")) continue; var cList = SystemContext as ContentList; var sing = cList.GetPropertySingleId(fs.Name); if (sing.CompareTo(pred.LeftOperand) != 0) continue; pred.LeftOperand = fs.Name; return; } }
private static void TransformIntToReference(Predicate pred) { foreach (var refFieldName in ReferenceFields.AllKeys) { if (ReferenceFields[refFieldName].CompareTo(pred.LeftOperand) == 0) pred.LeftOperand = refFieldName; } }
private ExpressionInfo GetExpressionInfo(Predicate pred) { TransformContentListFieldSingleId(pred); TransformIntToReference(pred); return new ExpressionInfo { LogicalOperator = pred.LogicalOperator, Expression = pred.RightOperand, FieldName = pred.LeftOperand, RelationalOperator = pred.Operator }; }
private static void TransformReferenceToInt(Predicate pred) { if (ReferenceFields[pred.LeftOperand] != null) pred.LeftOperand = ReferenceFields[pred.LeftOperand]; }
private ExpressionItem GetExpressionItem(ExpressionInfo expInfo) { if (expInfo == null || expInfo.IsEmpty) return null; PropertyType pType = null; var pred = new Predicate { LeftOperand = expInfo.FieldName, LogicalOperator = LogicalOperator.None, //expInfo.LogicalOperator, Operator = expInfo.RelationalOperator, RightOperand = expInfo.Expression }; TransformReferenceToInt(pred); switch (pred.LeftOperand) { case "Id": case "ParentId": case "Index": case "IsDeleted": case "IsInherited": case "Locked": case "LockType": case "LockTimeout": case "CreatedById": case "ModifiedById": case "LockedById": pred.PredicateType = PredicateType.IntExpression; break; case "CreatedBy": case "ModifiedBy": pred.PredicateType = PredicateType.ReferenceExpression; break; case "Name": case "Path": case "LockToken": pred.PredicateType = PredicateType.StringExpression; break; case "CreationDate": case "ModificationDate": case "LockDate": case "LastLockUpdate": pred.PredicateType = PredicateType.DateTimeExpression; break; //case "NodeType": //case "ContentListId": //case "ContentListType": //case "Parent": //case "IsModified": //case "NodeCreationDate": //case "NodeCreatedBy": //case "Version": //case "VersionId": //case "Lock": //case "LockedBy": //case "ETag": //case "Security": default: //#Text1 -> #String_0 if (expInfo.FieldName.StartsWith("#")) { var cList = SystemContext as ContentList; pred.LeftOperand = cList.GetPropertySingleId(expInfo.FieldName); } pType = ActiveSchema.PropertyTypes[pred.LeftOperand]; break; } if (pType != null) { switch (pType.DataType) { case DataType.String: pred.PredicateType = PredicateType.StringExpression; break; case DataType.Reference: pred.PredicateType = PredicateType.ReferenceExpression; break; case DataType.Int: pred.PredicateType = PredicateType.IntExpression; break; case DataType.Text: pred.PredicateType = PredicateType.SearchExpression; break; case DataType.DateTime: pred.PredicateType = PredicateType.DateTimeExpression; break; default: return null; } } return pred; }