Package tvbrowserdataservice.file

Examples of tvbrowserdataservice.file.SummaryFile


    String channelId1 = "Ch1";
    String channelId2 = "Ch2";
    String channelId3 = "Ch3";
   
    // Create a test file
    SummaryFile summary1 = new SummaryFile();
   
    summary1.setDayProgramVersion(date3, country, channelId1, 0, 1);
    summary1.setDayProgramVersion(date3, country, channelId1, 1, 2);
    summary1.setDayProgramVersion(date3, country, channelId1, 2, 3);
    summary1.setDayProgramVersion(date2, country, channelId1, 0, 4);
    summary1.setDayProgramVersion(date2, country, channelId1, 2, 5);
    summary1.setDayProgramVersion(date4, country, channelId1, 0, 6);
    summary1.setDayProgramVersion(date4, country, channelId1, 1, 7);
    summary1.setDayProgramVersion(date5, country, channelId1, 0, 8);

    summary1.setDayProgramVersion(date4, country, channelId2, 1, 9);
    summary1.setDayProgramVersion(date4, country, channelId2, 2, 10);
   
    // Save and load the file
    File file = null;
    SummaryFile summary2;
    try {
      file = File.createTempFile("tvbrowser", ".test_summary.gz");

      summary1.writeToFile(file);

      // System.out.println("Test file saved: " + file.getAbsolutePath());
     
      summary2 = new SummaryFile();
      summary2.readFromFile(file);
    }
    finally {
      if (file != null) {
        // file.delete();
      }
    }
   
    // Check the set fields
    assertEquals(summary2.getDayProgramVersion(date3, country, channelId1, 0), 1);
    assertEquals(summary2.getDayProgramVersion(date3, country, channelId1, 1), 2);
    assertEquals(summary2.getDayProgramVersion(date3, country, channelId1, 2), 3);
    assertEquals(summary2.getDayProgramVersion(date2, country, channelId1, 0), 4);
    assertEquals(summary2.getDayProgramVersion(date2, country, channelId1, 2), 5);
    assertEquals(summary2.getDayProgramVersion(date4, country, channelId1, 0), 6);
    assertEquals(summary2.getDayProgramVersion(date4, country, channelId1, 1), 7);
    assertEquals(summary2.getDayProgramVersion(date5, country, channelId1, 0), 8);

    assertEquals(summary2.getDayProgramVersion(date4, country, channelId2, 1), 9);
    assertEquals(summary2.getDayProgramVersion(date4, country, channelId2, 2), 10);
   
    // Check unset version
    assertEquals(summary2.getDayProgramVersion(date2, country, channelId1, 1), -1);

    // Check unset days
    assertEquals(summary2.getDayProgramVersion(date1, country, channelId1, 0), -1);
    assertEquals(summary2.getDayProgramVersion(date6, country, channelId1, 2), -1);
   
    // Check unset channel
    assertEquals(summary2.getDayProgramVersion(date3, country, channelId3, 1), -1);
  }
View Full Code Here


    while (groupIt.hasNext()) {

      monitor.setValue(i++);

      TvBrowserDataServiceChannelGroup group=groupIt.next();
      SummaryFile summaryFile = group.getSummary();
      if (summaryFile != null) {
        Date date = startDate;
        for (int day = 0; day < dateCount; day++) {
          for (TvDataLevel element : mSubscribedLevelArr) {
            String level = element.getId();
View Full Code Here

    InputStream stream = null;
    try {
      stream = IOUtilities.getStream(new URL(url));

      SummaryFile summary = new SummaryFile();
      summary.readFromStream(stream, null);

      return summary;
    } finally {
      if (stream != null) {
        stream.close();
View Full Code Here

   
    header();
   
    for (String mGroup : mGroups) {
      byte[] data;
      SummaryFile summary=null;
      ChannelList channelList=null;
      String groupId=null;
      String lastUpdateFileName=null;
       
      groupId = mGroup;
     
      String groupFileName = mGroup+"_info";
      try {
        data = mSource.loadFile(groupFileName);
      }catch(Exception e) {
        printError("Could not load group file '"+groupFileName+"' for group '"+groupId+"'");
      }
       
      String summaryFileName = mGroup+"_summary.gz";
      try {
        data = mSource.loadFile(summaryFileName);
        summary = new SummaryFile();
        summary.readFromStream(new ByteArrayInputStream(data), null);
      } catch (Exception e) {
        printError("Could not load summary file '"+summaryFileName+"' for group '"+groupId+"'");

      }
     
View Full Code Here


    for (int i=0; i<mGroupNameArr.length; i++) {

      // Create the file
      SummaryFile summary = new SummaryFile();
      File[] fileArr = mWorkDir.listFiles();
      for (File file : fileArr) {
        String fileName = file.getName();
        if (fileName.endsWith("_full.prog.gz")) {
          // This is a complete file -> Put its version to the summary
          try {
            Date date = DayProgramFile.getDateFromFileName(fileName);
            String country = DayProgramFile.getCountryFromFileName(fileName);
            String channelId = DayProgramFile.getChannelNameFromFileName(fileName);
            String levelName = DayProgramFile.getLevelFromFileName(fileName);

            //if (channelBelongsToGroup(channelId, country)) {
            if (RawDataProcessor.channelBelongsToGroup(mChannelListArr[i], channelId, country)) {
              int level = DayProgramFile.getLevelIndexForId(levelName);
              if (level == -1) {
                throw new PreparationException("Day program file has unknown level '"
                    + levelName + "': " + file.getAbsolutePath());
              }
              int version = DayProgramFile.readVersionFromFile(file);

              summary.setDayProgramVersion(date, country, channelId, level, version);
            }
          }
          catch (Exception exc) {
            throw new PreparationException("Adding day program file to summary " +
                "failed: " + file.getAbsolutePath(), exc);
          }
        }
      }

      System.out.println("writing summary to file...");

      // Save the file
      File file = new File(mWorkDir, mGroupNameArr[i]+"_"+SummaryFile.SUMMARY_FILE_NAME);
      try {
        summary.writeToFile(file);
      }
      catch (Exception exc) {
        throw new PreparationException("Writing summary file failed: "
          + file.getAbsolutePath(), exc);
      }
View Full Code Here

TOP

Related Classes of tvbrowserdataservice.file.SummaryFile

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.