Commit 6d057d78249b0fd1d34fd0ba75093b09f50ae4c4

Authored by Barry Norton
1 parent aab0afab4d
Exists in master

Using schema-updated

Showing 1 changed file with 28 additions and 5 deletions

mappings/medium.ttl View file @ 6d057d7
... ... @@ -27,21 +27,44 @@
27 27 lb:Medium a rr:TriplesMap ;
28 28 rr:logicalTable [rr:tableName "medium"] ;
29 29 rr:subjectMap [rr:class mo:Record ;
30   - rr:template "http://musicbrainz.org/record/{id}#_"] ;
  30 + rr:template "http://musicbrainz.org/record/{id}#_"] .
  31 +
  32 +lb:medium_name a rr:TriplesMap ;
  33 + rr:logicalTable [rr:tableName "medium"] ;
  34 + rr:subjectMap lb:sm_medium ;
31 35 rr:predicateObjectMap
32 36 [rr:predicate dc:title ;
33   - rr:objectMap [rr:column "name" ; rr:datatype xsd:string]] ,
34   - [rr:predicate mo:track_count ;
35   - rr:objectMap [rr:column "track_count" ; rr:datatype xsd:int]] .
  37 + rr:objectMap [rr:column "name" ; rr:datatype xsd:string]] .
36 38  
37 39 lb:medium_track a rr:TriplesMap ;
38 40 rr:logicalTable [rr:sqlQuery
39 41 """SELECT medium.id, track.id AS track_id
40 42 FROM medium
41   - INNER JOIN track ON track.medium = medium.id"""] ;
  43 + INNER JOIN tracklist ON medium.tracklist = tracklist.id
  44 + INNER JOIN track ON track.tracklist = tracklist.id"""] ;
42 45 rr:subjectMap lb:sm_medium ;
43 46 rr:predicateObjectMap [
44 47 rr:predicate mo:track ;
45 48 rr:objectMap [rr:template "http://musicbrainz.org/track/{track_id}#_" ;
46 49 rr:termType rr:IRI]] .
  50 +
  51 +lb:medium_track_count a rr:TriplesMap ;
  52 + rr:logicalTable [rr:sqlQuery
  53 + """SELECT medium.id, tracklist.track_count
  54 + FROM medium
  55 + INNER JOIN tracklist ON medium.tracklist = tracklist.id"""];
  56 + rr:subjectMap lb:sm_medium ;
  57 + rr:predicateObjectMap
  58 + [rr:predicate mo:track_count ;
  59 + rr:objectMap [rr:column "track_count" ; rr:datatype xsd:int]] .
  60 +
  61 +lb:medium_format a rr:TriplesMap ;
  62 + rr:logicalTable [rr:sqlQuery
  63 + """SELECT medium.id, medium_format.id as medium_format_id
  64 + FROM medium
  65 + INNER JOIN medium_format ON medium.format = medium_format.id"""];
  66 + rr:subjectMap lb:sm_medium ;
  67 + rr:predicateObjectMap
  68 + [rr:predicate mo:media_type ;
  69 + rr:objectMap [rr:column "medium_format_id" ; rr:termType rr:IRI]] .