tracker r2596 - in branches/turtle: . src/libtracker-data src/tracker-indexer
- From: pvanhoof svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2596 - in branches/turtle: . src/libtracker-data src/tracker-indexer
- Date: Thu, 27 Nov 2008 14:35:25 +0000 (UTC)
Author: pvanhoof
Date: Thu Nov 27 14:35:25 2008
New Revision: 2596
URL: http://svn.gnome.org/viewvc/tracker?rev=2596&view=rev
Log:
2008-11-27 Philip Van Hoof <philip codeminded be>
* src/tracker-indexer/tracker-removable-device.c
* src/libtracker-data/tracker-data-metadata.c
* src/libtracker-data/tracker-data-metadata.h: Coping with list-value
values in the Turtle file
Modified:
branches/turtle/ChangeLog
branches/turtle/src/libtracker-data/tracker-data-metadata.c
branches/turtle/src/libtracker-data/tracker-data-metadata.h
branches/turtle/src/tracker-indexer/tracker-removable-device.c
Modified: branches/turtle/src/libtracker-data/tracker-data-metadata.c
==============================================================================
--- branches/turtle/src/libtracker-data/tracker-data-metadata.c (original)
+++ branches/turtle/src/libtracker-data/tracker-data-metadata.c Thu Nov 27 14:35:25 2008
@@ -109,13 +109,49 @@
return;
}
- g_return_if_fail (tracker_field_get_multiple_values (field) == FALSE);
+ g_return_if_fail (tracker_field_get_multiple_values (field) == FALSE);
- g_hash_table_insert (metadata->table,
- g_object_ref (field),
- value);
+ g_hash_table_replace (metadata->table,
+ g_object_ref (field),
+ value);
}
+
+
+/**
+ * tracker_data_metadata_append_to_list:
+ * @metadata: A #TrackerDataMetadata
+ * @field_name: Field name for the metadata to insert.
+ * @value: Value for the metadata to insert.
+ *
+ * Inserts a new metadata element into @metadata.
+ **/
+void
+tracker_data_metadata_append_to_list (TrackerDataMetadata *metadata,
+ const gchar *field_name,
+ gchar *value)
+{
+ TrackerField *field;
+ GList *values;
+
+ field = tracker_ontology_get_field_by_name (field_name);
+
+ if (!field) {
+ g_warning ("Field name '%s' has isn't described in the ontology", field_name);
+ g_free (value);
+ return;
+ }
+
+ g_return_if_fail (tracker_field_get_multiple_values (field) == TRUE);
+
+ values = g_hash_table_lookup (metadata->table, field);
+
+ values = g_list_append (values, value);
+
+ g_hash_table_replace (metadata->table,
+ g_object_ref (field),
+ values);
+}
/**
* tracker_data_metadata_insert_values:
* @metadata: A #TrackerDataMetadata
@@ -137,9 +173,9 @@
g_return_if_fail (TRACKER_IS_FIELD (field));
g_return_if_fail (tracker_field_get_multiple_values (field) == TRUE);
- g_hash_table_insert (metadata->table,
- g_object_ref (field),
- list);
+ g_hash_table_replace (metadata->table,
+ g_object_ref (field),
+ list);
}
/**
Modified: branches/turtle/src/libtracker-data/tracker-data-metadata.h
==============================================================================
--- branches/turtle/src/libtracker-data/tracker-data-metadata.h (original)
+++ branches/turtle/src/libtracker-data/tracker-data-metadata.h Thu Nov 27 14:35:25 2008
@@ -43,6 +43,9 @@
void tracker_data_metadata_insert_values (TrackerDataMetadata *metadata,
const gchar *field_name,
GList *list);
+void tracker_data_metadata_append_to_list (TrackerDataMetadata *metadata,
+ const gchar *field_name,
+ gchar *value);
G_CONST_RETURN gchar *tracker_data_metadata_lookup (TrackerDataMetadata *metadata,
const gchar *field_name);
G_CONST_RETURN GList *tracker_data_metadata_lookup_values (TrackerDataMetadata *metadata,
Modified: branches/turtle/src/tracker-indexer/tracker-removable-device.c
==============================================================================
--- branches/turtle/src/tracker-indexer/tracker-removable-device.c (original)
+++ branches/turtle/src/tracker-indexer/tracker-removable-device.c Thu Nov 27 14:35:25 2008
@@ -209,10 +209,22 @@
/* Change this when Files and Emails becomes File and Email */
info->rdf_type = g_strdup_printf ("%ss", triple->object);
- } else
- tracker_data_metadata_insert (info->metadata,
- predicate,
- g_strdup (triple->object));
+ } else {
+ TrackerField *field;
+
+ field = tracker_ontology_get_field_by_name (predicate);
+ if (field) {
+ if (!tracker_field_get_multiple_values (field)) {
+ tracker_data_metadata_insert (info->metadata,
+ predicate,
+ g_strdup (triple->object));
+ } else {
+ tracker_data_metadata_append_to_list (info->metadata,
+ predicate,
+ g_strdup (triple->object));
+ }
+ }
+ }
} else if (triple->object_type == RAPTOR_IDENTIFIER_TYPE_RESOURCE) {
gchar *key = g_strdup_printf ("file://%s/:", info->base);
@@ -232,7 +244,8 @@
if (triple->object && strcmp (key, triple->object) == 0 &&
triple->predicate && strcmp (key, triple->predicate) != 0)
{
- gchar *predicate;
+ gchar *predicate;
+ TrackerField *field;
/* <URI> <Pfx:Predicate> <:> - is a removal of the
* resource's Pfx:Predicate */
@@ -240,9 +253,19 @@
/* We put NULL here, so that a null value goes into
* SQLite. Perhaps we should change this? If so, Why? */
- tracker_data_metadata_insert (info->metadata,
- predicate,
- NULL);
+
+ field = tracker_ontology_get_field_by_name (predicate);
+ if (field) {
+ if (!tracker_field_get_multiple_values (field)) {
+ tracker_data_metadata_insert (info->metadata,
+ predicate,
+ NULL);
+ } else {
+ tracker_data_metadata_insert_values (info->metadata,
+ predicate,
+ NULL);
+ }
+ }
}
g_free (key);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]