Search in sources :

Example 11 with ArtistInfo

use of com.github.hakko.musiccabinet.domain.model.music.ArtistInfo in project musiccabinet by hakko.

the class JdbcArtistInfoDaoTest method bioSummaryCanBeUpdated.

@Test
public void bioSummaryCanBeUpdated() {
    deleteArtistInfos();
    int abbaId = musicDao.getArtistId(aiAbba.getArtist());
    String biography = "new ABBA biography";
    dao.createArtistInfo(Arrays.asList(aiAbba));
    dao.setBioSummary(abbaId, biography);
    ArtistInfo dbAbba = dao.getArtistInfo(abbaId);
    Assert.assertEquals(biography, dbAbba.getBioSummary());
}
Also used : ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo) Test(org.junit.Test)

Example 12 with ArtistInfo

use of com.github.hakko.musiccabinet.domain.model.music.ArtistInfo in project musiccabinet by hakko.

the class JdbcArtistInfoDaoTest method loadFunctionDependency.

@Before
public void loadFunctionDependency() throws ApplicationException {
    PostgreSQLUtil.loadFunction(dao, UPDATE_ARTISTINFO);
    aiAbba = new ArtistInfoParserImpl(new ResourceUtil(AI_ABBA_FILE).getInputStream()).getArtistInfo();
    aiCher = new ArtistInfoParserImpl(new ResourceUtil(AI_CHER_FILE).getInputStream()).getArtistInfo();
    aiTina = new ArtistInfoParserImpl(new ResourceUtil(AI_TINA_FILE).getInputStream()).getArtistInfo();
    deleteArtists();
    // re-create artists
    for (ArtistInfo ai : new ArtistInfo[] { aiAbba, aiCher, aiTina }) {
        musicDao.getArtistId(ai.getArtist());
    }
}
Also used : ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) ArtistInfoParserImpl(com.github.hakko.musiccabinet.parser.lastfm.ArtistInfoParserImpl) ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo) Before(org.junit.Before)

Example 13 with ArtistInfo

use of com.github.hakko.musiccabinet.domain.model.music.ArtistInfo in project musiccabinet by hakko.

the class UserTopArtistsServiceTest method createArtistInfosAndLocalFiles.

private void createArtistInfosAndLocalFiles() throws ApplicationException {
    Map<Artist, ArtistInfo> artistInfos = new HashMap<>();
    List<File> files = new ArrayList<>();
    for (Period period : Period.values()) {
        String fileName = format(TOP_ARTISTS_FILE, period.getDescription());
        for (Artist artist : new UserTopArtistsParserImpl(new ResourceUtil(fileName, UTF8).getInputStream()).getArtists()) {
            artistInfos.put(artist, new ArtistInfo(artist));
            files.add(UnittestLibraryUtil.getFile(artist.getName(), "A", "T"));
        }
    }
    artistInfoDao.createArtistInfo(new ArrayList<ArtistInfo>(artistInfos.values()));
    submitFile(additionDao, files);
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) UserTopArtistsParserImpl(com.github.hakko.musiccabinet.parser.lastfm.UserTopArtistsParserImpl) ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Period(com.github.hakko.musiccabinet.domain.model.library.Period) ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo) File(com.github.hakko.musiccabinet.domain.model.library.File) UnittestLibraryUtil.submitFile(com.github.hakko.musiccabinet.util.UnittestLibraryUtil.submitFile)

Example 14 with ArtistInfo

use of com.github.hakko.musiccabinet.domain.model.music.ArtistInfo in project musiccabinet by hakko.

the class ArtistInfoServiceTest method canInvokeService.

@Test
public void canInvokeService() throws ApplicationException {
    String artistName = "A Previously Unknown Artist";
    int artistId = musicDao.getArtistId(artistName);
    ArtistInfo artistInfo = aiService.getArtistInfo(artistId);
    Assert.assertNotNull(artistInfo);
    Assert.assertEquals(artistName, artistInfo.getArtist().getName());
}
Also used : ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo) Test(org.junit.Test)

Example 15 with ArtistInfo

use of com.github.hakko.musiccabinet.domain.model.music.ArtistInfo in project musiccabinet by hakko.

the class ArtistInfoHandler method endElement.

@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
    if (parsing) {
        String chars = characterData.toString();
        if (TAG_NAME.equals(qName) && artistInfo == null) {
            artistInfo = new ArtistInfo();
            artistInfo.setArtist(new Artist(chars));
        } else if (TAG_IMAGE.equals(qName)) {
            if (ATTR_SMALL.equals(imageSize)) {
                artistInfo.setSmallImageUrl(chars);
            } else if (ATTR_MEDIUM.equals(imageSize)) {
                artistInfo.setMediumImageUrl(chars);
            } else if (ATTR_LARGE.equals(imageSize)) {
                artistInfo.setLargeImageUrl(chars);
            } else if (ATTR_EXTRA_LARGE.equals(imageSize)) {
                artistInfo.setExtraLargeImageUrl(chars);
            }
        } else if (TAG_LISTENERS.equals(qName)) {
            artistInfo.setListeners(toInt(chars));
        } else if (TAG_PLAY_COUNT.equals(qName)) {
            artistInfo.setPlayCount(toInt(chars));
            parsing = false;
        }
    }
    if (TAG_BIO_SUMMARY.equals(qName)) {
        artistInfo.setBioSummary(stripLicenseAndReadMoreLink(characterData.toString(), artistInfo.getArtist().getName()));
    } else if (TAG_BIO_CONTENT.equals(qName)) {
        artistInfo.setBioContent(stripLicenseAndReadMoreLink(characterData.toString(), artistInfo.getArtist().getName()));
    }
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo)

Aggregations

ArtistInfo (com.github.hakko.musiccabinet.domain.model.music.ArtistInfo)22 Artist (com.github.hakko.musiccabinet.domain.model.music.Artist)11 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)7 File (com.github.hakko.musiccabinet.domain.model.library.File)5 ResourceUtil (com.github.hakko.musiccabinet.util.ResourceUtil)4 UnittestLibraryUtil.getFile (com.github.hakko.musiccabinet.util.UnittestLibraryUtil.getFile)4 ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 HashSet (java.util.HashSet)3 Before (org.junit.Before)3 ArtistInfoParserImpl (com.github.hakko.musiccabinet.parser.lastfm.ArtistInfoParserImpl)2 TagTopArtists (com.github.hakko.musiccabinet.domain.model.aggr.TagTopArtists)1 UserRecommendedArtists (com.github.hakko.musiccabinet.domain.model.aggr.UserRecommendedArtists)1 RecommendedArtist (com.github.hakko.musiccabinet.domain.model.aggr.UserRecommendedArtists.RecommendedArtist)1 UserTopArtists (com.github.hakko.musiccabinet.domain.model.aggr.UserTopArtists)1 LastFmUser (com.github.hakko.musiccabinet.domain.model.library.LastFmUser)1 Period (com.github.hakko.musiccabinet.domain.model.library.Period)1 Album (com.github.hakko.musiccabinet.domain.model.music.Album)1 ArtistRelation (com.github.hakko.musiccabinet.domain.model.music.ArtistRelation)1