Package eu.nicolaslecoz.cmcc.cinema.domain

Examples of eu.nicolaslecoz.cmcc.cinema.domain.Personne


    }
   
    Elements directorsElt = doc.select("li[itemprop=director]");
   
    for (Element directorElt : directorsElt) {
      Personne realisateur = new Personne();
     
      recupererInfoPersonneFromAllocine(directorElt, realisateur);
     
      realisateur.addRoleOnFilmByType(film, RoleType.REALISATEUR);
     
      film.getRealisateurs().add(realisateur);
    }
   
    Elements actorsElt = doc.select("li[itemprop=actors]");
   
    for (Element actorElt : actorsElt) {
      Personne acteur = new Personne();
     
      recupererInfoPersonneFromAllocine(actorElt, acteur);
     
      Element actorLinkElt = actorElt.select("a[itemprop=url]").get(0);
      Element roleNameParElt = actorLinkElt.parent().nextElementSibling();
     
      acteur.addRoleOnFilmByType(film, RoleType.ACTEUR);
     
      if (roleNameParElt != null) {
        acteur.getRoles().get(0).setRole(roleNameParElt.text().replaceFirst("Rôle : ", ""));
      }
      film.getActeurs().add(acteur);
    }
   
    Elements actorLineElts = actorsElt.get(0).parent().parent().nextElementSibling().select("tr");
   
    for (Element actorLineElt : actorLineElts) {
      Personne acteur = new Personne();
     
      acteur.addRoleOnFilmByType(film, RoleType.ACTEUR);
      acteur.getRoles().get(0).setRole(actorLineElt.select("td").get(0).text());
     
      Elements actorLinkElts = actorLineElt.select("td").get(1).select("a");
     
      if (actorLinkElts.size() > 0) {
        acteur.setAllocineId(computeAllocineIdFromFicheActeurUrl(actorLinkElts.first().attr("href")));
        acteur.setName(actorLinkElts.get(0).text());
      } else {
        Element actorImgElt = actorLineElt.select("td").get(1).select("img").first();
       
        acteur.setName(actorImgElt.attr("alt"));
      }
      film.getActeurs().add(acteur);
    }
   
    Elements linkPersonElts = doc.select("a[href^=/personne/]");
   
    for (Element linkPersonElt : linkPersonElts) {
      String nom = linkPersonElt.text();
      String role = null;
     
      Elements parents = linkPersonElt.parents();
     
      if (parents != null && parents.size() > 3 && "tr".equalsIgnoreCase(parents.get(2).nodeName())) {
        role = parents.get(2).select("td").get(0).text();
      }
      RoleType roleType = RoleType.getRoleTypeByRoleInAllocine(role);
     
      if (roleType != null) {
        Personne personne = new Personne();
       
        personne.setName(nom);
        personne.setAllocineId(computeAllocineIdFromFicheActeurUrl(linkPersonElt.attr("href")));
       
        personne.addRoleOnFilmByType(film, roleType);
        film.addPersonneParRoleType(personne, roleType);
      }
    }
  }
View Full Code Here

TOP

Related Classes of eu.nicolaslecoz.cmcc.cinema.domain.Personne

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.