Example #1
0
        protected static RelationshipDefCol CreateRelationshipDefCol(PropDefCol lPropDefCol)
        {
            RelationshipDefCol relDefCol = new RelationshipDefCol();


            //Define Driver Relationships
            RelKeyDef relKeyDef = new RelKeyDef();
            IPropDef  propDef   = lPropDefCol[PK1_PROP1_NAME];

            RelPropDef lRelPropDef = new RelPropDef(propDef, "DriverFK1");

            relKeyDef.Add(lRelPropDef);

            propDef = lPropDefCol[PK1_PROP2_NAME];

            lRelPropDef = new RelPropDef(propDef, "DriverFK2");
            relKeyDef.Add(lRelPropDef);

            RelationshipDef relDef = new MultipleRelationshipDef("Driver",
                                                                 typeof(Car), relKeyDef, true, "",
                                                                 DeleteParentAction.DereferenceRelated);

            relDefCol.Add(relDef);
            return(relDefCol);
        }
Example #2
0
        /// <summary>
        /// Constructor to create new RelPropDef object
        /// </summary>
        /// <param name="ownerClassPropDef">The property definition of the 
        /// owner object</param>
        /// <param name="relatedObjectPropName">The property name of the 
        /// related object</param>
        public RelPropDef(IPropDef ownerClassPropDef,
                          string relatedObjectPropName)
        {
            ArgumentValidationHelper.CheckArgumentNotNull(ownerClassPropDef, "ownerClassPropDef");
            OwnerPropDef = ownerClassPropDef;
            RelatedClassPropName = relatedObjectPropName;
		}
        public virtual void TestPropertyWithCustomType()
        {
            IPropDef def = _loader.LoadProperty(@"<property  name=""TestProp"" type=""MyType"" assembly=""MyAssembly"" />");

            Assert.AreEqual("MyType", def.PropertyTypeName, "Property type should be same as that specified in xml");
            Assert.AreEqual("MyAssembly", def.PropertyTypeAssemblyName, "Property type should be same as that specified in xml");
        }
        public virtual void TestPropertyWithWriteNewRule()
        {
            IPropDef def = _loader.LoadProperty(@"<property  name=""TestProp"" readWriteRule=""WriteNew"" />");

            Assert.AreEqual(PropReadWriteRule.WriteNew, def.ReadWriteRule,
                            "Property read write rule should be same as that specified in xml");
        }
        public virtual void TestPropertyWithType()
        {
            IPropDef def = _loader.LoadProperty(@"<property  name=""TestProp"" type=""Int32"" />");

            Assert.AreEqual("Int32", def.PropertyTypeName, "Property type should be same as that specified in xml");
            Assert.AreEqual("System", def.PropertyTypeAssemblyName, "Property type should be same as that specified in xml");
        }
Example #6
0
        public void Test_ShouldHaveReadWriteRule_WithLambda_WriteNew_WhenIsNot_ShouldAssertFalse()
        {
            //---------------Set up test pack-------------------
            IClassDef classDef = SetupClassDef <FakeBOWithReadWriteRuleProp>();
            BOTester <FakeBOWithReadWriteRuleProp> boTester = CreateGenericTester <FakeBOWithReadWriteRuleProp>();
            const string propName     = "ReadWriteRuleReadOnly";
            var          propertyInfo =
                ReflectionUtilities.GetPropertyInfo <FakeBOWithReadWriteRuleProp, object>(bo => bo.ReadWriteRuleReadOnly);
            var propertyWrapper = propertyInfo.ToPropertyWrapper();
            const PropReadWriteRule expectedReadWriteRule = PropReadWriteRule.WriteNew;

            //---------------Assert Precondition----------------
            Assert.IsTrue(propertyWrapper.HasAttribute <AutoMapReadWriteRuleAttribute>());
            IPropDef propDef = classDef.GetPropDef(propName);

            Assert.IsNotNull(propDef);
            Assert.AreNotEqual(expectedReadWriteRule, propDef.ReadWriteRule);
            //---------------Test Result -----------------------
            try
            {
                boTester.ShouldHaveReadWriteRule(bo => bo.ReadWriteRuleReadOnly, expectedReadWriteRule);
                Assert.Fail("Expected to throw an AssertionException");
            }
            //---------------Test Result -----------------------
            catch (AssertionException ex)
            {
                string expected = string.Format(
                    "The Property '{0}' for class '{1}' should have a ReadWriteRule '{2}' but is '{3}'",
                    propDef.PropertyName,
                    propDef.ClassName, expectedReadWriteRule, propDef.ReadWriteRule);
                StringAssert.Contains(expected, ex.Message);
            }
        }
 public static bool IsPartOfObjectIdentity(this IPropDef propDef)
 {
     //It is assumed that all Guids are FK Props or PrimaryKey Props and that
     // only Guids are PK Props (i.e. natural PK's,
     // autonumber PK's and all these variants will not be catered for here.)
     return(propDef.PropertyType == typeof(System.Guid));
 }
        public virtual void TestPropertyWithAutoIncrementingField()
        {
            IPropDef def = _loader.LoadProperty(
                @"<property name=""TestProp"" autoIncrementing=""true"" />");

            Assert.AreEqual(true, def.AutoIncrementing);
        }
        public virtual void TestPropertyWithLength()
        {
            IPropDef def = _loader.LoadProperty(
                @"<property name=""TestProp"" length=""5"" />");

            Assert.AreEqual(5, def.Length);
        }
Example #10
0
        public virtual void TestPropertyWithDatabaseFieldNameWithSpaces()
        {
            IPropDef def =
                _loader.LoadProperty(@"<property name=""TestProp"" databaseField=""Test FieldName"" />");

            Assert.AreEqual("Test FieldName", def.DatabaseFieldName);
        }
        private static UIControlType GetControlType(IPropDef propDef)
        {
            UIControlType type;

            if (propDef.HasLookupList())
            {
                return(GetComboBoxControlType());
            }
            switch (propDef.PropertyType.Name)
            {
            case "String":
                type = GetTextBoxControlType();
                break;

            case "Boolean":
                type = GetCheckBoxControlType();
                break;

            case "DateTime":
                type = GetDateTimeControlType();
                break;

            default:
                type = GetTextBoxControlType();
                break;
            }

            return(type);
        }
Example #12
0
        /// <summary>
        /// Loads the property definition data
        /// </summary>
        private void LoadPropDefs(ICollection <string> xmlDefs)
        {
            try
            {
                if (xmlDefs.Count == 0 && _superClassDef == null)
                {
                    throw new InvalidXmlDefinitionException(String.Format("No property " +
                                                                          "definitions have been specified for the class definition of '{0}'. " +
                                                                          "Each class requires at least one 'property' and 'primaryKey' " +
                                                                          "element which define the mapping from the database table fields to " +
                                                                          "properties in the class that is being mapped to.",
                                                                          _className));
                }

                foreach (string propDefXml in xmlDefs)
                {
                    XmlPropertyLoader propLoader = new XmlPropertyLoader(DtdLoader, _defClassFactory);
                    IPropDef          propDef    = propLoader.LoadProperty(propDefXml);
                    if (propDef != null)
                    {
                        _propDefCol.Add(propDef);
                    }
                }
            }
            catch (Exception ex)
            {
                //This is a RecordingExceptionNotifier so this error will be logged and thrown later
                // thus allowing the entire XML File to be read and all errors reported
                GlobalRegistry.UIExceptionNotifier.Notify(ex, "", "Error ");
            }
        }
Example #13
0
        public void Test_Force_PrimaryKey_IsObjectID_AsCompulsoryWriteOnce_WithReadWriteRule_WriteNew()
        {
            //-------------Setup Test Pack ------------------
            const string xml =
                @"
				<classes>
					<class name=""TestClass"" assembly=""Habanero.Test.BO.Loaders"" >
						<property name=""TestClassID"" type=""Guid"" readWriteRule=""WriteNew""/>
						<primaryKey isObjectID=""true"">
							<prop name=""TestClassID""/>
						</primaryKey>
					</class>
				</classes>
			"            ;
            XmlClassDefsLoader loader       = CreateXmlClassDefsLoader();
            ClassDefCol        classDefList = loader.LoadClassDefs(xml);
            ClassDefValidator  validator    = new ClassDefValidator(GetDefClassFactory());
            IClassDef          classDef     = classDefList["Habanero.Test.BO.Loaders", "TestClass"];
            IPropDef           keyPropDef   = classDef.PrimaryKeyDef[0];

            //---------------Assert PreConditions---------------
            Assert.IsFalse(keyPropDef.Compulsory);
            Assert.AreEqual(PropReadWriteRule.WriteNew, keyPropDef.ReadWriteRule);
            //-------------Execute test ---------------------
            validator.ValidateClassDefs(classDefList);
            //---------------Test Result -----------------------
            Assert.IsTrue(keyPropDef.Compulsory);
            Assert.AreEqual(PropReadWriteRule.WriteNew, keyPropDef.ReadWriteRule);
        }
Example #14
0
        /// <summary>
        /// Loads the property definition from the reader
        /// </summary>
        protected override void LoadFromReader()
        {
            _reader.Read();
            LoadPropertyName();
            LoadDisplayName();
            LoadPropertyType();
            LoadReadWriteRule();
            LoadDefaultValue();
            LoadDatabaseFieldName();
            LoadDescription();
            LoadCompulsory();
            LoadAutoIncrementing();
            LoadLength();
            LoadKeepValuePrivate();

            _reader.Read();

            _propDef = _defClassFactory.CreatePropDef(_propertyName, _assemblyName, _typeName, _readWriteRule,
                                                      _databaseFieldName, _defaultValueString, _compulsory, _autoIncrementing, _length, _displayName, _description, _keepValuePrivate);

            while (_reader.Name == "rule")
            {
                var loader = new XmlRuleLoader(DtdLoader, _defClassFactory);
                loader.LoadRuleIntoProperty(_reader.ReadOuterXml(), _propDef);
            }
            int len = "lookupList".Length;

            if (_reader.Name.Length >= len &&
                _reader.Name.Substring(_reader.Name.Length - len, len) == "LookupList")
            {
                XmlLookupListLoader.LoadLookupListIntoProperty(_reader.ReadOuterXml(), _propDef,
                                                               DtdLoader, _defClassFactory);
            }
        }
Example #15
0
        ///<summary>
        /// Based on the class definition and the orderByString an <see cref="OrderCriteria"/> object is created.
        /// The orderCriteria object is a set of order by fields including information on their
        /// business object properties and their dataSource.
        ///</summary>
        ///<param name="classDef">The class definition to use for building the order criteria</param>
        ///<param name="orderByString">The orderby string to use for creating the <see cref="OrderCriteria"/>.</param>
        ///<returns>the newly created <see cref="OrderCriteria"/> object.</returns>
        public static IOrderCriteria CreateOrderCriteria(IClassDef classDef, string orderByString)
        {
            if (classDef == null)
            {
                throw new ArgumentNullException("classDef");
            }
            IOrderCriteria orderCriteria = OrderCriteria.FromString(orderByString);

            try
            {
                //TODO Mark 20 Mar 2009: Souldn't the following code be stripped out into a PrepareOrderBy method that is called before loading? (Similar to PrepareCriteria)
                foreach (OrderCriteriaField field in orderCriteria.Fields)
                {
                    Source    source = field.Source;
                    IClassDef relatedClassDef;
                    IClassDef classDefOfField = classDef;
                    if (classDef.IsUsingClassTableInheritance())
                    {
                        classDefOfField = classDef.GetPropDef(field.PropertyName).ClassDef;
                    }
                    PrepareSource(classDefOfField, ref source, out relatedClassDef);
                    field.Source = source;

                    IPropDef propDef = relatedClassDef.GetPropDef(field.PropertyName);
                    field.FieldName = propDef.DatabaseFieldName;
                    field.Source.ChildSourceLeaf.EntityName = relatedClassDef.GetTableName(propDef);
                }
                return(orderCriteria);
            }
            catch (InvalidPropertyNameException)
            {
                throw new InvalidOrderCriteriaException("The orderByString '" + orderByString
                                                        + "' is not valid for the classDef '" + classDef.ClassNameFull);
            }
        }
Example #16
0
 /// <summary>
 /// Removes a property definition from the collection
 /// </summary>
 /// <param name="propDef">The Property definition to remove</param>
 public void Remove(IPropDef propDef)
 {
     if (Contains(propDef))
     {
         _propDefs.Remove(propDef.PropertyName.ToUpper());
     }
 }
Example #17
0
 /// <summary>
 /// Loads the key properties
 /// </summary>
 /// <exception cref="InvalidXmlDefinitionException">Thrown if an error
 /// occurs while loading the properties</exception>
 private void LoadKeyProperties()
 {
     if (_reader.Name != "prop")
     {
         throw new InvalidXmlDefinitionException("A 'key' node is " +
                                                 "missing 'prop' nodes. Each key definition specifies " +
                                                 "a combination of one or more listed properties that " +
                                                 "must be unique for each row.  The 'prop' elements " +
                                                 "each have a 'name' " +
                                                 "attribute that specifies which existing property definition " +
                                                 "make up the alternate key.");
     }
     do
     {
         string propName = _reader.GetAttribute("name");
         if (string.IsNullOrEmpty(propName))
         {
             throw new InvalidXmlDefinitionException("The 'prop' node " +
                                                     "under a key definition is missing a valid 'name' attribute, " +
                                                     "which specifies the name of an existing property definition " +
                                                     "which makes up the alternate key.");
         }
         if (_propDefCol.Contains(propName))
         {
             _keyDef.Add(_propDefCol[propName]);
         }
         else
         {
             IPropDef tempKeyPropDef = _defClassFactory.CreatePropDef(propName, "System", "String", PropReadWriteRule.ReadWrite, null, null, false, false, 255, null, null, false);
             _keyDef.Add(tempKeyPropDef);
         }
         ReadAndIgnoreEndTag();
     } while (_reader.Name == "prop");
 }
Example #18
0
 /// <summary>
 /// Constructor to create new RelPropDef object
 /// </summary>
 /// <param name="ownerClassPropDef">The property definition of the
 /// owner object</param>
 /// <param name="relatedObjectPropName">The property name of the
 /// related object</param>
 public RelPropDef(IPropDef ownerClassPropDef,
                   string relatedObjectPropName)
 {
     ArgumentValidationHelper.CheckArgumentNotNull(ownerClassPropDef, "ownerClassPropDef");
     OwnerPropDef         = ownerClassPropDef;
     RelatedClassPropName = relatedObjectPropName;
 }
        public void Test_Force_PrimaryKey_IsObjectID_False_AsCompulsoryWriteOnce_WithReadWriteRule_ReadWrite()
        {
            //-------------Setup Test Pack ------------------
            const string       xml    = @"
				<classes>
					<class name=""TestClass"" assembly=""Habanero.Test.BO.Loaders"" >
						<property name=""TestClassID"" type=""string"" readWriteRule=""ReadWrite""/>
                        <primaryKey isObjectID=""false"">
                            <prop name=""TestClassID""/>
                        </primaryKey>
					</class>
				</classes>
			"            ;
            XmlClassDefsLoader loader = CreateXmlClassDefsLoader();
            //-------------Execute test ---------------------
            ClassDefCol classDefs = loader.LoadClassDefs(xml);

            //---------------Test Result -----------------------
            Assert.AreEqual(1, classDefs.Count);
            Assert.IsTrue(classDefs.Contains("Habanero.Test.BO.Loaders", "TestClass"), "Class 'TestClass' should have been loaded.");
            IClassDef classDef = classDefs["Habanero.Test.BO.Loaders", "TestClass"];

            Assert.AreEqual(1, classDef.PrimaryKeyDef.Count);
            IPropDef keyPropDef = classDef.PrimaryKeyDef[0];

            Assert.IsFalse(keyPropDef.Compulsory);
            Assert.AreEqual(PropReadWriteRule.ReadWrite, keyPropDef.ReadWriteRule);
        }
 private static void createPropRulesXml(XmlElement propDMElement, IPropDef propDef)
 {
     foreach (IPropRule propRule in propDef.PropRules)
     {
         createPropRuleXml(propDMElement, propRule);
     }
 }
Example #21
0
        public virtual void TestPropertyWithDatabaseFieldName()
        {
            IPropDef def =
                _loader.LoadProperty(@"<property  name=""TestProp"" databaseField=""TestFieldName"" />");

            Assert.AreEqual("TestFieldName", def.DatabaseFieldName, "Field Name should be the same as that specified in xml");
        }
Example #22
0
        public void Test_Map_WhenTwoPropsWithPrimaryKeyAttribute_ShouldRaiseError()
        {
            //---------------Set up test pack-------------------
            IClassDef cDef          = GetClassDefWithPropsMapped <FakeBOTwoPropsAttributePK>();
            IPropDef  stdNamingProp = GetPKPropDefWithStandardNamingConvention(cDef);

            //---------------Assert Precondition----------------
            Assert.IsNull(stdNamingProp, "There should not be a property with a standard naming convention");

            Assert.IsTrue(cDef.HasPrimaryKeyAttribute("PublicGuidProp"));
            Assert.IsTrue(cDef.HasPrimaryKeyAttribute("AnotherPrimaryKeyProp"));
            //---------------Execute Test ----------------------

            try
            {
                cDef.MapIdentity();
                Assert.Fail("Expected to throw an HabaneroDeveloperException");
            }
            //---------------Test Result -----------------------
            catch (HabaneroApplicationException ex)
            {
                StringAssert.Contains("You cannot auto map Business Objects", ex.Message);
                StringAssert.Contains(" with Composite Primary Keys. Please map using ClassDefs", ex.Message);
            }
        }
 private static void createPropRulesXml(XmlElement propDMElement, IPropDef propDef)
 {
     foreach (IPropRule propRule in propDef.PropRules)
     {
         createPropRuleXml(propDMElement, propRule);
     }
 }
Example #24
0
        public void Test_ShouldHaveDefault_WithLambda_WithSpecifiedValue_WhenNotHasDefault_ShouldAssertFalse()
        {
            //---------------Set up test pack-------------------
            IClassDef    classDef                 = SetupClassDefWithAddProperty <BOFakeWithDefault>();
            const string propName                 = "NonDefaultProp";
            IPropDef     propDef                  = classDef.GetPropDef(propName);
            const string defaultValueString       = "SomeOtherValue";
            BOTester <BOFakeWithDefault> boTester = CreateGenericTester <BOFakeWithDefault>();

            //---------------Assert Precondition----------------
            Assert.IsNullOrEmpty(propDef.DefaultValueString);
            Assert.AreNotEqual(defaultValueString, propDef.DefaultValueString);
            //---------------Test Result -----------------------
            try
            {
                boTester.ShouldHaveDefault(bo => bo.NonDefaultProp, defaultValueString);
                Assert.Fail("Expected to throw an AssertionException");
            }
            //---------------Test Result -----------------------
            catch (AssertionException ex)
            {
                string expected = string.Format("The Property '{0}' for class '{1}' should have a default but does not", propName, "BOFakeWithDefault");
                StringAssert.Contains(expected, ex.Message);
            }
        }
Example #25
0
        private static IBusinessObject GetBOWithProp1LTProp2(IPropDef prop1, IPropDef prop2, out DateTime prop1Value, out DateTime prop2Value)
        {
            prop1Value = DateTime.Now.AddDays(-1);
            prop2Value = DateTime.Now;
            IBusinessObject bo = GetBOWithPropValueSet(prop1, prop1Value, prop2, prop2Value);

            return(bo);
        }
Example #26
0
        public void TestContainsPropDef()
        {
            Assert.IsTrue(mKeyDef.Contains("PropName"));
            IPropDef lPropDef = mKeyDef["PropName"];

            Assert.AreEqual("PropName", lPropDef.PropertyName);
            Assert.IsTrue(mKeyDef.IgnoreIfNull);
        }
Example #27
0
        public virtual void TestPropertyWithPropRule()
        {
            IPropDef def =
                _loader.LoadProperty(
                    @"<property  name=""TestProp""><rule name=""StringRule""><add key=""minLength"" value=""8""/><add key=""maxLength"" value=""8"" /></rule></property>");

            Assert.AreEqual(1, def.PropRules.Count);
        }
Example #28
0
        private static IBusinessObject GetBOWithPropValueSet(IPropDef prop1, DateTime?prop1Value, IPropDef prop2, DateTime?prop2Value)
        {
            IBusinessObject bo = MockRepository.GenerateMock <IBusinessObject>();

            bo.Stub(busObj => busObj.GetPropertyValue(prop1.PropertyName)).Return(prop1Value);
            bo.Stub(busObj => busObj.GetPropertyValue(prop2.PropertyName)).Return(prop2Value);
            return(bo);
        }
Example #29
0
        public virtual void TestPropertyWithDateTimeDefaultValueNow()
        {
            IPropDef def = _loader.LoadProperty(
                @"<property  name=""TestProp"" type=""DateTime"" default=""Now"" />");

            Assert.AreEqual("Now", def.DefaultValue,
                            "Default value should be same as that specified in xml");
        }
 public ValidValueGeneratorIncrementalInt(IPropDef propDef) : base(propDef)
 {
    if(!_latestValue.ContainsKey(propDef))
    {
        _latestValue.Add(propDef, 0);
    }
     _latestValue.TryGetValue(propDef, out _nextValue);
 }
 ///<summary>
 ///</summary>
 ///<param name="propDef"></param>
 ///<exception cref="ArgumentNullException"></exception>
 public PropDefTester(IPropDef propDef)
 {
     if (propDef == null)
     {
         throw new ArgumentNullException("propDef");
     }
     PropDef = propDef;
 }
Example #32
0
 ///<summary>
 ///</summary>
 ///<param name="propLeft"></param>
 ///<param name="comparisonOperator"></param>
 ///<param name="propRight"></param>
 ///<exception cref="ArgumentNullException"></exception>
 public InterPropRule(IPropDef propLeft, ComparisonOperator comparisonOperator, IPropDef propRight)
 {
     if (propLeft == null) throw new ArgumentNullException("propLeft");
     if (propRight == null) throw new ArgumentNullException("propRight");
     LeftProp = propLeft;
     ComparisonOp = comparisonOperator;
     RightProp = propRight;
 }
        private static FilterClauseOperator GetFilterClauseOperator(IPropDef propDef)
        {
            if (propDef.HasLookupList()) return FilterClauseOperator.OpEquals;
            if (propDef.PropertyType.Name == "Boolean" || propDef.PropertyType.Name == "DateTime") 
                return FilterClauseOperator.OpEquals;

            return FilterClauseOperator.OpLike;
        }
 public ValidValueGeneratorIncrementalInt(IPropDef propDef) : base(propDef)
 {
     if (!_latestValue.ContainsKey(propDef))
     {
         _latestValue.Add(propDef, 0);
     }
     _latestValue.TryGetValue(propDef, out _nextValue);
 }
 private static void CheckPropertyTypeIsString(IPropDef propDef)
 {
     if (propDef.PropertyType != typeof(string))
     {
         throw new HabaneroArgumentException(
                   "You cannot use a ValidValueGeneratorName for generating values for a property that is not a string. For Prop : '" +
                   propDef.ClassName + "_" + propDef.PropertyName + "'");
     }
 }
Example #36
0
 /// <summary>
 /// Adds a property definition to this key
 /// </summary>
 /// <param name="propDef">The property definition to add</param>
 /// <exception cref="InvalidPropertyException">Thrown if the primary key definition is marked as and object id but more than one 
 /// property definition is being added</exception>
 public override void Add(IPropDef propDef)
 {
     if (Count > 0 && _isGuidObjectID)
     {
         throw new InvalidPropertyException("You cannot have more than one " +
             "property for a primary key that represents an object's Guid ID");
     }
     base.Add(propDef);
 }
 private int GetNextNameReference(IPropDef propDef)
 {
     if(!_nextNameDictionaryRef.ContainsKey(propDef)) _nextNameDictionaryRef.Add(propDef, 0);
     var nextNameReference = _nextNameDictionaryRef[propDef];
     nextNameReference++;
     if (nextNameReference >= NameList.Count) nextNameReference = 0;
     _nextNameDictionaryRef[propDef] = nextNameReference;
     return nextNameReference;
 }
 private static void CheckPropertyTypeIsString(IPropDef propDef)
 {
     if (propDef.PropertyType != typeof (string))
     {
         throw new HabaneroArgumentException(
             "You cannot use a ValidValueGeneratorName for generating values for a property that is not a string. For Prop : '" +
             propDef.ClassName + "_" + propDef.PropertyName + "'");
     }
 }
        public ValidValueGeneratorName(IPropDef propDef, IList<string> names)
            : base(propDef)
        {
            if (names == null) throw new ArgumentNullException("names");
            _propDef = propDef;
            CheckPropertyTypeIsString(propDef);

            NameList = names;
        }
        public IUIGridColumn GetUIGridColumn(IPropDef propDef)
        {
            if (propDef == null) throw new ArgumentNullException("propDef");
            UIControlType controlType = GetControlType(propDef);
            var gridColumn = _factory.CreateUIGridProperty(propDef.DisplayName, propDef.PropertyName, controlType.TypeName, controlType.AssemblyName,true, 100, PropAlignment.left, new Hashtable());
            //SetControlType(propDef, gridColumn);

            return gridColumn;
        }
Example #41
0
 private static void CheckPropDefHasLookupList(IPropDef propDef)
 {
     if (!propDef.HasLookupList())
     {
         throw new HabaneroDeveloperException
             ("There is a problem with the configuration of this application",
              string.Format
                  ("The application tried to configure a BOPropLookupList - with the propDef {0} that does not have a lookup list defined",
                   propDef.PropertyName));
     }
 }
 public IFilterPropertyDef CreateUIFilterProperty(IPropDef propDef)
 {
     if (propDef==null) throw new ArgumentNullException("propDef");
     UIControlType uiControlType = GetControlType(propDef);
     var filterClauseOperator = GetFilterClauseOperator(propDef);
     IFilterPropertyDef filterPropertyDef = _factory.CreateFilterPropertyDef(propDef.PropertyName,
                                                                             propDef.DisplayName,
                                                                             uiControlType.TypeName,
                                                                             uiControlType.AssemblyName,
                                                                             filterClauseOperator,
                                                                             new Dictionary<string, string>());
     return filterPropertyDef;
 }
        public IUIFormField GetUIFormField(IPropDef propDef)
        {
            if (propDef == null) throw new ArgumentNullException("propDef");

            var uiControlType = GetControlType(propDef);

            var uiFormField = _factory.CreateUIFormProperty(propDef.DisplayName, propDef.PropertyName,
                                                            uiControlType.TypeName, uiControlType.AssemblyName, "", "",
                                                            true, false, "", new Hashtable(), LayoutStyle.Label);


            //var uiFormField = new UIFormField(propDef.DisplayName, propDef.PropertyName);
            
            //SetControlType(propDef, uiFormField);
            return uiFormField;
        }
        private static void createPropertyDMXml(XmlElement classDMElement, IPropDef propDef)
        {
            XmlElement propDMElement = XmlUtilities.createXmlElement(classDMElement, "property");
            XmlUtilities.setXmlAttribute(propDMElement, "name", propDef.PropertyName);
            XmlUtilities.setXmlAttribute(propDMElement, "type", propDef.PropertyTypeName, "String");
            XmlUtilities.setXmlAttribute(propDMElement, "assembly", propDef.PropertyTypeAssemblyName == "CommonLanguageRuntimeLibrary" ? "System" : propDef.PropertyTypeAssemblyName, "System");
            XmlUtilities.setXmlAttribute(propDMElement, "readWriteRule", propDef.ReadWriteRule, PropReadWriteRule.ReadWrite);
            XmlUtilities.setXmlAttribute(propDMElement, "databaseField", propDef.DatabaseFieldName, propDef.PropertyName);
            XmlUtilities.setXmlAttribute(propDMElement, "default", propDef.DefaultValue);
            XmlUtilities.setXmlAttribute(propDMElement, "compulsory", propDef.Compulsory, false);
            XmlUtilities.setXmlAttribute(propDMElement, "autoIncrementing", propDef.AutoIncrementing, false);
            XmlUtilities.setXmlAttribute(propDMElement, "displayName", propDef.DisplayName, propDef.PropertyName);
            XmlUtilities.setXmlAttribute(propDMElement, "description", propDef.Description);
            XmlUtilities.setXmlAttribute(propDMElement, "keepValuePrivate", propDef.KeepValuePrivate, false);

            createPropRulesXml(propDMElement, propDef);
            createLookupListXml(propDMElement, propDef);
        }
        private static UIControlType GetControlType(IPropDef propDef)
        {
            UIControlType type;
            if (propDef.HasLookupList()) return GetComboBoxControlType();
            switch (propDef.PropertyType.Name)
            {
                case "String":
                    type = GetTextBoxControlType();
                    break;
                case "Boolean":
                    type = GetCheckBoxControlType();
                    break;
                case "DateTime":
                    type = GetDateTimeControlType();
                    break;
                default:
                    type = GetTextBoxControlType();
                    break;
            }

            return type;
        }
 public ValidValueGeneratorDouble(IPropDef propDef) : base(propDef)
 {
 }
 /// <summary>
 /// Constructor to initialise the exception with a specific message
 /// to display
 /// </summary>
 /// <param name="propDef">The property definition for the property that had the ReadWriteRule which threw the error.</param>
 /// <param name="message">The error message</param>
 public BOPropWriteException(IPropDef propDef, string message) : base(message)
 {
     _propDef = propDef;
 }
 /// <summary>
 /// Constructor to initialise the exception with a specific message
 /// to display, and the inner exception specified
 /// </summary>
 /// <param name="propDef">The property definition for the property that had the ReadWriteRule which threw the error.</param>
 /// <param name="message">The error message</param>
 /// <param name="inner">The inner exception</param>
 public BOPropWriteException(PropDef propDef, string message, Exception inner) : base(message, inner)
 {
     _propDef = propDef;
 }
 private static ValidValueGeneratorTextFile CreateValueGenerator(string fileName, IPropDef propDef = null)
 {
     if (propDef == null)
     {
         propDef = new PropDefFake
                       {
                           PropertyType = typeof (string)
                       };
     }
     return new ValidValueGeneratorTextFile(propDef, fileName);
 }
 public ValidValueGeneratorTextFileSpy(IPropDef propDef, string fileName)
     : base(propDef, fileName)
 {
 }
 private void SetDatabaseFieldName(IPropDef propDef, string relationshipName)
 {
     var propertyWrapper = this.ClassDef.ClassType.GetProperty(relationshipName).ToPropertyWrapper();
     if (!propertyWrapper.HasAttribute<AutoMapFieldNameAttribute>()) return;
     var autoMapFieldNameAttribute = propertyWrapper.GetAttribute<AutoMapFieldNameAttribute>();
     propDef.DatabaseFieldName = autoMapFieldNameAttribute.FieldName;
 }
Example #52
0
 /// <summary>
 /// Constructor to initialise a new property
 /// </summary>
 /// <param name="propDef">The property definition</param>
 public BOProp(IPropDef propDef)
 {
     if (propDef == null) throw new ArgumentNullException("propDef");
     _propDef =  propDef;
     UpdatesBusinessObjectStatus = true;
 }
Example #53
0
 public RelPropDefFake(IPropDef propDef) : base(propDef, "relprop")
 {}
Example #54
0
 /// <summary>
 /// Constructor to initialise a new property
 /// </summary>
 /// <param name="propDef">The property definition</param>
 public BOPropLookupList(IPropDef propDef) : base(propDef)
 {
     CheckPropDefHasLookupList(propDef);
 }
Example #55
0
 /// <summary>
 /// Constructor to initialise a new property
 /// </summary>
 /// <param name="propDef">The property definition</param>
 /// <param name="propValue">the default value for this property</param>
 internal BOPropLookupList(IPropDef propDef, object propValue) : base(propDef, propValue)
 {
     Loading = true;
     CheckPropDefHasLookupList(propDef);
     Loading = false;
 }
Example #56
0
 /// <summary>
 /// Constructor to initialise a new property with a specific value
 /// </summary>
 /// <param name="propDef">The property definition</param>
 /// <param name="propValue">The initial value</param>
 public BOProp(IPropDef propDef, object propValue)
     : this(propDef)
 {
     if (propDef == null) throw new ArgumentNullException("propDef");
     InitialiseProp(propValue, true);
 }
 /// <summary>
 /// Construct
 /// </summary>
 /// <param name="propDef"></param>
 public ValidValueGeneratorShort(IPropDef propDef) : base(propDef)
 {
 }
        /// <summary>
        /// Loads the lookup list data into the specified property definition
        /// </summary>
        /// <param name="sourceElement">The source element</param>
        /// <param name="def">The property definition to load into</param>
        /// <param name="dtdLoader">The dtd loader</param>
		/// <param name="defClassFactory">The factory for the definition classes</param>
        public static void LoadLookupListIntoProperty(string sourceElement, IPropDef def, DtdLoader dtdLoader, IDefClassFactory defClassFactory)
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(sourceElement);
            if (doc.DocumentElement == null)
            {
                throw new HabaneroDeveloperException
                    ("There was a problem loading the class definitions pleaser refer to the system administrator",
                     "The load lookup list property could not be loaded since the source element does not contain a document name");
            }
            string loaderClassName = "Xml" + doc.DocumentElement.Name + "Loader";
            Type loaderType = Type.GetType
                (typeof (XmlLookupListLoader).Namespace + "." + loaderClassName, true, true);
            XmlLookupListLoader loader =
                (XmlLookupListLoader)
                Activator.CreateInstance(loaderType, new object[] {dtdLoader, defClassFactory});
            def.LookupList = loader.LoadLookupList(doc.DocumentElement);
        }
Example #59
0
 private static IBusinessObject GetBOWithPropValueSet(IPropDef prop1, DateTime? prop1Value, IPropDef prop2, DateTime? prop2Value)
 {
     IBusinessObject bo = MockRepository.GenerateMock<IBusinessObject>();
     bo.Stub(busObj => busObj.GetPropertyValue(prop1.PropertyName)).Return(prop1Value);
     bo.Stub(busObj => busObj.GetPropertyValue(prop2.PropertyName)).Return(prop2Value);
     return bo;
 }
Example #60
0
 private static IBusinessObject GetBOWithProp1LTProp2(IPropDef prop1, IPropDef prop2, out DateTime prop1Value, out DateTime prop2Value)
 {
     prop1Value = DateTime.Now.AddDays(-1);
     prop2Value = DateTime.Now;
     IBusinessObject bo = GetBOWithPropValueSet(prop1, prop1Value, prop2, prop2Value);
     return bo;
 }