<commit_before>package org.dainst.gazetteer.controller;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.dainst.gazetteer.dao.GroupRoleRepository;
import org.dainst.gazetteer.dao.PlaceRepository;
import org.dainst.gazetteer.dao.RecordGroupRepository;
import org.dainst.gazetteer.dao.UserRepository;
import org.dainst.gazetteer.domain.GroupRole;
import org.dainst.gazetteer.domain.RecordGroup;
import org.dainst.gazetteer.domain.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class RecordGroupController {
	
	@Autowired
	private RecordGroupRepository recordGroupDao;
	
	@Autowired
	private UserRepository userDao;
	
	@Autowired
	private PlaceRepository placeDao;
	
	@Autowired
	private GroupRoleRepository groupRoleDao;
	
	@Value("${version}")
	private String version;
	
	private int usersPerPage = 10;
	
	private static final Logger logger = LoggerFactory.getLogger(RecordGroupController.class);
	
	
	@RequestMapping(value="/recordGroupManagement")
	public String getRecordGroupManagement(@RequestParam(required=false) String deleteRecordGroupId, ModelMap model) {
		
		List<RecordGroup> recordGroups = null;
		Map<String, String> groupRights = new HashMap<String, String>();
		if (isAdminEdit()) {
			recordGroups = (List<RecordGroup>) recordGroupDao.findAll();
			for (RecordGroup group : recordGroups) {
				groupRights.put(group.getId(), "admin");
			}
		}
		else {
			recordGroups = new ArrayList<RecordGroup>();
			User user = getUser();<commit_msg>sort record groups by name<commit_after>package org.dainst.gazetteer.controller;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.dainst.gazetteer.dao.GroupRoleRepository;
import org.dainst.gazetteer.dao.PlaceRepository;
import org.dainst.gazetteer.dao.RecordGroupRepository;
import org.dainst.gazetteer.dao.UserRepository;
import org.dainst.gazetteer.domain.GroupRole;
import org.dainst.gazetteer.domain.RecordGroup;
import org.dainst.gazetteer.domain.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Sort;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class RecordGroupController {
	
	@Autowired
	private RecordGroupRepository recordGroupDao;
	
	@Autowired
	private UserRepository userDao;
	
	@Autowired
	private PlaceRepository placeDao;
	
	@Autowired
	private GroupRoleRepository groupRoleDao;
	
	@Value("${version}")
	private String version;
	
	private int usersPerPage = 10;
	
	private static final Logger logger = LoggerFactory.getLogger(RecordGroupController.class);
	
	
	@RequestMapping(value="/recordGroupManagement")
	public String getRecordGroupManagement(@RequestParam(required=false) String deleteRecordGroupId, ModelMap model) {
		
		List<RecordGroup> recordGroups = null;
		Map<String, String> groupRights = new HashMap<String, String>();
		if (isAdminEdit()) {
			recordGroups = (List<RecordGroup>) recordGroupDao.findAll(new Sort(Sort.Direction.ASC, "creationDate"));
			for (RecordGroup group : recordGroups) {
				groupRights.put(group.getId(), "admin");
			}
		}
		else {
			recordGroups = new ArrayList<RecordGroup>();
			User user = getUser();
{'fraction_non_alphanumeric': 0.09882139619220308, 'fraction_numerical': 0.001813236627379873, 'mean_word_length': 6.318407960199005, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '1220852', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1281, 'n_words': 245}