Skip to content
Snippets Groups Projects
Commit 7c0556f3 authored by Ronny Böttger's avatar Ronny Böttger
Browse files

added Relationship

parent bead0ba5
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ aspect CreateRoleType { ...@@ -6,7 +6,7 @@ aspect CreateRoleType {
public Consultant RoleRag.CreateConsultant(String name) { public Consultant RoleRag.CreateConsultant(String name) {
Consultant r = new Consultant(); Consultant r = new Consultant();
r.setName("Consultant"); r.setName(name);
addRoleType(r); addRoleType(r);
//c.setWhole(getCompartmentByName("Bank")); //c.setWhole(getCompartmentByName("Bank"));
//resolveCompartmentType("Bank").addParts(r); //resolveCompartmentType("Bank").addParts(r);
...@@ -33,7 +33,7 @@ aspect CreateRoleType { ...@@ -33,7 +33,7 @@ aspect CreateRoleType {
public Customer RoleRag.CreateCustomer(String name) { public Customer RoleRag.CreateCustomer(String name) {
Customer r = new Customer(); Customer r = new Customer();
r.setName("Customer"); r.setName(name);
addRoleType(r); addRoleType(r);
//c.setWhole(getCompartmentByName("Bank")); //c.setWhole(getCompartmentByName("Bank"));
//resolveCompartmentType("Bank").addParts(r); //resolveCompartmentType("Bank").addParts(r);
......
...@@ -7,6 +7,7 @@ aspect Printing { ...@@ -7,6 +7,7 @@ aspect Printing {
getRoleTypeList().forEach(r -> sb.append(r.prettyPrint())); getRoleTypeList().forEach(r -> sb.append(r.prettyPrint()));
getCompartmentTypeList().forEach(c -> sb.append(c.prettyPrint())); getCompartmentTypeList().forEach(c -> sb.append(c.prettyPrint()));
//getFulfillmentList().forEach(f -> sb.append(f.prettyPrint())); //getFulfillmentList().forEach(f -> sb.append(f.prettyPrint()));
//getRelationshipList().forEach(rs -> sb.append(rs.prettyPrint()));
sb.append("-------------\n"); sb.append("-------------\n");
return sb.toString(); return sb.toString();
} }
...@@ -43,11 +44,13 @@ aspect Printing { ...@@ -43,11 +44,13 @@ aspect Printing {
eq CompartmentType.prettyPrint() { eq CompartmentType.prettyPrint() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("CT " + getName()); sb.append("CT " + getName());
//plays
if (!fulfillments().isEmpty()) if (!fulfillments().isEmpty())
sb.append("\n\tPlays "); sb.append("\n\tPlays ");
for (Fulfillment f : fulfillments()) { for (Fulfillment f : fulfillments()) {
sb.append("\n\t\t" + f.getFilled().getName() + " "); sb.append("\n\t\t" + f.getFilled().getName() + " ");
} }
//contains
if (getPartsList().getNumChild() != 0) if (getPartsList().getNumChild() != 0)
sb.append("\n\tContains "); sb.append("\n\tContains ");
for (RoleType r : getPartsList()) { for (RoleType r : getPartsList()) {
...@@ -56,6 +59,13 @@ aspect Printing { ...@@ -56,6 +59,13 @@ aspect Printing {
for (CompartmentType c : getContainsList()) { for (CompartmentType c : getContainsList()) {
sb.append("\n\t\t" + c.getName()); 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) if (getAttributeList().getNumChild() != 0)
sb.append("\n\tAttributes "); sb.append("\n\tAttributes ");
for (Attribute a : getAttributeList()) { for (Attribute a : getAttributeList()) {
...@@ -65,6 +75,15 @@ aspect Printing { ...@@ -65,6 +75,15 @@ aspect Printing {
return sb.toString(); return sb.toString();
} }
//syn String Fulfillment.prettyPrint() = getFiller().getName() + " fills " + getFilled().getName() + ";\n"; //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 */ /** Return a textual representation of the state machine */
/* /*
......
aspect Rel { 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 Relationship contributes this
to CompartmentType.rels() 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
...@@ -123,6 +123,7 @@ public class BankMain { ...@@ -123,6 +123,7 @@ public class BankMain {
peter2.addAttribute(phoneNumber1); peter2.addAttribute(phoneNumber1);
con2.addAttribute(phoneNumber2); con2.addAttribute(phoneNumber2);
con2.advises(cus2);
System.out.println(rag.prettyPrint()); System.out.println(rag.prettyPrint());
......
RoleRag ::= NaturalType* RoleType* CompartmentType* Fulfillment*; RoleRag ::= NaturalType* RoleType* CompartmentType* Fulfillment* Relationship*;
NamedElement ::= <Name>; NamedElement ::= <Name>;
TypedElement : NamedElement; TypedElement : NamedElement;
rel TypedElement.Type? -> RigidType; rel TypedElement.Type? -> RigidType;
...@@ -9,12 +9,12 @@ RoleType : Type; ...@@ -9,12 +9,12 @@ RoleType : Type;
rel RoleType.Incoming* -> Relationship; rel RoleType.Incoming* -> Relationship;
rel RoleType.Outgoing* -> Relationship; rel RoleType.Outgoing* -> Relationship;
NaturalType : RigidType; NaturalType : RigidType;
CompartmentType : RigidType ::= Parts:RoleType* Contains:CompartmentType* Relationships:Relationship*; CompartmentType : RigidType ::= Parts:RoleType* Contains:CompartmentType*; // Relationships:Relationship*;
//rel CompartmentType.Parts* <-> RoleType.Whole; //rel CompartmentType.Parts* <-> RoleType.Whole;
Fulfillment ::= Filler:RigidType Filled:RoleType; Fulfillment ::= Filler:RigidType Filled:RoleType;
//rel Fulfillment.Filler <-> NaturalType.Fulfillment*; //rel Fulfillment.Filler <-> NaturalType.Fulfillment*;
//rel Fulfillment.Filled -> RoleType; //rel Fulfillment.Filled -> RoleType;
Relationship ::= <Name> [First:RoleType] [Second:RoleType]; Relationship : NamedElement ::= First:RoleType Second:RoleType;
//rel Relationship.First -> RoleType; //rel Relationship.First -> RoleType;
//rel Relationship.Second -> RoleType; //rel Relationship.Second -> RoleType;
Irreflexive; Irreflexive;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment