Esempio n. 1
0
        protected void HandlePrimitiveCollections(ValueObjectConfig config, IMap <String, IList <XElement> > configDetails)
        {
            IList <XElement> memberTags = configDetails.Get(XmlConstants.BASIC.LocalName);

            if (memberTags == null)
            {
                return;
            }
            for (int j = memberTags.Count; j-- > 0;)
            {
                XElement element    = memberTags[j];
                String   memberName = XmlConfigUtil.GetRequiredAttribute(element, XmlConstants.NAME);

                if (config.IsIgnoredMember(memberName))
                {
                    continue;
                }

                config.SetValueObjectMemberType(memberName, ValueObjectMemberType.BASIC);

                String targetElementTypeName = XmlConfigUtil.GetAttribute(element, XmlConstants.TARGET_ELEMENT_TYPE);
                if (targetElementTypeName.Length == 0)
                {
                    continue;
                }

                Type elementType = XmlConfigUtil.GetTypeForName(targetElementTypeName);
                config.PutMemberType(memberName, elementType);
            }
        }
Esempio n. 2
0
        protected void HandleRelations(ValueObjectConfig config, IMap <String, IList <XElement> > configDetails)
        {
            IList <XElement> elementTypes = configDetails.Get(XmlConstants.RELATION.LocalName);

            if (elementTypes != null)
            {
                for (int i = elementTypes.Count; i-- > 0;)
                {
                    XElement entry      = elementTypes[i];
                    String   memberName = XmlConfigUtil.GetRequiredAttribute(entry, XmlConstants.NAME);

                    if (config.IsIgnoredMember(memberName))
                    {
                        continue;
                    }

                    config.SetValueObjectMemberType(memberName, ValueObjectMemberType.RELATION);

                    bool holdsListType = XmlConfigUtil.AttributeIsTrue(entry, XmlConstants.LIST_TYPE);
                    if (holdsListType)
                    {
                        config.AddListTypeMember(memberName);
                    }

                    String elementTypeName = XmlConfigUtil.GetAttribute(entry, XmlConstants.TARGET_VALUE_OBJECT);
                    if (elementTypeName.Length > 0)
                    {
                        Type elementType = XmlConfigUtil.GetTypeForName(elementTypeName);
                        config.PutMemberType(memberName, elementType);
                    }
                }
            }
        }
Esempio n. 3
0
        protected MemberConfig ReadMemberConfig(XElement memberElement)
        {
            String       memberName   = XmlConfigUtil.GetRequiredAttribute(memberElement, XmlConstants.NAME);
            MemberConfig memberConfig = new MemberConfig(memberName);

            String columnName = XmlConfigUtil.GetAttribute(memberElement, XmlConstants.COLUMN);

            if (columnName.Length > 0)
            {
                memberConfig.ColumnName = columnName;
            }
            String transientValue = XmlConfigUtil.GetAttribute(memberElement, XmlConstants.TRANSIENT);

            if (transientValue.Length != 0)
            {
                memberConfig.Transient = Boolean.Parse(transientValue);
            }
            String definedByValue = XmlConfigUtil.GetAttribute(memberElement, XmlConstants.DEFINED_BY);

            if (definedByValue.Length != 0)
            {
                memberConfig.DefinedBy = definedByValue;
            }
            return(memberConfig);
        }
Esempio n. 4
0
        protected ILinkConfig ReadIndependentLinkConfig(XElement linkTag)
        {
            String alias = XmlConfigUtil.GetRequiredAttribute(linkTag, XmlConstants.ALIAS);
            IndependentLinkConfig link = new IndependentLinkConfig(alias);

            String cascadeDeleteRaw = XmlConfigUtil.GetAttribute(linkTag, XmlConstants.CASCADE_DELETE);

            if (cascadeDeleteRaw.Length > 0)
            {
                CascadeDeleteDirection cascadeDelete = (CascadeDeleteDirection)Enum.Parse(typeof(CascadeDeleteDirection), cascadeDeleteRaw, true);
                link.CascadeDeleteDirection = cascadeDelete;
            }

            String leftStr = XmlConfigUtil.GetAttribute(linkTag, XmlConstants.LEFT);

            if (leftStr.Length > 0)
            {
                Type left = XmlConfigUtil.GetTypeForName(leftStr);
                link.Left = left;
            }

            String rightStr = XmlConfigUtil.GetAttribute(linkTag, XmlConstants.RIGHT);

            if (rightStr.Length > 0)
            {
                Type right = XmlConfigUtil.GetTypeForName(rightStr);
                link.Right = right;
            }

            return(link);
        }
Esempio n. 5
0
        protected void HandleMemberMappings(ValueObjectConfig config, IMap <String, IList <XElement> > configDetails, IEntityMetaData metaData)
        {
            Type entityType = config.EntityType;
            Type valueType  = config.ValueType;

            IMap <String, IPropertyInfo> entityPropertyMap = PropertyInfoProvider.GetPropertyMap(entityType);
            IMap <String, IPropertyInfo> valuePropertyMap  = PropertyInfoProvider.GetPropertyMap(valueType);

            for (int i = memberTagNames.Length; i-- > 0;)
            {
                String memberTagName = memberTagNames[i].LocalName;

                IList <XElement> memberTags = configDetails.Get(memberTagName);
                if (memberTags == null)
                {
                    continue;
                }

                for (int j = memberTags.Count; j-- > 0;)
                {
                    XElement element    = memberTags[j];
                    String   memberName = XmlConfigUtil.GetRequiredAttribute(element, XmlConstants.NAME);
                    if (config.IsIgnoredMember(memberName))
                    {
                        continue;
                    }
                    if (RuntimeValidationActive && !IsPropertyResolvable(valueType, valuePropertyMap, memberName, null))
                    {
                        throw new ArgumentException("Value type property '" + valueType.Name + "." + memberName + "' not found");
                    }

                    bool holdsListType = XmlConfigUtil.AttributeIsTrue(element, XmlConstants.LIST_TYPE);
                    if (holdsListType)
                    {
                        config.AddListTypeMember(memberName);
                    }

                    String entityMemberName = XmlConfigUtil.GetAttribute(element, XmlConstants.NAME_IN_ENTITY);
                    if (entityMemberName.Length == 0)
                    {
                        entityMemberName = memberName;
                    }
                    else
                    {
                        config.PutValueObjectMemberName(entityMemberName, memberName);
                    }
                    if (RuntimeValidationActive && !IsPropertyResolvable(entityType, entityPropertyMap, entityMemberName, metaData))
                    {
                        throw new ArgumentException("Entity type property '" + entityType.Name + "." + entityMemberName
                                                    + "' not found while configuring value type '" + valueType.Name + "'");
                    }
                }
            }
        }
Esempio n. 6
0
        protected IRelationConfig ReadRelationConfig(XElement relationElement, IMap <String, ILinkConfig> nameToLinkMap)
        {
            String      relationName = XmlConfigUtil.GetRequiredAttribute(relationElement, XmlConstants.NAME);
            String      linkName     = XmlConfigUtil.GetAttribute(relationElement, XmlConstants.LINK);
            ILinkConfig linkConfig   = null;

            if (linkName.Length > 0)
            {
                linkConfig = nameToLinkMap.Get(linkName);
            }
            if (linkConfig == null)
            {
                if (Log.InfoEnabled)
                {
                    if (linkName.Length > 0)
                    {
                        Log.Info("No LinkConfig found for name '" + linkName + "'. Creating one with default values.");
                    }
                    else
                    {
                        Log.Info("Unconfigured Link found for property '" + relationName + "'. Trying to resolve this later.");
                    }
                }
                linkConfig = new LinkConfig(linkName);
            }
            try
            {
                RelationConfig20 relationConfig = new RelationConfig20(relationName, linkConfig);

                String entityIdentifierName = XmlConfigUtil.GetAttribute(relationElement, XmlConstants.THIS);
                if (entityIdentifierName.Length > 0)
                {
                    EntityIdentifier entityIdentifier = (EntityIdentifier)Enum.Parse(typeof(EntityIdentifier), entityIdentifierName, true);
                    relationConfig.EntityIdentifier = entityIdentifier;
                }

                return(relationConfig);
            }
            catch (Exception e)
            {
                throw new Exception("Error occured while processing relation '" + relationName + "'", e);
            }
        }
Esempio n. 7
0
        protected LinkConfig ReadLinkConfig(XElement linkTag)
        {
            String     source = XmlConfigUtil.GetRequiredAttribute(linkTag, XmlConstants.SOURCE);
            LinkConfig link   = new LinkConfig(source);

            String cascadeDeleteRaw = XmlConfigUtil.GetAttribute(linkTag, XmlConstants.CASCADE_DELETE);

            if (cascadeDeleteRaw.Length > 0)
            {
                CascadeDeleteDirection cascadeDelete = (CascadeDeleteDirection)Enum.Parse(typeof(CascadeDeleteDirection), cascadeDeleteRaw, true);
                link.CascadeDeleteDirection = cascadeDelete;
            }

            String alias = XmlConfigUtil.GetAttribute(linkTag, XmlConstants.ALIAS);

            if (alias.Length > 0)
            {
                link.Alias = alias;
            }

            return(link);
        }