[tracker/wip/carlosg/domain-ontologies: 14/30] ontologies: Build dc/xsd/rdf/nrl/nao as GResource



commit 650ef5f5f6838139f03e4c7315711c75b2e94260
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon May 29 22:51:25 2017 +0200

    ontologies: Build dc/xsd/rdf/nrl/nao as GResource
    
    Those ontology files are the tracker core, as the database files' structure
    is modeled around those classes and properties. Include those as a GResource
    so they're guaranteed to be there, all other ontology files are optional
    and must be provided on TrackerDataManager initialization.
    
    The NAO ontology has been split between the official bits (included in the
    GResource) and the non-official bits (just used by the evolution miner, and
    moved to 90-tracker)

 configure.ac                                  |    3 ++
 src/libtracker-data/Makefile.am               |    2 +
 src/libtracker-data/tracker-data-manager.c    |    7 ++++++
 src/ontologies/11-rdf.ontology                |   15 +++++++++++++
 src/ontologies/31-nao-custom.ontology         |   29 +++++++++++++++++++++++++
 src/ontologies/31-nao.ontology                |   24 --------------------
 src/ontologies/90-tracker.ontology            |   15 -------------
 src/ontologies/Makefile.am                    |   17 +++++++++++++-
 src/ontologies/builtin-ontology.gresource.xml |   10 ++++++++
 9 files changed, 81 insertions(+), 41 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ffdd760..2cf2a56 100644
--- a/configure.ac
+++ b/configure.ac
@@ -898,6 +898,9 @@ AC_SUBST(GLIB_MKENUMS)
 GDBUS_CODEGEN=`$PKG_CONFIG --variable=gdbus_codegen gio-2.0`
 AC_SUBST(GDBUS_CODEGEN)
 
+GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable glib_compile_resources gio-2.0`
+AC_SUBST(GLIB_COMPILE_RESOURCES)
+
 ####################################################################
 # Should we build GLib based unit tests
 ####################################################################
diff --git a/src/libtracker-data/Makefile.am b/src/libtracker-data/Makefile.am
index f7c64be..a47fd84 100644
--- a/src/libtracker-data/Makefile.am
+++ b/src/libtracker-data/Makefile.am
@@ -20,6 +20,8 @@ libtracker_datadir = $(libdir)/tracker-$(TRACKER_API_VERSION)
 libtracker_data_LTLIBRARIES = libtracker-data.la
 
 libtracker_data_la_SOURCES =                           \
+       $(top_builddir)/src/ontologies/tracker-gresources.c \
+       $(top_builddir)/src/ontologies/tracker-gresources.h \
        tracker-vala-namespace.vala                    \
        tracker-sparql-expression.vala                 \
        tracker-sparql-pattern.vala                    \
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 51f4ced..1fca650 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -3455,6 +3455,13 @@ get_ontologies (const gchar  *ontologies_dir,
 
        sorted = g_list_sort (sorted, (GCompareFunc) compare_file_names);
 
+       /* Add our builtin ontologies so they are loaded first */
+       sorted = g_list_prepend (sorted, g_file_new_for_uri 
("resource://org/freedesktop/tracker/ontology/31-nao.ontology"));
+       sorted = g_list_prepend (sorted, g_file_new_for_uri 
("resource://org/freedesktop/tracker/ontology/20-dc.ontology"));
+       sorted = g_list_prepend (sorted, g_file_new_for_uri 
("resource://org/freedesktop/tracker/ontology/12-nrl.ontology"));
+       sorted = g_list_prepend (sorted, g_file_new_for_uri 
("resource://org/freedesktop/tracker/ontology/11-rdf.ontology"));
+       sorted = g_list_prepend (sorted, g_file_new_for_uri 
("resource://org/freedesktop/tracker/ontology/10-xsd.ontology"));
+
        g_object_unref (enumerator);
 
        return sorted;
diff --git a/src/ontologies/11-rdf.ontology b/src/ontologies/11-rdf.ontology
index 869f73e..7f65325 100644
--- a/src/ontologies/11-rdf.ontology
+++ b/src/ontologies/11-rdf.ontology
@@ -133,3 +133,18 @@ tracker:damaged a rdf:Property ;
        nrl:maxCardinality 1 ;
        rdfs:domain rdfs:Resource ;
        rdfs:range xsd:boolean .
+
+tracker:notify a rdf:Property ;
+       nrl:maxCardinality 1 ;
+       rdfs:domain rdfs:Class ;
+       rdfs:range xsd:boolean .
+
+tracker:writeback a rdf:Property ;
+       nrl:maxCardinality 1 ;
+       rdfs:domain rdf:Property ;
+       rdfs:range xsd:boolean .
+
+tracker:forceJournal a rdf:Property ;
+       nrl:maxCardinality 1 ;
+       rdfs:domain rdf:Property ;
+       rdfs:range xsd:boolean .
diff --git a/src/ontologies/31-nao-custom.ontology b/src/ontologies/31-nao-custom.ontology
new file mode 100644
index 0000000..03e9339
--- /dev/null
+++ b/src/ontologies/31-nao-custom.ontology
@@ -0,0 +1,29 @@
+@prefix nao: <http://www.semanticdesktop.org/ontologies/2007/08/15/nao#> .
+@prefix nie: <http://www.semanticdesktop.org/ontologies/2007/01/19/nie#> .
+@prefix nrl: <http://www.semanticdesktop.org/ontologies/2007/08/15/nrl#> .
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+
+# These are added and approval by Nepomuk-upstream should be gotten with an ouija board.
+
+nao:Property a rdfs:Class ;
+       rdfs:label "Custom property to extend a class dynamically" ;
+       rdfs:comment "Dont use this without asking first your ontology doctor" ;
+       rdfs:subClassOf rdfs:Resource .
+
+nao:propertyName a rdf:Property ;
+       nrl:maxCardinality 1 ;
+       rdfs:domain nao:Property ;
+       rdfs:range  xsd:string .
+
+nao:propertyValue a rdf:Property ;
+       nrl:maxCardinality 1 ;
+       rdfs:domain nao:Property ;
+       rdfs:range  xsd:string .
+
+nao:hasProperty a rdf:Property ;
+       rdfs:domain nie:InformationElement ;
+       rdfs:range  nao:Property .
+
+nao:predefined-tag-favorite a nao:Tag .
diff --git a/src/ontologies/31-nao.ontology b/src/ontologies/31-nao.ontology
index 1b3a109..4581d6b 100644
--- a/src/ontologies/31-nao.ontology
+++ b/src/ontologies/31-nao.ontology
@@ -1,6 +1,5 @@
 @prefix dc: <http://purl.org/dc/elements/1.1/> .
 @prefix nao: <http://www.semanticdesktop.org/ontologies/2007/08/15/nao#> .
-@prefix nie: <http://www.semanticdesktop.org/ontologies/2007/01/19/nie#> .
 @prefix nrl: <http://www.semanticdesktop.org/ontologies/2007/08/15/nrl#> .
 @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
 @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@@ -54,29 +53,6 @@ nao:deprecated a rdf:Property;
        rdfs:label "deprecated";
        rdfs:comment "If this property is assigned, the subject class, property, or resource, is deprecated 
and should not be used in production systems any longer. It may be removed without further notice." .
 
-# These are added and approval by Nepomuk-upstream is pending
-
-nao:Property a rdfs:Class ;
-       rdfs:label "Custom property to extend a class dynamically" ;
-       rdfs:comment "Dont use this without asking first your ontology doctor" ;
-       rdfs:subClassOf rdfs:Resource .
-
-nao:propertyName a rdf:Property ;
-       nrl:maxCardinality 1 ;
-       rdfs:domain nao:Property ;
-       rdfs:range  xsd:string .
-
-nao:propertyValue a rdf:Property ;
-       nrl:maxCardinality 1 ;
-       rdfs:domain nao:Property ;
-       rdfs:range  xsd:string .
-
-nao:hasProperty a rdf:Property ;
-       rdfs:domain nie:InformationElement ;
-       rdfs:range  nao:Property .
-
-nao:predefined-tag-favorite a nao:Tag .
-
 nao:lastModified a rdf:Property ;
        rdfs:label "lastModified" ;
        rdfs:comment "last modification date" ;
diff --git a/src/ontologies/90-tracker.ontology b/src/ontologies/90-tracker.ontology
index 565268c..3ac4467 100644
--- a/src/ontologies/90-tracker.ontology
+++ b/src/ontologies/90-tracker.ontology
@@ -18,11 +18,6 @@ tracker:tagRelatedTo a rdf:Property ;
        rdfs:domain nao:Tag ;
        rdfs:range rdfs:Class .
 
-tracker:notify a rdf:Property ;
-       nrl:maxCardinality 1 ;
-       rdfs:domain rdfs:Class ;
-       rdfs:range xsd:boolean .
-
 tracker:Volume a rdfs:Class ;
        rdfs:label "Storage media" ;
         rdfs:subClassOf nie:InformationElement ;
@@ -58,16 +53,6 @@ tracker:available a rdf:Property ;
        rdfs:domain nie:DataObject ;
        rdfs:range xsd:boolean .
 
-tracker:writeback a rdf:Property ;
-       nrl:maxCardinality 1 ;
-       rdfs:domain rdf:Property ;
-       rdfs:range xsd:boolean .
-
-tracker:forceJournal a rdf:Property ;
-       nrl:maxCardinality 1 ;
-       rdfs:domain rdf:Property ;
-       rdfs:range xsd:boolean .
-
 fts: a tracker:Namespace ;
        tracker:prefix "fts" .
 
diff --git a/src/ontologies/Makefile.am b/src/ontologies/Makefile.am
index 31ce129..b500fb4 100644
--- a/src/ontologies/Makefile.am
+++ b/src/ontologies/Makefile.am
@@ -3,13 +3,15 @@ maemo_ontology =                                       \
 
 configdir = $(datadir)/tracker/ontologies
 
-config_DATA =                                          \
+internal_config = \
        10-xsd.ontology     10-xsd.description         \
        11-rdf.ontology     11-rdf.description         \
        12-nrl.ontology     12-nrl.description         \
        20-dc.ontology      20-dc.description          \
+       31-nao.ontology     31-nao.description
+
+config_DATA =                                          \
        30-nie.ontology     30-nie.description         \
-       31-nao.ontology     31-nao.description         \
        32-nco.ontology     32-nco.description         \
        33-nfo.ontology     33-nfo.description         \
        34-nmo.ontology     34-nmo.description         \
@@ -29,6 +31,17 @@ if HAVE_MAEMO
 config_DATA += $(maemo_ontology)
 endif
 
+# GResource
+tracker_gresource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies 
$(srcdir)/builtin-ontology.gresource.xml)
+tracker-gresources.h: builtin-ontology.gresource.xml $(tracker_gresource_files) $(internal_config)
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --sourcedir=$(builddir) 
--generate --c-name tracker_gresources $<
+tracker-gresources.c: builtin-ontology.gresource.xml $(tracker_gresource_files) $(internal_config)
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --sourcedir=$(builddir) 
--generate --c-name tracker_gresources $<
+
+BUILT_SOURCES = tracker-gresources.c tracker-gresources.h
+
 EXTRA_DIST = \
+       $(internal_config) \
+       builtin-ontology.gresource.xml \
        $(maemo_ontology) \
        $(config_DATA)
diff --git a/src/ontologies/builtin-ontology.gresource.xml b/src/ontologies/builtin-ontology.gresource.xml
new file mode 100644
index 0000000..cd7b13f
--- /dev/null
+++ b/src/ontologies/builtin-ontology.gresource.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/freedesktop/tracker/ontology">
+    <file>10-xsd.ontology</file>
+    <file>11-rdf.ontology</file>
+    <file>12-nrl.ontology</file>
+    <file>20-dc.ontology</file>
+    <file>31-nao.ontology</file>
+  </gresource>
+</gresources>


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