/**
  * Supprime le distances/blason de la base.
  *
  * @throws SQLException
  */
 @Override
 public void delete() throws SqlPersistanceException {
   helper.delete(
       this,
       Collections.singletonMap(
           "NUMREGLEMENT", (Object) criteriaSet.getReglement().getNumReglement())); // $NON-NLS-1$
 }
  /** Sauvegarde la fédération en base de données. Les arguments sont ignoré. */
  @Override
  public void save() throws SqlPersistanceException {
    try {
      checkAlreadyExists();
      helper.save(this);

      String sql =
          "delete from NIVEAU_COMPETITION where NUMFEDERATION=" + numFederation; // $NON-NLS-1$
      Statement stmt = ApplicationCore.dbConnection.createStatement();
      stmt.executeUpdate(sql);

      Map<String, List<CompetitionLevel>> langFilteredCL =
          new HashMap<String, List<CompetitionLevel>>();

      for (CompetitionLevel cl : competitionLevels) {
        if (!langFilteredCL.containsKey(cl.getLang()))
          langFilteredCL.put(cl.getLang(), new ArrayList<CompetitionLevel>());
        langFilteredCL.get(cl.getLang()).add(cl);
      }

      for (Entry<String, List<CompetitionLevel>> entry : langFilteredCL.entrySet()) {
        int i = 1;
        for (CompetitionLevel cl : entry.getValue()) {
          cl.setNumLevel(i++);
          cl.save();
        }
      }
    } catch (SQLException e) {
      throw new SqlPersistanceException(e);
    }
  }
  /**
   * Sauvegarde le couple distances/blasons en base.
   *
   * @see org.ajdeveloppement.commons.sql.SqlPersistance#save()
   * @throws SqlPersistanceException
   */
  @SuppressWarnings("nls")
  @Override
  public void save() throws SqlPersistanceException {
    criteriaSet.save();

    Map<String, Object> fk = new HashMap<String, Object>();
    fk.put("NUMREGLEMENT", criteriaSet.getReglement().getNumReglement()); // $NON-NLS-1$
    fk.put("NUMBLASON", targetFace.getNumblason());
    fk.put("NUMCRITERIASET", criteriaSet.getNumCriteriaSet());
    helper.save(this, fk);

    try {
      Statement stmt = ApplicationCore.dbConnection.createStatement();
      try {
        stmt.executeUpdate(
            "delete from DISTANCES where NUMDISTANCESBLASONS="
                + numdistancesblason
                + " and NUMREGLEMENT="
                + criteriaSet.getReglement().getNumReglement());
        int i = 1;
        for (int distance : distances) {
          stmt.executeUpdate(
              "insert into DISTANCES (NUMDISTANCES, NUMDISTANCESBLASONS, NUMREGLEMENT, DISTANCE) "
                  + //$NON-NLS-1$
                  "VALUES ("
                  + (i++)
                  + ", "
                  + numdistancesblason
                  + ", "
                  + criteriaSet.getReglement().getNumReglement()
                  + ", "
                  + distance
                  + ")");
        }
      } finally {
        stmt.close();
      }
    } catch (SQLException e) {
      throw new SqlPersistanceException(e);
    }
  }
 /**
  * Supprime la fédération de la base de données. Les arguments sont ignoré.
  *
  * <p>Tous les règlements attaché à cette fédération seront également supprimés
  */
 @Override
 public void delete() throws SqlPersistanceException {
   helper.delete(this);
 }