Package org.jampa.model.statistics

Examples of org.jampa.model.statistics.StatisticItem


    String id;
    StatisticItemType type;
    String displayValue;
    String additionalValue;
    int value;
    StatisticItem item;
   
    Log.getInstance(StatisticsController.class).debug("Reading statistics."); //$NON-NLS-1$
   
    try {
      while (rs.next()) {
       
        id = rs.getString("ID"); //$NON-NLS-1$
        type = StatisticItemType.getValueOf(rs.getString("TYPE")); //$NON-NLS-1$
        displayValue = rs.getString("DISPLAY"); //$NON-NLS-1$
        additionalValue = rs.getString("ADDITIONAL"); //$NON-NLS-1$
        value = rs.getInt("VALUE"); //$NON-NLS-1$
       
        item = new StatisticItem(id, type, displayValue, additionalValue, value);
        _statsList.put(id, item);
      }
    } catch (SQLException e) {
      Log.getInstance(StatisticsController.class).error(e.getMessage());
    }   
View Full Code Here


 
  public void notifyPlay(String playlist, IAudioItem audioItem) {
    if ((_boStatsActivated) &&
        (audioItem instanceof AudioItem)) {
      String key;
      StatisticItem item;

      key = getKey(StatisticItemType.Playlist, playlist);
      if (_statsList.containsKey(key)) {
        item = _statsList.get(key);
      } else {
        item = new StatisticItem(key, StatisticItemType.Playlist, playlist, "", 0); //$NON-NLS-1$
        _statsList.put(key, item);
      }
      item.incValue();

      key = getKey(StatisticItemType.Genre, audioItem.getPropertiesList().get(AudioItem.GENRE));
      if (_statsList.containsKey(key)) {
        item = _statsList.get(key);
      } else {
        item = new StatisticItem(key, StatisticItemType.Genre, audioItem.getPropertiesList().get(AudioItem.GENRE), "", 0); //$NON-NLS-1$
        _statsList.put(key, item);
      }
      item.incValue();

      key = getKey(StatisticItemType.Artist, audioItem.getPropertiesList().get(AudioItem.ARTIST));
      if (_statsList.containsKey(key)) {
        item = _statsList.get(key);
      } else {
        item = new StatisticItem(key, StatisticItemType.Artist, audioItem.getPropertiesList().get(AudioItem.ARTIST), "", 0); //$NON-NLS-1$
        _statsList.put(key, item);
      }
      item.incValue();

      key = getKey(StatisticItemType.Album, audioItem.getPropertiesList().get(AudioItem.ALBUM));
      if (_statsList.containsKey(key)) {
        item = _statsList.get(key);
      } else {
        item = new StatisticItem(key,
            StatisticItemType.Album,
            audioItem.getPropertiesList().get(AudioItem.ALBUM),
            audioItem.getPropertiesList().get(AudioItem.ARTIST),
            0);
        _statsList.put(key, item);
      }
      item.incValue();

      key = getKey(StatisticItemType.Title, audioItem.getFileName());
      if (_statsList.containsKey(key)) {
        item = _statsList.get(key);
      } else {
        item = new StatisticItem(key,
            StatisticItemType.Title,
            audioItem.getPropertiesList().get(AudioItem.TITLE),
            audioItem.getPropertiesList().get(AudioItem.ARTIST) + " - " + audioItem.getPropertiesList().get(AudioItem.ALBUM),//$NON-NLS-1$           
            0);
        _statsList.put(key, item);
      }
      item.incValue();
    }
  }
View Full Code Here

    if (_boStatsActivated) {
      Log.getInstance(StatisticsController.class).debug("Writing statistics."); //$NON-NLS-1$

      Controller.getInstance().getHSQLController().resetStatisticsTable();

      StatisticItem item;
      Iterator<String> iter = _statsList.keySet().iterator();
      while (iter.hasNext()) {
        item = _statsList.get(iter.next());
        Controller.getInstance().getHSQLController().writeStatisticItem(item.getId(), item.getType().getValue(), item.getDisplayValue(), item.getAdditionalValue(), item.getValue());
      }
      Controller.getInstance().getHSQLController().doCommitDatabase();
    }
  }
View Full Code Here

    if (_boStatsActivated) {
      List<StatisticItem> tmpList = new ArrayList<StatisticItem>();
      List<StatisticItem> tmpLimitedList = new ArrayList<StatisticItem>();

      int totalCount = 0;
      StatisticItem item;
      Iterator<String> iter = _statsList.keySet().iterator();   
      while (iter.hasNext()) {
        item = _statsList.get(iter.next());
        if (item.getType() == type) {
          totalCount = totalCount + item.getValue();
          tmpList.add(item);
        }
      }

      Iterator<StatisticItem> iterItem = tmpList.iterator();
      while (iterItem.hasNext()) {
        item = iterItem.next();
        item.setPercentValue((item.getValue() * 100) / totalCount);
      }

      Collections.sort(tmpList, new StatisticItemComparator());
     
      int itemCount = 0;
View Full Code Here

TOP

Related Classes of org.jampa.model.statistics.StatisticItem

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.