Package com.totalchange.jizz.data.entity

Examples of com.totalchange.jizz.data.entity.JizzBroadcast


        JizzDj mockDj = new JizzDj();
        mockDj.setStation(mockStation);
        mockDj.setName("DJ Teste");
        mockDj.setEmail("test@test.com");

        JizzBroadcast mockBroadcast = new JizzBroadcast();
        mockBroadcast.setStation(mockStation);
        mockBroadcast.setEstimatedStart(new Date());

        for (Locale locale : Locale.getAvailableLocales()) {
            JizzEmailResponse response = renderer.generateSongReminderEmail(
                    locale, mockStation, mockDj, mockBroadcast);
View Full Code Here


        if (station == null) {
            throw new ServletException("Jizz needs to be initialised");
        }

        // Find the current broadcast
        JizzBroadcast broadcast = jizzBroadcastServices
                .getNextBroadcast(station);

        // If the current broadcast isn't finalised yet then need to throw an
        // error
        if (!broadcast.isFinalised()) {
            String msg = Messages.getMessage(station.getLocale(),
                    MSG_ERR_BROADCAST_NOT_FINALISED);

            DateFormat df = DateFormat.getDateInstance(DateFormat.LONG,
                    JizzServiceUtils.forLanguageTag(station.getLocale()));
            df.setTimeZone(station.getTimeZone());
            msg = MessageFormat.format(msg,
                    df.format(broadcast.getEstimatedStart()));

            logger.debug("Returning SC_NOT_FOUND with message {}", msg);
            response.sendError(HttpServletResponse.SC_NOT_FOUND, msg);
            return;
        }
View Full Code Here

        logger.trace("#executeAction(HttpServletRequest, List<FileItem>), "
                + "first up grabbing the current DJ");
        JizzDj dj = jizzDjServices.getCurrentDj();

        logger.trace("Grabbing the next braodcast");
        JizzBroadcast broadcast = jizzBroadcastServices.getNextBroadcast(dj
                .getStation());

        for (FileItem fileItem : sessionFiles) {
            if (!(fileItem instanceof JizzFileItem)) {
                logger.error("Somehow got a non-JizzFileItem instance");
View Full Code Here

    public void sendSongReminderMessage(int broadcastId, int djId)
            throws FatalTaskException {
        logger.trace("Task utility sending song reminder based on broadcast "
                + "id {} and dj id {}", broadcastId, djId);

        JizzBroadcast broadcast = jizzBroadcastServices
                .findBroadcastById(broadcastId);
        if (broadcast == null) {
            throw new FatalTaskException("Cannot execute sending of song "
                    + "reminder message: Broadcast with ID " + broadcastId
                    + " could not be found");
        }

        JizzDj dj = jizzDjServices.findDjById(djId);
        if (dj == null) {
            throw new FatalTaskException("Cannot execute sending of song "
                    + "reminder message: DJ with ID " + djId
                    + " could not be found");
        }

        jizzSongServices.sendSongReminderMessage(broadcast.getStation(),
                broadcast, dj);

        logger.trace("Task utility finished sending song reminder based on "
                + "broadcast id {} and dj id {}", broadcastId, djId);
    }
View Full Code Here

    public void sendNewBroadcastMessages(int broadcastId)
            throws FatalTaskException {
        logger.trace("Task utility sending new broadcast messages based on "
                + "broadcast id {}", broadcastId);

        JizzBroadcast broadcast = jizzBroadcastServices
                .findBroadcastById(broadcastId);
        if (broadcast == null) {
            throw new FatalTaskException("Cannot execute sending of new "
                    + "broadcast messages: Broadcast with ID " + broadcastId
                    + " could not be found");
        }

        jizzBroadcastServices.sendNewBroadcastMessages(broadcast.getStation(),
                broadcast);

        logger.trace("Task utility finished sending new broadcast messages "
                + "based on broadcast id", broadcastId);
    }
View Full Code Here

        this.jizzEmailServices = jizzEmailServices;
        this.jizzTaskQueue = jizzTaskQueue;
    }

    private JizzBroadcast createNewBroadcast(JizzStation station) {
        JizzBroadcast broadcast = new JizzBroadcast();
        broadcast.setStation(station);

        // The most important part of a new broadcast is its end date which is
        // calculated based on the Cron expression of the station
        try {
            Predictor cron = new Predictor(station.getBroadcastSchedule());
            cron.setTimeZone(station.getTimeZone());
            broadcast.setFinale(cron.nextMatchingDate());
        } catch (InvalidPatternException pEx) {
            logger.error("Cron trigger " + station.getBroadcastSchedule()
                    + " is invalid", pEx);

            // Send error to the admins
            String msg = JizzServicesErrors.getString(station.getLocale(),
                    MSG_ERR_INVALID_BROADCAST_SCHEDULE);
            msg = MessageFormat.format(msg, station.getBroadcastSchedule());
            jizzErrorServices.reportErrorToAdmins(station, msg, pEx);

            throw new RuntimeException("The cron trigger '"
                    + station.getBroadcastSchedule()
                    + "' is not valid, can't make a new broadcast", pEx);
        }

        // The estimated start date for now is 2 hours before the end. In the
        // future might try and inspect past broadcasts and guess an average,
        // but not now!
        long millis = broadcast.getFinale().getTime();
        broadcast.setEstimatedStart(new Date(millis
                - GUESSED_BROADCAST_LENGTH_IN_MILLIS));

        broadcast = jizzBroadcastDao.createOrUpdateBroadcast(broadcast);

        try {
View Full Code Here

    @Override
    public JizzBroadcast getNextBroadcast(JizzStation station) {
        logger.trace("Fetching next broadcast for station {}", station);

        // Look for a broadcast
        JizzBroadcast broadcast = jizzBroadcastDao
                .findNearestBroadcast(station);
        if (broadcast == null) {
            logger.debug("No broadcast for station {}, creating a new one",
                    station);
            broadcast = createNewBroadcast(station);
        } else if (broadcast.getFinale().before(new Date())) {
            // If have a broadcast just need to check it's still in date, and if
            // not, create a new one
            logger.debug("Previous broadcast {} has passed so making and "
                    + "moving onto the next", broadcast);
            broadcast = createNewBroadcast(station);
View Full Code Here

TOP

Related Classes of com.totalchange.jizz.data.entity.JizzBroadcast

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.