<% /******************************************************************************* * Copyright (c) 2013 Pascal Hirmer. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and the Apache License 2.0 which both accompany this distribution, * and are available at http://www.eclipse.org/legal/epl-v10.html * and http://www.apache.org/licenses/LICENSE-2.0 * * Contributors: * Pascal Hirmer - initial API and implementation *******************************************************************************/ %> <%@tag language="java" pageEncoding="UTF-8" description="This tag is used to render Topology Templates for selection in a dialog."%> <%-- attributes for the topology selection --%> <%@attribute name="templateURL" type="java.lang.String"%> <%@attribute name="topologyName" type="java.lang.String"%> <%@attribute name="topologyNamespace" type="java.lang.String"%> <%@attribute name="repositoryURL" type="java.lang.String" %> <%@attribute name="solutionTopologies" type="java.util.List"%> <%@tag import="java.io.StringWriter"%> <%@tag import="java.util.HashMap"%> <%@tag import="java.util.Map"%> <%@tag import="java.util.List"%> <%@tag import="java.util.UUID"%> <%@tag import="javax.xml.bind.Marshaller"%> <%@tag import="javax.xml.bind.JAXBContext"%> <%@tag import="javax.xml.bind.JAXBException"%> <%@tag import="javax.xml.namespace.QName"%> <%@tag import="org.eclipse.winery.model.tosca.Definitions"%> <%@tag import="org.eclipse.winery.model.tosca.TEntityTemplate"%> <%@tag import="org.eclipse.winery.model.tosca.TNodeTemplate"%> <%@tag import="org.eclipse.winery.model.tosca.TRelationshipTemplate"%> <%@tag import="org.eclipse.winery.model.tosca.TRelationshipType"%> <%@tag import="org.eclipse.winery.model.tosca.TServiceTemplate"%> <%@tag import="org.eclipse.winery.model.tosca.TTopologyTemplate"%> <%@tag import="org.eclipse.winery.repository.client.WineryRepositoryClientFactory"%> <%@tag import="org.eclipse.winery.repository.client.IWineryRepositoryClient"%> <%@tag import="org.eclipse.winery.common.Util"%> <%@taglib prefix="ntrq" tagdir="/WEB-INF/tags/common/templates/nodetemplates/reqscaps" %> <%@taglib prefix="nt" tagdir="/WEB-INF/tags/common/templates/nodetemplates"%>

There are several possible topology solutions
Please select your desired topology:

<% // the pixel distance between the displayed NodeTemplates final int NODE_TEMPLATE_DISTANCE = 150; List topologyTemplateSelector = solutionTopologies; int i = 0; int counter = 0; Map idMap; for (TTopologyTemplate choice: topologyTemplateSelector) { Definitions definitions = new Definitions(); TServiceTemplate st = new TServiceTemplate(); st.setTopologyTemplate(choice); definitions.getServiceTemplateOrNodeTypeOrNodeTypeImplementation().add(st); JAXBContext context = JAXBContext.newInstance(Definitions.class); Marshaller m = context.createMarshaller(); StringWriter stringWriter = new StringWriter(); m.marshal(definitions, stringWriter); int topCounter = 0; IWineryRepositoryClient client = WineryRepositoryClientFactory.getWineryRepositoryClient(); client.addRepository(repositoryURL); String id = "solution" + Integer.toString(i); String sourceId = null; idMap = new HashMap(); %>
<% for (TEntityTemplate entity: choice.getNodeTemplateOrRelationshipTemplate()) { if (entity instanceof TNodeTemplate) { TNodeTemplate nodeTemplate = (TNodeTemplate) entity; %> <% String randomId = UUID.randomUUID().toString(); %> <% topCounter = topCounter + NODE_TEMPLATE_DISTANCE; idMap.put(nodeTemplate.getId(), randomId); %> <% } } for (TEntityTemplate entity: choice.getNodeTemplateOrRelationshipTemplate()) { if (entity instanceof TRelationshipTemplate) { TRelationshipTemplate connector = (TRelationshipTemplate) entity; sourceId = ((TNodeTemplate) connector.getSourceElement().getRef()).getId(); String visualSourceId = idMap.get(sourceId); String targetId = ((TNodeTemplate) connector.getTargetElement().getRef()).getId(); String visualTargetId = idMap.get(targetId); QName type = connector.getType(); %> <% } } %>

Save this Topology     Overwrite current Topology     Open in new Window

Name:

Namespace:

<% counter++; i++; } %>