diff options
Diffstat (limited to 'sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents')
11 files changed, 1028 insertions, 0 deletions
diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-bundle/pom.xml b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-bundle/pom.xml new file mode 100644 index 00000000..9a9504ac --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-bundle/pom.xml @@ -0,0 +1,115 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>mwtnEvents</artifactId> + <groupId>com.highstreet.technologies.odl.dlux</groupId> + <version>0.5.1-SNAPSHOT</version> + </parent> + <artifactId>mwtnEvents-bundle</artifactId> + <name>${prefix} ${project.artifactId}</name> + <packaging>bundle</packaging> + <dependencies> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <version>${osgi.core.version}</version> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.compendium</artifactId> + <version>${osgi.core.version}</version> + </dependency> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.osgi.compendium</artifactId> + <version>${apache.felix.compendium}</version> + </dependency> + <dependency> + <groupId>org.opendaylight.dlux</groupId> + <artifactId>loader</artifactId> + <version>${dlux.loader.version}</version> + </dependency> + <dependency> + <groupId>com.highstreet.technologies.odl.dlux</groupId> + <artifactId>mwtnEvents-module</artifactId> + <version>0.5.1-SNAPSHOT</version> + </dependency> + </dependencies> + <build> + <resources> + <resource> + <directory>target/generated-resources</directory> + </resource> + <resource> + <directory>src/main/resources</directory> + </resource> + </resources> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <version>2.6</version> + <executions> + <!--loader Resources --> + <execution> + <id>unpack-loader-resources</id> + <goals> + <goal>unpack-dependencies</goal> + </goals> + <phase>generate-resources</phase> + <configuration> + <outputDirectory>${project.build.directory}/generated-resources</outputDirectory> + <groupId>com.highstreet.technologies.odl.dlux</groupId> + <includeArtifactIds>mwtnEvents-module</includeArtifactIds> + <excludes>META-INF\/**</excludes> + <excludeTransitive>true</excludeTransitive> + <ignorePermissions>false</ignorePermissions> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Import-Package>org.osgi.service.http, + org.osgi.framework;version="1.0.0", + org.opendaylight.dlux.loader + </Import-Package> + <Export-Package></Export-Package> + </instructions> + </configuration> + </plugin> + <!-- <plugin> + <artifactId>maven-resources-plugin</artifactId> + <version>3.0.1</version> + <executions> + <execution> + <id>copy-resources</id> + <!- - here the phase you need - -> + <phase>package</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>../../deploy</outputDirectory> + <resources> + <resource> + <directory>target</directory> + <includes> + <include>${project.artifactId}-${project.version}.jar</include> + </includes> + <filtering>true</filtering> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> --> + </plugins> + </build> +</project> diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 00000000..4cac53b2 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,19 @@ +<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> + <reference id="httpService" availability="mandatory" activation="eager" interface="org.osgi.service.http.HttpService"/> + <reference id="loader" availability="mandatory" activation="eager" interface="org.opendaylight.dlux.loader.DluxModuleLoader"/> + + <bean id="bundle" init-method="initialize" destroy-method="clean" class="org.opendaylight.dlux.loader.DluxModule"> + <property name="httpService" ref="httpService"/> + <property name="loader" ref="loader"/> + <property name="moduleName" value="mwtnEvents"/> + <property name="url" value="/src/app/mwtnEvents"/> + <property name="directory" value="/mwtnEvents"/> + <property name="requireJs" value="app/mwtnEvents/mwtnEvents.module"/> + <property name="angularJs" value="app.mwtnEvents"/> + <property name="cssDependencies"> + <list> + <value>src/app/mwtnEvents/mwtnEvents-custom.css</value> + </list> + </property> + </bean> +</blueprint>
\ No newline at end of file diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/pom.xml b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/pom.xml new file mode 100644 index 00000000..cf3ec048 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/pom.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>mwtnEvents</artifactId> + <groupId>com.highstreet.technologies.odl.dlux</groupId> + <version>0.5.1-SNAPSHOT</version> + </parent> + <artifactId>mwtnEvents-module</artifactId> + <name>${prefix} ${project.artifactId}</name> + <packaging>jar</packaging> + +</project>
\ No newline at end of file diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/images/mwtnEvents.png b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/images/mwtnEvents.png Binary files differnew file mode 100755 index 00000000..d93e6df5 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/images/mwtnEvents.png diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/mwtnEvents-custom.css b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/mwtnEvents-custom.css new file mode 100644 index 00000000..211adc44 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/mwtnEvents-custom.css @@ -0,0 +1,12 @@ +/** + * Add your application related css here + */ +.mwtnEventsGrid { + height: 600px; + background-color: white; +} + +.mwtnEventsGrid span { + color: #393939; +} +
\ No newline at end of file diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/mwtnEvents.controller.js b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/mwtnEvents.controller.js new file mode 100644 index 00000000..1a545adb --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/mwtnEvents.controller.js @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2016 Tech Mahindra Ltd. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +define( + [ 'app/mwtnEvents/mwtnEvents.module', 'app/mwtnEvents/mwtnEvents.services', 'app/mwtnCommons/mwtnCommons.services'], + function(mwtnEventsApp) { + + mwtnEventsApp.register + .controller( + 'mwtnEventsCtrl', + [ + '$scope', + '$rootScope', + '$mwtnEvents', + 'uiGridConstants', + function($scope, $rootScope, $mwtnEvents, uiGridConstants) { + + $rootScope.section_logo = 'src/app/mwtnEvents/images/mwtnEvents.png'; + + $scope.status = {alarms:true}; + $scope.oneATime = true; + + $scope.gridOptionsAlarms = JSON.parse(JSON.stringify($mwtnEvents.gridOptions)); + $scope.gridOptionsAlarms.columnDefs = [ + // { field: 'id', type: 'number', displayName: 'No.', headerCellClass: $scope.highlightFilteredHeader, width : 50, cellClass: 'number', pinnedLeft : true }, + // { field: 'icon', type: 'string', displayName: '', headerCellClass: $scope.highlightFilteredHeader, width: 25, enableSorting: false, enableFiltering:false, cellTemplate: iconCell }, + { field: 'timeStamp', type: 'string', displayName: 'Timestamp', headerCellClass: $scope.highlightFilteredHeader, width : 200,sort: { + direction: uiGridConstants.DESC, + priority: 1 + } }, + { field: 'counter', type: 'number', displayName: 'Counter', headerCellClass: $scope.highlightFilteredHeader, width: 90 }, + { field: 'nodeName', type: 'string', displayName: 'NetworkElement', headerCellClass: $scope.highlightFilteredHeader, width: 170 }, + { field: 'objectId', type: 'string', displayName: 'Object', headerCellClass: $scope.highlightFilteredHeader, width: 400 }, + + { field: 'problem', type: 'string', displayName: 'Alarm', headerCellClass: $scope.highlightFilteredHeader, width : 140 }, + { field: 'severity', type: 'string', displayName: 'Severity', headerCellClass: $scope.highlightFilteredHeader, width : 100 } + ]; + + $scope.gridOptionsAVC = JSON.parse(JSON.stringify($mwtnEvents.gridOptions)); + $scope.gridOptionsAVC.columnDefs = [ + // { field: 'id', type: 'number', displayName: 'No.', headerCellClass: $scope.highlightFilteredHeader, width : 50, cellClass: 'number', pinnedLeft : true }, + // { field: 'icon', type: 'string', displayName: '', headerCellClass: $scope.highlightFilteredHeader, width: 25, enableSorting: false, enableFiltering:false, cellTemplate: iconCell }, + { field: 'timeStamp', type: 'string', displayName: 'Timestamp', headerCellClass: $scope.highlightFilteredHeader, width : 200,sort: { + direction: uiGridConstants.DESC, + priority: 1 + } }, + { field: 'counter', type: 'number', displayName: 'Counter', headerCellClass: $scope.highlightFilteredHeader, width: 90 }, + { field: 'nodeName', type: 'string', displayName: 'NetworkElement', headerCellClass: $scope.highlightFilteredHeader, width: 170 }, + { field: 'objectId', type: 'string', displayName: 'Object', headerCellClass: $scope.highlightFilteredHeader, width: 400 }, + { field: 'attributeName', type: 'string', displayName: 'Attribute', headerCellClass: $scope.highlightFilteredHeader, width : 140 }, + { field: 'newValue', type: 'string', displayName: 'New value', headerCellClass: $scope.highlightFilteredHeader, width : 140 } + ]; + + $scope.gridOptionsObject = JSON.parse(JSON.stringify($mwtnEvents.gridOptions)); + $scope.gridOptionsObject.columnDefs = [ + // { field: 'id', type: 'number', displayName: 'No.', headerCellClass: $scope.highlightFilteredHeader, width : 50, cellClass: 'number', pinnedLeft : true }, + // { field: 'icon', type: 'string', displayName: '', headerCellClass: $scope.highlightFilteredHeader, width: 25, enableSorting: false, enableFiltering:false, cellTemplate: iconCell }, + { field: 'timeStamp', type: 'string', displayName: 'Timestamp', headerCellClass: $scope.highlightFilteredHeader, width : 200,sort: { + direction: uiGridConstants.DESC, + priority: 1 + } }, + { field: 'counter', type: 'number', displayName: 'Counter', headerCellClass: $scope.highlightFilteredHeader, width: 90 }, + { field: 'nodeName', type: 'string', displayName: 'NetworkElement', headerCellClass: $scope.highlightFilteredHeader, width: 170 }, + { field: 'objectId', type: 'string', displayName: 'Object', headerCellClass: $scope.highlightFilteredHeader, width: 400 }, + { field: 'objectType', type: 'string', displayName: 'Type', headerCellClass: $scope.highlightFilteredHeader, width: 400 }, + { field: 'action', type: 'string', displayName: 'Action', headerCellClass: $scope.highlightFilteredHeader, width: 100 } + + ]; + + var listenToNotifications = function() { + $mwtnEvents.getMwtnWebSocketUrl().then(function(success){ + + try { + var notificationSocket = new WebSocket(success); + + notificationSocket.onmessage = function(event) { + // we process our received event here + if (typeof event.data === 'string') { + // console.log("Client Received:\n" + event.data); + // console.log("---------------------------"); + $mwtnEvents.formatData(event).then(function(formated) { + switch (formated.notifType) { + case 'ProblemNotification': + $scope.gridOptionsAlarms.data.push(formated); + break; + case 'AttributeValueChangedNotification': + $scope.gridOptionsAVC.data.push(formated); + break; + case 'ObjectCreationNotification': + formated.action = 'created'; + if (formated.nodeName.contains('SDN-Controller')) { + formated.objectType = 'NETCONF session'; + } + $scope.gridOptionsObject.data.push(formated); + break; + case 'ObjectDeletionNotification': + formated.action = 'deleted'; + if (formated.nodeName.contains('SDN-Controller')) { + formated.objectType = 'NETCONF session'; + } + $scope.gridOptionsObject.data.push(formated); + break; + default: + console.error('Missing implementation for', formated.notifType); + } + }, function(error) { + // do nothing + }); + } + }; + + notificationSocket.onerror = function(error) { + console.log("Socket error: " + error); + }; + + notificationSocket.onopen = function(event) { + console.log("Socket connection opened."); + console.log("---------------------------"); + + function subscribe() { + if (notificationSocket.readyState === notificationSocket.OPEN) { + var data = { + 'data' : 'scopes', + 'scopes' : [ "ObjectCreationNotification", + "ObjectDeletionNotification", + "AttributeValueChangedNotification", + "ProblemNotification" ] + }; + notificationSocket.send(JSON.stringify(data)); + } + } + subscribe(); + }; + + notificationSocket.onclose = function(event) { + console.log("Socket connection closed."); + }; + } catch (e) { + console.error("Error when creating WebSocket.\n" + e); + } + }, function(error){ + console.error("Error when creating WebSocket.\n" + error); + }); + }; + listenToNotifications(); + } ]); + + }); diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/mwtnEvents.module.js b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/mwtnEvents.module.js new file mode 100644 index 00000000..f059d6d1 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/mwtnEvents.module.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2016 Tech Mahindra Ltd. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +define([ 'angularAMD', 'app/routingConfig', 'app/core/core.services', + 'common/config/env.module' , + 'app/mwtnCommons/mwtnCommons.module'], function(ng) { + var mwtnEventsApp = angular.module('app.mwtnEvents', [ 'app.core', + 'ui.router.state', 'config' ]); + + mwtnEventsApp.config(function($stateProvider, $compileProvider, + $controllerProvider, $provide, NavHelperProvider, $translateProvider) { + mwtnEventsApp.register = { + controller : $controllerProvider.register, + directive : $compileProvider.directive, + factory : $provide.factory, + service : $provide.service + + }; + + NavHelperProvider.addControllerUrl('app/mwtnEvents/mwtnEvents.controller'); + NavHelperProvider.addToMenu('mwtnEvents', { + "link" : "#/pnfEvents", + "active" : "main.mwtnEvents", + "title" : "pnf Events", + "icon" : "fa fa-bolt", // Add navigation icon css class here + "page" : { + "title" : "pnf Events", + "description" : "Events" + } + }); + + var access = routingConfig.accessLevels; + + $stateProvider.state('main.mwtnEvents', { + url : 'mwtnEvents', + access : access.admin, + views : { + 'content' : { + templateUrl : 'src/app/mwtnEvents/mwtnEvents.tpl.html', + controller : 'mwtnEventsCtrl' + } + } + }); + + }); + + return mwtnEventsApp; +}); diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/mwtnEvents.services.js b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/mwtnEvents.services.js new file mode 100644 index 00000000..1cd41fb7 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/mwtnEvents.services.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2016 Tech Mahindra Ltd. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +define([ 'app/mwtnEvents/mwtnEvents.module' ], function(mwtnEventsApp) { + + mwtnEventsApp.register.factory('$mwtnEvents', function($mwtnCommons) { + + var service = {}; + + service.gridOptions = $mwtnCommons.gridOptions; + service.getMwtnWebSocketUrl = $mwtnCommons.getMwtnWebSocketUrl; + service.formatData = $mwtnCommons.formatData; + + + return service; + }); +}); diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/mwtnEvents.tpl.html b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/mwtnEvents.tpl.html new file mode 100644 index 00000000..b0a2ed41 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/mwtnEvents.tpl.html @@ -0,0 +1,45 @@ +<ht-header help-link='sdnr/mwtnEvents/0.4.0/README.md'></ht-header> +<div class="mwtnError">{{error}}</div> + +<uib-accordion close-others="oneATime"> + +<div uib-accordion-group class="panel-primary" is-open="status.alarms"> + <uib-accordion-heading> <i class="pull-left fa" + ng-class="{'fa-chevron-down': status.alarms, 'fa-chevron-right': !status.alarms}"></i> + <span>{{'MWTN_ALARMS' | translate}} + ({{gridOptionsAlarms.data.length}})</span> </uib-accordion-heading> + + + <div id="mwtnEventsGridAlarms" ui-grid="gridOptionsAlarms" + ui-grid-exporter ui-grid-selection ui-grid-pinning + ui-grid-resize-columns ui-grid-move-columns class="mwtnEventsGrid"></div> +</div> + +<div uib-accordion-group class="panel-primary" is-open="status.avc"> + <uib-accordion-heading> <i class="pull-left fa" + ng-class="{'fa-chevron-down': status.avc, 'fa-chevron-right': !status.avc}"></i> + <span>{{'MWTN_ATTRIBUTE_VALUE_CHANGED' | translate}} + ({{gridOptionsAVC.data.length}})</span> </uib-accordion-heading> + + + <div id="mwtnEventsGridAVC" ui-grid="gridOptionsAVC" ui-grid-exporter + ui-grid-selection ui-grid-pinning ui-grid-resize-columns + ui-grid-move-columns class="mwtnEventsGrid"></div> +</div> + +<div uib-accordion-group class="panel-primary" is-open="status.object"> + <uib-accordion-heading> <i class="pull-left fa" + ng-class="{'fa-chevron-down': status.object, 'fa-chevron-right': !status.object}"></i> + <span>{{'MWTN_OBJECT_DELETION_CREATION' | translate}} + ({{gridOptionsObject.data.length}})</span> </uib-accordion-heading> + + <div id="mwtnEventsGridObject" ui-grid="gridOptionsObject" + ui-grid-exporter ui-grid-selection ui-grid-pinning + ui-grid-resize-columns ui-grid-move-columns class="mwtnEventsGrid"></div> +</div> + +</uib-accordion> +<hr /> +<div class="owl"> + <span class="white">ONAP SDN-R | ONF Wireless for @distversion@ - Build: @buildtime@</span> +</div>
\ No newline at end of file diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/xml2json.js b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/xml2json.js new file mode 100644 index 00000000..5ff7e578 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/mwtnEvents-module/src/main/resources/mwtnEvents/xml2json.js @@ -0,0 +1,567 @@ +/*
+ Copyright 2011-2013 Abdulla Abdurakhmanov
+ Original sources are available at https://code.google.com/p/x2js/
+
+ 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.
+ */
+
+function X2JS(config) {
+ 'use strict';
+
+ var VERSION = "1.1.5";
+
+ config = config || {};
+ initConfigDefaults();
+ initRequiredPolyfills();
+
+ function initConfigDefaults() {
+ if(config.escapeMode === undefined) {
+ config.escapeMode = true;
+ }
+ config.attributePrefix = config.attributePrefix || "_";
+ config.arrayAccessForm = config.arrayAccessForm || "none";
+ config.emptyNodeForm = config.emptyNodeForm || "text";
+ if(config.enableToStringFunc === undefined) {
+ config.enableToStringFunc = true;
+ }
+ config.arrayAccessFormPaths = config.arrayAccessFormPaths || [];
+ if(config.skipEmptyTextNodesForObj === undefined) {
+ config.skipEmptyTextNodesForObj = true;
+ }
+ if(config.stripWhitespaces === undefined) {
+ config.stripWhitespaces = true;
+ }
+ config.datetimeAccessFormPaths = config.datetimeAccessFormPaths || [];
+ }
+
+ var DOMNodeTypes = {
+ ELEMENT_NODE : 1,
+ TEXT_NODE : 3,
+ CDATA_SECTION_NODE : 4,
+ COMMENT_NODE : 8,
+ DOCUMENT_NODE : 9
+ };
+
+ function initRequiredPolyfills() {
+ function pad(number) {
+ var r = String(number);
+ if ( r.length === 1 ) {
+ r = '0' + r;
+ }
+ return r;
+ }
+ // Hello IE8-
+ if(typeof String.prototype.trim !== 'function') {
+ String.prototype.trim = function() {
+ return this.replace(/^\s+|^\n+|(\s|\n)+$/g, '');
+ }
+ }
+ if(typeof Date.prototype.toISOString !== 'function') {
+ // Implementation from http://stackoverflow.com/questions/2573521/how-do-i-output-an-iso-8601-formatted-string-in-javascript
+ Date.prototype.toISOString = function() {
+ return this.getUTCFullYear()
+ + '-' + pad( this.getUTCMonth() + 1 )
+ + '-' + pad( this.getUTCDate() )
+ + 'T' + pad( this.getUTCHours() )
+ + ':' + pad( this.getUTCMinutes() )
+ + ':' + pad( this.getUTCSeconds() )
+ + '.' + String( (this.getUTCMilliseconds()/1000).toFixed(3) ).slice( 2, 5 )
+ + 'Z';
+ };
+ }
+ }
+
+ function getNodeLocalName( node ) {
+ var nodeLocalName = node.localName;
+ if(nodeLocalName == null) // Yeah, this is IE!!
+ nodeLocalName = node.baseName;
+ if(nodeLocalName == null || nodeLocalName=="") // =="" is IE too
+ nodeLocalName = node.nodeName;
+ return nodeLocalName;
+ }
+
+ function getNodePrefix(node) {
+ return node.prefix;
+ }
+
+ function escapeXmlChars(str) {
+ if(typeof(str) == "string")
+ return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g, '/');
+ else
+ return str;
+ }
+
+ function unescapeXmlChars(str) {
+ return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, "'").replace(///g, '\/');
+ }
+
+ function toArrayAccessForm(obj, childName, path) {
+ switch(config.arrayAccessForm) {
+ case "property":
+ if(!(obj[childName] instanceof Array))
+ obj[childName+"_asArray"] = [obj[childName]];
+ else
+ obj[childName+"_asArray"] = obj[childName];
+ break;
+ /*case "none":
+ break;*/
+ }
+
+ if(!(obj[childName] instanceof Array) && config.arrayAccessFormPaths.length > 0) {
+ var idx = 0;
+ for(; idx < config.arrayAccessFormPaths.length; idx++) {
+ var arrayPath = config.arrayAccessFormPaths[idx];
+ if( typeof arrayPath === "string" ) {
+ if(arrayPath == path)
+ break;
+ }
+ else
+ if( arrayPath instanceof RegExp) {
+ if(arrayPath.test(path))
+ break;
+ }
+ else
+ if( typeof arrayPath === "function") {
+ if(arrayPath(obj, childName, path))
+ break;
+ }
+ }
+ if(idx!=config.arrayAccessFormPaths.length) {
+ obj[childName] = [obj[childName]];
+ }
+ }
+ }
+
+ function fromXmlDateTime(prop) {
+ // Implementation based up on http://stackoverflow.com/questions/8178598/xml-datetime-to-javascript-date-object
+ // Improved to support full spec and optional parts
+ var bits = prop.split(/[-T:+Z]/g);
+
+ var d = new Date(bits[0], bits[1]-1, bits[2]);
+ var secondBits = bits[5].split("\.");
+ d.setHours(bits[3], bits[4], secondBits[0]);
+ if(secondBits.length>1)
+ d.setMilliseconds(secondBits[1]);
+
+ // Get supplied time zone offset in minutes
+ if(bits[6] && bits[7]) {
+ var offsetMinutes = bits[6] * 60 + Number(bits[7]);
+ var sign = /\d\d-\d\d:\d\d$/.test(prop)? '-' : '+';
+
+ // Apply the sign
+ offsetMinutes = 0 + (sign == '-'? -1 * offsetMinutes : offsetMinutes);
+
+ // Apply offset and local timezone
+ d.setMinutes(d.getMinutes() - offsetMinutes - d.getTimezoneOffset())
+ }
+ else
+ if(prop.indexOf("Z", prop.length - 1) !== -1) {
+ d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds()));
+ }
+
+ // d is now a local time equivalent to the supplied time
+ return d;
+ }
+
+ function checkFromXmlDateTimePaths(value, childName, fullPath) {
+ if(config.datetimeAccessFormPaths.length > 0) {
+ var path = fullPath.split("\.#")[0];
+ var idx = 0;
+ for(; idx < config.datetimeAccessFormPaths.length; idx++) {
+ var dtPath = config.datetimeAccessFormPaths[idx];
+ if( typeof dtPath === "string" ) {
+ if(dtPath == path)
+ break;
+ }
+ else
+ if( dtPath instanceof RegExp) {
+ if(dtPath.test(path))
+ break;
+ }
+ else
+ if( typeof dtPath === "function") {
+ if(dtPath(obj, childName, path))
+ break;
+ }
+ }
+ if(idx!=config.datetimeAccessFormPaths.length) {
+ return fromXmlDateTime(value);
+ }
+ else
+ return value;
+ }
+ else
+ return value;
+ }
+
+ function parseDOMChildren( node, path ) {
+ if(node.nodeType == DOMNodeTypes.DOCUMENT_NODE) {
+ var result = new Object;
+ var nodeChildren = node.childNodes;
+ // Alternative for firstElementChild which is not supported in some environments
+ for(var cidx=0; cidx <nodeChildren.length; cidx++) {
+ var child = nodeChildren.item(cidx);
+ if(child.nodeType == DOMNodeTypes.ELEMENT_NODE) {
+ var childName = getNodeLocalName(child);
+ result[childName] = parseDOMChildren(child, childName);
+ }
+ }
+ return result;
+ }
+ else
+ if(node.nodeType == DOMNodeTypes.ELEMENT_NODE) {
+ var result = new Object;
+ result.__cnt=0;
+
+ var nodeChildren = node.childNodes;
+
+ // Children nodes
+ for(var cidx=0; cidx <nodeChildren.length; cidx++) {
+ var child = nodeChildren.item(cidx); // nodeChildren[cidx];
+ var childName = getNodeLocalName(child);
+
+ if(child.nodeType!= DOMNodeTypes.COMMENT_NODE) {
+ result.__cnt++;
+ if(result[childName] == null) {
+ result[childName] = parseDOMChildren(child, path+"."+childName);
+ toArrayAccessForm(result, childName, path+"."+childName);
+ }
+ else {
+ if(result[childName] != null) {
+ if( !(result[childName] instanceof Array)) {
+ result[childName] = [result[childName]];
+ toArrayAccessForm(result, childName, path+"."+childName);
+ }
+ }
+ (result[childName])[result[childName].length] = parseDOMChildren(child, path+"."+childName);
+ }
+ }
+ }
+
+ // Attributes
+ for(var aidx=0; aidx <node.attributes.length; aidx++) {
+ var attr = node.attributes.item(aidx); // [aidx];
+ result.__cnt++;
+ result[config.attributePrefix+attr.name]=attr.value;
+ }
+
+ // Node namespace prefix
+ var nodePrefix = getNodePrefix(node);
+ if(nodePrefix!=null && nodePrefix!="") {
+ result.__cnt++;
+ result.__prefix=nodePrefix;
+ }
+
+ if(result["#text"]!=null) {
+ result.__text = result["#text"];
+ if(result.__text instanceof Array) {
+ result.__text = result.__text.join("\n");
+ }
+ if(config.escapeMode)
+ result.__text = unescapeXmlChars(result.__text);
+ if(config.stripWhitespaces)
+ result.__text = result.__text.trim();
+ delete result["#text"];
+ if(config.arrayAccessForm=="property")
+ delete result["#text_asArray"];
+ result.__text = checkFromXmlDateTimePaths(result.__text, childName, path+"."+childName);
+ }
+ if(result["#cdata-section"]!=null) {
+ result.__cdata = result["#cdata-section"];
+ delete result["#cdata-section"];
+ if(config.arrayAccessForm=="property")
+ delete result["#cdata-section_asArray"];
+ }
+
+ if( result.__cnt == 1 && result.__text!=null ) {
+ result = result.__text;
+ }
+ else
+ if( result.__cnt == 0 && config.emptyNodeForm=="text" ) {
+ result = '';
+ }
+ else
+ if ( result.__cnt > 1 && result.__text!=null && config.skipEmptyTextNodesForObj) {
+ if( (config.stripWhitespaces && result.__text=="") || (result.__text.trim()=="")) {
+ delete result.__text;
+ }
+ }
+ delete result.__cnt;
+
+ if( config.enableToStringFunc && (result.__text!=null || result.__cdata!=null )) {
+ result.toString = function() {
+ return (this.__text!=null? this.__text:'')+( this.__cdata!=null ? this.__cdata:'');
+ };
+ }
+
+ return result;
+ }
+ else
+ if(node.nodeType == DOMNodeTypes.TEXT_NODE || node.nodeType == DOMNodeTypes.CDATA_SECTION_NODE) {
+ return node.nodeValue;
+ }
+ }
+
+ function startTag(jsonObj, element, attrList, closed) {
+ var resultStr = "<"+ ( (jsonObj!=null && jsonObj.__prefix!=null)? (jsonObj.__prefix+":"):"") + element;
+ if(attrList!=null) {
+ for(var aidx = 0; aidx < attrList.length; aidx++) {
+ var attrName = attrList[aidx];
+ var attrVal = jsonObj[attrName];
+ if(config.escapeMode)
+ attrVal=escapeXmlChars(attrVal);
+ resultStr+=" "+attrName.substr(config.attributePrefix.length)+"='"+attrVal+"'";
+ }
+ }
+ if(!closed)
+ resultStr+=">";
+ else
+ resultStr+="/>";
+ return resultStr;
+ }
+
+ function endTag(jsonObj,elementName) {
+ return "</"+ (jsonObj.__prefix!=null? (jsonObj.__prefix+":"):"")+elementName+">";
+ }
+
+ function endsWith(str, suffix) {
+ return str.indexOf(suffix, str.length - suffix.length) !== -1;
+ }
+
+ function jsonXmlSpecialElem ( jsonObj, jsonObjField ) {
+ if((config.arrayAccessForm=="property" && endsWith(jsonObjField.toString(),("_asArray")))
+ || jsonObjField.toString().indexOf(config.attributePrefix)==0
+ || jsonObjField.toString().indexOf("__")==0
+ || (jsonObj[jsonObjField] instanceof Function) )
+ return true;
+ else
+ return false;
+ }
+
+ function jsonXmlElemCount ( jsonObj ) {
+ var elementsCnt = 0;
+ if(jsonObj instanceof Object ) {
+ for( var it in jsonObj ) {
+ if(jsonXmlSpecialElem ( jsonObj, it) )
+ continue;
+ elementsCnt++;
+ }
+ }
+ return elementsCnt;
+ }
+
+ function parseJSONAttributes ( jsonObj ) {
+ var attrList = [];
+ if(jsonObj instanceof Object ) {
+ for( var ait in jsonObj ) {
+ if(ait.toString().indexOf("__")== -1 && ait.toString().indexOf(config.attributePrefix)==0) {
+ attrList.push(ait);
+ }
+ }
+ }
+ return attrList;
+ }
+
+ function parseJSONTextAttrs ( jsonTxtObj ) {
+ var result ="";
+
+ if(jsonTxtObj.__cdata!=null) {
+ result+="<![CDATA["+jsonTxtObj.__cdata+"]]>";
+ }
+
+ if(jsonTxtObj.__text!=null) {
+ if(config.escapeMode)
+ result+=escapeXmlChars(jsonTxtObj.__text);
+ else
+ result+=jsonTxtObj.__text;
+ }
+ return result;
+ }
+
+ function parseJSONTextObject ( jsonTxtObj ) {
+ var result ="";
+
+ if( jsonTxtObj instanceof Object ) {
+ result+=parseJSONTextAttrs ( jsonTxtObj );
+ }
+ else
+ if(jsonTxtObj!=null) {
+ if(config.escapeMode)
+ result+=escapeXmlChars(jsonTxtObj);
+ else
+ result+=jsonTxtObj;
+ }
+
+ return result;
+ }
+
+ function parseJSONArray ( jsonArrRoot, jsonArrObj, attrList ) {
+ var result = "";
+ if(jsonArrRoot.length == 0) {
+ result+=startTag(jsonArrRoot, jsonArrObj, attrList, true);
+ }
+ else {
+ for(var arIdx = 0; arIdx < jsonArrRoot.length; arIdx++) {
+ result+=startTag(jsonArrRoot[arIdx], jsonArrObj, parseJSONAttributes(jsonArrRoot[arIdx]), false);
+ result+=parseJSONObject(jsonArrRoot[arIdx]);
+ result+=endTag(jsonArrRoot[arIdx],jsonArrObj);
+ }
+ }
+ return result;
+ }
+
+ function parseJSONObject ( jsonObj ) {
+ var result = "";
+
+ var elementsCnt = jsonXmlElemCount ( jsonObj );
+
+ if(elementsCnt > 0) {
+ for( var it in jsonObj ) {
+
+ if(jsonXmlSpecialElem ( jsonObj, it) )
+ continue;
+
+ var subObj = jsonObj[it];
+
+ var attrList = parseJSONAttributes( subObj )
+
+ if(subObj == null || subObj == undefined) {
+ result+=startTag(subObj, it, attrList, true);
+ }
+ else
+ if(subObj instanceof Object) {
+
+ if(subObj instanceof Array) {
+ result+=parseJSONArray( subObj, it, attrList );
+ }
+ else if(subObj instanceof Date) {
+ result+=startTag(subObj, it, attrList, false);
+ result+=subObj.toISOString();
+ result+=endTag(subObj,it);
+ }
+ else {
+ var subObjElementsCnt = jsonXmlElemCount ( subObj );
+ if(subObjElementsCnt > 0 || subObj.__text!=null || subObj.__cdata!=null) {
+ result+=startTag(subObj, it, attrList, false);
+ result+=parseJSONObject(subObj);
+ result+=endTag(subObj,it);
+ }
+ else {
+ result+=startTag(subObj, it, attrList, true);
+ }
+ }
+ }
+ else {
+ result+=startTag(subObj, it, attrList, false);
+ result+=parseJSONTextObject(subObj);
+ result+=endTag(subObj,it);
+ }
+ }
+ }
+ result+=parseJSONTextObject(jsonObj);
+
+ return result;
+ }
+
+ this.parseXmlString = function(xmlDocStr) {
+ var isIEParser = window.ActiveXObject || "ActiveXObject" in window;
+ if (xmlDocStr === undefined) {
+ return null;
+ }
+ var xmlDoc;
+ if (window.DOMParser) {
+ var parser=new window.DOMParser();
+ var parsererrorNS = null;
+ // IE9+ now is here
+ if(!isIEParser) {
+ try {
+ parsererrorNS = parser.parseFromString("INVALID", "text/xml").childNodes[0].namespaceURI;
+ }
+ catch(err) {
+ parsererrorNS = null;
+ }
+ }
+ try {
+ xmlDoc = parser.parseFromString( xmlDocStr, "text/xml" );
+ if( parsererrorNS!= null && xmlDoc.getElementsByTagNameNS(parsererrorNS, "parsererror").length > 0) {
+ //throw new Error('Error parsing XML: '+xmlDocStr);
+ xmlDoc = null;
+ }
+ }
+ catch(err) {
+ xmlDoc = null;
+ }
+ }
+ else {
+ // IE :(
+ if(xmlDocStr.indexOf("<?")==0) {
+ xmlDocStr = xmlDocStr.substr( xmlDocStr.indexOf("?>") + 2 );
+ }
+ xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
+ xmlDoc.async="false";
+ xmlDoc.loadXML(xmlDocStr);
+ }
+ return xmlDoc;
+ };
+
+ this.asArray = function(prop) {
+ if(prop instanceof Array)
+ return prop;
+ else
+ return [prop];
+ };
+
+ this.toXmlDateTime = function(dt) {
+ if(dt instanceof Date)
+ return dt.toISOString();
+ else
+ if(typeof(dt) === 'number' )
+ return new Date(dt).toISOString();
+ else
+ return null;
+ };
+
+ this.asDateTime = function(prop) {
+ if(typeof(prop) == "string") {
+ return fromXmlDateTime(prop);
+ }
+ else
+ return prop;
+ };
+
+ this.xml2json = function (xmlDoc) {
+ return parseDOMChildren ( xmlDoc );
+ };
+
+ this.xml_str2json = function (xmlDocStr) {
+ var xmlDoc = this.parseXmlString(xmlDocStr);
+ if(xmlDoc!=null)
+ return this.xml2json(xmlDoc);
+ else
+ return null;
+ };
+
+ this.json2xml_str = function (jsonObj) {
+ return parseJSONObject ( jsonObj );
+ };
+
+ this.json2xml = function (jsonObj) {
+ var xmlDocStr = this.json2xml_str (jsonObj);
+ return this.parseXmlString(xmlDocStr);
+ };
+
+ this.getVersion = function () {
+ return VERSION;
+ };
+
+}
diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/pom.xml b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/pom.xml new file mode 100644 index 00000000..e898be3c --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnEvents/pom.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <artifactId>mwtn</artifactId> + <groupId>com.highstreet.technologies.odl.dlux</groupId> + <version>0.5.1-SNAPSHOT</version> + <relativePath>..</relativePath> + </parent> + + <packaging>pom</packaging> + <groupId>com.highstreet.technologies.odl.dlux</groupId> + <artifactId>mwtnEvents</artifactId> + <version>0.5.1-SNAPSHOT</version> + <name>${prefix} ${project.artifactId}</name> + + <prerequisites> + <maven>3.0</maven> + </prerequisites> + + <modules> + <module>mwtnEvents-module</module> + <module>mwtnEvents-bundle</module> + </modules> +</project>
\ No newline at end of file |