Skip to content
Snippets Groups Projects
Commit 2b8a1aa3 authored by Thomas Mewily's avatar Thomas Mewily
Browse files

a

parent 296c9fef
No related branches found
No related tags found
No related merge requests found
......@@ -4,10 +4,11 @@ import com.uca.core.*;
import com.uca.dao.*;
import com.uca.entity.*;
import java.sql.*;
import java.lang.Math;
public class _Initializer {
public static ProfEntity DEBUG_BORIS_ADMIN;
public static ProfEntity DEBUG_TOTO_ADMIN;
public static void DropTable(String name)
{
......@@ -36,6 +37,42 @@ public class _Initializer {
}
}
private static int rng(int min, int max)
{
return (int)(Math.random()*(max-min+1)+min);
}
private static void maybeAdd(EleveEntity e, GommetteEntity g, String motif)
{
if(rng(0,100) < 60)
{
Core.GommetteAttrib.create(e.getId(),
(rng(0, 100) >= 50 ? DEBUG_BORIS_ADMIN : DEBUG_TOTO_ADMIN).getId(),
g.getId(), new java.sql.Date(44938), motif);
}
}
private static java.sql.Date createSqlDate(int day, int month, int year) {
// Create a date string with leading zeros for month and day.
String dateString = String.format("%d-%02d-%02d", year, month, day);
return java.sql.Date.valueOf(dateString);
}
private static EleveEntity createEleve(String nom, String prenom)
{
EleveEntity e = Core.Eleve.create(nom, prenom,createSqlDate(rng(1, 27),rng(1, 11), rng(2000, 2010)),"Classe 1");
maybeAdd(e, bruyant, "Je vais finir par t'isoler");
maybeAdd(e, uniCorn, "J'espère que tu continueras à arborer ces couleurs arc en ciel plus tard");
maybeAdd(e, sagePetit, "Hehe boi");
return e;
}
private static GommetteEntity bruyant;
private static GommetteEntity uniCorn;
private static GommetteEntity sagePetit;
public static void Init(){
DropTable("users");
DropTable("profs");
......@@ -48,32 +85,36 @@ public class _Initializer {
CreateTable("eleves (id int primary key auto_increment, firstname varchar(100), lastname varchar(100), nomClasse varchar(100), dateNaissance DATE);");
CreateTable("gommettes (id int primary key auto_increment, nom varchar(100), description varchar(100), couleur varchar(100));");
CreateTable("gommetteAttribs (id int primary key auto_increment, idEleve int, idProf int, idGommette int, dateAttribution DATE, raison varchar(500));");
UserEntity e = Core.User.create("Le père de toto", "pas toto");
Core.User.create("Jean", "Némar");
Core.User.create("Paul", "Hisse");
Core.User.create("Kelly", "Diote");
Core.User.create("Alain", "Térieur");
Core.User.create("Matt", "Lecul");
Core.User.create("Lorie", "Fice");
Core.User.create("Sacha", "Touille");
Core.User.create("Terry", "Golo");
Core.User.create("Judas", "Nanas");
sagePetit = Core.Gommette.create("Brave Petit", Couleur.Vert, "S'est montré obéissant devant le prêtre");
uniCorn = Core.Gommette.create("Badge Unicorne", Couleur.ArcEnCiel, "C'est magique!");
bruyant = Core.Gommette.create("Bruyant", Couleur.Rouge, "Bavardage!!!");
DEBUG_BORIS_ADMIN = Core.Prof.create("Boris", "OUYA", "DaWarudo","KonoDioDa");
ProfEntity toto = Core.Prof.create("Thomas", "TAMAGNAUD", "CéMoiLul","BlockusMaster");
DEBUG_TOTO_ADMIN = Core.Prof.create("Thomas", "TAMAGNAUD", "CéMoiLul","BlockusMaster");
Core.GommetteAttrib.create(createEleve("Sacha", "Touille").getId(), DEBUG_BORIS_ADMIN.getId(), Core.Gommette.create("Chasseur", Couleur.Rouge, "passe son temps à attraper des pokemons").getId(), new java.sql.Date(44938), "Arrete de racketter tes camarades");
Core.GommetteAttrib.create(createEleve("Paul", "Hisse").getId(), DEBUG_TOTO_ADMIN.getId(), Core.Gommette.create("Autoritaire", Couleur.Rouge, "Fait peur à ses camarades").getId(), new java.sql.Date(44938), "La force de l'ordre ici c'est moi.");
Core.GommetteAttrib.create(createEleve("Terry", "Golo").getId(), DEBUG_BORIS_ADMIN.getId(), Core.Gommette.create("Blagueur", Couleur.ArcEnCiel, "Fait des blagues").getId(), new java.sql.Date(44938), "Faudrai songer à changer de disque.");
createEleve("Kelly", "Diote");
createEleve("Matt", "Lecul");
createEleve("Lorie", "Fice");
createEleve("Judas", "Nanas");
Core.Prof.create("Jean", "Pierre", "Framboisier","Fraise");
Core.Prof.create("Melina", "Myr", "Myrtille ","I<3K6");
GommetteEntity sagePetit = Core.Gommette.create("Brave Petit", Couleur.Vert, "S'est montré obéissant devant le prêtre");
GommetteEntity uniCorn = Core.Gommette.create("Badge Unicorne", Couleur.ArcEnCiel, "C'est magique!");
/*
EleveEntity bibi = Core.Eleve.create("Bibi","Johnson",new java.sql.Date(44938),"Zarbi");
EleveEntity bobo = Core.Eleve.create("Bobo","Bis",new java.sql.Date(10),"Pokemon");
Core.GommetteAttrib.create(bibi.getId(), DEBUG_BORIS_ADMIN.getId(), sagePetit.getId(), new java.sql.Date(44938), "Aucune raison");
Core.GommetteAttrib.create(bibi.getId(), toto.getId(), uniCorn.getId(), new java.sql.Date(44938), "Our Little Poney");
Core.GommetteAttrib.create(bobo.getId(), DEBUG_BORIS_ADMIN.getId(), uniCorn.getId(), new java.sql.Date(32), "Bravo bobo");
Core.GommetteAttrib.create(bobo.getId(), DEBUG_BORIS_ADMIN.getId(), uniCorn.getId(), new java.sql.Date(32), "Bravo bobo");*/
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment