2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 import React from 'react';
25 import NodeVisualElementConstants from './NodeVisualElementConstants.js';
26 import NodeVisualElementFactory from './NodeVisualElementFactory.js';
32 this.visualElementFactory = new NodeVisualElementFactory();
34 this.setNodeMeta = this.setNodeMeta.bind(this);
37 setNodeMeta(metaObject) {
38 this.graphMeta = metaObject;
39 this.visualElementFactory.setVisualElementMeta(metaObject);
42 buildNode(nodeType, nodeProps) {
44 let translate = `translate(
45 ${nodeProps.renderProps.x},
46 ${nodeProps.renderProps.y})`;
48 ...nodeProps.renderProps,
49 className: this.graphMeta.aaiEntityNodeDescriptors[nodeType].class,
53 let nodeVisualElementsData = this.extractVisualElementArrayFromMeta(
55 let nodeVisualElements = undefined;
56 if (nodeVisualElementsData) {
57 nodeVisualElements = [];
58 nodeVisualElementsData.map((elementData, index) => {
59 if (elementData.type === NodeVisualElementConstants.BUTTON) {
60 if (nodeProps.buttons) {
61 let isButtonSelected = true;
64 isSelected: isButtonSelected
68 nodeVisualElements.push(
69 this.visualElementFactory.buildVisualElement(nodeProps.meta,
70 elementData.type, elementData, index));
72 //Draw overlay only if the node is validated
73 if (nodeProps.meta.nodeMeta.nodeValidated) {
75 if (nodeProps.meta.nodeMeta.nodeIssue) {
76 let warningOverlayProps = {
77 name: NodeVisualElementConstants.ICON_WARNING,
79 nodeVisualElements.push(
80 this.visualElementFactory.buildVisualElement(nodeProps,
81 NodeVisualElementConstants.ICON, warningOverlayProps,
82 nodeVisualElementsData.length + 1));
84 let tickOverlayProps = {
85 name: NodeVisualElementConstants.ICON_TICK,
87 nodeVisualElements.push(
88 this.visualElementFactory.buildVisualElement(nodeProps,
89 NodeVisualElementConstants.ICON, tickOverlayProps,
90 nodeVisualElementsData.length + 1));
95 if (nodeVisualElements) {
96 return React.createElement('g', finalProps, nodeVisualElements);
99 return React.createElement('g', finalProps);
102 extractVisualElementArrayFromMeta(nodeClassName) {
103 let nodeVisualElements = undefined;
104 if (this.graphMeta.aaiEntityNodeDescriptors) {
106 this.graphMeta.aaiEntityNodeDescriptors[nodeClassName].visualElements;
108 return nodeVisualElements;
112 export default NodeFactory;