2 /*******************************************************************************
3 * Copyright (c) 2013-2014 University of Stuttgart.
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and the Apache License 2.0 which both accompany this distribution,
7 * and are available at http://www.eclipse.org/legal/epl-v10.html
8 * and http://www.apache.org/licenses/LICENSE-2.0
11 * Oliver Kopp - initial API and implementation and/or initial documentation
12 *******************************************************************************/
15 <%@tag pageEncoding="UTF-8"%>
17 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
18 <%@taglib prefix="bd" tagdir="/WEB-INF/tags/servicetemplates/boundarydefinitions" %>
20 <%@attribute name="definedPropertiesAsJSONString" required="true" %>
22 <div class="modal fade z1051" id="browseForServiceTemplatePropertyDiag" >
23 <div class="modal-dialog">
24 <div class="modal-content">
25 <div class="modal-header">
26 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
27 <h4 class="modal-title">Choose Property of Service Template</h4>
30 <div class="modal-body">
31 <p class="text-info">Please click on a node to select the element</p>
32 <div id='propertymappingstree'></div>
35 <div class="form-group">
36 <label for="newServiceTemplatePropertyRef">Reference to the property of the Service Template</label>
37 <input type="text" id="newServiceTemplatePropertyRef" class="form-control" />
43 <div class="modal-footer">
44 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
45 <button type="button" class="btn btn-primary" onclick="setServiceTemplatePropertyRef();">Set</button>
51 <%-- Browse for property --%>
53 The following cannot be used as we return TWO things: the template and the property
54 <bd:browseForX XShort="Property" XLong="Node Template, Relationship Template, or directly a property" />
56 <div class="modal fade z1051" id="browseForTemplateProperty">
57 <div class="modal-dialog" style="width:1000px;">
58 <div class="modal-content">
59 <div class="modal-header">
60 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
61 <h4 class="modal-title">Choose Node Template, Relationship Template, or directly a property</h4>
64 <div class="modal-body">
65 <p class="text-info">Please click on the desired element</p>
66 <iframe id="topologyTemplatePreview" class="topologyTemplatePreviewSizing" src="topologytemplate/?view=propertySelection&script=${pageContext.request.contextPath}/js/boundaryDefinitionsXSelection.js"></iframe>
69 <div class="form-group">
70 <label for="newObjectRef">Reference to the object in the topology template</label>
71 <input type="text" id="newObjectRef" class="form-control newObjectRef" /> <%-- newObjectRef required as --%>
73 <div class="form-group">
74 <label for="newObjectPropertyRef">Reference to the object's property</label>
75 <input type="text" id="newObjectPropertyRef" class="form-control" />
81 <div class="modal-footer">
82 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
83 <button type="button" class="btn btn-primary" onclick="setTemplateAndTemplatePropertyRef();">Set</button>
89 <bd:browseForReqOrCap label="Requirement" reqOrCap="Req" requirementsOrCapabilities="requirements"/>
90 <bd:browseForReqOrCap label="Capability" reqOrCap="Cap" requirementsOrCapabilities="capabilities"/>
93 //global variable to hold the reference to the input field where the selection of the service template property should be written into
94 //Requried as both a property mapping and a property constraint refer to a property of the service template.
95 var fieldToWriteSelectedServiceTemplateProperty;
97 function setServiceTemplatePropertyRef() {
98 fieldToWriteSelectedServiceTemplateProperty.val($("#newServiceTemplatePropertyRef").val());
99 $("#browseForServiceTemplatePropertyDiag").modal("hide");
102 function browseForServiceTemplateProperty(field) {
103 fieldToWriteSelectedServiceTemplateProperty = field;
104 $("#newServiceTemplatePropertyRef").val(field.val());
105 $("#browseForServiceTemplatePropertyDiag").modal("show");
110 * Opens topology and lets user select a node template, relationship template,
112 function browseForTemplateAndProperty() {
113 $("#newObjectRef").val($("#targetObjectRef").val());
114 $("#newObjectPropertyRef").val($("#targetPropertyRef").val());
115 $("#browseForTemplateProperty").modal("show");
118 function setTemplateAndTemplatePropertyRef() {
119 $("#targetObjectRef").val($("#newObjectRef").val());
120 // always copy over targetPropertyRef, even if it's empty
121 $("#targetPropertyRef").val($("#newObjectPropertyRef").val());
123 $("#browseForTemplateProperty").modal("hide");
126 <c:if test="${not empty definedPropertiesAsJSONString}">
127 // initialize the xmltree of the service template properties
128 // xmltree has to be inialized once and not more than once
129 // Therefore, we put it here and not in some shown events
130 require(["xmltree"], function(xmltree) {
132 xml: '${definedPropertiesAsJSONString}',
133 container: '#propertymappingstree',
134 startCollapsed: false,
135 clickCallback: serviceTemplatePropertyClicked
140 function serviceTemplatePropertyClicked(li, xpath, event) {
141 require(["winery-support"], function(ws) {
142 var pathFragmentRegExp = ws.QName_RegExp + "(.*)";
143 var pathFragmentPattern = new RegExp(pathFragmentRegExp);
145 // Transform the XPath to an XPath being namespace unaware
146 // This is required as the OpenTOSCA container does not implement XPath processing in a namespace-aware manner
147 var fragments = xpath.split("/");
149 $(fragments).each(function(i,e) {
150 var res = pathFragmentPattern.exec(e);
152 if (typeof res[1] !== undefined) {
153 e = "*[local-name()='" + res[3] + "']" + res[5];
158 xpath = path.join("/");
160 $("#newServiceTemplatePropertyRef").val(xpath);
164 /* communication with the iframe is at boundarydefinitions.jsp as we also need it for "Interfaces" */