Skip to content

Qualified association documentation

David Overgaard edited this page Mar 9, 2014 · 5 revisions

UML diagram

qualified_association_diagram

Features not currently supported

  • Visibility (scope) of generated hash. All generated hashes are private with access methods.
  • Value attributes with multiple key attributes

Papyrus Nodes and Edges used

qualified_association_edges

Adding a qualified association

Note: This is currently a two step process until Papyrus is enhanced to fully support qualified associations.

Logically (*Required for Ruby to be generated as expected)

  1. Value: Add a 'property' (member variable) to a class using either a property or an association to another class.
  2. Key: Add another property as a sub-property to value.
  3. From the Model Explorer right-click and select 'New Child -> Create a new Property'
    screenshot from 2014-03-02 07 42 47
  4. Define this attribute by selecting it and updating the UML sub-tab of the Properties tab.
    qualified_association_define_sub-property

Graphically

As an association
  1. From the Model Explorer window drag and drop the key property onto the UML diagram.
  2. Place it at the source end of the association as in the UML diagram above.
As a property
  1. Only the value property can be displayed in the class model. To do this drag and drop the value property from the Model Explorer into the related class model property (top) compartment.
    qualified_association_class_property

Sample Ruby output

Bank.rb

class Bank
  public
    def initialize()
      @customerByAccountNumber = Hash.new
    end

    def addCustomer(accountNumber, customer)
      @customerByAccountNumber[accountNumber]  = customer
    end
  
    def removeCustomer(accountNumber)
      @customerByAccountNumber.delete(accountNumber)
    end
    
    def getCustomer(accountNumber)
      return @customerByAccountNumber[accountNumber]
    end
  

  protected
  

  private
  
end
Customer.rb

class Customer
  public
    def initialize()
    end

  protected

  private
  
end

Quick links