Ejemplo n.º 1
0
        public PropertyPredefinition ToPropertyPredefinition()
        {
            var property = new PropertyPredefinition(this.AttributeName, this.AttributeType); //Todo insert attribute type

            property.SetAttributeType(this.AttributeType != null ? this.AttributeType : null);
            property.SetComment(this.Comment != null ? this.Comment : null);

            if (this.IsIndexed)
            {
                property.SetAsIndexed();
            }
            if (this.IsMandatory)
            {
                property.SetAsMandatory();
            }
            if (this.IsUnique)
            {
                property.SetAsUnique();
            }
            if (this.DefaultValue != null)
            {
                property.SetDefaultValue(this.DefaultValue);
            }

            if (this.Multiplicity.Equals(ServicePropertyMultiplicity.List))
            {
                property.SetMultiplicityToList();
            }
            if (this.Multiplicity.Equals(ServicePropertyMultiplicity.Set))
            {
                property.SetMultiplicityToSet();
            }

            return(property);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Generates a attribute definition
        /// </summary>
        /// <param name="aAttribute">The attribute that is going to be transfered</param>
        /// <returns>A attribute predefinition</returns>
        private PropertyPredefinition GenerateProperty(KeyValuePair <AttributeDefinition, string> aAttribute)
        {
            PropertyPredefinition result = new PropertyPredefinition(aAttribute.Key.AttributeName,
                                                                     aAttribute.Value);

            switch (aAttribute.Key.AttributeType.Type)
            {
            case SonesGQLGrammar.TERMINAL_SET:
                result.SetMultiplicityToSet();
                break;

            case SonesGQLGrammar.TERMINAL_LIST:
                result.SetMultiplicityToList();
                break;
            }

            if (aAttribute.Key.DefaultValue != null)
            {
                result.SetDefaultValue(aAttribute.Key.DefaultValue.ToString());
            }

            if (aAttribute.Key.AttributeType.TypeCharacteristics.IsMandatory)
            {
                result.SetAsMandatory();
            }

            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Reads an attribute definition from the GraphML File and stores
        /// it internal for later usage on vertex / edge reading.
        /// </summary>
        /// <param name='myReader'>
        /// XmlReader
        /// </param>
        private void ReadAttributeDefinition(XmlReader myReader)
        {
            #region data

            var attrId   = myReader.GetAttribute(GraphMLTokens.ID);
            var attrFor  = myReader.GetAttribute(GraphMLTokens.FOR);
            var attrName = myReader.GetAttribute(GraphMLTokens.ATTRIBUTE_NAME);
            var attrType = myReader.GetAttribute(GraphMLTokens.ATTRIBUTE_TYPE).ToLower();

            string attrDefault = null;

            using (var readerAttribute = myReader.ReadSubtree())
            {
                while (readerAttribute.Read())
                {
                    if (readerAttribute.Name == GraphMLTokens.DEFAULT)
                    {
                        attrDefault = readerAttribute.ReadElementContentAsString();
                    }
                }
            }

            // make attribute type DB conform (capitalize first letter)
            attrType = char.ToUpper(attrType[0]) + attrType.Substring(1).ToLower();
            // and store the whole definition
            _AttributeDefinitions.Add(attrId, new Tuple <string, string, string, string>(attrFor, attrName, attrType, attrDefault));
            // get GraphDB internal type
            attrType = GetInternalTypeName(attrType);

            #endregion

            #region alter vertex type with new attribute

            if (attrFor.Equals(GraphMLTokens.VERTEX))
            {
                var requestAlterVertexType = new RequestAlterVertexType(_VertexTypeName);

                var propertyPreDefinition = new PropertyPredefinition(attrName, attrType);

                propertyPreDefinition.SetDefaultValue(attrDefault);

                requestAlterVertexType.AddProperty(propertyPreDefinition);

                _GraphDB.AlterVertexType(_SecurityToken,
                                         _TransactionToken,
                                         requestAlterVertexType,
                                         (stats, vType) => vType);
            }

            #endregion
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates the vertexType based on the VertexTypeName.
        ///
        /// The vertexType contains one Outgoing Edge Defintion, the edge
        /// is weighted and can't contain any other attributes.
        /// </summary>
        private void CreateVertexType()
        {
            #region create vertex type

            var vertexTypePreDef = new VertexTypePredefinition(_VertexTypeName);
            var outEdgePreDef    = new OutgoingEdgePredefinition(_EdgeTypeName, vertexTypePreDef);

            #region create edge definition

            // weighted multi-edge
            outEdgePreDef.SetEdgeTypeAsWeighted();
            // set inner edge type to weighted
            outEdgePreDef.SetMultiplicityAsMultiEdge("Weighted");

            vertexTypePreDef.AddOutgoingEdge(outEdgePreDef);

            #endregion

            #region create id definition

            var idPreDefinition = new PropertyPredefinition(GraphMLTokens.VERTEX_ID_NAME, GraphMLTokens.VERTEX_ID_TYPE);

            idPreDefinition.SetDefaultValue(GraphMLTokens.VERTEX_ID_DEF_VAL);

            vertexTypePreDef.AddProperty(idPreDefinition);

            #endregion

            #region create vertex type

            var requestCreateVertexType = new RequestCreateVertexType(vertexTypePreDef);

            _GraphDB.CreateVertexType(_SecurityToken,
                                      _TransactionToken,
                                      requestCreateVertexType,
                                      (stats, vType) => vType);

            #endregion

            #endregion
        }
        public PropertyPredefinition ToPropertyPredefinition()
        {
            var property =  new PropertyPredefinition(this.AttributeName,this.AttributeType); //Todo insert attribute type
            property.SetAttributeType(this.AttributeType != null ? this.AttributeType : null);
            property.SetComment(this.Comment != null ? this.Comment : null);

            if (this.IsIndexed)
                property.SetAsIndexed();
            if (this.IsMandatory)
                property.SetAsMandatory();
            if (this.IsUnique)
                property.SetAsUnique();
            if (this.DefaultValue != null)
                property.SetDefaultValue(this.DefaultValue);

            if (this.Multiplicity.Equals(ServicePropertyMultiplicity.List))
                property.SetMultiplicityToList();
            if (this.Multiplicity.Equals(ServicePropertyMultiplicity.Set))
                property.SetMultiplicityToSet();

            return property;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Reads an attribute definition from the GraphML File and stores
        /// it internal for later usage on vertex / edge reading.
        /// </summary>
        /// <param name='myReader'>
        /// XmlReader
        /// </param>
        private void ReadAttributeDefinition(XmlReader myReader)
        {
            #region data

            var attrId 		= myReader.GetAttribute(GraphMLTokens.ID);
            var attrFor 	= myReader.GetAttribute(GraphMLTokens.FOR);
            var attrName 	= myReader.GetAttribute(GraphMLTokens.ATTRIBUTE_NAME);
            var attrType 	= myReader.GetAttribute(GraphMLTokens.ATTRIBUTE_TYPE).ToLower();

            string attrDefault = null;

            using (var readerAttribute = myReader.ReadSubtree())
            {
                while (readerAttribute.Read())
                {
                    if (readerAttribute.Name == GraphMLTokens.DEFAULT)
                    {
                        attrDefault = readerAttribute.ReadElementContentAsString();
                    }
                }
            }

            // make attribute type DB conform (capitalize first letter)
            attrType = char.ToUpper(attrType[0]) + attrType.Substring(1).ToLower();
            // and store the whole definition
            _AttributeDefinitions.Add(attrId, new Tuple<string, string, string, string>(attrFor, attrName, attrType, attrDefault));
            // get GraphDB internal type
            attrType = GetInternalTypeName(attrType);

            #endregion

            #region alter vertex type with new attribute

            if(attrFor.Equals(GraphMLTokens.VERTEX))
            {
                var requestAlterVertexType = new RequestAlterVertexType(_VertexTypeName);

                var propertyPreDefinition = new PropertyPredefinition(attrName, attrType);

                propertyPreDefinition.SetDefaultValue(attrDefault);

                requestAlterVertexType.AddProperty(propertyPreDefinition);

                _GraphDB.AlterVertexType(_SecurityToken,
                    _TransactionToken,
                    requestAlterVertexType,
                    (stats, vType) => vType);
            }

            #endregion
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates the vertexType based on the VertexTypeName.
        /// 
        /// The vertexType contains one Outgoing Edge Defintion, the edge
        /// is weighted and can't contain any other attributes.
        /// </summary>
        private void CreateVertexType()
        {
            #region create vertex type

            var vertexTypePreDef 	= new VertexTypePredefinition(_VertexTypeName);
            var outEdgePreDef 		= new OutgoingEdgePredefinition(_EdgeTypeName, vertexTypePreDef);

            #region create edge definition

            // weighted multi-edge
            outEdgePreDef.SetEdgeTypeAsWeighted();
            // set inner edge type to weighted
            outEdgePreDef.SetMultiplicityAsMultiEdge("Weighted");

            vertexTypePreDef.AddOutgoingEdge(outEdgePreDef);

            #endregion

            #region create id definition

            var idPreDefinition = new PropertyPredefinition(GraphMLTokens.VERTEX_ID_NAME , GraphMLTokens.VERTEX_ID_TYPE);

            idPreDefinition.SetDefaultValue(GraphMLTokens.VERTEX_ID_DEF_VAL);

            vertexTypePreDef.AddProperty(idPreDefinition);

            #endregion

            #region create vertex type

            var requestCreateVertexType = new RequestCreateVertexType(vertexTypePreDef);

            _GraphDB.CreateVertexType(_SecurityToken,
                                     _TransactionToken,
                                     requestCreateVertexType,
                                     (stats, vType) => vType);

            #endregion

            #endregion
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Generates a attribute definition
        /// </summary>
        /// <param name="aAttribute">The attribute that is going to be transfered</param>
        /// <returns>A attribute predefinition</returns>
        private PropertyPredefinition GenerateProperty(KeyValuePair<AttributeDefinition, string> aAttribute)
        {
            PropertyPredefinition result = new PropertyPredefinition(aAttribute.Key.AttributeName,
                                                                        aAttribute.Value);

            switch (aAttribute.Key.AttributeType.Type)
            {
                case SonesGQLGrammar.TERMINAL_SET:
                    result.SetMultiplicityToSet();
                    break;

                case SonesGQLGrammar.TERMINAL_LIST:
                    result.SetMultiplicityToList();
                    break;
            }

            if (aAttribute.Key.DefaultValue != null)
                result.SetDefaultValue(aAttribute.Key.DefaultValue.ToString());

            if (aAttribute.Key.AttributeType.TypeCharacteristics.IsMandatory)
                result.SetAsMandatory();

            return result;
        }