Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
milesstoetzner committed Dec 25, 2024
1 parent 61761ae commit fa42769
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 12 deletions.
23 changes: 14 additions & 9 deletions src/enricher/constraints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,21 @@ export class ConstraintEnricher {
}
assert.isDefined(left, 'Left not defined')

// TODO: migrate this
if (element.isRelation()) {
this.graph.addConstraint({
implies: [{and: [element.container.id, element.manualId, element.target.manualId]}, element.id],
})
} else {
this.graph.addConstraint({
implies: [{and: [element.container.id, element.manualId]}, element.id],
})
/**
* Implied by container presence and manual conditions
*/
const antecedent: {and: [string, string]} = {and: [element.container.id, element.manualId]}

/**
* Enhanced implied relations also include manual conditions of target
*/
if (element.isRelation() && this.graph.options.constraints.relationEnhancedImplication) {
antecedent.and.push(element.target.manualId)
}

this.graph.addConstraint({
implies: [antecedent, element.id],
})
}

private enrichConstraints() {
Expand Down
4 changes: 4 additions & 0 deletions src/graph/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ class ConstraintsOptions extends BaseOptions {

readonly relationSource: boolean
readonly relationTarget: boolean
readonly relationEnhancedImplication: boolean
readonly artifactContainer: boolean
readonly propertyContainer: boolean
readonly typeContainer: boolean
Expand Down Expand Up @@ -860,6 +861,9 @@ class ConstraintsOptions extends BaseOptions {
this.relationTarget = this.raw.relation_target_constraint ?? this.constraints
assert.isBoolean(this.relationTarget)

this.relationEnhancedImplication = this.raw.relation_enhanced_implication_mode ?? true
assert.isBoolean(this.relationEnhancedImplication)

this.artifactContainer = this.raw.artifact_container_constraint ?? this.constraints
assert.isBoolean(this.artifactContainer)

Expand Down
4 changes: 4 additions & 0 deletions src/specification/variability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ export type ConstraintsOptions = {
constraints?: boolean
relation_source_constraint?: boolean
relation_target_constraint?: boolean
// TODO: doc
// TODO: implement
// TODO: tests
relation_enhanced_implication_mode?: boolean
artifact_container_constraint?: boolean
property_container_constraint?: boolean
type_container_constraint?: boolean
Expand Down
10 changes: 10 additions & 0 deletions tests/conformance/implied-enhanced/new/expected.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
tosca_definitions_version: tosca_simple_yaml_1_3

node_types:
container:
derived_from: tosca.nodes.Root

topology_template:
node_templates:
container:
type: container
38 changes: 38 additions & 0 deletions tests/conformance/implied-enhanced/new/template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
tosca_definitions_version: tosca_variability_1_0_rc_3

node_types:
container:
derived_from: tosca.nodes.Root

topology_template:
variability:
options:
enrich_implementations: false
enrich_technologies: false
relation_enhanced_implication_mode: true

node_templates:
container:
type: container
persistent: true
managed: false
requirements:
- middleware: dmiddleware

dmiddleware:
type: container
managed: false
conditions: false
requirements:
- host: emachine

emachine:
type: container
managed: false
#conditions: false

other:
type: container
managed: false
requirements:
- host: emachine
38 changes: 38 additions & 0 deletions tests/conformance/implied-enhanced/old/template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
tosca_definitions_version: tosca_variability_1_0_rc_3

node_types:
container:
derived_from: tosca.nodes.Root

topology_template:
variability:
options:
enrich_implementations: false
enrich_technologies: false
relation_enhanced_implication_mode: false

node_templates:
container:
type: container
persistent: true
managed: false
requirements:
- middleware: dmiddleware

dmiddleware:
type: container
managed: false
conditions: false
requirements:
- host: emachine

emachine:
type: container
managed: false
#conditions: false

other:
type: container
managed: false
requirements:
- host: emachine
1 change: 1 addition & 0 deletions tests/conformance/implied-enhanced/old/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
error: Could not solve
5 changes: 2 additions & 3 deletions tests/minisat/plays/play.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@ topology_template:
requirements:
- middleware:
node: dmiddleware
conditions: false

dmiddleware:
type: container
managed: false
#conditions: false
conditions: false
requirements:
- host: emachine

emachine:
type: container
managed: false
conditions: false
#conditions: false

other:
type: container
Expand Down

0 comments on commit fa42769

Please sign in to comment.