Package morceaux.modele

Examples of morceaux.modele.Morceau


            String panier = session.getAttribute("Panier").toString();
            String[] tabPanier = panier.split("[;]");
            System.out.println("panieeeeeeeeeeer : " + tabPanier.toString());
            for(int i = 0; i < tabPanier.length; i++) {
                tabPanier[i] = tabPanier[i].replaceAll("null","");
                Morceau m = gestionnaireMorceaux.getMorceau(tabPanier[i]);
                gestionnaireUtilisateurs.addMorceau(conneclogin, m);
            }
            configureProfil(request, conneclogin);
            sizeListe = gestionnaireMorceaux.countMorceaux(user);
            session.setAttribute("Panier", null);
            //Panier
        } else if (action.equals("addMorceauPanier")) {
            String id = request.getParameter("id");
            String panier = null;
            double prix = 0;
           
            if(session.getAttribute("Panier") != null) {
                panier = session.getAttribute("Panier").toString() +id + ";";
                System.out.println(panier);
                session.setAttribute("Panier", panier);
            } else {
                panier = id +";";
                session.setAttribute("Panier", panier);
                System.out.println("Panier : " + panier);
            }
            Collection<Morceau> liste = new ArrayList<Morceau>();
            if(session.getAttribute("Panier") != null) {
                panier = session.getAttribute("Panier").toString();
                String[] tabPanier = panier.split("[;]");
                System.out.println("panieeeeeeeeeeer : " + tabPanier.toString());
                for(int i = 0; i < tabPanier.length; i++) {
                    tabPanier[i] = tabPanier[i].replaceAll("null","");
                    Morceau m = gestionnaireMorceaux.getMorceau(tabPanier[i]);
                    if(!liste.contains(m)){
                        liste.add(m);
                        prix += m.getPrix();
                    }  
                }
            }
            String reduc = "Pas de réduction";
            if(liste.size()>3 && liste.size()<= 5){
                prix = 0.9*prix;
                reduc = "10% de réduction";
            }
               
            else if(liste.size()>5 && liste.size()<= 10){
                prix = 0.8*prix;
                reduc = "20% de réduction";
            }
            else if(liste.size()>10){
                prix = 0.7*prix;
                reduc = "30% de réduction";
            }  
            request.setAttribute("listeMorceaux", liste);
            request.setAttribute("total", prix);
            request.setAttribute("reduc", reduc);
            forwardTo = "index.jsp?action=showPanier";
        } else if (action.equals("showPanier")) {
            double prix = 0;
            Collection<Morceau> liste = new ArrayList<Morceau>();
            if(session.getAttribute("Panier") != null) {
                String panier = session.getAttribute("Panier").toString();
                String[] tabPanier = panier.split("[;]");
                System.out.println("panieeeeeeeeeeer : " + tabPanier.toString());
                for(int i = 0; i < tabPanier.length; i++) {
                    tabPanier[i] = tabPanier[i].replaceAll("null","");
                    Morceau m = gestionnaireMorceaux.getMorceau(tabPanier[i]);
                    if(!liste.contains(m)){
                        prix += m.getPrix();
                        liste.add(m);
                    }
                }
            }
            String reduc = "Pas de réduction";
View Full Code Here


        try {
            String fName = "C:\\Users\\Thibaut\\Documents\\NetBeansProjects\\Tp2\\web\\resources\\listeChansons.txt";
            String thisLine;
            fis = new FileInputStream(fName);
            DataInputStream myInput = new DataInputStream(fis);
            Morceau m = null;
            Artiste a = null;
            Genre g = null;
            int counterInstrument = 0;
            while ((thisLine = myInput.readLine()) != null) {
                if (thisLine.startsWith("./")) {
                    String strar[] = thisLine.split("\\./");
                    String musique[] = strar[1].split(";");
                    String artiste = musique[0];
                    String titre = musique[1];
                    String url = musique[2];
                    String genre = musique[3];
                    float prix = Float.parseFloat(musique[4]);
                    m = new Morceau();
                    m.setTitre(titre);
                    m.setPrix(prix);
                    a = getArtiste(artiste);
                    g = getGenre(genre);
                    m.setGenre(g);
                    m.setArtiste(a);
                    m.setUrl(url);
                } else {
                    if (thisLine.equals("")) {
                        m.setNbPistes(counterInstrument);
                        em.persist(a);
                        em.persist(g);
                        em.persist(m);
                        counterInstrument = 0;
                    } else {
                        counterInstrument += 1;
                        String instrumental[] = thisLine.split(";");
                        String instrument = instrumental[0];
                        int difficulte = Integer.parseInt(instrumental[1]);
                        String piste = instrumental[2];
                        Instrument i = getInstrument(instrument);
                        Piste p = new Piste(piste,i,difficulte);
                        em.persist(p);
                        m.addPiste(p);
                    }
                }
            }
        } catch (FileNotFoundException ex) {
            Logger.getLogger(GestionnaireUtilisateurs.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

    public Morceau getMorceau(String id) {
        Query q = em.createQuery("select u from Morceau u where u.id=" + id);
        List results = q.getResultList();
        if (!results.isEmpty()) {
            Iterator stIterator = results.iterator();
            Morceau u = (Morceau) stIterator.next();
            return u;
        } else {
            return null;
        }
    }
View Full Code Here

TOP

Related Classes of morceaux.modele.Morceau

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.