/// <summary> /// Creates an validated asterisk chain for the given type. /// </summary> /// <param name="myIDChainPart">The type chain part.</param> public IDChainDefinition(ChainPartTypeOrAttributeDefinition myIDChainPart, TypesOfSelect mySelType, String myTypeName = null) { RootPart = myIDChainPart; IsValidated = true; SelectType = mySelType; _Edges = new List <EdgeKey>(); LevelKey = new LevelKey(); }
public SelectionElement(TypesOfSelect mySelType, Int64?myTypeID = null) { Selection = mySelType; TypeID = myTypeID; }
/// <summary> /// This will add all attributes of <paramref name="myDBObject"/> to the <paramref name="myAttributes"/> reference. Reference attributes will be resolved to the <paramref name="myDepth"/> /// </summary> /// <param name="myAttributes"></param> /// <param name="myType"></param> /// <param name="myDBObject"></param> /// <param name="myDepth"></param> /// <param name="myEdgeList"></param> /// <param name="myReference"></param> /// <param name="myUsingGraph"></param> /// <param name="mySelType"></param> /// <param name="myTypeID"></param> private void AddAttributesByDBO(ref Dictionary<String, Object> myAttributes, GraphDBType myType, DBObjectStream myDBObject, Int64 myDepth, EdgeList myEdgeList, String myReference, Boolean myUsingGraph, TypesOfSelect mySelType, TypeUUID myTypeID = null) { #region Get all attributes which are stored at the DBO foreach (var attr in myDBObject.GetAttributes()) { #region Check whether the attribute is still exist in the type - if not, continue var typeAttr = myType.GetTypeAttributeByUUID(attr.Key); if (typeAttr == null) { continue; } #endregion #region Only attributes of the selected myTypeID (TypesOfSelect.Ad) if (mySelType == TypesOfSelect.Ad) { if (myTypeID != typeAttr.GetDBType(_DBContext.DBTypeManager).UUID) { continue; } } #endregion if (attr.Value is ADBBaseObject) { #region Single base object if (mySelType != TypesOfSelect.Minus && mySelType != TypesOfSelect.Gt && mySelType != TypesOfSelect.Lt) { myAttributes.Add(typeAttr.Name, (attr.Value as ADBBaseObject).GetReadoutValue()); } #endregion } else if (attr.Value is IBaseEdge) { #region List of base objects if (mySelType != TypesOfSelect.Minus && mySelType != TypesOfSelect.Gt && mySelType != TypesOfSelect.Lt) { myAttributes.Add(typeAttr.Name, (attr.Value as IBaseEdge).GetReadoutValues()); } #endregion } else if (attr.Value is IReferenceEdge) { #region Reference edge if (mySelType == TypesOfSelect.Minus || mySelType == TypesOfSelect.Asterisk || mySelType == TypesOfSelect.Ad || mySelType == TypesOfSelect.Gt) { // Since we can define special depth (via setting) for attributes we need to check them now myDepth = GetDepth(-1, myDepth, myType, typeAttr); if ((myDepth > 0)) { myAttributes.Add(typeAttr.Name, ResolveAttributeValue(typeAttr, attr.Value, myDepth, myEdgeList, myDBObject, myReference, myUsingGraph)); } else { myAttributes.Add(typeAttr.Name, GetNotResolvedReferenceAttributeValue(myDBObject, typeAttr, myType, myEdgeList, myUsingGraph, _DBContext)); } } #endregion } else { throw new GraphDBException(new Error_NotImplemented(new System.Diagnostics.StackTrace(true))); } } #endregion #region Get all backwardEdge attributes if (mySelType == TypesOfSelect.Minus || mySelType == TypesOfSelect.Asterisk || mySelType == TypesOfSelect.Ad || mySelType == TypesOfSelect.Lt) { foreach (var beAttr in GetBackwardEdgeAttributes(myType)) { if (myDepth > 0) { if (mySelType == TypesOfSelect.Ad) { if (beAttr.BackwardEdgeDefinition.TypeUUID != myTypeID) { continue; } } var bes = myDBObject.GetBackwardEdges(beAttr.BackwardEdgeDefinition, _DBContext, _DBContext.DBObjectCache, beAttr.GetDBType(_DBContext.DBTypeManager)); if (bes.Failed()) throw new GraphDBException(bes.IErrors); if (bes.Value != null) // otherwise the DBO does not have any myAttributes.Add(beAttr.Name, ResolveAttributeValue(beAttr, bes.Value, myDepth, myEdgeList, myDBObject, myReference, myUsingGraph)); } else { if (mySelType == TypesOfSelect.Ad) { if (beAttr.BackwardEdgeDefinition.TypeUUID != myTypeID) { continue; } } var notResolvedBEs = GetNotResolvedBackwardEdgeReferenceAttributeValue(myDBObject, beAttr, beAttr.BackwardEdgeDefinition, myEdgeList, myUsingGraph, _DBContext); if (notResolvedBEs != null) { myAttributes.Add(beAttr.Name, notResolvedBEs); } } } } #endregion #region Get all undefined attributes from DBO if (mySelType == TypesOfSelect.Asterisk || mySelType == TypesOfSelect.Rhomb) { var undefAttrException = myDBObject.GetUndefinedAttributes(_DBContext.DBObjectManager); if (undefAttrException.Failed()) throw new GraphDBException(undefAttrException.IErrors); foreach (var undefAttr in undefAttrException.Value) myAttributes.Add(undefAttr.Key, undefAttr.Value.GetReadoutValue()); } #endregion #region Add special attributes if (mySelType == TypesOfSelect.Asterisk) { foreach (var specialAttr in GetSpecialAttributes(myType)) { if (!myAttributes.ContainsKey(specialAttr.Name)) { var result = (specialAttr as ASpecialTypeAttribute).ExtractValue(myDBObject, myType, _DBContext); if (result.Failed()) { throw new GraphDBException(result.IErrors); } myAttributes.Add(specialAttr.Name, result.Value.GetReadoutValue()); } } } #endregion }
/// <summary> /// Adds the typeNode as an asterisk *, rhomb # or minus - or ad /// </summary> /// <param name="typeNode"></param> public Exceptional AddSelectionType(String myReference, GraphDBType myType, TypesOfSelect mySelType, TypeUUID myTypeID = null) { var selElem = new SelectionElement(mySelType, myTypeID); if (!_Selections.ContainsKey(myReference)) _Selections.Add(myReference, new Dictionary<EdgeList, List<SelectionElement>>()); var level = new EdgeList(new EdgeKey(myType.UUID, null)); if (!_Selections[myReference].ContainsKey(level)) _Selections[myReference].Add(level, new List<SelectionElement>()); if (!_Selections[myReference][level].Exists(item => item.Selection == mySelType)) { _Selections[myReference][level].Add(selElem); } return Exceptional.OK; }
public SelectionElement(TypesOfSelect mySelType, Int64? myTypeID = null) { Selection = mySelType; TypeID = myTypeID; }
/// <summary> /// Adds the typeNode as an asterisk *, rhomb # or minus - or ad /// </summary> public void AddSelectionType(string myReference, IVertexType myType, TypesOfSelect mySelType, long? myTypeID = null) { var selElem = new SelectionElement(mySelType, myTypeID); if (!_Selections.ContainsKey(myReference)) _Selections.Add(myReference, new Dictionary<EdgeList, List<SelectionElement>>()); var level = new EdgeList(new EdgeKey(myType.ID)); if (!_Selections[myReference].ContainsKey(level)) _Selections[myReference].Add(level, new List<SelectionElement>()); if (!_Selections[myReference][level].Exists(item => item.Selection == mySelType)) { _Selections[myReference][level].Add(selElem); } }
/// <summary> /// This will add all attributes of <paramref name="myDBObject"/> to the /// <paramref name="myAttributes"/> reference. Reference attributes will be resolved to the <paramref name="myDepth"/> /// </summary> private void AddAttributesByDBO( SecurityToken mySecurityToken, Int64 myTransactionToken, ref Tuple<IDictionary<String, Object>, IDictionary<String, IEdgeView>> myAttributes, IVertexType myType, IVertex myDBObject, Int64 myDepth, EdgeList myEdgeList, String myReference, Boolean myUsingGraph, TypesOfSelect mySelType, Int64? myTypeID = null) { #region Get all attributes which are stored at the DBO #region properties foreach (var aProperty in myType.GetPropertyDefinitions(true)) { var tempResult = aProperty.GetValue(myDBObject); if (tempResult != null) { myAttributes.Item1.Add(aProperty.Name, tempResult); } } #endregion #region unstructured data foreach (var aUnstructuredProperty in myDBObject.GetAllUnstructuredProperties()) { myAttributes.Item1.Add(aUnstructuredProperty.PropertyName, aUnstructuredProperty.Property); } #endregion #region outgoing edges foreach (var outgoingEdgeDefinition in myType.GetOutgoingEdgeDefinitions(true)) { if (myDBObject.HasOutgoingEdge(outgoingEdgeDefinition.ID)) { // Since we can define special depth (via setting) for attributes we need to check them now myDepth = GetDepth(-1, myDepth, myType, outgoingEdgeDefinition); if ((myDepth > 0)) { myAttributes.Item2.Add( outgoingEdgeDefinition.Name, ResolveAttributeValue( outgoingEdgeDefinition, myDBObject.GetOutgoingEdge(outgoingEdgeDefinition.ID), myDepth, myEdgeList, myDBObject, myReference, myUsingGraph, mySecurityToken, myTransactionToken)); } else { myAttributes.Item2.Add(outgoingEdgeDefinition.Name, GetNotResolvedReferenceEdgeAttributeValue(myDBObject .GetOutgoingEdge(outgoingEdgeDefinition.ID) .GetTargetVertices())); } } } #endregion #region incoming foreach (var aIncomingEdgeDefinition in myType.GetIncomingEdgeDefinitions(true)) { if (myDBObject.HasIncomingVertices(aIncomingEdgeDefinition .RelatedEdgeDefinition .RelatedType.ID, aIncomingEdgeDefinition .RelatedEdgeDefinition.ID)) { if (myDepth > 0) { myAttributes.Item2.Add( aIncomingEdgeDefinition.Name, ResolveIncomingEdgeValue( aIncomingEdgeDefinition, myDBObject.GetIncomingVertices(aIncomingEdgeDefinition .RelatedEdgeDefinition .RelatedType .ID, aIncomingEdgeDefinition .RelatedEdgeDefinition.ID), myDepth, myEdgeList, myDBObject, myReference, myUsingGraph, mySecurityToken, myTransactionToken)); } else { myAttributes.Item2.Add(aIncomingEdgeDefinition.Name, GetNotResolvedReferenceEdgeAttributeValue(myDBObject.GetIncomingVertices(aIncomingEdgeDefinition .RelatedEdgeDefinition .RelatedType.ID, aIncomingEdgeDefinition .RelatedEdgeDefinition.ID))); } } } #endregion #endregion }
public SelectionElement(TypesOfSelect mySelType, TypeUUID myTypeID = null) { Selection = mySelType; TypeID = myTypeID; }