activefacts-metamodel 1.9.16 → 1.9.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/activefacts/metamodel/extensions.rb +99 -0
- data/lib/activefacts/metamodel/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: add6e3c8d9f09f1d7c92e94658e9b3a53c937edb
|
4
|
+
data.tar.gz: dadcd30c0c2c04178dd53d811e384521dbe1bb3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c614110af45ddc88a5181c70ae6b26e04db2d69e10fc07515420942fd70756c34150f615ef3acb4ca99856298f5b6aab64831180d1d22654963074826168b5d9
|
7
|
+
data.tar.gz: ad3a1fb187d7885d8c5264e6ffe62d8ae26b462d36a06194f88a4d663c63a190818a6c7c02ff81864db41847dfc453ba8c267d376c71bad0cf2881d89bc9e1ba
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'pp'
|
1
2
|
#
|
2
3
|
# ActiveFacts Vocabulary Metamodel.
|
3
4
|
# Extensions to the ActiveFacts Vocabulary classes (which are generated from the Metamodel)
|
@@ -66,6 +67,10 @@ module ActiveFacts
|
|
66
67
|
@constellation.ValueType[[identifying_role_values, name]] or
|
67
68
|
check_valid_nonexistent_object_type_name name
|
68
69
|
end
|
70
|
+
|
71
|
+
def object_type_lookup name
|
72
|
+
@constellation.ObjectType[[identifying_role_values, name]]
|
73
|
+
end
|
69
74
|
end
|
70
75
|
|
71
76
|
class Concept
|
@@ -550,8 +555,101 @@ module ActiveFacts
|
|
550
555
|
assimilation == 'partitioned'
|
551
556
|
end
|
552
557
|
|
558
|
+
def new_pi
|
559
|
+
trace :newpi, "Looking for New PI for #{name}" do
|
560
|
+
# An objectified fact type is identified by the object which plays it.
|
561
|
+
if fact_type && fact_type.all_role.size == 1
|
562
|
+
# REVISIT: If the OFT is separate (is this even possible?), this probably won't work:
|
563
|
+
return fact_type.all_role.single.object_type.preferred_identifier
|
564
|
+
end
|
565
|
+
|
566
|
+
# All roles in a preferred identifier must be a counterpart
|
567
|
+
# to a role played by this type or any of its supertypes.
|
568
|
+
# Here, a unary role is deemed to be its own counterpart.
|
569
|
+
# If this is an objectified fact type, its roles are deemed
|
570
|
+
# to be counterparts per virtue of the mirror role.
|
571
|
+
|
572
|
+
# if name == 'User'
|
573
|
+
# pp all_role_transitive.map{|a| a.fact_type.describe(a)}
|
574
|
+
# debugger
|
575
|
+
# end
|
576
|
+
|
577
|
+
art = all_role_transitive.map do |role|
|
578
|
+
# No TypeInheritance roles unless we play the subtype
|
579
|
+
if (ti = role.fact_type).is_a?(TypeInheritance) && role != ti.subtype_role
|
580
|
+
nil
|
581
|
+
elsif role.is_a?(MirrorRole)
|
582
|
+
nil
|
583
|
+
elsif role.fact_type.all_role.size == 1
|
584
|
+
role.base_role
|
585
|
+
else
|
586
|
+
x = (c = role.counterpart and c.base_role)
|
587
|
+
# debugger if x && x.object_type == self
|
588
|
+
x
|
589
|
+
end
|
590
|
+
end.compact
|
591
|
+
|
592
|
+
all_role.each do |role|
|
593
|
+
# Is this the subtype role in a supertype that identifies us?
|
594
|
+
if (ti = role.base_role.fact_type).is_a?(TypeInheritance)
|
595
|
+
if role == ti.subtype_role and ti.provides_identification
|
596
|
+
trace :newpi, "#{name} is identified by supertype #{ti.supertype.name}"
|
597
|
+
|
598
|
+
pcs = ti.supertype_role.all_role_ref.to_a.flat_map(&:role_sequence).flat_map(&:all_presence_constraint).to_a
|
599
|
+
debugger if pcs.size > 1
|
600
|
+
return pcs[0]
|
601
|
+
|
602
|
+
return ti.supertype_role.object_type.preferred_identifier
|
603
|
+
end
|
604
|
+
next # It can't be this TypeInheritance
|
605
|
+
end
|
606
|
+
|
607
|
+
# The fact type must be binary or unary
|
608
|
+
next if role.fact_type.all_role.size > 2
|
609
|
+
|
610
|
+
base_role = role.counterpart.base_role # Go to the OFT role that implied the link fact type
|
611
|
+
base_role.all_role_ref.each do |rr|
|
612
|
+
if rr.role_sequence.all_presence_constraint.size > 0
|
613
|
+
trace :newpi, "Looking for New PI that includes '#{base_role.fact_type.describe(base_role)}'"
|
614
|
+
end
|
615
|
+
rr.role_sequence.all_presence_constraint.each do |pc|
|
616
|
+
next unless pc.max_frequency == 1 and
|
617
|
+
pc.is_preferred_identifier and
|
618
|
+
!pc.enforcement # Alethic uniqueness constraint
|
619
|
+
# We have a uniqueness constraint that is alethic and preferred.
|
620
|
+
# If all its role are valid counterparts, this is our preferred identifier.
|
621
|
+
next if pc.role_sequence.all_role_ref.to_a.detect do |nrr|
|
622
|
+
if !art.include?(nrr.role)
|
623
|
+
trace :newpi, "Rejecting New PI with excluded role '#{nrr.role.fact_type.describe(nrr.role)}'"
|
624
|
+
end
|
625
|
+
!art.include?(nrr.role) # Nope, not included in the valid counterparts
|
626
|
+
end
|
627
|
+
trace :newpi, "Accepting New PI #{pc.describe}"
|
628
|
+
return pc
|
629
|
+
end
|
630
|
+
end
|
631
|
+
end
|
632
|
+
|
633
|
+
debugger
|
634
|
+
trace :newpi, "No New PI found for #{name}"
|
635
|
+
nil
|
636
|
+
|
637
|
+
end
|
638
|
+
end
|
639
|
+
|
553
640
|
def preferred_identifier
|
554
641
|
return @preferred_identifier if @preferred_identifier
|
642
|
+
|
643
|
+
@old_preferred_identifier = old_preferred_identifier
|
644
|
+
# @new_preferred_identifier = new_pi
|
645
|
+
# if @old_preferred_identifier != @new_preferred_identifier
|
646
|
+
## debugger
|
647
|
+
# new_pi
|
648
|
+
# end
|
649
|
+
return @preferred_identifier = @old_preferred_identifier
|
650
|
+
end
|
651
|
+
|
652
|
+
def old_preferred_identifier
|
555
653
|
if fact_type
|
556
654
|
# Objectified unaries are identified by the ID of the object that plays the role:
|
557
655
|
if fact_type.all_role.size == 1
|
@@ -615,6 +713,7 @@ module ActiveFacts
|
|
615
713
|
trace :pi, "PI roles must be played by one of #{all_supertypes.map(&:name)*", "}" if all_supertypes.size > 1
|
616
714
|
all_role.each{|role|
|
617
715
|
next unless role.is_unique || fact_type
|
716
|
+
next if role.fact_type.is_a?(TypeInheritance) && !role.fact_type.provides_identification
|
618
717
|
ftroles = Array(role.fact_type.all_role)
|
619
718
|
|
620
719
|
# Skip roles in ternary and higher fact types, they're objectified
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activefacts-metamodel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clifford Heath
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|