[tracker] Support nrl:InverseFunctionalProperty in .ontology files
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker] Support nrl:InverseFunctionalProperty in .ontology files
- Date: Thu, 12 Nov 2009 14:31:43 +0000 (UTC)
commit 64fd424d40aedb8f7e651c8dbd7854249da26f08
Author: Jürg Billeter <j bitron ch>
Date: Tue Nov 3 12:53:29 2009 +0100
Support nrl:InverseFunctionalProperty in .ontology files
data/ontologies/12-nrl.ontology | 2 +
src/libtracker-common/tracker-property.c | 45 +++++++++++++++++++++++++++-
src/libtracker-common/tracker-property.h | 5 +++
src/libtracker-data/tracker-data-manager.c | 27 +++++++++++++++-
4 files changed, 76 insertions(+), 3 deletions(-)
---
diff --git a/data/ontologies/12-nrl.ontology b/data/ontologies/12-nrl.ontology
index b8a5954..62e76db 100644
--- a/data/ontologies/12-nrl.ontology
+++ b/data/ontologies/12-nrl.ontology
@@ -7,6 +7,8 @@
nrl: a tracker:Namespace ;
tracker:prefix "nrl" .
+nrl:InverseFunctionalProperty a rdfs:Class .
+
nrl:maxCardinality 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 a0b4b1d..79d7b26 100644
--- a/src/libtracker-common/tracker-property.c
+++ b/src/libtracker-common/tracker-property.c
@@ -54,6 +54,7 @@ struct _TrackerPropertyPriv {
gboolean multiple_values;
gboolean filtered;
gboolean transient;
+ gboolean is_inverse_functional_property;
GArray *super_properties;
};
@@ -81,7 +82,8 @@ enum {
PROP_EMBEDDED,
PROP_MULTIPLE_VALUES,
PROP_FILTERED,
- PROP_TRANSIENT
+ PROP_TRANSIENT,
+ PROP_IS_INVERSE_FUNCTIONAL_PROPERTY
};
GType
@@ -240,6 +242,14 @@ tracker_property_class_init (TrackerPropertyClass *klass)
"Transient",
FALSE,
G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_IS_INVERSE_FUNCTIONAL_PROPERTY,
+ g_param_spec_boolean ("is-inverse-functional-property",
+ "is-inverse-functional-property",
+ "Is inverse functional property",
+ FALSE,
+ G_PARAM_READWRITE));
+
g_type_class_add_private (object_class, sizeof (TrackerPropertyPriv));
}
@@ -321,6 +331,9 @@ property_get_property (GObject *object,
case PROP_TRANSIENT:
g_value_set_boolean (value, priv->transient);
break;
+ case PROP_IS_INVERSE_FUNCTIONAL_PROPERTY:
+ g_value_set_boolean (value, priv->is_inverse_functional_property);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -378,6 +391,10 @@ property_set_property (GObject *object,
tracker_property_set_transient (TRACKER_PROPERTY (object),
g_value_get_boolean (value));
break;
+ case PROP_IS_INVERSE_FUNCTIONAL_PROPERTY:
+ tracker_property_set_is_inverse_functional_property (TRACKER_PROPERTY (object),
+ g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -574,6 +591,18 @@ tracker_property_get_filtered (TrackerProperty *field)
return priv->filtered;
}
+gboolean
+tracker_property_get_is_inverse_functional_property (TrackerProperty *property)
+{
+ TrackerPropertyPriv *priv;
+
+ g_return_val_if_fail (TRACKER_IS_PROPERTY (property), FALSE);
+
+ priv = GET_PRIV (property);
+
+ return priv->is_inverse_functional_property;
+}
+
TrackerProperty **
tracker_property_get_super_properties (TrackerProperty *property)
{
@@ -812,6 +841,20 @@ tracker_property_set_filtered (TrackerProperty *field,
}
void
+tracker_property_set_is_inverse_functional_property (TrackerProperty *property,
+ gboolean value)
+{
+ TrackerPropertyPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_PROPERTY (property));
+
+ priv = GET_PRIV (property);
+
+ priv->is_inverse_functional_property = value;
+ g_object_notify (G_OBJECT (property), "is-inverse-functional-property");
+}
+
+void
tracker_property_set_super_properties (TrackerProperty *property,
TrackerProperty **value)
{
diff --git a/src/libtracker-common/tracker-property.h b/src/libtracker-common/tracker-property.h
index 794e114..e6264b7 100644
--- a/src/libtracker-common/tracker-property.h
+++ b/src/libtracker-common/tracker-property.h
@@ -86,6 +86,8 @@ gboolean tracker_property_get_embedded (TrackerProperty
gboolean tracker_property_get_multiple_values (TrackerProperty *property);
gboolean tracker_property_get_filtered (TrackerProperty *property);
gboolean tracker_property_get_transient (TrackerProperty *property);
+gboolean tracker_property_get_is_inverse_functional_property
+ (TrackerProperty *property);
TrackerProperty ** tracker_property_get_super_properties (TrackerProperty *property);
void tracker_property_set_uri (TrackerProperty *property,
const gchar *value);
@@ -109,6 +111,9 @@ void tracker_property_set_filtered (TrackerProperty
gboolean value);
void tracker_property_set_transient (TrackerProperty *property,
gboolean value);
+void tracker_property_set_is_inverse_functional_property
+ (TrackerProperty *property,
+ gboolean value);
void tracker_property_set_super_properties (TrackerProperty *property,
TrackerProperty **super_properties);
void tracker_property_add_super_property (TrackerProperty *property,
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 57c4de5..bb0a9eb 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -108,6 +108,16 @@ load_ontology_file_from_path (const gchar *ontology_file)
tracker_property_set_uri (property, subject);
tracker_ontology_add_property (property);
g_object_unref (property);
+ } else if (g_strcmp0 (object, NRL_PREFIX "InverseFunctionalProperty") == 0) {
+ TrackerProperty *property;
+
+ property = tracker_ontology_get_property_by_uri (subject);
+ if (property == NULL) {
+ g_critical ("%s: Unknown property %s", ontology_file, subject);
+ continue;
+ }
+
+ tracker_property_set_is_inverse_functional_property (property, TRUE);
} else if (g_strcmp0 (object, TRACKER_PREFIX "Namespace") == 0) {
TrackerNamespace *namespace;
@@ -434,7 +444,9 @@ db_get_static_data (TrackerDBInterface *iface)
"\"tracker:indexed\", "
"\"tracker:fulltextIndexed\", "
"\"tracker:transient\", "
- "\"tracker:isAnnotation\" "
+ "\"tracker:isAnnotation\", "
+ "(SELECT 1 FROM \"rdfs:Resource_rdf:type\" WHERE ID = \"rdf:Property\".ID AND "
+ "\"rdf:type\" = (Select ID FROM \"rdfs:Resource\" WHERE Uri = '" NRL_PREFIX "InverseFunctionalProperty')) "
"FROM \"rdf:Property\" ORDER BY ID");
cursor = tracker_db_statement_start_cursor (stmt, NULL);
g_object_unref (stmt);
@@ -446,7 +458,7 @@ db_get_static_data (TrackerDBInterface *iface)
TrackerProperty *property;
const gchar *uri, *domain_uri, *range_uri;
gboolean multi_valued, indexed, fulltext_indexed;
- gboolean transient, annotation;
+ gboolean transient, annotation, is_inverse_functional_property;
gint id;
property = tracker_property_new ();
@@ -507,6 +519,16 @@ db_get_static_data (TrackerDBInterface *iface)
annotation = FALSE;
}
+ tracker_db_cursor_get_value (cursor, 8, &value);
+
+ if (G_VALUE_TYPE (&value) != 0) {
+ is_inverse_functional_property = (g_value_get_int (&value) == 1);
+ g_value_unset (&value);
+ } else {
+ /* NULL */
+ is_inverse_functional_property = FALSE;
+ }
+
tracker_property_set_transient (property, transient);
tracker_property_set_uri (property, uri);
tracker_property_set_domain (property, tracker_ontology_get_class_by_uri (domain_uri));
@@ -515,6 +537,7 @@ db_get_static_data (TrackerDBInterface *iface)
tracker_property_set_indexed (property, indexed);
tracker_property_set_fulltext_indexed (property, fulltext_indexed);
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_ontology_add_property (property);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]