diff --git a/src/main/java/com/example/cosmos_serversb/models/Groups.java b/src/main/java/com/example/cosmos_serversb/models/Groups.java index 94873fc..a4b330c 100644 --- a/src/main/java/com/example/cosmos_serversb/models/Groups.java +++ b/src/main/java/com/example/cosmos_serversb/models/Groups.java @@ -11,7 +11,7 @@ public class Groups { private static Groups theInstance = null; private static ArrayList groups = new ArrayList<>(); - private static HashMap testMap = new HashMap<>(); + private static HashMap groupsMap = new HashMap<>(); private static SessionFactory sessionFactory; private static String baseURI = "http://nitta-lab-www.is.konan-u.ac.jp/"; @@ -42,17 +42,17 @@ //getGroupsListByUidは現状うまく処理されない public static HashMap getGroupsListByUid(String uId){ - return getTestHashMap(); + return getGroupsHashMap(uId); } public static Group createGroup(String name, String uId){ //先にGidとuriの発行を行う String gId = getInstance().createGId(); String uri = baseURI + AppName + "/groups/" + gId; - createTestHashMap(gId, uri); Group testGroup = new Group(gId, uri, name, uId); Session session = SessionManager.getInstance().getSession(); session.save(testGroup); + return testGroup; } @@ -121,6 +121,7 @@ return DeleteResult.SUCCESS; } + /* //テスト用にHashMapの作成 public static void createTestHashMap(String gId, String uri){ testMap.put(gId, uri); @@ -129,11 +130,17 @@ for (String key : TestMap.keySet()) { System.out.println(key + " " + TestMap.get(key)); } - */ } + */ - public static HashMap getTestHashMap(){ - return testMap; + public static HashMap getGroupsHashMap(String uId){ + Session session = SessionManager.getInstance().getSession(); + User user = (User) session.load(User.class, uId); + for(Group group : user.groups){ + System.out.println(group); + groupsMap.put(group.getgId(), group.getUri()); + } + return groupsMap; } }