To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / common / TypeRegistrar.cpp @ 45:0033259c6772
History | View | Annotate | Download (9.66 KB)
| 1 |
|
|---|---|
| 2 |
#include "TypeRegistrar.h" |
| 3 |
|
| 4 |
#include "Objects.h" |
| 5 |
|
| 6 |
#include <dataquay/BasicStore.h> |
| 7 |
#include <dataquay/objectmapper/TypeMapping.h> |
| 8 |
#include <dataquay/objectmapper/ObjectBuilder.h> |
| 9 |
#include <dataquay/objectmapper/ContainerBuilder.h> |
| 10 |
|
| 11 |
using namespace Dataquay; |
| 12 |
|
| 13 |
namespace ClassicalData {
|
| 14 |
|
| 15 |
void
|
| 16 |
TypeRegistrar::registerTypes() |
| 17 |
{
|
| 18 |
qRegisterMetaType<Year> |
| 19 |
("ClassicalData::Year");
|
| 20 |
qRegisterMetaType<HistoricalEvent *> |
| 21 |
("ClassicalData::HistoricalEvent*");
|
| 22 |
qRegisterMetaType<Birth *> |
| 23 |
("ClassicalData::Birth*");
|
| 24 |
qRegisterMetaType<Death *> |
| 25 |
("ClassicalData::Death*");
|
| 26 |
qRegisterMetaType<Composition *> |
| 27 |
("ClassicalData::Composition*");
|
| 28 |
qRegisterMetaType<Work *> |
| 29 |
("ClassicalData::Work*");
|
| 30 |
qRegisterMetaType<Movement *> |
| 31 |
("ClassicalData::Movement*");
|
| 32 |
qRegisterMetaType<Composer *> |
| 33 |
("ClassicalData::Composer*");
|
| 34 |
qRegisterMetaType<Document *> |
| 35 |
("ClassicalData::Document*");
|
| 36 |
qRegisterMetaType<Form *> |
| 37 |
("ClassicalData::Form*");
|
| 38 |
qRegisterMetaType<QSet<Work *> > |
| 39 |
("QSet<ClassicalData::Work*>");
|
| 40 |
qRegisterMetaType<QSet<Movement *> > |
| 41 |
("QSet<ClassicalData::Movement*>");
|
| 42 |
qRegisterMetaType<QSet<Document *> > |
| 43 |
("QSet<ClassicalData::Document*>");
|
| 44 |
qRegisterMetaType<QSet<Form *> > |
| 45 |
("QSet<ClassicalData::Form*>");
|
| 46 |
qRegisterMetaType<QSet<QString> > |
| 47 |
("QSet<QString>");
|
| 48 |
qRegisterMetaType<QSet<Dataquay::Uri> > |
| 49 |
("QSet<Dataquay::Uri>");
|
| 50 |
qRegisterMetaType<AudioFile *> |
| 51 |
("ClassicalData::AudioFile*");
|
| 52 |
qRegisterMetaType<QSet<AudioFile *> > |
| 53 |
("QSet<ClassicalData::AudioFile*>");
|
| 54 |
qRegisterMetaType<Signal *> |
| 55 |
("ClassicalData::Signal*");
|
| 56 |
|
| 57 |
Node::registerDatatype(Uri("http://www.w3.org/2001/XMLSchema#gYear"),
|
| 58 |
"ClassicalData::Year", new Year::Encoder()); |
| 59 |
|
| 60 |
ObjectBuilder::getInstance()->registerClass |
| 61 |
<HistoricalEvent>("ClassicalData::HistoricalEvent*");
|
| 62 |
ObjectBuilder::getInstance()->registerClass |
| 63 |
<Birth>("ClassicalData::Birth*");
|
| 64 |
ObjectBuilder::getInstance()->registerClass |
| 65 |
<Death>("ClassicalData::Death*");
|
| 66 |
ObjectBuilder::getInstance()->registerClass |
| 67 |
<Composition>("ClassicalData::Composition*");
|
| 68 |
ObjectBuilder::getInstance()->registerClass |
| 69 |
<Work, QObject>("ClassicalData::Work*");
|
| 70 |
ObjectBuilder::getInstance()->registerClass |
| 71 |
<Movement, QObject>("ClassicalData::Movement*");
|
| 72 |
ObjectBuilder::getInstance()->registerClass |
| 73 |
<Composer, QObject>("ClassicalData::Composer*");
|
| 74 |
ObjectBuilder::getInstance()->registerClass |
| 75 |
<Document, QObject>("ClassicalData::Document*");
|
| 76 |
ObjectBuilder::getInstance()->registerClass |
| 77 |
<Form, QObject>("ClassicalData::Form*");
|
| 78 |
ObjectBuilder::getInstance()->registerClass |
| 79 |
<AudioFile>("ClassicalData::AudioFile*");
|
| 80 |
|
| 81 |
ContainerBuilder::getInstance()->registerContainer |
| 82 |
<QString, QSet<QString> > |
| 83 |
("QString", "QSet<QString>", ContainerBuilder::SetKind); |
| 84 |
|
| 85 |
ContainerBuilder::getInstance()->registerContainer |
| 86 |
<Dataquay::Uri, QSet<Dataquay::Uri> > |
| 87 |
("Dataquay::Uri", "QSet<Dataquay::Uri>", ContainerBuilder::SetKind); |
| 88 |
|
| 89 |
ContainerBuilder::getInstance()->registerContainer |
| 90 |
<Work*, QSet<Work*> > |
| 91 |
("ClassicalData::Work*", "QSet<ClassicalData::Work*>", |
| 92 |
ContainerBuilder::SetKind); |
| 93 |
|
| 94 |
ContainerBuilder::getInstance()->registerContainer |
| 95 |
<Movement*, QSet<Movement*> > |
| 96 |
("ClassicalData::Movement*", "QSet<ClassicalData::Movement*>", |
| 97 |
ContainerBuilder::SetKind); |
| 98 |
|
| 99 |
ContainerBuilder::getInstance()->registerContainer |
| 100 |
<Document*, QSet<Document*> > |
| 101 |
("ClassicalData::Document*", "QSet<ClassicalData::Document*>", |
| 102 |
ContainerBuilder::SetKind); |
| 103 |
|
| 104 |
ContainerBuilder::getInstance()->registerContainer |
| 105 |
<Form*, QSet<Form*> > |
| 106 |
("ClassicalData::Form*", "QSet<ClassicalData::Form*>", |
| 107 |
ContainerBuilder::SetKind); |
| 108 |
|
| 109 |
ContainerBuilder::getInstance()->registerContainer |
| 110 |
<AudioFile*, QSet<AudioFile*> > |
| 111 |
("ClassicalData::AudioFile*", "QSet<ClassicalData::AudioFile*>", |
| 112 |
ContainerBuilder::SetKind); |
| 113 |
} |
| 114 |
|
| 115 |
void
|
| 116 |
TypeRegistrar::addMappings(BasicStore *store, TypeMapping *mapping) |
| 117 |
{
|
| 118 |
if (store) {
|
| 119 |
store->addPrefix("foaf", Uri("http://xmlns.com/foaf/0.1/")); |
| 120 |
store->addPrefix("mo", Uri("http://purl.org/ontology/mo/")); |
| 121 |
store->addPrefix("dc", Uri("http://purl.org/dc/elements/1.1/")); |
| 122 |
store->addPrefix("bio", Uri("http://purl.org/vocab/bio/0.1/")); |
| 123 |
store->addPrefix("owl", Uri("http://www.w3.org/2002/07/owl#")); |
| 124 |
store->addPrefix("rdfs", Uri("http://www.w3.org/2000/01/rdf-schema#")); |
| 125 |
store->addPrefix("db", Uri("http://dbtune.org/musicbrainz/resource/")); |
| 126 |
store->addPrefix("dbv", Uri("http://dbtune.org/musicbrainz/resource/vocab/")); |
| 127 |
store->addPrefix("cmn", Uri("http://purl.org/ontology/classicalmusicnav#")); |
| 128 |
store->addPrefix("sim", Uri("http://purl.org/ontology/similarity/")); |
| 129 |
} |
| 130 |
|
| 131 |
if (mapping) {
|
| 132 |
mapping->setObjectTypePrefix(Uri("http://dbtune.org/classical/resource/"));
|
| 133 |
mapping->setPropertyPrefix(Uri("http://dbtune.org/classical/resource/vocab/"));
|
| 134 |
mapping->setRelationshipPrefix(Uri("http://dbtune.org/classical/resource/vocab/relationship/"));
|
| 135 |
} |
| 136 |
|
| 137 |
if (store && mapping) {
|
| 138 |
|
| 139 |
store->addPrefix("type", mapping->getObjectTypePrefix());
|
| 140 |
store->addPrefix("classical", Uri(mapping->getObjectTypePrefix().toString() + "type/")); |
| 141 |
store->addPrefix("property", mapping->getPropertyPrefix());
|
| 142 |
store->addPrefix("rel", mapping->getRelationshipPrefix());
|
| 143 |
|
| 144 |
store->add(Triple("classical:Composer", "a", store->expand("owl:Class"))); |
| 145 |
store->add(Triple("classical:Composer", "rdfs:subClassOf", store->expand("mo:MusicArtist"))); |
| 146 |
|
| 147 |
store->add(Triple("property:birth", "a", store->expand("owl:ObjectProperty"))); |
| 148 |
store->add(Triple("property:birth", "rdfs:subPropertyOf", store->expand("bio:event"))); |
| 149 |
|
| 150 |
store->add(Triple("property:death", "a", store->expand("owl:ObjectProperty"))); |
| 151 |
store->add(Triple("property:death", "rdfs:subPropertyOf", store->expand("bio:event"))); |
| 152 |
|
| 153 |
mapping->addTypeMapping("ClassicalData::Composer", store->expand("classical:Composer")); |
| 154 |
mapping->addPropertyMapping("ClassicalData::Composer", "pages", store->expand("foaf:page")); |
| 155 |
mapping->addPropertyMapping("ClassicalData::Composer", "name", store->expand("foaf:name")); |
| 156 |
mapping->addPropertyMapping("ClassicalData::Composer", "aliases", store->expand("dbv:alias")); |
| 157 |
mapping->addPropertyMapping("ClassicalData::Composer", "birth", store->expand("property:birth")); |
| 158 |
mapping->addPropertyMapping("ClassicalData::Composer", "death", store->expand("property:death")); |
| 159 |
mapping->addPropertyMapping("ClassicalData::Composer", "geonameURIs", store->expand("foaf:based_near")); |
| 160 |
mapping->addPropertyMapping("ClassicalData::Composer", "otherURIs", store->expand("owl:sameAs")); |
| 161 |
mapping->addPropertyMapping("ClassicalData::Composer", "gender", store->expand("foaf:gender")); |
| 162 |
|
| 163 |
mapping->addTypeMapping("ClassicalData::Birth", store->expand("bio:Birth")); |
| 164 |
mapping->addTypeMapping("ClassicalData::Death", store->expand("bio:Death")); |
| 165 |
mapping->addTypeUriPrefixMapping("ClassicalData::Birth", store->expand(":event/")); |
| 166 |
mapping->addTypeUriPrefixMapping("ClassicalData::Death", store->expand(":event/")); |
| 167 |
mapping->addPropertyMapping("ClassicalData::Birth", "year", store->expand("dc:date")); |
| 168 |
mapping->addPropertyMapping("ClassicalData::Death", "year", store->expand("dc:date")); |
| 169 |
mapping->addPropertyMapping("ClassicalData::Composition", "year", store->expand("dc:date")); |
| 170 |
mapping->addPropertyMapping("ClassicalData::Birth", "place", store->expand("bio:place")); |
| 171 |
mapping->addPropertyMapping("ClassicalData::Death", "place", store->expand("bio:place")); |
| 172 |
mapping->addPropertyMapping("ClassicalData::Composition", "place", store->expand("bio:place")); |
| 173 |
|
| 174 |
mapping->addTypeMapping("ClassicalData::Document", store->expand("foaf:Document")); |
| 175 |
mapping->addPropertyMapping("ClassicalData::Document", "topic", store->expand("foaf:primaryTopic")); |
| 176 |
|
| 177 |
mapping->addTypeMapping("ClassicalData::Work", store->expand("mo:MusicalWork")); |
| 178 |
|
| 179 |
mapping->addPropertyMapping("ClassicalData::Work", "composition", store->expand("mo:composed_in")); |
| 180 |
mapping->addPropertyMapping("ClassicalData::Work", "opus", store->expand("mo:opus")); |
| 181 |
mapping->addPropertyMapping("ClassicalData::Work", "catalogue", store->expand("mo:catalogue")); |
| 182 |
mapping->addPropertyMapping("ClassicalData::Work", "number", store->expand("mo:number")); |
| 183 |
mapping->addPropertyMapping("ClassicalData::Work", "partOf", store->expand("dc:isPartOf")); |
| 184 |
mapping->addPropertyMapping("ClassicalData::Work", "parts", store->expand("dc:hasPart")); |
| 185 |
mapping->addPropertyMapping("ClassicalData::Work", "pages", store->expand("foaf:page")); |
| 186 |
mapping->addPropertyMapping("ClassicalData::Work", "forms", store->expand("property:form")); |
| 187 |
mapping->addPropertyMapping("ClassicalData::Work", "key", store->expand("mo:key")); |
| 188 |
mapping->addPropertyMapping("ClassicalData::Work", "aliases", store->expand("dbv:alias")); |
| 189 |
mapping->addPropertyMapping("ClassicalData::Work", "name", store->expand("dc:title")); |
| 190 |
|
| 191 |
mapping->addTypeMapping("ClassicalData::Composition", store->expand("mo:Composition")); |
| 192 |
mapping->addTypeUriPrefixMapping("ClassicalData::Composition", store->expand(":event/")); |
| 193 |
mapping->addPropertyMapping("ClassicalData::Composition", "composer", store->expand("mo:composer")); |
| 194 |
mapping->addPropertyMapping("ClassicalData::Composition", "works", store->expand("mo:produced_work")); |
| 195 |
|
| 196 |
mapping->addTypeMapping("ClassicalData::AudioFile", store->expand("mo:AudioFile")); |
| 197 |
mapping->addPropertyMapping("ClassicalData::AudioFile", "hash", store->expand("foaf:sha1")); |
| 198 |
|
| 199 |
mapping->addTypeMapping("ClassicalData::Signal", store->expand("mo:Signal")); |
| 200 |
mapping->addPropertyMapping("ClassicalData::Signal", "availableAs", store->expand("mo:available_as")); |
| 201 |
mapping->addPropertyMapping("ClassicalData::Signal", "puid", store->expand("mo:puid")); |
| 202 |
mapping->addPropertyMapping("ClassicalData::Signal", "composer", store->expand("mo:composer")); |
| 203 |
mapping->addPropertyMapping("ClassicalData::Signal", "work", store->expand("mo:")); |
| 204 |
mapping->addPropertyMapping("ClassicalData::Signal", "availableAs", store->expand("mo:available_as")); |
| 205 |
} |
| 206 |
} |
| 207 |
|
| 208 |
} |
| 209 |
|