Package cat.quickdb.date200912.model

Examples of cat.quickdb.date200912.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

                QuickDBTests.user, QuickDBTests.pass, QuickDBTests.scheme);
    }

    @Test
    public void testBinding(){
        Bind b = new Bind();
        Bind2 b2 = new Bind2();

        b.setDescription("description");
        b2.setName("name binding2");

        Assert.assertTrue(b.save());
        Assert.assertTrue(b2.save());

        Bind bind = new Bind();
        admin.obtain(bind, "description = 'description'");
        Assert.assertEquals("description", bind.getDescription());
        Bind2 bind2 = new Bind2();
        admin.obtain(bind2, "name = 'name binding2'");
        Assert.assertEquals("name binding2", bind2.getName());
    }
View Full Code Here

    }

    @Test
    public void testBinding(){
        Bind b = new Bind();
        Bind2 b2 = new Bind2();

        b.setDescription("description");
        b2.setName("name binding2");

        Assert.assertTrue(b.save());
        Assert.assertTrue(b2.save());

        Bind bind = new Bind();
        admin.obtain(bind, "description = 'description'");
        Assert.assertEquals("description", bind.getDescription());
        Bind2 bind2 = new Bind2();
        admin.obtain(bind2, "name = 'name binding2'");
        Assert.assertEquals("name binding2", bind2.getName());
    }
View Full Code Here

        Assert.assertEquals(null, t2.getPruebaIgnore());
    }

    @Test
    public void testModifyCollection(){
        Collection1 test = new Collection1();
        test.setName("name");

        Collection2 t1 = new Collection2();
        t1.setDescription("description1");
        Collection2 t2 = new Collection2();
        t2.setDescription("description2");
        Collection2 t3 = new Collection2();
        t3.setDescription("description3");
        ArrayList array = new ArrayList();
        array.add(t1);
        array.add(t2);
        array.add(t3);

        test.setCollection2(array);

        Assert.assertTrue(admin.save(test));

        Assert.assertTrue(admin.obtain(test, "name = 'name'"));

        Collection2 t = new Collection2();
        t.setDescription("description added");
        test.getCollection2().add(t);

        Assert.assertTrue(admin.modify(test));

        Collection1 tt = new Collection1();
        Assert.assertTrue(admin.obtain(tt, "name = 'name'"));
        Assert.assertEquals("description added",
                ((Collection2)tt.getCollection2().get(tt.getCollection2().size()-1)).getDescription());
        Assert.assertTrue(admin.delete(test));
    }
View Full Code Here

    @Test
    public void testModifyCollection(){
        Collection1 test = new Collection1();
        test.setName("name");

        Collection2 t1 = new Collection2();
        t1.setDescription("description1");
        Collection2 t2 = new Collection2();
        t2.setDescription("description2");
        Collection2 t3 = new Collection2();
        t3.setDescription("description3");
        ArrayList array = new ArrayList();
        array.add(t1);
        array.add(t2);
        array.add(t3);

        test.setCollection2(array);

        Assert.assertTrue(admin.save(test));

        Assert.assertTrue(admin.obtain(test, "name = 'name'"));

        Collection2 t = new Collection2();
        t.setDescription("description added");
        test.getCollection2().add(t);

        Assert.assertTrue(admin.modify(test));

        Collection1 tt = new Collection1();
View Full Code Here

TOP

Related Classes of cat.quickdb.date200912.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.