%--
/*******************************************************************************
* Copyright (c) 2012-2013 University of Stuttgart.
* 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:
* Uwe Breitenbücher - initial API and implementation and/or initial documentation
* Oliver Kopp - integration with the repository, adapted to TOSCA v1.0
* Yves Schubert - switch to bootstrap 3
*******************************************************************************/
--%>
<%@page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@page buffer="none" %>
<%@page import="java.util.Collection"%>
<%@page import="java.util.List"%>
<%@page import="java.util.LinkedList"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.SortedSet"%>
<%@page import="javax.xml.namespace.QName"%>
<%@page import="org.apache.commons.lang3.StringUtils"%>
<%@page import="org.eclipse.winery.model.tosca.TArtifactTemplate"%>
<%@page import="org.eclipse.winery.model.tosca.TArtifactType"%>
<%@page import="org.eclipse.winery.model.tosca.TCapability"%>
<%@page import="org.eclipse.winery.model.tosca.TCapabilityType"%>
<%@page import="org.eclipse.winery.model.tosca.TEntityTemplate"%>
<%@page import="org.eclipse.winery.model.tosca.TTopologyTemplate"%>
<%@page import="org.eclipse.winery.model.tosca.TNodeTemplate"%>
<%@page import="org.eclipse.winery.model.tosca.TNodeType"%>
<%@page import="org.eclipse.winery.model.tosca.TPolicyType"%>
<%@page import="org.eclipse.winery.model.tosca.TRelationshipType"%>
<%@page import="org.eclipse.winery.model.tosca.TRelationshipTemplate"%>
<%@page import="org.eclipse.winery.model.tosca.TRelationshipTemplate.SourceElement"%>
<%@page import="org.eclipse.winery.model.tosca.TRelationshipTemplate.TargetElement"%>
<%@page import="org.eclipse.winery.model.tosca.TRequirement"%>
<%@page import="org.eclipse.winery.model.tosca.TRequirementType"%>
<%@page import="org.eclipse.winery.common.constants.Namespaces" %>
<%@page import="org.eclipse.winery.common.ids.definitions.ArtifactTemplateId"%>
<%@page import="org.eclipse.winery.common.ids.definitions.ServiceTemplateId" %>
<%@page import="org.eclipse.winery.common.interfaces.QNameWithName"%>
<%@page import="org.eclipse.winery.common.constants.QNames" %>
<%@page import="org.eclipse.winery.common.ModelUtilities"%>
<%@page import="org.eclipse.winery.common.Util"%>
<%@page import="org.eclipse.winery.repository.client.WineryRepositoryClientFactory"%>
<%@page import="org.eclipse.winery.repository.client.IWineryRepositoryClient"%>
<%@page import="org.eclipse.winery.repository.client.WineryRepositoryClient"%>
<%@page import="org.eclipse.winery.topologymodeler.WineryUtil"%>
<%@page import="com.sun.jersey.api.client.WebResource"%>
<%@page import="com.sun.jersey.api.client.Client"%>
<%@page import="com.sun.jersey.api.client.ClientResponse"%>
<%@page import="com.sun.jersey.api.client.config.ClientConfig"%>
<%@page import="com.sun.jersey.api.client.config.DefaultClientConfig"%>
<%-- nc.. = non-common .. --%>
<%@taglib prefix="ncnt" tagdir="/WEB-INF/tags/templates/nodetemplates" %>
<%@taglib prefix="ncrt" tagdir="/WEB-INF/tags/templates/relationshiptemplates" %>
<%@taglib prefix="tntrq" tagdir="/WEB-INF/tags/templates/nodetemplates/reqscaps" %>
<%@taglib prefix="ct" tagdir="/WEB-INF/tags/common" %>
<%@taglib prefix="tmpl" tagdir="/WEB-INF/tags/common/templates" %>
<%@taglib prefix="nt" tagdir="/WEB-INF/tags/common/templates/nodetemplates" %>
<%@taglib prefix="ntrq" tagdir="/WEB-INF/tags/common/templates/nodetemplates/reqscaps" %>
<%@taglib prefix="pol" tagdir="/WEB-INF/tags/common/policies" %>
<%@taglib prefix="t" tagdir="/WEB-INF/tags" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="wc" uri="http://www.eclipse.org/winery/functions" %>
<%@taglib prefix="tc" tagdir="/WEB-INF/tags/common/topologycompletion"%>
<%
String repositoryURL = request.getParameter("repositoryURL");
if (StringUtils.isEmpty(repositoryURL)) {
repositoryURL = "http://localhost:8080/winery";
} else if (repositoryURL.endsWith("/")) {
repositoryURL = repositoryURL.substring(0, repositoryURL.length()-1);
}
String ns = request.getParameter("ns");
if (StringUtils.isEmpty(ns)) {
%>
A namespace has to be provided by using the query parameter “ns.” Please start the modeler using the repository.
<%
return;
}
String id = request.getParameter("id");
if (StringUtils.isEmpty(id)) {
%>
An id has to be provided by using the query parameter “id.” Please start the modeler using the repository.
<%
return;
}
// initialize client dependend on useproxy URL parameter
IWineryRepositoryClient client;
if (request.getParameterMap().containsKey("useproxy")) {
// debugging - using fiddler:
client = new WineryRepositoryClient(true);
System.out.println("Using a proxy...");
} else {
// production:
client = WineryRepositoryClientFactory.getWineryRepositoryClient();
}
client.addRepository(repositoryURL);
if (!client.primaryRepositoryAvailable()) {
%>
The repository is not available.
<%
return;
}
QName serviceTemplateQName = new QName(ns, id);
TTopologyTemplate topologyTemplate = client.getTopologyTemplate(serviceTemplateQName);
if (topologyTemplate == null) {
%>
Something went wrong in the repository: topology template not found.
<%
return;
}
String topologyTemplateURL = repositoryURL + "/servicetemplates/" + Util.DoubleURLencode(serviceTemplateQName) + "/topologytemplate/";
String serviceTemplateName = client.getName(new ServiceTemplateId(serviceTemplateQName));
Collection relationshipTypes = client.getAllTypes(TRelationshipType.class);
%>
Winery Topologymodeler – <%= serviceTemplateName %>
loading...
<%
// only required for generating the CSS for each node type
Collection allNodeTypes = client.getAllTypes(TNodeType.class);
%>
<%-- Begin: Add&Edit Req/Cap --%>
<%List allTypes = client.getQNameListOfAllTypes(TRequirementType.class);%>
<%allTypes = client.getQNameListOfAllTypes(TCapabilityType.class);%>
<%-- End: Add&Edit Req/Cap --%>
<%allTypes = client.getQNameListOfAllTypes(TPolicyType.class);%>
Artifact Information
<%
// we want to display the name of the artifact template, not the id
Collection artifactTemplateList = client.getListOfAllInstances(ArtifactTemplateId.class);
%>
<%-- confusing, because DELETE at this place in the management part deletes the whole entity, not just the selected one
--%>
<%
List templateList = topologyTemplate.getNodeTemplateOrRelationshipTemplate();
List relationshipTemplates = new LinkedList();
for (TEntityTemplate template: templateList) {
if (template instanceof TRelationshipTemplate) {
relationshipTemplates.add((TRelationshipTemplate) template);
} else {
TNodeTemplate nodeTemplate = (TNodeTemplate) template;
// Get saved position
// x and y are stored as attributes of other namespaces
String left = ModelUtilities.getLeft(nodeTemplate);
String top = ModelUtilities.getTop(nodeTemplate);
%>
<%
}
}
%>
<%-- ===== BEGIN: enable editing properties of requirements and capabilities ===== --%>
<%-- create property value holders for each requirement type; used for NEWLY created requirements --%>
{${type.targetNamespace}}${type.name}
<%-- create property value holders for each capability type; used for NEWLY created capability --%>
{${type.targetNamespace}}${type.name}
<%-- ===== END: enable editing properties of requirements and capabilities ===== --%>
<%-- ===== BEGIN: enable editing properties of relationship types ===== --%>
<%-- idea:
* create editor in skelettonContainerForRelationshipTemplates,
* move it to the properties for editing,
* and move it back to skelettonContainerForRelationshipTemplates after editing
--%>
<%-- create property value holders for each relationship type; used for NEWLY created relationship templates --%>
<%-- create property value holders for each existing relationship template; used for existing relationship templates--%>
<%-- data-id stores the id of the relationship template --%>