diff --git a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Account.java b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Account.java index 159f403..5f97d07 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Account.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Account.java @@ -3,14 +3,14 @@ public class Account { private Map notifications; public Map getValue() { - Map temp_nil1 = new HashMap<>(); - temp_nil1.put("notifications",this.getNotifications()); - return temp_nil1; + Map temp_nil3 = new HashMap<>(); + temp_nil3.put("notifications",this.getNotifications()); + return temp_nil3; } public Map getNotifications() { return notifications; } - public void updateNotificationsFromMessages(String self, String gid, int mno, List messages, String members) { + 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) { diff --git a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Accounts.java b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Accounts.java index 6183f07..35ef30a 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Accounts.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Accounts.java @@ -20,8 +20,8 @@ } @Path("accounts/{v1}/notifications") @POST - public void updateNotificationsFromMessages(@PathParam("v1") String v1, @FormParam("gid") String gid, @FormParam("mno") int mno, @FormParam("messages") List messages, @FormParam("members") String members) { - getAccount(v1).updateNotificationsFromMessages(m.get(mno), gid, mno, messages, members); + public void updateNotificationsFromMessages(@PathParam("v1") String v1, @FormParam("gid") String gid, @FormParam("mno") int mno, @FormParam("messages") List messages, @FormParam("member") String member) { + getAccount(v1).updateNotificationsFromMessages(v1, gid, mno, messages, member); } @Path("/{v1}") @Produces(MediaType.APPLICATION_JSON) @@ -29,11 +29,11 @@ public Map getAccountValue(@PathParam("v1") String v1) { return getAccount(v1).getValue(); } - @Path("/{v1}/notifications") + @Path("/{aid}/notifications") @Produces(MediaType.APPLICATION_JSON) @GET - public Map getNotificationsValue(@PathParam("v1") String v1) { - return getAccount(v1).getNotifications(); + public Map getNotificationsValue(@PathParam("aid") String aid) { + return getAccount(aid).getNotifications(); } @Path("/{aid}/notifications") @DELETE diff --git a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Group.java b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Group.java index 08338b0..3579e08 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Group.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Group.java @@ -3,22 +3,22 @@ public class Group { private List members; - private Client client = ClientBuilder.newClient(); private List messages; + private Client client = ClientBuilder.newClient(); public Map getValue() { - Map temp_nil0 = new HashMap<>(); - temp_nil0.put("messages",this.getMessages()); - temp_nil0.put("members",this.getMembers()); - return temp_nil0; + Map temp_nil2 = new HashMap<>(); + temp_nil2.put("messages",this.getMessages()); + temp_nil2.put("members",this.getMembers()); + return temp_nil2; } - public List getMessages() { - return this.messages; + public String getMember(int mno) { + return this.members.get(mno); } public List getMembers() { return this.members; } - public String getMember(int mno) { - return this.members.get(mno); + public List getMessages() { + return this.messages; } public void postMessage(String gid, String message) throws JsonProcessingException { for (int mno = 0; mno < members.size(); mno++) { diff --git a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Groups.java b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Groups.java index cc91714..e00259d 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Groups.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Groups.java @@ -18,11 +18,11 @@ public Group getGroup(String gid) { return this.value.get(gid); } - @Path("/{gid}") + @Path("/{gid}/members/{mno}") @Produces(MediaType.APPLICATION_JSON) @GET - public Map getGroupValue(@PathParam("gid") String gid) { - return getGroup(gid).getValue(); + public String getMemberValue(@PathParam("gid") String gid, @PathParam("mno") int mno) { + return getGroup(gid).getMember(mno); } @Path("/{gid}/messages") @Produces(MediaType.APPLICATION_JSON) @@ -30,11 +30,11 @@ public List getMessagesValue(@PathParam("gid") String gid) { return getGroup(gid).getMessages(); } - @Path("/{gid}/members/{mno}") + @Path("/{gid}") @Produces(MediaType.APPLICATION_JSON) @GET - public String getMemberValue(@PathParam("gid") String gid, @PathParam("mno") int mno) { - return getGroup(gid).getMember(mno); + public Map getGroupValue(@PathParam("gid") String gid) { + return getGroup(gid).getValue(); } @Path("/{gid}/members") @Produces(MediaType.APPLICATION_JSON) @@ -42,15 +42,15 @@ public List getMembersValue(@PathParam("gid") String gid) { return getGroup(gid).getMembers(); } - @POST - public void createGroup(@FormParam("gid") String gid) { - this.value.put(gid,new Group(new ArrayList<>(), new ArrayList<>())); - } @Path("/{gid}/messages") @POST public void postMessage(@PathParam("gid") String gid, @FormParam("message") String message) throws JsonProcessingException { getGroup(gid).postMessage(gid, message); } + @POST + public void createGroup(@FormParam("gid") String gid) { + this.value.put(gid,new Group(new ArrayList<>(), new ArrayList<>())); + } @Path("/{gid}/members") @POST public void addGroupMember(@PathParam("gid") String gid, @FormParam("aid") String aid) { diff --git a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Account.java b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Account.java index ff5dda3..e5c60de 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Account.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Account.java @@ -1,28 +1,27 @@ import java.util.*; public class Account { - private String name; private int point; + private String name; public Map getValue() { - Map temp_nil9 = new HashMap<>(); - temp_nil9.put("point",this.getPoint()); - temp_nil9.put("name",this.getName()); - return temp_nil9; - } - public String getName() { - return this.name; + Map temp_nil5 = new HashMap<>(); + temp_nil5.put("point",this.getPoint()); + temp_nil5.put("name",this.getName()); + return temp_nil5; } 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_if0; if (hasWon) { temp_if0 = (this.point+1); } else { temp_if0 = this.point; - } - this.point = temp_if0; + }this.point = temp_if0; } 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 0e9528b..3282fe9 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Accounts.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Accounts.java @@ -23,31 +23,31 @@ 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}") - @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}") + @Produces(MediaType.APPLICATION_JSON) + @GET + public Map getAccountValue(@PathParam("mid") String mid) { + return getAccount(mid).getValue(); + } @Path("/{mid}/name") @Produces(MediaType.APPLICATION_JSON) @GET public String getNameValue(@PathParam("mid") String mid) { return getAccount(mid).getName(); } - @POST - public void signUp(@FormParam("name") String name, @FormParam("aid") String aid) { - this.value.put(aid,new Account(name, 0)); - } @Path("/{aid}/name") @PUT public void changeName(@PathParam("aid") String aid, @FormParam("name") String name) { getAccount(aid).changeName(aid, name); } + @POST + public void signUp(@FormParam("name") String name, @FormParam("aid") String aid) { + this.value.put(aid,new Account(name, 0)); + } } \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Member.java b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Member.java index f721703..8482dd2 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Member.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Member.java @@ -2,21 +2,21 @@ import javax.ws.rs.client.*; public class Member { - private Client client = ClientBuilder.newClient(); private String id; + private Client client = ClientBuilder.newClient(); public Map getValue() { - Map temp_nil10 = new HashMap<>(); - temp_nil10.put("name",this.getName()); - temp_nil10.put("id",this.getId()); - return temp_nil10; + Map temp_nil6 = new HashMap<>(); + temp_nil6.put("name",this.getName()); + temp_nil6.put("id",this.getId()); + return temp_nil6; + } + public String getId() { + return this.id; } public String getName() { String name = client.target("http://localhost:8080").path("/accounts."+id+".name").request().get(String.class); return name; } - public String getId() { - return this.id; - } public Member(String id) { this.id = id; } diff --git a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Room.java b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Room.java index 581174c..85e576f 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_nil8 = new HashMap<>(); - temp_nil8.put("members",this.members.getValue()); - temp_nil8.put("battle",this.getBattle()); - return temp_nil8; + Map temp_nil4 = new HashMap<>(); + temp_nil4.put("battle",this.getBattle()); + temp_nil4.put("members",this.members.getValue()); + return temp_nil4; } 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 8e0cde3..42789df 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Rooms.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Rooms.java @@ -18,54 +18,54 @@ public Room getRoom(String rid) { return this.value.get(rid); } - @Path("/{rid}/members/{mno}/name") - @Produces(MediaType.APPLICATION_JSON) - @GET - 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) - @GET - public Map getMemberValue(@PathParam("rid") String rid, @PathParam("mno") int mno) { - return getRoom(rid).getMembers().getMember(mno).getValue(); - } - @Path("/{rid}/members/{mno}/id") - @Produces(MediaType.APPLICATION_JSON) - @GET - public String getIdValue(@PathParam("rid") String rid, @PathParam("mno") int mno) { - return getRoom(rid).getMembers().getMember(mno).getId(); - } @Path("/{rid}") @Produces(MediaType.APPLICATION_JSON) @GET 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}/battle") @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") + @Produces(MediaType.APPLICATION_JSON) + @GET + public List getMembersValue(@PathParam("rid") String rid) { + return getRoom(rid).getMembers().getValue(); + } + @Path("/{rid}/members/{mno}") + @Produces(MediaType.APPLICATION_JSON) + @GET + public Map getMemberValue(@PathParam("rid") String rid, @PathParam("mno") int mno) { + return getRoom(rid).getMembers().getMember(mno).getValue(); + } + @Path("/{rid}/members/{mno}/name") + @Produces(MediaType.APPLICATION_JSON) + @GET + public String getNameValue(@PathParam("rid") String rid, @PathParam("mno") int mno) { + return getRoom(rid).getMembers().getMember(mno).getName(); + } + @Path("/{rid}/members/{mno}/id") + @Produces(MediaType.APPLICATION_JSON) + @GET + public String getIdValue(@PathParam("rid") String rid, @PathParam("mno") int mno) { + 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); } @Path("/{rid}/members") @POST public void addRoomMember(@PathParam("rid") String rid, @FormParam("id") String id) { getRoom(rid).getMembers().addRoomMember(rid, id); } - @Path("/{rid}/battle") - @PUT - public void battle(@PathParam("rid") String rid, @FormParam("hasWon") boolean hasWon) throws JsonProcessingException { - getRoom(rid).battle(rid, hasWon); + @POST + public void createRoom(@FormParam("rid") String rid) { + this.value.put(rid,new Room(false)); } } \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/Account.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/Account.java new file mode 100644 index 0000000..10f53f1 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/Account.java @@ -0,0 +1,22 @@ +import java.util.*; + +public class Account { + private Map notifications; + public Map getValue() { + Map temp_nil17 = new HashMap<>(); + temp_nil17.put("notifications",this.getNotifications()); + return temp_nil17; + } + 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/Accounts.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/Accounts.java new file mode 100644 index 0000000..2e7c4e3 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/Accounts.java @@ -0,0 +1,14 @@ +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/Group.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/Group.java new file mode 100644 index 0000000..faa7d19 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/Group.java @@ -0,0 +1,39 @@ +import java.util.*; + +public class Group { + private List messages; + private Account account; + private Accounts accounts; + private List members; + public Map getValue() { + Map temp_nil16 = new HashMap<>(); + temp_nil16.put("members",this.getMembers()); + temp_nil16.put("messages",this.getMessages()); + return temp_nil16; + } + 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/GroupChat.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/GroupChat.java new file mode 100644 index 0000000..6ee5abf --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/GroupChat.java @@ -0,0 +1,49 @@ +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/Groups.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/Groups.java new file mode 100644 index 0000000..ada656a --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/Groups.java @@ -0,0 +1,18 @@ +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/GroupChat/PULL-first/Account.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PULL-first/Account.java deleted file mode 100644 index 10f53f1..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PULL-first/Account.java +++ /dev/null @@ -1,22 +0,0 @@ -import java.util.*; - -public class Account { - private Map notifications; - public Map getValue() { - Map temp_nil17 = new HashMap<>(); - temp_nil17.put("notifications",this.getNotifications()); - return temp_nil17; - } - 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/PULL-first/Accounts.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PULL-first/Accounts.java deleted file mode 100644 index 2e7c4e3..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PULL-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/PULL-first/Group.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PULL-first/Group.java deleted file mode 100644 index faa7d19..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PULL-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_nil16 = new HashMap<>(); - temp_nil16.put("members",this.getMembers()); - temp_nil16.put("messages",this.getMessages()); - return temp_nil16; - } - 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/PULL-first/GroupChat.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PULL-first/GroupChat.java deleted file mode 100644 index 6ee5abf..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PULL-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/PULL-first/Groups.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PULL-first/Groups.java deleted file mode 100644 index ada656a..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/GroupChat/PULL-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 new file mode 100644 index 0000000..26867a3 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Account.java @@ -0,0 +1,33 @@ +import java.util.*; + +public class Account { + private int point; + private String name; + 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; + } + public String getName() { + return this.name; + } + public void updatePointFromBattle(String self, String rid, int mno, boolean battle, String id) { + int temp_if2; + if (hasWon) { + temp_if2 = (this.point+1); + } else { + temp_if2 = this.point; + }this.point = temp_if2; + } + 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/Accounts.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Accounts.java new file mode 100644 index 0000000..b5e61df --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Accounts.java @@ -0,0 +1,14 @@ +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/Member.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Member.java new file mode 100644 index 0000000..33658d5 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Member.java @@ -0,0 +1,23 @@ +import java.util.*; + +public class Member { + private String id; + 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; + } + 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/Members.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Members.java new file mode 100644 index 0000000..091b561 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Members.java @@ -0,0 +1,14 @@ +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/OnlineBattleGame2.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/OnlineBattleGame2.java new file mode 100644 index 0000000..16c3526 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/OnlineBattleGame2.java @@ -0,0 +1,58 @@ +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/PULL-first/Account.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PULL-first/Account.java deleted file mode 100644 index 26867a3..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PULL-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_nil9 = new HashMap<>(); - temp_nil9.put("name",this.getName()); - temp_nil9.put("point",this.getPoint()); - return temp_nil9; - } - 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_if2; - if (hasWon) { - temp_if2 = (this.point+1); - } else { - temp_if2 = this.point; - }this.point = temp_if2; - } - 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/PULL-first/Accounts.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PULL-first/Accounts.java deleted file mode 100644 index b5e61df..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PULL-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/PULL-first/Member.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PULL-first/Member.java deleted file mode 100644 index 33658d5..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PULL-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_nil10 = new HashMap<>(); - temp_nil10.put("id",this.getId()); - temp_nil10.put("name",this.getName()); - return temp_nil10; - } - 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/PULL-first/Members.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PULL-first/Members.java deleted file mode 100644 index 091b561..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PULL-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/PULL-first/OnlineBattleGame2.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PULL-first/OnlineBattleGame2.java deleted file mode 100644 index 16c3526..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PULL-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/PULL-first/Room.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PULL-first/Room.java deleted file mode 100644 index 17dc9db..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PULL-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_nil8 = new HashMap<>(); - temp_nil8.put("members",this.members.getValue()); - temp_nil8.put("battle",this.getBattle()); - return temp_nil8; - } - 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/PULL-first/Rooms.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PULL-first/Rooms.java deleted file mode 100644 index d4230fa..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/PULL-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 new file mode 100644 index 0000000..17dc9db --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Room.java @@ -0,0 +1,32 @@ +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_nil8 = new HashMap<>(); + temp_nil8.put("members",this.members.getValue()); + temp_nil8.put("battle",this.getBattle()); + return temp_nil8; + } + 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/Rooms.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Rooms.java new file mode 100644 index 0000000..d4230fa --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/prototypes/Java/OnlineBattleGame2/Rooms.java @@ -0,0 +1,18 @@ +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/src/generators/JerseyMethodBodyGenerator.java b/AlgebraicDataflowArchitectureModel/src/generators/JerseyMethodBodyGenerator.java index 4432e40..807cb94 100644 --- a/AlgebraicDataflowArchitectureModel/src/generators/JerseyMethodBodyGenerator.java +++ b/AlgebraicDataflowArchitectureModel/src/generators/JerseyMethodBodyGenerator.java @@ -312,9 +312,19 @@ resExp = ((Term) resExp).getChild(0); } String resourceAccess = resExp.toImplementation(new String[] {""}); + int v = 0; for (VariableDeclaration var: update2.getParameters()) { - args += delimiter + var.getName(); + if (v < out.getResource().getPathParams().size()) { + if (out.getResource().getPathParams().get(v) instanceof Variable) { + args += delimiter + ((Variable) out.getResource().getPathParams().get(v)).getName(); + } else if (out.getResource().getPathParams().get(v) instanceof Term) { + args += delimiter + "v" + (v + 1); + } + } else { + args += delimiter + var.getName(); + } delimiter = ", "; + v++; } update.addStatement(resourceAccess + "." + update2.getName() + "(" + args + ");"); } diff --git a/AlgebraicDataflowArchitectureModel/src/tests/JavaCodeGeneratorTest.java b/AlgebraicDataflowArchitectureModel/src/tests/JavaCodeGeneratorTest.java index dd02f23..8128ce4 100644 --- a/AlgebraicDataflowArchitectureModel/src/tests/JavaCodeGeneratorTest.java +++ b/AlgebraicDataflowArchitectureModel/src/tests/JavaCodeGeneratorTest.java @@ -387,8 +387,7 @@ private void testGroupChat() { try { - // check PULL-first - ArrayList generatedCode = generateCode("models/GroupChat.model", PushPullValue.PULL); + ArrayList generatedCode = generateCode("models/GroupChat.model", null); Map, // field name to type Map", - Map.entry(List.of("String"), - 1))), - Map.entry("addGroupMember", Map.entry("void", - Map.entry(List.of("String","String"), - 1))), - Map.entry("getMessages", Map.entry("List", - Map.entry(List.of("String"), - 1))), - Map.entry("postMessage", Map.entry("void", - Map.entry(List.of("String","String"), - 1))), - Map.entry("getMember", Map.entry("String", - Map.entry(List.of("String","int"), - 1))), - Map.entry("getNotifications", Map.entry("Map", - Map.entry(List.of("String"), - 1))), - Map.entry("hasRead", Map.entry("void", - Map.entry(List.of("String","String"), - 1))), - Map.entry("getGroup", Map.entry("Map", - Map.entry(List.of("String"), - 1))), - Map.entry("getAccounts", Map.entry("Map", - Map.entry(List.of(), - 1))), - Map.entry("signUp", Map.entry("void", - Map.entry(List.of("String"), - 1))), - Map.entry("getAccount", Map.entry("Map", - Map.entry(List.of("String"), - 1))), - Map.entry("getGroups", Map.entry("Map", - Map.entry(List.of(), - 1))), - Map.entry("createGroup", Map.entry("void", - Map.entry(List.of("String"), - 1)))))); - exprectedStructure.put("Group", Map.entry(Map.ofEntries(Map.entry("members", "List"), - Map.entry("messages", "List"), - Map.entry("account", "Account"), - Map.entry("accounts", "Accounts")), - Map.ofEntries(Map.entry("getValue", Map.entry("Map", - Map.entry(List.of(), - 1))), - Map.entry("getMembers", Map.entry("List", - Map.entry(List.of(), - 1))), - Map.entry("getMessages", Map.entry("List", - Map.entry(List.of(), - 1))), - Map.entry("getMember", Map.entry("String", - Map.entry(List.of("int"), - 1))), - Map.entry("postMessage", Map.entry("void", - Map.entry(List.of("String","String"), - 6))), - Map.entry("addGroupMember", Map.entry("void", - Map.entry(List.of("String","String"), - 1))), - Map.entry("Group", Map.entry("void", - Map.entry(List.of("List","List","Accounts"), - 3)))))); - exprectedStructure.put("Accounts", Map.entry(Map.ofEntries(), - Map.ofEntries(Map.entry("getValue", Map.entry("Map", - Map.entry(List.of(), - 1))), - Map.entry("getAccount", Map.entry("Account", - Map.entry(List.of("String"), - 1))), - Map.entry("signUp", Map.entry("void", - Map.entry(List.of("String"), - 1)))))); - exprectedStructure.put("Account", Map.entry(Map.ofEntries(), - Map.ofEntries(Map.entry("getValue", Map.entry("Map", - Map.entry(List.of(), - 1))), - Map.entry("getNotifications", Map.entry("Map", - Map.entry(List.of(), - 1))), - Map.entry("updateNotificationsFromMessages", Map.entry("void", - Map.entry(List.of("String","String","int","List","String"), - 1))), - Map.entry("hasRead", Map.entry("void", - Map.entry(List.of("String","String"), - 1))), - Map.entry("Account", Map.entry("void", - Map.entry(List.of("Map"), - 1)))))); - exprectedStructure.put("Groups", Map.entry(Map.ofEntries(Map.entry("value", "Map"), - Map.entry("accounts", "Accounts")), - Map.ofEntries(Map.entry("getValue", Map.entry("Map", - Map.entry(List.of(), - 1))), - Map.entry("getGroup", Map.entry("Group", - Map.entry(List.of("String"), - 1))), - Map.entry("createGroup", Map.entry("void", - Map.entry(List.of("String"), - 1))), - Map.entry("Groups", Map.entry("void", - Map.entry(List.of("Accounts"), - 1)))))); - - checkStructure(generatedCode, exprectedStructure); -// generateCheckCode(generatedCode); } catch (FileNotFoundException | ExpectedChannel | ExpectedChannelName | ExpectedLeftCurlyBracket | ExpectedInOrOutOrRefOrSubKeyword | ExpectedStateTransition | ExpectedEquals | ExpectedRHSExpression | WrongLHSExpression @@ -960,8 +843,7 @@ private void testOnlineBattleGame2() { try { - // check PULL-first - ArrayList generatedCode = generateCode("models/OnlineBattleGame2.model", PushPullValue.PULL); + ArrayList generatedCode = generateCode("models/OnlineBattleGame2.model", null); Map, // field name to type Map", -// Map.entry(List.of("String"), -// 1))), -// Map.entry("addRoomMember", Map.entry("void", -// Map.entry(List.of("String","String"), -// 1))), -// Map.entry("getRoom", Map.entry("Map", -// Map.entry(List.of("String"), -// 1))), -// Map.entry("getBattle", Map.entry("boolean", -// Map.entry(List.of("String"), -// 1))), -// Map.entry("battle", Map.entry("void", -// Map.entry(List.of("String","boolean"), -// 1))), -// Map.entry("getName", Map.entry("String", -// Map.entry(List.of("String","int"), -// 1))), -// Map.entry("getId", Map.entry("String", -// Map.entry(List.of("String","int"), -// 1))), -// Map.entry("getAccount", Map.entry("Map", -// Map.entry(List.of("String"), -// 1))), -// Map.entry("getPoint", Map.entry("int", -// Map.entry(List.of("String"), -// 1))), -// Map.entry("getAccounts", Map.entry("Map", -// Map.entry(List.of(), -// 1))), -// Map.entry("signUp", Map.entry("void", -// Map.entry(List.of("String","String"), -// 1))), -// Map.entry("getRooms", Map.entry("Map", -// Map.entry(List.of(), -// 1))), -// Map.entry("createRoom", Map.entry("void", -// Map.entry(List.of("String"), -// 1))), -// Map.entry("getMember", Map.entry("Map", -// Map.entry(List.of("String","int"), -// 1))), -//// Map.entry("getName", Map.entry("String", -//// Map.entry(List.of("String"), -//// 1))), -// Map.entry("changeName", Map.entry("void", -// Map.entry(List.of("String","String"), -// 1)))))); -// exprectedStructure.put("Members", Map.entry(Map.ofEntries(), -// Map.ofEntries(Map.entry("getValue", Map.entry("List", -// Map.entry(List.of(), -// 1))), -// Map.entry("getMember", Map.entry("Member", -// Map.entry(List.of("int"), -// 1))), -// Map.entry("addRoomMember", Map.entry("void", -// Map.entry(List.of("String","String"), -// 1)))))); -// exprectedStructure.put("Room", Map.entry(Map.ofEntries(Map.entry("members", "Members"), -// Map.entry("battle", "boolean"), -// Map.entry("account", "Account"), -// Map.entry("accounts", "Accounts")), -// Map.ofEntries(Map.entry("getValue", Map.entry("Map", -// Map.entry(List.of(), -// 1))), -// Map.entry("getMembers", Map.entry("Members", -// Map.entry(List.of(), -// 1))), -// Map.entry("getBattle", Map.entry("boolean", -// Map.entry(List.of(), -// 1))), -// Map.entry("battle", Map.entry("void", -// Map.entry(List.of("String","boolean"), -// 6))), -// Map.entry("Room", Map.entry("void", -// Map.entry(List.of("boolean","Accounts"), -// 2)))))); -// exprectedStructure.put("Account", Map.entry(Map.ofEntries(Map.entry("point", "int"), -// Map.entry("name", "String")), -// Map.ofEntries(Map.entry("getValue", Map.entry("Map", -// Map.entry(List.of(), -// 1))), -// Map.entry("getPoint", Map.entry("int", -// Map.entry(List.of(), -// 1))), -// Map.entry("getName", Map.entry("String", -// Map.entry(List.of(), -// 1))), -// Map.entry("updatePointFromBattle", Map.entry("void", -// Map.entry(List.of("String","String","int","boolean","String"), -// 1))), -// Map.entry("changeName", Map.entry("void", -// Map.entry(List.of("String","String"), -// 1))), -// Map.entry("Account", Map.entry("void", -// Map.entry(List.of("int","String"), -// 2)))))); -// exprectedStructure.put("Accounts", Map.entry(Map.ofEntries(), -// Map.ofEntries(Map.entry("getValue", Map.entry("Map", -// Map.entry(List.of(), -// 1))), -// Map.entry("getAccount", Map.entry("Account", -// Map.entry(List.of("String"), -// 1))), -// Map.entry("signUp", Map.entry("void", -// Map.entry(List.of("String","String"), -// 1)))))); -// exprectedStructure.put("Rooms", Map.entry(Map.ofEntries(Map.entry("value", "Map"), -// Map.entry("accounts", "Accounts")), -// Map.ofEntries(Map.entry("getValue", Map.entry("Map", -// Map.entry(List.of(), -// 1))), -// Map.entry("getRoom", Map.entry("Room", -// Map.entry(List.of("String"), -// 1))), -// Map.entry("createRoom", Map.entry("void", -// Map.entry(List.of("String"), -// 1))), -// Map.entry("Rooms", Map.entry("void", -// Map.entry(List.of("Accounts"), -// 1)))))); -// exprectedStructure.put("Member", Map.entry(Map.ofEntries(Map.entry("account", "Account"), -// Map.entry("accounts", "Accounts"), -// Map.entry("id", "String")), -// Map.ofEntries(Map.entry("getValue", Map.entry("Map", -// Map.entry(List.of(), -// 1))), -// Map.entry("getName", Map.entry("String", -// Map.entry(List.of(), -// 1))), -// Map.entry("getId", Map.entry("String", -// Map.entry(List.of(), -// 1))), -// Map.entry("updateNameFromId", Map.entry("void", -// Map.entry(List.of("String","int","String","int","String"), -// 2))), -// Map.entry("Member", Map.entry("void", -// Map.entry(List.of("Accounts","String"), -// 2)))))); -// -// checkStructure(generatedCode, exprectedStructure); -//// generateCheckCode(generatedCode); } catch (FileNotFoundException | ExpectedChannel | ExpectedChannelName | ExpectedLeftCurlyBracket | ExpectedInOrOutOrRefOrSubKeyword | ExpectedStateTransition | ExpectedEquals | ExpectedRHSExpression | WrongLHSExpression @@ -1707,8 +1438,8 @@ } TypeInference.infer(model); DataTransferMethodAnalyzer.decideToStoreResourceStates(graph); - ArrayList codetree = JavaMethodBodyGenerator.doGenerate(graph, model, JavaCodeGenerator.doGenerate(graph, model)); -// ArrayList codetree = new CodeGeneratorFromDataFlowGraph().generateCode(model, graph, new StandaloneSpecific(), new JavaSpecific()); +// ArrayList codetree = JavaMethodBodyGenerator.doGenerate(graph, model, JavaCodeGenerator.doGenerate(graph, model)); + ArrayList codetree = new CodeGeneratorFromDataFlowGraph().generateCode(model, graph, new StandaloneSpecific(), new JavaSpecific()); return codetree; }