aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml15
-rw-r--r--src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java6
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java52
-rw-r--r--src/main/java/org/onap/clamp/clds/transform/XslTransformer.java3
-rw-r--r--src/main/java/org/onap/clamp/clds/util/XmlTools.java57
-rwxr-xr-xsrc/main/java/org/onap/clamp/clds/util/drawing/AwtUtils.java71
-rwxr-xr-xsrc/main/java/org/onap/clamp/clds/util/drawing/ClampGraph.java43
-rwxr-xr-xsrc/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java64
-rw-r--r--src/main/java/org/onap/clamp/clds/util/drawing/DocumentBuilder.java55
-rw-r--r--src/main/java/org/onap/clamp/clds/util/drawing/ImageBuilder.java135
-rw-r--r--src/main/java/org/onap/clamp/clds/util/drawing/InvalidStateException.java30
-rwxr-xr-xsrc/main/java/org/onap/clamp/clds/util/drawing/Painter.java91
-rw-r--r--src/main/java/org/onap/clamp/clds/util/drawing/RectTypes.java28
-rw-r--r--src/main/java/org/onap/clamp/clds/util/drawing/SvgFacade.java48
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopController.java8
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopService.java2
-rw-r--r--src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java7
-rw-r--r--src/main/resources/META-INF/resources/designer/index.html3
-rw-r--r--src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html24
-rw-r--r--src/main/resources/META-INF/resources/designer/partials/portfolios/Template_model.html100
-rw-r--r--src/main/resources/META-INF/resources/designer/partials/portfolios/global_properties.html58
-rw-r--r--src/main/resources/META-INF/resources/designer/partials/portfolios/tosca_model_properties.html16
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js159
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js23
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/GlobalPropertiesCtrl.js15
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/ImportSchemaCtrl.js7
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js34
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/ToscaModelService.js7
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js172
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/app.js26
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/common_variables.js1
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/menuHandler.js81
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/propertyController.js124
-rw-r--r--src/main/resources/clds/camel/rest/clamp-api-v2.xml15
-rw-r--r--src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImplTest.java155
-rw-r--r--src/test/java/org/onap/clamp/clds/util/XmlToolsTest.java72
-rw-r--r--src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java90
-rw-r--r--src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphTest.java77
-rw-r--r--src/test/java/org/onap/clamp/clds/util/drawing/DocumentBuilderTest.java80
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java4
-rw-r--r--src/test/resources/clds/util/file.xml6
41 files changed, 1516 insertions, 548 deletions
diff --git a/pom.xml b/pom.xml
index bb59a882..b2952621 100644
--- a/pom.xml
+++ b/pom.xml
@@ -221,6 +221,21 @@
</dependencyManagement>
<dependencies>
+ <dependency>
+ <groupId>org.apache.xmlgraphics</groupId>
+ <artifactId>batik-svggen</artifactId>
+ <version>1.11</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xmlgraphics</groupId>
+ <artifactId>batik-svg-dom</artifactId>
+ <version>1.11</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xmlgraphics</groupId>
+ <artifactId>batik-transcoder</artifactId>
+ <version>1.11</version>
+ </dependency>
<dependency>
<groupId>com.att.eelf</groupId>
<artifactId>eelf-core</artifactId>
diff --git a/src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java b/src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java
index 1fb86c0c..3f1403f1 100644
--- a/src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java
+++ b/src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java
@@ -17,6 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END============================================
+ * * Modifications copyright (c) 2019 Nokia
* ===================================================================
*
*/
@@ -92,11 +93,6 @@ public class CldsSdcControllerConfiguration {
});
}
- @Bean(name = "csarInstaller")
- public CsarInstaller getCsarInstaller() {
- return new CsarInstallerImpl();
- }
-
@Bean(name = "sdcControllersConfiguration")
public SdcControllersConfiguration getSdcControllersConfiguration() {
return new SdcControllersConfiguration();
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
index 1303f2ab..a4ae14d0 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
@@ -17,6 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END============================================
+ * Modifications copyright (c) 2019 Nokia
* ===================================================================
*
*/
@@ -26,19 +27,16 @@ package org.onap.clamp.clds.sdc.controller.installer;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.google.gson.JsonObject;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-
import java.util.Optional;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.xml.transform.TransformerException;
-
import org.apache.commons.io.IOUtils;
import org.json.simple.parser.ParseException;
import org.onap.clamp.clds.client.DcaeInventoryServices;
@@ -55,9 +53,11 @@ import org.onap.clamp.clds.service.CldsService;
import org.onap.clamp.clds.service.CldsTemplateService;
import org.onap.clamp.clds.transform.XslTransformer;
import org.onap.clamp.clds.util.JsonUtils;
+import org.onap.clamp.clds.util.drawing.SvgFacade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.yaml.snakeyaml.Yaml;
@@ -66,6 +66,7 @@ import org.yaml.snakeyaml.Yaml;
* There is no state kept by the bean. It's used to deploy the csar/notification
* received from SDC in DB.
*/
+@Component
public class CsarInstallerImpl implements CsarInstaller {
private static final EELFLogger logger = EELFManager.getInstance().getLogger(CsarInstallerImpl.class);
@@ -80,25 +81,34 @@ public class CsarInstallerImpl implements CsarInstaller {
*/
@Value("${clamp.config.sdc.blueprint.parser.mapping:'classpath:/clds/blueprint-parser-mapping.json'}")
protected String blueprintMappingFile;
- @Autowired
protected ApplicationContext appContext;
- @Autowired
private CldsDao cldsDao;
- @Autowired
CldsTemplateService cldsTemplateService;
- @Autowired
CldsService cldsService;
- @Autowired
DcaeInventoryServices dcaeInventoryService;
- @Autowired
private XslTransformer cldsBpmnTransformer;
@Autowired
+ public CsarInstallerImpl(ApplicationContext appContext,
+ CldsDao cldsDao, CldsTemplateService cldsTemplateService, CldsService cldsService,
+ DcaeInventoryServices dcaeInventoryService, XslTransformer cldsBpmnTransformer) {
+ this.appContext = appContext;
+ this.cldsDao = cldsDao;
+ this.cldsTemplateService = cldsTemplateService;
+ this.cldsService = cldsService;
+ this.dcaeInventoryService = dcaeInventoryService;
+ this.cldsBpmnTransformer = cldsBpmnTransformer;
+ }
+
+ @Autowired
private BlueprintParser blueprintParser;
@Autowired
private ChainGenerator chainGenerator;
+ @Autowired
+ private SvgFacade svgFacade;
+
@PostConstruct
public void loadConfiguration() throws IOException {
BlueprintParserMappingConfiguration
@@ -154,16 +164,7 @@ public class CsarInstallerImpl implements CsarInstaller {
}
}
- private void createPolicyModel(CsarHandler csar) throws PolicyModelException {
- try{
- Optional<String> policyModelYaml = csar.getPolicyModelYaml();
- // save policy model into the database
- } catch (IOException e) {
- throw new PolicyModelException("TransformerException when decoding the YamlText", e);
- }
- }
-
- private BlueprintParserFilesConfiguration searchForRightMapping(BlueprintArtifact blueprintArtifact)
+ BlueprintParserFilesConfiguration searchForRightMapping(BlueprintArtifact blueprintArtifact)
throws SdcArtifactInstallerException {
List<BlueprintParserFilesConfiguration> listConfig = new ArrayList<>();
Yaml yaml = new Yaml();
@@ -202,6 +203,15 @@ public class CsarInstallerImpl implements CsarInstaller {
return node.toString();
}
+ private void createPolicyModel(CsarHandler csar) throws PolicyModelException {
+ try{
+ Optional<String> policyModelYaml = csar.getPolicyModelYaml();
+ // save policy model into the database
+ } catch (IOException e) {
+ throw new PolicyModelException("TransformerException when decoding the YamlText", e);
+ }
+ }
+
private static String searchForPolicyScopePrefix(BlueprintArtifact blueprintArtifact)
throws SdcArtifactInstallerException {
String policyName = null;
@@ -255,7 +265,7 @@ public class CsarInstallerImpl implements CsarInstaller {
if(microServicesChain.isEmpty()) {
microServicesChain = blueprintParser.fallbackToOneMicroService(blueprintArtifact.getDcaeBlueprint());
}
- //place where SVG text will be generated
+ String imageText = svgFacade.getSvgImage(microServicesChain);
CldsTemplate template = new CldsTemplate();
template.setBpmnId("Sdc-Generated");
@@ -264,7 +274,7 @@ public class CsarInstallerImpl implements CsarInstaller {
template.setPropText(
"{\"global\":[{\"name\":\"service\",\"value\":[\"" + blueprintArtifact.getDcaeBlueprint() + "\"]}]}");
template
- .setImageText(IOUtils.toString(appContext.getResource(configFiles.getSvgXmlFilePath()).getInputStream()));
+ .setImageText(imageText);
template.setName(TEMPLATE_NAME_PREFIX + buildModelName(csar, blueprintArtifact));
template.save(cldsDao, null);
logger.info("Fake Clds Template created for blueprint " + blueprintArtifact.getBlueprintArtifactName()
diff --git a/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java b/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java
index 5886e019..a8f233e4 100644
--- a/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java
+++ b/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java
@@ -23,6 +23,7 @@
package org.onap.clamp.clds.transform;
+import com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl;
import java.io.StringReader;
import java.io.StringWriter;
@@ -45,7 +46,7 @@ public class XslTransformer {
private Templates templates;
public void setXslResourceName(String xslResourceName) throws TransformerConfigurationException {
- TransformerFactory tfactory = TransformerFactory.newInstance();
+ TransformerFactory tfactory = new TransformerFactoryImpl();
tfactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
tfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
templates = tfactory.newTemplates(new StreamSource(ResourceFileUtil.getResourceAsStream(xslResourceName)));
diff --git a/src/main/java/org/onap/clamp/clds/util/XmlTools.java b/src/main/java/org/onap/clamp/clds/util/XmlTools.java
new file mode 100644
index 00000000..391f0087
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/util/XmlTools.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.util;
+
+import java.io.StringWriter;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import org.apache.batik.anim.dom.SVGDOMImplementation;
+import org.apache.batik.dom.GenericDOMImplementation;
+import org.apache.batik.util.SVGConstants;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+
+public class XmlTools {
+ public static String exportXmlDocumentAsString(Document doc) {
+ try {
+ TransformerFactory tf = TransformerFactory.newInstance();
+ Transformer transformer = tf.newTransformer();
+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ StringWriter writer = new StringWriter();
+ transformer.transform(new DOMSource(doc), new StreamResult(writer));
+ return writer.getBuffer().toString();
+ } catch (TransformerException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ public static Document createEmptySvgDocument() {
+ DOMImplementation domImplementation = GenericDOMImplementation.getDOMImplementation();
+ String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
+ return domImplementation.createDocument(svgNS, SVGConstants.SVG_SVG_TAG, null);
+ }
+}
diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/AwtUtils.java b/src/main/java/org/onap/clamp/clds/util/drawing/AwtUtils.java
new file mode 100755
index 00000000..f746ab14
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/util/drawing/AwtUtils.java
@@ -0,0 +1,71 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.util.drawing;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics2D;
+import java.awt.Point;
+import java.awt.Rectangle;
+
+public class AwtUtils {
+ private static final int ARROW_W = 4;
+ private static final int ARROW_H = 2;
+ private static final int FONT_SIZE = 12;
+ private static final int FONT_STYLE = Font.PLAIN;
+ private static final String FONT_FACE = "SansSerif";
+ private static final Color TRANSPARENT = new Color(0.0f, 0.0f,0.0f,0.0f);
+
+ static void rectWithText(Graphics2D g2d, String text, Point p, int w, int h) {
+ Rectangle rect = new Rectangle(p.x, p.y, w, h);
+ g2d.draw(rect);
+ Color oldColor = g2d.getColor();
+ g2d.setColor(TRANSPARENT);
+ g2d.fill(rect);
+ g2d.setColor(oldColor);
+ addText(g2d, text, p.x+w/2, p.y+h/2);
+ }
+
+ static void drawArrow(Graphics2D g2d, Point from, Point to, int lineThickness) {
+ int x2 = to.x - lineThickness;
+ g2d.drawLine(from.x, from.y, x2-lineThickness, to.y);
+ g2d.drawPolygon(new int[] {x2-ARROW_W, x2-ARROW_W, x2},new int[] {to.y- ARROW_H, to.y+ ARROW_H, to.y},3);
+ g2d.fillPolygon(new int[] {x2-ARROW_W, x2-ARROW_W, x2},new int[] {to.y- ARROW_H, to.y+ ARROW_H, to.y},3);
+ }
+
+ private static void addText(Graphics2D g2d, String text, int x, int y) {
+ Font f = new Font(FONT_FACE, FONT_STYLE, FONT_SIZE);
+ g2d.setFont(f);
+
+ FontMetrics fm1 = g2d.getFontMetrics();
+ int w1 = fm1.stringWidth(text);
+ int x1 = x - (w1 / 2);
+
+ g2d.setFont(f);
+ g2d.setColor(Color.BLACK);
+ g2d.drawString(text, x1, y);
+ }
+
+}
diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraph.java b/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraph.java
new file mode 100755
index 00000000..f49e735e
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraph.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.util.drawing;
+
+import java.util.Objects;
+import org.onap.clamp.clds.util.XmlTools;
+
+public class ClampGraph {
+ private final DocumentBuilder documentBuilder;
+ private String svg;
+
+ ClampGraph(DocumentBuilder documentBuilder) {
+ this.documentBuilder = documentBuilder;
+ }
+
+ public String getAsSVG() {
+ if(Objects.isNull(svg) || svg.isEmpty()) {
+ svg = XmlTools.exportXmlDocumentAsString(this.documentBuilder.getGroupingDocument());
+ }
+ return svg;
+ }
+}
diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java b/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java
new file mode 100755
index 00000000..243cb4aa
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.util.drawing;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+public class ClampGraphBuilder {
+ private String policy;
+ private String collector;
+ private List<String> microServices = new ArrayList<>();
+ private final Painter painter;
+
+ public ClampGraphBuilder(Painter painter) {
+ this.painter = painter;
+ }
+
+ public ClampGraphBuilder collector(String c) {
+ collector = c;
+ return this;
+ }
+
+ public ClampGraphBuilder policy(String p) {
+ policy = p;
+ return this;
+ }
+
+ public ClampGraphBuilder microService(String ms) {
+ microServices.add(ms);
+ return this;
+ }
+
+ public ClampGraph build() {
+ if(microServices.isEmpty()) {
+ throw new InvalidStateException("At least one microservice is required");
+ }
+ if(Objects.isNull(policy) || policy.trim().isEmpty()) {
+ throw new InvalidStateException("Policy element must be present");
+ }
+ return new ClampGraph(painter.doPaint(collector, microServices, policy));
+ }
+}
diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/DocumentBuilder.java b/src/main/java/org/onap/clamp/clds/util/drawing/DocumentBuilder.java
new file mode 100644
index 00000000..f34eaf2e
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/util/drawing/DocumentBuilder.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.util.drawing;
+
+import org.apache.batik.svggen.SVGGraphics2D;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class DocumentBuilder {
+ private final Document groupingDocument;
+ private final Document documentFactory;
+
+ static final String DATA_ELEMENT_ID_ATTRIBUTE = "data-element-id";
+
+ DocumentBuilder(Document groupingDocument, Document documentFactory) {
+ this.groupingDocument = groupingDocument;
+ this.documentFactory = documentFactory;
+ }
+
+ void pushChangestoDocument(SVGGraphics2D g2d, String dataElementId) {
+ Element element =
+ this.documentFactory.createElementNS(SVGGraphics2D.SVG_NAMESPACE_URI,
+ SVGGraphics2D.SVG_G_TAG);
+ element.setAttribute(DATA_ELEMENT_ID_ATTRIBUTE, dataElementId);
+ g2d.getRoot(element);
+ Node node = this.groupingDocument.importNode(element, true);
+ this.groupingDocument.getDocumentElement().appendChild(node);
+ }
+
+ Document getGroupingDocument() {
+ return groupingDocument;
+ }
+}
diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/ImageBuilder.java b/src/main/java/org/onap/clamp/clds/util/drawing/ImageBuilder.java
new file mode 100644
index 00000000..4d76581c
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/util/drawing/ImageBuilder.java
@@ -0,0 +1,135 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.util.drawing;
+
+import java.awt.BasicStroke;
+import java.awt.Point;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.geom.Ellipse2D;
+import java.util.UUID;
+import org.apache.batik.svggen.SVGGraphics2D;
+
+public class ImageBuilder {
+
+ public static final int POLICY_LINE_RATIO = 2;
+ public static final int COLLECTOR_LINE_RATIO = 6;
+ public static final float MS_LINE_TO_HEIGHT_RATIO = 0.75f;
+
+ private Point currentPoint;
+ private final int baseLength;
+ private final int rectHeight;
+ private final SVGGraphics2D g2d;
+ private final DocumentBuilder documentBuilder;
+
+ private static final int LINE_THICKNESS = 2;
+ private static final int CIRCLE_RADIUS = 17;
+
+ ImageBuilder(SVGGraphics2D svgGraphics2D, DocumentBuilder documentBuilder,
+ Point startingPoint, int baseLength, int rectHeight) {
+ this.g2d = svgGraphics2D;
+ this.documentBuilder = documentBuilder;
+ this.currentPoint = new Point(startingPoint);
+ this.baseLength = baseLength;
+ this.rectHeight = rectHeight;
+ }
+
+ ImageBuilder rectangle(String dataElementId, RectTypes rectType, String text) {
+ Point next = new Point(currentPoint.x + baseLength, currentPoint.y);
+ Point p = coordinatesForRectangle(currentPoint, next);
+
+ handleBasedOnRectType(rectType, text, p, baseLength, rectHeight);
+
+ documentBuilder.pushChangestoDocument(g2d, dataElementId);
+ currentPoint = next;
+ return this;
+ }
+
+ ImageBuilder arrow() {
+ String dataElementId = "Arrow-" + UUID.randomUUID().toString();
+ Point to = new Point(currentPoint.x + baseLength, currentPoint.y);
+ AwtUtils.drawArrow(g2d, currentPoint, to, LINE_THICKNESS);
+ documentBuilder.pushChangestoDocument(g2d, dataElementId);
+ currentPoint = to;
+ return this;
+ }
+
+ ImageBuilder circle(String dataElementId, int lineThickness) {
+ Point to = new Point(currentPoint.x + 2 * CIRCLE_RADIUS, currentPoint.y);
+ Shape circleStart =
+ new Ellipse2D.Double(currentPoint.x, currentPoint.y - CIRCLE_RADIUS,
+ 2 * CIRCLE_RADIUS, 2 * CIRCLE_RADIUS);
+
+ Stroke oldStroke = g2d.getStroke();
+ g2d.setStroke(new BasicStroke(lineThickness));
+ g2d.draw(circleStart);
+ g2d.setStroke(oldStroke);
+ documentBuilder.pushChangestoDocument(g2d, dataElementId);
+ currentPoint = to;
+ return this;
+ }
+
+ DocumentBuilder getDocumentBuilder() {
+ return documentBuilder;
+ }
+
+ private void handleBasedOnRectType(RectTypes rectType, String text, Point p, int w, int h) {
+ AwtUtils.rectWithText(g2d, text, p, w, h);
+ switch (rectType) {
+ case COLECTOR:
+ drawVerticalLineForCollector(p, w, h);
+ break;
+ case MICROSERVICE:
+ drawHorizontalLineForMicroService(p, w, h);
+ break;
+ case POLICY:
+ drawDiagonalLineForPolicy(p, w, h);
+ break;
+ }
+ }
+
+ private void drawVerticalLineForCollector(Point p, int w, int h) {
+ g2d.drawLine(p.x + w / COLLECTOR_LINE_RATIO, p.y, p.x + w / COLLECTOR_LINE_RATIO, p.y + h);
+ }
+
+ private void drawHorizontalLineForMicroService(Point p, int w, int h) {
+ int y = calculateMsHorizontalLineYCoordinate(p,h);
+ g2d.drawLine(p.x, y, p.x + w, y);
+ }
+
+ private void drawDiagonalLineForPolicy(Point p, int w, int h) {
+ g2d.drawLine(p.x, p.y + h / POLICY_LINE_RATIO, p.x + w / POLICY_LINE_RATIO, p.y);
+ }
+
+ private int calculateMsHorizontalLineYCoordinate(Point p, int h) {
+ return (int)(p.y * h * MS_LINE_TO_HEIGHT_RATIO);
+ }
+
+ private Point coordinatesForRectangle(Point from, Point next) {
+ int x = from.x;
+ int y = from.y - next.y + LINE_THICKNESS / 2;
+ return new Point(x,y);
+ }
+
+}
diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/InvalidStateException.java b/src/main/java/org/onap/clamp/clds/util/drawing/InvalidStateException.java
new file mode 100644
index 00000000..91af9f1a
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/util/drawing/InvalidStateException.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.util.drawing;
+
+public class InvalidStateException extends RuntimeException {
+ public InvalidStateException(String message) {
+ super(message);
+ }
+}
diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java b/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java
new file mode 100755
index 00000000..e41ca8fb
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.util.drawing;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Point;
+import java.awt.RenderingHints;
+import java.util.List;
+import org.apache.batik.svggen.SVGGraphics2D;
+
+public class Painter {
+ private final int canvasSize;
+ private final SVGGraphics2D g2d;
+ private final DocumentBuilder documentBuilder;
+
+ private static final int DEFALUT_CANVAS_SIZE = 900;
+ private static final int SLIM_LINE = 2;
+ private static final int THICK_LINE = 4;
+ private static final double RECT_RATIO = 3.0 / 2.0;
+ private static final int CIRCLE_RADIUS = 17;
+
+ public Painter(SVGGraphics2D svgGraphics2D, DocumentBuilder documentBuilder) {
+ this.g2d = svgGraphics2D;
+ this.documentBuilder = documentBuilder;
+ this.canvasSize = DEFALUT_CANVAS_SIZE;
+ }
+
+ DocumentBuilder doPaint(String collector, List<String> microServices, String policy) {
+ int numOfRectangles = 2 + microServices.size();
+ int numOfArrows = numOfRectangles + 1;
+ int baseLength = (canvasSize - 2 * CIRCLE_RADIUS) / (numOfArrows + numOfRectangles);
+ int rectHeight = (int) (baseLength / RECT_RATIO);
+
+ adjustGraphics2DProperties();
+
+ Point origin = new Point(0, rectHeight / 2);
+ ImageBuilder ib = new ImageBuilder(g2d, documentBuilder, origin, baseLength, rectHeight);
+
+ doTheActualDrawing(collector, microServices, policy, ib);
+
+ return ib.getDocumentBuilder();
+ }
+
+ private void doTheActualDrawing(String collector, List<String> microServices, String policy, ImageBuilder ib) {
+ ib.circle("start-circle", SLIM_LINE)
+ .arrow()
+ .rectangle(collector, RectTypes.COLECTOR, collector);
+
+ for(String ms : microServices) {
+ ib.arrow().rectangle(ms, RectTypes.MICROSERVICE, ms);
+ }
+
+ ib.arrow()
+ .rectangle(policy, RectTypes.POLICY, policy)
+ .arrow()
+ .circle("stop-circle", THICK_LINE);
+ }
+
+ private void adjustGraphics2DProperties() {
+ g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
+ RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
+ RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
+ g2d.setStroke(new BasicStroke(SLIM_LINE));
+ g2d.setPaint(Color.BLACK);
+ }
+
+
+}
diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/RectTypes.java b/src/main/java/org/onap/clamp/clds/util/drawing/RectTypes.java
new file mode 100644
index 00000000..e6932432
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/util/drawing/RectTypes.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.util.drawing;
+
+enum RectTypes {
+ COLECTOR, MICROSERVICE, POLICY
+} \ No newline at end of file
diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/SvgFacade.java b/src/main/java/org/onap/clamp/clds/util/drawing/SvgFacade.java
new file mode 100644
index 00000000..0ba84863
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/util/drawing/SvgFacade.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.util.drawing;
+
+import java.util.List;
+import org.apache.batik.svggen.SVGGraphics2D;
+import org.onap.clamp.clds.sdc.controller.installer.MicroService;
+import org.onap.clamp.clds.util.XmlTools;
+import org.springframework.stereotype.Component;
+import org.w3c.dom.Document;
+
+@Component
+public class SvgFacade {
+ public String getSvgImage(List<MicroService> microServicesChain) {
+ SVGGraphics2D svgGraphics2D = new SVGGraphics2D(XmlTools.createEmptySvgDocument());
+ Document document = XmlTools.createEmptySvgDocument();
+ DocumentBuilder dp = new DocumentBuilder(document, svgGraphics2D.getDOMFactory());
+ Painter p = new Painter(svgGraphics2D, dp);
+ ClampGraphBuilder cgp = new ClampGraphBuilder(p).collector("VES");
+ for(MicroService ms : microServicesChain) {
+ cgp = cgp.microService(ms.getName());
+ }
+ ClampGraph cg = cgp.policy("Policy").build();
+ return cg.getAsSVG();
+ }
+
+}
diff --git a/src/main/java/org/onap/clamp/loop/LoopController.java b/src/main/java/org/onap/clamp/loop/LoopController.java
index eeb6105b..7e451749 100644
--- a/src/main/java/org/onap/clamp/loop/LoopController.java
+++ b/src/main/java/org/onap/clamp/loop/LoopController.java
@@ -25,15 +25,16 @@ package org.onap.clamp.loop;
import com.google.gson.JsonArray;
import com.google.gson.reflect.TypeToken;
+
import java.lang.reflect.Type;
import java.util.List;
+
import org.onap.clamp.clds.util.JsonUtils;
import org.onap.clamp.policy.microservice.MicroServicePolicy;
import org.onap.clamp.policy.operational.OperationalPolicy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
-
@Controller
public class LoopController {
@@ -67,4 +68,9 @@ public class LoopController {
.fromJson(microServicePoliciesJson, MICROSERVICE_POLICY_TYPE);
return loopService.updateMicroservicePolicies(loopName, microservicePolicies);
}
+
+ public String getSVGRepresentation(String loopName) {
+ return loopService.getClosedLoopModelSVG(loopName);
+
+ }
}
diff --git a/src/main/java/org/onap/clamp/loop/LoopService.java b/src/main/java/org/onap/clamp/loop/LoopService.java
index 7b79c112..91b4bdf8 100644
--- a/src/main/java/org/onap/clamp/loop/LoopService.java
+++ b/src/main/java/org/onap/clamp/loop/LoopService.java
@@ -47,7 +47,7 @@ public class LoopService {
this.operationalPolicyService = operationalPolicyService;
}
- Loop addNewLoop(Loop loop) {
+ Loop saveOrUpdateLoop(Loop loop) {
return loopsRepository.save(loop);
}
diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
index e5b333db..7ebe0edb 100644
--- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
+++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
@@ -39,9 +39,9 @@ import javax.persistence.Table;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
+import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
import org.onap.clamp.loop.Loop;
import org.onap.clamp.policy.Policy;
-import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
@Entity
@Table(name = "micro_service_policies")
@@ -66,7 +66,6 @@ public class MicroServicePolicy implements Serializable, Policy {
@Column(name = "shared", nullable = false)
private Boolean shared;
- @Expose
@Column(name = "policy_tosca", nullable = false)
private String policyTosca;
@@ -79,7 +78,7 @@ public class MicroServicePolicy implements Serializable, Policy {
private Set<Loop> usedByLoops = new HashSet<>();
public MicroServicePolicy() {
- //serialization
+ // serialization
}
public MicroServicePolicy(String name, String policyTosca, Boolean shared, JsonObject jsonRepresentation,
@@ -91,6 +90,7 @@ public class MicroServicePolicy implements Serializable, Policy {
this.usedByLoops = usedByLoops;
}
+ @Override
public String getName() {
return name;
}
@@ -119,6 +119,7 @@ public class MicroServicePolicy implements Serializable, Policy {
this.policyTosca = policyTosca;
}
+ @Override
public JsonObject getJsonRepresentation() {
return jsonRepresentation;
}
diff --git a/src/main/resources/META-INF/resources/designer/index.html b/src/main/resources/META-INF/resources/designer/index.html
index 5d1e5304..e30d7245 100644
--- a/src/main/resources/META-INF/resources/designer/index.html
+++ b/src/main/resources/META-INF/resources/designer/index.html
@@ -180,6 +180,7 @@
<!-- dialog box ctl end -->
<script src="scripts/aOnBoot.js"></script>
-
+ <script src="scripts/propertyController.js"></script>
+ <script src="scripts/menuHandler.js"></script>
</body>
diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html
index 182dab8d..0da01535 100644
--- a/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html
+++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html
@@ -372,7 +372,6 @@ label {
var num = add_one_more();
setMultiSelect();
});
- loadPropertyWindow("policy")
// by default, parentPolicyConditions is disabled
//$("#parentPolicyConditions").prop('disabled', 'disabled');
@@ -383,7 +382,7 @@ label {
var allPolIds=[];
//Grab saved values for dropdowns
- var obj = elementMap[lastElementSelected];
+ var obj = getOperationalPolicyProperty();
var loadPolicy;
console.log("lastElementSelected :"+ lastElementSelected);
if (!($.isEmptyObject(obj))){
@@ -425,6 +424,7 @@ label {
console.log("number is=:" + num);
loadingId=false;
for (var j = 0; j < el[i].length; j++) {
+ console.log("attr:" + el[i][j].name + "; value is:" + el[i][j].value);
if(el[i][j].hasOwnProperty("name")){
$("#formId" + num + " #" + el[i][j].name).val(
el[i][j].value);
@@ -563,11 +563,13 @@ label {
console.log("save properties; add tableVal to policies: "+ tableVal);
});
- saveProperties(finalSaveList);
+ saveOpPolicyProperties(finalSaveList);
$("#close_button").click();
})
function add_one_more() {
+ console.log("add one more");
+ setPolicyOptions();
$("#nav_Tabs li").removeClass("active");
//FormSpan contains a block of the form that is not being displayed. We will create clones of that and add them to tabs
@@ -767,9 +769,10 @@ label {
}
function startNextItem() {
- console.log("start next Item");
+ console.log("start next Item, policyname is:" + $("#pname").val());
//save last item before transitioning
var lastItem = $("#policyTable .highlight");
+ console.log("start next Item, lastitem is:" + lastItem);
if (lastItem.length > 0) {
console.log("start next Item length > 0");
saveLastPolicyLocally($("#pname").val());
@@ -777,22 +780,20 @@ label {
lastItem.find("td").html($("#pname").val());
}
}
-
+
function add_new_policy(issueNewNames) {
+ console.log("add new policy");
//remove old gui forms
for (var i=1; i<($(".formId").length + 1); i++){
$("#go_properties_tab"+i).parent().remove();
}
$(".formId").remove();
-
- //Reset headers
- //$("#pname").val("0");
$("#pname").val("New_Policy");
- $("#timeout").val(defaults_props.policy.timeout);
-
+ $("#timeout").val(getOperationalPolicyProperty().timeout);
+
$("#add_one_more").click();
}
-
+ console.log("start next Item on 796");
startNextItem();
if (("#policyTable .highlight").length > 0){
@@ -804,7 +805,6 @@ label {
setASDCFields();
initTargetResourceId();
-
//load metrics dropdown
if (elementMap["global"]) {
for (var i = 0; i < (elementMap["global"].length); i++){
diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/Template_model.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/Template_model.html
deleted file mode 100644
index 0ca4e7ca..00000000
--- a/src/main/resources/META-INF/resources/designer/partials/portfolios/Template_model.html
+++ /dev/null
@@ -1,100 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- ONAP CLAMP
- ================================================================================
- Copyright (C) 2017 AT&T Intellectual Property. All rights
- reserved.
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ============LICENSE_END============================================
- ===================================================================
-
- -->
-
-<div attribute-test="templatemodel" id="configure-widgets" >
- <div attribute-test="templatemodelh" class="modal-header">
- <button type="button" class="close" ng-click="close(false)" aria-hidden="true" style="margin-top: -3px">&times;</button>
- <h4>'Template'</h4>
- </div>
- <div class="modal-body" style="height: 280px">
- <div style="height: 10px">
- </div>
- <form id="saveProps" name="t" class="form-horizontal">
-
- <div>
- <div class="form-group">
- <label for="schemaLocation" class="col-sm-4 control-label">ID</label>
-
- <div class="col-sm-8">
- <input class="form-control" type="text" focus="true" name="_id" id="_id" readonly>
- <div hidden id="warnings_">Special Characters are not allowed in template id.</span> <!-- <span ng-show="nameinUse" style="color: red"> Model Name Already In Use</span> --></div>
- </input>
- </div>
- </div>
- </div>
- </form>
- </div>
- <div attribute-test="templatemodelf" class="modal-footer">
- <button id="savePropsBtn" class="btn btn-primary" ng-disabled="t._id.$error.pattern" >Close</button>
- <button ng-click="close(true)" id="close_button" class="btn btn-primary">Cancel</button>
-
- </div>
- <script>
- loadPropertyWindow("template");
- var el=elementMap[lastElementSelected];
- //console.log(el)
- //console.log(lastElementSelected)
- //$("#id").val("lolololol")
- // $('.modal-header > h4').html($('.djs-visual > text').val());
- if(el!==undefined){
-
- for(var i=0;i<el.length;i++){
- console.log(el.length)
- console.log(el[i].name)
- console.log(el[i].value)
- $("#"+el[i].name).val(el[i].value);
- }
- }
- $("#_id").keyup(function(){
- var pattern=/^\s*[\w\-]*\s*$/
- if( !pattern.test($(this).val()) && !$(this).is("[disabled]")){
- $("#savePropsBtn").attr("disabled","");
- $("#warnings_").removeAttr("hidden")
- console.log("remove hidden")
- }
- else{
- //console.log($(this).is("[disabled]"))
- console.log("add hidden ")
- if($("#savePropsBtn").is("[disabled]")){
- $("#savePropsBtn").removeAttr("disabled");
- $("#warnings_").attr("hidden", "");
- console.log("add hidden if")
- }
-
- }
- })
-
- $("#saveProps").on('submit', function (event) {
- //console.log(lastElementSelected)
- saveProperties($(this).serializeArray())
- event.preventDefault();
- $("#close_button").click();
- })
-
- $("#savePropsBtn").click(function (event) {
- $("#saveProps").submit();
- })
-</script>
-</div>
-
-
diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/global_properties.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/global_properties.html
index c47e90a4..e7b4f383 100644
--- a/src/main/resources/META-INF/resources/designer/partials/portfolios/global_properties.html
+++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/global_properties.html
@@ -46,31 +46,6 @@
</a> / <a href="javascript:void(0);" class="btn-link" id='paramsCancel'>Cancel</a>
</div>
<div>
-
- <div class="form-group clearfix">
- <label for="actionSet" class="col-sm-4 control-label">
- Action Set</label>
-
- <div class="col-sm-8">
- <select class="form-control" id="actionSet" name="actionSet"
- onchange="propChangeAlert(this);">
- </select>
-
- </div>
- </div>
-
- <div class="form-group clearfix">
- <label for="location" class="col-sm-4 control-label">
- Location</label>
-
- <div class="col-sm-8">
- <select class="form-control" id="location" name="location"
- multiple size=2>
-
- </select>
-
- </div>
- </div>
<div class="form-group clearfix">
<label for="deployParameters" class="col-sm-4 control-label">
Deploy Parameters</label>
@@ -99,37 +74,4 @@
class="btn btn-primary">Cancel</button>
</div>
-
-
- <script>
- //display message only if global was previously saved
- asDiff = false;
-
- function propChangeAlert(actionset) {
- //throw warnings only if options were previously chosen
- if (elementMap["global"]) {
- loop1: for (var i = 0; i < elementMap["global"].length; i++) {
- if (elementMap["global"][i]["name"] == actionset.id) {
- //user did not change properties
- if (elementMap["global"][i]["value"][0] == actionset.value) {
- if (elementMap["global"][i]["name"] == "actionSet") {
- asDiff = false;
- }
- if (!asDiff) {
- $(".propChangeWarn").hide();
- }
- ;
- //user changed properties
- } else {
- if (elementMap["global"][i]["name"] == "actionSet") {
- asDiff = true;
- };
- $(".propChangeWarn").show();
- }
- break loop1;
- }
- }
- }
- }
- </script>
</div>
diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/tosca_model_properties.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/tosca_model_properties.html
index b053b24e..271def43 100644
--- a/src/main/resources/META-INF/resources/designer/partials/portfolios/tosca_model_properties.html
+++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/tosca_model_properties.html
@@ -48,18 +48,7 @@
href="javascript:void(0)" class="btn-link" id='paramsRetry'>Retry
</a> / <a href="javascript:void(0)" class="btn-link" id='paramsCancel'>Cancel</a>
</div>
- <div class="form-group clearfix" data-ng-if="policytypes">
- <label for="policytypes" class="col-sm-4 control-label">
- Policy Types<span id="locationErr"
- style="display: none; color: red;">&nbsp;*Required*</span>
- </label>
- <div class="col-sm-8">
- <select class="form-control" id="policytype" data-ng-change = "jsonByPolicyType(selectedHPPolicy, '{{selectedHPPolicy}}', '')" data-ng-model ="$parent.selectedHPPolicy">
- <option data-ng-repeat="pt in policytypes" value="{{pt}}">{{pt}}</option>
- </select>
- </div>
- </div>
</form>
<div class="alert alert-warning propChangeWarn" style="display: none;">
<strong>Warning!</strong> Property changes will reset all associated
@@ -73,8 +62,9 @@
</div>
</div>
</div>
-</div>
-<div class="modal-footer">
+ <div class="modal-footer">
<button data-ng-click="saveToscaProps()" id="savePropsBtn" class="btn btn-primary">Done</button>
<button data-ng-click="close(true)" id="close_button" class="btn btn-primary">Cancel</button>
+ </div>
</div>
+
diff --git a/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js b/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js
index 62ab5ab2..8a6981cb 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js
@@ -102,12 +102,14 @@ app
return def.promise;
};
this.getModel = function(modelName) {
-
var def = $q.defer();
var sets = [];
- var svcUrl = "/restservices/clds/v1/clds/model/" + modelName;
+ var svcUrl = "/restservices/clds/v2/loop/" + modelName;
+ //var svcUrl = "/restservices/clds/v1/clds/model/" + modelName;
$http.get(svcUrl).success(function(data) {
-
+ //var clModel = '{"name": "ClosedLoopTest","lastComputedState":"DESIGN","svgRepresentation": "representation","globalPropertiesJson": [{"name":"service","value":["4cc5b45a-1f63-4194-8100-cd8e14248c92"]},{"name":"vf","value":["07e266fc-49ab-4cd7-8378-ca4676f1b9ec"]},{"name":"actionSet","value":["vnfRecipe"]},{"name":"location","value":["DC1"]},{"name":"deployParameters","value":{"location_id":"","service_id":"","policy_id":"AUTO_GENERATED_POLICY_ID_AT_SUBMIT"}}], "blueprint": "yaml","lastComputedState": "DESIGN","operationalPolicies": [ {"name": "OpPolicyTest", "configurationsJson": { "policy1": [{"name": "pname","value": "policy1"},{"name": "pid","value": "0"},{"name": "timeout","value": "345"},{"policyConfigurations": [[{"name": "recipe","value": ["restart"]},{"name": "maxRetries","value": ["3"]},{"name": "retryTimeLimit","value": ["180"]},{"name": "_id","value": ["6TtHGPq"]},{"name": "parentPolicy","value": [""]},{"name": "actor","value": ["APPC"]},{"name": "recipeInput","value": [""]},{"name": "recipeLevel","value": ["VM"]},{"name": "targetResourceId","value": ["07e266fc-49ab-4cd7-8378-ca4676f1b9ec"]},{"name": "targetResourceIdOther","value": [""]},{"name": "enableGuardPolicy","value": ["on"]},{"name": "guardPolicyType","value": ["GUARD_YAML"]},{"name": "guardTargets","value": [".*"]},{"name": "minGuard","value": ["1"]},{"name": "maxGuard","value": ["1"]},{"name": "limitGuard","value": ["1"]},{"name": "timeUnitsGuard","value": ["minute"]},{"name": "timeWindowGuard","value": ["10"]},{"name": "guardActiveStart","value": ["00:00:01-05:00"]},{"name": "guardActiveEnd","value": ["00:00:00-05:00"]}]]}]} }],"microServicePolicies": [{"name": "tca","properties": "", "shared": true,"policyTosca": "tosca","jsonRepresentation": {"schema":{"title":"DCAE TCA Config","type":"object","required":["name","eventName"],"properties":{"name":{"propertyOrder":101,"title":"Name","type":"string","default":"New_Set"},"eventName":{"propertyOrder":102,"title":"EventName","type":"string","enum":["event1","event2"]},"clSchemaType":{"propertyOrder":103,"title":"Control Loop Schema Type","type":"string","enum":["","type1","type2"]},"threshold":{"propertyOrder":104,"title":"Threshold","format":"tabs","type":"array","items":{"type":"object","title":"Threshold","required":["metric","operator"],"properties":{"metric":{"propertyOrder":1001,"title":"Metric","type":"string","enum":["metric1","metric2"]},"operator":{"propertyOrder":1003,"default":">","title":"Operator","type":"string","enum":[">","<","=","<=",">="]}, "clEventStatus":{"propertyOrder":1004,"title":"Closed Loop Event Status","type":"string","enum":["","ONSET","ABATED"]}}}}}}}}],"loopLogs": [{ } ] }';
+ //cl_props = JSON.parse(clModel);
+ cl_props = data;
def.resolve(data);
}).error(function(data) {
@@ -119,7 +121,8 @@ app
var def = $q.defer();
var sets = [];
- var svcUrl = "/restservices/clds/v1/clds/model-names";
+ //var svcUrl = "/restservices/clds/v1/clds/model-names";
+ var svcUrl = "/restservices/clds/v2/loop/getAllNames";
$http.get(svcUrl).success(function(data) {
def.resolve(data);
@@ -201,35 +204,13 @@ app
});
return def.promise;
};
- this.checkPermittedActionCd = function(permittedActionCd, menuText,
- actionCd) {
-
- if (permittedActionCd.indexOf(actionCd) > -1) {
- document.getElementById(menuText).classList.remove('ThisLink');
- } else {
- document.getElementById(menuText).classList.add('ThisLink');
- }
- };
- this.processActionResponse = function(modelName, pars) {
+ this.processActionResponse = function(modelName) {
// populate control name (prefix and uuid here)
- var controlNamePrefix = pars.controlNamePrefix;
- var controlNameUuid = pars.controlNameUuid;
- deploymentId = pars.deploymentId;
- var modelEventService = pars.modelEventService;
- typeID = pars.typeId;
var headerText = "Closed Loop Modeler - " + modelName;
- if (controlNameUuid != null) {
- var actionCd = pars.event.actionCd;
- var actionStateCd = pars.event.actionStateCd;
- headerText = headerText + " [" + controlNamePrefix
- + controlNameUuid + "]";
- }
- document.getElementById("modeler_name").textContent = headerText;
- document.getElementById("templa_name").textContent = ("Template Used - " + selected_template);
- setStatus(pars)
- disableBPMNAddSVG(pars);
- this.enableDisableMenuOptions(pars);
+ setStatus();
+ manageCLImage(modelName);
+ enableDisableMenuOptions();
};
this.processRefresh = function(pars) {
@@ -239,13 +220,12 @@ app
}
typeID = newPars.typeId;
deploymentId = newPars.deploymentId;
- setStatus(newPars);
- this.enableDisableMenuOptions(newPars);
- elementMap = JSON.parse(newPars.propText);
+ setStatus();
+ enableDisableMenuOptions();
}
- function setStatus(pars) {
+ function setStatus() {
- var status = pars.status;
+ var status = getStatus();
// apply color to status
var statusColor = 'white';
if (status.trim() === "DESIGN") {
@@ -277,73 +257,48 @@ app
'<span id="status_clds" style="position: absolute; left: 61%;top: 151px; font-size:20px;">Status: '
+ statusMsg + '</span>');
}
- function disableBPMNAddSVG(pars) {
-
- var svg = pars.imageText.substring(pars.imageText.indexOf("<svg"))
- if ($("#svgContainer").length > 0)
- $("#svgContainer").remove();
- $("#js-canvas").append(
- "<span id=\"svgContainer\">" + svg + "</span>");
- /* added code for height width viewBox */
- $("#svgContainer svg").removeAttr("height");
- $("#svgContainer svg").removeAttr('viewBox');
- $("#svgContainer svg").removeAttr('width');
- $("#svgContainer svg").attr('width', '100%');
- $("#svgContainer svg").attr('height', '100%');
- $("#svgContainer").click(
- function(event) {
-
- // console.log($(event.target).parent().html())
- // console.log($($(event.target).parent()).attr("data-element-id"))
- var name = $($(event.target).parent()).attr("data-element-id")
- lastElementSelected = $($(event.target).parent()).attr(
- "data-element-id")
- checkIfElementType(name)
- });
+ function manageCLImage(modelName) {
+ getModelImage(modelName).then(function(pars) {
+ //var svg=' <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" color-interpolation="auto" color-rendering="auto" fill="black" fill-opacity="1" font-family="Dialog" font-size="12px" font-style="normal" font-weight="normal" image-rendering="auto" shape-rendering="auto" stroke="black" stroke-dasharray="none" stroke-dashoffset="0" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="10" stroke-opacity="1" stroke-width="1" text-rendering="auto"><!--Generated by the Batik Graphics2D SVG Generator--> <defs id="genericDefs"/> <g> <g stroke-width="2"> <circle cx="20" cy="21" fill="none" r="10"/> <line fill="none" x1="30" x2="91" y1="21" y2="21"/> <polygon fill="none" points=" 89 19 89 23 93 21"/> <polygon points=" 89 19 89 23 93 21" stroke="none"/> <g class="djs-group" xmlns="http://www.w3.org/2000/svg"> <g class="djs-element djs-shape" data-element-id="VesCollector_1g9cmz0" transform="matrix(1,0,0,1,207,140)" style="display: block;"> <rect fill="none" class="djs-outline" x="-6" y="-6" width="132" height="92"></rect> <g > <rect x="0" y="0" width="120" height="80" rx="0" ry="0" style="stroke-width: 2;" stroke="#000000" fill="#ffffff"></rect> <polyline points="120,80 120,20 " style="stroke-width: 2;" fill="none" stroke="#000000"></polyline> <polyline points="20,0 20,80 " style="stroke-width: 2;" fill="none" stroke="#000000"></polyline> <text style="font-family: Arial,sans-serif; font-size: 12px;" class=" djs-label"> <tspan x="25.5" y="43.5">VesCollector</tspan> </text> </g> <rect x="0" y="0" width="120" height="80" style="stroke-opacity: 0; stroke-width: 15;" fill="none" stroke="#ffffff" class="djs-hit"></rect> </g> </g> <line fill="none" x1="105" x2="105" y1="1" y2="44"/> <line fill="none" x1="160" x2="221" y1="21" y2="21"/> <polygon fill="none" points=" 219 19 219 23 223 21"/> <polygon points=" 219 19 219 23 223 21" stroke="none"/> <g class="djs-element djs-shape" data-element-id="tca"> <rect fill="none" class="djs-outline" height="90" width="132" x="225" y="1"/> <rect x="230" y="6" width="120" height="80" rx="0" ry="0" style="stroke-width: 2;" stroke="#000000" fill="#ffffff"></rect> <text font-family="sans-serif" stroke="none" x="228" xml:space="preserve" y="22" >third_app</text> <line fill="none" x1="225" x2="290" y1="33" y2="33"/> <rect x="230" y="6" width="120" height="80" style="stroke-opacity: 0; stroke-width: 15;" fill="none" stroke="#ffffff" class="djs-hit"></rect> </g> <line fill="none" x1="290" x2="351" y1="21" y2="21"/> <polygon fill="none" points=" 349 19 349 23 353 21"/> <polygon points=" 349 19 349 23 353 21" stroke="none"/> <rect fill="none" height="43" id="first_app" width="65" x="355" y="1"/> <text font-family="sans-serif" stroke="none" x="360" xml:space="preserve" y="22" data-element-id="tca">first_app</text> <line fill="none" x1="355" x2="420" y1="33" y2="33"/> <line fill="none" x1="420" x2="481" y1="21" y2="21"/> <polygon fill="none" points=" 479 19 479 23 483 21"/> <polygon points=" 479 19 479 23 483 21" stroke="none"/> <rect fill="none" height="43" id="second_app" width="65" x="485" y="1"/> <text font-family="sans-serif" stroke="none" x="479" xml:space="preserve" y="22" data-element-id="tca">second_app</text> <line fill="none" x1="485" x2="550" y1="33" y2="33"/> <line fill="none" x1="550" x2="611" y1="21" y2="21"/> <polygon fill="none" points=" 609 19 609 23 613 21"/> <polygon points=" 609 19 609 23 613 21" stroke="none"/> <rect fill="none" height="43" id="policy" width="65" x="615" y="1"/> <text font-family="sans-serif" stroke="none" x="630" xml:space="preserve" y="22" data-element-id="policyc">Policy</text> <line fill="none" x1="615" x2="647" y1="22" y2="1"/> <line fill="none" x1="680" x2="741" y1="21" y2="21"/> <polygon fill="none" points=" 739 19 739 23 743 21"/> <polygon points=" 739 19 739 23 743 21" stroke="none"/> <circle cx="755" cy="21" fill="none" r="10" stroke-width="4"/> </g> </g> </svg>';
+ var svg = pars;
+ if ($("#svgContainer").length > 0)
+ $("#svgContainer").remove();
+ $("#js-canvas").append(
+ "<span id=\"svgContainer\">" + svg + "</span>");
+ /* added code for height width viewBox */
+ $("#svgContainer svg").removeAttr("height");
+ $("#svgContainer svg").removeAttr('viewBox');
+ $("#svgContainer svg").removeAttr('width');
+ $("#svgContainer svg").attr('width', '100%');
+ $("#svgContainer svg").attr('height', '100%');
+ $("#svgContainer").click(
+ function(event) {
+ console.log("svgContainer:" + $("#svgContainer svg"));
+ // console.log($(event.target).parent().html())
+ // console.log($($(event.target).parent()).attr("data-element-id"))
+ var name = $($(event.target).parent()).attr("data-element-id")
+ lastElementSelected = $($(event.target).parent()).attr(
+ "data-element-id")
+ checkIfElementType(name)
+ });
+ }, function(data) {
+ });
}
- this.enableDisableMenuOptions = function(pars) {
-
- var permittedActionCd = pars.permittedActionCd;
- // dropdown options - always true
- document.getElementById('Open CL').classList.remove('ThisLink');
- if (readMOnly) {
- // enable model options
- document.getElementById('Properties CL').classList
- .remove('ThisLink');
- document.getElementById('Close Model').classList
- .remove('ThisLink');
- // disable models options
- document.getElementById('Save CL').classList.add('ThisLink');
- document.getElementById('Revert Model Changes').classList
- .add('ThisLink');
- } else {
- // enable menu options
- document.getElementById('Save CL').classList.remove('ThisLink');
- document.getElementById('Properties CL').classList
- .remove('ThisLink');
- document.getElementById('Revert Model Changes').classList
- .remove('ThisLink');
- document.getElementById('Close Model').classList
- .remove('ThisLink');
- document.getElementById('Validation Test').classList
- .remove('ThisLink');
- document.getElementById('Refresh Status').classList
- .remove('ThisLink');
- }
- // enable/disable menu options based on permittedActionCd
- // list
- this.checkPermittedActionCd(permittedActionCd, 'Validation Test',
- 'TEST');
- this.checkPermittedActionCd(permittedActionCd, 'Submit', 'SUBMIT');
- this.checkPermittedActionCd(permittedActionCd, 'Resubmit',
- 'RESUBMIT');
- this.checkPermittedActionCd(permittedActionCd, 'Update', 'UPDATE');
- this.checkPermittedActionCd(permittedActionCd, 'Stop', 'STOP');
- this
- .checkPermittedActionCd(permittedActionCd, 'Restart', 'RESTART');
- this.checkPermittedActionCd(permittedActionCd, 'Delete', 'DELETE');
- this.checkPermittedActionCd(permittedActionCd, 'Deploy', 'DEPLOY');
- this.checkPermittedActionCd(permittedActionCd, 'UnDeploy',
- 'UNDEPLOY');
+ enableDisableMenuOptions = function() {
+ enableDefaultMenu();
+ //var status = getStatus();
+ //enableActionMenu(status);
+ enableAllActionMenu();
}
+ getModelImage = function(modelName) {
+ var def = $q.defer();
+ var sets = [];
+ var svcUrl = "/restservices/clds/v2/loop/svgRepresentation/" + modelName;
+ $http.get(svcUrl).success(function(data) {
+ def.resolve(data);
+ }).error(function(data) {
+ def.reject("Not able to get the model image");
+ });
+ return def.promise;
+ };
} ]);
diff --git a/src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js
index 111bb246..a1625a93 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js
@@ -52,11 +52,9 @@ function($scope, $rootScope, $modalInstance, $window, $uibModalInstance, cldsMod
$scope.paramsRetry = function() {
// $("#paramsWarn").hide();
$("#ridinSpinners").css("display", "")
- loadSharedPropertyByService(currentValue, true, callBack);
$("#ridinSpinners").css("display", "none")
};
$scope.paramsCancel = function() {
- loadSharedPropertyByServiceProperties(callBack);
$("#paramsWarnrefresh").hide();
};
function completeClose() {
@@ -143,28 +141,9 @@ function($scope, $rootScope, $modalInstance, $window, $uibModalInstance, cldsMod
utmModels.type = 'Model';
$rootScope.utmModels = utmModels;
cldsModelService.getModel(modelName).then(function(pars) {
- // process data returned
- var propText = pars.propText;
- var status = pars.status;
- controlNamePrefix = pars.controlNamePrefix;
- var authorizedToUp = pars.userAuthorizedToUpdate;
- typeID = pars.typeId;
- controlNameUuid = pars.controlNameUuid;
- selected_template = pars.templateName;
- modelEventService = pars.event;
- actionStateCd = pars.event.actionStateCd;
- deploymentId = pars.deploymentId;
- if (readMOnly) {
- pars.permittedActionCd = [ "" ];
- }
-
// deserialize model properties
- if (propText == null) {
- } else {
- elementMap = JSON.parse(propText);
- }
selected_model = modelName;
- cldsModelService.processActionResponse(modelName, pars);
+ cldsModelService.processActionResponse(modelName);
// set model bpmn and open diagram
$rootScope.isPalette = true;
}, function(data) {
diff --git a/src/main/resources/META-INF/resources/designer/scripts/GlobalPropertiesCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/GlobalPropertiesCtrl.js
index 2916f396..2ac959b4 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/GlobalPropertiesCtrl.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/GlobalPropertiesCtrl.js
@@ -32,9 +32,7 @@ function($scope, $rootScope, $uibModalInstance, cldsModelService, $location,
dialogs, cldsTemplateService) {
$scope.$watch('name', function(newValue, oldValue) {
- setASDCFields()
-
- var el = elementMap["global"];
+ var el = getGlobalProperty();
if (el !== undefined) {
for (var i = 0; i < el.length; i++) {
if (el[i].name === 'deployParameters')
@@ -66,16 +64,7 @@ function($scope, $rootScope, $uibModalInstance, cldsModelService, $location,
console.log("close");
$uibModalInstance.close("closed");
};
- $scope.convertDeployParametersJsonToString = function() {
- var index = elementMap["global"].findIndex(function(e) {
- return (typeof e == "object" && !(e instanceof Array))
- && "deployParameters" == e["name"];
- });
- if (index != -1) {
- $('#deployParameters').val(JSON.stringify(elementMap["global"][index].value));
- }
- }
-
+
function noRepeats(form) {
var select = {};
for (var i = 0; i < form.length; i++) {
diff --git a/src/main/resources/META-INF/resources/designer/scripts/ImportSchemaCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/ImportSchemaCtrl.js
index 2fa401b3..7fb0f446 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/ImportSchemaCtrl.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/ImportSchemaCtrl.js
@@ -47,9 +47,8 @@ function($scope, $rootScope, $uibModalInstance, data, svnservice, fileUpload,
$rootScope.updateServiceInputPartInfo;
$rootScope.updateSchemElemant1;
// Below code is added to get the policyNames
- for ( var polElement in elementMap) {
- if (polElement.indexOf('Policy_') === 0) {
- var obj = elementMap[polElement];
+ var policies = getOperationalPolicyProperty();
+ for ( var obj in policies) {
if (!($.isEmptyObject(obj))) {
allPolicies = jQuery.extend({}, obj);
$scope.policyNames = [];
@@ -57,8 +56,6 @@ function($scope, $rootScope, $uibModalInstance, data, svnservice, fileUpload,
$scope.policyNames.push(policy);
}
}
- break;
- }
}
setTimeout(function() {
console.log("setTimeout");
diff --git a/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js
index f78ad1e6..09a1d0ca 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js
@@ -24,15 +24,17 @@ app.controller('ToscaModelCtrl',
['$scope', '$rootScope', '$modalInstance', '$location', 'dialogs', 'toscaModelService',
function($scope, $rootScope, $modalInstance, $location, dialogs, toscaModelService) {
- $scope.jsonByPolicyType = function(selectedPolicy, oldSelectedPolicy, editorData){
+ $scope.jsonByPolicyType = function(selectedPolicy, oldSelectedPolicy){
if (selectedPolicy && selectedPolicy != '') {
- toscaModelService.getHpModelJsonByPolicyType(selectedPolicy).then(function(response) {
+
$('#editor').empty();
- var toscaModel = JSON.parse(response.toscaModelJson);
- if($scope.policyList && toscaModel.schema.properties && toscaModel.schema.properties.policyList){
- toscaModel.schema.properties.policyList.enum = $scope.policyList;
+ var toscaModel = getMsUI(selectedPolicy);
+ if (toscaModel == null) {
+ $modalInstance.close('closed');
+ return;
}
+ var editorData = getMsProperty(selectedPolicy);
JSONEditor.defaults.options.theme = 'bootstrap3';
JSONEditor.defaults.options.iconlib = 'bootstrap2';
@@ -51,22 +53,20 @@ app.controller('ToscaModelCtrl',
});
$('#form1').show();
- });
+
} else {
$('#editor').empty();
$('#form1').hide();
}
}
- if($rootScope.selectedBoxName) {
- var policyType = $rootScope.selectedBoxName.split('_')[0].toLowerCase();
- $scope.toscaModelName = policyType.toUpperCase() + " Microservice";
- if(elementMap[lastElementSelected]) {
- $scope.jsonByPolicyType(policyType, '', elementMap[lastElementSelected][policyType]);
- }else{
- $scope.jsonByPolicyType(policyType, '', '');
- }
- }
+ $scope.$watch('name', function() {
+ if($rootScope.selectedBoxName) {
+ var policyType = $rootScope.selectedBoxName.split('_')[0].toLowerCase();
+ $scope.toscaModelName = policyType.toUpperCase() + " Microservice";
+ $scope.jsonByPolicyType(policyType, '', '');
+ }
+ });
$scope.getEditorData = function(){
if(!$scope.editor){
@@ -90,8 +90,7 @@ app.controller('ToscaModelCtrl',
var data = $scope.getEditorData();
if(data !== null) {
- data = {[policyType]: data};
- saveProperties(data);
+ saveMsProperties(policyType,data);
if($scope.editor) { $scope.editor.destroy(); $scope.editor = null; }
$modalInstance.close('closed');
}
@@ -109,7 +108,6 @@ app.controller('ToscaModelCtrl',
};
$scope.close = function(){
- angular.copy(elementMap[lastElementSelected], $scope.hpPolicyList);
$modalInstance.close('closed');
if($scope.editor) { $scope.editor.destroy(); $scope.editor = null; }
}
diff --git a/src/main/resources/META-INF/resources/designer/scripts/ToscaModelService.js b/src/main/resources/META-INF/resources/designer/scripts/ToscaModelService.js
index c99a4556..261a69c6 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/ToscaModelService.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/ToscaModelService.js
@@ -35,4 +35,11 @@ app.service('toscaModelService', ['alertService','$http', '$q', '$rootScope', fu
return response.data;
});
};
+ this.getMsProperties = function(policyType) {
+ setTimeout(function(){ alert("Hello"); }, 3000);
+ return getMsUI(policyType);
+ };
+
+
+
}]);
diff --git a/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js b/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js
index 2da505cf..347d7472 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js
@@ -37,76 +37,6 @@ function newElementProcessor(id) {
}
}
-function saveProperties(form) {
- elementMap[lastElementSelected] = form;
- totalJsonProperties = JSON.stringify(elementMap);
-
- //Take off the red border because the element has been edited
- if ($('g[data-element-id="' + lastElementSelected + '"]').length > 0) {
- var _idNode = $('g[data-element-id="' + lastElementSelected + '"]')
- _idNode.children("rect").each(function() {
- if ($(this).attr('class') === 'djs-outline-no-property-saved') {
- $(this).attr('class', "djs-outline")
- $(this).attr('fill', 'none')
- }
- });
- }
-}
-
-function saveGlobalProperties(form) {
- elementMap["global"] = form;
-}
-var isObject = function(a) {
- return (!!a) && (a.constructor === Object);
-};
-
-function loadPropertyWindow(type) {
- if (readMOnly) {
- if ($("#add_one_more").length == 1) {
- $("#add_one_more").off();
- $("#add_one_more").click(function(event) {
- event.preventDefault();
- })
- }
- $("input,#savePropsBtn").attr("disabled", "");
- $(".modal-body button").attr("disabled", "");
- ($("select:not([multiple])")).multiselect("disable");
- }
-
- var props = defaults_props[type];
-
- for (p in props) {
- if (isObject(props[p])) {
- var mySelect = $('#' + p);
- if (p == "operator") {
- $.each(props[p], function(val, text) {
- mySelect.append(
- $('<option></option>').val(val).html(val)
- );
- });
- } else {
- $.each(props[p], function(val, text) {
- mySelect.append(
- $('<option></option>').val(val).html(text)
- );
- });
- }
- } else {
- if (p == "pname") {
- var ms = new Date().getTime();
- props[p] = "Policy" + ms;
- }
- $("#" + p).val(props[p])
- }
- }
- setTimeout(function() {
- setMultiSelect(type);
- }, 100);
-
-
-
-}
-
function setMultiSelect() {
$("select").each(function(index, mySelect) {
@@ -141,58 +71,46 @@ function setMultiSelect() {
});
}
-function loadSharedPropertyByService(onChangeUUID, refresh, callBack) {
- setASDCFields()
-}
-
-function loadSharedPropertyByServiceProperties(callBack) {
- $.ajax({
- async: false,
- dataType: "json",
- url: '/restservices/clds/v1/clds/properties/',
- success: function(data) {
-
- setASDCFields();
- if (callBack && _.isFunction(callBack)) {
- callBack(true);
- }
- },
- error: function(s, a, err) {
- $('#servName').text($("#service option:selected").text());
- if (callBack && _.isFunction(callBack)) {
- callBack(false);
- }
- },
- timeout: 100000
-
- });
-}
-
-function setASDCFields() {
+function setPolicyOptions() {
+console.log("reset policy default options");
try {
- var location_values = defaults_props['global']['location'];
- if (location_values) {
- for (key in location_values) {
- if ($("#location").length > 0) {
- $("#location").append("<option value=\"" + key + "\">" + location_values[key] + "</opton>")
+ var actor_values = defaults_props['policy']['actor'];
+ if (actor_values) {
+ for (key in actor_values) {
+ if ($("#actor").length > 0) {
+ $("#actor").append("<option value=\"" + key + "\">" + actor_values[key] + "</opton>")
}
}
- $("#location").multiselect("rebuild");
+ $("#actor").multiselect("rebuild");
}
- var actionSet_values = defaults_props['global']['actionSet'];
- if (actionSet_values) {
- for (key in actionSet_values) {
- if ($("#actionSet").length > 0) {
- $("#actionSet").append("<option value=\"" + key + "\">" + actionSet_values[key] + "</opton>")
+ var recipe_values = defaults_props['policy']['vnfRecipe'];
+ if (recipe_values) {
+ for (key in recipe_values) {
+ if ($("#recipe").length > 0) {
+ $("#recipe").append("<option value=\"" + key + "\">" + recipe_values[key] + "</opton>")
}
}
- $("#actionSet").multiselect("rebuild");
+ $("#recipe").multiselect("rebuild");
}
- if ($("#location").length > 0 && !location_values) {
- showWarn();
+ var parentPolicyConditions_values = defaults_props['policy']['parentPolicyConditions'];
+ if (parentPolicyConditions_values) {
+ for (key in parentPolicyConditions_values) {
+ if ($("#parentPolicyConditions").length > 0) {
+ $("#parentPolicyConditions").append("<option value=\"" + key + "\">" + parentPolicyConditions_values[key] + "</opton>")
+ }
+ }
+ $("#parentPolicyConditions").multiselect("rebuild");
+ }
+ var timeUnitsGuard_values = defaults_props['policy']['timeUnitsGuard'];
+ if (timeUnitsGuard_values) {
+ for (key in timeUnitsGuard_values) {
+ if ($("#timeUnitsGuard").length > 0) {
+ $("#timeUnitsGuard").append("<option value=\"" + key + "\">" + timeUnitsGuard_values[key] + "</opton>")
+ }
+ }
+ $("#timeUnitsGuard").multiselect("rebuild");
}
-
function showWarn() {
$("#paramsWarn").show();
$('#servName').text($("#service option:selected").text());
@@ -203,6 +121,7 @@ function setASDCFields() {
}
+
//Typically used when opening a new model/template
function reloadDefaultVariables(isTemp) {
isTemplate = isTemp;
@@ -210,17 +129,18 @@ function reloadDefaultVariables(isTemp) {
}
$(window).on('load',function() {
- $.ajax({
- dataType: "json",
- url: '/restservices/clds/v1/clds/properties',
- success: function(data) {
- defaults_props = JSON.parse(data);
- },
- error: function(s, a, err) {
- console.log(err)
- console.log(s)
- console.log(a)
- },
- timeout: 100000
- });
+ $.ajax({
+ dataType: "json",
+ url: '/restservices/clds/v1/clds/properties',
+ success: function(data) {
+ defaults_props = JSON.parse(data);
+ },
+ error: function(s, a, err) {
+ console.log(err)
+ console.log(s)
+ console.log(a)
+ },
+ timeout: 100000
+ });
})
+
diff --git a/src/main/resources/META-INF/resources/designer/scripts/app.js b/src/main/resources/META-INF/resources/designer/scripts/app.js
index 100dda36..9ae2697e 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/app.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/app.js
@@ -232,7 +232,7 @@ function($scope, $rootScope, $timeout, dialogs) {
});
$scope.emptyMenuClick = function(value, name) {
- if ($rootScope.isNewClosed && name != "Save CL"
+ if ($rootScope.isNewClosed
&& name != "Close Model" && name != "Properties CL") {
saveConfirmationNotificationPopUp();
} else {
@@ -243,9 +243,6 @@ function($scope, $rootScope, $timeout, dialogs) {
$scope.saveConfirmationNotificationPopUp(function(data) {
if (data) {
- if ($rootScope.isNewClosed) {
- isSaveCheck("Save CL");
- }
$rootScope.isNewClosed = false;
} else {
return false;
@@ -266,15 +263,8 @@ function($scope, $rootScope, $timeout, dialogs) {
$scope.cldsClose();
} else if (name == "Open CL") {
$scope.cldsOpenModel();
- } else if (name == "Save CL") {
- $rootScope.isNewClosed = false;
- $scope.cldsPerformAction("SAVE");
- } else if (name == "Validation Test") {
- $scope.cldsPerformAction("TEST");
} else if (name == "Submit") {
$scope.cldsConfirmPerformAction("SUBMIT");
- } else if (name == "Resubmit") {
- $scope.cldsConfirmPerformAction("RESUBMIT");
} else if (name == "Update") {
$scope.cldsConfirmPerformAction("UPDATE");
} else if (name == "Delete") {
@@ -306,9 +296,6 @@ function($scope, $rootScope, $timeout, dialogs) {
link : "/cldsOpenModel",
name : "Open CL"
}, {
- link : "/cldsSaveModel",
- name : "Save CL"
- }, {
link : "/cldsOpenModelProperties",
name : "Properties CL"
}, {
@@ -319,17 +306,12 @@ function($scope, $rootScope, $timeout, dialogs) {
name : "Close Model"
} ],
"Manage" : [ {
- link : "/cldsTestActivate",
- name : "Validation Test"
- }, {
link : "/cldsSubmit",
name : "Submit"
}, {
- link : "/cldsResubmit",
- name : "Resubmit"
- }, {
- link : "/cldsUpdate",
- name : "Update"
+ // disabled for Dublin since Policy doesn't support updating in this release
+ // link : "/cldsUpdate",
+ // name : "Update"
}, {
link : "/cldsStop",
name : "Stop"
diff --git a/src/main/resources/META-INF/resources/designer/scripts/common_variables.js b/src/main/resources/META-INF/resources/designer/scripts/common_variables.js
index 02092d3f..826e1870 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/common_variables.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/common_variables.js
@@ -44,6 +44,7 @@ var isModelfrmClick = false;
var autoSaveRevision =-1;
var commandStackList = [];
+var cl_props=null
var defaults_props=null
var elementMap={}
var lastElementSelected=null
diff --git a/src/main/resources/META-INF/resources/designer/scripts/menuHandler.js b/src/main/resources/META-INF/resources/designer/scripts/menuHandler.js
new file mode 100644
index 00000000..43c9275f
--- /dev/null
+++ b/src/main/resources/META-INF/resources/designer/scripts/menuHandler.js
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+
+function enableActionMenu(status) {
+ var actionMap = '{"DESIGN": ["Submit","Delete"],"RUNNING": ["Stop","UnDeploy"],"SUBMITTED": ["Submit","Delete","Deploy"],"DEPLOYED": ["UnDeploy","Stop"],"UNDEPLOY": ["Deploy","Submit","Restart","Delete"],"STOPPED":["UnDeploy","Restart"]}';
+ var actionMapJson = JSON.parse(actionMap);
+ var actionArr = actionMapJson[status];
+ disableAllActionMenu();
+ if (actionArr != null && actionArr.length > 0) {
+ for (var i=0; i < actionArr.length; i++) {
+ document.getElementById(actionArr[i]).classList
+ .remove('ThisLink');
+ }
+ }
+}
+
+function disableAllActionMenu() {
+ var allActions = ["Submit","Stop","Restart","Delete","Deploy","UnDeploy"];
+ for (var i=0; i < allActions.length; i++) {
+ document.getElementById(allActions[i]).classList
+ .add('ThisLink');
+ }
+}
+
+function enableAllActionMenu() {
+ var allActions = ["Submit","Stop","Restart","Delete","Deploy","UnDeploy"];
+ for (var i=0; i < allActions.length; i++) {
+ document.getElementById(allActions[i]).classList
+ .remove('ThisLink');
+ }
+}
+
+function enableDefaultMenu() {
+ document.getElementById('Open CL').classList.remove('ThisLink');
+ document.getElementById('Wiki').classList.remove('ThisLink');
+ document.getElementById('Contact Us').classList.remove('ThisLink');
+ if (readMOnly) {
+ // enable model options
+ document.getElementById('Properties CL').classList
+ .remove('ThisLink');
+ document.getElementById('Close Model').classList
+ .remove('ThisLink');
+ // disable models options
+ document.getElementById('Save CL').classList.add('ThisLink');
+ document.getElementById('Revert Model Changes').classList
+ .add('ThisLink');
+ } else {
+ // enable menu options
+ document.getElementById('Save CL').classList.remove('ThisLink');
+ document.getElementById('Properties CL').classList
+ .remove('ThisLink');
+ document.getElementById('Revert Model Changes').classList
+ .remove('ThisLink');
+ document.getElementById('Close Model').classList
+ .remove('ThisLink');
+ document.getElementById('Refresh Status').classList
+ .remove('ThisLink');
+ }
+}
+
diff --git a/src/main/resources/META-INF/resources/designer/scripts/propertyController.js b/src/main/resources/META-INF/resources/designer/scripts/propertyController.js
new file mode 100644
index 00000000..d4795650
--- /dev/null
+++ b/src/main/resources/META-INF/resources/designer/scripts/propertyController.js
@@ -0,0 +1,124 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+ function saveMsProperties(type, form) {
+ var newMsProperties = cl_props["microServicePolicies"];
+
+ for (p in newMsProperties) {
+ if (newMsProperties[p]["name"] == type) {
+ newMsProperties[p]["properties"] = form;
+ }
+ }
+
+ var def = $q.defer();
+ var sets = [];
+ var svcUrl = "/restservices/clds/v2/loop/updateMicroservicePolicies/" + modelName;
+ var svcRequest = {
+ loopName : modelName,
+ newMicroservicePolicies : newMsProperties
+ };
+ $http.post(svcUrl, svcRequest).success(function(data) {
+ def.resolve(data);
+ }).error(function(data) {
+ def.reject("Save Model not successful");
+ return def.promise;
+ };
+ cl_props["microServicePolicies"] = newMsProperties;
+}
+
+function saveGlobalProperties(form) {
+ var def = $q.defer();
+ var sets = [];
+ var svcUrl = "/restservices/clds/v2/loop/globalProperties/" + modelName;
+ var svcRequest = {
+ loopName : modelName,
+ newGlobalPolicies : form
+ };
+ $http.post(svcUrl, svcRequest).success(function(data) {
+ def.resolve(data);
+ }).error(function(data) {
+ def.reject("Save Model not successful");
+ return def.promise;
+ };
+ cl_props["globalPropertiesJson"] = form;
+}
+
+function saveOpPolicyProperties(form) {
+ var newOpProperties = cl_props["operationalPolicies"];
+ newOpProperties["0"]["configurationsJson"]= form;
+
+ var def = $q.defer();
+ var sets = [];
+ var svcUrl = "/restservices/clds/v2/loop/updateOperationalPolicies/" + modelName;
+ var svcRequest = {
+ loopName : modelName,
+ newGlobalPolicies : newOpProperties
+ };
+ $http.post(svcUrl, svcRequest).success(function(data) {
+ def.resolve(data);
+ }).error(function(data) {
+ def.reject("Save Model not successful");
+ return def.promise;
+ };
+
+ cl_props["operationalPolicies"] = newOpProperties;
+}
+
+function getOperationalPolicyProperty() {
+ return cl_props["operationalPolicies"]["0"]["configurationsJson"];
+}
+
+function getGlobalProperty() {
+ return cl_props["globalPropertiesJson"];
+}
+
+function getMsProperty(type) {
+ var msProperties = cl_props["microServicePolicies"];
+ for (p in msProperties) {
+ if (msProperties[p]["name"] == type) {
+ return msProperties[p]["properties"];
+ }
+ }
+ return null;
+}
+
+function getMsUI(type) {
+ var msProperties = cl_props["microServicePolicies"];
+ for (p in msProperties) {
+ if (msProperties[p]["name"] == type) {
+ return msProperties[p]["jsonRepresentation"];
+ }
+ }
+ return null;
+}
+
+function getStatus() {
+ return cl_props["lastComputedState"];
+}
+
+function getDeploymentID() {
+ return cl_props["dcaeDeploymentId"];
+}
+
+function getDeploymentStatusURL() {
+ return cl_props["dcaeDeploymentStatusUrl"];
+}
diff --git a/src/main/resources/clds/camel/rest/clamp-api-v2.xml b/src/main/resources/clds/camel/rest/clamp-api-v2.xml
index 0a72a0c1..44237527 100644
--- a/src/main/resources/clds/camel/rest/clamp-api-v2.xml
+++ b/src/main/resources/clds/camel/rest/clamp-api-v2.xml
@@ -13,6 +13,21 @@
<to
uri="bean:org.onap.clamp.loop.LoopController?method=getLoop(${header.loopName})" />
</get>
+ <get uri="/v2/loop/svgRepresentation/{loopName}"
+ outType="java.lang.String"
+
+ produces="application/xml">
+ <to
+ uri="bean:org.onap.clamp.loop.LoopController?method=getSVGRepresentation(${header.loopName})" />
+ </get>
+ <post uri="/v2/loop/globalProperties/{loopName}"
+ type="com.google.gson.JsonArray"
+ consumes="application/json"
+ outType="org.onap.clamp.loop.Loop"
+ produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.loop.LoopController?method=updateOperationalPolicies(${header.loopName},${body})" />
+ </post>
<post uri="/v2/loop/updateOperationalPolicies/{loopName}"
type="com.google.gson.JsonArray"
consumes="application/json"
diff --git a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImplTest.java b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImplTest.java
index a995c523..1fe3ff3d 100644
--- a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImplTest.java
+++ b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImplTest.java
@@ -17,50 +17,161 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END============================================
+ * * Modifications copyright (c) 2019 Nokia
* ===================================================================
*
*/
-package org.onap.clamp.clds.sdc.controller.installer;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+package org.onap.clamp.clds.sdc.controller.installer;
import com.google.gson.JsonObject;
import java.io.IOException;
+import java.io.InputStream;
+import org.apache.commons.io.IOUtils;
+import org.assertj.core.api.Assertions;
+import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.clamp.clds.client.DcaeInventoryServices;
+import org.onap.clamp.clds.config.sdc.BlueprintParserFilesConfiguration;
+import org.onap.clamp.clds.dao.CldsDao;
+import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException;
+import org.onap.clamp.clds.service.CldsService;
+import org.onap.clamp.clds.service.CldsTemplateService;
+import org.onap.clamp.clds.transform.XslTransformer;
import org.onap.clamp.clds.util.JsonUtils;
import org.onap.clamp.clds.util.ResourceFileUtil;
+import org.onap.sdc.api.notification.INotificationData;
+import org.onap.sdc.api.notification.IResourceInstance;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+import org.springframework.context.ApplicationContext;
+import org.springframework.core.io.Resource;
+@RunWith(MockitoJUnitRunner.class)
public class CsarInstallerImplTest {
+ @Mock
+ private CsarHandler csarHandler;
+
+ @Mock
+ private ApplicationContext applicationContext;
+
+ @Mock
+ private DcaeInventoryServices dcaeInventoryServices;
+
+ @Mock
+ private IResourceInstance resourceInstance;
+
+ @Mock
+ private CldsService cldsService;
+
+ @Mock
+ private INotificationData notificationData;
+
+ @Mock
+ private Metadata metadata;
+
+ @Mock
+ private ISdcCsarHelper sdcCsarHelper;
+
+ private CsarInstallerImpl csarInstaller;
+ private BlueprintArtifact artifact;
+
+ /**
+ * Set up method.
+ * throws: Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ String dceaBlueprint = ResourceFileUtil.getResourceAsString("tosca/dcea_blueprint.yml");
+ artifact = prepareBlueprintArtifact(dceaBlueprint);
+ csarInstaller = new CsarInstallerImpl(applicationContext, new CldsDao(), new CldsTemplateService(),
+ cldsService, dcaeInventoryServices, new XslTransformer());
+ }
+
@Test
- public void shouldReturnInputParametersFromBlueprint() throws IOException {
+ public void shouldReturnInputParametersFromBlueprint() {
//given
String expectedBlueprintInputsText = "{\"aaiEnrichmentHost\":\"aai.onap.svc.cluster.local\""
- + ",\"aaiEnrichmentPort\":\"8443\""
- + ",\"enableAAIEnrichment\":true"
- + ",\"dmaap_host\":\"message-router\""
- + ",\"dmaap_port\":\"3904\""
- + ",\"enableRedisCaching\":false"
- + ",\"redisHosts\":\"dcae-redis:6379\""
- + ",\"tag_version\":\"nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.0\""
- + ",\"consul_host\":\"consul-server\""
- + ",\"consul_port\":\"8500\",\"cbs_host\":\"{\\\"test\\\":"
- + "{\\\"test\\\":\\\"test\\\"}}\",\"cbs_port\":\"10000\""
- + ",\"external_port\":\"32010\",\"policy_id\":\"AUTO_GENERATED_POLICY_ID_AT_SUBMIT\"}";
+ + ",\"aaiEnrichmentPort\":\"8443\""
+ + ",\"enableAAIEnrichment\":true"
+ + ",\"dmaap_host\":\"message-router\""
+ + ",\"dmaap_port\":\"3904\""
+ + ",\"enableRedisCaching\":false"
+ + ",\"redisHosts\":\"dcae-redis:6379\""
+ + ",\"tag_version\":"
+ + "\"nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.0\""
+ + ",\"consul_host\":\"consul-server\""
+ + ",\"consul_port\":\"8500\",\"cbs_host\":\"{\\\"test\\\":"
+ + "{\\\"test\\\":\\\"test\\\"}}\",\"cbs_port\":\"10000\""
+ + ",\"external_port\":\"32010\",\"policy_id\":\"AUTO_GENERATED_POLICY_ID_AT_SUBMIT\"}";
JsonObject expectedBlueprintInputs = JsonUtils.GSON.fromJson(expectedBlueprintInputsText, JsonObject.class);
- String dceaBlueprint = ResourceFileUtil.getResourceAsString("tosca/dcea_blueprint.yml");
- BlueprintArtifact blueprintArtifact = mock(BlueprintArtifact.class);
- when(blueprintArtifact.getDcaeBlueprint()).thenReturn(dceaBlueprint);
- CsarInstallerImpl csarInstaller = new CsarInstallerImpl();
+ //when
+ String parametersInJson = csarInstaller.getAllBlueprintParametersInJson(artifact);
+ //then
+ Assertions.assertThat(JsonUtils.GSON.fromJson(parametersInJson, JsonObject.class))
+ .isEqualTo(expectedBlueprintInputs);
+ }
+ @Test
+ public void shouldReturnBuildModelName() throws SdcArtifactInstallerException {
+ //given
+ String expectedModelName = "CLAMP_test_name_"
+ + "vtest_service_version_"
+ + "test_resource_instance_name_"
+ + "test_artifact_name";
+ prepareMockCsarHandler("name", "test_name",
+ "test_service_version");
+ Mockito.when(resourceInstance.getResourceInstanceName()).thenReturn("test_resource_instance_name");
//when
- String parametersInJson = csarInstaller.getAllBlueprintParametersInJson(blueprintArtifact);
+ String actualModelName = CsarInstallerImpl.buildModelName(csarHandler, artifact);
+ //then
+ Assertions.assertThat(actualModelName).isEqualTo(expectedModelName);
+ }
+
+ @Test
+ public void shouldReturnRightMapping() throws SdcArtifactInstallerException, IOException {
+ //given
+ String input = "[{\"blueprintKey\":\"tca_k8s\","
+ + "\"dcaeDeployable\":false,"
+ + "\"files\":{\"svgXmlFilePath\":\"samplePath\",\"bpmnXmlFilePath\":\"samplePath\"}}]";
+ BlueprintParserFilesConfiguration filesConfiguration = new BlueprintParserFilesConfiguration();
+ filesConfiguration.setBpmnXmlFilePath("samplePath");
+ filesConfiguration.setSvgXmlFilePath("samplePath");
+ Resource resource = Mockito.mock(Resource.class);
+ InputStream inputStream = IOUtils.toInputStream(input, "UTF-8");
+ Mockito.when(applicationContext.getResource(Mockito.any(String.class))).thenReturn(resource);
+ Mockito.when(resource.getInputStream()).thenReturn(inputStream);
+ csarInstaller.loadConfiguration();
+ //when
+ BlueprintParserFilesConfiguration configuration = csarInstaller.searchForRightMapping(artifact);
//then
- assertThat(JsonUtils.GSON.fromJson(parametersInJson, JsonObject.class)).isEqualTo(expectedBlueprintInputs);
+ Assertions.assertThat(configuration.getBpmnXmlFilePath()).isEqualTo("samplePath");
+ Assertions.assertThat(configuration.getSvgXmlFilePath()).isEqualTo("samplePath");
+ }
+
+ private BlueprintArtifact prepareBlueprintArtifact(String dceaBlueprint) {
+ artifact = new BlueprintArtifact();
+ artifact.setBlueprintArtifactName("test_artifact_name");
+ artifact.setBlueprintInvariantServiceUuid("test_inv_uuid");
+ artifact.setResourceAttached(resourceInstance);
+ artifact.setDcaeBlueprint(dceaBlueprint);
+ return artifact;
+ }
+
+ private void prepareMockCsarHandler(String metadataNameMockInput, String metadataNameMockOutput,
+ String serviceVersion) {
+ Mockito.when(csarHandler.getSdcCsarHelper()).thenReturn(sdcCsarHelper);
+ Mockito.when(sdcCsarHelper.getServiceMetadata()).thenReturn(metadata);
+ Mockito.when(metadata.getValue(metadataNameMockInput)).thenReturn(metadataNameMockOutput);
+ Mockito.when(csarHandler.getSdcNotification()).thenReturn(notificationData);
+ Mockito.when(notificationData.getServiceVersion()).thenReturn(serviceVersion);
}
} \ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/clds/util/XmlToolsTest.java b/src/test/java/org/onap/clamp/clds/util/XmlToolsTest.java
new file mode 100644
index 00000000..4351a80d
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/util/XmlToolsTest.java
@@ -0,0 +1,72 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.util;
+
+import java.io.IOException;
+import java.io.StringReader;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import org.apache.batik.anim.dom.SVGDOMImplementation;
+import org.apache.batik.util.SVGConstants;
+import org.junit.Assert;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class XmlToolsTest {
+
+ @Test
+ public void exportXmlDocumentAsStringTest() throws IOException, ParserConfigurationException, SAXException {
+ String expected = ResourceFileUtil.getResourceAsString("clds/util/file.xml");
+ Document document = parseStringToXmlDocument(expected);
+ String actual = XmlTools.exportXmlDocumentAsString(document);
+ Assert.assertEquals(expected.trim(), actual.trim());
+ }
+
+ @Test
+ public void createEmptySvgDocumentTest() {
+ Document doc = XmlTools.createEmptySvgDocument();
+ Assert.assertEquals(SVGDOMImplementation.SVG_NAMESPACE_URI, doc.getDocumentElement().getNamespaceURI());
+ Assert.assertEquals(SVGConstants.SVG_SVG_TAG, doc.getDocumentElement().getNodeName());
+ Assert.assertNull(doc.getDoctype());
+ }
+
+
+ public static Document parseStringToXmlDocument(String res)
+ throws ParserConfigurationException, SAXException, IOException {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setValidating(false);
+ dbf.setNamespaceAware(true);
+ dbf.setFeature("http://xml.org/sax/features/namespaces", false);
+ dbf.setFeature("http://xml.org/sax/features/validation", false);
+ dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
+ dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ InputSource is = new InputSource(new StringReader(res));
+ return db.parse(is);
+ }
+
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java b/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java
new file mode 100644
index 00000000..477e6a73
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.util.drawing;
+
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import java.util.Arrays;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ClampGraphBuilderTest {
+ @Mock
+ private Painter mockPainter;
+
+ @Captor
+ private ArgumentCaptor<String> collectorCaptor;
+
+ @Captor
+ private ArgumentCaptor<List<String>> microServicesCaptor;
+
+ @Captor
+ private ArgumentCaptor<String> policyCaptor;
+
+ @Test
+ public void clampGraphBuilderCompleteChainTest() {
+ String collector = "VES";
+ String ms1 = "ms1";
+ String ms2 = "ms2";
+ String policy = "Policy";
+ List<String> microServices = Arrays.asList(ms1, ms2);
+
+ ClampGraphBuilder clampGraphBuilder = new ClampGraphBuilder(mockPainter);
+ clampGraphBuilder.collector(collector).microService(ms1).microService(ms2).policy(policy).build();
+
+ verify(mockPainter, times(1))
+ .doPaint(collectorCaptor.capture(), microServicesCaptor.capture(), policyCaptor.capture());
+
+ Assert.assertEquals(collector, collectorCaptor.getValue());
+ Assert.assertEquals(microServices, microServicesCaptor.getValue());
+ Assert.assertEquals(policy, policyCaptor.getValue());
+ }
+
+ @Test(expected = InvalidStateException.class)
+ public void clampGraphBuilderNoPolicyGivenTest() {
+ String collector = "VES";
+ String ms1 = "ms1";
+ String ms2 = "ms2";
+
+ ClampGraphBuilder clampGraphBuilder = new ClampGraphBuilder(mockPainter);
+ clampGraphBuilder.collector(collector).microService(ms1).microService(ms2).build();
+ }
+
+ @Test(expected = InvalidStateException.class)
+ public void clampGraphBuilderNoMicroServiceGivenTest() {
+ String collector = "VES";
+ String policy = "Policy";
+
+ ClampGraphBuilder clampGraphBuilder = new ClampGraphBuilder(mockPainter);
+ clampGraphBuilder.collector(collector).policy(policy).build();
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphTest.java b/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphTest.java
new file mode 100644
index 00000000..6bbebdfd
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphTest.java
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.util.drawing;
+
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import javax.xml.parsers.ParserConfigurationException;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.clamp.clds.util.ResourceFileUtil;
+import org.onap.clamp.clds.util.XmlToolsTest;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ClampGraphTest {
+ @Mock
+ private DocumentBuilder mockDocumentBuilder;
+
+ @Test
+ public void getAsSVGTest() throws IOException, ParserConfigurationException, SAXException {
+ String expected = ResourceFileUtil.getResourceAsString("clds/util/file.xml");
+ Document document = XmlToolsTest.parseStringToXmlDocument(expected);
+
+ when(mockDocumentBuilder.getGroupingDocument()).thenReturn(document);
+
+ String actual = new ClampGraph(mockDocumentBuilder).getAsSVG();
+ Assert.assertEquals(expected.trim(), actual.trim());
+ }
+
+ @Test
+ public void getAsSVGLazyTest() throws IOException, ParserConfigurationException, SAXException {
+ String expected = ResourceFileUtil.getResourceAsString("clds/util/file.xml");
+ Document document = XmlToolsTest.parseStringToXmlDocument(expected);
+
+ when(mockDocumentBuilder.getGroupingDocument()).thenReturn(document);
+ ClampGraph cg = new ClampGraph(mockDocumentBuilder);
+
+ String actualFirst = cg.getAsSVG();
+ verify(mockDocumentBuilder, times(1)).getGroupingDocument();
+
+ String actualSecond = cg.getAsSVG();
+ verifyNoMoreInteractions(mockDocumentBuilder);
+
+ Assert.assertEquals(expected.trim(), actualFirst.trim());
+ Assert.assertEquals(expected.trim(), actualSecond.trim());
+
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/clds/util/drawing/DocumentBuilderTest.java b/src/test/java/org/onap/clamp/clds/util/drawing/DocumentBuilderTest.java
new file mode 100644
index 00000000..6546553c
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/util/drawing/DocumentBuilderTest.java
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.util.drawing;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import javax.xml.parsers.ParserConfigurationException;
+import org.apache.batik.svggen.SVGGraphics2D;
+import org.apache.batik.util.SVGConstants;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.clamp.clds.util.ResourceFileUtil;
+import org.onap.clamp.clds.util.XmlToolsTest;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+@RunWith(MockitoJUnitRunner.class)
+public class DocumentBuilderTest {
+ @Mock
+ private SVGGraphics2D mockG2d;
+
+ @Mock
+ private Document mockDomImpl;
+
+ @Test
+ public void pushChangestoDocumentTest() throws IOException, ParserConfigurationException, SAXException {
+ String dataElementId = "someId";
+ String newNodeTag = "tagged";
+ String newNodeText = "Sample text";
+ String xml = ResourceFileUtil.getResourceAsString("clds/util/file.xml");
+ Document document = XmlToolsTest.parseStringToXmlDocument(xml);
+ Node newNode = document.createElement(newNodeTag);
+ newNode.appendChild(document.createTextNode(newNodeText));
+
+ when(mockG2d.getRoot(any(Element.class))).then(a -> a.getArgumentAt(0, Element.class).appendChild(newNode));
+
+ DocumentBuilder db = new DocumentBuilder(document, document);
+ db.pushChangestoDocument(mockG2d, dataElementId);
+ Document actualDocument = db.getGroupingDocument();
+
+ Node addedActualNode = actualDocument.getDocumentElement().getLastChild();
+ String actualDataElementId =
+ addedActualNode.getAttributes().getNamedItem(DocumentBuilder.DATA_ELEMENT_ID_ATTRIBUTE).getTextContent();
+
+ Assert.assertEquals(dataElementId, actualDataElementId);
+ Assert.assertEquals(SVGConstants.SVG_G_TAG, addedActualNode.getNodeName());
+
+ Node addedActualNodeChild = addedActualNode.getLastChild();
+ Assert.assertEquals(newNodeTag, addedActualNodeChild.getNodeName());
+ Assert.assertEquals(newNodeText, addedActualNodeChild.getTextContent());
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
index a9c30873..b7781bf2 100644
--- a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
+++ b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
@@ -70,7 +70,7 @@ public class LoopServiceTestItCase {
testLoop.setLastComputedState(LoopState.DESIGN);
//when
- Loop actualLoop = loopService.addNewLoop(testLoop);
+ Loop actualLoop = loopService.saveOrUpdateLoop(testLoop);
//then
assertThat(actualLoop).isNotNull();
@@ -166,7 +166,7 @@ public class LoopServiceTestItCase {
private void saveTestLoopToDb() {
Loop testLoop = createTestLoop(EXAMPLE_LOOP_NAME, "blueprint", "representation");
testLoop.setGlobalPropertiesJson(JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class));
- loopService.addNewLoop(testLoop);
+ loopService.saveOrUpdateLoop(testLoop);
}
@Test
diff --git a/src/test/resources/clds/util/file.xml b/src/test/resources/clds/util/file.xml
new file mode 100644
index 00000000..81560bab
--- /dev/null
+++ b/src/test/resources/clds/util/file.xml
@@ -0,0 +1,6 @@
+<note>
+ <to>Tove</to>
+ <from>Jani</from>
+ <heading>Reminder</heading>
+ <body>Message body</body>
+</note>