Commit 6f23f896 authored by Mikael Ottela's avatar Mikael Ottela

Added support for order fields in field-data

svn path=/trunk/; revision=2952
parent d82941fc
2009-02-20 Mikael Ottela <mikael.ottela@ixonos.com>
* src/libtracker-data/tracker-data-schema.c
* src/libtracker-data/tracker-field-data.c
* src/libtracker-data/tracker-field-data.h: Added support for
order-fields.
2009-02-20 Mikael Ottela <mikael.ottela@ixonos.com>
* data/db/sqlite-stored-procs.sql:
......
......@@ -221,6 +221,7 @@ tracker_data_schema_get_metadata_field (TrackerDBInterface *iface,
const gchar *table_name;
gchar *this_field_name;
gchar *where_field;
gchar *order_field;
field_data = g_object_new (TRACKER_TYPE_FIELD_DATA,
"is-select", is_select,
......@@ -273,6 +274,18 @@ tracker_data_schema_get_metadata_field (TrackerDBInterface *iface,
}
tracker_field_data_set_where_field (field_data, where_field);
if ((tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_DOUBLE) ||
(tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_INDEX) ||
(tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_STRING)) {
order_field = g_strdup_printf ("M%d.MetaDataCollation", field_count);
tracker_field_data_set_needs_join (field_data, TRUE);
} else {
order_field = g_strdup_printf ("M%d.MetaDataValue", field_count);
}
tracker_field_data_set_order_field (field_data, order_field);
tracker_field_data_set_needs_null (field_data, FALSE);
g_free (where_field);
g_free (alias);
......
......@@ -38,6 +38,7 @@ struct _TrackerFieldDataPriv {
gchar *select_field;
gchar *where_field;
gchar *order_field;
gchar *id_field;
TrackerFieldType data_type;
......@@ -66,6 +67,7 @@ enum {
PROP_FIELD_NAME,
PROP_SELECT_FIELD,
PROP_WHERE_FIELD,
PROP_ORDER_FIELD,
PROP_ID_FIELD,
PROP_DATA_TYPE,
PROP_MULTIPLE_VALUES,
......@@ -121,6 +123,13 @@ tracker_field_data_class_init (TrackerFieldDataClass *klass)
"Where field",
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_ORDER_FIELD,
g_param_spec_string ("order-field",
"Order field",
"Order field",
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_ID_FIELD,
g_param_spec_string ("id-field",
......@@ -193,6 +202,7 @@ field_data_finalize (GObject *object)
g_free (priv->select_field);
g_free (priv->where_field);
g_free (priv->order_field);
g_free (priv->id_field);
(G_OBJECT_CLASS (tracker_field_data_parent_class)->finalize) (object);
......@@ -223,6 +233,8 @@ field_data_get_property (GObject *object,
break;
case PROP_WHERE_FIELD:
g_value_set_string (value, priv->where_field);
case PROP_ORDER_FIELD:
g_value_set_string (value, priv->order_field);
break;
case PROP_ID_FIELD:
g_value_set_string (value, priv->id_field);
......@@ -278,6 +290,10 @@ field_data_set_property (GObject *object,
tracker_field_data_set_where_field (TRACKER_FIELD_DATA (object),
g_value_get_string (value));
break;
case PROP_ORDER_FIELD:
tracker_field_data_set_order_field (TRACKER_FIELD_DATA (object),
g_value_get_string (value));
break;
case PROP_ID_FIELD:
tracker_field_data_set_id_field (TRACKER_FIELD_DATA (object),
g_value_get_string (value));
......@@ -382,6 +398,18 @@ tracker_field_data_get_where_field (TrackerFieldData *field_data)
return priv->where_field;
}
const gchar *
tracker_field_data_get_order_field (TrackerFieldData *field_data)
{
TrackerFieldDataPriv *priv;
g_return_val_if_fail (TRACKER_IS_FIELD_DATA (field_data), NULL);
priv = GET_PRIV (field_data);
return priv->order_field;
}
const gchar *
tracker_field_data_get_id_field (TrackerFieldData *field_data)
{
......@@ -572,6 +600,27 @@ tracker_field_data_set_where_field (TrackerFieldData *field_data,
g_object_notify (G_OBJECT (field_data), "where-field");
}
void
tracker_field_data_set_order_field (TrackerFieldData *field_data,
const gchar *value)
{
TrackerFieldDataPriv *priv;
g_return_if_fail (TRACKER_IS_FIELD_DATA (field_data));
priv = GET_PRIV (field_data);
g_free (priv->order_field);
if (value) {
priv->order_field = g_strdup (value);
} else {
priv->order_field = NULL;
}
g_object_notify (G_OBJECT (field_data), "order-field");
}
void
tracker_field_data_set_id_field (TrackerFieldData *field_data,
const gchar *value)
......
......@@ -55,6 +55,7 @@ const gchar * tracker_field_data_get_table_name (TrackerFieldData *field_data
const gchar * tracker_field_data_get_field_name (TrackerFieldData *field_data);
const gchar * tracker_field_data_get_select_field (TrackerFieldData *field_data);
const gchar * tracker_field_data_get_where_field (TrackerFieldData *field_data);
const gchar * tracker_field_data_get_order_field (TrackerFieldData *field_data);
const gchar * tracker_field_data_get_id_field (TrackerFieldData *field_data);
TrackerFieldType tracker_field_data_get_data_type (TrackerFieldData *field_data);
gboolean tracker_field_data_get_multiple_values (TrackerFieldData *field_data);
......@@ -73,6 +74,8 @@ void tracker_field_data_set_select_field (TrackerFieldData *field_data,
const gchar *value);
void tracker_field_data_set_where_field (TrackerFieldData *field_data,
const gchar *value);
void tracker_field_data_set_order_field (TrackerFieldData *field_data,
const gchar *value);
void tracker_field_data_set_id_field (TrackerFieldData *field_data,
const gchar *value);
void tracker_field_data_set_data_type (TrackerFieldData *field_data,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment