/// <summary> /// Creates all readouts of all types in the <paramref name="myTypeList"/> /// </summary> private List <IEnumerable <IVertexView> > CreateVertices(SecurityToken mySecurityToken, Int64 myTransactionToken, Dictionary <String, IVertexType> myTypeList, SelectResultManager mySelectResultManager, BinaryExpressionDefinition myWhereExpressionDefinition, Int64 myResolutionDepth, OrderByDefinition myOrderByDefinition, UInt64?myLimit, UInt64?myOffset) { var _ListOfListOfVertices = new List <IEnumerable <IVertexView> >(); // Create vertices for type foreach (var typeRef in myTypeList) { var _Vertices = CreateVerticesForType(mySecurityToken, myTransactionToken, typeRef, mySelectResultManager, myWhereExpressionDefinition, myResolutionDepth, myOrderByDefinition, myLimit, myOffset); // If this type did not returned any result, we wont add it to the result if (_Vertices != null) { _ListOfListOfVertices.Add(_Vertices); } } return(_ListOfListOfVertices); }
/// <summary> /// Creates the lazy readouts for the given <paramref name="myTypeReference"/> /// </summary> private IEnumerable <IVertexView> CreateVerticesForType(SecurityToken mySecurityToken, Int64 myTransactionToken, KeyValuePair <String, IVertexType> myTypeReference, SelectResultManager mySelectResultManager, BinaryExpressionDefinition myWhereExpressionDefinition, Int64 myResolutionDepth, OrderByDefinition myOrderByDefinition, UInt64?myLimit, UInt64?myOffset) { IEnumerable <IVertexView> _Vertices = new List <IVertexView>(); #region Check groupings & aggregates mySelectResultManager.ValidateGroupingAndAggregate(myTypeReference.Key, myTypeReference.Value); #endregion #region Check, whether the type was affected by the where expressions. This will use either the Graph or the GUID index of the type Boolean isInterestingWhere = (myWhereExpressionDefinition != null && IsInterestingWhereForReference(myTypeReference.Key, myWhereExpressionDefinition)); #endregion #region Create an IEnumerable of Readouts for this typeNode var result = mySelectResultManager.Examine(myResolutionDepth, myTypeReference.Key, myTypeReference.Value, isInterestingWhere, ref _Vertices, mySecurityToken, myTransactionToken); #endregion #region If this type did not returned any result, we wont add it to the result if (!result) { return(new List <IVertexView>()); } #endregion #region If there was a result for this typeNode we will add a new SelectionListElementResult // _Vertices = mySelectResultManager.GetResult(_Vertices); #region OrderBy if (myOrderByDefinition != null) { OrderVertices(mySecurityToken, myTransactionToken, myOrderByDefinition, ref _Vertices); } #endregion #region Limit if (myLimit != null || myOffset != null) { ApplyLimitAndOffset(myLimit, myOffset, ref _Vertices); } #endregion #endregion return(_Vertices); }
/// <summary> /// Creates the result manager and adds all selected elements /// </summary> private SelectResultManager CreateResultManager(SecurityToken mySecurityToken, Int64 myTransactionToken, SelectDefinition selectDefinition, Dictionary <String, IVertexType> myTypeList) { var _SelectResultManager = new SelectResultManager(_graphdb, _pluginManager); foreach (var selection in selectDefinition.SelectedElements) { #region Add all selection elements to SelectResultManager if (selection.Item1 is IDChainDefinition) { #region IDChainDefinition var idChainSelection = (selection.Item1 as IDChainDefinition); idChainSelection.Validate(_pluginManager, _graphdb, mySecurityToken, myTransactionToken, true); if (idChainSelection.SelectType != TypesOfSelect.None) { #region Asterisk, Minus, Rhomb, Ad //there's no limitation foreach (var typeRef in myTypeList) { if (idChainSelection.TypeName != null) { var type = _graphdb.GetVertexType( mySecurityToken, myTransactionToken, new RequestGetVertexType(idChainSelection.TypeName), (stats, vType) => vType); if (type == null) { throw new VertexTypeDoesNotExistException(idChainSelection.TypeName, ""); } Int64 typeID = type.ID; _SelectResultManager.AddSelectionType(typeRef.Key, typeRef.Value, idChainSelection.SelectType, typeID); } else { _SelectResultManager.AddSelectionType(typeRef.Key, typeRef.Value, idChainSelection.SelectType); } } #endregion continue; } #region Either IDNode or parameterless function if (idChainSelection.Reference == null) { /// this might be a parameterless function without a calling attribute _SelectResultManager.AddElementToSelection(selection.Item2, null, idChainSelection, false); } else //if (!(aColumnItemNode.ColumnSourceValue is AggregateNode)) { IVertexType theType = null; String reference = idChainSelection.Reference.Item1; // this will happen, if the user selected FROM User u SELECT Name if (!myTypeList.ContainsKey(reference)) { // if there is only one type, than we can treat this as the reference if (myTypeList.Count == 1) { theType = myTypeList.First().Value; } else { throw new Exception("Missing type reference for " + reference); } } else { theType = myTypeList[reference]; } //if (theType != null && theType.GetAncestorVertexTypesAndSelf().Select(x => x.ID).Contains(idChainSelection.LastAttribute.RelatedType.ID)) // reference = theType.GetAncestorVertexTypesAndSelf().Where(x => x.ID == idChainSelection.LastAttribute.RelatedType.ID).First().Name; if (idChainSelection.SelectType != TypesOfSelect.None) { _SelectResultManager.AddSelectionType(reference, theType, idChainSelection.SelectType); } else { _SelectResultManager.AddElementToSelection(selection.Item2, reference, idChainSelection, false, selection.Item3); } //else //{ // return new Exceptional<SelectResultManager>(new Error_NotImplemented(new System.Diagnostics.StackTrace(true))); //} } #endregion #endregion } else if (selection.Item1 is AggregateDefinition) { #region Aggregate var aggregateSelection = selection.Item1 as AggregateDefinition; aggregateSelection.ChainPartAggregateDefinition.Validate(_pluginManager, _graphdb, mySecurityToken, myTransactionToken); var selPartAggr = new SelectionElementAggregate(aggregateSelection.ChainPartAggregateDefinition.Aggregate, selection.Item2, new EdgeList(aggregateSelection.ChainPartAggregateDefinition.Parameter.Edges), new LevelKey(aggregateSelection.ChainPartAggregateDefinition.Parameter.Edges, _graphdb, mySecurityToken, myTransactionToken), aggregateSelection.ChainPartAggregateDefinition.Parameter, aggregateSelection); _SelectResultManager.AddAggregateElementToSelection(mySecurityToken, myTransactionToken, selection.Item2, aggregateSelection.ChainPartAggregateDefinition.Parameter.Reference.Item1, selPartAggr); #endregion } else { throw new NotImplementedQLException(""); } #endregion } #region Add groupings if (selectDefinition.GroupByIDs.IsNotNullOrEmpty()) { foreach (var group in selectDefinition.GroupByIDs) { group.Validate(_pluginManager, _graphdb, mySecurityToken, myTransactionToken, true); _SelectResultManager.AddGroupElementToSelection(group.Reference.Item1, group); } } #endregion #region Add having if (selectDefinition.Having != null) { selectDefinition.Having.Validate(_pluginManager, _graphdb, mySecurityToken, myTransactionToken); _SelectResultManager.AddHavingToSelection(selectDefinition.Having); } #endregion return(_SelectResultManager); }