protected override void ConvertUnknownAttributes(ATypePredefinition myTypePredefinition) { if (myTypePredefinition.UnknownAttributes == null) { return; } var toBeConverted = myTypePredefinition.UnknownAttributes.ToArray(); foreach (var unknown in toBeConverted) { if (_baseTypeManager.IsBaseType(unknown.AttributeType)) { var prop = ConvertUnknownToProperty(unknown); (myTypePredefinition as EdgeTypePredefinition).AddProperty(prop); } else { throw new PropertyHasWrongTypeException(myTypePredefinition.TypeName, unknown.AttributeName, unknown.Multiplicity, "a base type"); } } myTypePredefinition.ResetUnknown(); }
/// <summary> /// Checks whether a vertex type predefinition is not sealed and abstract. /// </summary> /// <param name="myVertexTypePredefinition">The vertex type predefinition to be checked.</param> protected override void CheckSealedAndAbstract(ATypePredefinition myTypePredefinition) { if (myTypePredefinition.IsSealed) { throw new UselessTypeException(myTypePredefinition); } }
/// <summary> /// Checks that the attribute names of the UnknownAttributes and Properties are not null or empty. /// </summary> /// <param name="myTypePredefinition">The type predefinition which holds the attributes.</param> protected static void CheckAttributeNames(ATypePredefinition myTypePredefinition) { if (myTypePredefinition.UnknownAttributes != null) { if (myTypePredefinition .UnknownAttributes .Any(_ => (_ == null) || (String.IsNullOrWhiteSpace(_.AttributeName)))) { throw new EmptyAttributeNameException("Attrbutename on type " + myTypePredefinition.TypeName + "is null!"); } } if (myTypePredefinition.Properties != null) { if (myTypePredefinition .Properties .Any(_ => (_ == null) || (String.IsNullOrWhiteSpace(_.AttributeName)))) { throw new EmptyAttributeNameException("Attrbutename on type " + myTypePredefinition.TypeName + "is null!"); } } }
/// <summary> /// Checks whether the vertex type property on an vertex type definition contains anything. /// </summary> /// <param name="myVertexTypeDefinition">The vertex type predefinition to be checked.</param> protected static void CheckVertexTypeName(ATypePredefinition myTypePredefinition) { if (string.IsNullOrWhiteSpace(myTypePredefinition.TypeName)) { throw new EmptyTypeNameException(); } }
/// <summary> /// Checks whether the edge type property on an outgoing edge definition contains anything. /// </summary> /// <param name="myTypeDefinition">The type predefinition that defines the outgoing edge.</param> /// <param name="myEdge">The outgoing edge to be checked.</param> protected static void CheckEdgeType(ATypePredefinition myTypeDefinition, OutgoingEdgePredefinition myEdge) { if (string.IsNullOrWhiteSpace(myEdge.EdgeType)) { throw new EmptyEdgeTypeException(myTypeDefinition, myEdge.AttributeName); } }
/// <summary> /// Creates a new instance of DuplicatedTypeNameException. /// </summary> /// <param name="myTypeName">The name of the type, that is tried to be added multiple times.</param> public DuplicatedAttributeNameException(ATypePredefinition myTypePredefinition, String myTypeName, Exception innerException = null) : base(innerException) { Predefinition = myTypePredefinition; DuplicatedName = myTypeName; _msg = string.Format("The attribute {0} was declared multiple times on type {1}.", DuplicatedName, Predefinition.TypeName); }
/// <summary> /// Checks the uniqueness of attribute names on a vertex type predefinition without asking the FS. /// </summary> /// <param name="myVertexTypeDefinition">The vertex type predefinition to be checked.</param> protected override void CheckAttributes(ATypePredefinition myTypePredefinitions) { var uniqueNameSet = new HashSet <string>(); CheckIncomingEdgesUniqueName((myTypePredefinitions as VertexTypePredefinition), uniqueNameSet); CheckOutgoingEdgesUniqueName((myTypePredefinitions as VertexTypePredefinition), uniqueNameSet); CheckPropertiesUniqueName((myTypePredefinitions as VertexTypePredefinition), uniqueNameSet); CheckBinaryPropertiesUniqueName((myTypePredefinitions as VertexTypePredefinition), uniqueNameSet); }
/// <summary> /// Checks if the name of the given vertex type predefinition is not used in FS before. /// </summary> /// <param name="myTypePredefinition">The name of this vertex type definition will be checked.</param> /// <param name="myTransaction">A transaction token for this operation.</param> /// <param name="mySecurity">A security token for this operation.</param> protected void CanAddCheckVertexNameUniqueWithFS(ATypePredefinition myTypePredefinition, Int64 myTransaction, SecurityToken mySecurity) { if (Get(myTypePredefinition.TypeName, myTransaction, mySecurity) != null) { throw new DuplicatedTypeNameException(myTypePredefinition.TypeName); } }
protected override void ConvertPropertyUniques(ATypePredefinition myTypePredefinition) { if (myTypePredefinition.Properties != null) { foreach (var uniqueProp in myTypePredefinition.Properties.Where(_ => _.IsUnique)) { (myTypePredefinition as VertexTypePredefinition) .AddUnique(new UniquePredefinition(uniqueProp.AttributeName)); } } }
/// <summary> /// Checks if a given property definition has a valid type. /// </summary> /// <param name="myVertexTypeDefinition">The vertex type predefinition that defines the property.</param> /// <param name="myProperty">The property to be checked.</param> protected void CheckPropertyType(ATypePredefinition myTypePredefinition, PropertyPredefinition myProperty) { if (String.IsNullOrWhiteSpace(myProperty.AttributeType)) { throw new EmptyPropertyTypeException(myTypePredefinition, myProperty.AttributeName); } if (!_baseTypeManager.IsBaseType(myProperty.AttributeType)) { throw new UnknownPropertyTypeException(myTypePredefinition, myProperty.AttributeType); } }
/// <summary> /// Check for the correct default value. /// </summary> /// <param name="vertexTypeDefinition">The vertex type predefinition to be checked.</param> protected void CheckDefaultValue(ATypePredefinition typePredefinition) { if (typePredefinition.Properties != null) { foreach (var item in typePredefinition.Properties.Where(_ => _.DefaultValue != null)) { try { var baseType = _baseStorageManager.GetBaseType(item.AttributeType); item.DefaultValue.ConvertToIComparable(baseType); } catch (Exception) { throw new InvalidTypeException(item.DefaultValue.GetType().Name, item.AttributeType); } } } }
/// <summary> /// Checks the uniqueness of property names on a vertex type predefinition without asking the FS. /// </summary> /// <param name="myVertexTypeDefinition">The vertex type predefinition to be checked.</param> /// <param name="myUniqueNameSet">A set of attribute names defined on this vertex type predefinition.</param> protected void CheckPropertiesUniqueName(ATypePredefinition myTypePredefinition, ISet <string> myUniqueNameSet) { if (myTypePredefinition.Properties != null) { foreach (var prop in myTypePredefinition.Properties) { prop.CheckNull("Property in type predefinition " + myTypePredefinition.TypeName); if (!myUniqueNameSet.Add(prop.AttributeName)) { throw new DuplicatedAttributeNameException(myTypePredefinition, prop.AttributeName); } CheckPropertyType(myTypePredefinition, prop); } } }
protected override void ConvertUnknownAttributes(ATypePredefinition myTypePredefinitions) { if (myTypePredefinitions.UnknownAttributes == null) { return; } var toBeConverted = myTypePredefinitions.UnknownAttributes.ToArray(); foreach (var unknown in toBeConverted) { if (BinaryPropertyPredefinition.TypeName.Equals(unknown.AttributeType)) { var prop = ConvertUnknownToBinaryProperty(unknown); (myTypePredefinitions as VertexTypePredefinition).AddBinaryProperty(prop); } else if (_baseTypeManager.IsBaseType(unknown.AttributeType)) { var prop = ConvertUnknownToProperty(unknown); (myTypePredefinitions as VertexTypePredefinition).AddProperty(prop); } else if (unknown.AttributeType.Contains(IncomingEdgePredefinition.TypeSeparator)) { var prop = ConvertUnknownToIncomingEdge(unknown); (myTypePredefinitions as VertexTypePredefinition).AddIncomingEdge(prop); } else { var prop = ConvertUnknownToOutgoingEdge(unknown); (myTypePredefinitions as VertexTypePredefinition).AddOutgoingEdge(prop); } } myTypePredefinitions.ResetUnknown(); }
/// <summary> /// Checks the unique predefinitions. /// </summary> /// <param name="myTypePredefinition">The to be checked unique predefinitions.</param> protected static void CheckUniques(ATypePredefinition myTypePredefinition) { //TODO //check that the properties in the uniques are existing in the properties of the predefinition or any parent type }
/// <summary> /// Creates an instance of EmptyEdgeTypeException. /// </summary> /// <param name="myPredefinition">The predefinition that causes the exception.</param> public EmptyPropertyTypeException(ATypePredefinition myPredefinition, String myPropertyName, Exception innerException = null) : base(innerException) { _msg = string.Format("The property type {0} on type {1} is empty.", myPropertyName, myPredefinition.TypeName); }
/// <summary> /// Convertes Unknown attributes depending on the type of the predefinition. /// </summary> /// <param name="myTypePredefinition">The predefinitions which contains the unknown attributes.</param> protected abstract void ConvertUnknownAttributes(ATypePredefinition myTypePredefinition);
/// <summary> /// Checks the uniqueness of attribute names on a vertex type predefinition without asking the FS. /// </summary> /// <param name="myVertexTypeDefinition">The vertex type predefinition to be checked.</param> protected abstract void CheckAttributes(ATypePredefinition vertexTypeDefinition);
public UnknownPropertyTypeException(ATypePredefinition myTypePredefinition, string myPropertyName, Exception innerException = null) : base(innerException) { _msg = string.Format("The property {0} on type {1} has an unknown type.", myPropertyName, myTypePredefinition.TypeName); }
/// <summary> /// Checks the index predefinitions. /// </summary> /// <param name="myTypePredefinition">The to be checked index predefinitions.</param> protected static void CheckIndices(ATypePredefinition myTypePredefinition) { //TODO }
/// <summary> /// Checks the properties which are marked as unique and add them to uniques. /// </summary> /// <param name="myTypePredefinition">The predefinition which contains the properties.</param> protected abstract void ConvertPropertyUniques(ATypePredefinition myTypePredefinition);
/// <summary> /// Checks whether a vertex type predefinition is not sealed and abstract. /// </summary> /// <param name="myVertexTypePredefinition">The vertex type predefinition to be checked.</param> protected abstract void CheckSealedAndAbstract(ATypePredefinition myTypePredefinition);
public UselessTypeException(ATypePredefinition predef) { this.VertexType = predef; _msg = string.Format("The type [{0}] is marked sealed and abstract. This makes this type useless.", predef.TypeName); }
/// <summary> /// Creates an instance of EmptyEdgeTypeException. /// </summary> /// <param name="myPredefinition">The predefinition that causes the exception.</param> public EmptyEdgeTypeException(ATypePredefinition myPredefinition, String myOutgoingEdgeName, Exception innerException = null) : base(innerException) { Predefinition = myPredefinition; PropertyName = myOutgoingEdgeName; _msg = string.Format("The outgoing edge {0} on vertex type {1} is empty.", myOutgoingEdgeName, myPredefinition.TypeName); }
/// <summary> /// Checks the uniqueness of attribute names on a vertex type predefinition without asking the FS. /// </summary> /// <param name="myVertexTypeDefinition">The vertex type predefinition to be checked.</param> protected override void CheckAttributes(ATypePredefinition myTypePredefinition) { var uniqueNameSet = new HashSet <string>(); CheckPropertiesUniqueName(myTypePredefinition, uniqueNameSet); }