package com.sumarlidi.medieval.webbapp.init;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.sumarlidi.medieval.application.services.RoleService;
import com.sumarlidi.medieval.application.services.UserService;
import com.sumarlidi.medieval.domain.User;

@Component
public class DBInit implements InitializingBean {

	@Autowired
	private RoleService roleService; 
	@Autowired 
	private UserService userService;
	@Override
	public void afterPropertiesSet() throws Exception {
		roleInit();
		userInit();
	}
	private void roleInit() {	
		roleService.createRoleIfNotExist("ROLE_USER");
		roleService.createRoleIfNotExist("ROLE_ADMIN");
		roleService.createRoleIfNotExist("ROLE_MOD");
	}
	private void userInit(){
		User admin = new User();
		admin.setEmail("Sumek@wp.pl");
		admin.setPassword("DzikieBazie");
		admin.setNick("Sumarlidi");
		admin.setTeam("Dziki Bez");
		userService.addIfNotExist(admin,"ROLE_ADMIN");
	}

}

@@ -887,16 +887,18 @@
 il(%22
-Sumek@wp
+Admin@mail
 .pl%22
@@ -925,19 +925,12 @@
 rd(%22
-DzikieBazie
+Mail
 %22);%0A
@@ -950,17 +950,13 @@
 ck(%22
-Sumarlidi
+Admin
 %22);%0A
@@ -976,17 +976,17 @@
 am(%22
-Dziki Bez
+AdminTeam
 %22);%0A

Update DBInit.java