Skip to content

Commit 1511f37

Browse files
committed
Export bug fixing: Cardinalities and node type properties
1 parent 1b0d551 commit 1511f37

File tree

6 files changed

+41
-27
lines changed

6 files changed

+41
-27
lines changed

ToscaDesigner/Generated TOSCA files/MyrtusCameraFeed.tosca

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ node_types:
1515

1616
requirements:
1717
- faceDetectionService:
18-
capability: Endpoint
19-
relationship: connectsTo
20-
occurrences: [1, 1]
18+
capability: tosca.capabilities.Endpoint
19+
relationship: tosca.relationships.connectsTo
20+
occurrences: [ 1, 1 ]
2121
capabilities:
2222
CameraFeed.WebService:
23-
occurrences: [0, -1]
23+
occurrences: [ 0, UNBOUNDED ]
2424
type: tosca.capabilities.Endpoint

ToscaDesigner/Generated TOSCA files/MyrtusFaceDetectionService.tosca

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ node_types:
1313
abstract: "false"
1414
final: "false"
1515

16+
1617
capabilities:
1718
FaceDetectionService:
18-
occurrences: [, ]
19+
occurrences: [ 0, UNBOUNDED ]
1920
type: tosca.capabilities.Endpoint

ToscaDesigner/Generated TOSCA files/MyrtusProxy.tosca

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ node_types:
1212
targetNamespace: "example.eu.myrtus.nodetypes"
1313
abstract: "false"
1414
final: "false"
15+
1516
requirements:
1617
- egress:
1718
capability: tosca.capabilities.Endpoint
18-
relationship: connectsTo
19-
occurrences: [, ]
19+
relationship: tosca.relationships.connectsTo
20+
occurrences: [ 0, UNBOUNDED ]
2021
capabilities:
2122
MyrtusProxy.WebService:
22-
occurrences: [, ]
23+
occurrences: [ 0, UNBOUNDED ]
2324
type: tosca.capabilities.Endpoint

ToscaDesigner/Generated TOSCA files/MyrtusSWComponent.tosca

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,24 @@ imports:
77

88
node_types:
99
example.eu.myrtus.nodetypes.MyrtusSWComponent:
10+
description: This is an example of a specialization made to represent Myrtus SW components. This component assumes the SW modules are containerized in Docker containers.
1011
derived_from: tosca.nodes.SoftwareComponent
1112
metadata:
1213
targetNamespace: "example.eu.myrtus.nodetypes"
1314
abstract: "true"
14-
final: ""
15+
final: "false"
16+
properties:
17+
dockerImage:
18+
type: string
19+
description:
20+
21+
port:
22+
type: integer
23+
description:
24+
required: false
1525
requirements:
1626
- connects:
1727
capability: tosca.capabilities.Endpoint
18-
relationship: tosca.relationships.connectTo
19-
occurrences: [, ]
28+
relationship: tosca.relationships.connectsTo
29+
occurrences: [ 0, UNBOUNDED ]
2030

ToscaDesigner/src/main/java/fr/softeam/toscadesigner/export/AbstractToscaFileGenerator.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,16 @@ private Handlebars setupHandlebars() {
101101
propertyStringValue = capability.getElement().getName();
102102
} else if (searchedPropertyName.equals("relationshipType")) {
103103
propertyStringValue = tRequirementDefinition.getRelationshipType().getElement().getName();
104-
} else if (searchedPropertyName.equals("lowerBound")) {
105-
propertyStringValue = tRequirementDefinition.getLowerBound();
106104
} else if (searchedPropertyName.equals("upperBound")) {
107105
propertyStringValue = tRequirementDefinition.getUpperBound();
106+
propertyStringValue = propertyStringValue.equals("-1") ? "UNBOUNDED" : propertyStringValue;
108107
}
109108
} else if (stereotype.getName().equals("TRelationshipTemplate")) {
110109
if (searchedPropertyName.equals("type")) {
111110
TRelationshipTemplate tRelationshipTemplate = TRelationshipTemplate
112111
.safeInstantiate((Association) context);
113112
TRelationshipType relationshipType = tRelationshipTemplate.getRelationshipType();
114-
Class element = relationshipType.getElement();
115-
propertyStringValue = element.getName();
113+
propertyStringValue = relationshipType.getElement().getName();
116114
}
117115
} else if (stereotype.getName().equals("TNodeTemplate")) {
118116
TNodeTemplate tNodeTemplate = TNodeTemplate.safeInstantiate((Class) context);
@@ -125,10 +123,9 @@ private Handlebars setupHandlebars() {
125123
.safeInstantiate((Class) context);
126124
if (searchedPropertyName.equals("capabilityType")) {
127125
propertyStringValue = tCapabilityDefinition.getCapabilityType().getElement().getName();
128-
} else if (searchedPropertyName.equals("lowerBound")) {
129-
propertyStringValue = tCapabilityDefinition.getLowerBound().toString();
130126
} else if (searchedPropertyName.equals("upperBound")) {
131127
propertyStringValue = tCapabilityDefinition.getUpperBound().toString();
128+
propertyStringValue = propertyStringValue.equals("-1") ? "UNBOUNDED" : propertyStringValue;
132129
}
133130
} else if (stereotype.getName().equals("TDeploymentArtifact")) {
134131
TDeploymentArtifact tDeploymentArtifact = TDeploymentArtifact.safeInstantiate((Class) context);
Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
{{imports this}}
22
node_types:
33
{{owner.name}}.{{name}}:
4-
{{#if (getProperty this "description")}} description: {{getProperty this "description"}}
5-
{{/if}}{{#if (getProperty this "derivedFrom")}} derived_from: {{getProperty this "derivedFrom"}}{{/if}}
4+
{{#if (getProperty this "description")}}
5+
description: {{getProperty this "description"}}
6+
{{/if}}{{#if (getProperty this "derivedFrom")}}
7+
derived_from: {{getProperty this "derivedFrom"}}{{/if}}
68
metadata:
79
targetNamespace: "{{getProperty this "targetNamespace"}}"
810
abstract: "{{getProperty this "abstract"}}"
911
final: "{{getProperty this "final"}}"
1012
{{#unless (noStereotypeApplications this "PropertyDefinitionType")}}properties:{{/unless}}
11-
{{#each ../ownedAttribute}}{{#extension}}{{#eq name "PropertyDefinitionType"}}
12-
{{../name}}: "{{../value}}"
13-
{{/eq}}{{/extension}}{{/each}}
13+
{{#each ../ownedAttribute}}{{#extension}}{{#eq name "PropertyDefinitionType"}}
14+
{{../name}}:
15+
type: {{../type.name}}
16+
description:
17+
{{#eq ../multiplicityMin "0"}}required: false{{/eq}}
18+
{{/eq}}{{/extension}}{{/each}}
1419
{{#unless (noStereotypeApplications this "TRequirementDefinitionType")}}requirements:{{/unless}}
1520
{{#each ownedElement}}{{#extension}}{{#eq name "TRequirementDefinitionType"}}{{#each ../ownedElement}}{{#extension}}{{#eq name "TRequirementDefinition"}}
1621
- {{../name}}:
17-
capability: {{getProperty ../this "capability"}}
18-
relationship: {{getProperty ../this "relationshipType"}}
19-
occurrences: [{{getProperty ../this "lowerBound"}}, {{getProperty ../this "upperBound"}}]
22+
capability: tosca.capabilities.{{getProperty ../this "capability"}}
23+
relationship: tosca.relationships.{{getProperty ../this "relationshipType"}}
24+
occurrences: [ {{getProperty ../this "lowerBound"}}, {{getProperty ../this "upperBound"}} ]
2025
{{/eq}}{{/extension}}{{/each}}{{/eq}}{{/extension}}{{/each}}
2126
{{#unless (noStereotypeApplications this "TCapabilityDefinitionsType")}}capabilities:{{/unless}}
2227
{{#each ownedElement}}{{#extension}}{{#eq name "TCapabilityDefinitionsType"}}{{#each ../ownedElement}}{{#extension}}{{#eq name "TCapabilityDefinition"}}
2328
{{../name}}:
24-
occurrences: [{{getProperty ../this "lowerBound"}}, {{getProperty ../this "upperBound"}}]
25-
type: tosca.capabilities.Endpoint
29+
occurrences: [ {{getProperty ../this "lowerBound"}}, {{getProperty ../this "upperBound"}} ]
30+
type: tosca.capabilities.{{getProperty ../this "capabilityType"}}
2631
{{/eq}}{{/extension}}{{/each}}{{/eq}}{{/extension}}{{/each}}

0 commit comments

Comments
 (0)