beagle r4452 - in trunk/beagle: BeagleClient Filters Util beagled tools
- From: kkubasik svn gnome org
- To: svn-commits-list gnome org
- Subject: beagle r4452 - in trunk/beagle: BeagleClient Filters Util beagled tools
- Date: Sun, 3 Feb 2008 09:59:02 +0000 (GMT)
Author: kkubasik
Date: Sun Feb 3 09:59:02 2008
New Revision: 4452
URL: http://svn.gnome.org/viewvc/beagle?rev=4452&view=rev
Log:
cleaning up the extraction of keyword mapping. Easier to read file format and more configurable
Added:
trunk/beagle/Filters/keyword-mapping.xml
Modified:
trunk/beagle/BeagleClient/Property.cs
trunk/beagle/Filters/Makefile.am
trunk/beagle/Util/Config.cs
trunk/beagle/beagled/PropertyKeywordFu.cs
trunk/beagle/beagled/QueryDriver.cs
trunk/beagle/tools/Query.cs
Modified: trunk/beagle/BeagleClient/Property.cs
==============================================================================
--- trunk/beagle/BeagleClient/Property.cs (original)
+++ trunk/beagle/BeagleClient/Property.cs Sun Feb 3 09:59:02 2008
@@ -34,6 +34,7 @@
namespace Beagle {
+
public enum PropertyType {
Text = 1,
Keyword = 2,
Modified: trunk/beagle/Filters/Makefile.am
==============================================================================
--- trunk/beagle/Filters/Makefile.am (original)
+++ trunk/beagle/Filters/Makefile.am Sun Feb 3 09:59:02 2008
@@ -170,7 +170,8 @@
$(srcdir)/FilterChm.cs
confdir = $(sysconfdir)/beagle
-conf_DATA = external-filters.xml.sample
+conf_DATA = external-filters.xml.sample \
+ keyword-mapping.xml
EXTRA_DIST = \
$(CSFILES) \
Added: trunk/beagle/Filters/keyword-mapping.xml
==============================================================================
--- (empty file)
+++ trunk/beagle/Filters/keyword-mapping.xml Sun Feb 3 09:59:02 2008
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<KeywordMappingStore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <PropertyInfo>
+ <Properties Keyword="artist" PropertyName="fixme:artist" PropType="Text">Artist of the music</Properties>
+ <Properties Keyword="mailto" PropertyName="parent:fixme:to_name" PropType="Text" />
+ <Properties Keyword="mailto" PropertyName="fixme:to_name" PropType="Text">Name of receipient</Properties>
+ <Properties Keyword="author" PropertyName="dc:author" PropType="Text">Author of the content</Properties>
+ <Properties Keyword="summary" PropertyName="dc:subject" PropType="Text">Brief description of the content</Properties>
+ <Properties Keyword="imagemodel" PropertyName="exif:Model" PropType="Text">Camera model as specified in exif or IPTC tags</Properties>
+ <Properties Keyword="imagecomment" PropertyName="iptc:caption" PropType="Text">IPTC caption</Properties>
+ <Properties Keyword="imagecomment" PropertyName="exif:UserComment" PropType="Text">Exif comments</Properties>
+ <Properties Keyword="imagecomment" PropertyName="jfif:Comment" PropType="Text">JFIF comments</Properties>
+ <Properties Keyword="imagecomment" PropertyName="digikam:caption" PropType="Text">Digikam User comments</Properties>
+ <Properties Keyword="imagecomment" PropertyName="fspot:Description" PropType="Text">F-Spot User comments</Properties>
+ <Properties Keyword="speakingto" PropertyName="fixme:speakingto" PropType="Keyword">Person engaged in conversation</Properties>
+ <Properties Keyword="speakingto" PropertyName="fixme:speakingto" PropType="Keyword">Person engaged in conversation</Properties>
+ <Properties Keyword="speakingto" PropertyName="fixme:speakingto" PropType="Keyword">Person engaged in conversation</Properties>
+ <Properties Keyword="mailtoaddr" PropertyName="parent:fixme:to_address" PropType="Text" />
+ <Properties Keyword="mailtoaddr" PropertyName="fixme:to_address" PropType="Text">Email address of receipient</Properties>
+ <Properties Keyword="inattachment" PropertyName="parent:fixme:hasAttachments" PropType="Keyword">Use 'inattachment:true' for email attachments.</Properties>
+ <Properties Keyword="imagetag" PropertyName="image:tag" PropType="Text">FSpot, Digikam image tags</Properties>
+ <Properties Keyword="source" PropertyName="beagle:Source" PropType="Keyword">Name of the backend</Properties>
+ <Properties Keyword="creator" PropertyName="dc:creator" PropType="Text">Creator of the content</Properties>
+ <Properties Keyword="emblem" PropertyName="nautilus:emblem" PropType="Keyword">Use emblem to identify items tagged with a specific emblem in nautilus.</Properties>
+ <Properties Keyword="mailinglist" PropertyName="parent:fixme:mlist" PropType="Text" />
+ <Properties Keyword="mailinglist" PropertyName="fixme:mlist" PropType="Text">Mailing list id e.g. dashboard-hackers.gnome.org</Properties>
+ <Properties Keyword="mailfrom" PropertyName="parent:fixme:from_name" PropType="Text" />
+ <Properties Keyword="mailfrom" PropertyName="fixme:from_name" PropType="Text">Name of email sender</Properties>
+ <Properties Keyword="genre" PropertyName="fixme:genre" PropType="Keyword">Genre of the music</Properties>
+ <Properties Keyword="ext" PropertyName="beagle:FilenameExtension" PropType="Keyword">File extension, e.g. ext:jpeg. Use ext: to search in files with no extension.</Properties>
+ <Properties Keyword="ext" PropertyName="beagle:FilenameExtension" PropType="Keyword">File extension, e.g. ext:jpeg. Use ext: to search in files with no extension.</Properties>
+ <Properties Keyword="filetype" PropertyName="beagle:FileType" PropType="Keyword">Type of content for HitType File</Properties>
+ <Properties Keyword="email" PropertyName="vCard:EMAIL" PropType="Text">Email in KAddressbook</Properties>
+ <Properties Keyword="host" PropertyName="fixme:host" PropType="Text">The host of this entitiy.</Properties>
+ <Properties Keyword="mimetype" PropertyName="beagle:MimeType" PropType="Keyword">Mimetype of the content</Properties>
+ <Properties Keyword="notetag" PropertyName="note:tag" PropType="Text">Tag associated with a tomboy note.</Properties>
+ <Properties Keyword="type" PropertyName="beagle:HitType" PropType="Keyword">Hittype of the content e.g. File, IMLog, MailMessage</Properties>
+ <Properties Keyword="title" PropertyName="dc:title" PropType="Text">Title</Properties>
+ <Properties Keyword="mailfromaddr" PropertyName="parent:fixme:from_address" PropType="Text" />
+ <Properties Keyword="mailfromaddr" PropertyName="fixme:from_address" PropType="Text">Email address of sender</Properties>
+ <Properties Keyword="pkggroup" PropertyName="pkg:group" PropType="Text">Group to which the package belongs e.g. System/Configuration/Packaging</Properties>
+ <Properties Keyword="inarchive" PropertyName="fixme:inside_archive" PropType="Keyword">Use 'inarchive:true' for files inside an archive.</Properties>
+ <Properties Keyword="album" PropertyName="fixme:album" PropType="Text">Album name of the music</Properties>
+ </PropertyInfo>
+</KeywordMappingStore>
\ No newline at end of file
Modified: trunk/beagle/Util/Config.cs
==============================================================================
--- trunk/beagle/Util/Config.cs (original)
+++ trunk/beagle/Util/Config.cs Sun Feb 3 09:59:02 2008
@@ -81,228 +81,7 @@
public static class Names {
internal const int NumConfig = 4;
- public const string DefaultMappings = @"ï<DocumentElement>
- <KeywordMappings>
- <Keyword>inarchive</Keyword>
- <PropertyName>fixme:inside_archive</PropertyName>
- <IsKeyword>true</IsKeyword>
- <Description>Use 'inarchive:true' for files inside an archive.</Description>
- <Type>2</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>genre</Keyword>
- <PropertyName>fixme:genre</PropertyName>
- <IsKeyword>true</IsKeyword>
- <Description>Genre of the music</Description>
- <Type>2</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>artist</Keyword>
- <PropertyName>fixme:artist</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Description>Artist of the music</Description>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>album</Keyword>
- <PropertyName>fixme:album</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Description>Album name of the music</Description>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>pkggroup</Keyword>
- <PropertyName>pkg:group</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Description>Group to which the package belongs e.g. System/Configuration/Packaging</Description>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>speakingto</Keyword>
- <PropertyName>fixme:speakingto</PropertyName>
- <IsKeyword>true</IsKeyword>
- <Description>Person engaged in conversation</Description>
- <Type>2</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>imagecomment</Keyword>
- <PropertyName>iptc:caption</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Description>IPTC caption</Description>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>imagecomment</Keyword>
- <PropertyName>exif:UserComment</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Description>Exif comments</Description>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>imagecomment</Keyword>
- <PropertyName>jfif:Comment</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Description>JFIF comments</Description>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>imagecomment</Keyword>
- <PropertyName>digikam:caption</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Description>Digikam User comments</Description>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>imagecomment</Keyword>
- <PropertyName>fspot:Description</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Description>F-Spot User comments</Description>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>imagetag</Keyword>
- <PropertyName>image:tag</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Description>FSpot, Digikam image tags</Description>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>imagemodel</Keyword>
- <PropertyName>exif:Model</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Description>Camera model as specified in exif or IPTC tags</Description>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>email</Keyword>
- <PropertyName>vCard:EMAIL</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Description>Email in KAddressbook</Description>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>speakingto</Keyword>
- <PropertyName>fixme:speakingto</PropertyName>
- <IsKeyword>true</IsKeyword>
- <Description>Person engaged in conversation</Description>
- <Type>2</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>inattachment</Keyword>
- <PropertyName>parent:fixme:hasAttachments</PropertyName>
- <IsKeyword>true</IsKeyword>
- <Description>Use 'inattachment:true' for email attachments.</Description>
- <Type>2</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>mailinglist</Keyword>
- <PropertyName>parent:fixme:mlist</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>mailinglist</Keyword>
- <PropertyName>fixme:mlist</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Description>Mailing list id e.g. dashboard-hackers.gnome.org</Description>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>mailtoaddr</Keyword>
- <PropertyName>parent:fixme:to_address</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>mailtoaddr</Keyword>
- <PropertyName>fixme:to_address</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Description>Email address of receipient</Description>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>mailto</Keyword>
- <PropertyName>parent:fixme:to_name</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>mailto</Keyword>
- <PropertyName>fixme:to_name</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Description>Name of receipient</Description>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>mailfromaddr</Keyword>
- <PropertyName>parent:fixme:from_address</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>mailfromaddr</Keyword>
- <PropertyName>fixme:from_address</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Description>Email address of sender</Description>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>mailfrom</Keyword>
- <PropertyName>parent:fixme:from_name</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>mailfrom</Keyword>
- <PropertyName>fixme:from_name</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Description>Name of email sender</Description>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>speakingto</Keyword>
- <PropertyName>fixme:speakingto</PropertyName>
- <IsKeyword>true</IsKeyword>
- <Description>Person engaged in conversation</Description>
- <Type>2</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>ext</Keyword>
- <PropertyName>beagle:FilenameExtension</PropertyName>
- <IsKeyword>true</IsKeyword>
- <Description>File extension, e.g. ext:jpeg. Use ext: to search in files with no extension.</Description>
- <Type>2</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>host</Keyword>
- <PropertyName>fixme:host</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Description>The host of this entitiy.</Description>
- <Type>1</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>emblem</Keyword>
- <PropertyName>nautilus:emblem</PropertyName>
- <IsKeyword>true</IsKeyword>
- <Description>Use emblem to identify items tagged with a specific emblem in nautilus.</Description>
- <Type>2</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>ext</Keyword>
- <PropertyName>beagle:FilenameExtension</PropertyName>
- <IsKeyword>true</IsKeyword>
- <Description>File extension, e.g. ext:jpeg. Use ext: to search in files with no extension.</Description>
- <Type>2</Type>
- </KeywordMappings>
- <KeywordMappings>
- <Keyword>notetag</Keyword>
- <PropertyName>note:tag</PropertyName>
- <IsKeyword>false</IsKeyword>
- <Description>Tag associated with a tomboy note.</Description>
- <Type>1</Type>
- </KeywordMappings>
-</DocumentElement>
-";
+
// DO NOT change these 4 names - the names should be same as Config.Name and file names
public const string FilesQueryableConfig = "FilesQueryable";
public const string BeagleSearchConfig = "BeagleSearch";
@@ -376,9 +155,7 @@
configs_dir = Path.Combine (PathFinder.StorageDir, "config");
if (!Directory.Exists (configs_dir)) {
Directory.CreateDirectory (configs_dir);
- }
- if (!File.Exists (Path.Combine (PathFinder.StorageDir,"keywordmappings.xml"))){
- File.WriteAllText (Path.Combine (PathFinder.StorageDir,"keywordmappings.xml"),Conf.Names.DefaultMappings);
+ return;
}
// Else check the directory for old config files
CheckOldConfig ();
Modified: trunk/beagle/beagled/PropertyKeywordFu.cs
==============================================================================
--- trunk/beagle/beagled/PropertyKeywordFu.cs (original)
+++ trunk/beagle/beagled/PropertyKeywordFu.cs Sun Feb 3 09:59:02 2008
@@ -26,6 +26,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.IO;
using System.Text;
@@ -38,7 +39,6 @@
public class PropertyDetail {
private PropertyType type;
private string property_name;
- private string alias;
// a short description, so that frontends can get the description from here
// and they dont need to guess the meaning of a query keyword (being too nice ?!)
private string short_desc;
@@ -66,18 +66,12 @@
this.property_name = property_name;
this.short_desc = desc;
}
-
- public PropertyDetail (PropertyType type, string property_name, string desc, string alias) {
- this.type = type;
- this.property_name = property_name;
- this.short_desc = desc;
- this.alias = alias;
- }
+
}
public class PropertyKeywordFu {
// mapping
- public static Hashtable property_table;
+ private static Hashtable property_table;
// static class
private PropertyKeywordFu () { }
@@ -147,14 +141,14 @@
((ArrayList)o).Add (new PropertyDetail (
mapping.IsKeyword ? PropertyType.Keyword : PropertyType.Text,
mapping.PropertyName,
- mapping.Description,mapping.Keyword));
+ mapping.Description));
} else if (o is PropertyDetail) {
ArrayList list = new ArrayList (2);
list.Add (o);
list.Add (new PropertyDetail (
mapping.IsKeyword ? PropertyType.Keyword : PropertyType.Text,
mapping.PropertyName,
- mapping.Description,mapping.Keyword));
+ mapping.Description));
property_table [mapping.Keyword] = list;
}
return;
@@ -197,5 +191,103 @@
}
return true;
}
+
+ public static void AddToCache (string keyword, PropertyDetail details) {
+
+ if (property_table.Contains (keyword)) {
+ object o = PropertyKeywordFu.property_table [keyword];
+ if (o is ArrayList) {
+ ((ArrayList)o).Add ( details );
+ } else if (o is PropertyDetail) {
+ ArrayList list = new ArrayList (2);
+ list.Add (o);
+ list.Add ( details );
+ PropertyKeywordFu.property_table [keyword] = list;
+ }
+ } else {
+
+ property_table.Add (keyword , details);
+
+ }
+ }
+ }
+ public class KeywordMappingStore
+ {
+ private List<PropertyInfo> property_info = new List<PropertyInfo>();
+
+ [XmlArray]
+ [XmlArrayItem (ElementName="Properties", Type=typeof(PropertyInfo))]
+ public List<PropertyInfo> PropertyInfo {
+ get {
+ return property_info;
+ }
+ set {
+ property_info = value;
+ }
+ }
+
+ public KeywordMappingStore (){
+ }
+
+
+ }
+
+ public class PropertyInfo
+ {
+ private string keyword;
+ private string propertyname;
+ private PropertyType prop_type;
+ private string description;
+
+ public PropertyInfo () {
+
+ }
+
+ public PropertyInfo (string k, string prop, PropertyType keyword, string descript) {
+ this.keyword = k;
+ this.propertyname = prop;
+ this.prop_type = keyword;
+ this.description = descript;
+ }
+
+ [XmlAttribute ("Keyword")]
+ public string Keyword {
+ get {
+ return keyword;
+ }
+ set {
+ keyword = value;
+ }
+ }
+ [XmlAttribute ("PropertyName")]
+ public string Propertyname {
+ get {
+ return propertyname;
+ }
+ set {
+ propertyname = value;
+ }
+ }
+
+ [XmlText]
+ public string Description {
+ get {
+ return description;
+ }
+ set {
+ description = value;
+ }
+ }
+
+ [XmlAttribute (AttributeName = "PropType",Type = typeof(PropertyType))]
+ public PropertyType PropType {
+ get {
+ return prop_type;
+ } set {
+ prop_type = value;
+ }
+ }
+
}
+
}
Modified: trunk/beagle/beagled/QueryDriver.cs
==============================================================================
--- trunk/beagle/beagled/QueryDriver.cs (original)
+++ trunk/beagle/beagled/QueryDriver.cs Sun Feb 3 09:59:02 2008
@@ -33,7 +33,7 @@
using System.Threading;
using Beagle.Util;
using System.Xml.Serialization;
-using System.Data;
+
namespace Beagle.Daemon {
public class QueryDriver {
@@ -205,48 +205,65 @@
public static void ReadKeywordMappings ()
{
-
- Logger.Log.Debug ("Reading mapping from filters");
- Stream s =File.Open (Path.Combine (PathFinder.StorageDir,"keywordmappings.xml") , FileMode.Open);
- DataTable dt = new DataTable("KeywordMappings");
- dt.Columns.Add ( new DataColumn ("Keyword", Type.GetType("System.String")));
- dt.Columns.Add ( new DataColumn ("PropertyName", Type.GetType("System.String")));
- dt.Columns.Add ( new DataColumn ("IsKeyword", Type.GetType("System.Boolean")));
- dt.Columns.Add ( new DataColumn ("Description", Type.GetType("System.String")));
- dt.Columns.Add ( new DataColumn ("Type", typeof(Beagle.PropertyType)));
- dt.AcceptChanges ();
- dt.ReadXml (s);
- s.Flush();
- s.Close();
- foreach ( DataRow r in dt.Rows){
- if (PropertyKeywordFu.property_table.Contains (r.ItemArray[0])) {
- object o = PropertyKeywordFu.property_table [r.ItemArray[0]];
- if (o is ArrayList) {
- ((ArrayList)o).Add ( new PropertyDetail (
- (Boolean.Parse( r.ItemArray[2].ToString())) ? PropertyType.Keyword : PropertyType.Text,
- r.ItemArray[1].ToString(),
- r.ItemArray[3].ToString()));
- } else if (o is PropertyDetail) {
- ArrayList list = new ArrayList (2);
- list.Add (o);
- list.Add ( new PropertyDetail (
- (Boolean.Parse( r.ItemArray[2].ToString())) ? PropertyType.Keyword : PropertyType.Text,
- r.ItemArray[1].ToString(),
- r.ItemArray[3].ToString()));
- PropertyKeywordFu.property_table [r.ItemArray[0]] = list;
- }
-
+ XmlSerializerFactory xsf = new XmlSerializerFactory();
+ XmlSerializer xs = xsf.CreateSerializer (typeof(KeywordMappingStore),new Type[] {typeof(PropertyInfo),typeof(Beagle.PropertyType)});
+ Stream s = null;
+ KeywordMappingStore kms = null;
+ try {
+ if (System.Environment.GetEnvironmentVariable ("$BEAGLE_LOAD_KEYWORDS_FROM") != null){
+ s =File.OpenRead (System.Environment.GetEnvironmentVariable ("$BEAGLE_LOAD_KEYWORDS_FROM"));
} else {
-
+ Logger.Log.Debug ("Reading mapping from filters");
+ s =File.OpenRead (Path.Combine (PathFinder.GlobalConfigDir,"../keyword-mapping.xml"));
+ }
+ kms = (KeywordMappingStore) xs.Deserialize (s);
+ s.Flush();
+ s.Close();
+ foreach (PropertyInfo pi in kms.PropertyInfo){
+ PropertyKeywordFu.AddToCache ( pi.Keyword, (
+ new PropertyDetail (
+ pi.PropType ,
+ pi.Propertyname,
+ pi.Description)));
+ }
+ } catch (IOException e) {
+ Logger.Log.Error (e);
+ }
- PropertyKeywordFu.property_table.Add (
- r.ItemArray[0], (
- new PropertyDetail (
- (Boolean.Parse( r.ItemArray[2].ToString())) ? PropertyType.Keyword : PropertyType.Text,
- r.ItemArray[1].ToString(),
- r.ItemArray[3].ToString())));
+ try {
+
+
+ if (File.Exists ( Path.Combine (PathFinder.StorageDir, "keyword-mapping.xml"))){
+ s =File.Open ( Path.Combine (PathFinder.StorageDir, "keyword-mapping.xml") , FileMode.Open);
+ kms = (KeywordMappingStore) xs.Deserialize (s);
+ s.Flush();
+ s.Close();
+ foreach (PropertyInfo pi in kms.PropertyInfo){
+ PropertyKeywordFu.AddToCache ( pi.Keyword, (
+ new PropertyDetail (
+ pi.PropType ,
+ pi.Propertyname,
+ pi.Description)));
+ }
}
+ } catch (IOException e) {
+ Logger.Log.Error (e);
}
+
+ //To Generate a starting file, the original reflection was used. I've kept the code, should we need to recreate
+ //the initial file.
+// KeywordMappingStore kms = new KeywordMappingStore();
+// foreach (String s1 in PropertyKeywordFu.Keys ) {
+// foreach (PropertyDetail pd in PropertyKeywordFu.Properties (s1) ) {
+// kms.PropertyInfo.Add ( new PropertyInfo (s1,pd.PropertyName,pd.Type, pd.Description));
+// System.Console.WriteLine(new PropertyInfo (s1,pd.PropertyName,pd.Type, pd.Description).Propertyname);
+// }
+// }
+//
+// XmlSerializerFactory xsf = new XmlSerializerFactory();
+// XmlSerializer xs = xsf.CreateSerializer (typeof(KeywordMappingStore),new Type[] {typeof(PropertyInfo),typeof(Beagle.PropertyType)});
+// xs.Serialize (Console.Out,kms);
+
}
////////////////////////////////////////////////////////
Modified: trunk/beagle/tools/Query.cs
==============================================================================
--- trunk/beagle/tools/Query.cs (original)
+++ trunk/beagle/tools/Query.cs Sun Feb 3 09:59:02 2008
@@ -33,7 +33,6 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;
-using System.Data;
using GLib;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]