[tracker/writeback] Added some more fields to the XMP writeback module



commit ab02d0180ed10a68af2fce90de4e643722a49e68
Author: Philip Van Hoof <philip codeminded be>
Date:   Wed Dec 16 17:31:31 2009 +0100

    Added some more fields to the XMP writeback module

 data/ontologies/30-nie.ontology               |    3 +-
 data/ontologies/32-nco.ontology               |    3 +-
 data/ontologies/38-nmm.ontology               |    3 +-
 src/tracker-writeback/Makefile.am             |   12 ++--
 src/tracker-writeback/tracker-writeback-xmp.c |   66 +++++++++++++++++++++++++
 tests/tracker-writeback/01-writeback.py       |    6 ++-
 6 files changed, 83 insertions(+), 10 deletions(-)
---
diff --git a/data/ontologies/30-nie.ontology b/data/ontologies/30-nie.ontology
index 5571fec..d6e0e61 100644
--- a/data/ontologies/30-nie.ontology
+++ b/data/ontologies/30-nie.ontology
@@ -137,7 +137,8 @@ nie:copyright a rdf:Property ;
 	rdfs:subPropertyOf dc:rights , nie:legal ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain nie:InformationElement ;
-	rdfs:range xsd:string .
+	rdfs:range xsd:string ;
+	tracker:writeback true .
 
 nie:comment a rdf:Property ;
 	nrl:maxCardinality 1 ;
diff --git a/data/ontologies/32-nco.ontology b/data/ontologies/32-nco.ontology
index f79d2e0..1f622bb 100644
--- a/data/ontologies/32-nco.ontology
+++ b/data/ontologies/32-nco.ontology
@@ -208,7 +208,8 @@ nco:contributor a rdf:Property ;
 	rdfs:comment "An entity responsible for making contributions to the content of the InformationElement." ;
 	rdfs:subPropertyOf dc:contributor ;
 	rdfs:domain nie:InformationElement ;
-	rdfs:range nco:Contact .
+	rdfs:range nco:Contact ;
+	tracker:writeback true .
 
 nco:creator a rdf:Property ;
 	rdfs:label "creator" ;
diff --git a/data/ontologies/38-nmm.ontology b/data/ontologies/38-nmm.ontology
index c3dd1d3..8ec27f7 100644
--- a/data/ontologies/38-nmm.ontology
+++ b/data/ontologies/38-nmm.ontology
@@ -323,7 +323,8 @@ nmm:camera a rdf:Property ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain nmm:Photo ;
 	rdfs:range xsd:string ;
-	tracker:weight 3 .
+	tracker:weight 3 ;
+	tracker:writeback true .
 
 nmm:exposureTime a rdf:Property ;
 	rdfs:label "Exposure time" ;
diff --git a/src/tracker-writeback/Makefile.am b/src/tracker-writeback/Makefile.am
index 857287c..0d67a81 100644
--- a/src/tracker-writeback/Makefile.am
+++ b/src/tracker-writeback/Makefile.am
@@ -39,12 +39,12 @@ libwriteback_xmp_la_LIBADD = $(GLIB2_LIBS) $(GCOV_LIBS) $(EXEMPI_LIBS)
 endif
 
 # Playlists
-if HAVE_TOTEM_PL_PARSER
-modules_LTLIBRARIES += libwriteback-playlist.la
-libwriteback_playlist_la_SOURCES = tracker-writeback-playlist.c
-libwriteback_playlist_la_LDFLAGS = $(module_flags)
-libwriteback_playlist_la_LIBADD = $(GLIB2_LIBS) $(GCOV_LIBS) $(TOTEM_PL_PARSER_LIBS)
-endif
+#if HAVE_TOTEM_PL_PARSER
+#modules_LTLIBRARIES += libwriteback-playlist.la
+#libwriteback_playlist_la_SOURCES = tracker-writeback-playlist.c
+#libwriteback_playlist_la_LDFLAGS = $(module_flags)
+#libwriteback_playlist_la_LIBADD = $(GLIB2_LIBS) $(GCOV_LIBS) $(TOTEM_PL_PARSER_LIBS)
+#endif
 
 #
 # Binaries
diff --git a/src/tracker-writeback/tracker-writeback-xmp.c b/src/tracker-writeback/tracker-writeback-xmp.c
index c20e291..b494008 100644
--- a/src/tracker-writeback/tracker-writeback-xmp.c
+++ b/src/tracker-writeback/tracker-writeback-xmp.c
@@ -184,11 +184,56 @@ writeback_xmp_update_file_metadata (TrackerWritebackFile *wbf,
 			}
 		}
 
+		if (g_strcmp0 (row[1], TRACKER_NCO_PREFIX "contributor") == 0) {
+			GPtrArray *name_array;
+			GError *error = NULL;
+			gchar *query;
+
+			query = g_strdup_printf ("SELECT ?fullname { "
+			                         "  <%s> nco:fullname ?fullname "
+			                         "}", row[2]);
+
+			name_array = tracker_resources_sparql_query (client, query, &error);
+
+			g_free (query);
+
+			if (!error) {
+				if (name_array && name_array->len > 0) {
+					GStrv name_row;
+
+					name_row = g_ptr_array_index (name_array, 0);
+
+					if (name_row[0]) {
+						xmp_delete_property (xmp, NS_DC, "contributor");
+						xmp_set_property (xmp, NS_DC, "contributor", name_row[0], 0);
+					}
+				}
+
+				if (name_array) {
+					g_ptr_array_foreach (name_array, (GFunc) g_strfreev, NULL);
+					g_ptr_array_free (name_array, TRUE);
+				}
+
+			} else {
+				g_clear_error (&error);
+			}
+		}
+
 		if (g_strcmp0 (row[1], TRACKER_NIE_PREFIX "description") == 0) {
 			xmp_delete_property (xmp, NS_DC, "description");
 			xmp_set_property (xmp, NS_DC, "description", row[2], 0);
 		}
 
+		if (g_strcmp0 (row[1], TRACKER_NIE_PREFIX "copyright") == 0) {
+			xmp_delete_property (xmp, NS_EXIF, "Copyright");
+			xmp_set_property (xmp, NS_DC, "Copyright", row[2], 0);
+		}
+
+		if (g_strcmp0 (row[1], TRACKER_NIE_PREFIX "comment") == 0) {
+			xmp_delete_property (xmp, NS_EXIF, "UserComment");
+			xmp_set_property (xmp, NS_EXIF, "UserComment", row[2], 0);
+		}
+
 		if (g_strcmp0 (row[1], TRACKER_NIE_PREFIX "keyword") == 0) {
 			if (!keywords) {
 				keywords = g_string_new (row[2]);
@@ -301,6 +346,27 @@ writeback_xmp_update_file_metadata (TrackerWritebackFile *wbf,
 			xmp_set_property (xmp, NS_EXIF, "FNumber", row[2], 0);
 		}
 
+		if (g_strcmp0 (row[1], TRACKER_NMM_PREFIX "camera") == 0) {
+			gchar *work_on = g_strdup (row[2]);
+			gchar *ptr = strchr (work_on, ' ');
+
+			if (ptr) {
+
+				*ptr = '\0';
+				ptr++;
+
+				xmp_delete_property (xmp, NS_EXIF, "Make");
+				xmp_set_property (xmp, NS_EXIF, "Make", work_on, 0);
+				xmp_delete_property (xmp, NS_EXIF, "Model");
+				xmp_set_property (xmp, NS_EXIF, "Model", ptr, 0);
+			} else {
+				xmp_delete_property (xmp, NS_EXIF, "Model");
+				xmp_set_property (xmp, NS_EXIF, "Model", work_on, 0);
+			}
+
+			g_free (work_on);
+		}
+
 		/*
 		  if (g_strcmp0 (row[1], PHOTO_HAS "contact") == 0) {
 		  Face recognition on the photos
diff --git a/tests/tracker-writeback/01-writeback.py b/tests/tracker-writeback/01-writeback.py
index 1e553b3..aa23596 100755
--- a/tests/tracker-writeback/01-writeback.py
+++ b/tests/tracker-writeback/01-writeback.py
@@ -69,7 +69,11 @@ class TestInsertion (unittest.TestCase):
                       nmm:focalLength '1' ;
                       nmm:exposureTime '1' ;
                       nmm:isoSpeed '1' ;
-                      nmm:fnumber '1' 
+                      nmm:fnumber '1' ;
+                      nmm:camera 'Some Test Model' ;
+                      nco:contributor [ a nco:Contact ;
+                                        nco:fullname 'test_fullname_2' ] ;
+                      nie:copyright 'test_copyright_1'
                }""" % (uri, uri, uri)
 
 



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