예제 #1
0
    def get_song_by_uri(self, uri):
        rows_canonical = self._graph.query(Queries.find_canonical_compiled(uri))
        canonical_tuple = MeraRdflibGraph._get_double_rows_simple_result(rows_canonical)
        if canonical_tuple is None:
            return None
        # rows_artist = self._graph.query(Queries.find_artists_uri_compiled(uri))
        rows_compilers = self._graph.query(Queries.find_compiler_uri_compiled(uri))
        rows_genres = self._graph.query(Queries.find_genres_compiled(uri))
        rows_alt_titles = self._graph.query(Queries.find_alternative_titles_compiled(uri))
        # rows_country = self._graph.query(Queries.find_country_compiled(uri))
        rows_discogs_id = self._graph.query(Queries.find_discogs_id_compiled(uri))
        rows_discogs_index = self._graph.query(Queries.find_discogs_index_compiled(uri))
        rows_transaction_id = self._graph.query(Queries.find_usos_transaction_id_compiled(uri))
        rows_isrc = self._graph.query(Queries.find_usos_isrc_compiled(uri))

        # rows_duration = None  # Not used yet
        # rows_date = None  # Not used yet
        # rows_album = None  # Not used yet


        return MeraSong(labelled_canonical=canonical_tuple,
                        labelled_alt_titles=MeraRdflibGraph._get_double_rows_multiple_result(rows_alt_titles),
                        labelled_collaborations=self._build_labelled_collaborations_from_rows(rows_compilers,
                                                                                              ROLE_WRITER),
                        # labelled_country=MeraRdflibGraph._get_double_rows_simple_result(rows_country),
                        # artists=MeraRdflibGraph._get_single_rows_multiple_result(rows_artist),
                        duration=None,
                        labelled_genres=MeraRdflibGraph._get_double_rows_multiple_result(rows_genres),
                        release_date=None,
                        album=None,
                        discogs_index=MeraRdflibGraph._get_single_rows_simple_result(rows_discogs_index),
                        discogs_id=MeraRdflibGraph._get_single_rows_simple_result(rows_discogs_id),
                        usos_transaction_id=MeraRdflibGraph._get_single_rows_simple_result(rows_transaction_id),
                        usos_isrc=MeraRdflibGraph._get_single_rows_simple_result(rows_isrc))