tl1.maxcom
Class BDD

java.lang.Object
  extended by tl1.maxcom.BDD

public class BDD
extends java.lang.Object

Classe de gestion de la base de données. Contient les fonctions pour accéder à la BDD

Author:
Télécom Lille1

Field Summary
private  SQLiteDatabase bdd
           
private static java.lang.String CAT_ID
           
private static java.lang.String CAT_IMAGE
           
private static java.lang.String CAT_NAME
           
private static java.lang.String CAT_NOTE
           
private static java.lang.String CAT_PARENT
           
private  BaseSQLite maBaseSQLite
           
private static java.lang.String NOM_BDD
           
private static int NUM_CAT_ID
           
private static int NUM_CAT_IMAGE
           
private static int NUM_CAT_NAME
           
private static int NUM_CAT_NOTE
           
private static int NUM_CAT_PARENT
           
private static int NUM_SH_DESCRIPTION
           
private static int NUM_SH_FAVORITE
           
private static int NUM_SH_ID
           
private static int NUM_SH_IMAGE
           
private static int NUM_SH_NAME
           
private static int NUM_SH_NBCLIC
           
private static int NUM_SH_NOTE
           
private static int NUM_SH_SOUND
           
private static int NUM_TAX_CAT
           
private static int NUM_TAX_ID
           
private static int NUM_TAX_SHEET
           
private static java.lang.String SHEET_DESCRIPTION
           
private static java.lang.String SHEET_FAVORITE
           
private static java.lang.String SHEET_ID
           
private static java.lang.String SHEET_IMAGE
           
private static java.lang.String SHEET_NAME
           
private static java.lang.String SHEET_NBCLIC
           
private static java.lang.String SHEET_NOTE
           
private static java.lang.String SHEET_SOUND
           
private static java.lang.String TABLE_CATEGORIE
           
private static java.lang.String TABLE_SHEET
           
private static java.lang.String TABLE_TAXONOMY
           
private static java.lang.String TAX_CAT
           
private static java.lang.String TAX_ID
           
private static java.lang.String TAX_SHEET
           
private static int VERSION_BDD
           
 
Constructor Summary
BDD(Context context)
          Création de la BDD et de sa table
 
Method Summary
 void close()
          On ferme l'accés à  la BDD
private  Categorie cursorToCategorie(Cursor c)
          Cette méthode permet de convertir un cursor en une categorie
private  java.util.ArrayList<Categorie> cursorToCategories(Cursor c)
          Permet de convertir un cursor en ensemble de catégories
private  Sheet cursorToSheet(Cursor c)
          Cette méthode permet de convertir un cursor en une fiche
private  java.util.ArrayList<Sheet> cursorToSheets(Cursor c)
          Permet de convertir un cursor en ensemble de fiches
private  java.util.ArrayList<java.lang.Integer> cursorToSheetsByCategoryId(Cursor c)
          Permet de convertir un cursor en ensemble d'entier représentant les ID des fiches
private  Taxonomy cursorToTaxonomy(Cursor c)
          Permet de convertir un cursor en taxonomy
 SQLiteDatabase getBDD()
           
 Categorie getCategorieWithId(int id)
          Récupération d'une catégorie avec son ID
 int getCategoryIdByImagePath(java.lang.String imagePath)
          Récupération de l'ID de la catégorie en fonction de son image
 java.util.ArrayList<Categorie> getChildCategories(int id)
          Récupération des catégories filles avec l'ID de la catégorie mère
 java.util.ArrayList<Sheet> getFavorites()
          Récupération des fiches favorites
 java.util.ArrayList<Categorie> getMainCategories()
           
 java.util.ArrayList<Sheet> getSheetsByCategoryId(int id)
          Récupération des fiches selon leur catégorie
 Sheet getSheetWithId(int id)
          Récupération d'une fiche avec son ID
 Sheet getSheetWithImage(java.lang.String image)
          Récupération d'une fiche avec son image
 Taxonomy getTaxonomyWithId(int id)
          Récupération de la taxonomy en fonction de son ID
 long insertCategorie(Categorie categorie)
          Insertion d'une catégorie dans la BDD.
 long insertSheet(Sheet fiche)
          Insertion d'une fiche dans la BDD.
 long insertTaxonomy(Taxonomy tax)
          Insertion d'une taxonomy dans la base.
 void open()
          On ouvre la BDD en écriture
 int removeCategorieWithID(int id)
          Suppression d'une catégorie avec son ID
 int removeSheetWithID(int id)
          Suppression d'une fiche avec son ID
 int removeTaxonomyWhitID(int id)
          Suppression d'une taxonomy avec son ID
 int updateCategorie(int id, Categorie categorie)
          Mise à jour d'une catégorie.
 int updateSheet(int id, Sheet fiche)
          Mise à jour d'une fiche.
 int updateTaxonomy(int id, Taxonomy tax)
          Mise à jour d'une taxonomy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION_BDD

private static final int VERSION_BDD
See Also:
Constant Field Values

NOM_BDD

private static final java.lang.String NOM_BDD
See Also:
Constant Field Values

TABLE_CATEGORIE

private static final java.lang.String TABLE_CATEGORIE
See Also:
Constant Field Values

CAT_ID

private static final java.lang.String CAT_ID
See Also:
Constant Field Values

NUM_CAT_ID

private static final int NUM_CAT_ID
See Also:
Constant Field Values

CAT_NAME

private static final java.lang.String CAT_NAME
See Also:
Constant Field Values

NUM_CAT_NAME

private static final int NUM_CAT_NAME
See Also:
Constant Field Values

CAT_IMAGE

private static final java.lang.String CAT_IMAGE
See Also:
Constant Field Values

NUM_CAT_IMAGE

private static final int NUM_CAT_IMAGE
See Also:
Constant Field Values

CAT_PARENT

private static final java.lang.String CAT_PARENT
See Also:
Constant Field Values

NUM_CAT_PARENT

private static final int NUM_CAT_PARENT
See Also:
Constant Field Values

CAT_NOTE

private static final java.lang.String CAT_NOTE
See Also:
Constant Field Values

NUM_CAT_NOTE

private static final int NUM_CAT_NOTE
See Also:
Constant Field Values

TABLE_SHEET

private static final java.lang.String TABLE_SHEET
See Also:
Constant Field Values

SHEET_ID

private static final java.lang.String SHEET_ID
See Also:
Constant Field Values

NUM_SH_ID

private static final int NUM_SH_ID
See Also:
Constant Field Values

SHEET_NAME

private static final java.lang.String SHEET_NAME
See Also:
Constant Field Values

NUM_SH_NAME

private static final int NUM_SH_NAME
See Also:
Constant Field Values

SHEET_DESCRIPTION

private static final java.lang.String SHEET_DESCRIPTION
See Also:
Constant Field Values

NUM_SH_DESCRIPTION

private static final int NUM_SH_DESCRIPTION
See Also:
Constant Field Values

SHEET_IMAGE

private static final java.lang.String SHEET_IMAGE
See Also:
Constant Field Values

NUM_SH_IMAGE

private static final int NUM_SH_IMAGE
See Also:
Constant Field Values

SHEET_SOUND

private static final java.lang.String SHEET_SOUND
See Also:
Constant Field Values

NUM_SH_SOUND

private static final int NUM_SH_SOUND
See Also:
Constant Field Values

SHEET_FAVORITE

private static final java.lang.String SHEET_FAVORITE
See Also:
Constant Field Values

NUM_SH_FAVORITE

private static final int NUM_SH_FAVORITE
See Also:
Constant Field Values

SHEET_NBCLIC

private static final java.lang.String SHEET_NBCLIC
See Also:
Constant Field Values

NUM_SH_NBCLIC

private static final int NUM_SH_NBCLIC
See Also:
Constant Field Values

SHEET_NOTE

private static final java.lang.String SHEET_NOTE
See Also:
Constant Field Values

NUM_SH_NOTE

private static final int NUM_SH_NOTE
See Also:
Constant Field Values

TABLE_TAXONOMY

private static final java.lang.String TABLE_TAXONOMY
See Also:
Constant Field Values

TAX_ID

private static final java.lang.String TAX_ID
See Also:
Constant Field Values

NUM_TAX_ID

private static final int NUM_TAX_ID
See Also:
Constant Field Values

TAX_CAT

private static final java.lang.String TAX_CAT
See Also:
Constant Field Values

NUM_TAX_CAT

private static final int NUM_TAX_CAT
See Also:
Constant Field Values

TAX_SHEET

private static final java.lang.String TAX_SHEET
See Also:
Constant Field Values

NUM_TAX_SHEET

private static final int NUM_TAX_SHEET
See Also:
Constant Field Values

bdd

private SQLiteDatabase bdd

maBaseSQLite

private BaseSQLite maBaseSQLite
Constructor Detail

BDD

public BDD(Context context)
Création de la BDD et de sa table

Parameters:
context -
Method Detail

open

public void open()
On ouvre la BDD en écriture


close

public void close()
On ferme l'accés à  la BDD


getBDD

public SQLiteDatabase getBDD()

insertCategorie

public long insertCategorie(Categorie categorie)
Insertion d'une catégorie dans la BDD. Utilisation d'un ContentValues (fonctionne comme une HashMap)

Parameters:
categorie -
Returns:
code d'erreur

insertSheet

public long insertSheet(Sheet fiche)
Insertion d'une fiche dans la BDD. Utilisation d'un ContentValues (fonctionne comme une HashMap)

Parameters:
fiche -
Returns:
code d'erreur

insertTaxonomy

public long insertTaxonomy(Taxonomy tax)
Insertion d'une taxonomy dans la base. Utilisation d'un ContentValues (fonctionne comme une HashMap)

Parameters:
tax -
Returns:
code d'erreur

updateCategorie

public int updateCategorie(int id,
                           Categorie categorie)
Mise à jour d'une catégorie. Consiste à en créer une et à écraser l'ancienne.

Parameters:
id - ID de la catégorie
categorie -
Returns:
code d'erreur

updateSheet

public int updateSheet(int id,
                       Sheet fiche)
Mise à jour d'une fiche. Consiste à en créer une et à écraser l'ancienne.

Parameters:
id - ID de la fiche
categorie -
Returns:
code d'erreur

updateTaxonomy

public int updateTaxonomy(int id,
                          Taxonomy tax)
Mise à jour d'une taxonomy. Consiste à en créer une et à écraser l'ancienne.

Parameters:
id - ID de la taxonomy
categorie -
Returns:
code d'erreur

removeCategorieWithID

public int removeCategorieWithID(int id)
Suppression d'une catégorie avec son ID

Parameters:
id -
Returns:

removeSheetWithID

public int removeSheetWithID(int id)
Suppression d'une fiche avec son ID

Parameters:
id -
Returns:

removeTaxonomyWhitID

public int removeTaxonomyWhitID(int id)
Suppression d'une taxonomy avec son ID

Parameters:
id -
Returns:

getCategorieWithId

public Categorie getCategorieWithId(int id)
Récupération d'une catégorie avec son ID

Parameters:
id -
Returns:
Categorie

getChildCategories

public java.util.ArrayList<Categorie> getChildCategories(int id)
Récupération des catégories filles avec l'ID de la catégorie mère

Parameters:
id -
Returns:
ArrayList

getSheetWithId

public Sheet getSheetWithId(int id)
Récupération d'une fiche avec son ID

Parameters:
id -
Returns:
Sheet

getSheetWithImage

public Sheet getSheetWithImage(java.lang.String image)
Récupération d'une fiche avec son image

Parameters:
id -
Returns:
Sheet

getCategoryIdByImagePath

public int getCategoryIdByImagePath(java.lang.String imagePath)
Récupération de l'ID de la catégorie en fonction de son image

Parameters:
imagePath -
Returns:

getSheetsByCategoryId

public java.util.ArrayList<Sheet> getSheetsByCategoryId(int id)
Récupération des fiches selon leur catégorie

Parameters:
id -
Returns:
ArrayList

getFavorites

public java.util.ArrayList<Sheet> getFavorites()
Récupération des fiches favorites

Returns:
ArrayList

getTaxonomyWithId

public Taxonomy getTaxonomyWithId(int id)
Récupération de la taxonomy en fonction de son ID

Parameters:
id -
Returns:
Taxonomy

cursorToCategorie

private Categorie cursorToCategorie(Cursor c)
Cette méthode permet de convertir un cursor en une categorie

Parameters:
c -
Returns:
Categorie

cursorToSheet

private Sheet cursorToSheet(Cursor c)
Cette méthode permet de convertir un cursor en une fiche

Parameters:
c -
Returns:
Sheet

cursorToSheets

private java.util.ArrayList<Sheet> cursorToSheets(Cursor c)
Permet de convertir un cursor en ensemble de fiches

Parameters:
c -
Returns:
ArrayList

cursorToCategories

private java.util.ArrayList<Categorie> cursorToCategories(Cursor c)
Permet de convertir un cursor en ensemble de catégories

Parameters:
c -
Returns:
ArrayList

cursorToTaxonomy

private Taxonomy cursorToTaxonomy(Cursor c)
Permet de convertir un cursor en taxonomy

Parameters:
c -
Returns:
Taxonomy

cursorToSheetsByCategoryId

private java.util.ArrayList<java.lang.Integer> cursorToSheetsByCategoryId(Cursor c)
Permet de convertir un cursor en ensemble d'entier représentant les ID des fiches

Parameters:
c -
Returns:
ArrayList

getMainCategories

public java.util.ArrayList<Categorie> getMainCategories()