Package ch.bsgroup.scrumit.domain

Examples of ch.bsgroup.scrumit.domain.Project


  @RequestMapping(value="allprojects/", method=RequestMethod.GET)
  public @ResponseBody List<SerializableProject> getAllProjects() {
    Set<Project> projects = this.projectService.getAllProjects();
    List<SerializableProject> serializedProjects = new ArrayList<SerializableProject>();
    for (Iterator<Project> iterator = projects.iterator(); iterator.hasNext();) {
      Project p = iterator.next();
      SerializableProject sp = new SerializableProject(p.getId(), p.getName());
      serializedProjects.add(sp);
    }
    return serializedProjects;
  }
View Full Code Here


    return serializedPersons;
  }

  @RequestMapping(value="{projectid}/", method=RequestMethod.GET)
  public @ResponseBody SerializableProject getProjectById(@PathVariable int projectid) {
    Project p = this.projectService.findProjectById(projectid);
    if (p == null) {
      throw new ResourceNotFoundException(projectid);
    }
    return new SerializableProject(p.getId(), p.getName(), p.getDescription(), p.getCreationDate());
  }
View Full Code Here

  }

  @RequestMapping(value="update/", method=RequestMethod.POST)
  public @ResponseBody Map<String, ? extends Object> updateProject(@RequestBody Project p, HttpServletResponse response) {
    Set<ConstraintViolation<Project>> failures = validator.validate(p);
    Project project = this.projectService.findProjectById(p.getId());
    project.setName(p.getName().trim());
    project.setDescription(p.getDescription().trim());
    if (!failures.isEmpty()) {
      response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
      return validationMessages(failures);
    } else {
      this.projectService.updateProject(project);
      SerializableProject sp = new SerializableProject(project.getId(), project.getName(),
          project.getDescription(), project.getCreationDate());
      return Collections.singletonMap("project", sp);
    }
  }
View Full Code Here

    Set<ConstraintViolation<Person>> failures = validator.validate(p);
    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);

      this.projectService.updateProject(project);
      return Collections.singletonMap("person", newPerson);
    }
  }
View Full Code Here

    this.taskService = taskService;
  }

  @RequestMapping(value="{projectid}/", method=RequestMethod.GET)
  public String getSprintUserstory(@PathVariable("projectid") int id, Model model) {
    Project p = this.projectService.findProjectById(id);
    if (p == null) {
      throw new ResourceNotFoundException(id);
    }
    model.addAttribute("projectid", id);
    model.addAttribute("projectname", p.getName());
    return "sprint/sprint-userstory";
  }
View Full Code Here

    }
  }

  @RequestMapping(value="add/{projectid}/", method=RequestMethod.POST)
  public @ResponseBody Map<String, ? extends Object> addSprint(@RequestBody Sprint s, @PathVariable int projectid, HttpServletResponse response) throws ParseException {
    Project p = this.projectService.findProjectById(projectid);
    if (p == null) {
      throw new ResourceNotFoundException(projectid);
    }
    s.setProject(p);
    Set<ConstraintViolation<Sprint>> failures = validator.validate(s);
View Full Code Here

  @RequestMapping(value="{projectid}/{sprintid}/", method=RequestMethod.GET)
  public String getBoard(@PathVariable("projectid") int pid, @PathVariable("sprintid") int sid, Model model) {
    model.addAttribute("projectid", pid);
    model.addAttribute("sprintid", sid);
    Project p = this.projectService.findProjectById(pid);
    if (p == null) {
      throw new ResourceNotFoundException(pid);
    }
    model.addAttribute("projectname", p.getName());
    Sprint s = this.sprintService.findSprintById(sid);
    if (s == null) {
      throw new ResourceNotFoundException(sid);
    }
    model.addAttribute("sprintslogan", s.getSlogan());
View Full Code Here

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

    Transaction tx = sess.beginTransaction();
    try {
      Project p = (Project)sess.createQuery("from Project where id = "+projectId).list().get(0);
      p.setPersons(null);
      sess.delete(p);
      tx.commit();
    }
    catch (IndexOutOfBoundsException ex) {
      System.out.println("exception: "+ex);
View Full Code Here

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

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

  public void testAddProject() {
    // fetch all projects from database
    Set<Project> projects = service.getAllProjects();

    // create new project
    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
    Set<Project> newProjects = service.getAllProjects();
View Full Code Here

TOP

Related Classes of ch.bsgroup.scrumit.domain.Project

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.