/// <summary> /// Create a new Tuple of type <paramref name="myTupleElementType"/> and values <paramref name="myValues"/> /// </summary> /// <param name="myTupleElementType"></param> /// <param name="myValues"></param> /// <returns></returns> public static TupleDefinition Create(params Object[] myValues) { var elements = new TupleDefinition(); foreach (var value in myValues) { elements.AddElement(new TupleElement(new ValueDefinition(value))); } return(elements); }
public void Remove(TupleDefinition myTupleDefinition) { if (myTupleDefinition == this) { TupleElements = new List <TupleElement>(); } else { foreach (var td in myTupleDefinition) { Remove(td); } } }
/// <summary> /// /// </summary> /// <param name="myTupleDefinition"></param> /// <returns></returns> private bool IsEncapsulatedBinaryExpression(TupleDefinition myTupleDefinition) { if (myTupleDefinition.Count() == 1) { if ((myTupleDefinition.First().Value is BinaryExpressionDefinition) || (myTupleDefinition.First().Value is UnaryExpressionDefinition)) { return(true); } else { return(false); } } else { return(false); } }
public static AOperationDefinition GetValidTupleReloaded(TupleDefinition myTupleDefinition, IGraphDB myIGraphDB, SecurityToken mySecurityToken, Int64 myTransactionToken) { switch (myTupleDefinition.KindOfTuple) { case KindOfTuple.Exclusive: if (myTupleDefinition.TupleElements.Count == 1) { return(myTupleDefinition.TupleElements[0].Value as ValueDefinition); } else { return(myTupleDefinition); } default: return(myTupleDefinition); } }
/// <summary> /// This will check all tupe value. If it contains only one value it will be converted to a ValueDefinition. If it contains a SelectDefinition it will be executed and the result added to the tuple. /// </summary> private AOperationDefinition AssignCorrectTuple(GQLPluginManager myPluginManager, TupleDefinition myTupleDefinition, BinaryOperator myOperator, IGraphDB myGraphDB, SecurityToken mySecurityToken, Int64 myTransactionToken) { var retVal = new TupleDefinition(myTupleDefinition.KindOfTuple); var validTuple = ABinaryOperator.GetValidTupleReloaded(myTupleDefinition, myGraphDB, mySecurityToken, myTransactionToken); if (validTuple is TupleDefinition) { foreach (var tupleVal in (validTuple as TupleDefinition)) { if (tupleVal.Value is ValueDefinition) { retVal.AddElement(tupleVal); } else if (tupleVal.Value is SelectDefinition) { #region partial select var selectManager = new SelectManager(myGraphDB, myPluginManager); var qresult = selectManager.ExecuteSelect(mySecurityToken, myTransactionToken, (tupleVal.Value as SelectDefinition), String.Empty); if (qresult.Error != null) { throw qresult.Error; } IAttributeDefinition curAttr = ((tupleVal.Value as SelectDefinition).SelectedElements.First().Item1 as IDChainDefinition).LastAttribute; foreach (var _Vertex in qresult.Vertices) { if (!(_Vertex.HasProperty(curAttr.Name))) { continue; } if (curAttr != null) { var val = new ValueDefinition(_Vertex.GetProperty <Object>(curAttr.Name)); retVal.AddElement(new TupleElement(val)); } else { throw new NotImplementedQLException(""); } } #endregion } else { throw new NotImplementedQLException(""); } } } else { return(validTuple); } return(retVal); }
protected AOperationDefinition CreateTupleValue(TupleDefinition myTupleDefinition) { return(myTupleDefinition); }