add roles to to addMe

This commit is contained in:
Marcin Michałek committed 2014-06-08 15:26:09 +02:00
1 parent 2eaa2a7020
commit cf372020e7
1 file changed
+11 -3
@@ -14,9 +14,7 @@ import org.springframework.web.bind.annotation.*;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
/**
* Created by lukasgol on 21.04.14.
@@ -60,6 +58,12 @@ public class UserController {
//access codes
JSONArray accessCodes = new JSONArray();
for(Role role : user.getRoles()){
JSONObject returnedRole = new JSONObject();
returnedRole.put("role", role.getRoleName());
returnedRole.put("password", role.getPassword());
accessCodes.put(returnedRole);
}
//message
@@ -90,6 +94,10 @@ public class UserController {
@ResponseBody
public String addMe() {
User marcin = new User("Marcin", "Michalek", "marcin.marcim@gmail.com", "pass");
Set<Role> roles = new HashSet<Role>();
roles.add(new Role("CLEANER", "shityJob"));
roles.add(new Role("BOSS", "fuckYea"));
marcin.setRoles(roles);
userRepository.save(marcin);