示例#1
0
        private void UpperValue(IEntity entity, XmlNode element)
        {
            if (entity is IEntityAttribute)
            {
                IEntityAttribute field      = entity as IEntityAttribute;
                XmlAttribute     upperValue = element.Attributes["value"];
                if (null != upperValue)
                {
                    if (upperValue.Value == "*")
                    {
                        field.Mult = Multiplicity.OneToMany;
                    }
                    else
                    {
                        field.Mult = Multiplicity.OneToOne;
                    }

                    ResolveReference(field);
                }
            }
            else
            {
                throw new UnknownContextException("UpperValue is being parse in a unknown context. UpperValue show be child of UML:Property");
            }
        }
示例#2
0
 private void ResolveReferenceMultiplicity(IEntityAttribute field)
 {
     if (field is EntityField)
     {
         ResolveReferenceMultiplicity((EntityField)field);
     }
 }
示例#3
0
        public void ResolveReference(IEntityAttribute field)
        {
            if (field is EntityField && field.Type is EntityClass)
            {
                EntityField e = (EntityField)field;
                if (e.ReferenceType == null && e.Type != null && e.Mult != Multiplicity.OneToOne)
                {
                    EntityField reference = new EntityField();
                    reference.Name          = e.Parent.Name;
                    reference.Type          = e.Parent;
                    reference.InfoOnly      = true;
                    reference.ReferenceType = e;

                    EntityClass entity = ((EntityClass)field.Type);
                    if (entity.HasField(reference.Name))
                    {
                        e.ReferenceType = entity.GetField(reference.Name);
                    }
                    else
                    {
                        e.ReferenceType = reference;
                        entity.AddField(reference);
                    }

                    ResolveReferenceMultiplicity(e);
                }
            }
        }
示例#4
0
        public void AddAttribute(IEntityAttribute newAttribute)
        {
            AgentAttribute newAgentAttribute = gameObject.AddComponent <AgentAttribute> ();

            //if (newAgentAttribute != null)
            //{
            //	m_Attributes.Add(newAgentAttribute);
            //}
        }
        public bool Equals(IEntityAttribute other)
        {
            var isEqual =
                (this.Id.Equals(other.Id) &&
                 this.IdEntity.Equals(other.IdEntity)) ||
                (this.Name.Equals(other.Name) &&
                 this.IdEntity.Equals(other.IdEntity));

            return(isEqual);
        }
示例#6
0
        private void ResolveIntrinsicType(XmlNode element, IEntityAttribute field)
        {
            if (element != null && element.HasChildNodes && element.FirstChild.HasChildNodes)
            {
                XmlAttribute type = element.FirstChild.FirstChild.Attributes["referentPath"];
                if (type != null)
                {
                    if (!dataTypes.ContainsKey(type.Value))
                    {
                        string key = Translator.Translate(type.Value.ToLower());
                        if (null == key)
                        {
                            throw new UnknownIntrinsicTypeException(type.Value);
                        }

                        dataTypes.Add(type.Value, Loki.DataRepresentation.Loaders.IntrinsicTypes.Create(key));
                    }
                    field.Type = dataTypes[type.Value];
                }
            }
        }
示例#7
0
        public void ResolveType(XmlNode element, IEntityAttribute field, bool addifnotfound)
        {
            XmlAttribute type = element.Attributes["type"];

            if (null != type)
            {
                if (dataTypes.ContainsKey(type.Value))
                {
                    field.Type = dataTypes[type.Value];
                    ResolveReference(field);
                }
                else
                {
                    if (addifnotfound)
                    {
                        field.Resolved = false;
                        unresolved.Add(new UnresolvedInfo(element, new EntityAttributeResolver(field)));
                    }
                }
            }
        }
示例#8
0
        /// <summary>
        /// Build an oracle type with any precision, length, etc. qualifiers included.
        /// </summary>
        /// <param name="attr"></param>
        /// <returns></returns>
        internal static string BuildAggregateOracleType(IEntityAttribute attr)
        {
            if (String.IsNullOrEmpty(attr.AttrType))
            {
                return(attr.AttrType);
            }

            string oracleType = attr.AttrType.Trim();

            // handle Oracle aliaes
            if (oracleType.Equals(Orcl.DECIMAL) || oracleType.Equals(Orcl.NUMERIC))
            {
                oracleType = Orcl.NUMBER;
            }

            if (oracleType == Orcl.NUMBER)   // add precisions and scale, if any, to NUMBER to create complete data type
            {
                if (attr.Precision != null || attr.Scale == 0)
                {
                    oracleType += "(" + (attr.Precision ?? 38).ToString();
                }
                if (attr.Precision != null || attr.Scale == 0)
                {
                    oracleType += "," + (attr.Scale ?? 0).ToString();
                }
                if (attr.Precision != null || attr.Scale == 0)
                {
                    oracleType += ")";
                }
            }
            else if (oracleType.Contains(Orcl.VARCHAR))
            {
                if (attr.Length >= 1)
                {
                    oracleType = oracleType + "(" + attr.Length + ")";
                }
            }

            return(oracleType);
        }
示例#9
0
 private void ParsePrimitiveType(IEntity entity, XmlNode element)
 {
     try {
         if (entity is IEntityAttribute)
         {
             IEntityAttribute field = entity as IEntityAttribute;
             ResolveIntrinsicType(element, field);
             IterateInnerChilds(element, field);
         }
         else
         {
             throw new UnknownContextException("uml:PrimitiveType is being parse in a unknown context. uml:PrimitiveType show be child of UML:Property or UML:Parameter");
         }
     } catch (UnknownIntrinsicTypeException ex) {
         if (entity is EntityField)
         {
             EntityField field = (EntityField)entity;
             throw new Exception("Error loading field '" + field.PropertyName + "'", ex);
         }
         throw;
     }
 }
示例#10
0
 public bool Equals(IEntityAttribute other)
 {
     return(this.Id.Equals(other.Id));
 }
示例#11
0
 public EntityAttributeResolver(IEntityAttribute entity) : base(entity)
 {
 }
示例#12
0
 public EntityAttributeResolver( IEntityAttribute entity )
     : base(entity)
 {
 }
示例#13
0
        public void ResolveReference( IEntityAttribute field )
        {
            if( field is EntityField && field.Type is EntityClass ) {
                EntityField e = (EntityField)field;
                if( e.ReferenceType == null && e.Type != null && e.Mult != Multiplicity.OneToOne ) {
                    EntityField reference = new EntityField();
                    reference.Name = e.Parent.Name;
                    reference.Type = e.Parent;
                    reference.InfoOnly = true;
                    reference.ReferenceType = e;

                    EntityClass entity = ((EntityClass)field.Type);
                    if( entity.HasField( reference.Name ) ) {
                        e.ReferenceType = entity.GetField( reference.Name );
                    }else{
                        e.ReferenceType = reference;
                        entity.AddField( reference );
                    }

                    ResolveReferenceMultiplicity( e );
                }
            }
        }
示例#14
0
 public void ResolveType(XmlNode element, IEntityAttribute field, bool addifnotfound)
 {
     XmlAttribute type = element.Attributes["type"];
     if( null != type ) {
         if( dataTypes.ContainsKey( type.Value ) ) {
             field.Type = dataTypes[type.Value];
             ResolveReference( field );
         } else {
             if( addifnotfound ) {
                 field.Resolved = false;
                 unresolved.Add( new UnresolvedInfo( element, new EntityAttributeResolver( field ) ) );
             }
         }
     }
 }
示例#15
0
        private void ResolveIntrinsicType( XmlNode element, IEntityAttribute field )
        {
            if( element != null && element.HasChildNodes && element.FirstChild.HasChildNodes ) {
                XmlAttribute type = element.FirstChild.FirstChild.Attributes["referentPath"];
                if( type != null ) {
                    if( !dataTypes.ContainsKey( type.Value ) ) {
                        string key = Translator.Translate( type.Value.ToLower() );
                        if( null == key ) {
                            throw new UnknownIntrinsicTypeException( type.Value );
                        }

                        dataTypes.Add( type.Value, Loki.DataRepresentation.Loaders.IntrinsicTypes.Create( key ) );
                    }
                    field.Type = dataTypes[type.Value];
                }
            }
        }
示例#16
0
 private void ResolveReferenceMultiplicity( IEntityAttribute field )
 {
     if( field is EntityField ) {
         ResolveReferenceMultiplicity( (EntityField)field );
     }
 }
示例#17
0
 internal static String GetDataTypeProperName(IEntityAttribute entityAttribute)
 {
     return(IsExistsType(entityAttribute.DataType) ? String.Empty : entityAttribute.DataType);
 }