private KnouNoticeInfo setChangeKnouNoticeFileInfo(KnouNoticeInfo knouNoticeInfo) {
   try {
     Dao<KnouNoticeInfo, Long> knouNoticeInfoDao = this.getHelper().getKnouNoticeInfoDao();
     ForeignCollection<KnouNoticeFileInfo> attacheFiles = knouNoticeInfo.AttacheFiles;
     if (attacheFiles == null) {
       attacheFiles = knouNoticeInfoDao.getEmptyForeignCollection("AttacheFiles");
     }
     attacheFiles.clear();
     for (int i = 0; i < knouNoticeInfo.AttacheFileArrayList.size(); i++) {
       KnouNoticeFileInfo knouNoticeFileInfo = knouNoticeInfo.AttacheFileArrayList.get(i);
       knouNoticeFileInfo._KNOU_NOTICE_ID = knouNoticeInfo;
       attacheFiles.add(knouNoticeFileInfo);
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   return knouNoticeInfo;
 }
 public boolean setParamValue(String paramName, int value) {
   boolean result = false;
   if (!TextUtils.isEmpty(paramName) && params != null) {
     GRWorkoutDayExerciseParamModel param = getParam(paramName);
     if (param != null) {
       param.setIntValue(value);
       try {
         result = (params.update(param) > 0);
       } catch (SQLException e) {
         Log.e(TAG, "Can't update/insert parameter " + paramName, e);
         result = false;
       }
     } else {
       GRWorkoutDayExerciseParamModel newParam =
           new GRWorkoutDayExerciseParamModel(paramName, value);
       result = params.add(newParam);
     }
   }
   return result;
 }
Beispiel #3
0
 public void setupDisplay() {
   if (characters != null) return;
   characters = new ArrayList<PlayerCharacter>();
   CloseableIterator<PlayerCharacter> pcs = charactersFC.closeableIterator();
   while (pcs.hasNext()) {
     characters.add(pcs.next());
   }
   try {
     pcs.close();
   } catch (SQLException e) {
   }
 }
  public double getCurrentNoise(TitaniumDb helper) throws SQLException, AngryJulienException {
    Dao<NoiseEntry, Long> dao = helper.dao(NoiseEntry.class, Long.class);
    QueryBuilder<NoiseEntry, Long> qb = dao.queryBuilder();
    long curTime = System.currentTimeMillis();

    double weekAgo = 0.0, dayAgo = 0.0, hourAgo = 0.0;

    //// WEEK AGO
    int count = 0;
    qb.where()
        .eq(NoiseEntry.COLUMN_NAME_PARENT_ID, this.id)
        .and()
        .between(
            NoiseEntry.COLUMN_NAME_TIMESTAMP,
            curTime - TimeUtils.WEEK - TimeUtils.HOUR,
            curTime - TimeUtils.WEEK + TimeUtils.HOUR);
    CloseableIterator<NoiseEntry> it = qb.iterator();
    while (it.hasNext()) {
      weekAgo += it.next().getNoise();
      count++;
    }
    it.close();
    if (count == 0) {
      weekAgo = -1.1;
    } else {
      weekAgo /= count;
    }

    /// DAY AGO
    count = 0;
    qb = dao.queryBuilder();
    qb.where()
        .eq(NoiseEntry.COLUMN_NAME_PARENT_ID, this.id)
        .and()
        .between(
            NoiseEntry.COLUMN_NAME_TIMESTAMP,
            curTime - TimeUtils.DAY - TimeUtils.HOUR,
            curTime - TimeUtils.DAY + TimeUtils.HOUR);
    it = qb.iterator();
    while (it.hasNext()) {
      dayAgo += it.next().getNoise();
      count++;
    }
    it.close();
    if (count == 0) {
      dayAgo = -1.1;
    } else {
      dayAgo /= count;
    }

    //// HOUR AGO
    count = 0;
    qb = dao.queryBuilder();
    qb.where()
        .eq(NoiseEntry.COLUMN_NAME_PARENT_ID, this.id)
        .and()
        .between(
            NoiseEntry.COLUMN_NAME_TIMESTAMP,
            curTime - TimeUtils.HOUR - (5 * TimeUtils.MINUTE),
            curTime - TimeUtils.HOUR + (5 * TimeUtils.MINUTE));
    it = qb.iterator();
    while (it.hasNext()) {
      hourAgo += it.next().getNoise();
      count++;
    }
    it.close();
    if (count == 0) {
      hourAgo = -1.1;
    } else {
      hourAgo /= count;
    }

    double time = 0;
    count = 0;
    if (dayAgo != -1.1) {
      count++;
      time += dayAgo;
    }
    if (weekAgo != -1.1) {
      count++;
      time += weekAgo;
    }
    if (hourAgo != -1.1) {
      count++;
      time += hourAgo;
    }

    if (count > 0) {
      return time / count;
    }

    time = 0.0;
    count = 0;

    it = noiseEntries.closeableIterator();
    while (it.hasNext()) {
      time += it.next().getNoise();
      count++;
    }

    if (count > 0) return time / count;
    throw new AngryJulienException("I am so mad at this point b/c you ain't got anything");
  }