Projet d'accès aux résultats des étudiant via client mobile

40
UNIVERSITE DE KINSHASA FACULTE POLYTECHNIQUE 2009 Travail réalisé par : BASHIZI MUTUZI Patrick TRAVAIL PRATIQUE DE LANGAGE DE PROGRAMMATION Access aux résultats de la délibération des étudiants de la faculté polytechnique par Client Mobile.

Transcript of Projet d'accès aux résultats des étudiant via client mobile

UNIVERSITE DE KINSHASA

FACULTE POLYTECHNIQUE

2009

Travail réalisé par : BASHIZI MUTUZI Patrick

TRAVAIL PRATIQUE DE LANGAGE DE

PROGRAMMATION

Access aux résultats de la délibération des étudiants de la faculté polytechnique

par Client Mobile.

2

Introduction

Sujet :

Access aux résultats de la délibération des étudiants de la faculté

polytechnique par Client Mobile.

Plan de travail

0. Modélisation et architecture du logiciel

1. Développement de la partie serveur.

2. Développement du client mobile

3. Intégration finale

0. MODELISATION ET ARCHITECTURE DU SYSTEME

0.1. Capture des besoins et fonctionnalités

Réaliser un service web et un client mobile à ce service pour l’accès aux

résultats de la délibération des épreuves en polytechnique.

Le diagramme UML de cas d’utilisation se résume donc à un

acteur (l’étudiant) et un cas d’utilisation (consulter son relevé).

0.2. Conception du système

Le système sera composé de deux parties principales :

- Le serveur

- Le client mobile

Les deux devront communiquer et s’échanger les donnés via des web

services.

3

0.3. Conception et implémentation des composants

0.3.1. Le serveur

Base des données Mysql

Technologie : J2EE

Modèle physique des données

Script de la base des données

-- --------------------------------------------------

--------------------

-- MySQL GRT Application

-- SQL Script

-- --------------------------------------------------

--------------------

SET FOREIGN_KEY_CHECKS = 0;

CREATE DATABASE IF NOT EXISTS `delibe`

4

CHARACTER SET latin1;

-- -------------------------------------

-- Tables

DROP TABLE IF EXISTS `delibe`.`cours`;

CREATE TABLE `delibe`.`cours` (

`idcours` INT(10) unsigned NOT NULL AUTO_INCREMENT,

`intitule` VARCHAR(45) NOT NULL,

`ponderation` INT(10) unsigned NOT NULL,

`titulaire` INT(10) unsigned NOT NULL,

PRIMARY KEY (`idcours`),

INDEX `FK_cours_1` (`titulaire`),

CONSTRAINT `FK_cours_1` FOREIGN KEY `FK_cours_1`

(`titulaire`)

REFERENCES `delibe`.`titulaire` (`idTitulaire`)

ON DELETE RESTRICT

ON UPDATE RESTRICT

)

ENGINE = InnoDB

ROW_FORMAT = Compact

CHARACTER SET latin1 COLLATE latin1_swedish_ci;

DROP TABLE IF EXISTS `delibe`.`epreuve`;

CREATE TABLE `delibe`.`epreuve` (

`idepreuve` INT(10) unsigned NOT NULL

AUTO_INCREMENT,

`session` INT(10) unsigned NOT NULL,

`idcours` INT(10) unsigned NOT NULL,

`idetudiant` INT(10) unsigned NOT NULL,

`cote_annee` DOUBLE(, ) NOT NULL,

`cote_examen` DOUBLE(, ) NOT NULL,

PRIMARY KEY (`idepreuve`),

INDEX `FK_epreuve_1` (`idcours`),

INDEX `FK_epreuve_2` (`idetudiant`),

CONSTRAINT `FK_epreuve_1` FOREIGN KEY

`FK_epreuve_1` (`idcours`)

REFERENCES `delibe`.`cours` (`idcours`)

ON DELETE RESTRICT

ON UPDATE RESTRICT,

CONSTRAINT `FK_epreuve_2` FOREIGN KEY

`FK_epreuve_2` (`idetudiant`)

REFERENCES `delibe`.`etudiant` (`idEtudiant`)

ON DELETE RESTRICT

ON UPDATE RESTRICT

5

)

ENGINE = InnoDB

ROW_FORMAT = Compact

CHARACTER SET latin1 COLLATE latin1_swedish_ci;

DROP TABLE IF EXISTS `delibe`.`etudiant`;

CREATE TABLE `delibe`.`etudiant` (

`idEtudiant` INT(10) unsigned NOT NULL

AUTO_INCREMENT,

`nom` VARCHAR(45) NOT NULL,

`postnom` VARCHAR(45) NOT NULL,

`prenom` VARCHAR(45) NOT NULL,

`password` VARCHAR(45) NOT NULL,

`promotion` VARCHAR(5) NOT NULL,

PRIMARY KEY (`idEtudiant`),

INDEX `FK_etudiant_1` (`promotion`),

CONSTRAINT `FK_etudiant_1` FOREIGN KEY

`FK_etudiant_1` (`promotion`)

REFERENCES `delibe`.`promotion` (`idpromotion`)

ON DELETE RESTRICT

ON UPDATE RESTRICT

)

ENGINE = InnoDB

ROW_FORMAT = Compact

CHARACTER SET latin1 COLLATE latin1_swedish_ci;

DROP TABLE IF EXISTS `delibe`.`promotion`;

CREATE TABLE `delibe`.`promotion` (

`idpromotion` VARCHAR(5) NOT NULL DEFAULT '',

`commentaire` VARCHAR(45) NOT NULL DEFAULT '',

PRIMARY KEY (`idpromotion`)

)

ENGINE = InnoDB

ROW_FORMAT = Compact

CHARACTER SET latin1 COLLATE latin1_swedish_ci;

DROP TABLE IF EXISTS `delibe`.`titulaire`;

CREATE TABLE `delibe`.`titulaire` (

`idTitulaire` INT(10) unsigned NOT NULL

AUTO_INCREMENT,

`nom` VARCHAR(45) NOT NULL,

`postnom` VARCHAR(45) NULL,

`prenom` VARCHAR(45) NULL,

PRIMARY KEY (`idTitulaire`)

6

)

ENGINE = InnoDB

ROW_FORMAT = Compact

CHARACTER SET latin1 COLLATE latin1_swedish_ci;

SET FOREIGN_KEY_CHECKS = 1;

-- --------------------------------------------------

--------------------

-- EOF

Architecture MVC (J2EE)

Nous avons usé de la technologie java.

Ainsi :

- Couche d’access aux données (DAL) : entity beans (non standards).

- Couche Business Logic : technologie Web Services SOAP.

- Couche GUI: techologie J2ME (Mobile)

Voici une capture du serveur dans Netbeans.

7

8

- Description du web Service

Type : SOAP.

Fichier WSDL

Vue en mode design dans Netbeans

9

Description : Le service web dispose de le méthode : String[]

getResultats(@WebParam(name = "idEtudiant") ,retournant les résultats d’un

étudiant dans un tableau de String.

Voici son implémentation :

10

Voici aussi ce que fait la méthode getDelibeOfEtudiant de la classe Epreuve :

11

Remarquons bien la requete SQL :

12

select intitule, cote_annee,cote_examen from cours,epreuve,etudiant where

etudiant.idEtudiant=epreuve.idetudiant and epreuve.idcours=cours.idcours

and etudiant.idetudiant=1;

Ce résultat devra donc être reçu par le client mobile.

Ce service étant bien finie et testé, on peut passer au client mobile.

0.3.2. Le client mobile

Techologie J2ME

Machine virtuelle : KVM

Profil : MIDP 2.0

Configuration : CLDC 1.1

Emulateur : DefaultFXTouchPhone1

- Conception et implémentation de la midlet principale : usage du

concepteur graphique de Netbeans pour définir le Flow de des

commandes et des Screans de l’application.

13

Pour accéder au service Web nous avons besoin d’un Stub local.

14

Code d’appel du service dans la midlet

resultatdelibeservice.ResultatDelibeServiceService_Stub stub = new

ResultatDelibeServiceService_Stub();

Code source de la Midlet

/*

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/

package client;

15

import java.io.IOException;

import java.rmi.RemoteException;

import java.util.Vector;

import javax.microedition.midlet.*;

import javax.microedition.lcdui.*;

import org.netbeans.microedition.lcdui.SimpleTableModel;

import org.netbeans.microedition.lcdui.SplashScreen;

import org.netbeans.microedition.lcdui.TableItem;

import org.netbeans.microedition.lcdui.WaitScreen;

import org.netbeans.microedition.util.SimpleCancellableTask;

import resultatdelibeservice.ResultatDelibeServiceService_Stub;

/**

* @author bash

*/

public class MainMidlet extends MIDlet implements CommandListener {

private boolean midletPaused = false;

// delibe.DelibeService_Stub del;

resultatdelibeservice.ResultatDelibeServiceService_Stub stub = new

ResultatDelibeServiceService_Stub();

//<editor-fold defaultstate="collapsed" desc=" Generated Fields ">

private Command exitCommand;

private Command okCommand;

16

private Command okCommand1;

private Command exitCommand1;

private Command okCommand2;

private Command backCommand;

private Command exitCommand2;

private Form loginForm;

private TextField textField;

private TextField textField1;

private ChoiceGroup choiceGroup;

private SplashScreen splashScreen;

private WaitScreen waitScreen;

private Alert alert;

private Form mainForm;

private TableItem tableItem;

private SimpleCancellableTask task;

private SimpleTableModel tableModel1;

//</editor-fold>

/**

* The HelloMIDlet constructor.

*/

public MainMidlet() {

17

}

//<editor-fold defaultstate="collapsed" desc=" Generated Methods ">

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize

">

/**

* Initilizes the application.

* It is called only once when the MIDlet is started. The method is called

before the <code>startMIDlet</code> method.

*/

private void initialize() {

// write pre-initialize user code here

// write post-initialize user code here

}

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Method:

startMIDlet ">

/**

* Performs an action assigned to the Mobile Device - MIDlet Started point.

*/

public void startMIDlet() {

// write pre-action user code here

18

switchDisplayable(null, getSplashScreen());

// write post-action user code here

}

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Method:

resumeMIDlet ">

/**

* Performs an action assigned to the Mobile Device - MIDlet Resumed point.

*/

public void resumeMIDlet() {

// write pre-action user code here

// write post-action user code here

}

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Method:

switchDisplayable ">

/**

* Switches a current displayable in a display. The <code>display</code>

instance is taken from <code>getDisplay</code> method. This method is used

by all actions in the design for switching displayable.

* @param alert the Alert which is temporarily set to the display; if

<code>null</code>, then <code>nextDisplayable</code> is set immediately

19

* @param nextDisplayable the Displayable to be set

*/

public void switchDisplayable(Alert alert, Displayable nextDisplayable) {

// write pre-switch user code here

Display display = getDisplay();

if (alert == null) {

display.setCurrent(nextDisplayable);

} else {

display.setCurrent(alert, nextDisplayable);

}

// write post-switch user code here

}

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Method:

commandAction for Displayables ">

/**

* Called by a system to indicated that a command has been invoked on a

particular displayable.

* @param command the Command that was invoked

* @param displayable the Displayable where the command was invoked

*/

public void commandAction(Command command, Displayable displayable) {

// write pre-action user code here

20

if (displayable == loginForm) {

if (command == exitCommand) {

// write pre-action user code here

exitMIDlet();

// write post-action user code here

} else if (command == okCommand) {

try {

// message.setText(del.test());

} catch (Exception e) {

}

// write pre-action user code here

switchDisplayable(null, getWaitScreen());

// write post-action user code here

}

} else if (displayable == mainForm) {

if (command == exitCommand2) {

// write pre-action user code here

switchDisplayable(null, getLoginForm());

// write post-action user code here

}

} else if (displayable == splashScreen) {

if (command == SplashScreen.DISMISS_COMMAND) {

// write pre-action user code here

switchDisplayable(null, getLoginForm());

21

// write post-action user code here

}

} else if (displayable == waitScreen) {

if (command == WaitScreen.FAILURE_COMMAND) {

// write pre-action user code here

switchDisplayable(getAlert(), getLoginForm());

// write post-action user code here

} else if (command == WaitScreen.SUCCESS_COMMAND) {

// write pre-action user code here

switchDisplayable(null, getMainForm());

// write post-action user code here

}

}

// write post-action user code here

}

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter:

exitCommand ">

/**

* Returns an initiliazed instance of exitCommand component.

* @return the initialized component instance

*/

22

public Command getExitCommand() {

if (exitCommand == null) {

// write pre-init user code here

exitCommand = new Command("Exit", Command.EXIT, 0);

// write post-init user code here

}

return exitCommand;

}

//</editor-fold>

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: loginForm

">

/**

* Returns an initiliazed instance of loginForm component.

* @return the initialized component instance

*/

public Form getLoginForm() {

if (loginForm == null) {

// write pre-init user code here

loginForm = new Form("Bienvennu ", new Item[] { getTextField(),

getTextField1(), getChoiceGroup() });

loginForm.addCommand(getExitCommand());

loginForm.addCommand(getOkCommand());

23

loginForm.setCommandListener(this);

// write post-init user code here

}

return loginForm;

}

//</editor-fold>

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter:

okCommand ">

/**

* Returns an initiliazed instance of okCommand component.

* @return the initialized component instance

*/

public Command getOkCommand() {

if (okCommand == null) {

// write pre-init user code here

okCommand = new Command("Ok", Command.OK, 0);

// write post-init user code here

}

return okCommand;

}

//</editor-fold>

24

//<editor-fold defaultstate="collapsed" desc=" Generated Getter:

splashScreen ">

/**

* Returns an initiliazed instance of splashScreen component.

* @return the initialized component instance

*/

public SplashScreen getSplashScreen() {

if (splashScreen == null) {

// write pre-init user code here

splashScreen = new SplashScreen(getDisplay());

splashScreen.setTitle("splashScreen");

splashScreen.setCommandListener(this);

splashScreen.setText("DELIBE MOBILE.(c)Patrick Bashizi");

// write post-init user code here

}

return splashScreen;

}

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter:

okCommand1 ">

/**

* Returns an initiliazed instance of okCommand1 component.

* @return the initialized component instance

25

*/

public Command getOkCommand1() {

if (okCommand1 == null) {

// write pre-init user code here

okCommand1 = new Command("Ok", Command.OK, 0);

// write post-init user code here

}

return okCommand1;

}

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter:

exitCommand1 ">

/**

* Returns an initiliazed instance of exitCommand1 component.

* @return the initialized component instance

*/

public Command getExitCommand1() {

if (exitCommand1 == null) {

// write pre-init user code here

exitCommand1 = new Command("Exit", Command.EXIT, 0);

// write post-init user code here

}

return exitCommand1;

26

}

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter:

okCommand2 ">

/**

* Returns an initiliazed instance of okCommand2 component.

* @return the initialized component instance

*/

public Command getOkCommand2() {

if (okCommand2 == null) {

// write pre-init user code here

okCommand2 = new Command("Ok", Command.OK, 0);

// write post-init user code here

}

return okCommand2;

}

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: textField ">

/**

* Returns an initiliazed instance of textField component.

* @return the initialized component instance

*/

27

public TextField getTextField() {

if (textField == null) {

// write pre-init user code here

textField = new TextField("identifiant", null, 32, TextField.ANY);

// write post-init user code here

}

return textField;

}

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: textField1

">

/**

* Returns an initiliazed instance of textField1 component.

* @return the initialized component instance

*/

public TextField getTextField1() {

if (textField1 == null) {

// write pre-init user code here

textField1 = new TextField("Mot de passe", null, 32, TextField.ANY |

TextField.PASSWORD);

// write post-init user code here

}

return textField1;

28

}

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter:

choiceGroup ">

/**

* Returns an initiliazed instance of choiceGroup component.

* @return the initialized component instance

*/

public ChoiceGroup getChoiceGroup() {

if (choiceGroup == null) {

// write pre-init user code here

choiceGroup = new ChoiceGroup("Promotion", Choice.MULTIPLE);

// write post-init user code here

}

return choiceGroup;

}

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: waitScreen

">

/**

* Returns an initiliazed instance of waitScreen component.

* @return the initialized component instance

29

*/

public WaitScreen getWaitScreen() {

if (waitScreen == null) {

// write pre-init user code here

waitScreen = new WaitScreen(getDisplay());

waitScreen.setTitle("operation en cours...");

waitScreen.setCommandListener(this);

waitScreen.setText("Patientez SVP...");

waitScreen.setTask(getTask());

// write post-init user code here

}

return waitScreen;

}

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: alert ">

/**

* Returns an initiliazed instance of alert component.

* @return the initialized component instance

*/

public Alert getAlert() {

if (alert == null) {

// write pre-init user code here

alert = new Alert("alert");

30

alert.setTimeout(Alert.FOREVER);

// write post-init user code here

}

return alert;

}

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: task ">

/**

* Returns an initiliazed instance of task component.

* @return the initialized component instance

*/

public SimpleCancellableTask getTask() {

if (task == null) {

// write pre-init user code here

task = new SimpleCancellableTask();

task.setExecutable(new org.netbeans.microedition.util.Executable() {

public void execute() throws Exception {

// write task-execution user code here

}

});

// write post-init user code here

}

return task;

31

}

//</editor-fold>

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter:

backCommand ">

/**

* Returns an initiliazed instance of backCommand component.

* @return the initialized component instance

*/

public Command getBackCommand() {

if (backCommand == null) {

// write pre-init user code here

backCommand = new Command("Back", Command.BACK, 0);

// write post-init user code here

}

return backCommand;

}

//</editor-fold>

//</editor-fold>

32

//<editor-fold defaultstate="collapsed" desc=" Generated Getter:

exitCommand2 ">

/**

* Returns an initiliazed instance of exitCommand2 component.

* @return the initialized component instance

*/

public Command getExitCommand2() {

if (exitCommand2 == null) {

// write pre-init user code here

exitCommand2 = new Command("Exit", Command.EXIT, 0);

// write post-init user code here

}

return exitCommand2;

}

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: mainForm

">

/**

* Returns an initiliazed instance of mainForm component.

* @return the initialized component instance

*/

public Form getMainForm() {

33

if (mainForm == null) {

// write pre-init user code here

mainForm = new Form("form", new Item[] { getTableItem() });

mainForm.addCommand(getExitCommand2());

mainForm.setCommandListener(this);

// write post-init user code here

}

return mainForm;

}

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: tableItem

">

/**

* Returns an initiliazed instance of tableItem component.

* @return the initialized component instance

*/

public TableItem getTableItem() {

if (tableItem == null) {

// write pre-init user code here

tableItem = new TableItem(getDisplay(), "R\u00E9sultats");

tableItem.setModel(getTableModel1());

// write post-init user code here

}

34

return tableItem;

}

//</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter:

tableModel1 ">

/**

* Returns an initiliazed instance of tableModel1 component.

* @return the initialized component instance

*/

public SimpleTableModel getTableModel1() {

if (tableModel1 == null) {

// write pre-init user code here

tableModel1 = new SimpleTableModel(new java.lang.String[][] {

new java.lang.String[] { "LP et CAO", "15", "18" },

new java.lang.String[] { "Math appliqu\u00E9s", "15", "15" },

new java.lang.String[] { "Electromagn\u00E9tisme", "12", "5" },

new java.lang.String[] { "Machines \u00E9lectriques", "13", "15" },

new java.lang.String[] { "Centrales et r\u00E9seaux", "4", "13" },

new java.lang.String[] { "G\u00E9nie des proc\u00E9d\u00E9s", "12",

"" },

new java.lang.String[] { "", "", "" }}, new java.lang.String[] { "Cours",

"Ann\u00E9e", "Examen" });

// write post-init user code here

}

35

return tableModel1;

}

//</editor-fold>

/**

* Returns a display instance.

* @return the display instance.

*/

public Display getDisplay() {

return Display.getDisplay(this);

}

/**

* Exits MIDlet.

*/

public void exitMIDlet() {

switchDisplayable(null, null);

destroyApp(true);

notifyDestroyed();

}

/**

* Called when MIDlet is started.

36

* Checks whether the MIDlet have been already started and initialize/starts

or resumes the MIDlet.

*/

public void startApp() {

if (midletPaused) {

resumeMIDlet();

} else {

initialize();

startMIDlet();

}

midletPaused = false;

}

/**

* Called when MIDlet is paused.

*/

public void pauseApp() {

midletPaused = true;

}

/**

* Called to signal the MIDlet to terminate.

* @param unconditional if true, then the MIDlet has to be unconditionally

terminated and all resources has to be released.

37

*/

public void destroyApp(boolean unconditional) {

}

}

RESULTATS

Le login

38

Une fois identifié, l’étudiant peut accédé à ses résultats :

39

40