<commit_before>package com.peta2kuba.pa165_haunted_houses.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.peta2kuba.pa165_haunted_houses.dto.PersonDTO;
import com.peta2kuba.pa165_haunted_houses.facade.PersonFacade;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.inject.Inject;
import java.util.Collection;

/**
 * @author turcovsky on 09/12/15.
 */
@RestController
@RequestMapping("/person")
public class PersonController {

	final static Logger logger = LoggerFactory.getLogger(PersonController.class);

	@Inject
	private PersonFacade personFacade;


	@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public final Collection<PersonDTO> getPeople() throws JsonProcessingException {

		logger.debug("rest getUsers()");
		return personFacade.findAllPersons();
	}

	@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public final PersonDTO getPersonById(@PathVariable("id") long id) throws Exception {

		logger.debug("rest getPersonById({})", id);
		PersonDTO personDTO = personFacade.findPersonById(id);
		if (personDTO == null){
			throw new RuntimeException("Person not found!");
		}
		return personDTO;
	}

	@RequestMapping(value = "/{email}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public final PersonDTO getPersonByEmail(@PathVariable("email") String email) throws Exception {

		logger.debug("rest getPersonByEmail({})", email);
		PersonDTO personDTO = personFacade.findPersonByEmail(email);
		if (personDTO == null){
			throw new RuntimeException("Person not found!");
		}
		return personDTO;
	}
}<commit_msg>rest part done<commit_after>package com.peta2kuba.pa165_haunted_houses.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.peta2kuba.pa165_haunted_houses.dto.PersonDTO;
import com.peta2kuba.pa165_haunted_houses.facade.PersonFacade;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
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.mvc.support.RedirectAttributes;
import org.springframework.web.util.UriComponentsBuilder;

import javax.inject.Inject;
import java.util.Collection;

/**
 * @author turcovsky on 09/12/15.
 */
@RestController
@RequestMapping("/person")
public class PersonController {

	final static Logger logger = LoggerFactory.getLogger(PersonController.class);

	@Inject
	private PersonFacade personFacade;

	@RequestMapping(value = "/add", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
	public final PersonDTO addPerson(@RequestBody PersonDTO person) throws Exception {

		logger.debug("rest addPerson()");

		personFacade.createPerson(person);
		return person;
	}

	@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
	public final void removePerson(@PathVariable("id") long id) throws Exception {
		logger.debug("rest removePerson({})", id);

		personFacade.removePersonById(id);
	}

	@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public final Collection<PersonDTO> getPeople() throws JsonProcessingException {

		logger.debug("rest getUsers()");
		return personFacade.findAllPersons();
	}

	@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public final PersonDTO getPersonById(@PathVariable("id") long id) throws Exception {

		logger.debug("rest getPersonById({})", id);
		PersonDTO personDTO = personFacade.findPersonById(id);
		if (personDTO == null){
			throw new RuntimeException("Person not found!");
		}
		return personDTO;
	}
}
{'fraction_non_alphanumeric': 0.10928476232785429, 'fraction_numerical': 0.00888494002665482, 'mean_word_length': 6.593591905564924, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5531830', 'n_tokens_mistral': 1375, 'n_tokens_neox': 1308, 'n_words': 259}