Search in sources :

Example 1 with GroupWeeklyArtistChart

use of com.github.hakko.musiccabinet.domain.model.aggr.GroupWeeklyArtistChart in project musiccabinet by hakko.

the class JdbcGroupWeeklyArtistChartDao method createArtistCharts.

@Override
public void createArtistCharts(List<GroupWeeklyArtistChart> artistCharts) {
    if (artistCharts.size() > 0) {
        clearImportTable();
        for (GroupWeeklyArtistChart artistChart : artistCharts) {
            batchInsert(artistChart);
        }
        updateArtistCharts();
    }
}
Also used : GroupWeeklyArtistChart(com.github.hakko.musiccabinet.domain.model.aggr.GroupWeeklyArtistChart)

Example 2 with GroupWeeklyArtistChart

use of com.github.hakko.musiccabinet.domain.model.aggr.GroupWeeklyArtistChart in project musiccabinet by hakko.

the class JdbcGroupWeeklyArtistChartDaoTest method loadFunctionDependency.

@Before
public void loadFunctionDependency() throws ApplicationException {
    PostgreSQLUtil.loadFunction(dao, UPDATE_GROUP_WEEKLY_ARTIST_CHART);
    PostgreSQLUtil.loadFunction(dao, UPDATE_LASTFMGROUP);
    artistChart = new GroupWeeklyArtistChart(brainwashed.getName(), new GroupWeeklyArtistChartParserImpl(new ResourceUtil(BRAINWASHED_FILE).getInputStream()).getArtistPlayCount());
    Collections.sort(artistChart.getArtistPlayCounts());
    createArtistMetaData();
}
Also used : ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) GroupWeeklyArtistChart(com.github.hakko.musiccabinet.domain.model.aggr.GroupWeeklyArtistChart) GroupWeeklyArtistChartParserImpl(com.github.hakko.musiccabinet.parser.lastfm.GroupWeeklyArtistChartParserImpl) Before(org.junit.Before)

Example 3 with GroupWeeklyArtistChart

use of com.github.hakko.musiccabinet.domain.model.aggr.GroupWeeklyArtistChart in project musiccabinet by hakko.

the class GroupWeeklyArtistChartService method updateSearchIndex.

@Override
public void updateSearchIndex() throws ApplicationException {
    List<GroupWeeklyArtistChart> artistCharts = new ArrayList<>();
    List<LastFmGroup> groups = lastFmDao.getLastFmGroups();
    setTotalOperations(groups.size());
    for (LastFmGroup group : groups) {
        try {
            WSResponse wsResponse = client.getWeeklyArtistChart(group);
            if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
                StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
                GroupWeeklyArtistChartParser parser = new GroupWeeklyArtistChartParserImpl(stringUtil.getInputStream());
                artistCharts.add(new GroupWeeklyArtistChart(group.getName(), parser.getArtistPlayCount()));
            }
        } catch (ApplicationException e) {
            LOG.warn("Fetching weekly artist chart for " + group.getName() + " failed.", e);
        }
        addFinishedOperation();
    }
    dao.createArtistCharts(artistCharts);
}
Also used : LastFmGroup(com.github.hakko.musiccabinet.domain.model.library.LastFmGroup) ApplicationException(com.github.hakko.musiccabinet.exception.ApplicationException) ArrayList(java.util.ArrayList) GroupWeeklyArtistChart(com.github.hakko.musiccabinet.domain.model.aggr.GroupWeeklyArtistChart) GroupWeeklyArtistChartParser(com.github.hakko.musiccabinet.parser.lastfm.GroupWeeklyArtistChartParser) WSResponse(com.github.hakko.musiccabinet.ws.lastfm.WSResponse) StringUtil(com.github.hakko.musiccabinet.util.StringUtil) GroupWeeklyArtistChartParserImpl(com.github.hakko.musiccabinet.parser.lastfm.GroupWeeklyArtistChartParserImpl)

Example 4 with GroupWeeklyArtistChart

use of com.github.hakko.musiccabinet.domain.model.aggr.GroupWeeklyArtistChart in project musiccabinet by hakko.

the class GroupWeeklyArtistChartServiceTest method canInvokeService.

@Test
public void canInvokeService() throws ApplicationException {
    GroupWeeklyArtistChart artistChart = service.getWeeklyArtistChart(new LastFmGroup("group name"));
    Assert.assertNotNull(artistChart);
    Assert.assertEquals(0, artistChart.getArtistPlayCounts().size());
}
Also used : LastFmGroup(com.github.hakko.musiccabinet.domain.model.library.LastFmGroup) GroupWeeklyArtistChart(com.github.hakko.musiccabinet.domain.model.aggr.GroupWeeklyArtistChart) Test(org.junit.Test)

Example 5 with GroupWeeklyArtistChart

use of com.github.hakko.musiccabinet.domain.model.aggr.GroupWeeklyArtistChart in project musiccabinet by hakko.

the class JdbcGroupWeeklyArtistChartDaoTest method validateSingleImport.

@Test
public void validateSingleImport() {
    GroupWeeklyArtistChart daoChart = dao.getWeeklyArtistChart(brainwashed);
    Assert.assertNotNull(daoChart);
    Assert.assertNotNull(daoChart.getArtistPlayCounts());
    Assert.assertEquals(artistChart, daoChart);
}
Also used : GroupWeeklyArtistChart(com.github.hakko.musiccabinet.domain.model.aggr.GroupWeeklyArtistChart) Test(org.junit.Test)

Aggregations

GroupWeeklyArtistChart (com.github.hakko.musiccabinet.domain.model.aggr.GroupWeeklyArtistChart)5 LastFmGroup (com.github.hakko.musiccabinet.domain.model.library.LastFmGroup)2 GroupWeeklyArtistChartParserImpl (com.github.hakko.musiccabinet.parser.lastfm.GroupWeeklyArtistChartParserImpl)2 Test (org.junit.Test)2 ApplicationException (com.github.hakko.musiccabinet.exception.ApplicationException)1 GroupWeeklyArtistChartParser (com.github.hakko.musiccabinet.parser.lastfm.GroupWeeklyArtistChartParser)1 ResourceUtil (com.github.hakko.musiccabinet.util.ResourceUtil)1 StringUtil (com.github.hakko.musiccabinet.util.StringUtil)1 WSResponse (com.github.hakko.musiccabinet.ws.lastfm.WSResponse)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1