-
Notifications
You must be signed in to change notification settings - Fork 20
/
relationship-type.go
67 lines (54 loc) · 2.12 KB
/
relationship-type.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package tosca_v2_0
import (
"github.com/tliron/puccini/tosca"
)
//
// RelationshipType
//
// [TOSCA-v2.0] @ ?
// [TOSCA-Simple-Profile-YAML-v1.3] @ 3.7.10
// [TOSCA-Simple-Profile-YAML-v1.2] @ 3.7.10
// [TOSCA-Simple-Profile-YAML-v1.1] @ 3.6.10
// [TOSCA-Simple-Profile-YAML-v1.0] @ 3.6.9
//
type RelationshipType struct {
*Type `name:"relationship type"`
PropertyDefinitions PropertyDefinitions `read:"properties,PropertyDefinition" inherit:"properties,Parent"`
AttributeDefinitions AttributeDefinitions `read:"attributes,AttributeDefinition" inherit:"attributes,Parent"`
InterfaceDefinitions InterfaceDefinitions `read:"interfaces,InterfaceDefinition" inherit:"interfaces,Parent"`
ValidTargetCapabilityTypeNames *[]string `read:"valid_target_types" inherit:"valid_target_types,Parent"`
Parent *RelationshipType `lookup:"derived_from,ParentName" json:"-" yaml:"-"`
ValidTargetCapabilityTypes CapabilityTypes `lookup:"valid_target_types,ValidTargetCapabilityTypeNames" inherit:"valid_target_types,Parent" json:"-" yaml:"-"`
}
func NewRelationshipType(context *tosca.Context) *RelationshipType {
return &RelationshipType{
Type: NewType(context),
PropertyDefinitions: make(PropertyDefinitions),
AttributeDefinitions: make(AttributeDefinitions),
InterfaceDefinitions: make(InterfaceDefinitions),
}
}
// tosca.Reader signature
func ReadRelationshipType(context *tosca.Context) tosca.EntityPtr {
self := NewRelationshipType(context)
context.ValidateUnsupportedFields(context.ReadFields(self))
return self
}
// tosca.Hierarchical interface
func (self *RelationshipType) GetParent() tosca.EntityPtr {
return self.Parent
}
// tosca.Inherits interface
func (self *RelationshipType) Inherit() {
logInherit.Debugf("relationship type: %s", self.Name)
if self.Parent == nil {
return
}
self.PropertyDefinitions.Inherit(self.Parent.PropertyDefinitions)
self.AttributeDefinitions.Inherit(self.Parent.AttributeDefinitions)
self.InterfaceDefinitions.Inherit(self.Parent.InterfaceDefinitions)
}
//
// RelationshipTypes
//
type RelationshipTypes []*RelationshipType