Beispiel #1
0
 public static Map<String, String> options() {
   LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
   for (Role s : Role.findAll()) {
     options.put(s.id.toString(), s.name);
   }
   return options;
 }
Beispiel #2
0
  @Test
  public void retrieveTestData() {
    List<ClubRole> allRoles = ClubRole.findAll();
    assertNotNull("Roles should be found!", allRoles);
    assertEquals("There should be 4 roles.", 4, allRoles.size());

    Role adminRole = Role.find("byName", "Admin").first();
    ClubRole clubRole = ClubRole.find("byRole", adminRole).first();
    assertNotNull("ClubAdmin role should be found!", clubRole);
    //	    assertEquals("Admin Role's name should be set","Admin", test.name);
  }
Beispiel #3
0
  public static List<Map<String, Object>> getTree(String node_role) {
    List<Map<String, Object>> nodes = new ArrayList<Map<String, Object>>();
    Map<String, Object> root = new HashMap<String, Object>();
    root.put("id", 0);
    root.put("text", Configure.get("SYS_COMPANY_NAME"));
    nodes.add(root);

    List<Map<String, Object>> parent = new ArrayList<Map<String, Object>>();
    List<Role> roles = Role.findAll();
    for (Role role : roles) {
      Map<String, Object> node = new HashMap<String, Object>();
      node.put("id", role.id);
      node.put("text", role.name);
      if (node_role != null && ("," + node_role + ",").indexOf("," + role.id + ",") > -1) {
        node.put("checked", true);
      } else {
        node.put("checked", false);
      }
      parent.add(node);
    }
    root.put("children", parent.toArray(new Object[parent.size()]));
    return nodes;
  }