[tracker/binary-log] Added tracker_class_get/set_id and tracker_property_get/set_id



commit d0a1e8eb2b808b09807bf065eb1dac9b52cb6a90
Author: Philip Van Hoof <philip codeminded be>
Date:   Thu Dec 31 11:45:21 2009 +0100

    Added tracker_class_get/set_id and tracker_property_get/set_id

 src/libtracker-common/tracker-class.c      |   48 +++++++++++++++++++++++++++-
 src/libtracker-common/tracker-class.h      |    4 ++
 src/libtracker-common/tracker-property.c   |   45 +++++++++++++++++++++++++-
 src/libtracker-common/tracker-property.h   |    3 ++
 src/libtracker-data/tracker-data-manager.c |   21 ++++++++++--
 src/libtracker-db/tracker-db-journal.c     |    2 +-
 6 files changed, 116 insertions(+), 7 deletions(-)
---
diff --git a/src/libtracker-common/tracker-class.c b/src/libtracker-common/tracker-class.c
index 4c8dd2b..1f81dfe 100644
--- a/src/libtracker-common/tracker-class.c
+++ b/src/libtracker-common/tracker-class.c
@@ -37,6 +37,7 @@ struct _TrackerClassPriv {
 	gchar *uri;
 	gchar *name;
 	gint count;
+	gint id;
 
 	GArray *super_classes;
 };
@@ -55,7 +56,8 @@ enum {
 	PROP_0,
 	PROP_URI,
 	PROP_NAME,
-	PROP_COUNT
+	PROP_COUNT,
+	PROP_ID
 };
 
 G_DEFINE_TYPE (TrackerClass, tracker_class, G_TYPE_OBJECT);
@@ -89,6 +91,15 @@ tracker_class_class_init (TrackerClassClass *klass)
 	                                                   "count",
 	                                                   "Count",
 	                                                   0,
+	                                                   G_MAXINT,
+	                                                   0,
+	                                                   G_PARAM_READWRITE));
+	g_object_class_install_property (object_class,
+	                                 PROP_ID,
+	                                 g_param_spec_int ("id",
+	                                                   "id",
+	                                                   "Id",
+	                                                   0,
 	                                                   INT_MAX,
 	                                                   0,
 	                                                   G_PARAM_READABLE | G_PARAM_WRITABLE));
@@ -103,6 +114,7 @@ tracker_class_init (TrackerClass *service)
 
 	priv = GET_PRIV (service);
 
+	priv->id = -1;
 	priv->super_classes = g_array_new (TRUE, TRUE, sizeof (TrackerClass *));
 }
 
@@ -141,6 +153,9 @@ class_get_property (GObject    *object,
 	case PROP_COUNT:
 		g_value_set_int (value, priv->count);
 		break;
+	case PROP_ID:
+		g_value_set_int (value, priv->id);
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
 		break;
@@ -162,6 +177,10 @@ class_set_property (GObject      *object,
 		tracker_class_set_count (TRACKER_CLASS (object),
 		                         g_value_get_int (value));
 		break;
+	case PROP_ID:
+		tracker_class_set_id (TRACKER_CLASS (object),
+		                      g_value_get_int (value));
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
 		break;
@@ -214,6 +233,18 @@ tracker_class_get_count (TrackerClass *service)
 	return priv->count;
 }
 
+gint
+tracker_class_get_id (TrackerClass *service)
+{
+	TrackerClassPriv *priv;
+
+	g_return_val_if_fail (TRACKER_IS_CLASS (service), 0);
+
+	priv = GET_PRIV (service);
+
+	return priv->id;
+}
+
 TrackerClass **
 tracker_class_get_super_classes (TrackerClass *service)
 {
@@ -282,6 +313,21 @@ tracker_class_set_count (TrackerClass *service,
 	priv->count = value;
 }
 
+
+void
+tracker_class_set_id (TrackerClass *service,
+                      gint          value)
+{
+	TrackerClassPriv *priv;
+
+	g_return_if_fail (TRACKER_IS_CLASS (service));
+
+	priv = GET_PRIV (service);
+
+	priv->id = value;
+}
+
+
 void
 tracker_class_set_super_classes (TrackerClass  *service,
                                  TrackerClass **value)
diff --git a/src/libtracker-common/tracker-class.h b/src/libtracker-common/tracker-class.h
index 44c2015..ceca625 100644
--- a/src/libtracker-common/tracker-class.h
+++ b/src/libtracker-common/tracker-class.h
@@ -52,6 +52,8 @@ TrackerClass *  tracker_class_new               (void);
 const gchar *   tracker_class_get_uri           (TrackerClass  *service);
 const gchar *   tracker_class_get_name          (TrackerClass  *service);
 gint            tracker_class_get_count         (TrackerClass  *service);
+gint            tracker_class_get_id            (TrackerClass  *service);
+
 TrackerClass  **tracker_class_get_super_classes (TrackerClass  *service);
 void            tracker_class_set_uri           (TrackerClass  *service,
                                                  const gchar   *value);
@@ -61,6 +63,8 @@ void            tracker_class_set_super_classes (TrackerClass  *self,
                                                  TrackerClass **super_classes);
 void            tracker_class_add_super_class   (TrackerClass  *self,
                                                  TrackerClass  *value);
+void            tracker_class_set_id            (TrackerClass  *service,
+                                                 gint           id);
 
 G_END_DECLS
 
diff --git a/src/libtracker-common/tracker-property.c b/src/libtracker-common/tracker-property.c
index a53fa27..5f1ca2b 100644
--- a/src/libtracker-common/tracker-property.c
+++ b/src/libtracker-common/tracker-property.c
@@ -47,6 +47,7 @@ struct _TrackerPropertyPriv {
 	TrackerClass   *domain;
 	TrackerClass   *range;
 	gint           weight;
+	gint           id;
 	gboolean       indexed;
 	gboolean       fulltext_indexed;
 	gboolean       embedded;
@@ -82,7 +83,8 @@ enum {
 	PROP_MULTIPLE_VALUES,
 	PROP_FILTERED,
 	PROP_TRANSIENT,
-	PROP_IS_INVERSE_FUNCTIONAL_PROPERTY
+	PROP_IS_INVERSE_FUNCTIONAL_PROPERTY,
+	PROP_ID
 };
 
 GType
@@ -200,6 +202,15 @@ tracker_property_class_init (TrackerPropertyClass *klass)
 	                                                   1,
 	                                                   G_PARAM_READWRITE));
 	g_object_class_install_property (object_class,
+	                                 PROP_ID,
+	                                 g_param_spec_int ("id",
+	                                                   "id",
+	                                                   "Id",
+	                                                   0,
+	                                                   G_MAXINT,
+	                                                   1,
+	                                                   G_PARAM_READWRITE));
+	g_object_class_install_property (object_class,
 	                                 PROP_INDEXED,
 	                                 g_param_spec_boolean ("indexed",
 	                                                       "indexed",
@@ -260,6 +271,7 @@ tracker_property_init (TrackerProperty *field)
 
 	priv = GET_PRIV (field);
 
+	priv->id = -1;
 	priv->weight = 1;
 	priv->embedded = TRUE;
 	priv->filtered = TRUE;
@@ -320,6 +332,9 @@ property_get_property (GObject    *object,
 	case PROP_WEIGHT:
 		g_value_set_int (value, priv->weight);
 		break;
+	case PROP_ID:
+		g_value_set_int (value, priv->id);
+		break;
 	case PROP_INDEXED:
 		g_value_set_boolean (value, priv->indexed);
 		break;
@@ -374,6 +389,10 @@ property_set_property (GObject      *object,
 		tracker_property_set_weight (TRACKER_PROPERTY (object),
 		                             g_value_get_int (value));
 		break;
+	case PROP_ID:
+		tracker_property_set_id (TRACKER_PROPERTY (object),
+		                         g_value_get_int (value));
+		break;
 	case PROP_INDEXED:
 		tracker_property_set_indexed (TRACKER_PROPERTY (object),
 		                              g_value_get_boolean (value));
@@ -534,6 +553,17 @@ tracker_property_get_weight (TrackerProperty *field)
 	return priv->weight;
 }
 
+gint
+tracker_property_get_id (TrackerProperty *field)
+{
+	TrackerPropertyPriv *priv;
+
+	g_return_val_if_fail (TRACKER_IS_PROPERTY (field), -1);
+
+	priv = GET_PRIV (field);
+
+	return priv->id;
+}
 
 gboolean
 tracker_property_get_indexed (TrackerProperty *field)
@@ -772,6 +802,19 @@ tracker_property_set_weight (TrackerProperty *field,
 	g_object_notify (G_OBJECT (field), "weight");
 }
 
+
+void
+tracker_property_set_id (TrackerProperty *field,
+                         gint             value)
+{
+	TrackerPropertyPriv *priv;
+	g_return_if_fail (TRACKER_IS_PROPERTY (field));
+
+	priv = GET_PRIV (field);
+
+	priv->id = value;
+}
+
 void
 tracker_property_set_indexed (TrackerProperty *field,
                               gboolean         value)
diff --git a/src/libtracker-common/tracker-property.h b/src/libtracker-common/tracker-property.h
index 6512c42..1ec000d 100644
--- a/src/libtracker-common/tracker-property.h
+++ b/src/libtracker-common/tracker-property.h
@@ -79,6 +79,7 @@ TrackerPropertyType tracker_property_get_data_type        (TrackerProperty
 TrackerClass *      tracker_property_get_domain           (TrackerProperty      *property);
 TrackerClass *      tracker_property_get_range            (TrackerProperty      *property);
 gint                tracker_property_get_weight           (TrackerProperty      *property);
+gint                tracker_property_get_id               (TrackerProperty      *property);
 gboolean            tracker_property_get_indexed          (TrackerProperty      *property);
 gboolean            tracker_property_get_fulltext_indexed (TrackerProperty      *property);
 gboolean            tracker_property_get_embedded         (TrackerProperty      *property);
@@ -98,6 +99,8 @@ void                tracker_property_set_range            (TrackerProperty
                                                            TrackerClass         *range);
 void                tracker_property_set_weight           (TrackerProperty      *property,
                                                            gint                  value);
+void                tracker_property_set_id               (TrackerProperty      *property,
+                                                           gint                  value);
 void                tracker_property_set_indexed          (TrackerProperty      *property,
                                                            gboolean              value);
 void                tracker_property_set_fulltext_indexed (TrackerProperty      *property,
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 504fa4c..608a1a5 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -419,6 +419,7 @@ db_get_static_data (TrackerDBInterface *iface)
 
 			tracker_ontology_add_class (class);
 			tracker_ontology_add_id_uri_pair (id, uri);
+			tracker_class_set_id (class, id);
 
 			/* xsd classes do not derive from rdfs:Resource and do not use separate tables */
 			if (!g_str_has_prefix (tracker_class_get_name (class), "xsd:")) {
@@ -532,6 +533,7 @@ db_get_static_data (TrackerDBInterface *iface)
 
 			tracker_property_set_transient (property, transient);
 			tracker_property_set_uri (property, uri);
+			tracker_property_set_id (property, id);
 			tracker_property_set_domain (property, tracker_ontology_get_class_by_uri (domain_uri));
 			tracker_property_set_range (property, tracker_ontology_get_class_by_uri (range_uri));
 			tracker_property_set_multiple_values (property, multi_valued);
@@ -543,7 +545,7 @@ db_get_static_data (TrackerDBInterface *iface)
 
 			tracker_ontology_add_property (property);
 			tracker_ontology_add_id_uri_pair (id, uri);
-
+			
 			g_object_unref (property);
 
 		}
@@ -554,7 +556,11 @@ db_get_static_data (TrackerDBInterface *iface)
 
 
 static void
-insert_uri_in_resource_table (TrackerDBInterface *iface, const gchar *uri, gint *max_id)
+insert_uri_in_resource_table (TrackerDBInterface *iface, 
+                              const gchar *uri, 
+                              gint *max_id,
+                              TrackerClass *class,
+                              TrackerProperty *property)
 {
 	TrackerDBStatement *stmt;
 	gint id = ++(*max_id);
@@ -577,6 +583,13 @@ insert_uri_in_resource_table (TrackerDBInterface *iface, const gchar *uri, gint
 	}
 
 	tracker_ontology_add_id_uri_pair (id, uri);
+
+	if (class)
+		tracker_class_set_id (class, id);
+
+	if (property)
+		tracker_property_set_id (property, id);
+
 	g_object_unref (stmt);
 
 }
@@ -745,7 +758,7 @@ create_decomposed_metadata_tables (TrackerDBInterface *iface,
 	/* insert class uri in rdfs:Resource table */
 	if (tracker_class_get_uri (service) != NULL) {
 		insert_uri_in_resource_table (iface, tracker_class_get_uri (service),
-		                              max_id);
+		                              max_id, service, NULL);
 	}
 
 	g_slist_free (class_properties);
@@ -900,7 +913,7 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 
 		for (i = 0; i < n_props; i++) {
 			insert_uri_in_resource_table (iface, tracker_property_get_uri (properties[i]),
-			                              &max_id);
+			                              &max_id, NULL, properties[i]);
 		}
 
 		create_fts_table (iface);
diff --git a/src/libtracker-db/tracker-db-journal.c b/src/libtracker-db/tracker-db-journal.c
index 6ede989..aa8d305 100644
--- a/src/libtracker-db/tracker-db-journal.c
+++ b/src/libtracker-db/tracker-db-journal.c
@@ -25,7 +25,7 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <stdio.h>
-#include <string.h>/query
+#include <string.h>
 #include <sys/stat.h>
 #include <unistd.h>
 



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