Example #1
0
 public UndefinedTypeAttribute(String myUndefinedAttributeName)
     : base(AttributeUUID)
 {
     UndefinedAttributeName = myUndefinedAttributeName;
     Name = myUndefinedAttributeName;
     TypeCharacteristics = new TypeCharacteristics();
 }
Example #2
0
 public TypeAttribute(AttributeUUID myAttributeUUID)
 {
     UUID                    = myAttributeUUID;
     RelatedGraphDBTypeUUID  = null;
     TypeCharacteristics     = new TypeCharacteristics();
     _Settings               = new Dictionary<String, ADBSettingsBase>();
 }
Example #3
0
        public void GetContent(CompilerContext context, ParseTreeNode parseNode)
        {
            if (parseNode.FirstChild.Term.Name.Equals("id_simple"))
            {

                #region simple id

                DBTypeDefinition = new DBTypeOfAttributeDefinition()
                {
                    Type = KindsOfType.UnknownSingle,
                    Name = parseNode.ChildNodes[0].Token.ValueString
                };

                #endregion

            }

            else if (parseNode.FirstChild.Term.Name.ToUpper().Equals(DBConstants.DBBackwardEdge.ToUpper()))
            {

                #region BackwardedgeDefinition

                var _TypeCharacteristics = new TypeCharacteristics();
                _TypeCharacteristics.IsBackwardEdge = true;
                DBTypeDefinition = new DBTypeOfAttributeDefinition()
                {
                    TypeCharacteristics = _TypeCharacteristics,
                    Name = parseNode.ChildNodes[0].Token.ValueString
                };

                #endregion

            }

            else if (parseNode.FirstChild.AstNode is EdgeTypeDefNode)
            {

                #region EdgeType definition

                DBTypeDefinition = new DBTypeOfAttributeDefinition()
                {
                    Type = ((EdgeTypeDefNode)parseNode.FirstChild.AstNode).Type,
                    Name = ((EdgeTypeDefNode)parseNode.FirstChild.AstNode).Name,
                    TypeCharacteristics = ((EdgeTypeDefNode)parseNode.FirstChild.AstNode).TypeCharacteristics,
                    EdgeType = ((EdgeTypeDefNode)parseNode.FirstChild.AstNode).EdgeType,
                    Parameters = ((EdgeTypeDefNode)parseNode.FirstChild.AstNode).Parameters,
                };

                #endregion

            }

            else if (parseNode.FirstChild.AstNode is SingleEdgeTypeDefNode)
            {

                #region Single edge type definition

                DBTypeDefinition = new DBTypeOfAttributeDefinition()
                {
                    Type = ((SingleEdgeTypeDefNode)parseNode.FirstChild.AstNode).Type,
                    Name = ((SingleEdgeTypeDefNode)parseNode.FirstChild.AstNode).Name,
                    TypeCharacteristics = ((SingleEdgeTypeDefNode)parseNode.FirstChild.AstNode).TypeCharacteristics,
                    EdgeType = ((SingleEdgeTypeDefNode)parseNode.FirstChild.AstNode).EdgeType,
                    Parameters = ((SingleEdgeTypeDefNode)parseNode.FirstChild.AstNode).Parameters,
                };

                #endregion

            }

            else if (parseNode.ChildNodes.Count >= 2)
            {

                KindsOfType type;

                #region set
                if (parseNode.ChildNodes[0].Token.ValueString.ToUpper() == DBConstants.SET)
                {
                    type = KindsOfType.UnknownSet;
                }
                #endregion

                #region list
                else if (parseNode.ChildNodes[0].Token.ValueString.ToUpper() == DBConstants.LIST)
                {
                    type = KindsOfType.UnknownList;
                }
                #endregion

                else
                {
                    throw new GraphDBException(new Error_NotImplemented(new System.Diagnostics.StackTrace(true)));
                }

                DBTypeDefinition = new DBTypeOfAttributeDefinition()
                {
                    Type = type,
                    Name = parseNode.ChildNodes[2].Token.ValueString
                };
            }

            else
            {
                throw new ArgumentException("Invalid Graph type definition...");
            }
        }
 public DBTypeOfAttributeDefinition()
 {
     TypeCharacteristics = new TypeCharacteristics();
 }
Example #5
0
        public void GetContent(CompilerContext context, ParseTreeNode parseNode)
        {
            #region TypeEdge class

            //if (!dbContext.DBPluginManager.HasEdgeType(parseNode.ChildNodes[2].Token.ValueString))
            //    throw new GraphDBException(new Error_EdgeTypeDoesNotExist(parseNode.ChildNodes[2].Token.ValueString));

            //EdgeType = dbContext.DBPluginManager.GetEdgeType(parseNode.ChildNodes[2].Token.ValueString);
            EdgeType = parseNode.ChildNodes[2].Token.ValueString;

            if (parseNode.ChildNodes[3].AstNode != null)
            {
                Parameters = ((EdgeTypeParamsNode)parseNode.ChildNodes[3].AstNode).Parameters;
            }

            #endregion

            if (parseNode.FirstChild.Term.Name.Equals("id_simple"))
            {
                #region simple id

                Type = KindsOfType.SingleNoneReference;

                Name = parseNode.ChildNodes[0].Token.ValueString;

                #endregion
            }

            else if (parseNode.FirstChild.Term.Name.ToUpper().Equals(DBConstants.DBBackwardEdge.ToUpper()))
            {
                Name = ((IDNode)parseNode.ChildNodes[2].AstNode).IDChainDefinition.Reference.Item2.Name;
                TypeCharacteristics = new TypeCharacteristics();
                TypeCharacteristics.IsBackwardEdge = true;
            }

            else
            {

                Name = parseNode.ChildNodes[5].Token.ValueString;

                if (parseNode.ChildNodes[0].Token.ValueString.ToUpper() == DBConstants.SET)
                {
                    Type = KindsOfType.UnknownSet;
                }

                if (parseNode.ChildNodes[0].Token.ValueString.ToUpper() == DBConstants.LIST)
                {
                    Type = KindsOfType.ListOfNoneReferences;
                }

            }
        }
Example #6
0
        public void Deserialize(ref SerializationReader mySerializationReader)
        {
            UInt32 _Capacity;

            try
            {

                if (mySerializationReader != null)
                {

                    UUID = new AttributeUUID();
                    UUID.Deserialize(ref mySerializationReader);
                    DBTypeUUID = new TypeUUID();
                    DBTypeUUID.Deserialize(ref mySerializationReader);
                    KindOfType = (KindsOfType)mySerializationReader.ReadOptimizedByte();
                    TypeCharacteristics = new TypeCharacteristics();
                    TypeCharacteristics.Deserialize(ref mySerializationReader);

                    Name = mySerializationReader.ReadString();

                    var hasEdgeType = mySerializationReader.ReadBoolean();

                    if (hasEdgeType)
                    {
                        try
                        {
                            EdgeType = (IEdgeType) mySerializationReader.ReadObject();
                        }
                        catch(Exception ex)
                        {
                            //NLOG: temporarily commented
                            //Logger.Fatal("Could not deserialize EdgeType");
                            throw new GraphDBException(new Error_UnknownDBError(ex));
                        }

                    }

                    RelatedGraphDBTypeUUID = new TypeUUID();
                    RelatedGraphDBTypeUUID.Deserialize(ref mySerializationReader);

                    if (TypeCharacteristics.IsBackwardEdge)
                        BackwardEdgeDefinition = (EdgeKey) mySerializationReader.ReadObject();

                    DefaultValue = (IObject) mySerializationReader.ReadObject();

                    #region Read Settings

                    _Capacity = mySerializationReader.ReadUInt32();

                    _Settings = new Dictionary<String, ADBSettingsBase>();

                    for (var i = 0; i < _Capacity; i++)
                    {

                        var _SettingObject = (ADBSettingsBase) mySerializationReader.ReadObject();

                        if (_SettingObject != null)
                            _Settings.Add(_SettingObject.Name, _SettingObject);

                        /*Type settingType = (Type)mySerializationReader.ReadObject();
                        ADBSettingsBase _SettingObject = null;
                        try
                        {
                            _SettingObject = (ADBSettingsBase)Activator.CreateInstance(settingType);
                        }
                        catch
                        {
                            Logger.Error("Could not create an instance of setting " + settingType.ToString());
                        }
                        Byte[] Bytes = (Byte[])mySerializationReader.ReadObject();
                        if (_SettingObject != null)
                        {
                            _SettingObject.Deserialize(new SerializationReader(Bytes));
                            _Settings.Add(_SettingObject.Name, _SettingObject);
                        }*/
                    }

                    #endregion

                }
            }

            catch (Exception e)
            {
                throw new SerializationException("The Setting could not be deserialized!\n\n" + e);
            }
        }