Package com.totalchange.jizz.web.shared.home

Examples of com.totalchange.jizz.web.shared.home.HomeResult


    @Override
    public HomeResult execute(HomeAction action, ExecutionContext context)
            throws DispatchException {
        logger.trace("Jizz Home execution underway");
        HomeResult result = new HomeResult();

        // Look for the station - if nothing there then this is a new install
        JizzStation station = jizzStationDao.getPrimaryStation();
        if (station == null) {
            result.setNewInstall(true);
            logger.info("New install detected by virtue of no primary "
                    + "station.  Returning result {}", result);
            return result;
        }
        result.setStationName(station.getName());

        // Look for the DJ based on their login name
        JizzDj dj = jizzDjServices.getCurrentDj();
        result.setName(dj.getName());
        result.setEmail(dj.getEmail());
        if (dj.getEmail() != null && dj.getEmail().length() > 0 && dj.getEmailConfirmation() != null) {
            result.setEmailAwaitingConfirmation(true);
        } else {
            result.setEmailAwaitingConfirmation(false);
        }
        result.setLocale(dj.getLocale());

        // Look up the next broadcast and set in its details
        JizzBroadcast broadcast = jizzBroadcastServices
                .getNextBroadcast(station);
        if (broadcast.getActualStart() != null) {
            logger.trace("Broadcast start date isn't estimated - it's "
                    + "confirmed");
            result.setNextBroadcastStartDateEstimated(false);
            result.setNextBroadcastStartDate(broadcast.getActualStart());
        } else {
            logger.trace("Broadcast start date is still estimated");
            result.setNextBroadcastStartDateEstimated(true);
            result.setNextBroadcastStartDate(broadcast.getEstimatedStart());
        }
        result.setNextBroadcastEndDate(broadcast.getFinale());

        // Find this DJ's history for this broadcast
        List<JizzSong> songs = jizzSongServices.getSongsForBroadcast(dj,
                broadcast);
        List<HomeResultSong> resultSongs = new ArrayList<HomeResultSong>(
                songs.size());
        for (JizzSong song : songs) {
            HomeResultSong resultSong = new HomeResultSong();
            resultSong.setArtist(song.getArtist());
            resultSong.setTitle(song.getTitle());
            resultSongs.add(resultSong);
        }
        result.setSubmittedSongs(resultSongs);

        // How many songs can this DJ submit?
        result.setHowManySongsDjCanSubmit(jizzSongServices
                .getHowManySongsDjCanSubmit(dj, broadcast, songs));

        logger.trace("Jizz Home execution complete with result {}", result);
        return result;
    }
View Full Code Here


    @Test
    public void testExecuteNewInstall() throws DispatchException {
        expect(mockJizzStationDao.getPrimaryStation()).andReturn(null);

        replayAll();
        HomeResult result = homeHandler.execute(new HomeAction(), null);
        assertTrue(result.isNewInstall());
        verifyAll();
    }
View Full Code Here

       
        expect(mockJizzStationDao.getPrimaryStation()).andReturn(mockStation);
        expect(mockJizzDjServices.getCurrentDj()).andReturn(mockDj);

        replayAll();
        HomeResult result = homeHandler.execute(new HomeAction(), null);
        assertEquals(mockDj.getName(), result.getName());
       
        verifyAll();       
    }
View Full Code Here

TOP

Related Classes of com.totalchange.jizz.web.shared.home.HomeResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.