Example #1
0
  public void checkConsistencyErrors(String confLoggerId) {
    // check logger ID
    if (confLoggerId != null && !confLoggerId.equals(loggerId)) {
      setWrongLoggerId(true);
    }
    // check scanPoint for record
    ScanPoint scanPoint = null;
    int scanpointOrderConverted = -1;
    try {
      scanpointOrderConverted = Integer.parseInt(scanpointOrder);
      scanPoint = ScanPointsRegistry.getInstance().getScanPointByOrder(scanpointOrderConverted);
    } catch (NumberFormatException e) {
    }
    if (scanpointOrderConverted == -1 || scanPoint == null) {
      setWrongScanPoint(true);
      return;
    }
    // check team ID
    Team team = null;
    try {
      int teamNumber = extractTeamNumber();
      team = TeamsRegistry.getInstance().getTeamByNumber(teamNumber);
    } catch (NumberFormatException e) {
    }
    if (team == null) {
      setWrongTeamNumber(true);
      return;
    }
    // check record date and time
    try {
      LevelPoint levelPoint = scanPoint.getLevelPointByDistance(team.getDistanceId());

      Date recordDateTimeMinutes = DateUtils.trimToMinutes(sdf.parse(recordDateTime));
      Date dateFrom = levelPoint.getLevelPointMinDateTime();
      Date dateTo = levelPoint.getLevelPointMaxDateTime();
      if (levelPoint.getPointType() == PointType.START) {
        dateFrom = shiftTimeForStart(dateFrom, -10);
        // check start only for levelPointMinDateTime
        // if started after max time, then start time = max
        if (recordDateTimeMinutes.before(dateFrom)) {
          setWrongRecordDateTime(true);
        }
      } else {
        // check other levelPoints for hitting min and max limits
        if (recordDateTimeMinutes.before(dateFrom) || recordDateTimeMinutes.after(dateTo)) {
          setWrongRecordDateTime(true);
        }
      }
    } catch (Exception e) {
      Log.d("CHECK_LOGDATA", "exception during time check", e);
      setWrongRecordDateTime(true);
    }
  }
  public static synchronized List<RawTeamLevelDismiss> loadRawTeamLevelDismiss(int scanPointId) {
    List<RawTeamLevelDismiss> result = new ArrayList<RawTeamLevelDismiss>();
    try {
      Connection conn = ConnectionPool.getInstance().getConnection();
      Statement stmt = null;
      ResultSet rs = null;
      try {
        String sql =
            "select `"
                + USER_ID
                + "`, `"
                + DEVICE_ID
                + "`, `"
                + TEAM_ID
                + "`, `"
                + TEAMUSER_ID
                + "`, `"
                + DISMISS_DATE
                + "` from `"
                + TABLE_RAW_TEAM_LEVEL_DISMISS
                + "` where `"
                + SCANPOINT_ID
                + "` = "
                + scanPointId;
        stmt = conn.createStatement();
        rs = stmt.executeQuery(sql);
        while (rs.next()) {
          Integer userId = rs.getInt(1);
          Integer deviceId = rs.getInt(2);
          Integer teamId = rs.getInt(3);
          Integer teamUserId = rs.getInt(4);
          Date recordDateTime = DateFormat.parse(rs.getString(5));

          RawTeamLevelDismiss rawTeamLevelDismiss =
              new RawTeamLevelDismiss(
                  userId, deviceId, scanPointId, teamId, teamUserId, recordDateTime);
          // init reference fields
          rawTeamLevelDismiss.setScanPoint(
              ScanPointsRegistry.getInstance().getScanPointById(scanPointId));
          rawTeamLevelDismiss.setTeam(TeamsRegistry.getInstance().getTeamById(teamId));

          result.add(rawTeamLevelDismiss);
        }
      } finally {
        try {
          if (rs != null) {
            rs.close();
            rs = null;
          }
          if (stmt != null) {
            stmt.close();
            stmt = null;
          }
          if (conn != null) {
            conn.close();
            conn = null;
          }
        } catch (SQLException e) {
          // resource release failed
        }
      }
    } catch (Exception e) {
      logger.error(e.getMessage());
      logger.debug("error trace", e);
    }

    return result;
  }