@@ -0,0 +1,3930 @@
+package com.aemreunal.controller.scenario;%0A%0A/*%0A ***************************%0A * Copyright (c) 2014      *%0A *                         *%0A * This code belongs to:   *%0A *                         *%0A * @author Ahmet Emre %C3%9Cnal *%0A * S001974                 *%0A *                         *%0A * aemreunal@gmail.com     *%0A * emre.unal@ozu.edu.tr    *%0A *                         *%0A * aemreunal.com           *%0A ***************************%0A */%0A%0Aimport java.util.List;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.hateoas.mvc.ControllerLinkBuilder;%0Aimport org.springframework.http.HttpStatus;%0Aimport org.springframework.http.ResponseEntity;%0Aimport org.springframework.stereotype.Controller;%0Aimport org.springframework.web.bind.annotation.PathVariable;%0Aimport org.springframework.web.bind.annotation.RequestMapping;%0Aimport org.springframework.web.bind.annotation.RequestMethod;%0Aimport org.springframework.web.bind.annotation.RequestParam;%0Aimport com.aemreunal.config.GlobalSettings;%0Aimport com.aemreunal.controller.project.ProjectController;%0Aimport com.aemreunal.controller.user.UserController;%0Aimport com.aemreunal.domain.Scenario;%0Aimport com.aemreunal.service.ScenarioService;%0A%0Aimport static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;%0A%0A@Controller%0A@RequestMapping(GlobalSettings.SCENARIO_PATH_MAPPING)%0Apublic class ScenarioController %7B%0A    @Autowired%0A    private ScenarioService scenarioService;%0A%0A    // TODO add search by attributes%0A    @RequestMapping(method = RequestMethod.GET, produces = %22application/json;charset=UTF-8%22)%0A    public ResponseEntity%3CList%3CScenario%3E%3E getAllScenariosOfUser(@PathVariable String username,%0A                                                                @PathVariable Long projectId) %7B%0A        List%3CScenario%3E scenarios = scenarioService.getScenariosOfProject(username, projectId);%0A        return new ResponseEntity%3CList%3CScenario%3E%3E(scenarios, HttpStatus.OK);%0A    %7D%0A%0A    @RequestMapping(method = RequestMethod.GET, value = GlobalSettings.SCENARIO_ID_MAPPING, produces = %22application/json;charset=UTF-8%22)%0A    public ResponseEntity%3CScenario%3E getScenario(@PathVariable String username,%0A                                                @PathVariable Long projectId,%0A                                                @PathVariable Long scenarioId) %7B%0A        Scenario scenario = scenarioService.getScenario(username, projectId, scenarioId);%0A        addLinks(username, projectId, scenarioId, scenario);%0A        return new ResponseEntity%3CScenario%3E(scenario, HttpStatus.OK);%0A    %7D%0A%0A    private void addLinks(String username, Long projectId, Long scenarioId, Scenario scenario) %7B%0A        scenario.add(ControllerLinkBuilder.linkTo(methodOn(ScenarioController.class).getScenario(username, projectId, scenarioId)).withSelfRel());%0A        scenario.add(ControllerLinkBuilder.linkTo(methodOn(UserController.class).getUserByUsername(username)).withRel(%22owner%22));%0A        scenario.add(ControllerLinkBuilder.linkTo(methodOn(ProjectController.class).getProjectById(username, projectId)).withRel(%22project%22));%0A    %7D%0A%0A    @RequestMapping(method = RequestMethod.DELETE, value = GlobalSettings.SCENARIO_ID_MAPPING, produces = %22application/json;charset=UTF-8%22)%0A    public ResponseEntity%3CScenario%3E deleteScenario(@PathVariable String username,%0A                                                   @PathVariable Long projectId,%0A                                                   @PathVariable Long scenarioId,%0A                                                   @RequestParam(value = %22confirm%22, required = true) String confirmation) %7B%0A        if (confirmation.toLowerCase().equals(%22yes%22)) %7B%0A            Scenario deletedScenario = scenarioService.delete(username, projectId, scenarioId);%0A            return new ResponseEntity%3CScenario%3E(deletedScenario, HttpStatus.OK);%0A        %7D else %7B%0A            return new ResponseEntity%3CScenario%3E(HttpStatus.PRECONDITION_FAILED);%0A        %7D%0A    %7D%0A%7D%0A

Create Scenario controller