summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/CSV.js348
-rw-r--r--src/utils/CommonAPIService.js131
-rw-r--r--src/utils/DiffUtil.js98
-rw-r--r--src/utils/ExportExcel.js394
-rw-r--r--src/utils/GeneralCommonFunctions.js344
-rw-r--r--src/utils/GlobalConstants.js20
-rw-r--r--src/utils/GlobalExtConstants.js110
-rw-r--r--src/utils/OxmUtility.js28
-rw-r--r--src/utils/Routes.js3
-rw-r--r--src/utils/SpinnerContainer.jsx9
10 files changed, 1478 insertions, 7 deletions
diff --git a/src/utils/CSV.js b/src/utils/CSV.js
new file mode 100644
index 0000000..d570ddb
--- /dev/null
+++ b/src/utils/CSV.js
@@ -0,0 +1,348 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2021 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=========================================================
+ */
+
+import {GlobalExtConstants} from './GlobalExtConstants.js';
+let OXM = GlobalExtConstants.OXM;
+
+function camelToDash(str) {
+ return (str.replace(/\W+/g, '-')
+ .replace(/([a-z\d])([A-Z])/g, '$1-$2')).toLowerCase();
+}
+
+function sortColumn(col1, col2) {
+ if (col1.value < col2.value) {
+ return -1;
+ } else if (col1.value > col2.value) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+var buildAttrList = function(inputParam, cols) {
+ // console.log('[getSearchParam] inputParam: ' + inputParam);
+ let searchParam = inputParam;
+
+ if (['PSERVER', 'COMPLEX', 'CLOUDREGION',
+ 'NETWORKPROFILE', 'VIRTUALDATACENTER'].indexOf(inputParam.toUpperCase()) === -1) {
+ searchParam = inputParam.substring(0, inputParam.length - 1);
+ // console.log('[getSearchParam] searchParam: ' + searchParam);
+ }
+ console.log('Before loop included',searchParam);
+ if('CHASSIES'.indexOf(inputParam.toUpperCase()) !== -1){
+ searchParam = inputParam.substring(0, inputParam.length - 2) + 's';
+ }else if(inputParam.substr(inputParam.length - 3) === 'ies'){
+ searchParam = inputParam.substring(0, inputParam.length - 3) + 'y';
+ }else if('COMPLEXES'.indexOf(inputParam.toUpperCase()) !== -1){
+ searchParam = inputParam.substring(0, inputParam.length - 2);
+ }
+ if(inputParam.toUpperCase() === 'PINTERFACES'){
+ searchParam = 'pInterface';
+ }
+ console.log('After loop included',searchParam);
+ if (inputParam.toUpperCase() === 'LINESOFBUSINESS') {
+ searchParam = 'lineOfBusiness';
+ // console.log('[getSearchParam] searchParam: ' + searchParam);
+ }
+
+ // read oxm xml file
+ let oxmFile = JSON.parse(OXM);
+ let javaTypes = oxmFile['xml-bindings']['java-types'][0]['java-type'];
+ // console.log('[buildAttrList] javaTypes:');
+ // console.log(javaTypes);
+
+ let foundIndex = -1;
+ for (let i = 0; i < javaTypes.length && foundIndex === -1; i++) {
+ if (javaTypes[i]['xml-root-element'][0]['$']['name'] === camelToDash(searchParam)) {
+ // console.log(javaTypes[i]);
+ foundIndex = i;
+ }
+ }
+
+ //Adding Quick fix will be get rid of it later
+ console.log('searchParam>>>>>>>stage2:',inputParam);
+ if(foundIndex === -1){
+ for (let i = 0; i < javaTypes.length && foundIndex === -1; i++) {
+ if (javaTypes[i]['xml-root-element'][0]['$']['name'] === camelToDash(inputParam)) {
+ foundIndex = i;
+ }
+ if(foundIndex === -1){
+ if(inputParam.substr(inputParam.length - 1) === 's'){
+ searchParam = inputParam.substring(0, inputParam.length - 1);
+ console.log('searchParam>>>>>>>stage3:',searchParam);
+ }
+ if (javaTypes[i]['xml-root-element'][0]['$']['name'] === camelToDash(searchParam)) {
+ foundIndex = i;
+ }
+ }
+ }
+ }
+
+ // build the column list
+ let columns = cols;
+ if(foundIndex > -1) {
+ //for (let j = 0; j < javaTypes[foundIndex]['java-attributes'][0]['xml-element'].length; j++) {
+ // columns.push({value: javaTypes[foundIndex]['java-attributes'][0]['xml-element'][j]['$']['name']});
+ //}
+ if (javaTypes[foundIndex]['java-attributes']) {
+ let elementLength = 0;
+ if (javaTypes[foundIndex]['java-attributes'][0]['xml-element']) {
+ elementLength = javaTypes[foundIndex]['java-attributes'][0]['xml-element'].length;
+ }
+ for (var j = 0; j < elementLength; j++) {
+ let isPrimitive = JSON.stringify(javaTypes[foundIndex]['java-attributes'][0]['xml-element'][j]['$']['type']).indexOf('java.lang') > -1;
+ if(isPrimitive) { //add to the list
+ let node = {value: javaTypes[foundIndex]['java-attributes'][0]['xml-element'][j]['$']['name']};
+ columns.push(node);
+ }
+ }
+ }
+ }
+
+ //sort the column list
+ columns.sort(sortColumn);
+
+ // console.log('[buildAttrList] columns:');
+ // console.log(columns);
+
+ return columns;
+}
+
+var multiTypeBuildAttrList = function(nodes) {
+ // read oxm xml file
+ let oxmFile = JSON.parse(OXM);
+ let javaTypes = oxmFile['xml-bindings']['java-types'][0]['java-type'];
+
+ let typeList = new Map();
+
+ nodes.forEach(node => {
+ let searchParam = node['node-type'];
+
+ let foundIndex = -1;
+ for (let i = 0; i < javaTypes.length && foundIndex === -1; i++) {
+ if (javaTypes[i]['xml-root-element'][0]['$']['name'] === camelToDash(searchParam)) {
+ foundIndex = i;
+ if (!typeList.has(searchParam)) {
+
+ let props = [];
+ //for (let j = 0; j < javaTypes[foundIndex]['java-attributes'][0]['xml-element'].length; j++) {
+ //props.push({
+ //value: javaTypes[foundIndex]['java-attributes'][0]['xml-element'][j]['$']['name']
+ //});
+ //}
+ if (javaTypes[foundIndex]['java-attributes']) {
+ let elementLength = 0;
+ if (javaTypes[foundIndex]['java-attributes'][0]['xml-element']) {
+ elementLength = javaTypes[foundIndex]['java-attributes'][0]['xml-element'].length;
+ }
+ for (var j = 0; j < elementLength; j++) {
+ let isPrimitive = JSON.stringify(javaTypes[foundIndex]['java-attributes'][0]['xml-element'][j]['$']['type']).indexOf('java.lang') > -1;
+ if(isPrimitive) { //add to the list
+ let node = {value: javaTypes[foundIndex]['java-attributes'][0]['xml-element'][j]['$']['name']};
+ props.push(node);
+ }
+ }
+ }
+
+ props.sort(sortColumn);
+ typeList.set(searchParam, props);
+ }
+ }
+ }
+ });
+
+ // console.log('typeList:');
+ // console.log(typeList);
+
+ return typeList;
+}
+
+var buildCSV = function(columns, nodes) {
+ let outputArray = [];
+ outputArray[0] = [];
+
+ for (let i = 0; i < columns.length; i++) {
+ let str = columns[i].value;
+ outputArray[0][str] = columns[i];
+ }
+
+ // console.log('[buildCSV] initial outputArray with columns:');
+ // console.log(outputArray);
+
+ // console.log('[buildCSV] nodes.length:');
+ // console.log(nodes.length);
+
+ let q = 0;
+ for (let j = 1; j < nodes.length + 1; j++) {
+ outputArray[j] = [];
+ for (var k in nodes[q].properties) {
+ if (nodes[q].properties.hasOwnProperty(k)) {
+ let str = k;
+ outputArray[j][str] = nodes[q].properties[k].toString();
+ }
+ }
+ let relative = nodes[q]['related-to'];
+ for(var r = 0; r<relative.length; r++){
+ var relationship = '';
+ var relationshipLabel = '';
+ var nodeType = '';
+ var url = '';
+ for(var k in relative[r]){
+ let relation = k.toString();
+ if(relation === 'relationship-label'){
+ relationshipLabel = relative[r][k].toString().slice(33);
+ }
+ if(relation === 'node-type'){
+ nodeType = relative[r][k].toString();
+ }
+ if(relation === 'url'){
+ url = relative[r][k].toString();
+ }
+ relationship = 'Relationship ' + relationshipLabel + ' ' + nodeType + ' - ' + url;
+ console.log('relationship>>>>>',relationship);
+ }
+ let cnt = r + 1;
+ let str = 'Relationship' + cnt;
+ outputArray[j][str] = relationship;
+ outputArray[0][str] ='Relationship'+cnt;
+ }
+ q++;
+ }
+
+ return outputArray;
+}
+
+var multiTypebuildCSV = function(nodes) {
+ let outputArray = [];
+
+ nodes.forEach(node => {
+ let nodeVal = [];
+ for (var prop in node.properties) {
+ if (node.properties.hasOwnProperty(prop)) {
+ let val = { value: prop + ': ' + node.properties[prop].toString()};
+ // console.log(val);
+ nodeVal.push(val);
+ }
+ }
+ nodeVal.sort(sortColumn);
+ nodeVal.unshift({ value: node['node-type'] }, {value : node.url });
+ let relative = node['related-to'];
+ for(var r = 0; r<relative.length; r++){
+ var relationship = '';
+ var relationshipLabel = '';
+ var nodeType = '';
+ var url = '';
+ for(var k in relative[r]){
+ let relation = k.toString();
+ if(relation === 'relationship-label'){
+ relationshipLabel = relative[r][k].toString().slice(33);
+ }
+ if(relation === 'node-type'){
+ nodeType = relative[r][k].toString();
+ }
+ if(relation === 'url'){
+ url = relative[r][k].toString();
+ }
+ relationship = 'Relationship ' + relationshipLabel + ' ' + nodeType + ' - ' + url;
+ console.log('relationship>>>>>',relationship);
+ }
+ let cnt = r + 1;
+ let val = { value: 'Relationship'+cnt + ': ' + relationship};
+ nodeVal.push(val);
+ }
+ outputArray.push(nodeVal);
+ });
+
+ // console.log(outputArray);
+ return outputArray;
+}
+
+var convertToCSVStr = function(outputArray) {
+ let array = (typeof outputArray !== 'object' ? JSON.parse(outputArray) : outputArray);
+ let str = '';
+ let row = '';
+
+ for (let index in outputArray[0]) {
+ // convert each value to string and comma-separated
+ row += index + ',';
+ }
+ row = row.slice(0, -1);
+ // append Label row with line break
+ str += row + '\r\n';
+
+ for (let i = 1; i < array.length; i++) {
+ let line = '';
+ for (let k in outputArray[0]) {
+ if (outputArray[0].hasOwnProperty(k)) {
+ if (array[i][k]) {
+ line += array[i][k] + ',';
+ } else {
+ line += ',';
+ }
+ }
+ }
+ str += line + '\r\n';
+ }
+ return str;
+}
+
+var multiTypeConvertToCSVStr = function(outputArray) {
+ let array = (typeof outputArray !== 'object' ? JSON.parse(outputArray) : outputArray);
+ let str = '';
+ let max = 0;
+ // find max length of array to determine number of rows to loop through
+ array.forEach(node => {
+ if (node.length > max) {
+ max = node.length;
+ }
+ });
+
+ // console.log('max: ' + max);
+
+ for (let i = 0; i < max; i++) {
+ let line = '';
+ for (let j = 0; j < array.length; j++) {
+ line += array[j][i] ? array[j][i].value + ',' : ',';
+ }
+ str += line + '\r\n';
+ }
+ return str;
+}
+
+var downloadCSV = function(csvStr, filename) {
+ // console.log(csvStr);
+ var a = document.createElement('a');
+ a.setAttribute('style', 'display:none;');
+ document.body.appendChild(a);
+ var blob = new Blob([csvStr], { type: 'text/csv' });
+ var url = window.URL.createObjectURL(blob);
+ a.href = url;
+ a.download = filename + '.csv';
+ a.click();
+}
+export const CSV = {
+ buildAttrList : buildAttrList,
+ multiTypeBuildAttrList : multiTypeBuildAttrList,
+ buildCSV : buildCSV,
+ multiTypebuildCSV : multiTypebuildCSV,
+ convertToCSVStr : convertToCSVStr,
+ multiTypeConvertToCSVStr : multiTypeConvertToCSVStr,
+ downloadCSV : downloadCSV
+};
diff --git a/src/utils/CommonAPIService.js b/src/utils/CommonAPIService.js
new file mode 100644
index 0000000..c7aea45
--- /dev/null
+++ b/src/utils/CommonAPIService.js
@@ -0,0 +1,131 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2021 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=========================================================
+ */
+
+import axios from 'axios';
+import {GlobalExtConstants} from './GlobalExtConstants.js';
+
+const commonApi = (settings, path, httpMethodType, reqPayload, stubPath, overrideDomain, specialCase, additionalHeaders, noProxy) => {
+ let BASE_URL = GlobalExtConstants.BASE_URL;
+ const proxyConfig = {
+ //enter proxy details here for local
+ proxy : {
+ host: '',
+ port: ''
+ }
+ };
+
+ let SWITCH_URL = '';
+ let APERTURE_SERVICE = JSON.parse(sessionStorage.getItem(GlobalExtConstants.ENVIRONMENT + 'APERTURE_SERVICE'));
+ if(overrideDomain){
+ SWITCH_URL = overrideDomain + '/';
+ if(settings.ISTABULAR){
+ SWITCH_URL+= settings.TABULAR + '/'
+ + settings.PREFIX + '/'
+ + settings.APERTURE + '/'
+ + settings.TABULARVERSION + '/'
+ + path;
+ }else{
+ SWITCH_URL+= path;
+ }
+ }else if(APERTURE_SERVICE && (settings.ISAPERTURE !== undefined)){
+ let baseURL = (settings.NODESERVER) ? 'https://'+ settings.NODESERVER : BASE_URL;
+ SWITCH_URL = baseURL + '/';
+ if(!noProxy){
+ SWITCH_URL += settings.PROXY + '/';
+ }
+ SWITCH_URL += settings.PREFIX + '/'
+ + settings.APERTURE + '/';
+ if(settings.ISAPERTURE && settings.APERTURE_SERVICENAME !== undefined){
+ SWITCH_URL += settings.VERSION + '/'
+ + settings.APERTURE_SERVICENAME;
+ }else if(settings.ISAPERTURE){
+ SWITCH_URL += settings.VERSION + '/';
+ }
+ SWITCH_URL += path;
+ }else if(settings.NODESERVER){
+ SWITCH_URL = 'https://'
+ + settings.NODESERVER + '/';
+ if(!noProxy){
+ SWITCH_URL += settings.PROXY + '/';
+ }
+ SWITCH_URL += settings.PREFIX + '/';
+ if(specialCase){
+ SWITCH_URL += specialCase + '/';
+ }
+ SWITCH_URL += settings.VERSION + '/'
+ + path;
+ }else{
+ SWITCH_URL = BASE_URL + '/';
+ if(!noProxy){
+ SWITCH_URL += settings.PROXY + '/';
+ }
+ SWITCH_URL += settings.PREFIX + '/';
+ if(specialCase){
+ SWITCH_URL += specialCase + '/';
+ }
+ SWITCH_URL += settings.VERSION + '/'
+ + path;
+ }
+ console.log('Making call to the backend >>>>>>>>>>>', SWITCH_URL);
+
+ var headers = {'Content-Type' : 'application/json','Access-Control-Allow-Origin' : '*','X-FromAppId':'AAI-UI', 'X-TransactionId' : 'AAI-UI', 'Accept':'application/json'};
+ if(additionalHeaders){
+ for(var i = 0; i < additionalHeaders.length; i++){
+ if(additionalHeaders[i].name && additionalHeaders[i].value){
+ headers[additionalHeaders[i].name] = additionalHeaders[i].value;
+ }else{
+ console.log("CommonAPIService :: Additional headers passed in are not in teh proper format: "+ JSON.stringify(additionalHeaders));
+ }
+ }
+ }
+ console.log("HEADER VALUES: "+ headers);
+ if(settings.USESTUBS){
+ return new Promise((resolve, reject) => {
+ var responseObj = {};
+ responseObj.data = require('app/assets/stubs/' + stubPath + '.json');
+ responseObj.status = 200;
+ responseObj.headers = [];
+ if(responseObj.data && responseObj.data.results){
+ responseObj.headers['total-results'] = Object.keys(responseObj.data.results).length;
+ resolve(responseObj);
+ }else if(responseObj.data && ['BYOQPersonalQueries','BYOQCommunityQueries','BYOQPublicQueries','ConvertQueryToTree','SingleTransactionEdit'].indexOf(stubPath) > -1 ){
+ resolve(responseObj);
+ }else if(responseObj.data){
+ responseObj.headers['total-results'] = 0;
+ reject(responseObj.data);
+ }else{
+ reject('Error');
+ }
+ })
+ }else if (['PUT','PATCH','DELETE','POST'].indexOf(httpMethodType) > -1 && reqPayload !== null) {
+ return axios({ method: httpMethodType,
+ url: SWITCH_URL,
+ data: reqPayload,
+ headers: headers });
+ }else{
+ if(settings.NODESERVER){
+ return axios.get(SWITCH_URL, proxyConfig);
+ }else{
+ return axios.get(SWITCH_URL);
+ }
+ }
+};
+
+export default commonApi;
diff --git a/src/utils/DiffUtil.js b/src/utils/DiffUtil.js
new file mode 100644
index 0000000..5e69162
--- /dev/null
+++ b/src/utils/DiffUtil.js
@@ -0,0 +1,98 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2021 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=========================================================
+ */
+
+
+var deepDiffMapper = function() {
+ return {
+ VALUE_CREATED: 'created',
+ VALUE_UPDATED: 'updated',
+ VALUE_DELETED: 'deleted',
+ VALUE_UNCHANGED: 'unchanged',
+ map: function(obj1, obj2) {
+ if (this.isFunction(obj1) || this.isFunction(obj2)) {
+ throw 'Invalid argument. Function given, object expected.';
+ }
+ if (this.isValue(obj1) || this.isValue(obj2)) {
+ return {
+ type: this.compareValues(obj1, obj2),
+ data: (obj1 === undefined) ? obj2 : obj1
+ };
+ }
+
+ var diff = {};
+ for (var key in obj1) {
+ if (this.isFunction(obj1[key])) {
+ continue;
+ }
+
+ var value2 = undefined;
+ if ('undefined' != typeof(obj2[key])) {
+ value2 = obj2[key];
+ }
+
+ diff[key] = this.map(obj1[key], value2);
+ }
+ for (var key in obj2) {
+ if (this.isFunction(obj2[key]) || ('undefined' != typeof(diff[key]))) {
+ continue;
+ }
+
+ diff[key] = this.map(undefined, obj2[key]);
+ }
+
+ return diff;
+
+ },
+ compareValues: function(value1, value2) {
+ if (value1 === value2) {
+ return this.VALUE_UNCHANGED;
+ }
+ if (this.isDate(value1) && this.isDate(value2) && value1.getTime() === value2.getTime()) {
+ return this.VALUE_UNCHANGED;
+ }
+ if ('undefined' == typeof(value1)) {
+ return this.VALUE_CREATED;
+ }
+ if ('undefined' == typeof(value2)) {
+ return this.VALUE_DELETED;
+ }
+
+ return this.VALUE_UPDATED;
+ },
+ isFunction: function(obj) {
+ return {}.toString.apply(obj) === '[object Function]';
+ },
+ isArray: function(obj) {
+ return {}.toString.apply(obj) === '[object Array]';
+ },
+ isObject: function(obj) {
+ return {}.toString.apply(obj) === '[object Object]';
+ },
+ isDate: function(obj) {
+ return {}.toString.apply(obj) === '[object Date]';
+ },
+ isValue: function(obj) {
+ return !this.isObject(obj) && !this.isArray(obj);
+ }
+ }
+}();
+
+
+export default deepDiffMapper;
diff --git a/src/utils/ExportExcel.js b/src/utils/ExportExcel.js
new file mode 100644
index 0000000..7a4b096
--- /dev/null
+++ b/src/utils/ExportExcel.js
@@ -0,0 +1,394 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2021 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=========================================================
+ */
+
+import {GlobalExtConstants} from './GlobalExtConstants.js';
+import * as Excel from 'exceljs/dist/exceljs.min.js';
+
+let OXM = GlobalExtConstants.OXM;
+let EXCELCELLS = GlobalExtConstants.EXCELCELLS;
+let DOWNLOAD_ALL = GlobalExtConstants.DOWNLOAD_ALL;
+let INVLIST = GlobalExtConstants.INVLIST;
+
+function camelToDash(str) {
+ return (str.replace(/\W+/g, '-')
+ .replace(/([a-z\d])([A-Z])/g, '$1-$2')).toLowerCase();
+}
+
+function sortColumn(col1, col2) {
+ if (col1.value < col2.value) {
+ return -1;
+ } else if (col1.value > col2.value) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+var buildAttrList = function(inputParam, cols, sortBy) {
+ // console.log('[getSearchParam] inputParam: ' + inputParam);
+ let searchParam = inputParam;
+
+ if (['PSERVER', 'COMPLEX', 'CLOUDREGION',
+ 'NETWORKPROFILE', 'VIRTUALDATACENTER','VNFC'].indexOf(inputParam.toUpperCase()) === -1) {
+ searchParam = inputParam.substring(0, inputParam.length - 1);
+ // console.log('[getSearchParam] searchParam: ' + searchParam);
+ }
+ if('CHASSIES'.indexOf(inputParam.toUpperCase()) !== -1){
+ searchParam = inputParam.substring(0, inputParam.length - 2) + 's';
+ }else if(inputParam.substr(inputParam.length - 3) === 'ies'){
+ searchParam = inputParam.substring(0, inputParam.length - 3) + 'y';
+ }else if('COMPLEXES'.indexOf(inputParam.toUpperCase()) !== -1){
+ searchParam = inputParam.substring(0, inputParam.length - 2);
+ }
+ if(inputParam.toUpperCase() === 'PINTERFACES'){
+ searchParam = 'pInterface';
+ }
+ if (inputParam.toUpperCase() === 'LINESOFBUSINESS') {
+ searchParam = 'lineOfBusiness';
+ // console.log('[getSearchParam] searchParam: ' + searchParam);
+ }
+
+ // read oxm xml file
+ let oxmFile = JSON.parse(OXM);
+ let javaTypes = oxmFile['xml-bindings']['java-types'][0]['java-type'];
+ // console.log('[buildAttrList] javaTypes:');
+ // console.log(javaTypes);
+
+ let foundIndex = -1;
+ for (let i = 0; i < javaTypes.length && foundIndex === -1; i++) {
+ if (javaTypes[i]['xml-root-element'][0]['$']['name'] === camelToDash(searchParam)) {
+ // console.log(javaTypes[i]);
+ foundIndex = i;
+ }
+ }
+
+ //Adding Quick fix will be get rid of it later
+ console.log('searchParam>>>>>>>stage2:',inputParam);
+ if(foundIndex === -1){
+ for (let i = 0; i < javaTypes.length && foundIndex === -1; i++) {
+ if (javaTypes[i]['xml-root-element'][0]['$']['name'] === camelToDash(inputParam)) {
+ foundIndex = i;
+ }
+ if(foundIndex === -1){
+ if(inputParam.substr(inputParam.length - 1) === 's'){
+ searchParam = inputParam.substring(0, inputParam.length - 1);
+ console.log('searchParam>>>>>>>stage3:',searchParam);
+ }
+ if (javaTypes[i]['xml-root-element'][0]['$']['name'] === camelToDash(searchParam)) {
+ foundIndex = i;
+ }
+ }
+ }
+ }
+
+ // build the column list
+ let columns = cols;
+ let requiredColumn = [];
+ if(foundIndex > -1) {
+ //for (let j = 0; j < javaTypes[foundIndex]['java-attributes'][0]['xml-element'].length; j++) {
+ // columns.push({value: javaTypes[foundIndex]['java-attributes'][0]['xml-element'][j]['$']['name']});
+ //}
+ if (javaTypes[foundIndex]['java-attributes']) {
+ let elementLength = 0;
+ if (javaTypes[foundIndex]['java-attributes'][0]['xml-element']) {
+ elementLength = javaTypes[foundIndex]['java-attributes'][0]['xml-element'].length;
+ }
+ for (var j = 0; j < elementLength; j++) {
+ let isPrimitive = JSON.stringify(javaTypes[foundIndex]['java-attributes'][0]['xml-element'][j]['$']['type']).indexOf('java.lang') > -1;
+ let reqObj = JSON.stringify(javaTypes[foundIndex]['java-attributes'][0]['xml-element'][j]['$']['required']);
+ let description='';
+ if(javaTypes[foundIndex]['java-attributes'][0]['xml-element'][j]['xml-properties'] && javaTypes[foundIndex]['java-attributes'][0]['xml-element'][j]['xml-properties'][0]['xml-property'][0]['$']['name']=='description'){
+ description= javaTypes[foundIndex]['java-attributes'][0]['xml-element'][j]['xml-properties'][0]['xml-property'][0]['$']['value'];
+ }
+ let node = {value: javaTypes[foundIndex]['java-attributes'][0]['xml-element'][j]['$']['name'],description: description};
+ if(isPrimitive) { //add to the list
+ columns.push(node);
+ }
+ if(reqObj && reqObj.indexOf('true') > -1){
+ requiredColumn.push(node);
+ }
+ }
+ }
+ }
+
+ //sort the column list
+ columns.sort(sortColumn);
+ //Sort column with requiredColumn
+ if(sortBy === 'required'){
+ for(var c=0; c< columns.length; c++){
+ if(requiredColumn.indexOf(columns[c]) === -1){
+ requiredColumn.push(columns[c]);
+ }
+ }
+ }
+ if(sortBy && (sortBy === 'required' || sortBy === 'mandatory')){
+ columns = requiredColumn;
+ }
+ // console.log('[buildAttrList] columns:');
+ // console.log(columns);
+
+ return columns;
+}
+var getDescriptionForNodes= function (){
+ var invKeys = Object.keys(INVLIST.INVENTORYLIST);
+ let oxmFile = JSON.parse(OXM);
+ let javaTypes = oxmFile['xml-bindings']['java-types'][0]['java-type'];
+ let nodeDescriptionObj={};
+ let invList = invKeys.map(item => {
+ for (let i = 0; i < javaTypes.length; i++) {
+ if(javaTypes[i]['$']['name'].toLowerCase() === camelToDash(INVLIST.INVENTORYLIST[item].modelPath).toLowerCase()) {
+ if(javaTypes[i]['xml-properties'] !== undefined && javaTypes[i]['xml-properties'][0]['xml-property'] && javaTypes[i]['xml-properties'][0]['xml-property'][0]['$']['name']==='description'){
+ nodeDescriptionObj[INVLIST.INVENTORYLIST[item].modelPath]=javaTypes[i]['xml-properties'][0]['xml-property'][0]['$']['value'];
+ }else{
+ nodeDescriptionObj[INVLIST.INVENTORYLIST[item].modelPath]='';
+ }
+ }
+ }
+ return nodeDescriptionObj;
+ });
+ return invList;
+}
+
+var generateExcels = function(nodeResults,dslQuery) {
+ console.log('inside generateExcels>>>>>');
+ //Creating New Workbook
+ var workbook = new Excel.Workbook();
+ var nodesType = [];
+ var worksheet;
+ var columnsJsonObj = {}
+ var columnsList = []
+ columnsJsonObj.columns = columnsList;
+ var nodesLength = nodeResults.length;
+ console.log('nodeResults.length.......',nodesLength);
+ for(var n=0;n<nodesLength;n++){
+ //Creating Sheet for that particular WorkBook
+ let nodeTypeVal = nodeResults[n]["node-type"];
+ let url = nodeResults[n]["url"];
+ let columns = [];
+ let buildColumns = [];
+ if(nodesType.indexOf(nodeTypeVal) == -1){
+ nodesType.push(nodeTypeVal);
+ worksheet = workbook.addWorksheet(nodeTypeVal,{properties: {showGridLines: true}});
+ buildColumns = buildAttrList(nodeTypeVal, [], 'required');
+ if(dslQuery){
+ let tempDslQuery= dslQuery+',';
+ let nodeTypeProperties ='';
+ let plainNodes ='';
+ var nodePatternwithProp = generateRegexForDsl(nodeTypeVal);
+ var nodeRegularExp = new RegExp(nodePatternwithProp, 'g');
+ plainNodes = tempDslQuery.match(nodeRegularExp);
+ console.log('plainNodes model Gallery null>>>>>*',plainNodes);
+ if(plainNodes){
+ let propertiesPattern ="\\{.*?\\}";
+ var propRegularExp = new RegExp(propertiesPattern, 'g');
+ nodeTypeProperties = plainNodes[0].match(propRegularExp);
+ console.log('nodeTypeProperties model Gallery>>>>>*',nodeTypeProperties);
+ nodeTypeProperties = nodeTypeProperties[0].slice(1,-1).replace(/\'/g,'').toLowerCase().split(',');
+ for(var z=0;z<buildColumns.length;z++){
+ if(nodeTypeProperties.indexOf(buildColumns[z].value.toLowerCase()) !== -1){
+ columns.push(buildColumns[z]);
+ }
+ }
+ console.log('on condition table columns>>>>',columns);
+ }else{
+ columns=buildColumns;
+ }
+ }else{
+ columns=buildColumns;
+ }
+ columns.push({value: 'uri'});
+ columns.push({value: 'relationship-list'});
+ var column = {
+ [nodeTypeVal] : columns
+ }
+ columnsJsonObj.columns.push(column);
+ if (!worksheet.columns) {
+ worksheet.columns = Object.keys(columns).map((k) => ({ header: columns[k].value, key: columns[k].value, width:15}))
+ }
+ }else{
+ worksheet = workbook.getWorksheet(nodeTypeVal);
+ let col = columnsJsonObj.columns;
+ for(var c in col){
+ if(col[c][nodeTypeVal]){
+ columns = col[c][nodeTypeVal];
+ }
+ }
+ }
+ var excelCellsHeader = [];
+ var loop = 0;
+ var noOfCol = Math.ceil(columns.length/26);
+ while(loop<noOfCol){
+ if(loop === 0){
+ for(var j=0; j<EXCELCELLS.length; j++){
+ excelCellsHeader.push(EXCELCELLS[j]);
+ }
+ }else{
+ for(var j=0; j<EXCELCELLS.length; j++){
+ excelCellsHeader.push(EXCELCELLS[loop-1]+EXCELCELLS[j]);
+ }
+ }
+ loop++;
+ }
+ console.log('excelCellsHeader.......',excelCellsHeader);
+ console.log('worksheet.columns>>>>',worksheet.columns);
+ var row = [];
+ var relativeRow = [];
+ var rows = [];
+ for(var x in columns){
+ if(nodeResults[n].properties[columns[x].value] !== undefined){
+ row.push(nodeResults[n].properties[columns[x].value]);
+ relativeRow.push("");
+ }else{
+ row.push("");
+ relativeRow.push("");
+ }
+ }
+ row[row.length-2] = url;
+ console.log('Push Row after>>>>>>>>>>>',row);
+ var relationships = [];
+ if(nodeResults[n]["related-to"]){
+ let relative =nodeResults[n]["related-to"];
+ var relativeLength = relative.length;
+ console.log('relativeLength>>>>>>>>>>>',relativeLength);
+ if(relativeLength>0){
+ for(var r = 0; r<relative.length; r++){
+ var relationship = '';
+ var relationshipLabel = '';
+ var nodeType = '';
+ var localUrl = '';
+ for(var k in relative[r]){
+ let relation = k.toString();
+ if(relation === 'relationship-label'){
+ relationshipLabel = relative[r][k].toString().slice(33);
+ }
+ if(relation === 'node-type'){
+ nodeType = relative[r][k].toString();
+ }
+ if(relation === 'url'){
+ localUrl = relative[r][k].toString();
+ }
+ }
+ relationship = 'Relationship ' + relationshipLabel + ' ' + nodeType + ' - ' + localUrl;
+ if(r===0){
+ row[row.length-1] = relationship;
+ rows.push(row);
+ }else{
+ let tempRow = [];
+ tempRow = [...relativeRow]; // cloning in ES6 Way to avoid deep copy
+ tempRow[tempRow.length-1] = relationship;
+ rows.push(tempRow);
+ }
+ }
+ }else{
+ rows.push(row);
+ }
+ }else{
+ rows.push(row);
+ }
+ console.log('Rows before pushing>>>>>>>>>>>',rows);
+ let initMergeCell = (n==0) ? 2: worksheet.rowCount + 1;
+ worksheet.addRows(rows);
+ console.log('initMergeCell>>>>>>',initMergeCell);
+ //worksheet.getColumn(columns.length).values = relationships;
+ let lastMergeCell = (relativeLength==0)? initMergeCell : initMergeCell + relativeLength - 1;
+ console.log('lastMergeCell>>>>>>',lastMergeCell);
+ for(var x=0;x<columns.length-1;x++){
+ var cell = excelCellsHeader[x] + initMergeCell +':'+excelCellsHeader[x]+lastMergeCell;
+ worksheet.mergeCells(cell);
+ }
+ }
+ var workbookName = 'NodesList_'+nodesLength+'_Results.xlsx';
+ generateWorkbook(workbook,workbookName);
+ }
+ var generateRegexForDsl= function(nodeType){
+ var nodePatternwithProp = nodeType+"\\*\\{.*?\\}\\(.*?\\)[\\,|\\>|\\]|\\)]|"+nodeType+"\\*\\(.*?\\)\\{.*?\\}[\\,|\\>|\\]|\\)]|"+nodeType+"\\{.*?\\}\\(.*?\\)[\\,|\\>|\\]|\\)]|"+nodeType+"\\(.*?\\)\\{.*?\\}[\\,|\\>|\\]|\\)]|"+nodeType+"\\{.*?\\}[\\,|\\>|\\]|\\)]|"+nodeType+"\\*\\{.*?\\}[\\,|\\>|\\]|\\)]";
+ return nodePatternwithProp;
+ }
+ var generateExcelFromTabularView = function(tabledata,tableheaders,workbookName) {
+ console.log('inside generateExcelFromTabularView>>>>>');
+ //Creating New Workbook
+ var workbook = new Excel.Workbook();
+ var worksheet = workbook.addWorksheet('Results',{properties: {showGridLines: true}});
+ var columns = [];
+ if (!worksheet.columns) {
+ worksheet.columns = Object.keys(tableheaders).map((k) => ({ header: tableheaders[k].name, key: tableheaders[k].name, width:20}))
+ }
+ var rows = [];
+ var row = [];
+ for(var n=0; n<tabledata.length; n++){
+ console.log('TableData<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<',tabledata[n]);
+ row = [];
+ Object.keys(tableheaders).map((k) => { row.push(tabledata[n][tableheaders[k].name])});
+ rows.push(row);
+ }
+ worksheet.addRows(rows);
+ generateWorkbook(workbook,workbookName);
+ }
+ var generateExcelFromTabularViewMultiTabs = function(tabData,tabHeaders,workBookName) {
+ console.log('inside generateExcelFromTabularViewMultiTabs>>>>>');
+ //Creating New Workbook
+ var workbook = new Excel.Workbook();
+ Object.keys(tabData).forEach((key,index) => {
+ var worksheet = workbook.addWorksheet((index+1)+'_'+key,{properties: {showGridLines: true}});
+ var columns = [];
+ var tableData = tabData[key];
+ var tableHeaders = tabHeaders[key];
+ if (!worksheet.columns) {
+ worksheet.columns = Object.keys(tableHeaders).map((k) => ({ header: tableHeaders[k].name, key: tableHeaders[k].name, width:20}))
+ }
+ var rows = [];
+ var row = [];
+ for(var n = 0; n < tableData.length; n++){
+ console.log('TableData<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<',tableData[n]);
+ row = [];
+ Object.keys(tableHeaders).map((k) => { row.push(tableData[n][tableHeaders[k].name])});
+ rows.push(row);
+ }
+ worksheet.addRows(rows);
+ });
+ generateWorkbook(workbook,workBookName);
+ }
+ var generateViolationExcels = function(tabledata,tableheaders) {
+ generateExcelFromTabularView(tabledata, tableheaders, 'DataIntegrityViolationTable.xlsx');
+ }
+ var generateWorkbook = function(workbook,workbookName){
+ console.log('generateWorkbook :',workbookName);
+ workbook.xlsx.writeBuffer().then(function (data) {
+ const blob = new Blob([data],
+ { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
+ const url = window.URL.createObjectURL(blob);
+ const anchor = document.createElement('a');
+ document.body.appendChild(anchor);
+ anchor.href = url;
+ anchor.download = workbookName;
+ anchor.click();
+ window.URL.revokeObjectURL(url);
+ });
+ }
+
+
+export const ExportExcel = {
+ buildAttrList : buildAttrList,
+ generateExcels : generateExcels,
+ generateViolationExcels : generateViolationExcels,
+ generateExcelFromTabularView: generateExcelFromTabularView,
+ generateExcelFromTabularViewMultiTabs: generateExcelFromTabularViewMultiTabs,
+ getDescriptionForNodes: getDescriptionForNodes
+};
diff --git a/src/utils/GeneralCommonFunctions.js b/src/utils/GeneralCommonFunctions.js
new file mode 100644
index 0000000..1f2d0e1
--- /dev/null
+++ b/src/utils/GeneralCommonFunctions.js
@@ -0,0 +1,344 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2021 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=========================================================
+ */
+
+import {GlobalExtConstants} from 'utils/GlobalExtConstants.js';
+
+let OXM = GlobalExtConstants.OXM;
+
+var scrollTo = function(id) {
+ setTimeout(function () {
+ document.getElementById("main-app-container").scrollTop = document.getElementById(id).offsetTop;
+ }, 100);
+}
+var populatePathDSL = function(tree, isInit, onLoad, enableRealTime){
+ console.log('populatePathDSL>>>>>>> pathFIlter****',tree);
+ var DSL = '';
+ var treeArray = '';
+ var treeArrayLength = 0;
+ if(isInit){
+ treeArray = tree;
+ treeArrayLength = 1;
+ }else{
+ treeArray = tree.children;
+ treeArrayLength = tree.children.length;
+ }
+ for(var k = 0; treeArray && k < treeArrayLength; k++){
+ if(k === 0 && treeArrayLength > 1){
+ DSL += '[';
+ }
+ var node = '';
+ if(isInit){
+ node = tree;
+ }else{
+ node = treeArray[k];
+ }
+ var nodeData=(onLoad)?node:node.data;
+ if(nodeData){
+ console.log('***************',JSON.stringify(nodeData));
+ if(isInit){
+ DSL += '(>'+nodeData.name;
+ }else{
+ DSL += nodeData.name;
+ }
+
+ let propState=false;
+ if(nodeData.details){
+ var tempAttributeString = '';
+ var selectedAttributeCount = 0;
+ for (var key in nodeData.details.attrDetails){
+ if(nodeData.details.attrDetails[key].filterValue && nodeData.details.attrDetails[key].filterValue[0] !==''){
+ DSL += '(\'' + nodeData.details.attrDetails[key].attributeName + '\',';
+ let dslValues='';
+ for(var indx=0; indx<nodeData.details.attrDetails[key].filterValue.length; indx++){
+ dslValues=(indx>0) ? dslValues+',':dslValues;
+ if(enableRealTime && nodeData.details.attrDetails[key].filterType && nodeData.details.attrDetails[key].filterType[indx]){
+ dslValues += nodeData.details.attrDetails[key].filterType[indx]+'(\''+ nodeData.details.attrDetails[key].filterValue[indx] + '\')';
+ }else{
+ dslValues +='\''+nodeData.details.attrDetails[key].filterValue[indx] + '\'';
+ }
+ if(nodeData.details.attrDetails[key].filterValue.length-1 === indx){
+ dslValues +=')';
+ }
+ }
+ DSL += dslValues;
+ }
+ }
+ }
+ }
+ if(node.children && node.children.length>0){
+ DSL+= '>' + populatePathDSL(node,false,onLoad,enableRealTime);
+ }
+ if(k !== treeArrayLength - 1){
+ DSL += ',';
+ }
+ if(k === treeArrayLength - 1 && treeArrayLength > 1){
+ DSL += ']';
+ }
+ }
+ if(isInit){
+ DSL+=')';
+ }
+ return DSL;
+ }
+ var getFilteringOptions = function(nodeType){
+ var propertiesDsl = [];
+ var result = JSON.parse(OXM);
+ var arrayOfTypes = result['xml-bindings']['java-types'][0]['java-type'];
+ //console.dir(arrayOfTypes);
+ var foundIndex = -1;
+ var searchParam = nodeType;
+
+ if (nodeType.toUpperCase() === 'LINESOFBUSINESS') {
+ searchParam = 'lineOfBusiness';
+ }
+ //console.log('searchParam:' + searchParam);
+ for (var i = 0; i < arrayOfTypes.length && foundIndex === -1; i++) {
+ if (arrayOfTypes[i]['xml-root-element'][0]['$']['name'] === camelToDash(searchParam)) {
+ foundIndex = i;
+ }
+ }
+ if(foundIndex && arrayOfTypes[foundIndex]){
+ //build the filter list
+ for (var j = 0; j < arrayOfTypes[foundIndex]['java-attributes'][0]['xml-element'].length; j++) {
+ let property = arrayOfTypes[foundIndex]['java-attributes'][0]['xml-element'][j]['$']['name'];
+ let type = arrayOfTypes[foundIndex]['java-attributes'][0]['xml-element'][j]['$']['type'];
+ if(property !== 'length'){
+ if (type === 'java.lang.String' || type === 'java.lang.Boolean' || type === 'java.lang.Long' || type === 'java.lang.Integer') {
+ propertiesDsl[property] = {};
+ propertiesDsl[property].isSelected = false;
+ propertiesDsl[property].attributeName = property;
+ propertiesDsl[property].filterValue = [''];
+ propertiesDsl[property].filterType = [''];
+ propertiesDsl[property].dslPath = [];
+ propertiesDsl[property].dslPathTree = [];
+ }
+ }
+ }
+ let sortedPropertiesDsl = propertiesDsl.sort(function (filter1, filter2) {
+ if (filter1.attributeName < filter2.attributeName) {
+ return -1;
+ } else if (filter1.attributeName > filter2.attributeName) {
+ return 1;
+ } else {
+ return 0;
+ }
+ });
+ //console.log('FilterList' + JSON.stringify(sortedPropertiesDsl));
+ return sortedPropertiesDsl;
+ }else{
+ return [];
+ }
+ }
+ var getNodeTypes = function(){
+ var result = JSON.parse(OXM);
+ var arrayOfTypes = result['xml-bindings']['java-types'][0]['java-type'];
+ var nodeTypeArray = [];
+ for(var j = 0; j < arrayOfTypes.length; j++){
+ if(arrayOfTypes[j]['xml-root-element'] && arrayOfTypes[j]['xml-root-element'][0]
+ && arrayOfTypes[j]['xml-root-element'][0]['$'] && arrayOfTypes[j]['xml-root-element'][0]['$']['name']){
+ nodeTypeArray.push((arrayOfTypes[j]['xml-root-element'][0]['$']['name']).toLowerCase());
+ }
+ }
+ return nodeTypeArray;
+ }
+ var populateContainer = function(nodeType){
+ var result = JSON.parse(OXM);
+ var arrayOfTypes = result['xml-bindings']['java-types'][0]['java-type'];
+ var isFound = false;
+ var container = '';
+ for (var i = 0; i < arrayOfTypes.length && !isFound; i++) {
+ if(arrayOfTypes[i]['xml-root-element'][0]['$']['name'] === nodeType
+ && arrayOfTypes[i]['xml-properties']
+ && arrayOfTypes[i]['xml-properties'][0]
+ && arrayOfTypes[i]['xml-properties'][0]['xml-property']){
+ isFound = true;
+ for(var k = 0; k < arrayOfTypes[i]['xml-properties'][0]['xml-property'].length; k++){
+ if(arrayOfTypes[i]['xml-properties'][0]['xml-property'][k]['$']['name'] === 'container'){
+ container = arrayOfTypes[i]['xml-properties'][0]['xml-property'][k]['$']['value'];
+ }
+ }
+ }
+ }
+ return container;
+ }
+ var getEditableAttributes = function(nodeType){
+ //get this from the oxm field
+ var result = JSON.parse(OXM);
+ var arrayOfTypes = result['xml-bindings']['java-types'][0]['java-type'];
+ var isFound = false;
+ var uiEditableProps = [];
+ for (var i = 0; i < arrayOfTypes.length && !isFound; i++) {
+ if(arrayOfTypes[i]['xml-root-element'][0]['$']['name'] === nodeType
+ && arrayOfTypes[i]['xml-properties']
+ && arrayOfTypes[i]['xml-properties'][0]
+ && arrayOfTypes[i]['xml-properties'][0]['xml-property']){
+ isFound = true;
+ for(var k = 0; k < arrayOfTypes[i]['xml-properties'][0]['xml-property'].length; k++){
+ if(arrayOfTypes[i]['xml-properties'][0]['xml-property'][k]['$']['name'] === 'uiEditableProps'){
+ uiEditableProps = ((arrayOfTypes[i]['xml-properties'][0]['xml-property'][k]['$']['value']).replace(/\s/g,"")).split(',');
+ }
+ }
+ }
+ }
+ return uiEditableProps;
+ }
+ var populateEdgeRules = function(nodeType,edgeRules){
+ var nodeDetails = [];
+ var node = null;
+ console.log('populateEdgeRules.nodeType: ' + nodeType);
+ var id = generateID();
+ for (var i = 0; i < edgeRules.length; i++) {
+ var ruleObj = edgeRules[i];
+ if (ruleObj.from === nodeType && !nodeDetails[ruleObj.to + id]) {
+ node = ruleObj.to + id;
+ if(!nodeDetails[node]){
+ nodeDetails[node] = {};
+ nodeDetails[node].nodeType = ruleObj.to;
+ nodeDetails[node].isSelected = false;
+ nodeDetails[node].attrDetails = GeneralCommonFunctions.getFilteringOptions(ruleObj.to);
+ nodeDetails[node].parentContainer = GeneralCommonFunctions.populateContainer(ruleObj.to);
+ }
+ }
+ if (ruleObj.to === nodeType && !nodeDetails[ruleObj.from + id]) {
+ node = ruleObj.from + id;
+ if(!nodeDetails[node]){
+ nodeDetails[node] = {};
+ nodeDetails[node].nodeType = ruleObj.from;
+ nodeDetails[node].isSelected = false;
+ nodeDetails[node].attrDetails = GeneralCommonFunctions.getFilteringOptions(ruleObj.from);
+ nodeDetails[node].parentContainer = GeneralCommonFunctions.populateContainer(ruleObj.from);
+ }
+ }
+ }
+ let nodesSorted = nodeDetails.sort(function (filter1, filter2) {
+ if (filter1.nodeType < filter2.nodeType) {
+ return -1;
+ } else if (filter1.nodeType > filter2.nodeType) {
+ return 1;
+ } else {
+ return 0;
+ }
+ });
+ console.log('EdgeRulesList' + JSON.stringify(nodesSorted));
+ nodeDetails = nodesSorted;
+ return nodeDetails;
+ }
+var camelToDash = function(str){
+ return (str.replace(/\W+/g, '-')
+ .replace(/([a-z\d])([A-Z])/g, '$1-$2')).toLowerCase();
+}
+var generateID = function(){
+ return Math.random().toString().replace('0.', '');
+}
+var extractNodeDetails = function(node, isRoot, errorFunction, isAperture){
+ let nodeType = node['node-type'];
+ let nodeData = {
+ "name": nodeType,
+ "id": nodeType,
+ "children": [],
+ "details":{}
+ }
+ nodeData.details.includeInOutput = node.store;
+ nodeData.details.isSelected = true;
+ nodeData.details.isRootNode = isRoot;
+ nodeData.details.nodeType = nodeType;
+ var attributes = GeneralCommonFunctions.getFilteringOptions(nodeType);
+ nodeData.details.attrDetails = attributes;
+ nodeData.details.parentContainer = GeneralCommonFunctions.populateContainer(nodeType);
+ if(node.store && !node['requested-props']){
+ for(var key in nodeData.details.attrDetails){
+ nodeData.details.attrDetails[key].isSelected = true;
+ }
+ }else if (node.store && node['requested-props']){
+ for(var key in node['requested-props']){
+ nodeData.details.attrDetails[key].isSelected = true;
+ }
+ }
+ var isValid = true;
+ for (var x in node['node-filter']){
+ if(isValid){
+ for (var y in node['node-filter'][x]) {
+ if(isValid){
+ var attrKey = node['node-filter'][x][y]['key'];
+ var filter = node['node-filter'][x][y]['filter'];
+ //If aperture is not turned on and query loaded uses anything besides EQ throw error
+ //when merged with calls from builder use condition to enable this
+ /*if(!isAperture && filter !== 'EQ'){
+ errorFunction(null, "invalidQuery");
+ isValid = false;
+ }*/
+ if(!nodeData.details.attrDetails[attrKey]){
+ nodeData.details.attrDetails[attrKey] = {};
+ }
+ if(nodeData.details.attrDetails[attrKey].filterType.length > 0 && nodeData.details.attrDetails[attrKey].filterType[0] === ''){
+ nodeData.details.attrDetails[attrKey].filterType = [];
+ }
+ if(nodeData.details.attrDetails[attrKey].filterValue.length > 0 && nodeData.details.attrDetails[attrKey].filterValue[0] === ''){
+ nodeData.details.attrDetails[attrKey].filterValue = [];
+ }
+
+ if(node['node-filter'][x][y]['value'][0]){
+ for (var i in node['node-filter'][x][y]['value']){
+ nodeData.details.attrDetails[attrKey].filterType.push(filter);
+ nodeData.details.attrDetails[attrKey].filterValue.push(node['node-filter'][x][y]['value'][i]);
+ }
+ if(!nodeData.details.attrDetails[attrKey].attributeName){
+ nodeData.details.attrDetails[attrKey].attributeName = attrKey;
+ }
+ }else{
+ //if a filter had no values associated to it do nothing
+ //when merged with calls from builder use condition to enable this
+ /* errorFunction(null, "invalidQuery");
+ isValid = false; */
+ }
+ }
+ }
+ }
+ }
+ var initWhereNode = null;
+ if(node['where-filter'].length > 0){
+ for(var index in node['where-filter']){
+ initWhereNode = GeneralCommonFunctions.extractNodeDetails(node['where-filter'][index].children[0], true);
+ }
+ }
+ if(initWhereNode){
+ nodeData.details.dslPath=[];
+ nodeData.details.dslPathTree=[];
+ nodeData.details.dslPathTree.push(initWhereNode);
+ }
+ if(node.children.length > 0){
+ for(var i = 0; i < node.children.length; i++){
+ nodeData.children[i] = GeneralCommonFunctions.extractNodeDetails(node.children[i], false);
+ }
+ }
+ return nodeData;
+}
+export const GeneralCommonFunctions = {
+ scrollTo: scrollTo,
+ populatePathDSL: populatePathDSL,
+ getFilteringOptions: getFilteringOptions,
+ getNodeTypes: getNodeTypes,
+ populateContainer: populateContainer,
+ populateEdgeRules: populateEdgeRules,
+ camelToDash: camelToDash,
+ generateID: generateID,
+ extractNodeDetails: extractNodeDetails,
+ getEditableAttributes: getEditableAttributes
+};
diff --git a/src/utils/GlobalConstants.js b/src/utils/GlobalConstants.js
index 56de6eb..e3ce2a9 100644
--- a/src/utils/GlobalConstants.js
+++ b/src/utils/GlobalConstants.js
@@ -40,4 +40,22 @@ export const STATUS_CODE_5XX_SERVER_ERROR = 500;
export const filterBarActionTypes = keyMirror(FilterBarConstants.FILTER_BAR_ACTION_TYPES);
-export const UNIFIED_FILTERS_URL = BASE_URL + '/rest/search/unifiedFilterRequest'; \ No newline at end of file
+export const UNIFIED_FILTERS_URL = BASE_URL + '/rest/search/unifiedFilterRequest';
+
+var url = window.location.href;
+var environment = '';
+var APP_TITLE_REGX = '\/services\/(\\w+)';
+var APP_TITLE_REGX_LOCAL = '\/(\\w+)/#';
+if(url.includes('localhost')){
+ var regTitle = new RegExp(APP_TITLE_REGX_LOCAL);
+ environment = url.match(regTitle)[1].toUpperCase() + '_LOCALHOST_';
+}else if (url.includes('ecompc_')){
+ environment = url.split('/')[3] + '_';
+}else{
+ var regTitle = new RegExp(APP_TITLE_REGX);
+ environment = url.match(regTitle)[1].toUpperCase() + '_NON_WEBJUNCTION_';
+}
+
+export const ENVIRONMENT = environment;
+
+
diff --git a/src/utils/GlobalExtConstants.js b/src/utils/GlobalExtConstants.js
new file mode 100644
index 0000000..3a5f223
--- /dev/null
+++ b/src/utils/GlobalExtConstants.js
@@ -0,0 +1,110 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2021 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=========================================================
+ */
+
+
+const appConfigJson = require('app/assets/configuration/app_config.json');
+const BACKEND_IP_ADDRESS = document.location.hostname;
+const BACKEND_PORT_NUMBER = window.location.port;
+const PROTOCOL = window.location.protocol;
+var url = window.location.href;
+var environment = '';
+if(url.includes('localhost')){
+ var regTitle = new RegExp(appConfigJson.APP_TITLE_REGX_LOCAL);
+ environment = url.match(regTitle)[1].toUpperCase() + '_LOCALHOST_';
+}else if (url.includes('ecompc_')){
+ environment = url.split('/')[3] + '_';
+}else{
+ var regTitle = new RegExp(appConfigJson.APP_TITLE_REGX);
+ environment = url.match(regTitle)[1].toUpperCase() + '_NON_WEBJUNCTION_';
+}
+
+let pathNameVar = sessionStorage.getItem(environment + 'PAGE_TITLE');
+let apertureService = JSON.parse(sessionStorage.getItem(environment + 'APERTURE_SERVICE'));
+console.log('GlobalExtConstants apertureService************',apertureService);
+if (!pathNameVar || pathNameVar === '' || pathNameVar === null) {
+ if(url.includes('localhost')){
+ var regTitle = new RegExp(appConfigJson.APP_TITLE_REGX_LOCAL);
+ sessionStorage.setItem(environment + 'PAGE_TITLE',url.match(regTitle)[1].toUpperCase());
+ }else{
+ var regTitle = new RegExp(appConfigJson.APP_TITLE_REGX);
+ sessionStorage.setItem(environment + 'PAGE_TITLE',url.match(regTitle)[1].toUpperCase());
+ }
+}
+
+console.log('sessionStorage.getItem(PAGE_TITLE)>>>>>',sessionStorage.getItem(environment + 'PAGE_TITLE'));
+pathNameVar = sessionStorage.getItem(environment + 'PAGE_TITLE').toLowerCase();
+if(pathNameVar === 'a&ai'){
+ pathNameVar = 'aai';
+}
+const appName = appConfigJson[pathNameVar.toUpperCase()];
+const inventoryList = require('app/assets/configuration/' + pathNameVar + '/' + appName.INVLIST);
+
+var base = '';
+var url = window.location.href;
+if(url.includes('ecompc_')){
+ base = PROTOCOL + '//' + BACKEND_IP_ADDRESS + '/' + url.split('/')[3];
+}else{
+ base = PROTOCOL + '//' + BACKEND_IP_ADDRESS + ':' + BACKEND_PORT_NUMBER;
+}
+const baseURL = base;
+
+var overrideDomain = baseURL;
+if(inventoryList.NODESERVER){
+ overrideDomain = 'https://' + inventoryList.NODESERVER;
+}
+/*
+REGEX - will use the REGEXP operation
+EQ
+CONTAINS - will use the LIKE operation in mysql (case insensitive by default)
+STARTS_WITH - will use the LIKE operation in mysql (case insensitive by default)
+ENDS_WITH - will use the LIKE operation in mysql (case insensitive by default)
+GT
+LT
+GTE
+LTE
+*/
+
+
+var filterTypeList = ['EQ','NEQ','CONTAINS','NOT_CONTAINS','STARTS_WITH','NOT_STARTS_WITH','ENDS_WITH','NOT_ENDS_WITH','GT','LT','GTE','LTE','REGEX','NOT_REGEX'];
+var tabularFilterType = (apertureService) ? 'CONTAINS' : '=';
+var uriDelimiter = '*';
+
+
+export const GlobalExtConstants = {
+ TITLE : appName.TITLE,
+ ENVIRONMENT : environment,
+ PATHNAME : pathNameVar,
+ BASE_URL : baseURL,
+ OVERRIDE_DOMAIN: overrideDomain,
+ CUSTOMQUERYLIST : require('app/assets/configuration/' + pathNameVar + '/' + appName.CUSTQUERYLIST),
+ INVLIST : inventoryList,
+ EDGERULES : require('app/assets/configuration/' + pathNameVar + '/dbedgeRules.json'),
+ OXM : JSON.stringify(require('app/assets/configuration/' + pathNameVar + '/' + appName.OXM)),
+ COLOR_BLUE : '#009fdb',
+ PAGINATION_CONSTANT : { RESULTS_PER_PAGE : 50 , PAGE_RANGE_DISPLAY : 10},
+ DOWNLOAD_ALL : 500,
+ EXCELCELLS : ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'],
+ DOWNLOAD_TOOLTIP : 'Downloads Current Page Results',
+ APERTURE_SERVICE : apertureService,
+ FILTER_TYPES: filterTypeList,
+ TABULAR_FILTER_TYPE: tabularFilterType,
+ URI_DELIMITCHAR: uriDelimiter,
+ EMAIL_EXT: '@test.com'
+};
diff --git a/src/utils/OxmUtility.js b/src/utils/OxmUtility.js
new file mode 100644
index 0000000..513ee42
--- /dev/null
+++ b/src/utils/OxmUtility.js
@@ -0,0 +1,28 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2021 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=========================================================
+ */
+/*import {PATHNAME} from './GlobalExtConstants.js';
+
+export function loadOxmFile() {
+ if (!sessionStorage.getItem('oxmFile')) {
+ console.log('[LoadOxmFile] sending request to oxm file');
+ const aaiOxm = require('../assets/configuration/' + PATHNAME + '/oxm.xml');
+ sessionStorage.setItem('oxmFile', JSON.stringify(aaiOxm));
+ }
+}*/
diff --git a/src/utils/Routes.js b/src/utils/Routes.js
index 3d1b4cf..8130671 100644
--- a/src/utils/Routes.js
+++ b/src/utils/Routes.js
@@ -18,8 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-import {encrypt } from './Crypto.js';
-import { decrypt } from '../utils/Crypto.js';
+import {encrypt, decrypt } from './Crypto.js';
export function changeUrlAddress(pathObj, historyObj) {
diff --git a/src/utils/SpinnerContainer.jsx b/src/utils/SpinnerContainer.jsx
index 17e6e58..648a2e4 100644
--- a/src/utils/SpinnerContainer.jsx
+++ b/src/utils/SpinnerContainer.jsx
@@ -19,16 +19,17 @@
* ============LICENSE_END=========================================================
*/
import React, { Component } from 'react';
-import { PropTypes } from 'prop-types';
import { ClipLoader } from 'react-spinners';
-import {COLOR_BLUE} from 'utils/GlobalConstants.js';
+import {COLOR_BLUE} from './GlobalExtConstants.js';
+import { PropTypes } from 'prop-types';
class SpinnerContainer extends Component {
render() {
// if loading, show content as busy (ex: grey out)
- const spinnerContentClass = this.props.loading ? 'spin-content' : '';
+ const spinnerContentClass = this.props.loading ? 'spinner-content' : '';
+ const containerClass = this.props.fullscreen ? 'col-lg-12 spinner-container' : 'spinner-container';
return (
- <div className='spin-container'>
+ <div className={containerClass}>
<div className='spinner'>
<ClipLoader color={COLOR_BLUE} loading={this.props.loading} />
</div>