<commit_before>package pl.mycalories.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import pl.mycalories.error.ErrorInformation;
import pl.mycalories.model.Meal;
import pl.mycalories.service.MealService;
import pl.mycalories.service.MealServiceError;

@RestController
@RequestMapping("/meal")
public class MealController extends AbstractController<Meal, MealService> {

    private MealServiceError mealServiceError;

    @Autowired
    public void setMealServiceError(MealServiceError mealServiceError) {
        this.mealServiceError = mealServiceError;
    }

    @Autowired
    public MealController(MealService service) {
        super(service);
    }

    @Override
    @PutMapping("/{id}")
    public @ResponseBody
    ResponseEntity<?> update(@PathVariable Long id, @RequestBody Meal meal) {
        ErrorInformation errorInformation = mealServiceError.checkIfProductsAreModified(meal);

        if(errorInformation.getHttpStatus() != HttpStatus.OK) {
            return new ResponseEntity<ErrorInformation>(errorInformation, errorInformation.getHttpStatus());
        }

        meal.setId(id);
        meal = service.save(meal);

        return new ResponseEntity<Meal>(meal, HttpStatus.OK);
    }
}<commit_msg>override create method (checking original product nutritional values before save)<commit_after>package pl.mycalories.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import pl.mycalories.error.ErrorInformation;
import pl.mycalories.model.Meal;
import pl.mycalories.service.MealService;
import pl.mycalories.service.MealServiceError;

@RestController
@RequestMapping("/meal")
public class MealController extends AbstractController<Meal, MealService> {

    private MealServiceError mealServiceError;

    @Autowired
    public void setMealServiceError(MealServiceError mealServiceError) {
        this.mealServiceError = mealServiceError;
    }

    @Autowired
    public MealController(MealService service) {
        super(service);
    }

    @Override
    @PostMapping
    public @ResponseBody
    ResponseEntity<?> create(@RequestBody Meal meal) {
        ErrorInformation errorInformation = mealServiceError.checkIfProductsAreModified(meal);

        if(errorInformation.getHttpStatus() != HttpStatus.OK) {
            return new ResponseEntity<ErrorInformation>(errorInformation, errorInformation.getHttpStatus());
        }

        Meal createdMeal = service.save(meal);
        return new ResponseEntity<Meal>(createdMeal, HttpStatus.OK);
    }

    @Override
    @PutMapping("/{id}")
    public @ResponseBody
    ResponseEntity<?> update(@PathVariable Long id, @RequestBody Meal meal) {
        ErrorInformation errorInformation = mealServiceError.checkIfProductsAreModified(meal);

        if(errorInformation.getHttpStatus() != HttpStatus.OK) {
            return new ResponseEntity<ErrorInformation>(errorInformation, errorInformation.getHttpStatus());
        }

        meal.setId(id);
        meal = service.save(meal);
        return new ResponseEntity<Meal>(meal, HttpStatus.OK);
    }
}
{'fraction_non_alphanumeric': 0.09301634472511144, 'fraction_numerical': 0.0, 'mean_word_length': 4.351351351351352, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4624847', 'n_tokens_mistral': 903, 'n_tokens_neox': 883, 'n_words': 169}