Package org.mypj.db.thing

Examples of org.mypj.db.thing.Person


    List<Person> ps = impl.getAll();
    if (ps == null)
      return null;
    PersonInfo[] info = new PersonInfo[ps.size()];
    for (int i = 0; i < ps.size(); i++) {
      Person p = ps.get(i);
      info[i] = new PersonInfo();
      info[i].setName(p.getName());
      if (p.getContacts() != null && p.getContacts().size() > 0)
        info[i].setContact(p.getContacts().get(i).getContent());
    }
    return info;
  }
View Full Code Here


  private static final long serialVersionUID = 1L;

  @Override
  public BasicInfo createPerson(BasicInfo info) {
    PersonManagerImpl impl = new PersonManagerImpl();
    Person p1 = new Person(info.getEditName());
    p1.setBirthday(info.getEditBirthday());
    p1.setSex(info.getEditSex());
    p1.setPs(info.getEditPs());
    Contact c1 = new Contact(info.getEditContact());
    p1.getContacts().add(c1);
    if (!impl.isExist(p1)) {
      impl.create(p1);
      info.setViewName(info.getEditName());
      info.setViewContact(info.getEditContact());
      if (info.getEditBirthday() != null) {
View Full Code Here

  @Override
  public void delete(Person person) {
    PersistenceManager pm = PMF.get().getPersistenceManager();
    try {
      Person p = (Person) pm.getObjectById(Person.class, person.getId());
      if (p != null)
        pm.deletePersistent(p);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
View Full Code Here

    try {
      // where ID
      if (person == null) {
        return false;
      } else if (person.getId() != null) {
        Person p = (Person) pm.getObjectById(Person.class, person
            .getId());
        if (p != null)
          return true;
        else
          return false;
View Full Code Here

  @Override
  public void update(Person person) {
    PersistenceManager pm = PMF.get().getPersistenceManager();
    try {
      Person old_person = (Person) pm.getObjectById(Person.class, person
          .getId());
      if (old_person != null)
        old_person.setThis(person);
      pm.makePersistent(old_person);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      pm.close();
View Full Code Here

//        ApiProxy.setEnvironmentForCurrentThread(null);
  }

  @Test
  public void testAddPersonContact() {
    Person p1=new Person("haku");
    Contact c1=new Contact("08056828543");
    p1.getContacts().add(c1);
    impl.create(p1);
    Person p2= impl.getByName("haku");
    assertNotNull(p2);
    assertNotNull(p2.getContacts());
    assertEquals(1,p2.getContacts().size());
    assertEquals("08056828543",p2.getContacts().get(0).getContent());
    assertEquals("haku",p2.getContacts().get(0).getPerson().getName());
  }
View Full Code Here

    assertEquals("haku",p2.getContacts().get(0).getPerson().getName());
  }

  @Test
  public void testAddPersonEvent() {
    Person p1=new Person("haku");
    Event e1=new Event(new Date(),"my home","study japanese");
    p1.getEvents().add(e1);
    impl.create(p1);
    Person p2= impl.getByName("haku");
    assertNotNull(p2);
    assertNotNull(p2.getEvents());
    assertEquals(1,p2.getEvents().size());
    assertEquals("study japanese",p2.getEvents().get(0).getPs());
    assertEquals("haku",p2.getEvents().get(0).getPerson().getName());
  }
View Full Code Here

    assertEquals("haku",p2.getEvents().get(0).getPerson().getName());
  }

  @Test
  public void testCreate() {
    Person p1=new Person("haku");
    impl.create(p1);
    Person p2=new Person("bai");
    impl.create(p2);
    Person p3= impl.getByName("haku");
    assertNotNull(p3);
  }
View Full Code Here

    assertNotNull(p3);
  }

  @Test
  public void testDelete() {
    Person p1=new Person("haku");
    impl.create(p1);
    Person p2= impl.getByName("haku");
    impl.delete(p2);
    Person p3= impl.getByName("haku");
    assertNull(p3);
  }
View Full Code Here

    assertNull(p3);
  }

  @Test
  public void testGetAll() {
    Person p1=new Person("haku");
    impl.create(p1);
    Person p2=new Person("pony");
    impl.create(p2);
    Person p3=new Person("bai");
    impl.create(p3);
    List<Person> persons = impl.getAll();
    assertEquals(3, persons.size());
  }
View Full Code Here

TOP

Related Classes of org.mypj.db.thing.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.