/* * Moteur.java * * Created on 25 avril 2007, 13:23 */ package Application.ApplicationMusee.Moteur; import Application.ObjetsMusee.*; import Application.RessourcesHumainesMusee.*; import Application.ObjetsMusee.Projects.*; import Application.ObjetsMusee.Flow.*; import java.util.*; import java.io.*; import java.lang.String; import Application.ApplicationMusee.Dialogues.AfficheUtilisateur; /** * * @author Vince */ public class Moteur{ //private String utilisateur[]; //private String password[]; private String login; private String password; public Hashtable HMusee; public Hashtable HMuseeTemp; public Hashtable Hutilisateur; public Hashtable HPersonnel; public Hashtable HProjet; public Hashtable HProjetTemp; public Vector VPersonnes; private Properties propLogin; public Hashtable HMouvement; // static boolean authentifie = false; /** Creates a new instance of Moteur */ public Moteur() { // loadUtilisateur(); // loadPiecesCollection(); loadFichierPiece(); loadPersonnel(); // loadProjet(); loadFichierProjet(); loadVecteurPers(); loadFichierPers(); loadMouvement(); } //Utlilisateur et pass temporairement en Hashtable -> fichier properties à implementer /*public void loadUtilisateur() { int i; utilisateur=new String[2]; password=new String[2]; Hutilisateur = new Hashtable(10); utilisateur[0]="vince"; utilisateur[1]="steph"; password[0]="avince"; password[1]="asteph"; for(i=0; i<2 ; i++) { Hutilisateur.put(utilisateur[i],password[i]); } }*/ //PieceMusee chargée en Hashtable public void loadPiecesCollection(){ String dir = System.getProperty("user.home"); String separation = System.getProperty("file.separator"); //Enlever commentaire dans constructeur pour ajouter de nouvelle piece par defaut dans le fichier HMuseeTemp = new Hashtable(50); System.out.println("Hastable" + HMusee); //Insert de quelques pieces PieceMuseeSciencesNat P1 = new PieceMuseeSciencesNat("AnimalEmpaille",true,false, 2000, "Animale", true, "Canada", "DansLesBois", 'T', "ours.jpg", "animal","Genretest","Especetest","AuteurMoi",1997,"Embranch","ClaaseTest","RegneTest","Viande", "ben comme nous"); HMuseeTemp.put(P1.GetIdentifiant().GetID(),P1); PieceMuseeSciencesNat P2 = new PieceMuseeSciencesNat("Plante",true,false, 2001, "Plante", true, "USA", "DansLesBuissons", 'T', "plante.jpg", "vegetal","Genretest2","Especetest2","AuteurMoi2",1997,"Embranch2","ClaaseTest2","RegneTest2","Fleur", "FeuilleComposée"); HMuseeTemp.put(P2.GetIdentifiant().GetID(),P2); PieceMuseeSciencesNat P3 = new PieceMuseeSciencesNat("CoquillageDesMers",true,false, 2002, "Coquillage", true, "Canade", "DansLeau", 'T', "coquillage.jpg", "animal","Genretest3","Especetest3","AuteurMoi2",1997,"Embranch2","ClaaseTest2","RegneTest2","Animal", "hermaphrodite"); HMuseeTemp.put(P3.GetIdentifiant().GetID(),P3); //Enregistrement dans le fichier PiecesMusee.ser try { System.out.println("Ecriture fichier Objet"); FileOutputStream fos = new FileOutputStream(dir + separation + "JAVA" + separation + "Application" + separation + "Data" + separation + "PiecesMusee.ser"); ObjectOutputStream oos = new ObjectOutputStream(fos); int cpt =0; PieceMuseeSciencesNat p = new PieceMuseeSciencesNat(); Enumeration E = HMuseeTemp.elements(); while(E.hasMoreElements()) { cpt++; p=(PieceMuseeSciencesNat) E.nextElement(); oos.writeObject(p); } oos.flush(); } catch(FileNotFoundException e) { System.err.println("Erreur! Fichier non trouvé ["+e+"]"); } catch(IOException e) { System.err.println("Erreur!? ["+e+"]"); } } //Enregistrement des Pieces dans le fichier PieceMusee.ser public void SauveFichierPiece(){ String dir = System.getProperty("user.home"); String separation = System.getProperty("file.separator"); try { System.out.println("Ecriture fichier Objet"); FileOutputStream fos = new FileOutputStream(dir + separation + "JAVA" + separation + "Application" + separation + "Data" + separation + "PiecesMusee.ser"); ObjectOutputStream oos = new ObjectOutputStream(fos); int cpt =0; PieceMuseeSciencesNat p = new PieceMuseeSciencesNat(); Enumeration E = HMusee.elements(); while(E.hasMoreElements()) { cpt++; p=(PieceMuseeSciencesNat) E.nextElement(); oos.writeObject(p); } oos.flush(); } catch(FileNotFoundException e) { System.err.println("Erreur! Fichier non trouvé ["+e+"]"); } catch(IOException e) { System.err.println("Erreur!? ["+e+"]"); } } //chargement du fichier de serialisation public void loadFichierPiece(){ HMusee = new Hashtable(50); PieceMuseeSciencesNat P = new PieceMuseeSciencesNat(); String dir = System.getProperty("user.home"); String separation = System.getProperty("file.separator"); String FichierObjet = dir + separation + "JAVA" + separation + "Application" + separation + "Data" + separation + "PiecesMusee.ser"; //System.out.println("Chemin trouver:" + FichierObjet); try { System.out.println("Lecture fichier Objet"); FileInputStream fis = new FileInputStream(FichierObjet); ObjectInputStream ois = new ObjectInputStream(fis); for(int i=0;i<50;i++) { P=(PieceMuseeSciencesNat) ois.readObject(); HMusee.put(P.GetIdentifiant().GetID(),P); } } catch(FileNotFoundException e) { System.err.println("Erreur! Fichier non trouvé ["+e+"]"); } catch(IOException e) { System.err.println("Erreur!? ["+e+"]"); } catch(ClassNotFoundException e) { System.err.println("Erreur!Classe non trouvée ["+e+"]"); } } //Ajouter un objet dans la Hashtable public void AjoutPiece(PieceMuseeSciencesNat P) { HMusee.put(P.GetIdentifiant().GetID(),P); } //Recherche lengthpass d'un utilisateur en parametre /*public String ChercheUtil(String N) { String nom = null; for(int i=0 ; i1?"s":""); System.out.println(message); ExpoTemporaire E = new ExpoTemporaire(); Publication Publi = new Publication(); Conference Conf = new Conference(); String fic; String premlettre; for(int i=0 ; i> tempo = " + tempo + " - Login = " + getLogin()); if(tempo.equals(ID)) { int fin = obj.getClass().getName().length(); if(obj.getClass().getName().substring(36,fin).equals("MembrePersonnel")) { persM = (MembrePersonnel) obj; //AfficheUtilisateur affuser = new AfficheUtilisateur(this,persM); //affuser.setVisible(true); System.out.println("On retourne persM : " + persM.GetIdentifiant().GetID()); return persM; //AffichePers a = new AffichePers(mot,persM); //a.setVisible(true); } else { if(obj.getClass().getName().substring(36,fin).equals("PersonnelScientifique")) { persS = (PersonnelScientifique) obj; //AffichePers a = new AffichePers(mot,persS); //a.setVisible(true); //AfficheUtilisateur affuser = new AfficheUtilisateur(this,persS); //affuser.setVisible(true); System.out.println("On retourne persS : " + persS.GetIdentifiant().GetID()); return persS; } else { System.out.println(">>> MODIFIER dans ListePers pour accueillir de nouvelles classe !! casting necessaire"); } } System.out.println("Piece = ID = "+tempo + " Nom : " + persM.getNom() + " Fonction : " + persM.getFonction()); //AffichePers a = new AffichePers(mot,obj); //a.setVisible(true); } } System.out.println("ON RETOURNE NULL"); return null; } public boolean modifierPassword(String ID, String password) { Enumeration e = VPersonnes.elements(); String tempo; Object obj; while(e.hasMoreElements()) { obj = e.nextElement(); tempo = ((EstIdentifiable) obj).GetIdentifiant().GetID(); //System.out.println("boucle ... >> tempo = " + tempo + " - Login = " + getLogin()); if(tempo.equals(ID)) { int fin = obj.getClass().getName().length(); if(obj.getClass().getName().substring(36,fin).equals("MembrePersonnel")) { MembrePersonnel mp = (MembrePersonnel) obj; mp.setPassword(password); UpdateLogin(ID, password); return true; } else { if(obj.getClass().getName().substring(36,fin).equals("PersonnelScientifique")) { PersonnelScientifique ps = (PersonnelScientifique) obj; ps.setPassword(password); UpdateLogin(ID, password); return true; } } } } return false; } public boolean trouverCle(String s, String cle) { s = "BlablablaTESTblablabla"; if(s.contains(cle)) { System.out.println("OK trouvé"); } } } ERROR is : Application/ApplicationMusee/Moteur/Moteur.java [895:1] cannot resolve symbol symbol : method contains (java.lang.String) location: class java.lang.String if(s.contains(cle)) ^