// // Ontologies.cs : Translate between Xesam and Beagle ontologies // // Copyright (C) 2008 Christof Franke (Adding Ontos) // Copyright (C) 2007 Arun Raghavan // // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // using System; using System.Collections.Generic; namespace Beagle { namespace Xesam { class Ontologies { private static Dictionary fields_mapping; private static Dictionary sources_mapping; private static Dictionary contents_mapping; private static string[] fields_supported = null; private static string[] sources_supported = null; private static string[] contents_supported = null; static Ontologies () { InitializeFieldsMapping (); InitializeSourcesMapping (); InitializeContentsMapping (); } private static void InitializeFieldsMapping () { fields_mapping = new Dictionary (); /////////////////////////////// Xesam-Standard fields_mapping.Add ("xesam:title", "beagle:Filename"); //fixme:title and dc:title mostly empty fields_mapping.Add ("xesam:author", "author"); fields_mapping.Add ("xesam:fileSystemType", "beagle:FileType"); fields_mapping.Add ("xesam:creator", "creator"); fields_mapping.Add ("xesam:sourceModified", "date"); //modified date of all files, not only source fields_mapping.Add ("xesam:width", "fixme:width"); //for video files beagle has extra fields for width and heigt fields_mapping.Add ("xesam:height", "fixme:height"); //Xesam only supports on width, height field fields_mapping.Add ("xesam:pageCount", "fixme:page-count"); fields_mapping.Add ("xesam:mimeType", "mimetype"); fields_mapping.Add ("xesam:url", "uri"); fields_mapping.Add ("xesam:fileExtension", "beagle:FilenameExtension"); fields_mapping.Add ("xesam:from", "fixme:from_address"); //Email -Adress fields_mapping.Add ("xesam:to", "fixme:to_addr"); //Email-Asress fields_mapping.Add ("xesam:subject", "dc:title"); fields_mapping.Add ("xesam:isRead", "fixme:isSeen"); // fields_mapping.Add ("xesam:title", "fixme:title"); fields_mapping.Add ("xesam:artist", "fixme:artist"); fields_mapping.Add ("xesam:ExactFilename", "beagle:ExactFilename"); fields_mapping.Add ("xesam:videoCodec", "fixme:video:codec"); //fields_mapping.Add ("xesam:creator", "creator"); //fields_mapping.Add ("xesam:fileExtension", "beagle:FilenameExtension"); ////////////////////Beagle Special Ontos // !!! TODO: please change if there is xesam support !!! fields_mapping.Add ("dc:title", "dc:title"); fields_mapping.Add ("snippet", "snippetLine"); fields_mapping.Add ("beagle:hitType", "beagle:HitType"); fields_mapping.Add ("emblem", "nautilus:emblem"); //fields_mapping.Add ("dc:author", "author"); //fields_mapping.Add ("dc:date", "date"); //fields_mapping.Add ("mime", "mimetype"); //fields_mapping.Add ("uri", "uri"); //fields_mapping.Add ("url", "uri"); // Mail Ontologies fields_mapping.Add ("beagle:from_name", "fixme:from_name"); fields_mapping.Add ("beagle:from_addr", "fixme:from_address"); fields_mapping.Add ("beagle:to_name", "fixme:to_name"); fields_mapping.Add ("beagle:to_addr", "fixme:to_address"); fields_mapping.Add ("beagle:isSent", "fixme:isSent"); fields_mapping.Add ("beagle:isAnswered", "fixme:isAnswered"); fields_mapping.Add ("beagle:folder", "fixme:folder"); fields_mapping.Add ("beagle:client", "fixme:client"); fields_mapping.Add ("beagle:stock_mail-replied", "stock_mail-replied"); fields_mapping.Add ("beagle:stock_mail-open", "stock_mail-open"); fields_mapping.Add ("beagle:stock_mail", "stock_mail"); // Mail Attachment fields_mapping.Add ("beagle:hasAttachments", "parent:fixme:hasAttachments"); fields_mapping.Add ("beagle:attachment_title", "fixme:attachment_title"); fields_mapping.Add ("beagle:parent:title", "parent:dc:title"); // InstantMsgLogs Ontologies // Ive seen no Xesam support for IM -files ; // !!! TODO: please change if there is support !!! fields_mapping.Add ("beagle:speakingto", "fixme:speakingto"); fields_mapping.Add ("beagle:starttime", "fixme:starttime"); //fields_mapping.Add ("beagle:client", "fixme:client"); fields_mapping.Add ("beagle:protocol", "fixme:protocol"); fields_mapping.Add ("beagle:identity", "fixme:identity"); fields_mapping.Add ("beagle:speakingto_alias", "fixme:speakingto_alias"); fields_mapping.Add ("beagle:speakingto_icon", "fixme:speakingto_icon"); // Calendar Ontologies //TODO: fixme:summary fixme:starttime fixme:description stock_calendar fixme:endtime fixme:location fixme:attendee } private static void InitializeSourcesMapping () { sources_mapping = new Dictionary (); sources_mapping.Add ("xesam:ArchivedFile", "filetype:archive"); sources_mapping.Add ("xesam:File", "type:File"); sources_mapping.Add ("xesam:MessageboxMessage","type:MailMessage"); } private static void InitializeContentsMapping () { contents_mapping = new Dictionary (); contents_mapping.Add ("xesam:Archive", "filetype:archive"); contents_mapping.Add ("xesam:Audio", "filetype:audio"); contents_mapping.Add ("xesam:Bookmark", "type:Bookmark"); contents_mapping.Add ("xesam:Contact", "type:Contact"); contents_mapping.Add ("xesam:Document", "( filetype:document or filetype:documentation )"); contents_mapping.Add ("xesam:Documentation", "filetype:documentation"); contents_mapping.Add ("xesam:Email", "type:MailMessage"); contents_mapping.Add ("xesam:IMMessage", "type:IMLog"); contents_mapping.Add ("xesam:Image", "filetype:image"); contents_mapping.Add ("xesam:Media", "( filetype:audio or filetype:video )"); contents_mapping.Add ("xesam:Message", "( type:MailMessage or type:IMLog )"); contents_mapping.Add ("xesam:RSSMessage", "type:FeedItem"); contents_mapping.Add ("xesam:SourceCode", "filetype:source"); contents_mapping.Add ("xesam:TextDocument", "filetype:document"); contents_mapping.Add ("xesam:Video", "filetype:video"); contents_mapping.Add ("xesam:Visual", "( filetype:image or filetype:video )"); contents_mapping.Add ("xesam:Alarm", "type:Calendar"); contents_mapping.Add ("xesam:Event", "type:Calendar"); contents_mapping.Add ("xesam:FreeBusy", "type:Calendar"); contents_mapping.Add ("xesam:Task", "type:Task"); } public static string[] GetSupportedXesamFields () { if (fields_supported == null) { List ret = new List (); foreach (string field in fields_mapping.Keys) ret.Add (field); fields_supported = ret.ToArray (); } return fields_supported; } public static string XesamToBeagleField (string xesamField) { if (fields_mapping.ContainsKey (xesamField)) return fields_mapping [xesamField]; else { Console.Error.WriteLine ("Unsupported field: {0}", xesamField); return xesamField.Replace (':', '-'); } } public static string[] GetSupportedXesamSources () { if (sources_supported == null) { List ret = new List (); foreach (string field in sources_mapping.Keys) ret.Add (field); sources_supported = ret.ToArray (); } return sources_supported; } public static string XesamToBeagleSource (string xesamSource) { if (sources_mapping.ContainsKey (xesamSource)) return sources_mapping [xesamSource]; else { Console.Error.WriteLine ("Unsupported source: {0}", xesamSource); return String.Empty; } } public static string[] GetSupportedXesamContents () { if (contents_supported == null) { List ret = new List (); foreach (string field in contents_mapping.Keys) ret.Add (field); contents_supported = ret.ToArray (); } return contents_supported; } public static string XesamToBeagleContent (string xesamContent) { if (contents_mapping.ContainsKey (xesamContent)) return contents_mapping [xesamContent]; else { Console.Error.WriteLine ("Unsupported content type: {0}", xesamContent); return String.Empty; } } } } }