예제 #1
0
파일: Role.java 프로젝트: ukwa/w3act
 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;
 }
예제 #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);
  }
예제 #3
0
파일: Role.java 프로젝트: nbuu/k2studio
  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;
  }