# HG changeset patch # User Chris Cannam # Date 1271773292 -3600 # Node ID add3570c6035f1534186bbff239fa89083afb2ba # Parent a42493a3baf83208f212e5f1d294c36ecbd80407 * Add new "write" option to composer utility * Default year transcodes to empty string instead of zero diff -r a42493a3baf8 -r add3570c6035 common/Objects.h --- a/common/Objects.h Fri Apr 09 16:19:50 2010 +0100 +++ b/common/Objects.h Tue Apr 20 15:21:32 2010 +0100 @@ -35,10 +35,13 @@ struct Encoder : public Dataquay::Node::VariantEncoder { QString fromVariant(const QVariant &v) { - QString s = QString("%1").arg(v.value().toInt()); + int y = v.value().toInt(); + if (y == 0) return ""; + QString s = QString("%1").arg(y); return s; } QVariant toVariant(const QString &s) { + if (s == "") return QVariant::fromValue(Year()); QVariant v = QVariant::fromValue(s.toInt()); return v; } diff -r a42493a3baf8 -r add3570c6035 utilities/composer/composer.cpp --- a/utilities/composer/composer.cpp Fri Apr 09 16:19:50 2010 +0100 +++ b/utilities/composer/composer.cpp Tue Apr 20 15:21:32 2010 +0100 @@ -68,6 +68,7 @@ cerr << " " << name << " search " << endl; cerr << " " << name << " match " << endl; cerr << " " << name << " merge [ ...]" << endl; + cerr << " " << name << " write" << endl; exit(-1); } @@ -331,9 +332,11 @@ delete loader; - bool write = false; + bool write = false, writeFull = false; if (command == "merge") { write = true; + } else if (command == "write") { + writeFull = true; } TransactionalStore *ts = 0; @@ -367,7 +370,9 @@ } } - if (command == "list") { + if (command == "write") { + if (!args.empty()) usage(argv[0]); + } else if (command == "list") { if (!args.empty()) usage(argv[0]); listBrief(allComposers); } else if (command == "list-uris") { @@ -402,24 +407,6 @@ } if (write) { -/* - ObjectStorer *storer = new ObjectStorer(store); - - storer->setTypeMapping(tm); - - storer->setPropertyStorePolicy(ObjectStorer::StoreIfChanged); -// storer->setObjectStorePolicy(ObjectStorer::StoreAllObjects); - storer->setBlankNodePolicy(ObjectStorer::NoBlankNodes); - - cerr << "Mapping results back to store..."; -// storer->storeAllObjects(root->children()); -// storer->setFollowPolicy(ObjectStorer::FollowAll); - storer->setFollowPolicy(ObjectStorer::FollowObjectProperties); - storer->store(objects); - cerr << " done" << endl; - - delete storer; -*/ cerr << "Committing changes..."; mapper->commit(); @@ -428,6 +415,26 @@ cerr << "Saving to file out.ttl..."; store->save("out.ttl"); cerr << " done" << endl; + + } else if (writeFull) { + + ObjectStorer *storer = new ObjectStorer(store); + + storer->setTypeMapping(tm); + + storer->setPropertyStorePolicy(ObjectStorer::StoreIfChanged); + storer->setBlankNodePolicy(ObjectStorer::NoBlankNodes); + + cerr << "Mapping results back to store..."; + storer->setFollowPolicy(ObjectStorer::FollowObjectProperties); + storer->store(objects); + cerr << " done" << endl; + + cerr << "Saving to file out.ttl..."; + store->save("out.ttl"); + cerr << " done" << endl; + + delete storer; } delete mapper; diff -r a42493a3baf8 -r add3570c6035 utilities/widgettest/widgettest.cpp --- a/utilities/widgettest/widgettest.cpp Fri Apr 09 16:19:50 2010 +0100 +++ b/utilities/widgettest/widgettest.cpp Tue Apr 20 15:21:32 2010 +0100 @@ -1,5 +1,7 @@ /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ +#include + #include "TypingSelectWidget.h" #include "TypeRegistrar.h" #include "Objects.h" @@ -7,7 +9,6 @@ #include #include -#include #include #include #include