/// <summary> /// Extracts the attribute from <paramref name="myDBObject"/>. /// </summary> /// <param name="myType"></param> /// <param name="myTypeAttribute"></param> /// <param name="myDBObject"></param> /// <param name="myLevelKey"></param> /// <returns></returns> private Object GetAttributeValue(GraphDBType myType, TypeAttribute myTypeAttribute, DBObjectStream myDBObject, EdgeList myLevelKey) { if (myTypeAttribute.TypeCharacteristics.IsBackwardEdge) { #region IsBackwardEdge EdgeKey edgeKey = myTypeAttribute.BackwardEdgeDefinition; var contBackwardExcept = myDBObject.ContainsBackwardEdge(edgeKey, _DBContext, _DBContext.DBObjectCache, myType); if (contBackwardExcept.Failed()) throw new GraphDBException(contBackwardExcept.IErrors); if (contBackwardExcept.Value) { var getBackwardExcept = myDBObject.GetBackwardEdges(edgeKey, _DBContext, _DBContext.DBObjectCache, myTypeAttribute.GetDBType(_DBContext.DBTypeManager)); if (getBackwardExcept.Failed()) throw new GraphDBException(getBackwardExcept.IErrors); return getBackwardExcept.Value; } #endregion } else if (myDBObject.HasAttribute(myTypeAttribute.UUID, myType)) { #region ELSE (!IsBackwardEdge) return myDBObject.GetAttribute(myTypeAttribute.UUID, myType, _DBContext); #endregion } return null; }
private IObject GetDbos(IDChainDefinition myIDChainDefinition, DBObjectStream myDBObjectStream, DBContext dbContext, SessionSettings mySessionToken, DBObjectCache dbObjectCache) { if (myIDChainDefinition.LastAttribute.IsBackwardEdge) { var contBackwardExcept = myDBObjectStream.ContainsBackwardEdge(myIDChainDefinition.LastAttribute.BackwardEdgeDefinition, dbContext, dbObjectCache, myIDChainDefinition.LastAttribute.GetRelatedType(dbContext.DBTypeManager)); if (contBackwardExcept.Failed()) throw new GraphDBException(contBackwardExcept.IErrors); if (contBackwardExcept.Value) { var beStream = dbObjectCache.LoadDBBackwardEdgeStream(myIDChainDefinition.LastType, myDBObjectStream.ObjectUUID).Value; if (beStream.ContainsBackwardEdge(myIDChainDefinition.LastAttribute.BackwardEdgeDefinition)) return beStream.GetBackwardEdges(myIDChainDefinition.LastAttribute.BackwardEdgeDefinition); else return null; } else { return null; } } else { if (myIDChainDefinition.LastAttribute.KindOfType == KindsOfType.SpecialAttribute) { return myDBObjectStream.GetAttribute(myIDChainDefinition.LastAttribute.UUID, myIDChainDefinition.LastAttribute.GetRelatedType(dbContext.DBTypeManager), dbContext); } else { return myDBObjectStream.GetAttribute(myIDChainDefinition.LastAttribute.UUID); } } }
/// <summary> Gets an attribute value - references will be resolved. </summary> /// /// <remarks> Stefan, 16.04.2010. </remarks> /// /// <param name="myType"> Type. </param> /// <param name="myTypeAttribute"> my type attribute. </param> /// <param name="myDBObject"> my database object. </param> /// <param name="myDepth"> Depth of my. </param> /// <param name="myLevelKey"> my level key. </param> /// <param name="reference"> The reference. </param> /// <param name="myUsingGraph"> true to my using graph. </param> /// <param name="attributeValue"> [out] The attribute value. </param> /// /// <returns> true if it succeeds, false if the DBO does not have the attribute. </returns> private Boolean GetAttributeValueAndResolve(GraphDBType myType, SelectionElement mySelectionelement, DBObjectStream myDBObject, Int64 myDepth, EdgeList myLevelKey, String reference, Boolean myUsingGraph, out Object attributeValue, String myUndefAttrName = null) { var typeAttribute = mySelectionelement.Element; if (typeAttribute.TypeCharacteristics.IsBackwardEdge) { #region IsBackwardEdge EdgeKey edgeKey = typeAttribute.BackwardEdgeDefinition; var contBackwardExcept = myDBObject.ContainsBackwardEdge(edgeKey, _DBContext, _DBContext.DBObjectCache, myType); if (contBackwardExcept.Failed()) throw new GraphDBException(contBackwardExcept.IErrors); if (contBackwardExcept.Value) { if (myDepth > 0) { var dbos = myDBObject.GetBackwardEdges(edgeKey, _DBContext, _DBContext.DBObjectCache, typeAttribute.GetDBType(_DBContext.DBTypeManager)); if (dbos.Failed()) throw new GraphDBException(dbos.IErrors); if (dbos.Value != null) { attributeValue = ResolveAttributeValue(typeAttribute, dbos.Value, myDepth, myLevelKey, myDBObject, reference, myUsingGraph); return true; } } else { attributeValue = GetNotResolvedBackwardEdgeReferenceAttributeValue(myDBObject, typeAttribute, edgeKey, myLevelKey, myUsingGraph, _DBContext); return true; } } #endregion } else if (myDBObject.HasAttribute(typeAttribute, _DBContext)) { #region SelectValueAssignment - kind of static assignment of selected attribute if (mySelectionelement.SelectValueAssignment != null && mySelectionelement.SelectValueAssignment.ValueAssignmentType == SelectValueAssignment.ValueAssignmentTypes.Always) { // Currently the prior add SelectionElement verifies that TermDefinition is always a ValueDefinition - if others will become valid this must be changed! attributeValue = (mySelectionelement.SelectValueAssignment.TermDefinition as ValueDefinition).Value.Value; return true; } #endregion #region ELSE (!IsBackwardEdge) #region not a reference attribute value if (!typeAttribute.IsUserDefinedType(_DBContext.DBTypeManager)) { var attrVal = myDBObject.GetAttribute(typeAttribute, myType, _DBContext); if (attrVal.Failed()) { throw new GraphDBException(attrVal.IErrors); } // currently, we do not want to return a ADBBaseObject but the real value if (attrVal.Value is ADBBaseObject) attributeValue = (attrVal.Value as ADBBaseObject).GetReadoutValue(); else if (attrVal.Value is IBaseEdge) attributeValue = (attrVal.Value as IBaseEdge).GetReadoutValues(); else attributeValue = attrVal.Value; return true; } #endregion #region ELSE Reference attribute value else { if (myDepth > 0) { var attrValue = myDBObject.GetAttribute(typeAttribute.UUID, myType, _DBContext); attributeValue = ResolveAttributeValue(typeAttribute, attrValue, myDepth, myLevelKey, myDBObject, reference, myUsingGraph); return true; } else { attributeValue = GetNotResolvedReferenceAttributeValue(myDBObject, typeAttribute, myType, myLevelKey, myUsingGraph, _DBContext); return true; } } #endregion #endregion } else if (mySelectionelement.SelectValueAssignment != null) { // Currently the prior add SelectionElement verifies that TermDefinition is always a ValueDefinition - if others will become valid this must be changed! attributeValue = (mySelectionelement.SelectValueAssignment.TermDefinition as ValueDefinition).Value.Value; return true; } attributeValue = null; return false; }