You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by ro...@apache.org on 2005/06/04 05:58:14 UTC

svn commit: r179932 - in /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper: ./ Configuration/ Configuration/Cache/ Scope/ Test/bin/Debug/

Author: roberto
Date: Fri Jun  3 20:58:12 2005
New Revision: 179932

URL: http://svn.apache.org/viewcvs?rev=179932&view=rev
Log:
+Adding new C# DataMapper validateSqlMapConfig <setting> 
(alternative would be to pass in an additional parameter bool to the Configure() methods since this new setting requires that the config document is parsed before being validated)
~Updated CacheModel AddProperty() method name

Modified:
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Cache/CacheModel.cs
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapConfig.xsd

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config?rev=179932&r1=179931&r2=179932&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config Fri Jun  3 20:58:12 2005
@@ -10,6 +10,7 @@
 		<setting useStatementNamespaces="${useStatementNamespaces}"/>
 		<setting cacheModelsEnabled="true"/>
 		<setting validateSqlMap="false"/>
+		<setting validateSqlMapConfig="true"/>
 	</settings>
 	
 	<!-- Optional if resource -->

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Cache/CacheModel.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Cache/CacheModel.cs?rev=179932&r1=179931&r2=179932&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Cache/CacheModel.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Cache/CacheModel.cs Fri Jun  3 20:58:12 2005
@@ -301,11 +301,11 @@
 
 
 		/// <summary>
-		/// Add a propertie
+		/// Add a property
 		/// </summary>
-		/// <param name="name">The name of the propertie</param>
-		/// <param name="value">The value of the propertie</param>
-		public void AddPropertie(string name, string value)
+		/// <param name="name">The name of the property</param>
+		/// <param name="value">The value of the property</param>
+		public void AddProperty(string name, string value)
 		{
 			_properties.Add(name, value);
 		}

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs?rev=179932&r1=179931&r2=179932&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs Fri Jun  3 20:58:12 2005
@@ -130,6 +130,10 @@
 		/// </summary>
 		private const string ATR_VALIDATE_SQLMAP = "validateSqlMap";
 		/// <summary>
+		/// Token for validateSqlMapConfig attribute.
+		/// </summary>
+		private const string ATR_VALIDATE_SQLMAP_CONFIG = "validateSqlMapConfig";
+		/// <summary>
 		/// Token for embedStatementParams attribute.
 		/// </summary>
 		private const string ATR_EMBED_STATEMENT_PARAMS = "useEmbedStatementParams";
@@ -353,7 +357,12 @@
 			
 			try
 			{
-				ValidateSchema( document.ChildNodes[1], "SqlMapConfig.xsd" );
+				ParseValidateSqlMapConfigSetting();
+
+				if (_configScope.ValidateSqlMapConfig) 
+				{
+					ValidateSchema( document.ChildNodes[1], "SqlMapConfig.xsd" );
+				}
 				Initialize();
 				return _configScope.SqlMapper;
 			}
@@ -363,6 +372,25 @@
 			}
 		}
 
+		private void ParseValidateSqlMapConfigSetting()
+		{
+			_configScope.ErrorContext.Activity = "Checking if configuration document should be validated";
+	
+			XmlNodeList settings = _configScope.SqlMapConfigDocument.SelectNodes(XML_CONFIG_SETTINGS);
+	
+			if (settings!=null)
+			{
+				foreach (XmlNode setting in settings)
+				{
+					if (setting.Attributes[ATR_VALIDATE_SQLMAP_CONFIG] != null )
+					{	
+						string value = setting.Attributes[ATR_VALIDATE_SQLMAP_CONFIG].Value;
+						_configScope.ValidateSqlMapConfig =  Convert.ToBoolean( value ); 
+					}
+				}
+			}
+		}
+
 
 		/// <summary>
 		/// validate againts schema
@@ -1147,7 +1175,7 @@
 						string name = propertie.Attributes["name"].Value;
 						string value = propertie.Attributes["value"].Value;
 					
-						cacheModel.AddPropertie(name, value);
+						cacheModel.AddProperty(name, value);
 					}
 
 					cacheModel.Initialize();

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs?rev=179932&r1=179931&r2=179932&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs Fri Jun  3 20:58:12 2005
@@ -60,6 +60,7 @@
 		private bool _isCacheModelsEnabled = false;
 		private bool _useEmbedStatementParams = false;
 		private bool _validateSqlMap = false;
+		private bool _validateSqlMapConfig = true;
 		private bool _isCallFromDao = false;
 
 		private SqlMapper _sqlMapper = null;
@@ -84,6 +85,15 @@
 
 		#region Properties
 
+		/// <summary>
+		/// Indicates whether or not to validate the configuration document
+		/// </summary>
+		public bool ValidateSqlMapConfig
+		{
+			set { _validateSqlMapConfig = value; }
+			get { return _validateSqlMapConfig; }
+		}
+		
 		/// <summary>
 		/// Set if theparser should validate the sqlMap documents
 		/// </summary>

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapConfig.xsd
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapConfig.xsd?rev=179932&r1=179931&r2=179932&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapConfig.xsd (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapConfig.xsd Fri Jun  3 20:58:12 2005
@@ -57,6 +57,7 @@
 			<xs:attribute name="useStatementNamespaces" type="xs:string"/>
 			<xs:attribute name="cacheModelsEnabled" type="xs:string"/>
 			<xs:attribute name="validateSqlMap" default="false" type="xs:string"/>
+			<xs:attribute name="validateSqlMapConfig" default="true" type="xs:string"/>
 			<xs:attribute name="useEmbedStatementParams" type="xs:string" default="false"/>
 		</xs:complexType>
 	</xs:element>