/// <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 }
private Exceptional<String> CreateGraphDMLforDBObject(DumpFormats myDumpFormat, DBContext myDBContext, GraphDBType myGraphDBType, DBObjectStream myDBObjectStream) { var stringBuilder = new StringBuilder(); var delimiter = ", "; stringBuilder.Append(String.Concat(S_INSERT.ToUpperString(), " ", S_INTO.ToUpperString(), " ", myGraphDBType.Name, " ", S_VALUES.ToUpperString(), " ", S_BRACKET_LEFT)); stringBuilder.Append(String.Concat(S_UUID.ToUpperString(), " = '", myDBObjectStream.ObjectUUID.ToString(), "'", delimiter)); #region CreateGraphDMLforDBODefinedAttributes var defAttrsDML = CreateGraphDMLforDBObjectDefinedAttributes(myDumpFormat, myDBObjectStream.GetAttributes(), myGraphDBType, myDBObjectStream, myDBContext); if (!defAttrsDML.Success()) { return defAttrsDML; } stringBuilder.Append(defAttrsDML.Value); #endregion #region CreateGDMLforDBOUnDefinedAttributes var undefAttrs = myDBObjectStream.GetUndefinedAttributes(myDBContext.DBObjectManager); if (!undefAttrs.Success()) { return new Exceptional<String>(undefAttrs); } if (undefAttrs.Value.Count > 0) { Exceptional<String> undefAttrsDML = CreateGraphDMLforDBObjectUndefinedAttributes(myDumpFormat, undefAttrs.Value, myGraphDBType, myDBObjectStream); if (!undefAttrsDML.Success()) { return undefAttrsDML; } stringBuilder.Append(undefAttrsDML.Value); } #endregion stringBuilder.RemoveSuffix(delimiter); stringBuilder.Append(S_BRACKET_RIGHT); return new Exceptional<String>(stringBuilder.ToString()); }