Skip to content

Commit dfde27e

Browse files
committed
Merge branch 'master' into ustutt
2 parents f53b41f + fd796ef commit dfde27e

File tree

25 files changed

+430
-65
lines changed

25 files changed

+430
-65
lines changed

.github/workflows/build.yml

+15
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,19 @@ name: Winery CI
33
on: [ push, pull_request ]
44

55
jobs:
6+
7+
pre_job:
8+
continue-on-error: true
9+
runs-on: ubuntu-latest
10+
outputs:
11+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
12+
steps:
13+
- id: skip_check
14+
uses: fkirc/skip-duplicate-actions@master
615

716
java8:
17+
needs: pre_job
18+
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
819
runs-on: ubuntu-latest
920
steps:
1021
- uses: actions/checkout@v2
@@ -16,6 +27,8 @@ jobs:
1627
run: mvn -Pjava -B package
1728

1829
java12:
30+
needs: pre_job
31+
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
1932
runs-on: ubuntu-latest
2033
steps:
2134
- uses: actions/checkout@v2
@@ -33,6 +46,8 @@ jobs:
3346
coverage-reports: org.eclipse.winery.reporting/target/site/jacoco-aggregate/jacoco.xml
3447

3548
frontend:
49+
needs: pre_job
50+
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
3651
runs-on: ubuntu-latest
3752
steps:
3853
- uses: actions/checkout@v2

.idea/runConfigurations/Winery_Server.xml

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/model/EdmmConverter.java

+68-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
import java.io.UnsupportedEncodingException;
1818
import java.net.URLDecoder;
19+
import java.util.ArrayList;
20+
import java.util.HashMap;
1921
import java.util.List;
2022
import java.util.Map;
2123
import java.util.Objects;
@@ -39,6 +41,7 @@
3941
import org.eclipse.winery.model.tosca.TRelationshipType;
4042
import org.eclipse.winery.model.tosca.TRelationshipTypeImplementation;
4143
import org.eclipse.winery.model.tosca.TServiceTemplate;
44+
import org.eclipse.winery.model.tosca.extensions.OTParticipant;
4245
import org.eclipse.winery.model.tosca.utils.ModelUtilities;
4346

4447
import io.github.edmm.core.parser.Entity;
@@ -49,6 +52,8 @@
4952
import io.github.edmm.core.parser.SequenceEntity;
5053
import io.github.edmm.core.parser.support.DefaultKeys;
5154

55+
import static org.eclipse.winery.model.tosca.constants.Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE;
56+
5257
public class EdmmConverter {
5358

5459
private final Map<QName, TNodeType> nodeTypes;
@@ -85,20 +90,82 @@ public EdmmConverter(Map<QName, TNodeType> nodeTypes, Map<QName, TRelationshipTy
8590
}
8691

8792
public EntityGraph transform(TServiceTemplate serviceTemplate) {
93+
8894
EntityGraph entityGraph = new EntityGraph();
8995

96+
setMetadata(entityGraph);
97+
9098
List<TNodeTemplate> nodeTemplates = serviceTemplate.getTopologyTemplate().getNodeTemplates();
9199
List<TRelationshipTemplate> relationshipTemplates = serviceTemplate.getTopologyTemplate().getRelationshipTemplates();
92100
if (!nodeTemplates.isEmpty()) {
93101
entityGraph.addEntity(new MappingEntity(EntityGraph.COMPONENTS, entityGraph));
94102
}
95-
96103
nodeTemplates.forEach(nodeTemplate -> createNode(nodeTemplate, entityGraph));
97104
relationshipTemplates.forEach(relationship -> createRelation(relationship, entityGraph));
98105

106+
List<OTParticipant> participants = serviceTemplate.getTopologyTemplate().getParticipants();
107+
if (participants != null && !participants.isEmpty()) {
108+
entityGraph.addEntity(new MappingEntity(EntityGraph.PARTICIPANTS, entityGraph));
109+
participants.forEach(participant -> createParticipant(participant, nodeTemplates, entityGraph));
110+
}
111+
112+
createTechnologyMapping(nodeTemplates, entityGraph);
113+
99114
return entityGraph;
100115
}
101116

117+
private void setMetadata(EntityGraph entityGraph) {
118+
entityGraph.addEntity(new ScalarEntity("edm_1_0", EntityGraph.VERSION, entityGraph));
119+
entityGraph.addEntity(new ScalarEntity("12345", EntityGraph.MULTI_ID, entityGraph));
120+
}
121+
122+
private void createTechnologyMapping(List<TNodeTemplate> nodeTemplates, EntityGraph entityGraph) {
123+
124+
Map<String, List<TNodeTemplate>> deploymentTechnologyMapping = new HashMap<>();
125+
for (TNodeTemplate nodeTemplate : nodeTemplates) {
126+
Map<QName, String> attributes = nodeTemplate.getOtherAttributes();
127+
String key = attributes.get(new QName(TOSCA_WINERY_EXTENSIONS_NAMESPACE, "deployment-technology"));
128+
if (key != null) {
129+
deploymentTechnologyMapping.computeIfAbsent(key, k -> new ArrayList<>());
130+
deploymentTechnologyMapping.get(key).add(nodeTemplate);
131+
}
132+
}
133+
134+
if (!deploymentTechnologyMapping.isEmpty()) {
135+
entityGraph.addEntity(new MappingEntity(EntityGraph.ORCHESTRATION_TECHNOLOGY, entityGraph));
136+
137+
deploymentTechnologyMapping.forEach((key, nodes) -> {
138+
EntityId entity = EntityGraph.ORCHESTRATION_TECHNOLOGY.extend(key);
139+
entityGraph.addEntity(new SequenceEntity(entity, entityGraph));
140+
for (TNodeTemplate nodeTemplate : nodes) {
141+
EntityId valueEntity = entity.extend(nodeTemplate.getId());
142+
entityGraph.addEntity(new ScalarEntity(nodeTemplate.getId(), valueEntity, entityGraph));
143+
}
144+
});
145+
}
146+
}
147+
148+
private void createParticipant(OTParticipant participant, List<TNodeTemplate> nodeTemplates, EntityGraph entityGraph) {
149+
150+
EntityId participantEntity = EntityGraph.PARTICIPANTS.extend(participant.getName());
151+
entityGraph.addEntity(new MappingEntity(participantEntity, entityGraph));
152+
153+
EntityId endpointEntityId = participantEntity.extend(DefaultKeys.ENDPOINT);
154+
entityGraph.addEntity(new ScalarEntity(participant.getUrl(), endpointEntityId, entityGraph));
155+
156+
EntityId componentsEntityId = participantEntity.extend(DefaultKeys.COMPONENTS);
157+
entityGraph.addEntity(new SequenceEntity(componentsEntityId, entityGraph));
158+
159+
for (TNodeTemplate nodeTemplate : nodeTemplates) {
160+
Map<QName, String> attributes = nodeTemplate.getOtherAttributes();
161+
String name = attributes.get(new QName(TOSCA_WINERY_EXTENSIONS_NAMESPACE, "participant"));
162+
if (participant.getName().equals(name)) {
163+
EntityId valueEntity = componentsEntityId.extend(nodeTemplate.getId());
164+
entityGraph.addEntity(new ScalarEntity(nodeTemplate.getId(), valueEntity, entityGraph));
165+
}
166+
}
167+
}
168+
102169
private void createRelation(TRelationshipTemplate relationship, EntityGraph entityGraph) {
103170
EntityId sourceComponentEntityId = EntityGraph.COMPONENTS.extend(relationship.getSourceElement().getRef().getId());
104171
// the entity will always be in the graph since we first transform the NodeTemplates

org.eclipse.winery.edmm/src/test/java/org/eclipse/winery/edmm/model/EdmmConverterTest.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void transformOneNodeTemplate() {
5454
EntityGraph transform = edmmConverter.transform(serviceTemplate);
5555

5656
assertNotNull(transform);
57-
assertEquals(11, transform.vertexSet().size());
57+
assertEquals(13, transform.vertexSet().size());
5858
}
5959

6060
@Test
@@ -72,7 +72,6 @@ void transformDerivedFrom() {
7272
EntityGraph transform = edmmConverter.transform(serviceTemplate);
7373

7474
assertNotNull(transform);
75-
assertEquals(11, transform.vertexSet().size());
7675
assertTrue(transform.vertexSet().stream().anyMatch(entity ->
7776
entity instanceof ScalarEntity
7877
&& entity.getName().equals("extends")
@@ -94,7 +93,6 @@ void transformProperties() {
9493
EntityGraph transform = edmmConverter.transform(serviceTemplate);
9594

9695
assertNotNull(transform);
97-
assertEquals(21, transform.vertexSet().size());
9896
assertTrue(transform.vertexSet().stream().anyMatch(entity ->
9997
entity instanceof MappingEntity
10098
&& entity.getName().equals("properties")
@@ -139,7 +137,6 @@ void transformTopologyWithRelationsAndRelationTypes() {
139137
EntityGraph transform = edmmConverter.transform(serviceTemplate);
140138

141139
assertNotNull(transform);
142-
assertEquals(47, transform.vertexSet().size());
143140
assertTrue(transform.vertexSet().stream().anyMatch(entity ->
144141
entity instanceof ScalarEntity
145142
&& entity.getName().equals("hosted_on")
@@ -171,7 +168,6 @@ void transformTopologyWithOperations() {
171168
EntityGraph transform = edmmConverter.transform(serviceTemplate);
172169

173170
assertNotNull(transform);
174-
assertEquals(14, transform.vertexSet().size());
175171

176172
Optional<Entity> operations = transform.getEntity(Arrays.asList("0", "components", "test_node_4", "operations"));
177173
assertTrue(operations.isPresent());
@@ -247,6 +243,7 @@ void transformTopology() {
247243
" extends: depends_on\n" +
248244
" connects_to:\n" +
249245
" extends: depends_on\n" +
246+
"multi_id: '12345'\n" +
250247
"component_types:\n" +
251248
" https_ex.orgtoscatoedmm__test_node_type_2:\n" +
252249
" extends: software_component\n" +
@@ -266,6 +263,7 @@ void transformTopology() {
266263
" https_ex.orgtoscatoedmm__test_node_type_4:\n" +
267264
" extends: web_application\n" +
268265
" software_component:\n" +
269-
" extends: base\n", stringWriter.toString());
266+
" extends: base\n" +
267+
"version: edm_1_0\n", stringWriter.toString());
270268
}
271269
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/********************************************************************************
2+
* Copyright (c) 2021 Contributors to the Eclipse Foundation
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0, or the Apache Software License 2.0
10+
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
11+
*
12+
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
13+
********************************************************************************/
14+
table {
15+
width: 210px;
16+
table-layout: fixed;
17+
border: 1px solid #ddd;
18+
}
19+
20+
th {
21+
background-color: #cfd8dc;
22+
color: #000;
23+
text-align: left;
24+
}
25+
26+
th,
27+
td {
28+
border-top: 0;
29+
border-left: 0;
30+
border-right: 0;
31+
border-bottom: 1px solid #ddd;
32+
padding-left: 2px;
33+
}
34+
35+
tr {
36+
cursor: pointer;
37+
}
38+
39+
tr:nth-child(even) {
40+
background-color: #f2f2f2;
41+
}
42+
43+
.table-td div {
44+
overflow: hidden;
45+
text-overflow: ellipsis;
46+
white-space: nowrap;
47+
position: relative;
48+
width: auto;
49+
max-width: 100%;
50+
-webkit-transition: max-width linear 1ms;
51+
transition: max-width linear 1ms;
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!--
2+
* Copyright (c) 2021 Contributors to the Eclipse Foundation
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0, or the Apache Software License 2.0
10+
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
11+
*
12+
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
13+
-->
14+
15+
<div *ngIf="isEmpty()" style="color: dimgray; text-align: center">
16+
<span>No deployment technologies available.</span>
17+
</div>
18+
19+
<table>
20+
<thead>
21+
<tr>
22+
<th>Name</th>
23+
<th style="width: 60px">Use</th>
24+
</tr>
25+
</thead>
26+
<tbody>
27+
<tr *ngFor="let p of deploymentTechnologies">
28+
<td class="table-td"
29+
[class.cell-with-comment]="isEllipsisActive(name)">
30+
<div #name>{{ p.name }}</div>
31+
<span class="cell-comment">{{ p.name }}</span>
32+
</td>
33+
<td class="table-td">
34+
<div style="margin-left: 2px; margin-top: 4px;">
35+
<input type="radio" id="{{ node.id }}--{{ p.id }}"
36+
[name]="node.id"
37+
[value]="p.id"
38+
(change)="toggleMembership(p)"
39+
[checked]="isMember(p)">
40+
<label for="{{ node.id }}--{{ p.id }}"></label>
41+
</div>
42+
</td>
43+
</tr>
44+
</tbody>
45+
</table>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/********************************************************************************
2+
* Copyright (c) 2021 Contributors to the Eclipse Foundation
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0, or the Apache Software License 2.0
10+
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
11+
*
12+
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
13+
********************************************************************************/
14+
15+
import { Component, Input, OnInit } from '@angular/core';
16+
import { NgRedux } from '@angular-redux/store';
17+
import { TNodeTemplate } from '../models/ttopology-template';
18+
import { IWineryState } from '../redux/store/winery.store';
19+
import { WineryActions } from '../redux/actions/winery.actions';
20+
import { BackendService } from '../services/backend.service';
21+
import { DeploymentTechnology } from '../models/deployment-technology';
22+
import { QName } from '../../../../shared/src/app/model/qName';
23+
import { TOSCA_WINERY_EXTENSIONS_NAMESPACE } from '../models/namespaces';
24+
25+
@Component({
26+
selector: 'winery-assign-deployment-technology',
27+
templateUrl: './assign-deployment-technology.component.html',
28+
styleUrls: ['./assign-deployment-technology.component.css']
29+
})
30+
export class AssignDeploymentTechnologyComponent implements OnInit {
31+
32+
static QNAME_DEPLOYMENT_TECHNOLOGY = QName.create(TOSCA_WINERY_EXTENSIONS_NAMESPACE, 'deployment-technology').qName;
33+
34+
@Input() readonly: boolean;
35+
@Input() deploymentTechnologies: DeploymentTechnology[];
36+
@Input() node: TNodeTemplate;
37+
38+
constructor(private ngRedux: NgRedux<IWineryState>,
39+
private ngActions: WineryActions,
40+
private backendService: BackendService) {
41+
}
42+
43+
ngOnInit() {
44+
this.backendService.requestSupportedDeploymentTechnologies().subscribe(value => this.deploymentTechnologies = value);
45+
}
46+
47+
isEllipsisActive(cell): boolean {
48+
return (cell.offsetWidth < cell.scrollWidth);
49+
}
50+
51+
isMember(dt: DeploymentTechnology) {
52+
const value = this.node.otherAttributes[AssignDeploymentTechnologyComponent.QNAME_DEPLOYMENT_TECHNOLOGY];
53+
return value && dt.id === value;
54+
}
55+
56+
toggleMembership(dt: DeploymentTechnology) {
57+
this.ngRedux.dispatch(this.ngActions.assignDeploymentTechnology(this.node, dt.id));
58+
}
59+
60+
isEmpty(): boolean {
61+
return !this.deploymentTechnologies || this.deploymentTechnologies.length === 0;
62+
}
63+
}

0 commit comments

Comments
 (0)