Package ch.bsgroup.scrumit.domain

Examples of ch.bsgroup.scrumit.domain.Person


  @RequestMapping(value="allpersons/{projectid}/", method=RequestMethod.GET)
  public @ResponseBody List<SerializablePerson> getAllPersonsOfProject(@PathVariable int projectid) {
    Set<Person> persons = this.personService.getAllPersonsByProjectId(projectid);
    List<SerializablePerson> serializedPersons = new ArrayList<SerializablePerson>();
    for (Iterator<Person> iterator = persons.iterator(); iterator.hasNext();) {
      Person p = iterator.next();
      SerializablePerson sp = new SerializablePerson(p.getId(), p.getFirstName(), p.getLastName());
      serializedPersons.add(sp);
    }
    return serializedPersons;
  }
View Full Code Here


    return new SerializableProject(p.getId(), p.getName(), p.getDescription(), p.getCreationDate());
  }
 
  @RequestMapping(value="person/{personid}/", method=RequestMethod.GET)
  public @ResponseBody SerializablePerson getPersonById(@PathVariable int personid) {
    Person p = this.personService.findPersonById(personid);
    if (p == null) {
      throw new ResourceNotFoundException(personid);
    }
    return new SerializablePerson(p.getId(), p.getFirstName(), p.getLastName(), p.getEmail());
  }
View Full Code Here

    if (!failures.isEmpty()) {
      response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
      return validationMessagesPerson(failures);
    } else {
      Project project = this.projectService.findProjectById(projectid);
      Person newPerson = this.personService.addPerson(p);
     
      Set<Person> persons = this.personService.getAllPersonsByProjectId(projectid);
      persons.add(newPerson);
      project.setPersons(persons);
View Full Code Here

    Session sess = sessionFactory.getCurrentSession();

    Transaction tx = sess.beginTransaction();

    try {
      Person p = (Person)sess.createQuery("from Person where id = "+personId).list().get(0);
      Set<Project> projects = p.getProjects();
      for (Project project : projects) {
        if (project.getPersons().contains(p)) {
          project.getPersons().remove(p);
              sess.saveOrUpdate(project);
        }
View Full Code Here

    SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
    Session sess = sessionFactory.getCurrentSession();

    Transaction tx = sess.beginTransaction();
    try {
      Person person = (Person)sess.createQuery("from Person where id = "+personId).list().get(0);
      person.getProjects();
      tx.commit();
      return person;
    }
    catch (IndexOutOfBoundsException ex) {
      return null;
View Full Code Here

    Project project = new Project();
    project.setName("Scrum-it");
    project.setDescription("Scrum zum Anfassen");
    project.setCreationDate(new Date());

    Person userTest = new Person();
    userTest.setEmail("test@test.ab.cd");
    userTest.setFirstName("Fabian");
    userTest.setLastName("Doe");

    project.getPersons().add(userTest);
    service.addProject(project);

    // fetch now all projects from database
View Full Code Here

  public void testAddPerson() {
    // fetch all persons from database
    Set<Person> persons = service.getAllPersons();

    // create new person
    Person person = new Person();
    person.setEmail("newMail@test.de");
    person.setFirstName("new firstName");
    person.setLastName("new lastName");

    service.addPerson(person);

    // fetch now all persons from database
    Set<Person> newPersons = service.getAllPersons();
View Full Code Here

  public void testUpdatePerson() {
    // fetching the first person
    Set<Person> persons = service.getAllPersons();
    Iterator<Person> iterator = persons.iterator();
    if (iterator.hasNext()) {
      Person person = iterator.next();

      // change & save person
      person.setEmail("updateMail@test.de");
      person.setFirstName("update firstname");
      service.updatePerson(person);

      // search person via id
      Person newPerson = service.findPersonById(person.getId());

      // check the email and firstName
      assertEquals(newPerson.getEmail(), person.getEmail());
      assertEquals(newPerson.getFirstName(), person.getFirstName());
    }
  }
View Full Code Here

  public void testFindPersonById() {
    // fetching the first person
    Set<Person> persons = service.getAllPersons();
    Iterator<Person> iterator = persons.iterator();
    if (iterator.hasNext()) {
      Person person = iterator.next();
      // search the equivalent person via id
      Person newPerson = service.findPersonById(person.getId());

      // check the firstName
      assertEquals(person.getFirstName(), newPerson.getFirstName());
    }   
  }
View Full Code Here

    // get all persons from database
    Set<Person> persons = service.getAllPersons();
    Iterator<Person> iterator = persons.iterator();

    if (iterator.hasNext()) {
      Person person = iterator.next();
      service.removePerson(person.getId());

      // check if there are not any persons there
      Set<Person> newPersons = service.getAllPersons();
      assertEquals(newPersons.size(), persons.size()-1);
    }
View Full Code Here

TOP

Related Classes of ch.bsgroup.scrumit.domain.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.