Exemple #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);
        }
Exemple #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);
        }
        /// <summary>
        /// Converts the unknown properties into properties / edges.
        /// </summary>
        /// <param name="myUnknown">The unknown property predefinition.</param>
        /// <returns>The property predefinition.</returns>
        protected static PropertyPredefinition ConvertUnknownToProperty(UnknownAttributePredefinition myUnknown)
        {
            if (myUnknown.EdgeType != null)
            {
                throw new Exception("An edge type is not allowed on a property.");
            }

            var prop = new PropertyPredefinition(myUnknown.AttributeName, myUnknown.AttributeType)
                       .SetDefaultValue(myUnknown.DefaultValue)
                       .SetComment(myUnknown.Comment);

            if (myUnknown.IsUnique)
            {
                prop.SetAsUnique();
            }

            if (myUnknown.IsMandatory)
            {
                prop.SetAsMandatory();
            }

            if (myUnknown.Multiplicity != null)
            {
                switch (myUnknown.Multiplicity)
                {
                case UnknownAttributePredefinition.LISTMultiplicity:
                    prop.SetMultiplicityToList();
                    break;

                case UnknownAttributePredefinition.SETMultiplicity:
                    prop.SetMultiplicityToSet();
                    break;

                default:
                    throw new Exception("Unknown multiplicity for properties.");
                }
            }

            return(prop);
        }
        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;
        }
        /// <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;
        }
        private static PropertyPredefinition ConvertUnknownToProperty(UnknownAttributePredefinition unknown)
        {
            if (unknown.EdgeType != null)
                throw new Exception("An edge type is not allowed on a property.");

            var prop = new PropertyPredefinition(unknown.AttributeName)
                           .SetDefaultValue(unknown.DefaultValue)
                           .SetAttributeType(unknown.AttributeType)
                           .SetComment(unknown.Comment);

            if (unknown.IsUnique)
                prop.SetAsUnique();

            if (unknown.IsMandatory)
                prop.SetAsMandatory();

            if (unknown.Multiplicity != null)
                switch (unknown.Multiplicity)
                {
                    case UnknownAttributePredefinition.LISTMultiplicity:
                        prop.SetMultiplicityToList();
                        break;
                    case UnknownAttributePredefinition.SETMultiplicity:
                        prop.SetMultiplicityToSet();
                        break;
                    default:
                        throw new Exception("Unknown multiplicity for properties.");
                }
            return prop;
        }