Package org.ops4j.pax.exam.sample2.model

Examples of org.ops4j.pax.exam.sample2.model.Person


    }
  }
 
  public Person findPerson( int id )
  {
    Person person = new Person();
   
    for (Person tmp : listPerson)
    {
      if ( tmp.getId()==id )
      {
View Full Code Here


 
  public Person getNewPerson()
  {
    int id=0;
   
    Person person = new Person();
   
    try
    {
      model.Connect();
      id=model.MaxId();
      model.Disconnect();
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    person.setId(id+1);

    return person;
  }
View Full Code Here

    return person;
  }
 
  public Person newPerson( HttpServletRequest request )
  {
    Person person = new Person();
    ArrayList<Phone> phones = new ArrayList<Phone>();
    String phone = "phone[0].phone";;
    int i=0;
   
    person.setId( Integer.parseInt(request.getParameter("id")) );
    person.setFistname(request.getParameter("fistname"));
    person.setSurname(request.getParameter("surname"));
    person.setAge( Integer.parseInt(request.getParameter("age")) );
   
    while(request.getParameter(phone)!=null)
    {
      phones.add(new Phone( request.getParameter(phone) ));
      phone = "phone["+i+"].phone";
      i++;
    }
   
    if (!phones.isEmpty())
    {
      phones.remove(0);
    }
   
    person.setPhone(phones);
   
    return person;
  }
View Full Code Here

  @Override
  public Person Read(int id) throws SQLException
  {
    statement = connection.createStatement();
    Person person=null;
    ArrayList<Phone> phones = null;
   
    query="SELECT * FROM PERSONS WHERE ID="+id+";";
    result = statement.executeQuery(query);
    result.next();
   
    if (result.getRow()==1)
    {
      person = new Person();  
      person.setId(result.getInt("ID"));
      person.setFistname(result.getNString("FISTNAME"));
      person.setSurname(result.getNString("SURNAME"));
      person.setAge(result.getInt("AGE"));
     
      Statement statementPhone = connection.createStatement();

      query="SELECT * FROM PHONES WHERE PERSONID="+id+";";
      ResultSet resultPhone = statementPhone.executeQuery(query);
      phones = new ArrayList<Phone>();
     
      while (resultPhone.next())
      { 
        Phone phone = new Phone();
        phone.setPhone(resultPhone.getNString("PHONE"));
        phones.add(phone);
      }
      statementPhone.close();
      person.setPhone(phones);
    }
    statement.close();
    return person;
  }
View Full Code Here

  public ArrayList<Person> ReadAll() throws SQLException
  {
    statement = connection.createStatement();
    ArrayList<Person> list = new ArrayList<Person>();
    ArrayList<Phone> phones;
    Person person;
   
    query="SELECT * FROM PERSONS;";
    result = statement.executeQuery(query);
 
    while ( result.next() )
    {  
      person = new Person();
      person.setId(result.getInt("ID"));
      person.setFistname(result.getNString("FISTNAME"));
      person.setSurname(result.getNString("SURNAME"));
      person.setAge(result.getInt("AGE"));
     
      phones = new ArrayList<Phone>();
     
      query="SELECT * FROM PHONES WHERE PERSONID="+person.getId()+";";
      Statement statementPhone = connection.createStatement();
      ResultSet resultPhone = statementPhone.executeQuery(query);
     
      while (resultPhone.next())
      { 
        Phone phone = new Phone();
        phone.setPhone(resultPhone.getNString("PHONE"));
        phones.add(phone);
      }
      resultPhone.close();
      person.setPhone(phones);
      list.add(person);
    }
    statement.close();
    return list;
  }
View Full Code Here

 
  private List<Person> createList() {
    List<Person> rv = new ArrayList<Person>();
   
    {
      Person p = new Person("Tom","Schindl");
      p.setStreet("Bahnhofstrasse 1");
      p.setZip("6020");
      p.setCity("Innsbruck");
      rv.add(p)
    }
   
    {
      Person p = new Person("John","Doe");
      p.setStreet("Mainstreet 1");
      p.setZip("E10E4");
      p.setCity("San Francisco");
      rv.add(p);
    }
   
    return rv;
  }
View Full Code Here

        Collection<Map<String, ?>> cast = (Collection<Map<String, ?>>) data.get("cast");
        for (Map<String, ?> entry : cast) {
            Integer id = (Integer) entry.get("id");
            String jobName = (String) entry.get("job");
            if ("Actor".equals(jobName)) {
                Actor actor = new Actor();
                actor.setId(id);
                doImportPerson(actor);
                Role role = new Role();
                role.setActor(actor);
                role.setMovie(movie);
                role.setName((String) entry.get("character"));
View Full Code Here

    @PersistenceContext
    private EntityManager em;

    public Actor findById(int id) {
        Actor actor = em.find(Actor.class, id);
        actor.getRoles();
        return actor;
    }
View Full Code Here

                role.setName((String) entry.get("character"));
                em.persist(role);
                movie.getRoles().add(role);
            }
            else if ("Director".equals(jobName)) {
                Director director = new Director();
                director.setId(id);
                director.getMovies().add(movie);
                doImportPerson(director);
                movie.setDirector(director);
            }
            else {
                logger.info("Could not add person with job {} {}", jobName, entry);
View Full Code Here

    @PersistenceContext
    private EntityManager em;

    public Movie findById(int id) {
        Movie movie = em.find(Movie.class, id);
        movie.getActors();
        movie.getRoles();
        movie.getRatings();
        return movie;
    }
View Full Code Here

TOP

Related Classes of org.ops4j.pax.exam.sample2.model.Person

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.