Esempio n. 1
0
        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();
        }
Esempio n. 2
0
 /// <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);
     }
 }
Esempio n. 3
0
        /// <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!");
                }
            }
        }
Esempio n. 4
0
 /// <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();
     }
 }
Esempio n. 5
0
 /// <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);
        }
Esempio n. 7
0
        /// <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);
        }
Esempio n. 8
0
 /// <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);
     }
 }
Esempio n. 9
0
 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));
         }
     }
 }
Esempio n. 10
0
        /// <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);
            }
        }
Esempio n. 11
0
 /// <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);
             }
         }
     }
 }
Esempio n. 12
0
        /// <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);
                }
            }
        }
Esempio n. 13
0
        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();
        }
Esempio n. 14
0
 /// <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
 }
Esempio n. 15
0
 /// <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);
 }
Esempio n. 16
0
 /// <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);
Esempio n. 17
0
 /// <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);
Esempio n. 18
0
 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);
 }
Esempio n. 19
0
 /// <summary>
 /// Checks the index predefinitions.
 /// </summary>
 /// <param name="myTypePredefinition">The to be checked index predefinitions.</param>
 protected static void CheckIndices(ATypePredefinition myTypePredefinition)
 {
     //TODO
 }
Esempio n. 20
0
 /// <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);
Esempio n. 21
0
 /// <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);
Esempio n. 22
0
 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);
 }
Esempio n. 23
0
 /// <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);
 }
Esempio n. 24
0
        /// <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);
        }