/// <summary> /// Checks if the attribute names on vertex type definitions are unique, containing parent myAttributes. /// </summary> /// <param name="myTopologicallySortedPointer">A pointer to a vertex type predefinitions in a topologically sorted linked list.</param> /// <param name="myAttributes">A dictionary vertex type name to attribute names, that is build up during the process of CanAddCheckWithFS.</param> /// <param name="myTransaction">A transaction token for this operation.</param> /// <param name="mySecurity">A security token for this operation.</param> private void CanAddCheckAttributeNameUniquenessWithFS(LinkedListNode<VertexTypePredefinition> myTopologicallySortedPointer, IDictionary<string, HashSet<string>> myAttributes, TransactionToken myTransaction, SecurityToken mySecurity) { var parentPredef = GetParentPredefinitionOnTopologicallySortedList(myTopologicallySortedPointer); if (parentPredef == null) { //Get the parent type from FS. var parent = Get(myTopologicallySortedPointer.Value.SuperVertexTypeName, myTransaction, mySecurity); if (parent == null) //No parent type was found. throw new InvalidBaseVertexTypeException(myTopologicallySortedPointer.Value.SuperVertexTypeName); if (parent.GetProperty<bool>((long)AttributeDefinitions.BaseTypeDotIsSealed)) //The parent type is sealed. throw new SealedBaseVertexTypeException(myTopologicallySortedPointer.Value.VertexTypeName, parent.GetPropertyAsString((long)AttributeDefinitions.AttributeDotName)); var parentType = new VertexType(parent); var attributeNames = parentType.GetAttributeDefinitions(true).Select(_=>_.Name); myAttributes[myTopologicallySortedPointer.Value.VertexTypeName] = new HashSet<string>(attributeNames); } else { myAttributes[myTopologicallySortedPointer.Value.VertexTypeName] = new HashSet<string>(myAttributes[parentPredef.Value.VertexTypeName]); } var attributeNamesSet = myAttributes[myTopologicallySortedPointer.Value.VertexTypeName]; CheckIncomingEdgesUniqueName(myTopologicallySortedPointer.Value, attributeNamesSet); CheckOutgoingEdgesUniqueName(myTopologicallySortedPointer.Value, attributeNamesSet); CheckPropertiesUniqueName(myTopologicallySortedPointer.Value, attributeNamesSet); }
private Dictionary<String, TypeInfo> GenerateTypeInfos( LinkedList<VertexTypePredefinition> myDefsSortedTopologically, IDictionary<string, VertexTypePredefinition> myDefsByName, long myFirstID, TransactionToken myTransaction, SecurityToken mySecurity) { var neededVertexTypes = new HashSet<string>(); foreach (var def in myDefsByName) { neededVertexTypes.Add(def.Value.VertexTypeName); neededVertexTypes.Add(def.Value.SuperVertexTypeName); if (def.Value.OutgoingEdges != null) foreach (var edge in def.Value.OutgoingEdges) { neededVertexTypes.Add(edge.AttributeType); } } //At most all vertex types are needed. var result = new Dictionary<String, TypeInfo>((int)myFirstID + myDefsByName.Count); foreach (var vertexType in neededVertexTypes) { if (myDefsByName.ContainsKey(vertexType)) { result.Add(vertexType, new TypeInfo { AttributeCountWithParents = myDefsByName[vertexType].AttributeCount, VertexInfo = new VertexInformation((long)BaseTypes.VertexType, myFirstID++) }); } else { var vertex = _vertexManager.ExecuteManager.GetSingleVertex(new BinaryExpression(new SingleLiteralExpression(vertexType), BinaryOperator.Equals, _vertexTypeNameExpression), myTransaction, mySecurity); IVertexType neededVertexType = new VertexType(vertex); result.Add(vertexType, new TypeInfo { AttributeCountWithParents = neededVertexType.GetAttributeDefinitions(true).LongCount(), VertexInfo = new VertexInformation((long)BaseTypes.VertexType, BaseGraphStorageManager.GetUUID(vertex)) }); } } //accumulate attribute counts for (var current = myDefsSortedTopologically.First; current != null; current = current.Next) { if (!result.ContainsKey(current.Value.VertexTypeName)) continue; var info = result[current.Value.VertexTypeName]; info.AttributeCountWithParents = info.AttributeCountWithParents + result[current.Value.SuperVertexTypeName].AttributeCountWithParents; result[current.Value.VertexTypeName] = info; } return result; }