diff --git a/sir/schema/__init__.py b/sir/schema/__init__.py
index 91af4ea0..a74484c8 100644
--- a/sir/schema/__init__.py
+++ b/sir/schema/__init__.py
@@ -40,22 +40,24 @@
SearchAnnotation = E(modelext.CustomAnnotation, [
F("id", "id"),
F("entity", ["areas.area.gid", "artists.artist.gid", "events.event.gid",
- "instruments.instrument.gid", "labels.label.gid",
- "places.place.gid", "recordings.recording.gid",
- "releases.release.gid", "release_groups.release_group.gid",
+ "genres.genre.gid", "instruments.instrument.gid",
+ "labels.label.gid", "places.place.gid",
+ "recordings.recording.gid", "releases.release.gid",
+ "release_groups.release_group.gid",
"series.series.gid", "works.work.gid"]),
F("name", ["areas.area.name", "artists.artist.name", "events.event.name",
- "instruments.instrument.name", "labels.label.name",
- "places.place.name", "recordings.recording.name",
- "releases.release.name", "release_groups.release_group.name",
+ "genres.genre.name", "instruments.instrument.name",
+ "labels.label.name", "places.place.name",
+ "recordings.recording.name", "releases.release.name",
+ "release_groups.release_group.name",
"series.series.name", "works.work.name"]),
F("text", "text"),
F("type", ["areas.__tablename__", "artists.__tablename__",
- "events.__tablename__", "instruments.__tablename__",
- "labels.__tablename__", "places.__tablename__",
- "recordings.__tablename__", "releases.__tablename__",
- "release_groups.__tablename__", "series.__tablename__",
- "works.__tablename__"],
+ "events.__tablename__", "genres.__tablename__",
+ "instruments.__tablename__", "labels.__tablename__",
+ "places.__tablename__", "recordings.__tablename__",
+ "releases.__tablename__", "release_groups.__tablename__",
+ "series.__tablename__", "works.__tablename__"],
transformfunc=tfs.annotation_type)
],
1.5,
diff --git a/sir/schema/modelext.py b/sir/schema/modelext.py
index 416b627b..b9cb5e98 100644
--- a/sir/schema/modelext.py
+++ b/sir/schema/modelext.py
@@ -18,6 +18,7 @@ class CustomAnnotation(Annotation):
areas = relationship("AreaAnnotation", viewonly=True)
artists = relationship("ArtistAnnotation", viewonly=True)
events = relationship("EventAnnotation", viewonly=True)
+ genres = relationship("GenreAnnotation", viewonly=True)
instruments = relationship("InstrumentAnnotation", viewonly=True)
labels = relationship("LabelAnnotation", viewonly=True)
places = relationship("PlaceAnnotation", viewonly=True)
diff --git a/sir/schema/queryext.py b/sir/schema/queryext.py
index eedeae1e..63b6c5b6 100644
--- a/sir/schema/queryext.py
+++ b/sir/schema/queryext.py
@@ -3,7 +3,8 @@
# Copyright (c) 2015 Wieland Hoffmann
# License: MIT, see LICENSE for details
from mbdata.models import (Annotation, AreaAnnotation, ArtistAnnotation,
- EventAnnotation, InstrumentAnnotation, LabelAnnotation,
+ EventAnnotation, GenreAnnotation,
+ InstrumentAnnotation, LabelAnnotation,
PlaceAnnotation, RecordingAnnotation, ReleaseAnnotation,
ReleaseGroupAnnotation, SeriesAnnotation, WorkAnnotation)
from sqlalchemy import func
@@ -13,6 +14,7 @@
AreaAnnotation,
ArtistAnnotation,
EventAnnotation,
+ GenreAnnotation,
InstrumentAnnotation,
LabelAnnotation,
PlaceAnnotation,
diff --git a/sir/schema/transformfuncs.py b/sir/schema/transformfuncs.py
index e74bd89f..738262e5 100644
--- a/sir/schema/transformfuncs.py
+++ b/sir/schema/transformfuncs.py
@@ -9,6 +9,7 @@
"area_annotation": "area",
"artist_annotation": "artist",
"event_annotation": "event",
+ "genre_annotation": "genre",
"instrument_annotation": "instrument",
"label_annotation": "label",
"place_annotation": "place",
diff --git a/sir/wscompat/convert.py b/sir/wscompat/convert.py
index 0ac8a281..17753d8b 100644
--- a/sir/wscompat/convert.py
+++ b/sir/wscompat/convert.py
@@ -761,6 +761,8 @@ def convert_annotation(obj):
l.append(convert_one_annotation(obj, 'artist', a.artist))
for a in obj.events:
l.append(convert_one_annotation(obj, 'event', a.event))
+ for a in obj.genres:
+ l.append(convert_one_annotation(obj, 'genre', a.genre))
for a in obj.instruments:
l.append(convert_one_annotation(obj, 'instrument', a.instrument))
for a in obj.labels:
diff --git a/test/sql/annotation.sql b/test/sql/annotation.sql
index b7c4f04b..9ab47700 100644
--- a/test/sql/annotation.sql
+++ b/test/sql/annotation.sql
@@ -25,13 +25,19 @@ INSERT INTO artist (id, gid, name, sort_name) VALUES
(5, 'dc19b13a-5ca5-44f5-8f0e-0c37a8ab1958', 'Annotated Artist A', 'Annotated Artist A'),
(6, 'ca4c2228-227c-4904-932a-dff442c091ea', 'Annotated Artist B', 'Annotated Artist B');
+INSERT INTO genre (id, gid, name) VALUES
+ (1, '1b50083b-1afa-4778-82c8-548b309af783', 'dubstep');
+
UPDATE artist_meta SET rating=70, rating_count=4 WHERE id=3;
INSERT INTO annotation (id, editor, text) VALUES (1, 1, 'Test annotation 1');
INSERT INTO annotation (id, editor, text) VALUES (2, 1, 'Test annotation 2');
INSERT INTO annotation (id, editor, text) VALUES (3, 1, 'Duplicate annotation');
INSERT INTO annotation (id, editor, text) VALUES (4, 1, 'Duplicate annotation');
+INSERT INTO annotation (id, editor, text) VALUES (5, 1, 'Genre annotation');
INSERT INTO artist_annotation (artist, annotation) VALUES (3, 1), (4, 2), (5, 3), (6, 4);
+INSERT INTO genre_annotation (genre, annotation) VALUES (1, 5);
+
INSERT INTO artist_gid_redirect VALUES ('a4ef1d08-962e-4dd6-ae14-e42a6a97fc11', 3);
diff --git a/test/test_indexing_real_data.py b/test/test_indexing_real_data.py
index 437cc6c2..bac2f8ea 100644
--- a/test/test_indexing_real_data.py
+++ b/test/test_indexing_real_data.py
@@ -670,6 +670,14 @@ def test_index_cdstub(self):
def test_index_annotation(self):
expected = [
+ {
+ '_store': '1b50083b-1afa-4778-82c8-548b309af783dubstepGenre annotation',
+ 'name': u'dubstep',
+ 'text': u'Genre annotation',
+ 'entity': '1b50083b-1afa-4778-82c8-548b309af783',
+ 'type': 'genre',
+ 'id': 1
+ },
{
'_store': '745c079d-374e-4436-9448-da92dedef3ceTest ArtistTest annotation 1',
'name': u'Test Artist',