protected IParameter GetParameters() { IParameter p = DerivedFrom.CustomParameters; if (!DerivedFrom.IsStatic) { // parameters for a node will be where the Subject at this level is filtered by ID = this node's ID. // Nodes below this one should filter correctly with this parameter if the configuration has been set up correctly. var p2 = new SimpleParameter(DerivedFrom.Subject.IdField, "=", ID); // we also want to combine any custom parameters that this node might have if (p != null) { var c = new Conjunction() .Parameter(p) .Parameter(p2); p = c; } else p = p2; } return p; }
public IParameter GetParameter() { Junction junc = new Conjunction(); if (Type == JunctionType.Disjunction) junc = new Disjunction(); foreach (var v in this) junc.Add(v.GetParameter()); return junc; }
/// <summary> /// Gets all children for this node. If getAll = true, all children will be returned with IsMatch = true for those that also match additional parameters. /// </summary> /// <param name="additionalParameters">Any additional parameters used to narrow the children returned.</param> /// <param name="getAll">If true, sets IsMatch = true for those nodes that also match additional parameters. If false, only returns children that also match additional parameters.</param> /// <returns></returns> public List<DataNode> GetChildren(IParameter additionalParameters, bool getAll) { //TODO: this method uses explicit casts to internal concrete classes for Subject and Fields List<DataNode> children = new List<DataNode>(); // loop through the children template nodes and figure out what children we need to load foreach (TemplateNode currentTemplate in DerivedFrom.Children) { if (currentTemplate.IsStatic) { // static nodes are just created directly from template DataNode node = new DataNode(); node.DerivedFrom = currentTemplate; node.Parent = this; node.ID = null; node.Text = currentTemplate.Text; // static nodes inherit match from parent node.IsMatch = this.IsMatch; children.Add(node); } else { DataNode currentNode = this; List<SortField> groups = (currentTemplate.GroupBy ?? new List<SortField>()); // start with the given additionalParameters which will just be combined with any other parameters from parent template nodes // this allows for further filtering at any level of the tree if necessary var p = new Conjunction(); // gather parameters to narrow results for this child // loop condition has additional check to ensure we don't traverse off the top of the tree for (int level = 0; level < currentTemplate.SearchParameterLevels && currentNode != null; level++) { // only traverse up non-grouped nodes in the hierarchy if (currentNode.GroupIndex == -1) { var tempParam = currentNode.GetParameters(); if (tempParam != null) p.Add(tempParam); } currentNode = currentNode.Parent; } // keep reference to parameters that will give us a wider search in case we need to get all results later IParameter widerParms = p; // now narrow the normal parameters to get fewer children if (additionalParameters != null) p.Add(additionalParameters); // this is what makes the whole process possible - get all children using search parameters //TODO List<object> results = null; // currentTemplate.Queryer.Search(currentTemplate.Subject, p); // initially set allResults to results, but if we're getting all children update it with those instead List<object> allResults = results; if (getAll && p != widerParms) //TODO allResults = null; // currentTemplate.Queryer.Search(currentTemplate.Subject, widerParms); var fields = new List<IField>(); fields.AddRange(ItemData.GetPlaceholders(currentTemplate.Subject, currentTemplate.Text).Values); if (currentTemplate.AdditionalFields != null) foreach (var f in currentTemplate.AdditionalFields) fields.Add (currentTemplate.Subject[f]); foreach (var f in groups) fields.Add (currentTemplate.Subject[f.FieldSourceName]); // grouped fields are sorted first, then by SortBy fields var sort = new List<SortField>(groups); sort.AddRange(currentTemplate.SortBy); //TODO List<ItemData> data = null; // currentTemplate.Queryer.GetSortedData(currentTemplate.Subject, allResults, fields, sort); children = AddNodes(currentTemplate, data); } } // gather children for the next sibling of currentTemplate return children; }