Package application.exceptions

Examples of application.exceptions.DataFormatException


  }

  public void setTaux(double taux) throws DataFormatException
  {
    if(taux < 0)
      throw new DataFormatException("Le taux de repartition du genre ne peut etre negatif.");

    _taux = taux;
  }
View Full Code Here


   *
   */
  public void setCode(String code) throws DataFormatException
  {
    if(code.length() < 1 || code.length() > 2)
      throw new DataFormatException("Le code genre doit faire entre 1 et 2 caracteres.");

    _code = code;
  }
View Full Code Here

  }

  public void setLibelle(String libelle) throws DataFormatException
  {
    if(libelle.length() < 1 || libelle.length() > 30)
      throw new DataFormatException("Le libelle doit faire entre 1 et 30 caracteres.");

    _libelle = libelle;
  }
View Full Code Here

  }

  public void ajouterFilm(String titre, Collection<ModeleGenre> genres, ModeleIndividu realisateur, Collection<ModeleIndividu> acteurs) throws SQLException, DataFormatException
  {
    if(genres.size() < 1)
      throw new DataFormatException("Il faut au moins un genre.");
    if(acteurs.size() < 1)
      throw new DataFormatException("Il faut au moins un acteur.");
    if(realisateur.getPrenom() == null & realisateur.getNom() == null)
      throw new DataFormatException("Le realisateur doit avoir au moins un nom ou un prenom.");
    // Ajout du realisateur avant de pouvoir ajouter le film
    realisateur.setDB(_DB);
    int numRealisateur = realisateur.ajouter();

    // Ajout du film
    ModeleFilm film = new ModeleFilm(_DB);
    film.setTitre(titre);
    film.setRealisateur(realisateur);
    int numFilm = film.ajouter();

    // Si le film n'existe pas
    if(numFilm > 0)
    {

      // Ajout des genres au film
      Iterator<ModeleGenre> itGenres = genres.iterator();
      CallableStatement cst = _DB.prepareCall("{call majVideotheque.ajouterGenre(?, ?)}");
      ModeleGenreFilm genreFilm = new ModeleGenreFilm(_DB);
      genreFilm.setNumFilm(numFilm);
      while(itGenres.hasNext())
      {
        genreFilm.setCodeGenre(itGenres.next().getCode());
        genreFilm.ajouter(cst);
      }
      cst.close();

      // Ajout des acteurs au film
      Iterator<ModeleIndividu> itActeurs = acteurs.iterator();
      cst = _DB.prepareCall("{call majVideotheque.ajouterActeur(?, ?, ?)}");
      ModeleActeur acteur = new ModeleActeur(_DB);
      acteur.setNumFilm(numFilm);
      ModeleIndividu individu;
      while(itActeurs.hasNext())
      {
        individu = itActeurs.next();
        if(individu.getPrenom() == null && individu.getNom() == null)
          throw new DataFormatException("Un acteur n'a ni nom, ni prenom.");
        acteur.setIndividu(individu);

        acteur.ajouter(cst);
      }
      cst.close();
    }
    // Si le film existe
    else
      throw new DataFormatException("Le film existe deja.");
  }
View Full Code Here

   */

  public void setNum(int num) throws DataFormatException
  {
    if(num < 1)
      throw new DataFormatException("Le numero d'identifiant de l'individu est incorrect.");

    _num = num;
  }
View Full Code Here

  }

  public void setPrenom(String prenom) throws DataFormatException
  {
    if(prenom != null && prenom.length() > 30)
      throw new DataFormatException("Le prenom doit faire entre 1 et 30 caracteres.");

    _prenom = prenom;
  }
View Full Code Here

  }

  public void setNom(String nom) throws DataFormatException
  {
    if(nom != null && nom.length() > 30)
      throw new DataFormatException("Le nom doit faire entre 1 et 30 caracteres.");

    _nom = nom;
  }
View Full Code Here

   *
   */
  public int ajouter() throws DataFormatException, SQLException
  {
    if(!(_DB instanceof Database))
      throw new DataFormatException("Cet object individu est en lecture seule.");
    if((_prenom == null) || (_nom == null))
      throw new DataFormatException("Les attributs prenom et nom doivent etre renseignes.");

    // Ajout dans la base de donnees
    CallableStatement cst = _DB.prepareCall("{? = call MAJVIDEOTHEQUE.AJOUTERINDIVIDU(?, ?)}");
    cst.setString(2, _nom);
    cst.setString(3, _prenom);
View Full Code Here

   *
   */
  public int ajouter(CallableStatement cst) throws DataFormatException, SQLException
  {
    if(!(_DB instanceof Database))
      throw new DataFormatException("Cet object individu est en lecture seule.");
    if((_prenom == null) || (_nom == null))
      throw new DataFormatException("Les attributs prenom et nom doivent etre renseignes.");

    // Ajout dans la base de donnees
    cst.setString(2, _nom);
    cst.setString(3, _prenom);
    cst.registerOutParameter(1, java.sql.Types.INTEGER);
View Full Code Here

 
  public void setNumFilm(int numFilm) throws DataFormatException
  {
    if(numFilm < 1)
      throw new DataFormatException("Le numero d'identifiant du film est incorrect.");

    _numFilm = numFilm;
  }
View Full Code Here

TOP

Related Classes of application.exceptions.DataFormatException

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.