<commit_before>package com.outofbounds.empire.Showings.Controllers;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.outofbounds.empire.Movies.Models.Movie;
import com.outofbounds.empire.Movies.Repositories.MovieRepository;
import com.outofbounds.empire.Showings.Models.Showing;
import com.outofbounds.empire.Showings.Repositories.ShowingRepository;
import com.outofbounds.empire.Showrooms.Models.Showroom;
import com.outofbounds.empire.Showrooms.Repositories.ShowroomRepository;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * Created by Anders on 26-Sep-17.
 */
@RestController
public class ShowingController {
    @Autowired
    public ShowingRepository showingRepository;

    @Autowired
    public MovieRepository movieRepository;

    @Autowired
    public ShowroomRepository showroomRepository;

    /**
     * Basic route for showings
     * @return Showing
     */

    @CrossOrigin(origins = "http://localhost:8000")
    @RequestMapping(method = RequestMethod.GET, value = "/showings")
    public @ResponseBody
    List<Showing> showings() {
        return showingRepository.findAll();
    }

    @CrossOrigin(origins = "http://localhost:8000")
    @RequestMapping(method = RequestMethod.POST, value = "/showings")
    public @ResponseBody
    Showing addShowing(
            @RequestParam (required = true) int movie_id,
            @RequestParam (required = true) int showroom_id
    )
    {
        Showing showing = new Showing(
                movieRepository.findById(movie_id),
                showroomRepository.findById(showroom_id),
                new Date()
        );
        showingRepository.save(showing);
        return showing;
    }<commit_msg>formatted date input ready<commit_after>package com.outofbounds.empire.Showings.Controllers;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.outofbounds.empire.Movies.Models.Movie;
import com.outofbounds.empire.Movies.Repositories.MovieRepository;
import com.outofbounds.empire.Showings.Models.Showing;
import com.outofbounds.empire.Showings.Repositories.ShowingRepository;
import com.outofbounds.empire.Showrooms.Models.Showroom;
import com.outofbounds.empire.Showrooms.Repositories.ShowroomRepository;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;

/**
 * Created by Anders on 26-Sep-17.
 */
@RestController
public class ShowingController {
    @Autowired
    public ShowingRepository showingRepository;

    @Autowired
    public MovieRepository movieRepository;

    @Autowired
    public ShowroomRepository showroomRepository;

    /**
     * Basic route for showings
     * @return Showing
     */

    @CrossOrigin(origins = "http://localhost:8000")
    @RequestMapping(method = RequestMethod.GET, value = "/showings")
    public @ResponseBody
    List<Showing> showings() {
        return showingRepository.findAll();
    }

    @CrossOrigin(origins = "http://localhost:8000")
    @RequestMapping(method = RequestMethod.POST, value = "/showings")
    public @ResponseBody
    Showing addShowing(
            @RequestParam (required = true) int movie_id,
            @RequestParam (required = true) int showroom_id,
            @RequestParam (required = true) String date
    )
    {
        Date datetime = null;
        DateFormat df = new SimpleDateFormat("MM dd HH mm yyyy", Locale.ENGLISH);
        try{
            datetime = df.parse(date);
        } catch (Exception e) {
            e.printStackTrace();
        }

        Showing showing = new Showing(
                movieRepository.findById(movie_id),
                showroomRepository.findById(showroom_id),
                datetime
        );
        showingRepository.save(showing);
        return showing;
    }
{'fraction_non_alphanumeric': 0.09866017052375152, 'fraction_numerical': 0.00584652862362972, 'mean_word_length': 3.358811040339703, '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': '682740', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1162, 'n_words': 224}