Ejemplo n.º 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))
Ejemplo n.º 2
0
    def get_artist_of_unknown_type_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_aliases = self._graph.query(Queries.find_aliases_compiled(uri))
        rows_namevars = self._graph.query(Queries.find_namevars_compiled(uri))
        rows_country = self._graph.query(Queries.find_country_compiled(uri))
        rows_civil = self._graph.query(Queries.find_civil_compiled(uri))

        if rows_civil is not None:  # It is an ArtistPerson
            return MeraArtistPerson(labelled_canonical=canonical_tuple,
                                    labelled_aliases=MeraRdflibGraph._get_double_rows_multiple_result(rows_aliases),
                                    labelled_namevars=MeraRdflibGraph._get_double_rows_multiple_result(rows_namevars),
                                    labelled_country=MeraRdflibGraph._get_double_rows_simple_result(rows_country),
                                    labelled_civil=MeraRdflibGraph._get_double_rows_simple_result(rows_civil))
        rows_members = self._graph.query(Queries.find_members_uri_compiled(uri))
        if rows_members is None:  # It has not members, so it hasn't group properties
            return MeraArtist(labelled_canonical=canonical_tuple,
                              labelled_aliases=MeraRdflibGraph._get_double_rows_multiple_result(rows_aliases),
                              labelled_namevars=MeraRdflibGraph._get_double_rows_multiple_result(rows_namevars),
                              labelled_country=MeraRdflibGraph._get_double_rows_simple_result(rows_country))
        # By elimination, it is a group
        object_members = None
        uri_members = MeraRdflibGraph._get_single_rows_multiple_result(rows_members)
        if uri_members is not None:
            object_members = [self.get_artist_person_by_uri(person) for person in uri_members]

        return MeraArtistGroup(labelled_canonical=canonical_tuple,
                               labelled_aliases=MeraRdflibGraph._get_double_rows_multiple_result(rows_aliases),
                               labelled_namevars=MeraRdflibGraph._get_double_rows_multiple_result(rows_namevars),
                               labelled_country=MeraRdflibGraph._get_double_rows_simple_result(rows_country),
                               members=object_members)
Ejemplo n.º 3
0
    def get_artist_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_aliases = self._graph.query(Queries.find_aliases_compiled(uri))
        rows_namevars = self._graph.query(Queries.find_namevars_compiled(uri))
        rows_country = self._graph.query(Queries.find_country_compiled(uri))

        return MeraArtist(labelled_canonical=canonical_tuple,
                          labelled_aliases=MeraRdflibGraph._get_double_rows_multiple_result(rows_aliases),
                          labelled_namevars=MeraRdflibGraph._get_double_rows_multiple_result(rows_namevars),
                          labelled_country=MeraRdflibGraph._get_double_rows_simple_result(rows_country))
Ejemplo n.º 4
0
    def get_artist_group_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_aliases = self._graph.query(Queries.find_aliases_compiled(uri))
        rows_namevars = self._graph.query(Queries.find_namevars_compiled(uri))
        rows_country = self._graph.query(Queries.find_country_compiled(uri))
        rows_members = self._graph.query(Queries.find_members_uri_compiled(uri))

        object_members = None
        uri_members = MeraRdflibGraph._get_single_rows_multiple_result(rows_members)
        if uri_members is not None:
            object_members = [self.get_artist_person_by_uri(person) for person in uri_members]

        return MeraArtistGroup(labelled_canonical=canonical_tuple,
                               labelled_aliases=MeraRdflibGraph._get_double_rows_multiple_result(rows_aliases),
                               labelled_namevars=MeraRdflibGraph._get_double_rows_multiple_result(rows_namevars),
                               labelled_country=MeraRdflibGraph._get_double_rows_simple_result(rows_country),
                               members=object_members)