@@ -0,0 +1,2445 @@
+package com.aemreunal.service;%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 javax.validation.ConstraintViolationException;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.stereotype.Service;%0Aimport org.springframework.transaction.annotation.Transactional;%0Aimport com.aemreunal.config.GlobalSettings;%0Aimport com.aemreunal.domain.Project;%0Aimport com.aemreunal.domain.Scenario;%0Aimport com.aemreunal.exception.project.ProjectNotFoundException;%0Aimport com.aemreunal.exception.scenario.ScenarioNotFoundException;%0Aimport com.aemreunal.repository.scenario.ScenarioRepo;%0A%0A@Transactional%0A@Service%0Apublic class ScenarioService %7B%0A    @Autowired%0A    private ProjectService projectService;%0A%0A    @Autowired%0A    private ScenarioRepo scenarioRepo;%0A%0A    public Scenario save(String username, Long projectId, Scenario scenario) throws ConstraintViolationException %7B%0A        if (GlobalSettings.DEBUGGING) %7B%0A            System.out.println(%22Saving scenario with ID = %5C'%22 + scenario.getScenarioId() + %22%5C'%22);%0A        %7D%0A        // Even though the 'project' variable is only used inside the if-clause,%0A        // the Project is found no matter what to ensure it exists and legitimate.%0A        Project project = projectService.findProjectById(username, projectId);%0A        if (scenario.getProject() == null) %7B%0A            // This means it hasn't been saved yet%0A            scenario.setProject(project);%0A        %7D%0A        return scenarioRepo.save(scenario);%0A    %7D%0A%0A    public Scenario getScenario(String username, Long projectId, Long scenarioId) throws ScenarioNotFoundException, ProjectNotFoundException %7B%0A        if (GlobalSettings.DEBUGGING) %7B%0A            System.out.println(%22Finding scenario with ID = %5C'%22 + scenarioId + %22%5C' in project = %5C'%22 + projectId + %22%5C'%22);%0A        %7D%0A        Project project = projectService.findProjectById(username, projectId);%0A        Scenario scenario = scenarioRepo.findByScenarioIdAndProject(scenarioId, project);%0A        if(scenario == null) %7B%0A            throw new ScenarioNotFoundException(scenarioId);%0A        %7D%0A        return scenario;%0A    %7D%0A%0A%7D%0A

Create Scenario service class