Class: ActiveFacts::Metamodel::Query
- Inherits:
-
Object
- Object
- ActiveFacts::Metamodel::Query
- Defined in:
- lib/activefacts/vocabulary/metamodel.rb,
lib/activefacts/vocabulary/extensions.rb
Instance Method Summary collapse
- #all_step ⇒ Object
- #show ⇒ Object
-
#validate ⇒ Object
Check all parts of this query for validity.
Instance Method Details
#all_step ⇒ Object
797 798 799 |
# File 'lib/activefacts/vocabulary/extensions.rb', line 797 def all_step all_variable.map{|jn| jn.all_step.to_a}.flatten.uniq end |
#show ⇒ Object
778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 |
# File 'lib/activefacts/vocabulary/extensions.rb', line 778 def show steps_shown = {} debug :query, "Displaying full contents of Query #{concept.guid}" do all_variable.sort_by{|jn| jn.ordinal}.each do |variable| debug :query, "#{variable.describe}" do variable.all_step. each do |step| next if steps_shown[step] steps_shown[step] = true debug :query, "#{step.describe}" end variable.all_play.each do |play| debug :query, "role of #{play.describe} in '#{play.role.fact_type.default_reading}'" end end end end end |
#validate ⇒ Object
Check all parts of this query for validity
802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 |
# File 'lib/activefacts/vocabulary/extensions.rb', line 802 def validate show return # Check the variables: steps = [] variables = all_variable.sort_by{|jn| jn.ordinal} variables.each_with_index do |variable, i| raise "Variable #{i} should have ordinal #{variable.ordinal}" unless variable.ordinal == i raise "Variable #{i} has missing object_type" unless variable.object_type variable.all_play do |play| raise "Variable for #{object_type.name} includes role played by #{play.object_type.name}" unless play.object_type == object_type end steps += variable.all_step end steps.uniq! # Check the steps: steps.each do |step| raise "Step has missing fact type" unless step.fact_type raise "Step has missing input node" unless step.input_play raise "Step has missing output node" unless step.output_play if (role = input_play).role.fact_type != fact_type or (role = output_play).role.fact_type != fact_type raise "Step has role #{role.describe} which doesn't belong to the fact type '#{fact_type.default_reading}' it traverses" end end # REVISIT: Do a connectivity check end |