diff --git a/statemachine.solution/src/main/jastadd/CreateRoleType.jadd b/statemachine.solution/src/main/jastadd/CreateRoleType.jadd index 113e399c81cca984f360efb1248e35e5aa994b57..286055f25a92f86f41bfa9a9a6c06f6da1dbf59e 100644 --- a/statemachine.solution/src/main/jastadd/CreateRoleType.jadd +++ b/statemachine.solution/src/main/jastadd/CreateRoleType.jadd @@ -6,7 +6,7 @@ aspect CreateRoleType { public Consultant RoleRag.CreateConsultant(String name) { Consultant r = new Consultant(); - r.setName("Consultant"); + r.setName(name); addRoleType(r); //c.setWhole(getCompartmentByName("Bank")); //resolveCompartmentType("Bank").addParts(r); @@ -33,7 +33,7 @@ aspect CreateRoleType { public Customer RoleRag.CreateCustomer(String name) { Customer r = new Customer(); - r.setName("Customer"); + r.setName(name); addRoleType(r); //c.setWhole(getCompartmentByName("Bank")); //resolveCompartmentType("Bank").addParts(r); diff --git a/statemachine.solution/src/main/jastadd/Printing.jrag b/statemachine.solution/src/main/jastadd/Printing.jrag index 0b7b970af886c82dfd8afa912376e813b11bf0e3..845d7a151f0206dbbc49a912a6610f760fa03cc8 100644 --- a/statemachine.solution/src/main/jastadd/Printing.jrag +++ b/statemachine.solution/src/main/jastadd/Printing.jrag @@ -7,6 +7,7 @@ aspect Printing { getRoleTypeList().forEach(r -> sb.append(r.prettyPrint())); getCompartmentTypeList().forEach(c -> sb.append(c.prettyPrint())); //getFulfillmentList().forEach(f -> sb.append(f.prettyPrint())); + //getRelationshipList().forEach(rs -> sb.append(rs.prettyPrint())); sb.append("-------------\n"); return sb.toString(); } @@ -43,11 +44,13 @@ aspect Printing { eq CompartmentType.prettyPrint() { StringBuilder sb = new StringBuilder(); sb.append("CT " + getName()); + //plays if (!fulfillments().isEmpty()) sb.append("\n\tPlays "); for (Fulfillment f : fulfillments()) { sb.append("\n\t\t" + f.getFilled().getName() + " "); } + //contains if (getPartsList().getNumChild() != 0) sb.append("\n\tContains "); for (RoleType r : getPartsList()) { @@ -56,6 +59,13 @@ aspect Printing { for (CompartmentType c : getContainsList()) { sb.append("\n\t\t" + c.getName()); } + //rels + if (!rels().isEmpty()) + sb.append("\n\tRels "); + for (Relationship rs : rels()) { + sb.append("\n\t\t" + rs.getFirst().getName() + " " + rs.getName() + " " + rs.getSecond().getName()); + } + //attributes if (getAttributeList().getNumChild() != 0) sb.append("\n\tAttributes "); for (Attribute a : getAttributeList()) { @@ -65,6 +75,15 @@ aspect Printing { return sb.toString(); } //syn String Fulfillment.prettyPrint() = getFiller().getName() + " fills " + getFilled().getName() + ";\n"; + /*eq Relationship.prettyPrint() { + StringBuilder sb = new StringBuilder(); + sb.append("RST " + getName()); + sb.append("\n\t" + getFirst().getName() + " advises " + getSecond().getName()); + sb.append("\n"); + return sb.toString(); + }*/ + + /** Return a textual representation of the state machine */ /* diff --git a/statemachine.solution/src/main/jastadd/Rel.jadd b/statemachine.solution/src/main/jastadd/Rel.jadd index 342032ba24be55032081165304e39b8186613012..fbd6e918eb7b9ffd68e6e913976233f546856d74 100644 --- a/statemachine.solution/src/main/jastadd/Rel.jadd +++ b/statemachine.solution/src/main/jastadd/Rel.jadd @@ -1,11 +1,39 @@ aspect Rel { - /* - coll ArrayList<Relationship> CompartmentType.rels() - [new ArrayList<Relationship>()] with add; - //PersonConsultantFulfillment contributes this + coll Set<Relationship> CompartmentType.rels() + [new HashSet<Relationship>()] with add; + Relationship contributes this to CompartmentType.rels() - for getFirst(); + for containingCompartmentType(); + + + inh CompartmentType Relationship.containingCompartmentType(); + eq RoleRag.getRelationship(int i).containingCompartmentType() { + for (CompartmentType c : getCompartmentTypeList()) { + for (RoleType r : c.getPartsList()) { + if (getRelationship(i).getFirst().equals(r)) + return c; + } + } + return null; + } + + public void Consultant.advises(Customer r) { + new Relationship().setName("advises").setFirst(this).setSecond(r); + } + + //syn Set<Relationship> CompartmentType.rels() = relsOfParts(this); + //inh Set<Relationship> CompartmentType.relsOfParts(CompartmentType c); + + //eq RoleRag.getRelationship(int i).aaaaaaaaaaaaaaa + + /* + inh Set<Relationship> CompartmentType.rels(); + eq RoleRag.getCompartmentTypeList(int i).rels() { + for (Relationship r : getRelationshipList()) { + + } + } */ } \ No newline at end of file diff --git a/statemachine.solution/src/main/java/de/tudresden/inf/st/bank/BankMain.java b/statemachine.solution/src/main/java/de/tudresden/inf/st/bank/BankMain.java index a285806a0e37559bc644cf62317335902c1f9dc2..6f0dd8d3ee4050e7495dba4ee69bd65d1e28298c 100644 --- a/statemachine.solution/src/main/java/de/tudresden/inf/st/bank/BankMain.java +++ b/statemachine.solution/src/main/java/de/tudresden/inf/st/bank/BankMain.java @@ -123,6 +123,7 @@ public class BankMain { peter2.addAttribute(phoneNumber1); con2.addAttribute(phoneNumber2); + con2.advises(cus2); System.out.println(rag.prettyPrint()); diff --git a/statemachine.solution/src/main/resources/Bank.relast b/statemachine.solution/src/main/resources/Bank.relast index eeba253a2791cdee668ebecaa070ed6df724dc87..31563b033ff56e8bb677a2ebf1baeeee0b77128c 100644 --- a/statemachine.solution/src/main/resources/Bank.relast +++ b/statemachine.solution/src/main/resources/Bank.relast @@ -1,4 +1,4 @@ -RoleRag ::= NaturalType* RoleType* CompartmentType* Fulfillment*; +RoleRag ::= NaturalType* RoleType* CompartmentType* Fulfillment* Relationship*; NamedElement ::= <Name>; TypedElement : NamedElement; rel TypedElement.Type? -> RigidType; @@ -9,12 +9,12 @@ RoleType : Type; rel RoleType.Incoming* -> Relationship; rel RoleType.Outgoing* -> Relationship; NaturalType : RigidType; -CompartmentType : RigidType ::= Parts:RoleType* Contains:CompartmentType* Relationships:Relationship*; +CompartmentType : RigidType ::= Parts:RoleType* Contains:CompartmentType*; // Relationships:Relationship*; //rel CompartmentType.Parts* <-> RoleType.Whole; Fulfillment ::= Filler:RigidType Filled:RoleType; //rel Fulfillment.Filler <-> NaturalType.Fulfillment*; //rel Fulfillment.Filled -> RoleType; -Relationship ::= <Name> [First:RoleType] [Second:RoleType]; +Relationship : NamedElement ::= First:RoleType Second:RoleType; //rel Relationship.First -> RoleType; //rel Relationship.Second -> RoleType; Irreflexive;