tracker r2174 - in branches/indexer-split: . data data/services src/libtracker-common src/libtracker-db tests/libtracker-common



Author: ifrade
Date: Wed Aug 27 17:19:27 2008
New Revision: 2174
URL: http://svn.gnome.org/viewvc/tracker?rev=2174&view=rev

Log:
Fixed GetRegisteredTypes method in the API adding a PropertyPrefix attribute to service type description

Modified:
   branches/indexer-split/ChangeLog
   branches/indexer-split/data/services/default.service
   branches/indexer-split/data/sqlite-service-types.sql
   branches/indexer-split/data/sqlite-stored-procs.sql
   branches/indexer-split/data/sqlite-xesam.sql
   branches/indexer-split/src/libtracker-common/tracker-ontology.c
   branches/indexer-split/src/libtracker-common/tracker-ontology.h
   branches/indexer-split/src/libtracker-common/tracker-service.c
   branches/indexer-split/src/libtracker-common/tracker-service.h
   branches/indexer-split/src/libtracker-db/tracker-db-manager.c
   branches/indexer-split/tests/libtracker-common/tracker-ontology-test.c

Modified: branches/indexer-split/data/services/default.service
==============================================================================
--- branches/indexer-split/data/services/default.service	(original)
+++ branches/indexer-split/data/services/default.service	Wed Aug 27 17:19:27 2008
@@ -1,6 +1,7 @@
 [Files]
 DisplayName=All Files
 Description=All files in the filesystem
+PropertyPrefix=File
 UIVisible=true
 Icon=system-file-manager
 UIView=icon
@@ -24,6 +25,7 @@
 [Documents]
 DisplayName=Documents
 Description=Office and PDF based files
+PropertyPrefix=Doc
 Parent=Files
 UIVisible=true
 Icon=x-office-document
@@ -62,6 +64,7 @@
 [Images]
 DisplayName=Images
 Description=Image based files
+PropertyPrefix=Image
 Parent=Files
 UIVisible=true
 UIView=icon
@@ -86,6 +89,7 @@
 [Music]
 DisplayName=Music
 Description=Music based files
+PropertyPrefix=Audio
 Parent=Files
 UIVisible=true
 UIView=tabular
@@ -115,6 +119,7 @@
 [Videos]
 DisplayName=Videos
 Description=Video based files
+PropertyPrefix=Video
 Parent=Files
 UIVisible=true
 UIView=icon
@@ -177,6 +182,7 @@
 [Emails]
 DisplayName=Emails
 Description=All Emails
+PropertyPrefix=Email
 UIVisible=true
 UIMetadata1=Email:Subject
 UIMetadata2=Email:Sender
@@ -280,6 +286,7 @@
 [Applications]
 DisplayName=Applications
 Description=Application files
+PropertyPrefix=App
 UIVisible=true
 Icon=stock_active
 ShowServiceFiles=true

Modified: branches/indexer-split/data/sqlite-service-types.sql
==============================================================================
--- branches/indexer-split/data/sqlite-service-types.sql	(original)
+++ branches/indexer-split/data/sqlite-service-types.sql	Wed Aug 27 17:19:27 2008
@@ -8,6 +8,7 @@
 
 	DisplayName		Text default ' ',
 	Parent			Text default ' ',
+	PropertyPrefix		Text default ' ',
 	Enabled			Integer default 1, 
 	Embedded		Integer default 1, /* service is created by the indexer if embedded. User or app defined services are not embedded */
 	ChildResource		Integer default 0, /* service is a child service */

Modified: branches/indexer-split/data/sqlite-stored-procs.sql
==============================================================================
--- branches/indexer-split/data/sqlite-stored-procs.sql	(original)
+++ branches/indexer-split/data/sqlite-stored-procs.sql	Wed Aug 27 17:19:27 2008
@@ -20,7 +20,7 @@
 GetFileMTime SELECT M.MetaDataValue  FROM Services F inner join ServiceNumericMetaData M on F.ID = M.ServiceID WHERE F.Path = ? and F.Name = ? and M.MetaDataID = (select ID From MetaDataTypes where MetaName ='File:Modified');
 
 GetServices SELECT TypeName, Description, Parent  FROM ServiceTypes ORDER BY TypeID;
-GetAllServices SELECT TypeID, TypeName, Parent, Enabled, Embedded, HasMetadata, HasFullText, HasThumbs, ContentMetadata, Database, ShowServiceFiles, ShowServiceDirectories, KeyMetadata1, KeyMetadata2, KeyMetadata3, KeyMetadata4, KeyMetadata5, KeyMetadata6, KeyMetadata7, KeyMetadata8, KeyMetadata9, KeyMetadata10, KeyMetadata11  FROM ServiceTypes;
+GetAllServices SELECT TypeID, TypeName, Parent, PropertyPrefix, Enabled, Embedded, HasMetadata, HasFullText, HasThumbs, ContentMetadata, Database, ShowServiceFiles, ShowServiceDirectories, KeyMetadata1, KeyMetadata2, KeyMetadata3, KeyMetadata4, KeyMetadata5, KeyMetadata6, KeyMetadata7, KeyMetadata8, KeyMetadata9, KeyMetadata10, KeyMetadata11  FROM ServiceTypes;
 
 /* GetNewID and UpdateNewID are deprecated !! */
 GetNewID SELECT OptionValue FROM Options WHERE OptionKey = 'Sequence';
@@ -224,7 +224,7 @@
 GetXesamMetaDataTextLookups SELECT DISTINCT L.MetaName FROM XesamMetaDataLookup L INNER JOIN XesamMetaDataTypes T ON (T.MetaName = L.XesamMetaName) WHERE T.DataTypeID = 3;
 
 GetXesamMetaDataTypes SELECT ID, MetaName, DataTypeID, FieldName, Weight, Embedded, MultipleValues, Delimited, Filtered, Abstract FROM XesamMetaDataTypes;
-GetXesamServiceTypes SELECT TypeID, TypeName, Parents, Enabled, Embedded, HasMetadata, HasFullText, HasThumbs, ContentMetadata, Database, ShowServiceFiles, ShowServiceDirectories, KeyMetadata1, KeyMetadata2, KeyMetadata3, KeyMetadata4, KeyMetadata5, KeyMetadata6, KeyMetadata7, KeyMetadata8, KeyMetadata9, KeyMetadata10, KeyMetadata11  FROM XesamServiceTypes;
+GetXesamServiceTypes SELECT TypeID, TypeName, Parents, PropertyPrefix, Enabled, Embedded, HasMetadata, HasFullText, HasThumbs, ContentMetadata, Database, ShowServiceFiles, ShowServiceDirectories, KeyMetadata1, KeyMetadata2, KeyMetadata3, KeyMetadata4, KeyMetadata5, KeyMetadata6, KeyMetadata7, KeyMetadata8, KeyMetadata9, KeyMetadata10, KeyMetadata11  FROM XesamServiceTypes;
 
 InsertXesamMimes replace into XesamFileMimes (Mime) Values (?);
 InsertXesamMimePrefixes replace into XesamFileMimePrefixes (MimePrefix) Values (?);

Modified: branches/indexer-split/data/sqlite-xesam.sql
==============================================================================
--- branches/indexer-split/data/sqlite-xesam.sql	(original)
+++ branches/indexer-split/data/sqlite-xesam.sql	Wed Aug 27 17:19:27 2008
@@ -35,6 +35,7 @@
 	TypeCount		Integer default 0,
 
 	DisplayName		Text default ' ',
+	PropertyPrefix          Text default ' ',
 	Enabled			Integer default 1, 
 	Embedded		Integer default 1, /* service is created by the indexer if embedded. User or app defined services are not embedded */
 	ChildResource		Integer default 0, /* service is a child service */

Modified: branches/indexer-split/src/libtracker-common/tracker-ontology.c
==============================================================================
--- branches/indexer-split/src/libtracker-common/tracker-ontology.c	(original)
+++ branches/indexer-split/src/libtracker-common/tracker-ontology.c	Wed Aug 27 17:19:27 2008
@@ -503,16 +503,56 @@
 {
 	GList *field_types = NULL, *iter = NULL;
 	GSList *names = NULL;
-	TrackerField *field;
+	TrackerField   *field;
+	TrackerService *service = NULL, *parent;
+	const gchar    *prefix;
+	const gchar    *parent_name = NULL;
+	const gchar    *parent_prefix = NULL;
+	
+
+	if (service_type) {
+		service = tracker_ontology_get_service_type_by_name (service_type);
+		if (!service) {
+			return NULL;
+		}
+
+		/* Prefix for properties of the category */
+		prefix = tracker_service_get_property_prefix (service);
+		
+		if (!prefix || g_strcmp0 (prefix, " ") == 0) {
+			prefix = service_type;
+		}
+		
+		/* Prefix for properties of the parent */
+		parent_name = tracker_ontology_get_parent_service (service_type);
+
+		if (parent_name) {
+			parent = tracker_ontology_get_service_type_by_name (parent_name);
+		
+			if (!parent) {
+				g_critical ("Category %s (set as %s parent) is not in the ontology",
+					    parent_name, service_type);
+			}
+			parent_prefix = tracker_service_get_property_prefix (parent);
+		
+			if (!parent_prefix || g_strcmp0 (parent_prefix, " ") == 0) {
+				parent_prefix = parent_name;
+			}
+		}
+	}
 
 	field_types = g_hash_table_get_values (metadata_table);
 
 	for (iter = field_types; iter != NULL; iter = iter->next) {
+
 		field = (TrackerField*)iter->data;
 
+		const gchar *name = tracker_field_get_name (field);
+
 		if (service_type == NULL 
-		    || g_str_has_prefix (tracker_field_get_name (field), service_type)) {
-			names = g_slist_prepend (names, g_strdup (tracker_field_get_name (field)));
+		    || g_str_has_prefix (name, prefix)
+		    || g_str_has_prefix (name, parent_prefix)) {
+			names = g_slist_prepend (names, g_strdup (name));
 		}
 	}
 	return names;

Modified: branches/indexer-split/src/libtracker-common/tracker-ontology.h
==============================================================================
--- branches/indexer-split/src/libtracker-common/tracker-ontology.h	(original)
+++ branches/indexer-split/src/libtracker-common/tracker-ontology.h	Wed Aug 27 17:19:27 2008
@@ -71,7 +71,7 @@
 								  const gchar    *parent);
 TrackerField *     tracker_ontology_get_field_def                (const gchar    *name);
 const gchar *      tracker_ontology_get_field_id                 (const gchar    *name);
-TrackerField *  tracker_ontology_get_field_def_by_id          (gint            id);
+TrackerField *     tracker_ontology_get_field_def_by_id          (gint            id);
 
 G_END_DECLS
 

Modified: branches/indexer-split/src/libtracker-common/tracker-service.c
==============================================================================
--- branches/indexer-split/src/libtracker-common/tracker-service.c	(original)
+++ branches/indexer-split/src/libtracker-common/tracker-service.c	Wed Aug 27 17:19:27 2008
@@ -36,6 +36,7 @@
 	gchar	      *name;
 	gchar	      *parent;
 
+	gchar         *property_prefix;
 	gchar	      *content_metadata;
 	GSList	      *key_metadata;
 
@@ -67,6 +68,7 @@
 	PROP_ID,
 	PROP_NAME,
 	PROP_PARENT,
+	PROP_PROPERTY_PREFIX,
 	PROP_CONTENT_METADATA,
 	PROP_KEY_METADATA,
 	PROP_DB_TYPE,
@@ -160,6 +162,13 @@
 							      NULL,
 							      G_PARAM_READWRITE));
 	g_object_class_install_property (object_class,
+					 PROP_PROPERTY_PREFIX,
+					 g_param_spec_string ("property-prefix",
+							      "property-prefix",
+							      "The properties of this category are prefix:name",
+							      NULL,
+							      G_PARAM_READWRITE));
+	g_object_class_install_property (object_class,
 					 PROP_CONTENT_METADATA,
 					 g_param_spec_string ("content-metadata",
 							      "content-metadata",
@@ -275,6 +284,9 @@
 	case PROP_PARENT:
 		g_value_set_string (value, priv->parent);
 		break;
+	case PROP_PROPERTY_PREFIX:
+		g_value_set_string (value, priv->property_prefix);
+		break;
 	case PROP_CONTENT_METADATA:
 		g_value_set_string (value, priv->content_metadata);
 		break;
@@ -330,6 +342,10 @@
 		tracker_service_set_name (TRACKER_SERVICE (object),
 					  g_value_get_string (value));
 		break;
+	case PROP_PROPERTY_PREFIX:
+		tracker_service_set_property_prefix (TRACKER_SERVICE (object),
+						     g_value_get_string (value));
+		break;
 	case PROP_PARENT:
 		tracker_service_set_parent (TRACKER_SERVICE (object),
 					    g_value_get_string (value));
@@ -451,6 +467,18 @@
 }
 
 const gchar *
+tracker_service_get_property_prefix (TrackerService *service)
+{
+	TrackerServicePriv *priv;
+	
+	g_return_val_if_fail (TRACKER_IS_SERVICE (service), NULL);
+
+	priv = GET_PRIV (service);
+
+	return priv->property_prefix;
+}
+
+const gchar *
 tracker_service_get_content_metadata (TrackerService *service)
 {
 	TrackerServicePriv *priv;
@@ -631,6 +659,27 @@
 }
 
 void
+tracker_service_set_property_prefix (TrackerService *service,
+				     const gchar    *value)
+{
+	TrackerServicePriv *priv;
+
+	g_return_if_fail (TRACKER_IS_SERVICE (service));
+
+	priv = GET_PRIV (service);
+
+	g_free (priv->property_prefix);
+
+	if (value) {
+		priv->property_prefix = g_strdup (value);
+	} else {
+		priv->property_prefix = NULL;
+	}
+
+	g_object_notify (G_OBJECT (service), "property-prefix");
+}
+
+void
 tracker_service_set_content_metadata (TrackerService *service,
 				      const gchar    *value)
 {

Modified: branches/indexer-split/src/libtracker-common/tracker-service.h
==============================================================================
--- branches/indexer-split/src/libtracker-common/tracker-service.h	(original)
+++ branches/indexer-split/src/libtracker-common/tracker-service.h	Wed Aug 27 17:19:27 2008
@@ -69,6 +69,7 @@
 gint            tracker_service_get_id                       (TrackerService *service);
 const gchar *   tracker_service_get_name                     (TrackerService *service);
 const gchar *   tracker_service_get_parent                   (TrackerService *service);
+const gchar *   tracker_service_get_property_prefix          (TrackerService *service);
 const gchar *   tracker_service_get_content_metadata         (TrackerService *service);
 const GSList *  tracker_service_get_key_metadata             (TrackerService *service);
 TrackerDBType   tracker_service_get_db_type                  (TrackerService *service);
@@ -86,6 +87,8 @@
 							      const gchar    *value);
 void            tracker_service_set_parent                   (TrackerService *service,
 							      const gchar    *value);
+void            tracker_service_set_property_prefix          (TrackerService *service,
+							      const gchar    *value);
 void            tracker_service_set_content_metadata         (TrackerService *service,
 							      const gchar    *value);
 void            tracker_service_set_key_metadata             (TrackerService *service,

Modified: branches/indexer-split/src/libtracker-db/tracker-db-manager.c
==============================================================================
--- branches/indexer-split/src/libtracker-db/tracker-db-manager.c	(original)
+++ branches/indexer-split/src/libtracker-db/tracker-db-manager.c	Wed Aug 27 17:19:27 2008
@@ -996,7 +996,7 @@
         TrackerService *service;
         GSList         *new_list = NULL;
         gint            id, i;
-	gchar          *name, *parent, *content_metadata;
+	gchar          *name, *parent, *content_metadata, *property_prefix = NULL;
 	gboolean        enabled, embedded, has_metadata, has_fulltext;
 	gboolean        has_thumbs, show_service_files, show_service_directories;
 
@@ -1006,19 +1006,21 @@
 				   0, &id,
 				   1, &name,
 				   2, &parent,
-				   3, &enabled,
-				   4, &embedded,
-				   5, &has_metadata,
-				   6, &has_fulltext,
-				   7, &has_thumbs,
-				   8, &content_metadata,
-				   10, &show_service_files,
-				   11, &show_service_directories,
+				   3, &property_prefix,
+				   4, &enabled,
+				   5, &embedded,
+				   6, &has_metadata,
+				   7, &has_fulltext,
+				   8, &has_thumbs,
+				   9, &content_metadata,
+				   11, &show_service_files,
+				   12, &show_service_directories,
 				   -1);
 
         tracker_service_set_id (service, id);
         tracker_service_set_name (service, name);
         tracker_service_set_parent (service, parent);
+	tracker_service_set_property_prefix (service, property_prefix);
         tracker_service_set_enabled (service, enabled);
         tracker_service_set_embedded (service, embedded);
         tracker_service_set_has_metadata (service, has_metadata);
@@ -1029,7 +1031,7 @@
         tracker_service_set_show_service_files (service, show_service_files);
         tracker_service_set_show_service_directories (service, show_service_directories);
 
-        for (i = 12; i < 23; i++) {
+        for (i = 13; i < 24; i++) {
 		gchar *metadata;
 
 		tracker_db_result_set_get (result_set, i, &metadata, -1);
@@ -1039,7 +1041,9 @@
 		}
         }
 
-	/* FIXME: is this necessary? */
+	/* FIXME: is this necessary? 
+	 * This values are set as key metadata in default.service already
+	 */
 #if 0
         /* Hack to prevent db change late in the cycle, check the
          * service name matches "Applications", then add some voodoo.
@@ -1062,6 +1066,7 @@
 
 	g_free (name);
 	g_free (parent);
+	g_free (property_prefix);
 	g_free (content_metadata);
 
         return service;

Modified: branches/indexer-split/tests/libtracker-common/tracker-ontology-test.c
==============================================================================
--- branches/indexer-split/tests/libtracker-common/tracker-ontology-test.c	(original)
+++ branches/indexer-split/tests/libtracker-common/tracker-ontology-test.c	Wed Aug 27 17:19:27 2008
@@ -96,10 +96,11 @@
 }
 
 static TrackerService *
-create_service_definition (gint        id, 
-			   const char *name, 
-			   const char *parent, 
-			   gboolean    embedded) 
+create_service_definition (gint         id, 
+			   const gchar *name, 
+			   const gchar *parent, 
+			   const gchar *prefix,
+			   gboolean     embedded) 
 {
         TrackerService *def;
 	/* array_to_list use prepend, so use reverse order here  */
@@ -113,6 +114,7 @@
         tracker_service_set_id (def, id);
         tracker_service_set_name (def, name);
         tracker_service_set_parent (def, parent);
+	tracker_service_set_property_prefix (def, prefix);
         tracker_service_set_db_type (def, TRACKER_DB_TYPE_CONTENT);
         tracker_service_set_enabled (def, FALSE);
         tracker_service_set_embedded (def, embedded);
@@ -140,13 +142,13 @@
 
 	GSList *mimes, *mime_prefixes;
 
-	def = create_service_definition (0, "Test service", "Parent service", TRUE);
-	parent_def = create_service_definition (1, "Parent service", NULL, FALSE);
-        other_def = create_service_definition (2, "Applications", NULL, FALSE);
-        conv_def = create_service_definition (3, "Conversations", NULL, FALSE);
-        gaim_def = create_service_definition (4, "GaimConversations", "Conversations", FALSE);
-        gossip_def = create_service_definition (5, "GossipConversations", "Conversations", FALSE);
-        new_gaim_def = create_service_definition (6, "NewGaimConversations", "GaimConversations", FALSE);
+	def = create_service_definition (0, "Test service", "Parent service", NULL, TRUE);
+	parent_def = create_service_definition (1, "Parent service", NULL, NULL, FALSE);
+        other_def = create_service_definition (2, "Applications", NULL, "App", FALSE);
+        conv_def = create_service_definition (3, "Conversations", NULL, NULL, FALSE);
+        gaim_def = create_service_definition (4, "GaimConversations", "Conversations", NULL, FALSE);
+        gossip_def = create_service_definition (5, "GossipConversations", "Conversations", NULL, FALSE);
+        new_gaim_def = create_service_definition (6, "NewGaimConversations", "GaimConversations", NULL, FALSE);
 
         field_title = create_field_definition ("0", 
                                                "App.Title", 
@@ -358,7 +360,7 @@
 	g_assert (!field_types);
 
 	/* App field types */
-	field_types = tracker_ontology_registered_field_types ("App");
+	field_types = tracker_ontology_registered_field_types ("Applications");
 
 	g_assert_cmpint (1 ,==, g_slist_length (field_types));
 



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