~c-franke/do/XesamSearch

« back to all changes in this revision

Viewing changes to XesamBeagleAdaptor/Ontologies.cs

  • Committer: Christof Franke
  • Date: 2008-02-26 13:25:41 UTC
  • Revision ID: kraut@workstation-20080226132541-xz4d9tt2kwktp1gn
Add: Ontologies needed for beagle-xesam-adaptor

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// Ontologies.cs : Translate between Xesam and Beagle ontologies
 
3
//
 
4
// Copyright (C) 2008 Christof Franke <c.franke@muenchen-mail.de> (Adding Ontos)
 
5
// Copyright (C) 2007 Arun Raghavan <arunissatan@gmail.com>
 
6
//
 
7
 
 
8
//
 
9
// Permission is hereby granted, free of charge, to any person obtaining a
 
10
// copy of this software and associated documentation files (the "Software"),
 
11
// to deal in the Software without restriction, including without limitation
 
12
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
 
13
// and/or sell copies of the Software, and to permit persons to whom the
 
14
// Software is furnished to do so, subject to the following conditions:
 
15
//
 
16
// The above copyright notice and this permission notice shall be included in
 
17
// all copies or substantial portions of the Software.
 
18
//
 
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
24
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 
25
// DEALINGS IN THE SOFTWARE.
 
26
//
 
27
 
 
28
using System;
 
29
using System.Collections.Generic;
 
30
 
 
31
namespace Beagle {
 
32
        namespace Xesam {
 
33
                class Ontologies {
 
34
                        private static Dictionary<string, string> fields_mapping;
 
35
                        private static Dictionary<string, string> sources_mapping;
 
36
                        private static Dictionary<string, string> contents_mapping;
 
37
                        private static string[] fields_supported = null;
 
38
                        private static string[] sources_supported = null;
 
39
                        private static string[] contents_supported = null;
 
40
 
 
41
                        static Ontologies ()
 
42
                        {
 
43
                                InitializeFieldsMapping ();
 
44
                                InitializeSourcesMapping ();
 
45
                                InitializeContentsMapping ();
 
46
                        }
 
47
 
 
48
                        private static void InitializeFieldsMapping ()
 
49
                        {
 
50
                                fields_mapping = new Dictionary<string, string> ();
 
51
                                
 
52
                                /////////////////////////////// Xesam-Standard
 
53
                                fields_mapping.Add ("xesam:title", "beagle:Filename"); //fixme:title and dc:title mostly empty
 
54
                                fields_mapping.Add ("xesam:author", "author");
 
55
                                fields_mapping.Add ("xesam:fileSystemType", "beagle:FileType"); 
 
56
                                fields_mapping.Add ("xesam:creator", "creator");
 
57
                                fields_mapping.Add ("xesam:sourceModified", "date"); //modified date of all files, not only source
 
58
                                fields_mapping.Add ("xesam:width", "fixme:width");      //for video files beagle has extra fields for width and heigt
 
59
                                fields_mapping.Add ("xesam:height", "fixme:height"); //Xesam only supports on width, height field
 
60
                                fields_mapping.Add ("xesam:pageCount", "fixme:page-count");
 
61
                                fields_mapping.Add ("xesam:mimeType", "mimetype");
 
62
                                fields_mapping.Add ("xesam:url", "uri");
 
63
                                fields_mapping.Add ("xesam:fileExtension", "beagle:FilenameExtension");
 
64
                                fields_mapping.Add ("xesam:from", "fixme:from_address"); //Email -Adress
 
65
                                fields_mapping.Add ("xesam:to", "fixme:to_addr"); //Email-Asress
 
66
                                fields_mapping.Add ("xesam:subject", "dc:title");
 
67
                                fields_mapping.Add ("xesam:isRead", "fixme:isSeen");
 
68
                        //      fields_mapping.Add ("xesam:title", "fixme:title");
 
69
                                fields_mapping.Add ("xesam:artist", "fixme:artist");
 
70
                                fields_mapping.Add ("xesam:ExactFilename", "beagle:ExactFilename");
 
71
                                fields_mapping.Add ("xesam:videoCodec", "fixme:video:codec");
 
72
                                //fields_mapping.Add ("xesam:creator", "creator");
 
73
                                //fields_mapping.Add ("xesam:fileExtension", "beagle:FilenameExtension");
 
74
                                
 
75
                                ////////////////////Beagle Special Ontos
 
76
                                // !!! TODO: please change if there is xesam support  !!!
 
77
                                fields_mapping.Add ("dc:title", "dc:title");
 
78
                                fields_mapping.Add ("snippet", "snippetLine");
 
79
                                fields_mapping.Add ("beagle:hitType", "beagle:HitType");
 
80
                                fields_mapping.Add ("emblem", "nautilus:emblem");
 
81
                                //fields_mapping.Add ("dc:author", "author");
 
82
                                //fields_mapping.Add ("dc:date", "date");
 
83
                                //fields_mapping.Add ("mime", "mimetype");
 
84
                                //fields_mapping.Add ("uri", "uri");
 
85
                                //fields_mapping.Add ("url", "uri");
 
86
                                
 
87
                                
 
88
                                // Mail Ontologies  
 
89
                                fields_mapping.Add ("beagle:from_name", "fixme:from_name");
 
90
                                fields_mapping.Add ("beagle:from_addr", "fixme:from_address");
 
91
                                fields_mapping.Add ("beagle:to_name", "fixme:to_name");
 
92
                                fields_mapping.Add ("beagle:to_addr", "fixme:to_address");
 
93
                                fields_mapping.Add ("beagle:isSent", "fixme:isSent");
 
94
                                fields_mapping.Add ("beagle:isAnswered", "fixme:isAnswered");
 
95
                                fields_mapping.Add ("beagle:folder", "fixme:folder");
 
96
                                fields_mapping.Add ("beagle:client", "fixme:client");  
 
97
                                fields_mapping.Add ("beagle:stock_mail-replied", "stock_mail-replied");
 
98
                                fields_mapping.Add ("beagle:stock_mail-open", "stock_mail-open");
 
99
                                fields_mapping.Add ("beagle:stock_mail", "stock_mail");
 
100
                                 
 
101
                                // Mail Attachment 
 
102
                                fields_mapping.Add ("beagle:hasAttachments", "parent:fixme:hasAttachments");
 
103
                                fields_mapping.Add ("beagle:attachment_title", "fixme:attachment_title");
 
104
                                fields_mapping.Add ("beagle:parent:title", "parent:dc:title");
 
105
                                
 
106
                                                
 
107
                                // InstantMsgLogs Ontologies  
 
108
                                //      Ive seen no Xesam support for IM -files  ; 
 
109
                //  !!! TODO: please change if there is support !!!
 
110
                                fields_mapping.Add ("beagle:speakingto", "fixme:speakingto");
 
111
                                fields_mapping.Add ("beagle:starttime", "fixme:starttime");
 
112
                                //fields_mapping.Add ("beagle:client", "fixme:client");
 
113
                                fields_mapping.Add ("beagle:protocol", "fixme:protocol");
 
114
                                fields_mapping.Add ("beagle:identity", "fixme:identity");
 
115
                                fields_mapping.Add ("beagle:speakingto_alias", "fixme:speakingto_alias");
 
116
                                fields_mapping.Add ("beagle:speakingto_icon", "fixme:speakingto_icon");
 
117
                                                
 
118
                                // Calendar Ontologies
 
119
                                //TODO: fixme:summary fixme:starttime fixme:description stock_calendar fixme:endtime fixme:location fixme:attendee
 
120
                        }
 
121
 
 
122
                        private static void InitializeSourcesMapping ()
 
123
                        {
 
124
                                sources_mapping = new Dictionary<string, string> ();
 
125
 
 
126
                                sources_mapping.Add ("xesam:ArchivedFile", "filetype:archive");
 
127
                                sources_mapping.Add ("xesam:File", "type:File");
 
128
                                sources_mapping.Add ("xesam:MessageboxMessage","type:MailMessage");
 
129
                        }
 
130
 
 
131
                        private static void InitializeContentsMapping ()
 
132
                        {
 
133
                                contents_mapping = new Dictionary<string, string> ();
 
134
 
 
135
                                contents_mapping.Add ("xesam:Archive", "filetype:archive");
 
136
                                contents_mapping.Add ("xesam:Audio", "filetype:audio");
 
137
                                contents_mapping.Add ("xesam:Bookmark", "type:Bookmark");
 
138
                                contents_mapping.Add ("xesam:Contact", "type:Contact");
 
139
                                contents_mapping.Add ("xesam:Document", "( filetype:document or filetype:documentation )");
 
140
                                contents_mapping.Add ("xesam:Documentation", "filetype:documentation");
 
141
                                contents_mapping.Add ("xesam:Email", "type:MailMessage");
 
142
                                contents_mapping.Add ("xesam:IMMessage", "type:IMLog");
 
143
                                contents_mapping.Add ("xesam:Image", "filetype:image");
 
144
                                contents_mapping.Add ("xesam:Media", "( filetype:audio or filetype:video )");
 
145
                                contents_mapping.Add ("xesam:Message", "( type:MailMessage or type:IMLog )");
 
146
                                contents_mapping.Add ("xesam:RSSMessage", "type:FeedItem");
 
147
                                contents_mapping.Add ("xesam:SourceCode", "filetype:source");
 
148
                                contents_mapping.Add ("xesam:TextDocument", "filetype:document");
 
149
                                contents_mapping.Add ("xesam:Video", "filetype:video");
 
150
                                contents_mapping.Add ("xesam:Visual", "( filetype:image or filetype:video )");
 
151
                                contents_mapping.Add ("xesam:Alarm", "type:Calendar");
 
152
                                contents_mapping.Add ("xesam:Event", "type:Calendar");
 
153
                                contents_mapping.Add ("xesam:FreeBusy", "type:Calendar");
 
154
                                contents_mapping.Add ("xesam:Task", "type:Task");
 
155
                        }
 
156
 
 
157
                        public static string[] GetSupportedXesamFields ()
 
158
                        {
 
159
                                if (fields_supported == null) {
 
160
                                        List<string> ret = new List<string> ();
 
161
 
 
162
                                        foreach (string field in fields_mapping.Keys)
 
163
                                                ret.Add (field);
 
164
 
 
165
                                        fields_supported = ret.ToArray ();
 
166
                                }
 
167
 
 
168
                                return fields_supported;
 
169
                        }
 
170
 
 
171
                        public static string XesamToBeagleField (string xesamField) {
 
172
                                if (fields_mapping.ContainsKey (xesamField))
 
173
                                        return fields_mapping [xesamField];
 
174
                                else {
 
175
                                        Console.Error.WriteLine ("Unsupported field: {0}", xesamField);
 
176
                                        return xesamField.Replace (':', '-');
 
177
                                }
 
178
                        }
 
179
 
 
180
                        public static string[] GetSupportedXesamSources ()
 
181
                        {
 
182
                                if (sources_supported == null) {
 
183
                                        List<string> ret = new List<string> ();
 
184
 
 
185
                                        foreach (string field in sources_mapping.Keys)
 
186
                                                ret.Add (field);
 
187
 
 
188
                                        sources_supported = ret.ToArray ();
 
189
                                }
 
190
 
 
191
                                return sources_supported;
 
192
                        }
 
193
 
 
194
                        public static string XesamToBeagleSource (string xesamSource)
 
195
                        {
 
196
                                if (sources_mapping.ContainsKey (xesamSource))
 
197
                                        return sources_mapping [xesamSource];
 
198
                                else {
 
199
                                        Console.Error.WriteLine ("Unsupported source: {0}", xesamSource);
 
200
                                        return String.Empty;
 
201
                                }
 
202
                        }
 
203
 
 
204
 
 
205
                        public static string[] GetSupportedXesamContents ()
 
206
                        {
 
207
                                if (contents_supported == null) {
 
208
                                        List<string> ret = new List<string> ();
 
209
 
 
210
                                        foreach (string field in contents_mapping.Keys)
 
211
                                                ret.Add (field);
 
212
 
 
213
                                        contents_supported = ret.ToArray ();
 
214
                                }
 
215
 
 
216
                                return contents_supported;
 
217
                        }
 
218
 
 
219
                        public static string XesamToBeagleContent (string xesamContent)
 
220
                        {
 
221
                                if (contents_mapping.ContainsKey (xesamContent))
 
222
                                        return contents_mapping [xesamContent];
 
223
                                else {
 
224
                                        Console.Error.WriteLine ("Unsupported content type: {0}", xesamContent);
 
225
                                        return String.Empty;
 
226
                                }
 
227
                        }
 
228
                }
 
229
        }
 
230
}