beagle r4456 - trunk/beagle/Util



Author: dbera
Date: Sun Feb  3 18:44:28 2008
New Revision: 4456
URL: http://svn.gnome.org/viewvc/beagle?rev=4456&view=rev

Log:
Fix PathFinder to deal with the data files from conf-data and BEAGLE_CONF_DATA env variable.
No need for PropertyKeyword attribute since Filters and Backends wont have the mapping specified in their attributes any more. Instead, rename it to QueryKeywordMapping and change it suitably to store the mapping information.

Added:
   trunk/beagle/Util/QueryKeywordMapping.cs
      - copied, changed from r4452, /trunk/beagle/Util/PropertyKeywordAttribute.cs
Removed:
   trunk/beagle/Util/PropertyKeywordAttribute.cs
Modified:
   trunk/beagle/Util/Config.cs
   trunk/beagle/Util/Makefile.am
   trunk/beagle/Util/PathFinder.cs

Modified: trunk/beagle/Util/Config.cs
==============================================================================
--- trunk/beagle/Util/Config.cs	(original)
+++ trunk/beagle/Util/Config.cs	Sun Feb  3 18:44:28 2008
@@ -157,6 +157,7 @@
 				Directory.CreateDirectory (configs_dir);
 				return;
 			}
+
 			// Else check the directory for old config files
 			CheckOldConfig ();
 		}
@@ -278,6 +279,10 @@
 			get { return Get (Conf.Names.NetworkingConfig); }
 		}
 
+		private static string GlobalConfigDir {
+			get { return Path.Combine (PathFinder.ConfigDataDir, "config-files"); }
+		}
+
 		// Utility method to check if global config files exist for the main config types
 		public static bool CheckGlobalConfig ()
 		{
@@ -286,7 +291,7 @@
 								Names.DaemonConfig,
 								Names.NetworkingConfig}) {
 				string filename = (name + ".xml");
-				string global_file = Path.Combine (PathFinder.GlobalConfigDir, filename);
+				string global_file = Path.Combine (GlobalConfigDir, filename);
 				if (! File.Exists (global_file))
 					return false;
 			}
@@ -302,7 +307,7 @@
 		{
 			string filename = (name + ".xml");
 
-			string global_file = Path.Combine (PathFinder.GlobalConfigDir, filename);
+			string global_file = Path.Combine (GlobalConfigDir, filename);
 			string local_file = Path.Combine (configs_dir, filename);
 
 			Config merge_from = LoadFrom (local_file);
@@ -477,19 +482,19 @@
 			Log.Info ("Old config files found. Moving them to the new format...");
 
 			// Load the global config files
-			Config global_fsq_config = LoadFrom (Path.Combine (PathFinder.GlobalConfigDir, Names.FilesQueryableConfig + ".xml"));
+			Config global_fsq_config = LoadFrom (Path.Combine (GlobalConfigDir, Names.FilesQueryableConfig + ".xml"));
 			foreach (Option option in global_fsq_config.Options.Values)
 				option.Global = true;
 
-			Config global_networking_config = LoadFrom (Path.Combine (PathFinder.GlobalConfigDir, Names.NetworkingConfig + ".xml"));
+			Config global_networking_config = LoadFrom (Path.Combine (GlobalConfigDir, Names.NetworkingConfig + ".xml"));
 			foreach (Option option in global_networking_config.Options.Values)
 				option.Global = true;
 
-			Config global_bs_config = LoadFrom (Path.Combine (PathFinder.GlobalConfigDir, Names.BeagleSearchConfig + ".xml"));
+			Config global_bs_config = LoadFrom (Path.Combine (GlobalConfigDir, Names.BeagleSearchConfig + ".xml"));
 			foreach (Option option in global_bs_config.Options.Values)
 				option.Global = true;
 
-			Config global_daemon_config = LoadFrom (Path.Combine (PathFinder.GlobalConfigDir, Names.DaemonConfig + ".xml"));
+			Config global_daemon_config = LoadFrom (Path.Combine (GlobalConfigDir, Names.DaemonConfig + ".xml"));
 			foreach (Option option in global_daemon_config.Options.Values)
 				option.Global = true;
 

Modified: trunk/beagle/Util/Makefile.am
==============================================================================
--- trunk/beagle/Util/Makefile.am	(original)
+++ trunk/beagle/Util/Makefile.am	Sun Feb  3 18:44:28 2008
@@ -145,7 +145,7 @@
 	$(srcdir)/SemWeb/Algos.cs               \
 	$(srcdir)/SemWeb/Remote.cs              \
 	$(srcdir)/SemWeb/XPathSemWebNavigator.cs\
-	$(srcdir)/PropertyKeywordAttribute.cs
+	$(srcdir)/QueryKeywordMapping.cs
 
 UTIL_ASSEMBLIES =				\
 	$(BEAGLED_LIBS)				\

Modified: trunk/beagle/Util/PathFinder.cs
==============================================================================
--- trunk/beagle/Util/PathFinder.cs	(original)
+++ trunk/beagle/Util/PathFinder.cs	Sun Feb  3 18:44:28 2008
@@ -208,25 +208,24 @@
 		}
 
 		// Location of the global config files.
-		// Once installted, it is Sysconfdir/beagle/config-files.
+		// Once installted, it is Sysconfdir/beagle
 		// Otherwise it is $BEAGLE_CONF_DIR
-		static string global_config_dir = null;
-		static public string GlobalConfigDir {
+		static string config_data_dir = null;
+		static public string ConfigDataDir {
 			get {
-				if (global_config_dir == null) {
-					global_config_dir = Environment.GetEnvironmentVariable ("BEAGLE_CONF_DIR");
-					if (global_config_dir == null)
-						global_config_dir = Path.Combine (
-							Path.Combine (ExternalStringsHack.SysConfDir, "beagle"),
-							"config-files");
-					if (global_config_dir.EndsWith ("/"))
-						global_config_dir = global_config_dir.Remove (global_config_dir.Length - 1, 1);
-					global_config_dir = Path.GetFullPath (global_config_dir);
-					if (! Directory.Exists (global_config_dir))
-						throw new Exception ("Global config directory '"+global_config_dir+"' doesn't exist");
+				if (config_data_dir == null) {
+					config_data_dir = Environment.GetEnvironmentVariable ("BEAGLE_CONF_DIR");
+					if (config_data_dir == null)
+						config_data_dir = Path.Combine (ExternalStringsHack.SysConfDir, "beagle");
+
+					if (config_data_dir.EndsWith ("/"))
+						config_data_dir = config_data_dir.Remove (config_data_dir.Length - 1, 1);
+					config_data_dir = Path.GetFullPath (config_data_dir);
+					if (! Directory.Exists (config_data_dir))
+						throw new Exception ("Global config directory '"+config_data_dir+"' doesn't exist");
 				}
 
-				return global_config_dir;
+				return config_data_dir;
 			}
 		}
 	}

Copied: trunk/beagle/Util/QueryKeywordMapping.cs (from r4452, /trunk/beagle/Util/PropertyKeywordAttribute.cs)
==============================================================================
--- /trunk/beagle/Util/PropertyKeywordAttribute.cs	(original)
+++ trunk/beagle/Util/QueryKeywordMapping.cs	Sun Feb  3 18:44:28 2008
@@ -1,7 +1,7 @@
 //
-// PropertyKeywordAttribute.cs
+// QueryKeywordMapping.cs
 //
-// Copyright (C) 2006 Debajyoti Bera
+// Copyright (C) 2006,2007 Debajyoti Bera
 //
 
 //
@@ -25,32 +25,42 @@
 //
 
 using System;
+using System.Xml.Serialization;
 
 namespace Beagle.Util {
 
-	[AttributeUsage (AttributeTargets.Class, AllowMultiple=true)]
-	public class PropertyKeywordMapping : Attribute {
+	// FIXME handle i18n issues... user might use an i18n-ised string
+	public class QueryKeywordMapping {
 		private string keyword, propertyname, description = null;
 		private bool is_keyword = false;
 
+		[XmlAttribute ("QueryKeyword")]
 		public string Keyword {
 			get { return keyword; }
 			set { keyword = value; }
 		}
 
+		[XmlAttribute ("BeagleProperty")]
 		public string PropertyName {
 			get { return propertyname; }
 			set { propertyname = value; }
 		}
 
+		[XmlText]
 		public string Description {
 			get { return description; }
 			set { description = value; }
 		}
 
+		[XmlAttribute ("Tokenize")]
+		public bool Tokenize {
+			get { return ! is_keyword; }
+			set { is_keyword = ! value; }
+		}
+
+		[XmlIgnore]
 		public bool IsKeyword {
 			get { return is_keyword; }
-			set { is_keyword = value; }
 		}
 	}
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]