diff --git a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Accounts.java b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Accounts.java index 35ef30a..c18d220 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Accounts.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Accounts.java @@ -35,13 +35,13 @@ public Map getNotificationsValue(@PathParam("aid") String aid) { return getAccount(aid).getNotifications(); } + @POST + public void signUp(@FormParam("aid") String aid) { + this.value.put(aid,new Account(new HashMap<>())); + } @Path("/{aid}/notifications") @DELETE public void hasRead(@PathParam("aid") String aid, @FormParam("gid") String gid) { getAccount(aid).hasRead(aid, gid); } - @POST - public void signUp(@FormParam("aid") String aid) { - this.value.put(aid,new Account(new HashMap<>())); - } } \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Group.java b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Group.java index 3579e08..bb06954 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Group.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Group.java @@ -7,16 +7,16 @@ private Client client = ClientBuilder.newClient(); public Map getValue() { Map temp_nil2 = new HashMap<>(); - temp_nil2.put("messages",this.getMessages()); temp_nil2.put("members",this.getMembers()); + temp_nil2.put("messages",this.getMessages()); return temp_nil2; } - 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; } @@ -31,7 +31,7 @@ } form.param("member", member.toString()); Entity
entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); - String result = client.target("http://localhost:8080").path("/accounts."+member+".notifications").request().post(entity, String.class); + String result = client.target("http://localhost:8080").path("/accounts/"+member+"/notifications").request().post(entity, String.class); } this.messages.add(message); } diff --git a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Groups.java b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Groups.java index e00259d..19b1f42 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Groups.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/GroupChat/Groups.java @@ -18,18 +18,6 @@ public Group getGroup(String gid) { return this.value.get(gid); } - @Path("/{gid}/members/{mno}") - @Produces(MediaType.APPLICATION_JSON) - @GET - public String getMemberValue(@PathParam("gid") String gid, @PathParam("mno") int mno) { - return getGroup(gid).getMember(mno); - } - @Path("/{gid}/messages") - @Produces(MediaType.APPLICATION_JSON) - @GET - public List getMessagesValue(@PathParam("gid") String gid) { - return getGroup(gid).getMessages(); - } @Path("/{gid}") @Produces(MediaType.APPLICATION_JSON) @GET @@ -43,6 +31,23 @@ return getGroup(gid).getMembers(); } @Path("/{gid}/messages") + @Produces(MediaType.APPLICATION_JSON) + @GET + public List getMessagesValue(@PathParam("gid") String gid) { + return getGroup(gid).getMessages(); + } + @Path("/{gid}/members/{mno}") + @Produces(MediaType.APPLICATION_JSON) + @GET + public String getMemberValue(@PathParam("gid") String gid, @PathParam("mno") int mno) { + return getGroup(gid).getMember(mno); + } + @Path("/{gid}/members") + @POST + public void addGroupMember(@PathParam("gid") String gid, @FormParam("aid") String aid) { + getGroup(gid).addGroupMember(gid, aid); + } + @Path("/{gid}/messages") @POST public void postMessage(@PathParam("gid") String gid, @FormParam("message") String message) throws JsonProcessingException { getGroup(gid).postMessage(gid, message); @@ -51,9 +56,4 @@ 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) { - getGroup(gid).addGroupMember(gid, aid); - } } \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Account.java b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Account.java index f7594e2..31bc4bd 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Account.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Account.java @@ -1,27 +1,27 @@ import java.util.*; public class Account { - private int point; private String name; + private int point; public Map getValue() { - 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; + Map temp_nil5 = new HashMap<>(); + temp_nil5.put("point",this.getPoint()); + temp_nil5.put("name",this.getName()); + return temp_nil5; } 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_if1; + int temp_if0; if (battle) { - temp_if1 = (this.point+1); + temp_if0 = (this.point+1); } else { - temp_if1 = this.point; - }this.point = temp_if1; + temp_if0 = this.point; + }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 9ec4085..fc4d20e 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 e566317..d12c2cf 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Member.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Member.java @@ -5,16 +5,16 @@ private String id; private Client client = ClientBuilder.newClient(); public Map getValue() { - Map temp_nil5 = new HashMap<>(); - temp_nil5.put("name",this.getName()); - temp_nil5.put("id",this.getId()); - return temp_nil5; + Map temp_nil6 = new HashMap<>(); + temp_nil6.put("id",this.getId()); + temp_nil6.put("name",this.getName()); + 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); + String name = client.target("http://localhost:8080").path("/accounts/"+id+"/name").request().get(String.class); return name; } public Member(String id) { diff --git a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Room.java b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Room.java index 55dce69..edbdd93 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_nil3 = new HashMap<>(); - temp_nil3.put("members",this.members.getValue()); - temp_nil3.put("battle",this.getBattle()); - return temp_nil3; + 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; @@ -26,7 +26,7 @@ form.param("battle", Boolean.toString(battle)); form.param("id", id.toString()); Entity entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); - String result = client.target("http://localhost:8080").path("/accounts."+id+".point").request().post(entity, String.class); + String result = client.target("http://localhost:8080").path("/accounts/"+id+"/point").request().post(entity, String.class); } this.battle = hasWon; } diff --git a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Rooms.java b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/OnlineBattleGame2/Rooms.java index c0b7951..818eebd 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}") @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}/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}/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}/battle") @Produces(MediaType.APPLICATION_JSON) @GET public boolean getBattleValue(@PathParam("rid") String rid) { return getRoom(rid).getBattle(); } + @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") + @Produces(MediaType.APPLICATION_JSON) + @GET + public List getMembersValue(@PathParam("rid") String rid) { + return getRoom(rid).getMembers().getValue(); + } @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); - } @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); + } } \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/VotingSystem/Account.java b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/VotingSystem/Account.java index fce3635..5bdc922 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/VotingSystem/Account.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/VotingSystem/Account.java @@ -3,9 +3,9 @@ public class Account { private String vote; public Map getValue() { - Map temp_nil0 = new HashMap<>(); - temp_nil0.put("vote",this.getVote()); - return temp_nil0; + Map temp_nil7 = new HashMap<>(); + temp_nil7.put("vote",this.getVote()); + return temp_nil7; } public String getVote() { return this.vote; diff --git a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/VotingSystem/Counts.java b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/VotingSystem/Counts.java index 9baed06..06026ed 100644 --- a/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/VotingSystem/Counts.java +++ b/AlgebraicDataflowArchitectureModel/prototypes/JAX-RS/VotingSystem/Counts.java @@ -19,7 +19,7 @@ Map> accounts = new HashMap<>(); accounts = accounts_json; for (String aid: accounts.keySet()) { - String vote = client.target("http://localhost:8080").path("/accounts."+aid+".vote").request().get(String.class); + String vote = client.target("http://localhost:8080").path("/accounts/"+aid+"/vote").request().get(String.class); v0.put(aid,vote); } return v0; diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/CustomerManagement/PUSH-first/Companies.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/CustomerManagement/PUSH-first/Companies.java deleted file mode 100644 index 148543f..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/CustomerManagement/PUSH-first/Companies.java +++ /dev/null @@ -1,14 +0,0 @@ -import java.util.*; - -public class Companies { - private Map value = new HashMap<>(); - public Map getValue() { - return new HashMap<>(value); - } - public Company getCompany(String cid) { - return this.value.get(cid); - } - public void addCampany(String address, String cid) { - this.value.put(cid,new Company(address)); - } -} \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/CustomerManagement/PUSH-first/Company.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/CustomerManagement/PUSH-first/Company.java deleted file mode 100644 index 518a8f0..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/CustomerManagement/PUSH-first/Company.java +++ /dev/null @@ -1,19 +0,0 @@ -import java.util.*; - -public class Company { - private String address; - public Map getValue() { - Map temp_nil8 = new HashMap<>(); - temp_nil8.put("address",this.getAddress()); - return temp_nil8; - } - public String getAddress() { - return this.address; - } - public void setAddress(String cid, String add) { - this.address = add; - } - public Company(String address) { - this.address = address; - } -} \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/CustomerManagement/PUSH-first/Customer.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/CustomerManagement/PUSH-first/Customer.java deleted file mode 100644 index 1279f8c..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/CustomerManagement/PUSH-first/Customer.java +++ /dev/null @@ -1,33 +0,0 @@ -import java.util.*; - -public class Customer { - private Company company; - private Companies companies; - private String organization; - public Map getValue() { - Map temp_nil9 = new HashMap<>(); - temp_nil9.put("organization",this.getOrganization()); - temp_nil9.put("address",this.getAddress()); - return temp_nil9; - } - public String getAddress() { - return address; - } - public String getOrganization() { - return this.organization; - } - public void updateAddressFromOrganization(String self, String uid, String organization) { - this.address = address; - this.organization = organization; - } - public void setOrganization(String uid, String cid) { - this.organization = cid; - this.company = this.companies.getCompany(this.organization); - this.updateAddressFromOrganization(uid, uid, organization); - } - public Customer(Companies companies, String organization) { - this.companies = companies; - this.organization = organization; - this.company = this.companies.getCompany(this.organization); - } -} \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/CustomerManagement/PUSH-first/CustomerManagement.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/CustomerManagement/PUSH-first/CustomerManagement.java deleted file mode 100644 index 6a2e752..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/CustomerManagement/PUSH-first/CustomerManagement.java +++ /dev/null @@ -1,43 +0,0 @@ -import java.util.*; - -public class CustomerManagement { - private Companies companies; - private Customers customers; - public CustomerManagement() { - companies = new Companies(); - customers = new Customers(companies); - } - public String getAddress(String uid) { - return this.customers.getCustomer(uid).getAddress(); - } - public Map getCustomer(String uid) { - return this.customers.getCustomer(uid).getValue(); - } - public String getOrganization(String uid) { - return this.customers.getCustomer(uid).getOrganization(); - } - public void setOrganization(String uid, String cid) { - this.customers.getCustomer(uid).setOrganization(uid, cid); - } - public Map getCompany(String cid) { - return this.companies.getCompany(cid).getValue(); - } - public Map getCompanies() { - return this.companies.getValue(); - } - public void addCampany(String address, String cid) { - this.companies.addCampany(address, cid); - } - public Map getCustomers() { - return this.customers.getValue(); - } - public void addCustomer(String org, String uid) { - this.customers.addCustomer(org, uid); - } - public String getAddress(String cid) { - return this.companies.getCompany(cid).getAddress(); - } - public void setAddress(String cid, String add) { - this.companies.getCompany(cid).setAddress(cid, add); - } -} \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/prototypes/Java/CustomerManagement/PUSH-first/Customers.java b/AlgebraicDataflowArchitectureModel/prototypes/Java/CustomerManagement/PUSH-first/Customers.java deleted file mode 100644 index c19487b..0000000 --- a/AlgebraicDataflowArchitectureModel/prototypes/Java/CustomerManagement/PUSH-first/Customers.java +++ /dev/null @@ -1,18 +0,0 @@ -import java.util.*; - -public class Customers { - private Map value = new HashMap<>(); - private Companies companies; - public Map getValue() { - return new HashMap<>(value); - } - public Customer getCustomer(String uid) { - return this.value.get(uid); - } - public void addCustomer(String org, String uid) { - this.value.put(uid,new Customer(companies, org)); - } - public Customers(Companies companies) { - this.companies = companies; - } -} \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/src/generators/CodeGeneratorFromDataFlowGraph.java b/AlgebraicDataflowArchitectureModel/src/generators/CodeGeneratorFromDataFlowGraph.java index 365a1c2..95ae4b5 100644 --- a/AlgebraicDataflowArchitectureModel/src/generators/CodeGeneratorFromDataFlowGraph.java +++ b/AlgebraicDataflowArchitectureModel/src/generators/CodeGeneratorFromDataFlowGraph.java @@ -1050,7 +1050,7 @@ // generate a pull data transfer from a depending in/ref resource. Type srcResourceType = srcResPath.getResourceStateType(); String srcResName2 = langSpec.toVariableName(getComponentName(srcResPath.getResourceHierarchy(), langSpec)); - String srcPath2 = srcResPath.toString().replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); + String srcPath2 = srcResPath.toResourcePath().replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); generatePullDataTransfer(stateGetter, srcResName2, srcPath2, srcResourceType, false, platformSpec, langSpec); bDeclareClientField = true; } @@ -1081,7 +1081,7 @@ stateGetter.addStatement(langSpec.getVariableDeclaration(srcResType2.getInterfaceTypeName(), srcResName2) + langSpec.getAssignment() + srcGetter + langSpec.getStatementDelimiter()); } else { - String srcPath2 = src2.toString().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); + String srcPath2 = src2.toResourcePath().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); generatePullDataTransfer(stateGetter, srcResName2, srcPath2, srcResType2, false, platformSpec, langSpec); bDeclareClientField = true; } @@ -1098,7 +1098,7 @@ stateGetter.addStatement(langSpec.getVariableDeclaration(srcResType2.getInterfaceTypeName(), srcResName2) + langSpec.getAssignment() + dependingGetter + langSpec.getStatementDelimiter()); } else { - String srcPath2 = src2.toString().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); + String srcPath2 = src2.toResourcePath().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); generatePullDataTransfer(stateGetter, srcResName2, srcPath2, srcResType2, false, platformSpec, langSpec); bDeclareClientField = true; } @@ -1202,7 +1202,7 @@ // for REST API Type parentResType = insideResPath.getResourceStateType(); String parentResName = langSpec.toVariableName(getComponentName(insideResPath.getResourceHierarchy(), langSpec)); - String parentResPath = insideResPath.toString().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); + String parentResPath = insideResPath.toResourcePath().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); generatePullDataTransfer(stateGetter, parentResName, parentResPath, parentResType, true, platformSpec, langSpec); bDeclareClientField = true; } @@ -1887,7 +1887,7 @@ // for REST API Type parentResType = insideResPath.getResourceStateType(); String parentResName = langSpec.toVariableName(getComponentName(insideResPath.getResourceHierarchy(), langSpec)); - String parentResPath = insideResPath.toString().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); + String parentResPath = insideResPath.toResourcePath().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); generatePullDataTransfer(update, parentResName, parentResPath, parentResType, true, platformSpec, langSpec); } } @@ -2066,7 +2066,7 @@ String dstPath = null; if (filledPaths != null && filledPaths.get(out1) != null) { ResourcePath filledDstPath = filledPaths.get(out1).getKey(); - dstPath = filledDstPath.toString().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); + dstPath = filledDstPath.toResourcePath().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); } else { dstPath = dstRes.toResourcePath(pathParamsUrl); } @@ -2803,7 +2803,7 @@ // for REST API Type parentResType = insideResPath.getResourceStateType(); String parentResName = langSpec.toVariableName(getComponentName(insideResPath.getResourceHierarchy(), langSpec)); - String parentResPath = insideResPath.toString().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); + String parentResPath = insideResPath.toResourcePath().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); generatePullDataTransfer(input, parentResName, parentResPath, parentResType, true, platformSpec, langSpec); } } @@ -2973,7 +2973,7 @@ String dstPath = null; if (filledPaths != null && filledPaths.get(out2) != null) { ResourcePath filledDstPath = filledPaths.get(out2).getKey(); - dstPath = filledDstPath.toString().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); + dstPath = filledDstPath.toResourcePath().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); } else { dstPath = dstRes.toResourcePath(pathParamsUrl); } diff --git a/AlgebraicDataflowArchitectureModel/src/generators/JerseyMethodBodyGenerator.java b/AlgebraicDataflowArchitectureModel/src/generators/JerseyMethodBodyGenerator.java index cbef7e0..42c2067 100644 --- a/AlgebraicDataflowArchitectureModel/src/generators/JerseyMethodBodyGenerator.java +++ b/AlgebraicDataflowArchitectureModel/src/generators/JerseyMethodBodyGenerator.java @@ -533,7 +533,7 @@ String dstPath = null; if (filledPaths != null && filledPaths.get(out) != null) { ResourcePath filledDstPath = filledPaths.get(out).getKey(); - dstPath = filledDstPath.toString().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); + dstPath = filledDstPath.toResourcePath().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); } else { dstPath = dstRes.getResourceHierarchy().toResourcePath(pathParams); } @@ -716,7 +716,7 @@ String dstPath = null; if (filledPaths != null && filledPaths.get(out) != null) { ResourcePath filledDstPath = filledPaths.get(out).getKey(); - dstPath = filledDstPath.toString().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); + dstPath = filledDstPath.toResourcePath().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); } else { dstPath = dstRes.getResourceHierarchy().toResourcePath(pathParams); } @@ -890,7 +890,7 @@ // generate a pull data transfer from a depending in/ref resource. Type srcResourceType = src2.getResourceStateType(); String srcResName2 = JerseyCodeGenerator.toVariableName(JerseyCodeGenerator.getComponentName(src2.getResourceHierarchy())); - String srcPath2 = src2.toString().replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); + String srcPath2 = src2.toResourcePath().replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); generatePullDataTransfer(getter, srcResName2, srcPath2, srcResourceType); } } @@ -916,7 +916,7 @@ ResourcePath src2 = cm2.getResource(); Type srcResType2 = src2.getResourceStateType(); String srcResName2 = JerseyCodeGenerator.toVariableName(JerseyCodeGenerator.getComponentName(src2.getResourceHierarchy())); - String srcPath2 = src2.toString().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); + String srcPath2 = src2.toResourcePath().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); generatePullDataTransfer(getter, srcResName2, srcPath2, srcResType2); } else { // a depending channel member. @@ -926,7 +926,7 @@ // generate a pull data transfer from a depending in/ref resource. Type srcResType2 = src2.getResourceStateType(); String srcResName2 = JerseyCodeGenerator.toVariableName(JerseyCodeGenerator.getComponentName(src2.getResourceHierarchy())); - String srcPath2 = src2.toString().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); + String srcPath2 = src2.toResourcePath().replaceAll(":.*\\}","\\}").replaceAll("\\{", "\"+").replaceAll("\\}", "+\""); generatePullDataTransfer(getter, srcResName2, srcPath2, srcResType2); } } diff --git a/AlgebraicDataflowArchitectureModel/src/models/dataConstraintModel/ResourcePath.java b/AlgebraicDataflowArchitectureModel/src/models/dataConstraintModel/ResourcePath.java index b24568f..bfd163b 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/dataConstraintModel/ResourcePath.java +++ b/AlgebraicDataflowArchitectureModel/src/models/dataConstraintModel/ResourcePath.java @@ -198,4 +198,13 @@ public String toString() { return resourceHierarchy.toString(pathParams); } + + public String toResourcePath() { + List params = new ArrayList<>(); + String[] sideEffects = new String[] {""}; + for (Map.Entry param: pathParams) { + params.add("{" + param.getKey().toString() + "}"); + } + return resourceHierarchy.toResourcePath(params); + } }