Skip to content

Commit

Permalink
Merge branch 'main' into ustutt
Browse files Browse the repository at this point in the history
  • Loading branch information
lharzenetter committed Jan 16, 2023
2 parents 1205cc0 + 20277f5 commit 130443b
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 19 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ You are solely responsible for determining the appropriateness of using or redis
## Acknowledgements

The initial code contribution has been supported by the Federal Ministry for Economic Affairs and Energy as part of the [CloudCycle] project (01MD11023).
Current development is supported by the [Federal Ministry for Economic Affairs and Climate Action] as part of the [PlanQK] project (01MK20005N), the [DFG] (Deutsche Forschungsgemeinschaft) project [ReSUS] (425911815), as well as the DFG’s Excellence Initiative project [SimTech] (EXC 2075 - 390740016).
Current development is supported by the [Federal Ministry for Economic Affairs and Climate Action] as part of the [PlanQK] project (01MK20005N), the [DFG] (Deutsche Forschungsgemeinschaft) projects [ReSUS] (425911815) and [IAC²] (314720630), as well as the DFG’s Excellence Initiative project [SimTech] (EXC 2075 - 390740016).
Additional development has been funded by the Federal Ministry for Economic Affairs and Energy projects [SmartOrchestra] (01MD16001F) and [SePiA.Pro] (01MD16013F), as well as by the DFG projects [SustainLife] (641730) and [ADDCompliance] (636503).
Further development is also funded by the European Union’s Horizon 2020 project [RADON] (825040).

Expand Down Expand Up @@ -88,3 +88,4 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
[PlanQK]: https://planqk.de
[SimTech]: https://www.simtech.uni-stuttgart.de/
[ReSUS]: https://www.iaas.uni-stuttgart.de/en/projects/resus/
[IAC²]: https://www.iaas.uni-stuttgart.de/forschung/projekte/iacc/
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019-2021 Contributors to the Eclipse Foundation
* Copyright (c) 2019-2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand Down Expand Up @@ -40,6 +40,7 @@
import org.eclipse.winery.model.tosca.TRelationshipType;
import org.eclipse.winery.model.tosca.TRelationshipTypeImplementation;
import org.eclipse.winery.model.tosca.TServiceTemplate;
import org.eclipse.winery.model.tosca.TTopologyTemplate;
import org.eclipse.winery.model.tosca.extensions.OTParticipant;
import org.eclipse.winery.model.tosca.utils.ModelUtilities;

Expand Down Expand Up @@ -86,22 +87,26 @@ public EdmmConverter(Map<QName, TNodeType> nodeTypes, Map<QName, TRelationshipTy
}

public EntityGraph transform(TServiceTemplate serviceTemplate) {
assert serviceTemplate.getTopologyTemplate() != null;
return this.transform(serviceTemplate.getTopologyTemplate(), ModelUtilities.getOwnerParticipantOfServiceTemplate(serviceTemplate));
}

public EntityGraph transform(TTopologyTemplate topology, String ownerParticipant) {
EntityGraph entityGraph = new EntityGraph();

setMetadata(entityGraph);
List<TNodeTemplate> nodeTemplates = topology.getNodeTemplates();
List<TRelationshipTemplate> relationshipTemplates = topology.getRelationshipTemplates();

List<TNodeTemplate> nodeTemplates = serviceTemplate.getTopologyTemplate().getNodeTemplates();
List<TRelationshipTemplate> relationshipTemplates = serviceTemplate.getTopologyTemplate().getRelationshipTemplates();
if (!nodeTemplates.isEmpty()) {
entityGraph.addEntity(new MappingEntity(EntityGraph.COMPONENTS, entityGraph));
}

nodeTemplates.forEach(nodeTemplate -> createNode(nodeTemplate, entityGraph));
relationshipTemplates.forEach(relationship -> createRelation(relationship, entityGraph));
List<OTParticipant> participants = topology.getParticipants();

List<OTParticipant> participants = serviceTemplate.getTopologyTemplate().getParticipants();
if (participants != null && !participants.isEmpty()) {
entityGraph.addEntity(new ScalarEntity(ModelUtilities.getOwnerParticipantOfServiceTemplate(serviceTemplate), EntityGraph.OWNER, entityGraph));
if (participants != null && !participants.isEmpty() && ownerParticipant != null) {
entityGraph.addEntity(new ScalarEntity(ownerParticipant, EntityGraph.OWNER, entityGraph));
entityGraph.addEntity(new MappingEntity(EntityGraph.PARTICIPANTS, entityGraph));
participants.forEach(participant -> createParticipant(participant, nodeTemplates, entityGraph));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2012-2022 Contributors to the Eclipse Foundation
* Copyright (c) 2012-2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand Down Expand Up @@ -85,6 +85,7 @@
import org.eclipse.winery.model.tosca.TRelationshipTypeImplementation;
import org.eclipse.winery.model.tosca.TServiceTemplate;
import org.eclipse.winery.model.tosca.TTag;
import org.eclipse.winery.model.tosca.TTopologyTemplate;
import org.eclipse.winery.model.tosca.utils.ModelUtilities;
import org.eclipse.winery.repository.backend.BackendUtils;
import org.eclipse.winery.repository.backend.IRepository;
Expand Down Expand Up @@ -294,8 +295,7 @@ public static Response getYamlCSARofSelectedResource(final AbstractComponentInst
return Response.ok().header("Content-Disposition", contentDisposition).type(MimeTypes.MIMETYPE_ZIP).entity(so).build();
}

public static EntityGraph getEdmmEntityGraph(TServiceTemplate element, boolean useAbsolutPaths) {

private static EdmmConverter createEdmmConverter(boolean useAbsolutPaths) {
IRepository repository = RepositoryFactory.getRepository();

Map<QName, TNodeType> nodeTypes = repository.getQNameToElementMapping(NodeTypeId.class);
Expand All @@ -312,15 +312,34 @@ public static EntityGraph getEdmmEntityGraph(TServiceTemplate element, boolean u
throw new IllegalStateException("No Relationship Types defined!");
}

EdmmConverter edmmConverter = new EdmmConverter(nodeTypes, relationshipTypes, nodeTypeImplementations, relationshipTypeImplementations, artifactTemplates, oneToOneMappings, useAbsolutPaths);
return new EdmmConverter(nodeTypes, relationshipTypes, nodeTypeImplementations, relationshipTypeImplementations, artifactTemplates, oneToOneMappings, useAbsolutPaths);
}

public static EntityGraph getEdmmEntityGraph(TServiceTemplate element, boolean useAbsolutPaths) {
EdmmConverter converter = createEdmmConverter(useAbsolutPaths);

return edmmConverter.transform(element);
return converter.transform(element);
}

public static Response getEdmmModel(TServiceTemplate element, boolean useAbsolutPaths) {
public static EntityGraph getEdmmEntityGraph(TTopologyTemplate topology, boolean useAbsolutePaths) {
EdmmConverter converter = createEdmmConverter(useAbsolutePaths);

return converter.transform(topology, null);
}

public static Response getEdmmModel(TTopologyTemplate element, boolean useAbsolutPaths) {
EntityGraph transform = getEdmmEntityGraph(element, useAbsolutPaths);

return getEdmmModelAsYamlResponse(transform);
}

public static Response getEdmmModel(TServiceTemplate element, boolean useAbsolutPaths) {
EntityGraph transform = getEdmmEntityGraph(element, useAbsolutPaths);

return getEdmmModelAsYamlResponse(transform);
}

private static Response getEdmmModelAsYamlResponse(EntityGraph transform) {
StringWriter stringWriter = new StringWriter();
transform.generateYamlOutput(stringWriter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.eclipse.winery.model.tosca.TInterface;
import org.eclipse.winery.model.tosca.TOperation;
import org.eclipse.winery.model.tosca.TServiceTemplate;
import org.eclipse.winery.model.tosca.TTopologyTemplate;
import org.eclipse.winery.repository.backend.IRepository;
import org.eclipse.winery.repository.backend.RepositoryFactory;
import org.eclipse.winery.repository.rest.RestUtils;
Expand Down Expand Up @@ -84,12 +85,23 @@ public class EdmmResource {
private static final String LIFECYCLE_NAME = "http://opentosca.org/interfaces/lifecycle";
private static final String[] LIFECYCLE = {"create", "configure", "start", "stop", "delete"};

private final TServiceTemplate element;
private final TTopologyTemplate element;

public EdmmResource(TServiceTemplate element) {
this(element.getTopologyTemplate());
}

public EdmmResource(TTopologyTemplate element) {
this.element = element;
}

@GET
@Path("export")
@Produces()
public Response exportEdmm(@QueryParam(value = "edmmUseAbsolutePaths") String edmmUseAbsolutePaths) {
return RestUtils.getEdmmModel(this.element, edmmUseAbsolutePaths != null);
}

@GET
@Path("supportedTechnologies")
@Produces(MediaType.APPLICATION_JSON)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012-2021 Contributors to the Eclipse Foundation
* Copyright (c) 2012-2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand Down Expand Up @@ -75,6 +75,7 @@
import org.eclipse.winery.repository.rest.resources.apiData.PropertyDiffList;
import org.eclipse.winery.repository.rest.resources.apiData.QNameApiData;
import org.eclipse.winery.repository.rest.resources.apiData.UpdateInfo;
import org.eclipse.winery.repository.rest.resources.edmm.EdmmResource;
import org.eclipse.winery.repository.splitting.Splitting;
import org.eclipse.winery.repository.targetallocation.Allocation;
import org.eclipse.winery.repository.targetallocation.util.AllocationRequest;
Expand Down Expand Up @@ -174,6 +175,11 @@ public Response mergeWithOtherTopologyTemplate(String strOtherServiceTemplateQNa
return Response.noContent().build();
}

@Path("edmm")
public EdmmResource getTopologyTemplateAsEdmm() {
return new EdmmResource(this.topologyTemplate);
}

@Path("nodetemplates/")
public NodeTemplatesResource getNodeTemplatesResource() {
// FIXME: onDelete will not work as we have a copy of the original list. We have to add a "listener" to remove at the list and route that remove to the original list
Expand Down Expand Up @@ -253,7 +259,7 @@ public Response split(@Context UriInfo uriInfo) {
ResourceResult result = new ResourceResult();
result.setStatus(Response.Status.CREATED);
result.setMessage(new QNameApiData(splitServiceTemplateId));

return result.getResponse();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2022-2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand All @@ -26,7 +26,6 @@
import org.eclipse.winery.repository.rest.resources.AbstractResourceTest;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down

0 comments on commit 130443b

Please sign in to comment.