<commit_before>package net.tofweb.controller;

import java.net.URI;
import java.util.Collection;

import javax.annotation.Resource;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;

import net.tofweb.model.Widget;
import net.tofweb.service.WidgetService;

@RestController
@RequestMapping("/widget")
public class WidgetController {

	@Resource
	WidgetService widgetService;

	@RequestMapping(method = RequestMethod.GET)
	Collection<Widget> get() {
		return widgetService.findAll();
	}

	@RequestMapping(method = RequestMethod.GET, value = "/{widgetId}")
	Widget getById(@PathVariable Integer widgetId) {
		return widgetService.findById(widgetId);
	}

	@RequestMapping(method = RequestMethod.POST)
	ResponseEntity<?> add(@RequestBody Widget widget) {
		Widget result = widgetService.save(widget);
		URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}").buildAndExpand(result.getId())
				.toUri();

		return ResponseEntity.created(location).build();
	}
}<commit_msg>Added update<commit_after>package net.tofweb.controller;

import java.net.URI;
import java.util.Collection;

import javax.annotation.Resource;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;

import net.tofweb.model.Widget;
import net.tofweb.service.WidgetService;

@RestController
@RequestMapping("/widget")
public class WidgetController {

	@Resource
	WidgetService widgetService;

	@RequestMapping(method = RequestMethod.GET)
	Collection<Widget> get() {
		return widgetService.findAll();
	}

	@RequestMapping(method = RequestMethod.GET, value = "/{widgetId}")
	Widget getById(@PathVariable Integer widgetId) {
		return widgetService.findById(widgetId);
	}

	@RequestMapping(method = RequestMethod.POST)
	ResponseEntity<?> add(@RequestBody Widget widget) {
		Widget result = widgetService.save(widget);
		URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}").buildAndExpand(result.getId())
				.toUri();

		return ResponseEntity.created(location).build();
	}

	@RequestMapping(method = RequestMethod.PUT)
	Widget update(@RequestBody Widget widget) {
		return widgetService.save(widget);
	}
}
{'fraction_non_alphanumeric': 0.11404728789986092, 'fraction_numerical': 0.0, 'mean_word_length': 6.71313672922252, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5393151', 'n_tokens_mistral': 817, 'n_tokens_neox': 796, 'n_words': 139}