aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2020-05-13 09:34:05 +0200
committerXue Gao <xg353y@intl.att.com>2020-05-18 10:51:30 +0000
commit061ecec6a6099ad7fb480b0fe67f6e5154f9db23 (patch)
tree7efafa09fd0b1ade0b256dc521f48e6bfa66c56f /src/main/java
parent515251fb5ce2d8f2b4ccb5bd5d3ebd46deb4d29a (diff)
Add info in the SVG
Add two additional fields in the SVG for the UI so that components can easily get the data without the need to access the models Issue-ID: CLAMP-852 Signed-off-by: sebdet <sebastien.determe@intl.att.com> Change-Id: I872d3c8b0336d813e1a1cf590f6c8a06cccbe230
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/clamp/clds/util/drawing/DocumentBuilder.java12
-rw-r--r--src/main/java/org/onap/clamp/clds/util/drawing/ImageBuilder.java8
-rwxr-xr-xsrc/main/java/org/onap/clamp/clds/util/drawing/Painter.java10
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopService.java7
4 files changed, 27 insertions, 10 deletions
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
index f34eaf2ee..7c624be0f 100644
--- a/src/main/java/org/onap/clamp/clds/util/drawing/DocumentBuilder.java
+++ b/src/main/java/org/onap/clamp/clds/util/drawing/DocumentBuilder.java
@@ -33,6 +33,8 @@ public class DocumentBuilder {
private final Document documentFactory;
static final String DATA_ELEMENT_ID_ATTRIBUTE = "data-element-id";
+ static final String DATA_ELEMENT_GROUPING_ATTRIBUTE = "data-grouping-id";
+ static final String DATA_FOR_UI_ATTRIBUTE = "data-for-ui";
DocumentBuilder(Document groupingDocument, Document documentFactory) {
this.groupingDocument = groupingDocument;
@@ -40,10 +42,20 @@ public class DocumentBuilder {
}
void pushChangestoDocument(SVGGraphics2D g2d, String dataElementId) {
+ pushChangestoDocument(g2d, dataElementId,null,null);
+ }
+
+ void pushChangestoDocument(SVGGraphics2D g2d, String dataElementId, String dataGroupingId, String dataForUI) {
Element element =
this.documentFactory.createElementNS(SVGGraphics2D.SVG_NAMESPACE_URI,
SVGGraphics2D.SVG_G_TAG);
element.setAttribute(DATA_ELEMENT_ID_ATTRIBUTE, dataElementId);
+ if (dataGroupingId != null) {
+ element.setAttribute(DATA_ELEMENT_GROUPING_ATTRIBUTE, dataGroupingId);
+ }
+ if (dataForUI != null) {
+ element.setAttribute(DATA_FOR_UI_ATTRIBUTE, dataForUI);
+ }
g2d.getRoot(element);
Node node = this.groupingDocument.importNode(element, true);
this.groupingDocument.getDocumentElement().appendChild(node);
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
index f63ead8e7..72df90f2b 100644
--- a/src/main/java/org/onap/clamp/clds/util/drawing/ImageBuilder.java
+++ b/src/main/java/org/onap/clamp/clds/util/drawing/ImageBuilder.java
@@ -49,7 +49,7 @@ public class ImageBuilder {
private static final int CIRCLE_RADIUS = 17;
ImageBuilder(SVGGraphics2D svgGraphics2D, DocumentBuilder documentBuilder, Point startingPoint, int baseLength,
- int rectHeight) {
+ int rectHeight) {
this.g2d = svgGraphics2D;
this.documentBuilder = documentBuilder;
this.currentPoint = new Point(startingPoint);
@@ -57,13 +57,13 @@ public class ImageBuilder {
this.rectHeight = rectHeight;
}
- ImageBuilder rectangle(String dataElementId, RectTypes rectType, String text) {
+ ImageBuilder rectangle(String dataElementId, RectTypes rectType, String boxText, String groupingId, String uiData) {
Point next = new Point(currentPoint.x + baseLength, currentPoint.y);
Point point = coordinatesForRectangle(currentPoint, next);
- handleBasedOnRectType(rectType, text, point, baseLength, rectHeight);
+ handleBasedOnRectType(rectType, boxText, point, baseLength, rectHeight);
- documentBuilder.pushChangestoDocument(g2d, dataElementId);
+ documentBuilder.pushChangestoDocument(g2d, dataElementId, groupingId, uiData);
currentPoint = next;
return this;
}
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
index 509d4e41c..ff7d2c215 100755
--- a/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java
+++ b/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java
@@ -79,14 +79,18 @@ public class Painter {
private void doTheActualDrawing(String collector, Set<MicroServicePolicy> microServices,
Set<OperationalPolicy> policies,
ImageBuilder ib) {
- ib.circle("start-circle", SLIM_LINE).arrow().rectangle(collector, RectTypes.COLECTOR, collector);
+ ib.circle("start-circle", SLIM_LINE).arrow().rectangle(collector, RectTypes.COLECTOR, collector, null, null);
for (MicroServicePolicy ms : microServices) {
ib.arrow().rectangle(ms.getName(),
- RectTypes.MICROSERVICE, ms.getPolicyModel().getPolicyAcronym());
+ RectTypes.MICROSERVICE, ms.getPolicyModel().getPolicyAcronym(),
+ ms.getLoopElementModel() != null ? ms.getLoopElementModel().getName() : null,
+ ms.getLoopElementModel() != null ? ms.getLoopElementModel().getName() : null);
}
for (OperationalPolicy policy : policies) {
- ib.arrow().rectangle(policy.getName(), RectTypes.POLICY, policy.getPolicyModel().getPolicyAcronym());
+ ib.arrow().rectangle(policy.getName(), RectTypes.POLICY, policy.getPolicyModel().getPolicyAcronym(),
+ policy.getLoopElementModel() != null ? policy.getLoopElementModel().getName() : null,
+ policy.getLoopElementModel() != null ? policy.getLoopElementModel().getName() : null);
}
ib.arrow().circle("stop-circle", THICK_LINE);
}
diff --git a/src/main/java/org/onap/clamp/loop/LoopService.java b/src/main/java/org/onap/clamp/loop/LoopService.java
index 3f568a331..5f0822816 100644
--- a/src/main/java/org/onap/clamp/loop/LoopService.java
+++ b/src/main/java/org/onap/clamp/loop/LoopService.java
@@ -120,9 +120,10 @@ public class LoopService {
PolicyModel policyModel = policyModelsService.getPolicyModel(policyType, policyVersion);
Set<OperationalPolicy> opPolicySet = loop.getOperationalPolicies();
for (OperationalPolicy opPolicy : opPolicySet) {
- if (opPolicy.getPolicyModel().equals(policyModel)) {
- throw new IllegalArgumentException("This type of Operational Policy is already added to the loop. Please choose another one.");
- }
+ if (opPolicy.getPolicyModel().equals(policyModel)) {
+ throw new IllegalArgumentException(
+ "This type of Operational Policy is already added to the loop. Please choose another one.");
+ }
}
if (policyModel == null) {
return null;