tracker r2279 - in trunk: . data data/dbus src/trackerd
- From: ifrade svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2279 - in trunk: . data data/dbus src/trackerd
- Date: Tue, 30 Sep 2008 11:57:52 +0000 (UTC)
Author: ifrade
Date: Tue Sep 30 11:57:51 2008
New Revision: 2279
URL: http://svn.gnome.org/viewvc/tracker?rev=2279&view=rev
Log:
Added method GetAll in metadata interface
Modified:
trunk/ChangeLog
trunk/data/dbus/tracker-metadata.xml
trunk/data/sqlite-stored-procs.sql
trunk/src/trackerd/tracker-db.c
trunk/src/trackerd/tracker-db.h
trunk/src/trackerd/tracker-metadata.c
trunk/src/trackerd/tracker-metadata.h
Modified: trunk/data/dbus/tracker-metadata.xml
==============================================================================
--- trunk/data/dbus/tracker-metadata.xml (original)
+++ trunk/data/dbus/tracker-metadata.xml Tue Sep 30 11:57:51 2008
@@ -14,6 +14,16 @@
<arg type="as" name="metadata" direction="out" />
</method>
+ <!-- Retrieves all known metadata of the service/uri in an array of
+ key,value
+ -->
+ <method name="GetAll">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="s" name="service_type" direction="in" />
+ <arg type="s" name="uri" direction="in" />
+ <arg type="aas" name="metadata" direction="out" />
+ </method>
+
<!-- Sets specified metadata keys to the specified metadata values
for a service and id pair.
-->
Modified: trunk/data/sqlite-stored-procs.sql
==============================================================================
--- trunk/data/sqlite-stored-procs.sql (original)
+++ trunk/data/sqlite-stored-procs.sql Tue Sep 30 11:57:51 2008
@@ -109,6 +109,8 @@
GetMetadataIDValue SELECT MetadataID, MetadataValue FROM ServiceMetadata WHERE ServiceID = ? ORDER BY MetadataID
GetMetadataIDValueNumeric SELECT MetadataID, MetadataValue FROM ServiceNumericMetadata WHERE ServiceID = ? ORDER BY MetadataID
+GetAllMetadata SELECT MetadataID, MetadataDisplay FROM ServiceMetadata WHERE ServiceID = ? UNION SELECT MetadataID, MetadataValue FROM ServiceKeywordMetadata WHERE ServiceID = ? UNION SELECT MetadataID, upper(MetadataValue) FROM ServiceNumericMetadata WHERE ServiceID = ?;
+
SetMetadataKeyword INSERT INTO ServiceKeywordMetaData (ServiceID, MetaDataID, MetaDataValue) VALUES (?,?,?);
SetMetadata INSERT INTO ServiceMetaData (ServiceID, MetaDataID, MetaDataValue, MetaDataDisplay) VALUES (?,?,?,?);
SetMetadataNumeric INSERT INTO ServiceNumericMetaData (ServiceID, MetaDataID, MetaDataValue) VALUES (?,?,?);
Modified: trunk/src/trackerd/tracker-db.c
==============================================================================
--- trunk/src/trackerd/tracker-db.c (original)
+++ trunk/src/trackerd/tracker-db.c Tue Sep 30 11:57:51 2008
@@ -1247,6 +1247,61 @@
NULL);
}
+static void
+db_result_set_to_ptr_array (TrackerDBResultSet *result_set,
+ GPtrArray **previous)
+{
+ gchar *prop_id_str;
+ gchar *value;
+ TrackerField *field;
+ gboolean valid = result_set != NULL;
+
+ while (valid) {
+ /* Item is a pair (property_name, value) */
+ gchar **item = g_new0 (gchar *, 2);
+
+ tracker_db_result_set_get (result_set, 0, &prop_id_str, 1, &value, -1);
+ item[1] = g_strdup (value);
+
+ field = tracker_ontology_get_field_by_id (GPOINTER_TO_UINT (prop_id_str));
+
+ item[0] = g_strdup (tracker_field_get_name (field));
+
+ g_ptr_array_add (*previous, item);
+
+ valid = tracker_db_result_set_iter_next (result_set);
+ }
+}
+
+GPtrArray *
+tracker_db_metadata_get_all (const gchar *service_type,
+ const gchar *service_id)
+{
+ TrackerDBInterface *iface;
+ TrackerDBResultSet *result_set;
+ GPtrArray *result;
+
+ result = g_ptr_array_new ();
+
+ iface = tracker_db_manager_get_db_interface_by_service (service_type);
+ if (!iface) {
+ g_warning ("Unable to obtain a DB connection for service type '%s'",
+ service_type);
+ return result;
+ }
+
+ result_set = tracker_db_exec_proc (iface, "GetAllMetadata", service_id, service_id, service_id, NULL);
+
+ if (result_set) {
+ db_result_set_to_ptr_array (result_set, &result);
+ g_object_unref (result_set);
+ }
+
+ return result;
+
+}
+
+
TrackerDBResultSet *
tracker_db_metadata_get_array (TrackerDBInterface *iface,
const gchar *service_type,
@@ -2858,13 +2913,13 @@
TrackerDBResultSet *
tracker_db_metadata_get_types (TrackerDBInterface *iface,
- const gchar *class,
- gboolean writeable)
+ const gchar *klass,
+ gboolean writeable)
{
g_return_val_if_fail (TRACKER_IS_DB_INTERFACE (iface), NULL);
- g_return_val_if_fail (class != NULL, NULL);
+ g_return_val_if_fail (klass != NULL, NULL);
- if (strcmp (class, "*") == 0) {
+ if (strcmp (klass, "*") == 0) {
if (writeable) {
return tracker_db_exec_proc (iface,
"GetWriteableMetadataTypes",
@@ -2878,12 +2933,12 @@
if (writeable) {
return tracker_db_exec_proc (iface,
"GetWriteableMetadataTypesLike",
- class,
+ klass,
NULL);
} else {
return tracker_db_exec_proc (iface,
"GetMetadataTypesLike",
- class,
+ klass,
NULL);
}
}
Modified: trunk/src/trackerd/tracker-db.h
==============================================================================
--- trunk/src/trackerd/tracker-db.h (original)
+++ trunk/src/trackerd/tracker-db.h Tue Sep 30 11:57:51 2008
@@ -70,6 +70,8 @@
TrackerDBResultSet *tracker_db_metadata_get (TrackerDBInterface *iface,
const gchar *id,
const gchar *key);
+GPtrArray * tracker_db_metadata_get_all (const gchar *service_type,
+ const gchar *service_id);
TrackerDBResultSet *tracker_db_metadata_get_array (TrackerDBInterface *iface,
const gchar *service_type,
const gchar *service_id,
@@ -100,7 +102,7 @@
const gchar *key,
gboolean update_indexes);
TrackerDBResultSet *tracker_db_metadata_get_types (TrackerDBInterface *iface,
- const gchar *class,
+ const gchar *klass,
gboolean writeable);
/* Search API */
Modified: trunk/src/trackerd/tracker-metadata.c
==============================================================================
--- trunk/src/trackerd/tracker-metadata.c (original)
+++ trunk/src/trackerd/tracker-metadata.c Tue Sep 30 11:57:51 2008
@@ -231,6 +231,58 @@
}
void
+tracker_metadata_get_all (TrackerMetadata *object,
+ const gchar *service_type,
+ const gchar *uri,
+ DBusGMethodInvocation *context,
+ GError **error)
+{
+ guint request_id;
+ gchar *service_id;
+ GPtrArray * values;
+ GError *actual_error = NULL;
+
+ request_id = tracker_dbus_get_next_request_id ();
+
+ tracker_dbus_async_return_if_fail (service_type != NULL, context);
+ tracker_dbus_async_return_if_fail (uri != NULL, context);
+
+ tracker_dbus_request_new (request_id,
+ "DBus request to get all metadata values, "
+ "service type:'%s' uri:'%s'",
+ service_type, uri);
+
+ if (!tracker_ontology_service_is_valid (service_type)) {
+ tracker_dbus_request_failed (request_id,
+ &actual_error,
+ "Service '%s' is invalid or has not been implemented yet",
+ service_type);
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
+ }
+
+ service_id = tracker_db_file_get_id_as_string (service_type, uri);
+ if (!service_id) {
+ tracker_dbus_request_failed (request_id,
+ &actual_error,
+ "Service URI '%s' not found",
+ uri);
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
+ }
+
+ values = tracker_db_metadata_get_all (service_type, service_id);
+
+ dbus_g_method_return (context, values);
+ g_ptr_array_foreach (values, (GFunc)g_strfreev, NULL);
+ g_ptr_array_free (values, TRUE);
+
+ tracker_dbus_request_success (request_id);
+}
+
+void
tracker_metadata_set (TrackerMetadata *object,
const gchar *service_type,
const gchar *uri,
Modified: trunk/src/trackerd/tracker-metadata.h
==============================================================================
--- trunk/src/trackerd/tracker-metadata.h (original)
+++ trunk/src/trackerd/tracker-metadata.h Tue Sep 30 11:57:51 2008
@@ -58,6 +58,11 @@
gchar **keys,
DBusGMethodInvocation *context,
GError **error);
+void tracker_metadata_get_all (TrackerMetadata *object,
+ const gchar *service_type,
+ const gchar *uri,
+ DBusGMethodInvocation *context,
+ GError **error);
void tracker_metadata_set (TrackerMetadata *object,
const gchar *service_type,
const gchar *uri,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]