<commit_before>package jp.hitting.svn_diff_browser.controller

import jp.hitting.svn_diff_browser.Constants
import jp.hitting.svn_diff_browser.model.RepositoryModel
import jp.hitting.svn_diff_browser.service.RepositoryService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import java.util.*
import javax.servlet.http.HttpSession

/**
 * Repository Controller.
 * Created by hitting on 2016/03/04.
 */
@Controller
@RequestMapping("/repository")
class RepositoryController {

    @Autowired
    private val repositoryServiceImpl: RepositoryService? = null

    /**
     * Repository detail page
     *
     * @param id repository ID
     * @param dir target directory
     * @param session HttpSession
     * @param model Model
     * @return detail view name
     */
    @RequestMapping("/{id}")
    fun detail(@PathVariable("id") id: Int, path: String?, session: HttpSession, model: Model): String {
        val map = session.getAttribute(Constants.SessionKey.SESSION_REPOSITORY_KEY) as? HashMap<Int, RepositoryModel>
        if (map == null || !map.containsKey(id)) {
            // TODO error message
            return "index"
        }

        val repository = map.get(id)!!
        val temp = repository.url.split("/")
        val repositoryName = temp.get(temp.size - 1)
        model.addAttribute("repositoryName", repositoryName)

        val targetPath = if (path == null) "/" else "/" + path
        model.addAttribute("path", targetPath)
        // FIXME init repository twice
        model.addAttribute("logList", this.repositoryServiceImpl!!.getLogList(repository, targetPath))
        model.addAttribute("pathList", this.repositoryServiceImpl!!.getPathList(repository, targetPath))

        return "detail"
    }

    /**
     * Repository commit log page at revision.
     *
     * @param id repository ID
     * @param rev revision
     * @param session HttpSession
     * @param model Model
     * @return diff view name
     */
    @RequestMapping("/{id}/rev/{rev}")
    fun diff(@PathVariable("id") id: Int, @PathVariable("rev") rev: Long, path: String?, session: HttpSession, model: Model): String {
        val map = session.getAttribute(Constants.SessionKey.SESSION_REPOSITORY_KEY) as? HashMap<Int, RepositoryModel>
        if (map == null || !map.containsKey(id)) {
            // TODO error message
            return "index"
        }

        val targetPath = if (path == null) "/" else "/" + path

        // TODO
        this.repositoryServiceImpl!!.getDiffList(map.get(id)!!, targetPath, rev)
        return "diff"
    }
<commit_msg>pass diff list to diff.html<commit_after>package jp.hitting.svn_diff_browser.controller

import jp.hitting.svn_diff_browser.Constants
import jp.hitting.svn_diff_browser.model.RepositoryModel
import jp.hitting.svn_diff_browser.service.RepositoryService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import java.util.*
import javax.servlet.http.HttpSession

/**
 * Repository Controller.
 * Created by hitting on 2016/03/04.
 */
@Controller
@RequestMapping("/repository")
class RepositoryController {

    @Autowired
    private val repositoryServiceImpl: RepositoryService? = null

    /**
     * Repository detail page
     *
     * @param id repository ID
     * @param dir target directory
     * @param session HttpSession
     * @param model Model
     * @return detail view name
     */
    @RequestMapping("/{id}")
    fun detail(@PathVariable("id") id: Int, path: String?, session: HttpSession, model: Model): String {
        val map = session.getAttribute(Constants.SessionKey.SESSION_REPOSITORY_KEY) as? HashMap<Int, RepositoryModel>
        if (map == null || !map.containsKey(id)) {
            // TODO error message
            return "index"
        }

        val repository = map.get(id)!!
        val temp = repository.url.split("/")
        val repositoryName = temp.get(temp.size - 1)
        model.addAttribute("repositoryName", repositoryName)

        val targetPath = if (path == null) "/" else "/" + path
        model.addAttribute("path", targetPath)
        // FIXME init repository twice
        model.addAttribute("logList", this.repositoryServiceImpl!!.getLogList(repository, targetPath))
        model.addAttribute("pathList", this.repositoryServiceImpl!!.getPathList(repository, targetPath))

        return "detail"
    }

    /**
     * Repository commit log page at revision.
     *
     * @param id repository ID
     * @param rev revision
     * @param session HttpSession
     * @param model Model
     * @return diff view name
     */
    @RequestMapping("/{id}/rev/{rev}")
    fun diff(@PathVariable("id") id: Int, @PathVariable("rev") rev: Long, path: String?, session: HttpSession, model: Model): String {
        val map = session.getAttribute(Constants.SessionKey.SESSION_REPOSITORY_KEY) as? HashMap<Int, RepositoryModel>
        if (map == null || !map.containsKey(id)) {
            // TODO error message
            return "index"
        }

        val targetPath = if (path == null) "/" else "/" + path

        model.addAttribute("diffList", this.repositoryServiceImpl!!.getDiffList(map.get(id)!!, targetPath, rev))
        return "diff"
    }

{'fraction_non_alphanumeric': 0.11513745091038914, 'fraction_numerical': 0.0032131381649410924, 'mean_word_length': 3.1503703703703705, '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': '3025793', 'n_tokens_mistral': 1553, 'n_tokens_neox': 1540, 'n_words': 376}