diff --git a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Account.java b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Account.java index e5c60de..f7594e2 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Account.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Account.java @@ -4,10 +4,10 @@ private int point; private String name; public Map getValue() { - Map temp_nil5 = new HashMap<>(); - temp_nil5.put("point",this.getPoint()); - temp_nil5.put("name",this.getName()); - return temp_nil5; + Map temp_nil4 = new HashMap<>(); + temp_nil4.put("name",this.getName()); + temp_nil4.put("point",this.getPoint()); + return temp_nil4; } public int getPoint() { return point; @@ -16,12 +16,12 @@ return this.name; } public void updatePointFromBattle(String self, String rid, int mno, boolean battle, String id) { - int temp_if0; - if (hasWon) { - temp_if0 = (this.point+1); + int temp_if1; + if (battle) { + temp_if1 = (this.point+1); } else { - temp_if0 = this.point; - }this.point = temp_if0; + temp_if1 = this.point; + }this.point = temp_if1; } public void changeName(String aid, String name) { this.name = name; diff --git a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Accounts.java b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Accounts.java index 3282fe9..9ec4085 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Accounts.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Accounts.java @@ -23,18 +23,18 @@ public void updatePointFromBattle(@PathParam("mid") String mid, @FormParam("rid") String rid, @FormParam("mno") int mno, @FormParam("battle") boolean battle, @FormParam("id") String id) { getAccount(mid).updatePointFromBattle(mid, rid, mno, battle, id); } - @Path("/{mid}/point") - @Produces(MediaType.APPLICATION_JSON) - @GET - public int getPointValue(@PathParam("mid") String mid) { - return getAccount(mid).getPoint(); - } @Path("/{mid}") @Produces(MediaType.APPLICATION_JSON) @GET public Map getAccountValue(@PathParam("mid") String mid) { return getAccount(mid).getValue(); } + @Path("/{mid}/point") + @Produces(MediaType.APPLICATION_JSON) + @GET + public int getPointValue(@PathParam("mid") String mid) { + return getAccount(mid).getPoint(); + } @Path("/{mid}/name") @Produces(MediaType.APPLICATION_JSON) @GET diff --git a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Member.java b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Member.java index 8482dd2..e566317 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Member.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Member.java @@ -5,10 +5,10 @@ private String id; private Client client = ClientBuilder.newClient(); public Map getValue() { - Map temp_nil6 = new HashMap<>(); - temp_nil6.put("name",this.getName()); - temp_nil6.put("id",this.getId()); - return temp_nil6; + Map temp_nil5 = new HashMap<>(); + temp_nil5.put("name",this.getName()); + temp_nil5.put("id",this.getId()); + return temp_nil5; } public String getId() { return this.id; diff --git a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Room.java b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Room.java index 85e576f..55dce69 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Room.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Room.java @@ -6,10 +6,10 @@ private boolean battle; private Client client = ClientBuilder.newClient(); public Map getValue() { - Map temp_nil4 = new HashMap<>(); - temp_nil4.put("battle",this.getBattle()); - temp_nil4.put("members",this.members.getValue()); - return temp_nil4; + Map temp_nil3 = new HashMap<>(); + temp_nil3.put("members",this.members.getValue()); + temp_nil3.put("battle",this.getBattle()); + return temp_nil3; } public Members getMembers() { return this.members; diff --git a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Rooms.java b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Rooms.java index 42789df..c0b7951 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Rooms.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Rooms.java @@ -18,23 +18,11 @@ public Room getRoom(String rid) { return this.value.get(rid); } - @Path("/{rid}") + @Path("/{rid}/members/{mno}/name") @Produces(MediaType.APPLICATION_JSON) @GET - public Map getRoomValue(@PathParam("rid") String rid) { - return getRoom(rid).getValue(); - } - @Path("/{rid}/battle") - @Produces(MediaType.APPLICATION_JSON) - @GET - public boolean getBattleValue(@PathParam("rid") String rid) { - return getRoom(rid).getBattle(); - } - @Path("/{rid}/members") - @Produces(MediaType.APPLICATION_JSON) - @GET - public List getMembersValue(@PathParam("rid") String rid) { - return getRoom(rid).getMembers().getValue(); + public String getNameValue(@PathParam("rid") String rid, @PathParam("mno") int mno) { + return getRoom(rid).getMembers().getMember(mno).getName(); } @Path("/{rid}/members/{mno}") @Produces(MediaType.APPLICATION_JSON) @@ -42,11 +30,17 @@ public Map getMemberValue(@PathParam("rid") String rid, @PathParam("mno") int mno) { return getRoom(rid).getMembers().getMember(mno).getValue(); } - @Path("/{rid}/members/{mno}/name") + @Path("/{rid}") @Produces(MediaType.APPLICATION_JSON) @GET - public String getNameValue(@PathParam("rid") String rid, @PathParam("mno") int mno) { - return getRoom(rid).getMembers().getMember(mno).getName(); + public Map getRoomValue(@PathParam("rid") String rid) { + return getRoom(rid).getValue(); + } + @Path("/{rid}/members") + @Produces(MediaType.APPLICATION_JSON) + @GET + public List getMembersValue(@PathParam("rid") String rid) { + return getRoom(rid).getMembers().getValue(); } @Path("/{rid}/members/{mno}/id") @Produces(MediaType.APPLICATION_JSON) @@ -55,17 +49,23 @@ return getRoom(rid).getMembers().getMember(mno).getId(); } @Path("/{rid}/battle") - @PUT - public void battle(@PathParam("rid") String rid, @FormParam("hasWon") boolean hasWon) throws JsonProcessingException { - getRoom(rid).battle(rid, hasWon); + @Produces(MediaType.APPLICATION_JSON) + @GET + public boolean getBattleValue(@PathParam("rid") String rid) { + return getRoom(rid).getBattle(); + } + @POST + public void createRoom(@FormParam("rid") String rid) { + this.value.put(rid,new Room(false)); } @Path("/{rid}/members") @POST public void addRoomMember(@PathParam("rid") String rid, @FormParam("id") String id) { getRoom(rid).getMembers().addRoomMember(rid, id); } - @POST - public void createRoom(@FormParam("rid") String rid) { - this.value.put(rid,new Room(false)); + @Path("/{rid}/battle") + @PUT + public void battle(@PathParam("rid") String rid, @FormParam("hasWon") boolean hasWon) throws JsonProcessingException { + getRoom(rid).battle(rid, hasWon); } } \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PUSH-first/Account.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PUSH-first/Account.java deleted file mode 100644 index c4a78ce..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PUSH-first/Account.java +++ /dev/null @@ -1,22 +0,0 @@ -import java.util.*; - -public class Account { - private Map notifications; - public Map getValue() { - Map temp_nil19 = new HashMap<>(); - temp_nil19.put("notifications",this.getNotifications()); - return temp_nil19; - } - public Map getNotifications() { - return new HashMap<>(notifications); - } - public void updateNotificationsFromMessages(String self, String gid, int mno, List messages, String member) { - this.notifications.put(gid,true); - } - public void hasRead(String aid, String gid) { - this.notifications.remove(gid); - } - public Account(Map notifications) { - this.notifications = notifications; - } -} \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PUSH-first/Accounts.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PUSH-first/Accounts.java deleted file mode 100644 index 2e7c4e3..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PUSH-first/Accounts.java +++ /dev/null @@ -1,14 +0,0 @@ -import java.util.*; - -public class Accounts { - private Map value = new HashMap<>(); - public Map getValue() { - return new HashMap<>(value); - } - public Account getAccount(String v1) { - return this.value.get(v1); - } - public void signUp(String aid) { - this.value.put(aid,new Account(new HashMap<>())); - } -} \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PUSH-first/Group.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PUSH-first/Group.java deleted file mode 100644 index 2f3c073..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PUSH-first/Group.java +++ /dev/null @@ -1,39 +0,0 @@ -import java.util.*; - -public class Group { - private List messages; - private Account account; - private Accounts accounts; - private List members; - public Map getValue() { - Map temp_nil18 = new HashMap<>(); - temp_nil18.put("members",this.getMembers()); - temp_nil18.put("messages",this.getMessages()); - return temp_nil18; - } - public List getMessages() { - return this.messages; - } - public List getMembers() { - return this.members; - } - public String getMember(int mno) { - return this.members.get(mno); - } - public void postMessage(String gid, String message) { - this.messages.add(message); - for (int mno = 0; mno < this.members.size(); mno++) { - String member = getMember(mno); - this.account = accounts.getAccount(member); - this.account.updateNotificationsFromMessages(member, gid, mno, messages, member); - } - } - public void addGroupMember(String gid, String aid) { - this.members.add(aid); - } - public Group(List messages, Accounts accounts, List members) { - this.messages = messages; - this.accounts = accounts; - this.members = members; - } -} \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PUSH-first/GroupChat.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PUSH-first/GroupChat.java deleted file mode 100644 index 6ee5abf..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PUSH-first/GroupChat.java +++ /dev/null @@ -1,49 +0,0 @@ -import java.util.*; - -public class GroupChat { - private Accounts accounts; - private Groups groups; - public GroupChat() { - accounts = new Accounts(); - groups = new Groups(accounts); - } - public Map getGroup(String gid) { - return this.groups.getGroup(gid).getValue(); - } - public Map getAccount(String v1) { - return this.accounts.getAccount(v1).getValue(); - } - public List getMessages(String gid) { - return this.groups.getGroup(gid).getMessages(); - } - public void postMessage(String gid, String message) { - this.groups.getGroup(gid).postMessage(gid, message); - } - public List getMembers(String gid) { - return this.groups.getGroup(gid).getMembers(); - } - public void addGroupMember(String gid, String aid) { - this.groups.getGroup(gid).addGroupMember(gid, aid); - } - public Map getNotifications(String v1) { - return this.accounts.getAccount(v1).getNotifications(); - } - public void hasRead(String aid, String gid) { - this.accounts.getAccount(aid).hasRead(aid, gid); - } - public String getMember(String gid, int mno) { - return this.groups.getGroup(gid).getMember(mno); - } - public Map getAccounts() { - return this.accounts.getValue(); - } - public void signUp(String aid) { - this.accounts.signUp(aid); - } - public Map getGroups() { - return this.groups.getValue(); - } - public void createGroup(String gid) { - this.groups.createGroup(gid); - } -} \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PUSH-first/Groups.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PUSH-first/Groups.java deleted file mode 100644 index ada656a..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PUSH-first/Groups.java +++ /dev/null @@ -1,18 +0,0 @@ -import java.util.*; - -public class Groups { - private Map value = new HashMap<>(); - private Accounts accounts; - public Map getValue() { - return new HashMap<>(value); - } - public Group getGroup(String gid) { - return this.value.get(gid); - } - public void createGroup(String gid) { - this.value.put(gid,new Group(new ArrayList<>(), accounts, new ArrayList<>())); - } - public Groups(Accounts accounts) { - this.accounts = accounts; - } -} \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Account.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Account.java index 26867a3..f95e5e6 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Account.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Account.java @@ -1,33 +1,33 @@ import java.util.*; public class Account { - private int point; private String name; + private int point; public Map getValue() { - Map temp_nil9 = new HashMap<>(); - temp_nil9.put("name",this.getName()); - temp_nil9.put("point",this.getPoint()); - return temp_nil9; - } - public int getPoint() { - return point; + Map temp_nil1 = new HashMap<>(); + temp_nil1.put("name",this.getName()); + temp_nil1.put("point",this.getPoint()); + return temp_nil1; } public String getName() { return this.name; } + public int getPoint() { + return point; + } public void updatePointFromBattle(String self, String rid, int mno, boolean battle, String id) { - int temp_if2; - if (hasWon) { - temp_if2 = (this.point+1); + int temp_if0; + if (battle) { + temp_if0 = (this.point+1); } else { - temp_if2 = this.point; - }this.point = temp_if2; + temp_if0 = this.point; + }this.point = temp_if0; } public void changeName(String aid, String name) { this.name = name; } - public Account(int point, String name) { - this.point = point; + public Account(String name, int point) { this.name = name; + this.point = point; } } \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Accounts.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Accounts.java index b5e61df..6d92c89 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Accounts.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Accounts.java @@ -9,6 +9,6 @@ return this.value.get(mid); } public void signUp(String name, String aid) { - this.value.put(aid,new Account(0, name)); + this.value.put(aid,new Account(name, 0)); } } \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Member.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Member.java index 33658d5..aac4c47 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Member.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Member.java @@ -5,10 +5,10 @@ private Account account; private Accounts accounts; public Map getValue() { - Map temp_nil10 = new HashMap<>(); - temp_nil10.put("id",this.getId()); - temp_nil10.put("name",this.getName()); - return temp_nil10; + Map temp_nil2 = new HashMap<>(); + temp_nil2.put("name",this.getName()); + temp_nil2.put("id",this.getId()); + return temp_nil2; } public String getId() { return this.id; diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/OnlineBattleGame2.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/OnlineBattleGame2.java index 16c3526..cc758ed 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/OnlineBattleGame2.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/OnlineBattleGame2.java @@ -7,23 +7,14 @@ accounts = new Accounts(); rooms = new Rooms(accounts); } - public Map getRoom(String rid) { - return this.rooms.getRoom(rid).getValue(); - } - public Map getMember(String rid, int mno) { - return this.rooms.getRoom(rid).getMembers().getMember(mno).getValue(); - } - public int getPoint(String mid) { - return this.accounts.getAccount(mid).getPoint(); - } public boolean getBattle(String rid) { return this.rooms.getRoom(rid).getBattle(); } public void battle(String rid, boolean hasWon) { this.rooms.getRoom(rid).battle(rid, hasWon); } - public String getId(String rid, int mno) { - return this.rooms.getRoom(rid).getMembers().getMember(mno).getId(); + public Map getRoom(String rid) { + return this.rooms.getRoom(rid).getValue(); } public String getName(String mid) { return this.accounts.getAccount(mid).getName(); @@ -31,8 +22,11 @@ public void changeName(String aid, String name) { this.accounts.getAccount(aid).changeName(aid, name); } - public String getName(String rid, int mno) { - return this.rooms.getRoom(rid).getMembers().getMember(mno).getName(); + public Map getAccounts() { + return this.accounts.getValue(); + } + public void signUp(String name, String aid) { + this.accounts.signUp(name, aid); } public List getMembers(String rid) { return this.rooms.getRoom(rid).getMembers().getValue(); @@ -40,11 +34,8 @@ public void addRoomMember(String rid, String id) { this.rooms.getRoom(rid).getMembers().addRoomMember(rid, id); } - public Map getAccounts() { - return this.accounts.getValue(); - } - public void signUp(String name, String aid) { - this.accounts.signUp(name, aid); + public int getPoint(String mid) { + return this.accounts.getAccount(mid).getPoint(); } public Map getRooms() { return this.rooms.getValue(); @@ -55,4 +46,13 @@ public Map getAccount(String mid) { return this.accounts.getAccount(mid).getValue(); } + public Map getMember(String rid, int mno) { + return this.rooms.getRoom(rid).getMembers().getMember(mno).getValue(); + } + public String getId(String rid, int mno) { + return this.rooms.getRoom(rid).getMembers().getMember(mno).getId(); + } + public String getName(String rid, int mno) { + return this.rooms.getRoom(rid).getMembers().getMember(mno).getName(); + } } \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/Account.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/Account.java deleted file mode 100644 index 9b3c0af..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/Account.java +++ /dev/null @@ -1,33 +0,0 @@ -import java.util.*; - -public class Account { - private int point; - private String name; - public Map getValue() { - Map temp_nil12 = new HashMap<>(); - temp_nil12.put("name",this.getName()); - temp_nil12.put("point",this.getPoint()); - return temp_nil12; - } - public int getPoint() { - return point; - } - public String getName() { - return this.name; - } - public void updatePointFromBattle(String self, String rid, int mno, boolean battle, String id) { - int temp_if3; - if (hasWon) { - temp_if3 = (this.point+1); - } else { - temp_if3 = this.point; - }this.point = temp_if3; - } - public void changeName(String aid, String name) { - this.name = name; - } - public Account(int point, String name) { - this.point = point; - this.name = name; - } -} \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/Accounts.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/Accounts.java deleted file mode 100644 index b5e61df..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/Accounts.java +++ /dev/null @@ -1,14 +0,0 @@ -import java.util.*; - -public class Accounts { - private Map value = new HashMap<>(); - public Map getValue() { - return new HashMap<>(value); - } - public Account getAccount(String mid) { - return this.value.get(mid); - } - public void signUp(String name, String aid) { - this.value.put(aid,new Account(0, name)); - } -} \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/Member.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/Member.java deleted file mode 100644 index b23d481..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/Member.java +++ /dev/null @@ -1,23 +0,0 @@ -import java.util.*; - -public class Member { - private String id; - private Account account; - private Accounts accounts; - public Map getValue() { - Map temp_nil13 = new HashMap<>(); - temp_nil13.put("id",this.getId()); - temp_nil13.put("name",this.getName()); - return temp_nil13; - } - public String getId() { - return this.id; - } - public String getName() { - return this.account.getName(); - } - public Member(String id, Accounts accounts) { - this.id = id; - this.accounts = accounts; - } -} \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/Members.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/Members.java deleted file mode 100644 index 091b561..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/Members.java +++ /dev/null @@ -1,14 +0,0 @@ -import java.util.*; - -public class Members { - private List value = new ArrayList<>(); - public List getValue() { - return new ArrayList<>(value); - } - public Member getMember(int mno) { - return this.value.get(mno); - } - public void addRoomMember(String rid, String id) { - this.value.add(new Member(id, accounts)); - } -} \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/OnlineBattleGame2.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/OnlineBattleGame2.java deleted file mode 100644 index 16c3526..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/OnlineBattleGame2.java +++ /dev/null @@ -1,58 +0,0 @@ -import java.util.*; - -public class OnlineBattleGame2 { - private Accounts accounts; - private Rooms rooms; - public OnlineBattleGame2() { - accounts = new Accounts(); - rooms = new Rooms(accounts); - } - public Map getRoom(String rid) { - return this.rooms.getRoom(rid).getValue(); - } - public Map getMember(String rid, int mno) { - return this.rooms.getRoom(rid).getMembers().getMember(mno).getValue(); - } - public int getPoint(String mid) { - return this.accounts.getAccount(mid).getPoint(); - } - public boolean getBattle(String rid) { - return this.rooms.getRoom(rid).getBattle(); - } - public void battle(String rid, boolean hasWon) { - this.rooms.getRoom(rid).battle(rid, hasWon); - } - public String getId(String rid, int mno) { - return this.rooms.getRoom(rid).getMembers().getMember(mno).getId(); - } - public String getName(String mid) { - return this.accounts.getAccount(mid).getName(); - } - public void changeName(String aid, String name) { - this.accounts.getAccount(aid).changeName(aid, name); - } - public String getName(String rid, int mno) { - return this.rooms.getRoom(rid).getMembers().getMember(mno).getName(); - } - public List getMembers(String rid) { - return this.rooms.getRoom(rid).getMembers().getValue(); - } - public void addRoomMember(String rid, String id) { - this.rooms.getRoom(rid).getMembers().addRoomMember(rid, id); - } - public Map getAccounts() { - return this.accounts.getValue(); - } - public void signUp(String name, String aid) { - this.accounts.signUp(name, aid); - } - public Map getRooms() { - return this.rooms.getValue(); - } - public void createRoom(String rid) { - this.rooms.createRoom(rid); - } - public Map getAccount(String mid) { - return this.accounts.getAccount(mid).getValue(); - } -} \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/Room.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/Room.java deleted file mode 100644 index 85b976f..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/Room.java +++ /dev/null @@ -1,32 +0,0 @@ -import java.util.*; - -public class Room { - private Members members = new Members(); - private boolean battle; - private Account account; - private Accounts accounts; - public Map getValue() { - Map temp_nil11 = new HashMap<>(); - temp_nil11.put("members",this.members.getValue()); - temp_nil11.put("battle",this.getBattle()); - return temp_nil11; - } - public Members getMembers() { - return this.members; - } - public boolean getBattle() { - return this.battle; - } - public void battle(String rid, boolean hasWon) { - this.battle = hasWon; - for (int mno = 0; mno < this.members.getValue().size(); mno++) { - String id = this.members.getMember(mno).getId(); - this.account = accounts.getAccount(id); - this.account.updatePointFromBattle(id, rid, mno, battle, id); - } - } - public Room(boolean battle, Accounts accounts) { - this.battle = battle; - this.accounts = accounts; - } -} \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/Rooms.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/Rooms.java deleted file mode 100644 index d4230fa..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PUSH-first/Rooms.java +++ /dev/null @@ -1,18 +0,0 @@ -import java.util.*; - -public class Rooms { - private Map value = new HashMap<>(); - private Accounts accounts; - public Map getValue() { - return new HashMap<>(value); - } - public Room getRoom(String rid) { - return this.value.get(rid); - } - public void createRoom(String rid) { - this.value.put(rid,new Room(false, accounts)); - } - public Rooms(Accounts accounts) { - this.accounts = accounts; - } -} \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Room.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Room.java index 17dc9db..43129a4 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Room.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Room.java @@ -6,10 +6,10 @@ private Account account; private Accounts accounts; public Map getValue() { - Map temp_nil8 = new HashMap<>(); - temp_nil8.put("members",this.members.getValue()); - temp_nil8.put("battle",this.getBattle()); - return temp_nil8; + Map temp_nil0 = new HashMap<>(); + temp_nil0.put("members",this.members.getValue()); + temp_nil0.put("battle",this.getBattle()); + return temp_nil0; } public Members getMembers() { return this.members; diff --git a/AlgebraicDataflowArchitectureModel/src/generators/CodeGeneratorFromDataFlowGraph.java b/AlgebraicDataflowArchitectureModel/src/generators/CodeGeneratorFromDataFlowGraph.java index dc818eb..365a1c2 100644 --- a/AlgebraicDataflowArchitectureModel/src/generators/CodeGeneratorFromDataFlowGraph.java +++ b/AlgebraicDataflowArchitectureModel/src/generators/CodeGeneratorFromDataFlowGraph.java @@ -1517,19 +1517,41 @@ if (((StoreAttribute) resourceNode.getAttribute()).isStored()) { try { if (resourceNode.getInSideResources().contains(out.getResource())) { + Term unifiedMassage = null; + for (ChannelNode srcChNode: ancestorSrcChannels) { + DataTransferChannel abcestorSrcCh = (DataTransferChannel) srcChNode.getChannel(); + Term message = abcestorSrcCh.fillOutsideResourcePaths(out, getPushAccessor(platformSpec), null).getValue(); + if (unifiedMassage == null) { + unifiedMassage = message; + } else { + unifiedMassage = (Term) unifiedMassage.unify(message); + } + } Expression updateExp = null; if (ch.getReferenceChannelMembers().size() == 0) { - updateExp = ch.deriveUpdateExpressionOf(out, getPushAccessor(platformSpec)).getKey(); + Term message = ch.fillOutsideResourcePaths(out, getPushAccessor(platformSpec), null).getValue(); + if (unifiedMassage == null) { + unifiedMassage = message; + } else { + unifiedMassage = (Term) unifiedMassage.unify(message); + } + updateExp = ch.deriveUpdateExpressionOf(out, unifiedMassage, getPushAccessor(platformSpec)); } else { // if there exists one or more reference channel member. HashMap inputResourceToStateAccessor = new HashMap<>(); for (ChannelMember in: ch.getInputChannelMembers()) { inputResourceToStateAccessor.put(in, getPushAccessor(platformSpec)); } - for (ChannelMember c: ch.getReferenceChannelMembers()) { - inputResourceToStateAccessor.put(c, getRefAccessor(platformSpec)); + for (ChannelMember ref: ch.getReferenceChannelMembers()) { + inputResourceToStateAccessor.put(ref, getRefAccessor(platformSpec)); } - updateExp = ch.deriveUpdateExpressionOf(out, getPushAccessor(platformSpec), inputResourceToStateAccessor).getKey(); + Term message = ch.fillOutsideResourcePaths(out, getPushAccessor(platformSpec), inputResourceToStateAccessor).getValue(); + if (unifiedMassage == null) { + unifiedMassage = message; + } else { + unifiedMassage = (Term) unifiedMassage.unify(message); + } + updateExp = ch.deriveUpdateExpressionOf(out, unifiedMassage, getPushAccessor(platformSpec)); } // Replace Json constructor with a constructor of the child resource. ResourceHierarchy outRes = out.getResource().getResourceHierarchy(); diff --git a/AlgebraicDataflowArchitectureModel/src/generators/JavaMethodBodyGenerator.java b/AlgebraicDataflowArchitectureModel/src/generators/JavaMethodBodyGenerator.java index 91cecdd..f220abd 100644 --- a/AlgebraicDataflowArchitectureModel/src/generators/JavaMethodBodyGenerator.java +++ b/AlgebraicDataflowArchitectureModel/src/generators/JavaMethodBodyGenerator.java @@ -119,9 +119,19 @@ } if (((StoreAttribute) dst.getAttribute()).isStored()) { // update stored state of dst side resource (when every incoming edge is in push style) + Term unifiedMassage = null; + if (directDstCh != ch) { + unifiedMassage = directDstCh.fillOutsideResourcePaths(out, JavaCodeGenerator.pushAccessor, null).getValue(); + } Expression updateExp = null; if (ch.getReferenceChannelMembers().size() == 0) { - updateExp = ch.deriveUpdateExpressionOf(out, JavaCodeGenerator.pushAccessor).getKey(); + Term message = ch.fillOutsideResourcePaths(out, JavaCodeGenerator.pushAccessor, null).getValue(); + if (unifiedMassage == null) { + unifiedMassage = message; + } else { + unifiedMassage = (Term) unifiedMassage.unify(message); + } + updateExp = ch.deriveUpdateExpressionOf(out, unifiedMassage, JavaCodeGenerator.pushAccessor); } else { // if there exists one or more reference channel member. HashMap inputResourceToStateAccessor = new HashMap<>(); @@ -131,7 +141,13 @@ for (ChannelMember c: ch.getReferenceChannelMembers()) { inputResourceToStateAccessor.put(c, JavaCodeGenerator.refAccessor); } - updateExp = ch.deriveUpdateExpressionOf(out, JavaCodeGenerator.pushAccessor, inputResourceToStateAccessor).getKey(); + Term message = ch.fillOutsideResourcePaths(out, JavaCodeGenerator.pushAccessor, inputResourceToStateAccessor).getValue(); + if (unifiedMassage == null) { + unifiedMassage = message; + } else { + unifiedMassage = (Term) unifiedMassage.unify(message); + } + updateExp = ch.deriveUpdateExpressionOf(out, unifiedMassage, JavaCodeGenerator.pushAccessor); } // Replace Json constructor with a constructor of a descendant resource. ResourceHierarchy outRes = out.getResource().getResourceHierarchy(); diff --git a/AlgebraicDataflowArchitectureModel/src/generators/JerseyMethodBodyGenerator.java b/AlgebraicDataflowArchitectureModel/src/generators/JerseyMethodBodyGenerator.java index 807cb94..cbef7e0 100644 --- a/AlgebraicDataflowArchitectureModel/src/generators/JerseyMethodBodyGenerator.java +++ b/AlgebraicDataflowArchitectureModel/src/generators/JerseyMethodBodyGenerator.java @@ -131,9 +131,19 @@ } if (((StoreAttribute) dst.getAttribute()).isStored()) { // update stored state of dst side resource (when every incoming edge is in push style) + Term unifiedMassage = null; + if (directDstCh != ch) { + unifiedMassage = directDstCh.fillOutsideResourcePaths(out, JerseyCodeGenerator.pushAccessor, null).getValue(); + } Expression updateExp = null; if (ch.getReferenceChannelMembers().size() == 0) { - updateExp = ch.deriveUpdateExpressionOf(out, JerseyCodeGenerator.pushAccessor).getKey(); + Term message = ch.fillOutsideResourcePaths(out, JerseyCodeGenerator.pushAccessor, null).getValue(); + if (unifiedMassage == null) { + unifiedMassage = message; + } else { + unifiedMassage = (Term) unifiedMassage.unify(message); + } + updateExp = ch.deriveUpdateExpressionOf(out, unifiedMassage, JerseyCodeGenerator.pushAccessor); } else { // if there exists one or more reference channel member. HashMap inputResourceToStateAccessor = new HashMap<>(); @@ -143,7 +153,13 @@ for (ChannelMember c: ch.getReferenceChannelMembers()) { inputResourceToStateAccessor.put(c, JerseyCodeGenerator.refAccessor); } - updateExp = ch.deriveUpdateExpressionOf(out, JerseyCodeGenerator.pushAccessor, inputResourceToStateAccessor).getKey(); + Term message = ch.fillOutsideResourcePaths(out, JerseyCodeGenerator.pushAccessor, inputResourceToStateAccessor).getValue(); + if (unifiedMassage == null) { + unifiedMassage = message; + } else { + unifiedMassage = (Term) unifiedMassage.unify(message); + } + updateExp = ch.deriveUpdateExpressionOf(out, unifiedMassage, JerseyCodeGenerator.pushAccessor); } // Replace Json constructor with a constructor of a descendant resource. ResourceHierarchy outRes = out.getResource().getResourceHierarchy(); diff --git a/AlgebraicDataflowArchitectureModel/src/models/dataFlowModel/DataTransferChannel.java b/AlgebraicDataflowArchitectureModel/src/models/dataFlowModel/DataTransferChannel.java index 23a6c65..6ab539a 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/dataFlowModel/DataTransferChannel.java +++ b/AlgebraicDataflowArchitectureModel/src/models/dataFlowModel/DataTransferChannel.java @@ -225,6 +225,18 @@ return deriveUpdateExpressionOf(targetMember, stateAccessor, null); } + /** + * Derive the state update calculation of the target channel member with a given resource push/pull state accessor. + * @param targetMember a channel member whose state is to be updated + * @param stateAccessor a push/pull resource state accessor + * @param inputResourceToStateAccessor push/pull resource state accessors (if null, stateAccessor is used.) + * @return the derived update calculation and the unified message + * @throws ParameterizedIdentifierIsFutureWork + * @throws ResolvingMultipleDefinitionIsFutureWork + * @throws InvalidMessage + * @throws UnificationFailed + * @throws ValueUndefined + */ public Map.Entry deriveUpdateExpressionOf(ChannelMember targetMember, IResourceStateAccessor stateAccessor, Map inputResourceToStateAccessor) throws ParameterizedIdentifierIsFutureWork, ResolvingMultipleDefinitionIsFutureWork, InvalidMessage, UnificationFailed, ValueUndefined { if (!getOutputChannelMembers().contains(targetMember)) return null; @@ -282,6 +294,18 @@ return fillOutsideResourcePaths(targetMember, stateAccessor, null).getKey(); } + /** + * Fill outside resource paths with a given resource push/pull state accessor. + * @param targetMember a channel member whose state is to be updated + * @param stateAccessor a push/pull resource state accessor + * @param inputResourceToStateAccessor push/pull resource state accessors (if null, stateAccessor is used.) + * @return map from a depending channel member to the pair of the filled resource path and the set of the depended channel members + * @throws ParameterizedIdentifierIsFutureWork + * @throws ResolvingMultipleDefinitionIsFutureWork + * @throws InvalidMessage + * @throws UnificationFailed + * @throws ValueUndefined + */ public Map.Entry>>, Term> fillOutsideResourcePaths(ChannelMember targetMember, IResourceStateAccessor stateAccessor, Map inputResourceToStateAccessor) throws ParameterizedIdentifierIsFutureWork, ResolvingMultipleDefinitionIsFutureWork, InvalidMessage, UnificationFailed, ValueUndefined { Map>> resourcePaths = new HashMap<>();