[tracker/miner-web-review: 37/74] Add ontology property tracker:fulltextNoLimit



commit d45a77953389e0f56329ff6200f13a97a02a5e9a
Author: Mikael Ottela <mikael ottela ixonos com>
Date:   Thu Feb 25 14:50:32 2010 +0100

    Add ontology property tracker:fulltextNoLimit
    
    tracker:fulltextNoLimit will allow disabling minimum word length
    checks for certain properties in the ontology.
    
    For instance short family names are crucial even when short.

 data/ontologies/11-rdf.ontology            |    5 +++
 src/libtracker-common/tracker-property.c   |   44 ++++++++++++++++++++++++++-
 src/libtracker-common/tracker-property.h   |    3 ++
 src/libtracker-data/tracker-data-manager.c |   32 +++++++++++++++++--
 4 files changed, 78 insertions(+), 6 deletions(-)
---
diff --git a/data/ontologies/11-rdf.ontology b/data/ontologies/11-rdf.ontology
index 1e8e02d..421d59b 100644
--- a/data/ontologies/11-rdf.ontology
+++ b/data/ontologies/11-rdf.ontology
@@ -86,6 +86,11 @@ tracker:fulltextIndexed a rdf:Property ;
 	rdfs:domain rdf:Property ;
 	rdfs:range xsd:boolean .
 
+tracker:fulltextNoLimit a rdf:Property ;
+	nrl:maxCardinality 1 ;
+	rdfs:domain rdf:Property ;
+	rdfs:range xsd:boolean .
+
 tracker:transient a rdf:Property ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain rdf:Property ;
diff --git a/src/libtracker-common/tracker-property.c b/src/libtracker-common/tracker-property.c
index 0e742e2..e1cffac 100644
--- a/src/libtracker-common/tracker-property.c
+++ b/src/libtracker-common/tracker-property.c
@@ -50,6 +50,7 @@ struct _TrackerPropertyPriv {
 	gint           id;
 	gboolean       indexed;
 	gboolean       fulltext_indexed;
+	gboolean       fulltext_no_limit;
 	gboolean       embedded;
 	gboolean       multiple_values;
 	gboolean       filtered;
@@ -80,6 +81,7 @@ enum {
 	PROP_WEIGHT,
 	PROP_INDEXED,
 	PROP_FULLTEXT_INDEXED,
+	PROP_FULLTEXT_NO_LIMIT,
 	PROP_EMBEDDED,
 	PROP_MULTIPLE_VALUES,
 	PROP_FILTERED,
@@ -227,6 +229,13 @@ tracker_property_class_init (TrackerPropertyClass *klass)
 	                                                       TRUE,
 	                                                       G_PARAM_READWRITE));
 	g_object_class_install_property (object_class,
+	                                 PROP_FULLTEXT_NO_LIMIT,
+	                                 g_param_spec_boolean ("fulltext-no-limit",
+	                                                       "fulltext-no-limit",
+	                                                       "Full-text indexing without word length limits",
+	                                                       TRUE,
+	                                                       G_PARAM_READWRITE));
+	g_object_class_install_property (object_class,
 	                                 PROP_EMBEDDED,
 	                                 g_param_spec_boolean ("embedded",
 	                                                       "embedded",
@@ -350,6 +359,9 @@ property_get_property (GObject    *object,
 	case PROP_FULLTEXT_INDEXED:
 		g_value_set_boolean (value, priv->fulltext_indexed);
 		break;
+	case PROP_FULLTEXT_NO_LIMIT:
+		g_value_set_boolean (value, priv->fulltext_no_limit);
+		break;
 	case PROP_IS_NEW:
 		g_value_set_boolean (value, priv->is_new);
 		break;
@@ -417,6 +429,10 @@ property_set_property (GObject      *object,
 		tracker_property_set_fulltext_indexed (TRACKER_PROPERTY (object),
 		                                       g_value_get_boolean (value));
 		break;
+	case PROP_FULLTEXT_NO_LIMIT:
+		tracker_property_set_fulltext_no_limit (TRACKER_PROPERTY (object),
+							g_value_get_boolean (value));
+		break;
 	case PROP_EMBEDDED:
 		tracker_property_set_embedded (TRACKER_PROPERTY (object),
 		                               g_value_get_boolean (value));
@@ -593,7 +609,6 @@ tracker_property_get_indexed (TrackerProperty *field)
 	return priv->indexed;
 }
 
-
 gboolean
 tracker_property_get_fulltext_indexed (TrackerProperty *field)
 {
@@ -607,6 +622,18 @@ tracker_property_get_fulltext_indexed (TrackerProperty *field)
 }
 
 gboolean
+tracker_property_get_fulltext_no_limit (TrackerProperty *field)
+{
+	TrackerPropertyPriv *priv;
+
+	g_return_val_if_fail (TRACKER_IS_PROPERTY (field), FALSE);
+
+	priv = GET_PRIV (field);
+
+	return priv->fulltext_no_limit;
+}
+
+gboolean
 tracker_property_get_is_new (TrackerProperty *field)
 {
 	TrackerPropertyPriv *priv;
@@ -630,7 +657,6 @@ tracker_property_get_embedded (TrackerProperty *field)
 	return priv->embedded;
 }
 
-
 gboolean
 tracker_property_get_multiple_values (TrackerProperty *field)
 {
@@ -885,6 +911,20 @@ tracker_property_set_fulltext_indexed (TrackerProperty *field,
 }
 
 void
+tracker_property_set_fulltext_no_limit (TrackerProperty *field,
+                                       gboolean                 value)
+{
+	TrackerPropertyPriv *priv;
+
+	g_return_if_fail (TRACKER_IS_PROPERTY (field));
+
+	priv = GET_PRIV (field);
+
+	priv->fulltext_no_limit = value;
+	g_object_notify (G_OBJECT (field), "fulltext-no-limit");
+}
+
+void
 tracker_property_set_embedded (TrackerProperty *field,
                                gboolean                 value)
 {
diff --git a/src/libtracker-common/tracker-property.h b/src/libtracker-common/tracker-property.h
index 7cb4e02..297438f 100644
--- a/src/libtracker-common/tracker-property.h
+++ b/src/libtracker-common/tracker-property.h
@@ -82,6 +82,7 @@ gint                tracker_property_get_weight           (TrackerProperty
 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_fulltext_no_limit(TrackerProperty      *property);
 gboolean            tracker_property_get_embedded         (TrackerProperty      *property);
 gboolean            tracker_property_get_multiple_values  (TrackerProperty      *property);
 gboolean            tracker_property_get_filtered         (TrackerProperty      *property);
@@ -106,6 +107,8 @@ void                tracker_property_set_indexed          (TrackerProperty
                                                            gboolean              value);
 void                tracker_property_set_fulltext_indexed (TrackerProperty      *property,
                                                            gboolean              value);
+void                tracker_property_set_fulltext_no_limit(TrackerProperty      *property,
+                                                           gboolean              value);
 void                tracker_property_set_embedded         (TrackerProperty      *property,
                                                            gboolean              value);
 void                tracker_property_set_multiple_values  (TrackerProperty      *property,
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 86fe7fa..1978c28 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -323,6 +323,18 @@ load_ontology_statement (const gchar *ontology_file,
 		if (strcmp (object, "true") == 0) {
 			tracker_property_set_fulltext_indexed (property, TRUE);
 		}
+	} else if (g_strcmp0 (predicate, TRACKER_PREFIX "fulltextNoLimit") == 0) {
+		TrackerProperty *property;
+
+		property = tracker_ontologies_get_property_by_uri (subject);
+		if (property == NULL) {
+			g_critical ("%s: Unknown property %s", ontology_file, subject);
+			return;
+		}
+
+		if (strcmp (object, "true") == 0) {
+			tracker_property_set_fulltext_no_limit (property, TRUE);
+		}
 	} else if (g_strcmp0 (predicate, TRACKER_PREFIX "prefix") == 0) {
 		TrackerNamespace *namespace;
 
@@ -974,6 +986,7 @@ db_get_static_data (TrackerDBInterface *iface)
 	                                              "\"nrl:maxCardinality\", "
 	                                              "\"tracker:indexed\", "
 	                                              "\"tracker:fulltextIndexed\", "
+	                                              "\"tracker:fulltextNoLimit\", "
 	                                              "\"tracker:transient\", "
 	                                              "\"tracker:isAnnotation\", "
 	                                              "(SELECT 1 FROM \"rdfs:Resource_rdf:type\" WHERE ID = \"rdf:Property\".ID AND "
@@ -988,7 +1001,7 @@ db_get_static_data (TrackerDBInterface *iface)
 			GValue value = { 0 };
 			TrackerProperty *property;
 			const gchar     *uri, *domain_uri, *range_uri;
-			gboolean         multi_valued, indexed, fulltext_indexed;
+			gboolean         multi_valued, indexed, fulltext_indexed, fulltext_no_limit;
 			gboolean         transient, annotation, is_inverse_functional_property;
 			gint             id;
 
@@ -1033,6 +1046,16 @@ db_get_static_data (TrackerDBInterface *iface)
 			tracker_db_cursor_get_value (cursor, 7, &value);
 
 			if (G_VALUE_TYPE (&value) != 0) {
+				fulltext_no_limit = (g_value_get_int (&value) == 1);
+				g_value_unset (&value);
+			} else {
+				/* NULL */
+				fulltext_no_limit = FALSE;
+			}
+
+			tracker_db_cursor_get_value (cursor, 8, &value);
+
+			if (G_VALUE_TYPE (&value) != 0) {
 				transient = (g_value_get_int (&value) == 1);
 				g_value_unset (&value);
 			} else {
@@ -1040,7 +1063,7 @@ db_get_static_data (TrackerDBInterface *iface)
 				transient = FALSE;
 			}
 
-			tracker_db_cursor_get_value (cursor, 8, &value);
+			tracker_db_cursor_get_value (cursor, 9, &value);
 
 			if (G_VALUE_TYPE (&value) != 0) {
 				annotation = (g_value_get_int (&value) == 1);
@@ -1050,7 +1073,7 @@ db_get_static_data (TrackerDBInterface *iface)
 				annotation = FALSE;
 			}
 
-			tracker_db_cursor_get_value (cursor, 9, &value);
+			tracker_db_cursor_get_value (cursor, 10, &value);
 
 			if (G_VALUE_TYPE (&value) != 0) {
 				is_inverse_functional_property = TRUE;
@@ -1069,13 +1092,14 @@ db_get_static_data (TrackerDBInterface *iface)
 			tracker_property_set_multiple_values (property, multi_valued);
 			tracker_property_set_indexed (property, indexed);
 			tracker_property_set_fulltext_indexed (property, fulltext_indexed);
+			tracker_property_set_fulltext_no_limit (property, fulltext_no_limit);
 			tracker_property_set_embedded (property, !annotation);
 			tracker_property_set_is_inverse_functional_property (property, is_inverse_functional_property);
 			property_add_super_properties_from_db (iface, property);
 
 			tracker_ontologies_add_property (property);
 			tracker_ontologies_add_id_uri_pair (id, uri);
-			
+
 			g_object_unref (property);
 
 		}



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