Package devplugin

Examples of devplugin.ChannelDayProgram


        else if(milliSeconds + diff >= 86400 * 1000) {
          date = date.addDays(1);
        }
      }
     
      ChannelDayProgram dayProg = db.getDayProgram(date, ch);
     
      if (dayProg != null) {
        Program prog = dayProg.getProgram(progID);
        if (prog != null) {
          return prog;
        }
        else {
          mLog.warning("could not find program with id '"+progID+"' (date: "+date+")");
View Full Code Here


   * @param channel The channel of the programs.
   * @return an Iterator for all programs of one day and channel.<br>
   * If the requested data is not available, the iterator is empty, but not <code>null</code>.
   */
  public Iterator<Program> getChannelDayProgram(Date date, Channel channel) {
    ChannelDayProgram channelDayProgram = TvDataBase.getInstance()
        .getDayProgram(date, channel);
    if (channelDayProgram == null) {
      return EMPTY_ITERATOR;
    }
    return channelDayProgram.getPrograms();
  }
View Full Code Here

          }
          else {
            /* We have a date array and can test the programs */
            for(int i = 0; i < mChannelDateArr.length; i++) {
              if(mChannelDateArr[i] != null) {
                ChannelDayProgram chProg = TvDataBase.getInstance().getDayProgram(mChannelDateArr[i],ch[i]);

                if(chProg != null && chProg.getProgramCount() > 0 && mOnAirRowProgramsArr[i] != -1) {
                  if (mOnAirRowProgramsArr[i] >= chProg.getProgramCount()) {
                    fillOnAirArrays(ch);
                    mLog.warning("Reset of on-air-arrays");
                  }
                  Program p = chProg.getProgramAt(mOnAirRowProgramsArr[i]);

                  if(p.isOnAir()) {
                    p.validateMarking();
                  } else if(p.isExpired()) {
                    onAirChanged = true;
                    p.validateMarking();

                    int n = mOnAirRowProgramsArr[i]+1;

                    if(n < chProg.getProgramCount()) {
                      mOnAirRowProgramsArr[i] = n;
                      chProg.getProgramAt(mOnAirRowProgramsArr[i]).validateMarking();
                    }
                    else {
                      /* The last day program is expired so we have to
                       * look for the on air program on the next day */
                      mChannelDateArr[i] = mChannelDateArr[i].addDays(1);

                      chProg = TvDataBase.getInstance().getDayProgram(mChannelDateArr[i],ch[i]);

                      // The next day has no data
                      if(chProg == null || chProg.getProgramCount() < 1) {
                        mOnAirRowProgramsArr[i] = -1;
                      } else {
                        mOnAirRowProgramsArr[i] = 0;
                        chProg.getProgramAt(mOnAirRowProgramsArr[i]).validateMarking();
                      }
                    }
                  }
                }
                else if(mChannelDateArr[i].compareTo(Date.getCurrentDate()) < 0) {
                  /* If the date array for the channel contains a date
                   * earlier than today we have to use today instead */
                  mChannelDateArr[i] = Date.getCurrentDate();
                  onAirChanged = true;

                  chProg = TvDataBase.getInstance().getDayProgram(mChannelDateArr[i],ch[i]);

                  if(chProg != null && chProg.getProgramCount() > 0) {
                    mOnAirRowProgramsArr[i] = 0;
                    chProg.getProgramAt(mOnAirRowProgramsArr[i]).validateMarking();
                  }
                }
              }
            }
          }
View Full Code Here

    Arrays.fill(mOnAirRowProgramsArr, -1);

    Date currentDate = Date.getCurrentDate();
    for(int i = 0; i < ch.length; i++) {
      ChannelDayProgram chProg = TvDataBase.getInstance().getDayProgram(currentDate,ch[i]);

      if(chProg == null) {
        mChannelDateArr[i] = null;
      } else {
        int n = chProg.getProgramCount();

        for(int j = 0; j < n; j++) {
          Program p = chProg.getProgramAt(j);
          if(p.isOnAir() || !p.isExpired()) {
            p.validateMarking();
            mOnAirRowProgramsArr[i] = j;
            mChannelDateArr[i] = currentDate;
            break;
          }
        }

        if(mOnAirRowProgramsArr[i] == -1) {
          chProg = TvDataBase.getInstance().getDayProgram(currentDate.addDays(1),ch[i]);

          if(chProg != null && chProg.getProgramCount() > 0 && chProg.getProgramAt(0).isOnAir()) {
            chProg.getProgramAt(0).validateMarking();
            mOnAirRowProgramsArr[i] = 0;
          }

          mChannelDateArr[i] = currentDate.addDays(1);
        }
View Full Code Here

      /*
       * Search through all channels.
       */
      Date currentDate = Date.getCurrentDate();
      for (Channel channel : channels) {
        ChannelDayProgram today = TvDataBase.getInstance().getDayProgram(currentDate, channel);

        if (today != null && today.getProgramCount() > 0) {
          final int programCount = today.getProgramCount();
          for (int j = 0; j < programCount; j++) {
            if (j == 0 && today.getProgramAt(j).getStartTime() > IOUtilities.getMinutesAfterMidnight()) {
              ChannelDayProgram yesterday = TvDataBase.getInstance().getDayProgram(currentDate.addDays(-1), channel);

              if (yesterday != null && yesterday.getProgramCount() > 0) {
                Program p = yesterday.getProgramAt(yesterday.getProgramCount() - 1);

                if (p.isOnAir()) {
                  addToNowRunning(p, programs, additional);
                  Program p1 = today.getProgramAt(0);
                  addToNext(p1, nextPrograms, nextAdditionalPrograms);
                  break;
                }
              }
            }

            Program p = today.getProgramAt(j);

            if (p.isOnAir()) {
              addToNowRunning(p, programs, additional);
              Program nextProgram = null;
              if (j < programCount - 1) {
                nextProgram = today.getProgramAt(j + 1);
              } else {
                ChannelDayProgram tomorrow = TvDataBase.getInstance().getDayProgram(currentDate.addDays(1), channel);
                if (tomorrow != null && tomorrow.getProgramCount() > 0) {
                  nextProgram = tomorrow.getProgramAt(0);
                }
              }
              if (nextProgram != null) {
                addToNext(nextProgram, nextPrograms, nextAdditionalPrograms);
              }
View Full Code Here

            }
          } else if (start > time && day == 1 && count == 0) {

            int temptime = time + 24 * 60;
            try {
              ChannelDayProgram dayProg = TvDataBase.getInstance().getDayProgram(currentDate, ch);
              p = dayProg.getProgramAt(dayProg.getProgramCount() - 1);

              start = p.getStartTime();
              end = p.getStartTime() + p.getLength();

              if (start <= temptime && temptime < end && MainFrame.getInstance().getProgramFilter().accept(p)) {
View Full Code Here

        if (progress != null) {
          progress.setValue(day * channels.length + channelIdx);
        }
        Channel channel = channels[channelIdx];
        if (channel != null) {
            ChannelDayProgram dayProg = TvDataBase.getInstance().getDayProgram(startDate, channel);
            if (dayProg != null) {
              // This day has data -> remember it
              lastDayWithData = day;

              // Search this day program
              for (int i = 0; i < dayProg.getProgramCount(); i++) {
                final Program prog = dayProg.getProgramAt(i);
                if (matches(prog, fieldArr)) {
                  if(listModel != null) {
                    SwingUtilities.invokeLater(new Runnable() {
                      public void run() {
                        int insertIndex = 0;
View Full Code Here

        // Get the channel and date
        Channel channel = getChannelFromFileName(key, channelArr, channelIdArr);
        if ((channel != null) && (date != null)) {
          mLog.info("Day program was deleted by third party: " + date + " on "
              + channel.getName());
          ChannelDayProgram dummyProg = new MutableChannelDayProgram(date,
              channel);
          fireDayProgramTouched(dummyProg, null);
          fireDayProgramDeleted(dummyProg);

          mTvDataInventory.setUnknown(date, channel);
        }
        else {
          // we do not know the channel of this file -> remove from list of
          // remembered files
          mTvDataInventory.setUnknown(key);
        }
      }
    }

    // Check whether day programs were added or replaced
    for (File tvDataFile : tvDataArr) {
      String fileName = tvDataFile.getName();

      // Get the channel and date
      Channel channel = getChannelFromFileName(fileName, channelArr,
          channelIdArr);
      Date date = getDateFromFileName(fileName);
      if ((channel != null) && (date != null)) {
        // Get the version
        int version = (int) tvDataFile.length();

        // Check whether this day program is known
        int knownStatus = mTvDataInventory.getKnownStatus(date, channel,
            version);

        if ((knownStatus == TvDataInventory.UNKNOWN)
            || (knownStatus == TvDataInventory.OTHER_VERSION)) {
          // do not try to read very old unknown files
          if (isValidDate(date)) {
            if (!somethingChanged) {
              // This is the first changed day program -> fire update start
              TvDataUpdater.getInstance().fireTvDataUpdateStarted();
            }

            // Inform the listeners
            mLog.info("Day program was changed by third party: " + date + " on "
                + channel.getName());
            ChannelDayProgram newDayProg = getDayProgram(date, channel, false);
            if (newDayProg != null) {
              handleKnownStatus(knownStatus, newDayProg, version);
            }

            somethingChanged = true;
View Full Code Here

    }

    // Create a backup (Rename the old file if it exists)
    File file = getDayProgramFile(date, channel);
    File backupFile = null;
    ChannelDayProgram oldProg = getDayProgram(date, channel, false);
    if (file.exists()) {
      backupFile = new File(file.getAbsolutePath() + ".backup");
      if (!file.renameTo(backupFile)) {
        // Renaming failed -> There will be no backup
        backupFile = null;
View Full Code Here

        Channel ch = getChannelFromFileName(deleteFile.getName(), channelArr, channelIdArr);
        Date date = getDateFromFileName(deleteFile.getName());

        if(ch != null && date != null) {
          if(informPlugins) {
            ChannelDayProgram dayProgram = getDayProgram(date, ch);
            if (dayProgram != null) {
              fireDayProgramTouched(dayProgram, null);
              fireDayProgramDeleted(dayProgram);
            }
          }
View Full Code Here

TOP

Related Classes of devplugin.ChannelDayProgram

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.