aboutsummaryrefslogtreecommitdiffstats
path: root/ransim/ransimctrlr/RANSIM-CTRLR
diff options
context:
space:
mode:
Diffstat (limited to 'ransim/ransimctrlr/RANSIM-CTRLR')
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/.gitignore1
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/WebContent/META-INF/MANIFEST.MF2
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/pom.xml280
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimController.java1150
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimControllerDatabase.java409
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimControllerServices.java730
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimPciHandler.java1011
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellData.java64
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellDetails.java273
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellInfo.java123
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellNeighbor.java96
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CreateACellReq.java80
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/DeleteACellReq.java50
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/FmAlarmInfo.java74
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetACellDetailReq.java50
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNeighborList.java76
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNeighborListReq.java50
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNetconfServerDetailsReq.java51
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetPmDataReq.java61
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetTopology.java98
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/ModifyACellReq.java76
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NbrDump.java54
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeighborDetails.java65
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeighborPmDetails.java64
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeihborId.java93
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NetconfServers.java104
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/OperationLog.java108
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PmDataDump.java47
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PmParameters.java85
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SetCollisionReq.java50
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SetConstants.java112
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/Topology.java112
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/TopologyDump.java52
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/client/RestClient.java122
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/config/RansimRestConfig.java99
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/config/RansimRestInitializer.java49
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/AdditionalMeasurements.java50
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/CommonEventHeaderFm.java86
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/CommonEventHeaderPm.java62
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/DeviceData.java47
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/DeviceDataDecoder.java57
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/DeviceDataEncoder.java47
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/EventFm.java55
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/EventPm.java44
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/FaultFields.java88
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/FmMessage.java37
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/Measurement.java46
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/MessageTypes.java33
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/ModifyNeighbor.java55
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/ModifyPci.java112
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/Neighbor.java88
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/NeighborHo.java51
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/PmMessage.java37
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/SetConfigTopology.java97
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/Topology.java96
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/UpdateCell.java85
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/server/RansimWebSocketServer.java222
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/resources/META-INF/persistence.xml43
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/resources/log4j.properties50
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/resources/logback.xml242
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimController.java262
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimControllerServices.java75
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/models/TestApiModels.java60
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/test/resources/META-INF/persistence.xml43
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/test/resources/hibernate.properties29
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/test/resources/log4j.properties8
66 files changed, 8328 insertions, 0 deletions
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/.gitignore b/ransim/ransimctrlr/RANSIM-CTRLR/.gitignore
new file mode 100644
index 0000000..b83d222
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/WebContent/META-INF/MANIFEST.MF b/ransim/ransimctrlr/RANSIM-CTRLR/WebContent/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..59499bc
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/WebContent/META-INF/MANIFEST.MF
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/pom.xml b/ransim/ransimctrlr/RANSIM-CTRLR/pom.xml
new file mode 100644
index 0000000..cacf31f
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/pom.xml
@@ -0,0 +1,280 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ Ran Simulator Controller
+ ================================================================================
+ Copyright (C) 2020 Wipro Limited 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=========================================================
+ -->
+<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>
+ <groupId>org.onap.ransim</groupId>
+ <artifactId>RansimSuite</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>RANSIM-CTRLR</artifactId>
+ <description>RANSIM CTRLR</description>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <springframework.version>4.3.3.RELEASE</springframework.version>
+ <eclipselink.version>2.6.0</eclipselink.version>
+ <javax.persistence.version>2.1.0</javax.persistence.version>
+ <mariadb.jdbc.version>1.2.3</mariadb.jdbc.version>
+ <javax.persistence.api.version>1.0.2</javax.persistence.api.version>
+ <jetty.version>9.2.11.v20150529</jetty.version>
+ <version.org.hibernate>4.3.11.Final</version.org.hibernate>
+ </properties>
+ <packaging>war</packaging>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.1</version>
+ <configuration>
+ <attachClasses>true</attachClasses>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-maven-plugin</artifactId>
+ <version>${jetty.version}</version>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <skip>true</skip>
+ <includes>**/org/openecomp/**/*.java</includes>
+ <configLocation>/google_checks.xml</configLocation>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <versionRange>2.17,)</versionRange>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore />
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>javax.persistence</artifactId>
+ <version>${javax.persistence.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>eclipselink</artifactId>
+ <version>${eclipselink.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ <version>2.9.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jmockit</groupId>
+ <artifactId>jmockit</artifactId>
+ <version>1.19</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.9.5</version>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.3</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>apache-log4j-extras</artifactId>
+ <version>1.2.17</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>19.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mariadb.jdbc</groupId>
+ <artifactId>mariadb-java-client</artifactId>
+ <version>2.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${springframework.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ <version>3.0.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>2.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-client</artifactId>
+ <version>1.18</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-core</artifactId>
+ <version>1.18</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.websocket</groupId>
+ <artifactId>javax.websocket-api</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>1.9.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-mock</artifactId>
+ <version>2.0.8</version>
+ </dependency>
+ <dependency>
+ <groupId>com.mockrunner</groupId>
+ <artifactId>mockrunner</artifactId>
+ <version>0.3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>1.5.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>1.5.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>${springframework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ <version>${springframework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ <version>${springframework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <version>${version.org.hibernate}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-testing</artifactId>
+ <version>${version.org.hibernate}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.6.2</version>
+ </dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger2</artifactId>
+ <version>2.5.0</version>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger-ui</artifactId>
+ <version>2.5.0</version>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimController.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimController.java
new file mode 100644
index 0000000..9ea789e
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimController.java
@@ -0,0 +1,1150 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.controller;
+
+import com.google.gson.Gson;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Random;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.persistence.Query;
+import javax.persistence.TypedQuery;
+import javax.websocket.Session;
+
+import org.apache.log4j.Logger;
+import org.onap.ransim.websocket.model.*;
+import org.onap.ransim.rest.api.models.CellData;
+import org.onap.ransim.rest.api.models.CellDetails;
+import org.onap.ransim.rest.api.models.CellNeighbor;
+import org.onap.ransim.rest.api.models.FmAlarmInfo;
+import org.onap.ransim.rest.api.models.GetNeighborList;
+import org.onap.ransim.rest.api.models.NbrDump;
+import org.onap.ransim.rest.api.models.NeighborDetails;
+import org.onap.ransim.rest.api.models.NeighborPmDetails;
+import org.onap.ransim.rest.api.models.NeihborId;
+import org.onap.ransim.rest.api.models.NetconfServers;
+import org.onap.ransim.rest.api.models.OperationLog;
+import org.onap.ransim.rest.api.models.PmDataDump;
+import org.onap.ransim.rest.api.models.PmParameters;
+import org.onap.ransim.rest.api.models.TopologyDump;
+import org.onap.ransim.rest.client.RestClient;
+import org.onap.ransim.websocket.model.FmMessage;
+import org.onap.ransim.websocket.model.ModifyNeighbor;
+import org.onap.ransim.websocket.model.ModifyPci;
+import org.onap.ransim.websocket.model.Neighbor;
+import org.onap.ransim.websocket.model.PmMessage;
+import org.onap.ransim.websocket.model.SetConfigTopology;
+import org.onap.ransim.websocket.model.Topology;
+import org.onap.ransim.websocket.model.UpdateCell;
+import org.onap.ransim.websocket.server.RansimWebSocketServer;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+public class RansimController {
+
+ static Logger log = Logger.getLogger(RansimController.class
+ .getName());
+
+ private static RansimController rsController = null;
+ Properties netconfConstants = new Properties();
+ int gridSize = 10;
+ boolean collision = false;
+ String serverIdPrefix = "";
+ static int numberOfCellsPerNcServer = 15;
+ int numberOfMachines = 1;
+ int numberOfProcessPerMc = 5;
+ boolean strictValidateRansimAgentsAvailability = false;
+ static public Map<String, Session> webSocketSessions = new ConcurrentHashMap<String, Session>();
+ static Map<String, String> serverIdIpPortMapping = new ConcurrentHashMap<String, String>();
+
+ static Map<String, String> globalNcServerUuidMap = new ConcurrentHashMap<String, String>();
+ static List<String> unassignedServerIds = Collections
+ .synchronizedList(new ArrayList<String>());
+ static Map<String, List<String>> serverIdIpNodeMapping = new ConcurrentHashMap<String, List<String>>();
+ int nextServerIdNumber = 1001;
+ String sdnrServerIp = "";
+ int sdnrServerPort = 0;
+ static String sdnrServerUserid = "";
+ static String sdnrServerPassword = "";
+ static String dumpFileName = "";
+ static long maxPciValueAllowed = 503;
+
+ static RansimPciHandler rsPciHdlr = RansimPciHandler.getRansimPciHandler();
+
+ private RansimController() {
+
+ }
+
+ /**
+ * To accesss variable of this class from another class.
+ *
+ * @return returns rscontroller constructor
+ */
+ public static synchronized RansimController getRansimController() {
+ if (rsController == null) {
+ rsController = new RansimController();
+ new KeepWebsockAliveThread(rsController).start();
+ }
+ return rsController;
+ }
+
+ private String checkIpPortAlreadyExists(String ipPort,
+ Map<String, String> serverIdIpPortMapping) {
+ String serverId = null;
+ for (String key : serverIdIpPortMapping.keySet()) {
+ String value = serverIdIpPortMapping.get(key);
+ if (value.equals(ipPort)) {
+ serverId = key;
+ break;
+ }
+ }
+ return serverId;
+ }
+
+ /**
+ * Add web socket sessions.
+ *
+ * @param ipPort
+ * ip address for the session
+ * @param wsSession
+ * session details
+ */
+ public synchronized String addWebSocketSessions(String ipPort,
+ Session wsSession) {
+ loadProperties();
+ if (webSocketSessions.containsKey(ipPort)) {
+ log.info("addWebSocketSessions: Client session "
+ + wsSession.getId() + " for " + ipPort
+ + " already exist. Removing old session.");
+ webSocketSessions.remove(ipPort);
+ }
+
+ log.info("addWebSocketSessions: Adding Client session "
+ + wsSession.getId() + " for " + ipPort);
+ webSocketSessions.put(ipPort, wsSession);
+ String serverId = null;
+ if (!serverIdIpPortMapping.containsValue(ipPort)) {
+ if (unassignedServerIds.size() > 0) {
+ log.info("addWebSocketSessions: No serverIds pending to assign for "
+ + ipPort);
+ serverId = checkIpPortAlreadyExists(ipPort,
+ serverIdIpPortMapping);
+ if (serverId == null) {
+ serverId = unassignedServerIds.remove(0);
+ } else {
+ if (unassignedServerIds.contains(serverId)) {
+ unassignedServerIds.remove(serverId);
+ }
+ }
+ log.info("RansCtrller = Available unassigned ServerIds :"
+ + unassignedServerIds);
+ log.info("RansCtrller = addWebSocketSessions: Adding serverId "
+ + serverId + " for " + ipPort);
+ serverIdIpPortMapping.put(serverId, ipPort);
+ log.debug("RansCtrller = serverIdIpPortMapping >>>> :"
+ + serverIdIpPortMapping);
+ mapServerIdToNodes(serverId);
+ RansimControllerDatabase rsDb = new RansimControllerDatabase();
+ try {
+
+ NetconfServers server = rsDb.getNetconfServer(serverId);
+ if (server != null) {
+ server.setIp(ipPort.split(":")[0]);
+ server.setNetconfPort(ipPort.split(":")[1]);
+ rsDb.mergeNetconfServers(server);
+ }
+
+ } catch (Exception e1) {
+ log.info("Exception mapServerIdToNodes :", e1);
+ }
+ } else {
+ log.info("addWebSocketSessions: No serverIds pending to assign for "
+ + ipPort);
+ }
+ } else {
+ for (String key : serverIdIpPortMapping.keySet()) {
+ if (serverIdIpPortMapping.get(key).equals(ipPort)) {
+ log.info("addWebSocketSessions: ServerId " + key + " for "
+ + ipPort + " is exist already");
+ serverId = key;
+ break;
+ }
+ }
+ }
+ return serverId;
+ }
+
+ /**
+ * Map server ID to the cells
+ *
+ * @param serverId
+ * Server ID
+ */
+ private void mapServerIdToNodes(String serverId) {
+ dumpSessionDetails();
+ if (serverIdIpNodeMapping.containsKey(serverId)) {
+ // already mapped.RansimController Do nothing.
+ } else {
+ List<String> nodeIds = new ArrayList<String>();
+ RansimControllerDatabase rsDb = new RansimControllerDatabase();
+ try {
+ List<CellDetails> nodes = rsDb.getCellsWithNoServerIds();
+ for (CellDetails cell : nodes) {
+ cell.setServerId(serverId);
+ nodeIds.add(cell.getNodeId());
+ rsDb.mergeCellDetails(cell);
+ }
+ serverIdIpNodeMapping.put(serverId, nodeIds);
+ } catch (Exception e1) {
+ log.info("Exception mapServerIdToNodes :", e1);
+
+ }
+ }
+ }
+
+ /**
+ * It removes the web socket sessions.
+ *
+ * @param ipPort
+ * ip address of the netconf server
+ */
+ public synchronized void removeWebSocketSessions(String ipPort) {
+ RansimControllerDatabase rsDb = new RansimControllerDatabase();
+ log.info("remove websocket session request received for: " + ipPort);
+ try {
+ if (webSocketSessions.containsKey(ipPort)) {
+ String removedServerId = null;
+ for (String serverId : serverIdIpPortMapping.keySet()) {
+ String ipPortVal = serverIdIpPortMapping.get(serverId);
+ if (ipPortVal.equals(ipPort)) {
+ if (!unassignedServerIds.contains(serverId)) {
+ unassignedServerIds.add(serverId);
+ log.info(serverId + "added in unassignedServerIds");
+ }
+ NetconfServers ns = rsDb.getNetconfServer(serverId);
+ ns.setIp(null);
+ ns.setNetconfPort(null);
+ log.info(serverId + " ip and Port set as null ");
+ rsDb.mergeNetconfServers(ns);
+ removedServerId = serverId;
+ break;
+ }
+ }
+ serverIdIpPortMapping.remove(removedServerId);
+
+ Session wsSession = webSocketSessions.remove(ipPort);
+ log.info("removeWebSocketSessions: Client session "
+ + wsSession.getId() + " for " + ipPort
+ + " is removed. Server Id : " + removedServerId);
+ } else {
+ log.info("addWebSocketSessions: Client session for " + ipPort
+ + " not exist");
+ }
+ } catch (Exception e) {
+ log.info("Exception in removeWebSocketSessions. e: " + e);
+ }
+
+ }
+
+ /**
+ * Checks the number of ransim agents running.
+ *
+ * @param cellsToBeSimulated
+ * number of cells to be simulated
+ * @return returns true if there are enough ransim agents running
+ */
+ public boolean hasEnoughRansimAgentsRunning(int cellsToBeSimulated) {
+
+ log.info("hasEnoughRansimAgentsRunning: numberOfCellsPerNCServer "
+ + numberOfCellsPerNcServer + " , webSocketSessions.size:"
+ + webSocketSessions.size() + " , cellsToBeSimulated:"
+ + cellsToBeSimulated);
+ log.info(strictValidateRansimAgentsAvailability);
+
+ if (strictValidateRansimAgentsAvailability) {
+ if (numberOfCellsPerNcServer * webSocketSessions.size() < cellsToBeSimulated) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * It updates the constant values in the properties file.
+ */
+ public void loadProperties() {
+ InputStream input = null;
+ try {
+ input = new FileInputStream(
+ "/tmp/ransim-install/config/ransim.properties");
+ netconfConstants.load(input);
+ serverIdPrefix = netconfConstants.getProperty("serverIdPrefix");
+ numberOfCellsPerNcServer = Integer.parseInt(netconfConstants
+ .getProperty("numberOfCellsPerNCServer"));
+ numberOfMachines = Integer.parseInt(netconfConstants
+ .getProperty("numberOfMachines"));
+ numberOfProcessPerMc = Integer.parseInt(netconfConstants
+ .getProperty("numberOfProcessPerMc"));
+ strictValidateRansimAgentsAvailability = Boolean
+ .parseBoolean(netconfConstants
+ .getProperty("strictValidateRansimAgentsAvailability"));
+ sdnrServerIp = netconfConstants.getProperty("sdnrServerIp");
+ sdnrServerPort = Integer.parseInt(netconfConstants
+ .getProperty("sdnrServerPort"));
+ sdnrServerUserid = netconfConstants.getProperty("sdnrServerUserid");
+ sdnrServerPassword = netconfConstants
+ .getProperty("sdnrServerPassword");
+ dumpFileName = netconfConstants.getProperty("dumpFileName");
+ maxPciValueAllowed = Long.parseLong(netconfConstants
+ .getProperty("maxPciValueAllowed"));
+
+ } catch (Exception e) {
+ log.info("Properties file error", e);
+ } finally {
+ try {
+ if (input != null) {
+ input.close();
+ }
+ } catch (Exception ex) {
+ log.info("Properties file error", ex);
+ }
+ }
+ }
+
+ /**
+ * The function adds the cell(with nodeId passed as an argument) to its
+ * netconf server list if the netconf server already exists. Else it will
+ * create a new netconf server in the NetconfServers Table and the cell into
+ * its list.
+ *
+ * @param nodeId
+ * node Id of the cell
+ */
+ static void setNetconfServers(String nodeId) {
+
+ RansimControllerDatabase rsDb = new RansimControllerDatabase();
+ CellDetails currentCell = rsDb.getCellDetail(nodeId);
+
+ Set<CellDetails> newList = new HashSet<CellDetails>();
+ try {
+ if (currentCell != null) {
+ NetconfServers server = rsDb.getNetconfServer(currentCell
+ .getServerId());
+
+ if (server == null) {
+
+ server = new NetconfServers();
+ server.setServerId(currentCell.getServerId());
+ } else {
+ newList.addAll(server.getCells());
+ }
+
+ newList.add(currentCell);
+ server.setCells(newList);
+ log.info("setNetconfServers: nodeId: " + nodeId + ", X:"
+ + currentCell.getGridX() + ", Y:"
+ + currentCell.getGridY() + ", ip: " + server.getIp()
+ + ", portNum: " + server.getNetconfPort()
+ + ", serverId:" + currentCell.getServerId());
+
+ rsDb.mergeNetconfServers(server);
+
+ }
+
+ } catch (Exception eu) {
+ log.info("/setNetconfServers Function Error", eu);
+
+ }
+ }
+
+ private static double degToRadians(double angle) {
+ double radians = 57.2957795;
+ return (angle / radians);
+ }
+
+ private static double metersDeglon(double angle) {
+
+ double d2r = degToRadians(angle);
+ return ((111415.13 * Math.cos(d2r)) - (94.55 * Math.cos(3.0 * d2r)) + (0.12 * Math
+ .cos(5.0 * d2r)));
+
+ }
+
+ private static double metersDeglat(double angle) {
+
+ double d2r = degToRadians(angle);
+ return (111132.09 - (566.05 * Math.cos(2.0 * d2r))
+ + (1.20 * Math.cos(4.0 * d2r)) - (0.002 * Math.cos(6.0 * d2r)));
+
+ }
+
+ /**
+ * generateClusterFromFile()
+ *
+ * @throws IOException
+ */
+ static void generateClusterFromFile() throws IOException {
+
+ EntityManagerFactory emfactory = Persistence
+ .createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+ log.info("Inside generateClusterFromFile");
+ File dumpFile = null;
+ String cellDetailsString = "";
+
+ dumpFile = new File(dumpFileName);
+
+ BufferedReader br = null;
+ try {
+ log.info("Reading dump file");
+ br = new BufferedReader(new FileReader(dumpFile));
+
+ StringBuilder sb = new StringBuilder();
+ String line = br.readLine();
+ while (line != null) {
+ sb.append(line);
+ sb.append("\n");
+ line = br.readLine();
+ }
+ cellDetailsString = sb.toString();
+
+ TopologyDump dumpTopo = new Gson().fromJson(cellDetailsString,
+ TopologyDump.class);
+ CellDetails cellsDb = new CellDetails();
+
+ log.info("dumpTopo.getCellList().size():"
+ + dumpTopo.getCellList().size());
+ for (int i = 0; i < dumpTopo.getCellList().size(); i++) {
+ Gson g = new Gson();
+ String pnt = g.toJson(dumpTopo.getCellList().get(i));
+ log.info("Creating Cell:" + pnt);
+ log.info("Creating Cell:"
+ + dumpTopo.getCellList().get(i).getCell().getNodeId());
+
+ cellsDb = new CellDetails();
+ entitymanager.getTransaction().begin();
+ cellsDb.setNodeId(dumpTopo.getCellList().get(i).getCell()
+ .getNodeId());
+ cellsDb.setPhysicalCellId(dumpTopo.getCellList().get(i)
+ .getCell().getPhysicalCellId());
+ cellsDb.setLongitude(dumpTopo.getCellList().get(i).getCell()
+ .getLongitude());
+ cellsDb.setLatitude(dumpTopo.getCellList().get(i).getCell()
+ .getLatitude());
+ cellsDb.setServerId(dumpTopo.getCellList().get(i).getCell()
+ .getPnfName());
+ if (!unassignedServerIds.contains(cellsDb.getServerId())) {
+ unassignedServerIds.add(cellsDb.getServerId());
+ }
+ cellsDb.setNetworkId(dumpTopo.getCellList().get(i).getCell()
+ .getNetworkId());
+
+ double lon = Float.valueOf(dumpTopo.getCellList().get(i)
+ .getCell().getLongitude());
+ double lat = Float.valueOf(dumpTopo.getCellList().get(i)
+ .getCell().getLatitude());
+
+ double xx = (lon - 0) * metersDeglon(0);
+ double yy = (lat - 0) * metersDeglat(0);
+
+ double rad = Math.sqrt(xx * xx + yy * yy);
+
+ if (rad > 0) {
+ double ct = xx / rad;
+ double st = yy / rad;
+ xx = rad * ((ct * Math.cos(0)) + (st * Math.sin(0)));
+ yy = rad * ((st * Math.cos(0)) - (ct * Math.sin(0)));
+ }
+
+ cellsDb.setScreenX((float) (xx));
+ cellsDb.setScreenY((float) (yy));
+
+ List<String> attachedNoeds = serverIdIpNodeMapping.get(cellsDb
+ .getServerId());
+ log.info("Attaching Cell:"
+ + dumpTopo.getCellList().get(i).getCell().getNodeId()
+ + " to " + cellsDb.getServerId());
+ if (attachedNoeds == null) {
+ attachedNoeds = new ArrayList<String>();
+ }
+ attachedNoeds.add(cellsDb.getNodeId());
+ serverIdIpNodeMapping.put(cellsDb.getServerId(), attachedNoeds);
+ if (attachedNoeds.size() > numberOfCellsPerNcServer) {
+ log.warn("Attaching Cell:"
+ + dumpTopo.getCellList().get(i).getCell()
+ .getNodeId() + " to "
+ + cellsDb.getServerId()
+ + ", But it is exceeding numberOfCellsPerNcServer "
+ + numberOfCellsPerNcServer);
+ }
+
+ entitymanager.merge(cellsDb);
+ entitymanager.flush();
+ entitymanager.getTransaction().commit();
+
+ setNetconfServers(cellsDb.getNodeId());
+ }
+
+ dumpSessionDetails();
+
+ try {
+
+ for (int i = 0; i < dumpTopo.getCellList().size(); i++) {
+
+ String cellNodeId = dumpTopo.getCellList().get(i).getCell()
+ .getNodeId();
+ entitymanager.getTransaction().begin();
+
+ // neighbor list with the corresponding node id
+ CellNeighbor neighborList = entitymanager.find(
+ CellNeighbor.class, cellNodeId);
+ // cell with the corresponding nodeId
+ CellDetails currentCell = entitymanager.find(
+ CellDetails.class, cellNodeId);
+
+ Set<NeighborDetails> newCell = new HashSet<NeighborDetails>();
+
+ if (currentCell != null) {
+ if (neighborList == null) {
+ neighborList = new CellNeighbor();
+ neighborList.setNodeId(cellNodeId);
+ }
+ List<NbrDump> neighboursFromFile = dumpTopo
+ .getCellList().get(i).getNeighbor();
+ log.info("Creating Neighbor for Cell :" + cellNodeId);
+ for (NbrDump a : neighboursFromFile) {
+ String id = a.getNodeId().trim();
+ boolean noHo = Boolean.parseBoolean(a
+ .getBlacklisted().trim());
+ CellDetails neighborCell = entitymanager.find(
+ CellDetails.class, id);
+ NeighborDetails neighborDetails = new NeighborDetails(
+ new NeihborId(currentCell.getNodeId(),
+ neighborCell.getNodeId()), noHo);
+
+ newCell.add(neighborDetails);
+ }
+
+ neighborList.setNeighborList(newCell);
+ entitymanager.merge(neighborList);
+ entitymanager.flush();
+
+ entitymanager.getTransaction().commit();
+
+ rsPciHdlr.setCollisionConfusionFromFile(cellNodeId);
+
+ }
+
+ }
+
+ } catch (Exception e1) {
+ log.info("Exception generateClusterFromFile :", e1);
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ }
+
+ try {
+
+ long startTimeSectorNumber = System.currentTimeMillis();
+ for (int i = 0; i < dumpTopo.getCellList().size(); i++) {
+
+ CellData icellData = dumpTopo.getCellList().get(i);
+ CellDetails icell = entitymanager.find(CellDetails.class,
+ icellData.getCell().getNodeId());
+ int icount = icell.getSectorNumber();
+ if (icount == 0) {
+ entitymanager.getTransaction().begin();
+ log.info("Setting sectorNumber for Cell(i) :"
+ + icell.getNodeId());
+ int jcount = 0;
+ for (int j = (i + 1); j < dumpTopo.getCellList().size(); j++) {
+
+ CellData jcellData = dumpTopo.getCellList().get(j);
+ if (icellData.getCell().getLatitude()
+ .equals(jcellData.getCell().getLatitude())) {
+ if (icellData
+ .getCell()
+ .getLongitude()
+ .equals(jcellData.getCell()
+ .getLongitude())) {
+
+ if (icount == 0) {
+ icount++;
+ jcount = icount + 1;
+ }
+
+ CellDetails jcell = entitymanager.find(
+ CellDetails.class, dumpTopo
+ .getCellList().get(j)
+ .getCell().getNodeId());
+
+ jcell.setSectorNumber(jcount);
+ log.info("Setting sectorNumber for Cell(j) :"
+ + jcell.getNodeId()
+ + " icell: "
+ + icell.getNodeId()
+ + " Sector number: " + jcount);
+ entitymanager.merge(jcell);
+ jcount++;
+ if (jcount > 3) {
+ break;
+ }
+ }
+ }
+ }
+ icell.setSectorNumber(icount);
+ entitymanager.merge(icell);
+ entitymanager.flush();
+ entitymanager.getTransaction().commit();
+ }
+
+ }
+
+ long endTimeSectorNumber = System.currentTimeMillis();
+ log.info("Time taken for setting sector number: "
+ + (endTimeSectorNumber - startTimeSectorNumber));
+
+ } catch (Exception e3) {
+ log.info("Exception generateClusterFromFile :", e3);
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ }
+
+ } catch (Exception e) {
+ log.info("Exception generateClusterFromFile :", e);
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ } finally {
+ br.close();
+ entitymanager.close();
+ emfactory.close();
+ }
+ }
+
+ /**
+ * The function deletes the cell from the database with the nodeId passed in
+ * the arguments. It removes the cell from its neighbor's neighbor list and
+ * the netconf server list.
+ *
+ * @param nodeId
+ * node Id of the cell to be deleted.
+ * @return returns success or failure message
+ */
+ public static String deleteCellFunction(String nodeId) {
+ String result = "failure node dosent exist";
+ log.info("deleteCellFunction called with nodeId :" + nodeId);
+ RansimControllerDatabase rsDb = new RansimControllerDatabase();
+
+ try {
+ CellDetails deleteCelldetail = rsDb.getCellDetail(nodeId);
+
+ CellNeighbor deleteCellNeighbor = rsDb.getCellNeighbor(nodeId);
+
+ if (deleteCelldetail != null) {
+ if (deleteCellNeighbor != null) {
+ List<CellNeighbor> cellNeighborList = rsDb
+ .getCellNeighborList();
+ for (CellNeighbor cellNeighbors : cellNeighborList) {
+ Set<NeighborDetails> currentCellNeighbors = new HashSet<NeighborDetails>(
+ cellNeighbors.getNeighborList());
+
+ NeihborId deleteNeighborDetail = new NeihborId(
+ cellNeighbors.getNodeId(),
+ deleteCelldetail.getNodeId());
+
+ if (currentCellNeighbors.contains(deleteNeighborDetail)) {
+ log.info("Deleted Cell is Neighbor of NodeId : "
+ + cellNeighbors.getNodeId());
+ currentCellNeighbors.remove(deleteNeighborDetail);
+ cellNeighbors.setNeighborList(currentCellNeighbors);
+ rsDb.mergeCellNeighbor(cellNeighbors);
+ }
+ }
+
+ deleteCellNeighbor.getNeighborList().clear();
+ rsDb.deleteCellNeighbor(deleteCellNeighbor);
+ }
+
+ rsDb.deleteCellDetails(deleteCelldetail);
+ result = "cell has been deleted from the database";
+ } else {
+ log.info("cell id does not exist");
+ result = "failure nodeId dosent exist";
+ return result;
+ }
+ } catch (Exception eu) {
+ log.info("Exception deleteCellFunction :", eu);
+
+ result = "exception in function";
+ }
+ return result;
+ }
+
+ /**
+ * Send configuration details to all the netconf server.
+ */
+ public void sendInitialConfigAll() {
+ RansimControllerDatabase rsDb = new RansimControllerDatabase();
+ try {
+ dumpSessionDetails();
+ List<NetconfServers> ncServers = rsDb.getNetconfServersList();
+ for (NetconfServers netconfServers : ncServers) {
+ String ipPortKey = serverIdIpPortMapping.get(netconfServers
+ .getServerId());
+ if (ipPortKey == null || ipPortKey.trim().equals("")) {
+ log.info("No client for " + netconfServers.getServerId());
+ for (String ipPortKeyStr : webSocketSessions.keySet()) {
+ if (!serverIdIpPortMapping.containsValue(ipPortKeyStr)) {
+ serverIdIpPortMapping.put(
+ netconfServers.getServerId(), ipPortKeyStr);
+ ipPortKey = ipPortKeyStr;
+ break;
+ }
+ }
+ }
+ if (ipPortKey != null && !ipPortKey.trim().equals("")) {
+ Session clSess = webSocketSessions.get(ipPortKey);
+ if (clSess != null) {
+ sendInitialConfig(netconfServers.getServerId());
+ try {
+ String[] agentDetails = ipPortKey.split(":");
+ new RestClient().sendMountRequestToSdnr(
+ netconfServers.getServerId(), sdnrServerIp,
+ sdnrServerPort, agentDetails[0],
+ agentDetails[1], sdnrServerUserid,
+ sdnrServerPassword);
+ } catch (Exception ex1) {
+ log.info("Ignoring exception", ex1);
+ }
+
+ } else {
+ log.info("No session for " + ipPortKey);
+ }
+ }
+ }
+ } catch (Exception eu) {
+ log.info("Exception:", eu);
+ }
+ }
+
+ /**
+ * Sends initial configuration details of the cells for a new netconf server
+ * that has been started.
+ *
+ * @param ipPortKey
+ * ip address details of the netconf server
+ */
+ public void sendInitialConfigForNewAgent(String ipPortKey, String serverId) {
+ try {
+ dumpSessionDetails();
+ if (ipPortKey != null && !ipPortKey.trim().equals("")) {
+ if (serverId != null && !serverId.trim().equals("")) {
+ Session clSess = webSocketSessions.get(ipPortKey);
+ if (clSess != null) {
+ String[] agentDetails = ipPortKey.split(":");
+ sendInitialConfig(serverId);
+ new RestClient().sendMountRequestToSdnr(serverId,
+ sdnrServerIp, sdnrServerPort, agentDetails[0],
+ agentDetails[1], sdnrServerUserid,
+ sdnrServerPassword);
+ } else {
+ log.info("No session for " + ipPortKey);
+ }
+ } else {
+ log.info("No serverid for " + ipPortKey);
+ }
+ } else {
+ log.info("Invalid ipPortKey " + ipPortKey);
+ }
+ } catch (Exception eu) {
+ log.info("Exception:", eu);
+ }
+ }
+
+ /**
+ * To send the initial configration to the netconf server.
+ *
+ * @param serverId
+ * ip address details of the netconf server
+ */
+ public void sendInitialConfig(String serverId) {
+
+ RansimControllerDatabase rsDb = new RansimControllerDatabase();
+ try {
+ NetconfServers server = rsDb.getNetconfServer(serverId);
+ log.info("sendInitialConfig: serverId:" + serverId + ", server:"
+ + server);
+ if (server == null) {
+ return;
+ }
+
+ String ipPortKey = serverIdIpPortMapping.get(serverId);
+
+ log.info("sendInitialConfig: ipPortKey:" + ipPortKey);
+
+ List<CellDetails> cellList = new ArrayList<CellDetails>(
+ server.getCells());
+
+ List<Topology> config = new ArrayList<Topology>();
+
+ for (int i = 0; i < server.getCells().size(); i++) {
+ Topology cell = new Topology();
+ CellDetails currentCell = rsDb.getCellDetail(cellList.get(i)
+ .getNodeId());
+ CellNeighbor neighbor = rsDb.getCellNeighbor(cellList.get(i)
+ .getNodeId());
+
+ cell.setCellId("" + currentCell.getNodeId());
+ cell.setPciId(currentCell.getPhysicalCellId());
+ cell.setPnfName(serverId);
+
+ List<Neighbor> nbrList = new ArrayList<Neighbor>();
+ Set<NeighborDetails> nbrsDet = neighbor.getNeighborList();
+ for (NeighborDetails cellDetails : nbrsDet) {
+ Neighbor nbr = new Neighbor();
+ CellDetails nbrCell = rsDb.getCellDetail(cellDetails
+ .getNeigbor().getNeighborCell());
+ nbr.setNodeId(nbrCell.getNodeId());
+ nbr.setPhysicalCellId(nbrCell.getPhysicalCellId());
+ nbr.setPnfName(nbrCell.getServerId());
+ nbr.setServerId(nbrCell.getServerId());
+ nbr.setPlmnId(nbrCell.getNetworkId());
+ nbr.setBlacklisted(cellDetails.isBlacklisted());
+ nbrList.add(nbr);
+ }
+ cell.setNeighborList(nbrList);
+ config.add(i, cell);
+ }
+
+ SetConfigTopology topo = new SetConfigTopology();
+
+ topo.setServerId(server.getServerId());
+ String uuid = globalNcServerUuidMap.get(server.getServerId());
+ if (uuid == null) {
+ uuid = getUuid();
+ globalNcServerUuidMap.put(server.getServerId(), uuid);
+ }
+ topo.setUuid(uuid);
+
+ topo.setTopology(config);
+
+ Gson gson = new Gson();
+ String jsonStr = gson.toJson(topo);
+ log.info("ConfigTopologyMessage: " + jsonStr);
+ Session clSess = webSocketSessions.get(ipPortKey);
+ RansimWebSocketServer.sendSetConfigTopologyMessage(jsonStr, clSess);
+
+ } catch (Exception eu) {
+ log.info("Exception:", eu);
+ }
+
+ }
+
+ private static String getUuid() {
+ return UUID.randomUUID().toString();
+ }
+
+ /**
+ * The function alters the database information based on the modifications
+ * made in the SDNR.
+ *
+ * @param message
+ * message received from the SDNR
+ * @param session
+ * sends the session details
+ * @param ipPort
+ * ip address of the netconf server
+ */
+ public void handleModifyPciFromSdnr(String message, Session session,
+ String ipPort) {
+ log.info("handleModifyPciFromSDNR: message:" + message + " session:"
+ + session + " ipPort:" + ipPort);
+ RansimControllerDatabase rcDb = new RansimControllerDatabase();
+ ModifyPci modifyPci = new Gson().fromJson(message, ModifyPci.class);
+ log.info("handleModifyPciFromSDNR: modifyPci:" + modifyPci.getCellId()
+ + "; pci: " + modifyPci.getPciId());
+ String source = "Netconf";
+
+ CellDetails cd = rcDb.getCellDetail(modifyPci.getCellId());
+ long pci = cd.getPhysicalCellId();
+ cd.setPhysicalCellId(modifyPci.getPciId());
+ rcDb.mergeCellDetails(cd);
+ rsPciHdlr.updatePciOperationsTable(modifyPci.getCellId(), source, pci,
+ modifyPci.getPciId());
+ }
+
+ /**
+ * The function alters the database information based on the modifications
+ * made in the SDNR.
+ *
+ * @param message
+ * message received from the SDNR
+ * @param session
+ * sends the session details
+ * @param ipPort
+ * ip address of the netconf server
+ */
+ public void handleModifyNeighborFromSdnr(String message, Session session,
+ String ipPort) {
+ log.info("handleModifyAnrFromSDNR: message:" + message + " session:"
+ + session + " ipPort:" + ipPort);
+ RansimControllerDatabase rsDb = new RansimControllerDatabase();
+ ModifyNeighbor modifyNeighbor = new Gson().fromJson(message,
+ ModifyNeighbor.class);
+ log.info("handleModifyAnrFromSDNR: modifyPci:"
+ + modifyNeighbor.getCellId());
+ CellDetails currentCell = rsDb
+ .getCellDetail(modifyNeighbor.getCellId());
+ List<NeighborDetails> neighborList = new ArrayList<NeighborDetails>();
+ List<String> cellList = new ArrayList<String>();
+ cellList.add(modifyNeighbor.getCellId());
+ String nbrsAdd = "";
+ String nbrsDel = "";
+ String source = "Netconf";
+
+ for (int i = 0; i < modifyNeighbor.getNeighborList().size(); i++) {
+ if (modifyNeighbor.getNeighborList().get(i).isBlacklisted()) {
+ NeighborDetails nd = new NeighborDetails(new NeihborId(
+ modifyNeighbor.getCellId(), modifyNeighbor
+ .getNeighborList().get(i).getNodeId()), true);
+ rsDb.mergeNeighborDetails(nd);
+ cellList.add(modifyNeighbor.getNeighborList().get(i)
+ .getNodeId());
+ if (nbrsAdd.equals("")) {
+ nbrsDel = modifyNeighbor.getNeighborList().get(i)
+ .getNodeId();
+ } else {
+ nbrsDel += ","
+ + modifyNeighbor.getNeighborList().get(i)
+ .getNodeId();
+ }
+ } else {
+ NeighborDetails nd = new NeighborDetails(new NeihborId(
+ modifyNeighbor.getCellId(), modifyNeighbor
+ .getNeighborList().get(i).getNodeId()), false);
+ rsDb.mergeNeighborDetails(nd);
+ cellList.add(modifyNeighbor.getNeighborList().get(i)
+ .getNodeId());
+ if (nbrsDel.equals("")) {
+ nbrsAdd = modifyNeighbor.getNeighborList().get(i)
+ .getNodeId();
+ } else {
+ nbrsAdd += ","
+ + modifyNeighbor.getNeighborList().get(i)
+ .getNodeId();
+ }
+ }
+
+ }
+
+ for (String cl : cellList) {
+ RansimPciHandler.setCollisionConfusionFromFile(cl);
+ }
+
+ log.info("neighbor list: " + neighborList);
+
+ rsPciHdlr.updateNbrsOperationsTable(modifyNeighbor.getCellId(), source,
+ nbrsAdd, nbrsDel);
+ }
+
+ /**
+ * The function sends the modification made in the GUI to the netconf
+ * server.
+ *
+ * @param cellId
+ * node Id of the cell which was modified
+ * @param pciId
+ * PCI number of the cell which was modified
+ */
+ public void handleModifyPciFromGui(String cellId, long pciId) {
+ log.info("handleModifyPciFromGUI: cellId:" + cellId + " pciId:" + pciId);
+ RansimControllerDatabase rsDb = new RansimControllerDatabase();
+
+ try {
+ CellDetails currentCell = rsDb.getCellDetail(cellId);
+ CellNeighbor neighborList = rsDb.getCellNeighbor(cellId);
+ List<Neighbor> nbrList = new ArrayList<Neighbor>();
+ Iterator<NeighborDetails> iter = neighborList.getNeighborList()
+ .iterator();
+ while (iter.hasNext()) {
+ NeighborDetails nbCell = iter.next();
+ Neighbor nbr = new Neighbor();
+ CellDetails nbrCell = rsDb.getCellDetail(nbCell.getNeigbor()
+ .getNeighborCell());
+
+ nbr.setNodeId(nbrCell.getNodeId());
+ nbr.setPhysicalCellId(nbrCell.getPhysicalCellId());
+ nbr.setPnfName(nbrCell.getNodeName());
+ nbr.setServerId(nbrCell.getServerId());
+ nbr.setPlmnId(nbrCell.getNetworkId());
+ nbrList.add(nbr);
+ }
+
+ String pnfName = currentCell.getServerId();
+ String ipPort = serverIdIpPortMapping.get(pnfName);
+ log.info("handleModifyPciFromGui:ipPort >>>>>>> " + ipPort);
+
+ if (ipPort != null && !ipPort.trim().equals("")) {
+
+ String[] ipPortArr = ipPort.split(":");
+ Topology oneCell = new Topology(pnfName, pciId, cellId, nbrList);
+ UpdateCell updatedPci = new UpdateCell(
+ currentCell.getServerId(), ipPortArr[0], ipPortArr[1],
+ oneCell);
+ Gson gson = new Gson();
+ String jsonStr = gson.toJson(updatedPci);
+ if (ipPort != null && !ipPort.trim().equals("")) {
+ Session clSess = webSocketSessions.get(ipPort);
+ if (clSess != null) {
+ RansimWebSocketServer.sendUpdateCellMessage(jsonStr,
+ clSess);
+ log.info("handleModifyPciFromGui, message: " + jsonStr);
+ } else {
+ log.info("No client session for " + ipPort);
+ }
+ } else {
+ log.info("No client for " + currentCell.getServerId());
+ }
+ }
+
+ } catch (Exception eu) {
+
+ log.info("Exception:", eu);
+ }
+ }
+
+ /**
+ * The function unmounts the connection with SDNR.
+ *
+ * @return returns null value
+ */
+ public String stopAllCells() {
+ RansimControllerDatabase rcDb = new RansimControllerDatabase();
+ try {
+ List<NetconfServers> ncServers = rcDb.getNetconfServersList();
+ for (NetconfServers netconfServers : ncServers) {
+ try {
+ log.info("Unmount " + netconfServers.getServerId());
+ new RestClient().sendUnmountRequestToSdnr(
+ netconfServers.getServerId(), sdnrServerIp,
+ sdnrServerPort, sdnrServerUserid,
+ sdnrServerPassword);
+ } catch (Exception e) {
+ log.info("Ignore Exception:", e);
+ }
+ serverIdIpNodeMapping.clear();
+ }
+ return "Netconf servers unmounted.";
+ } catch (Exception eu) {
+
+ log.info("Exception:", eu);
+ return "Error";
+ }
+
+ }
+
+ /**
+ * Used to dump session details.
+ */
+ synchronized public static void dumpSessionDetails() {
+
+ try {
+
+ log.info("serverIdIpPortMapping.size:"
+ + serverIdIpPortMapping.size() + "webSocketSessions.size"
+ + webSocketSessions.size());
+ for (String key : serverIdIpPortMapping.keySet()) {
+ String val = serverIdIpPortMapping.get(key);
+ Session sess = webSocketSessions.get(val);
+ log.info("ServerId:" + key + " IpPort:" + val + " Session:"
+ + sess);
+ }
+ for (String serverId : unassignedServerIds) {
+ log.info("Unassigned ServerId:" + serverId);
+ }
+ for (String serverId : serverIdIpPortMapping.keySet()) {
+ List<String> attachedNoeds = serverIdIpNodeMapping
+ .get(serverId);
+ if (attachedNoeds != null) {
+ log.info("ServerId:" + serverId + " attachedNoeds.size:"
+ + attachedNoeds.size() + " nodes:"
+ + attachedNoeds.toArray());
+ } else {
+ log.info("ServerId:" + serverId + " attachedNoeds:" + null);
+ }
+ }
+ } catch (Exception e) {
+ log.info("Exception:", e);
+ }
+ }
+
+}
+
+class KeepWebsockAliveThread extends Thread {
+ static Logger log = Logger
+ .getLogger(KeepWebsockAliveThread.class.getName());
+ RansimController rsCtrlr = null;
+
+ KeepWebsockAliveThread(RansimController ctrlr) {
+ rsCtrlr = ctrlr;
+ }
+
+ @Override
+ public void run() {
+ log.info("Inside KeepWebsockAliveThread run method");
+ while (true) {
+ for (String ipPort : rsCtrlr.webSocketSessions.keySet()) {
+ try {
+ Session sess = rsCtrlr.webSocketSessions.get(ipPort);
+ RansimWebSocketServer.sendPingMessage(sess);
+ log.debug("Sent ping message to Client ipPort:" + ipPort);
+ } catch (Exception ex1) {
+ }
+ }
+ try {
+ Thread.sleep(10000);
+ } catch (Exception ex) {
+ }
+ }
+ }
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimControllerDatabase.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimControllerDatabase.java
new file mode 100644
index 0000000..0d7ea3a
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimControllerDatabase.java
@@ -0,0 +1,409 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.controller;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.persistence.Query;
+import javax.persistence.TypedQuery;
+
+import org.apache.log4j.Logger;
+import org.onap.ransim.rest.api.models.CellDetails;
+import org.onap.ransim.rest.api.models.CellNeighbor;
+import org.onap.ransim.rest.api.models.NeighborDetails;
+import org.onap.ransim.rest.api.models.NetconfServers;
+import org.onap.ransim.rest.api.models.OperationLog;
+
+public class RansimControllerDatabase {
+
+ static Logger log = Logger.getLogger(RansimControllerDatabase.class
+ .getName());
+
+ /**
+ * Gets the CellDetail from the database.
+ *
+ * @param nodeId Node Id of the cell(primary key)
+ * @return Returns the cell with mentioned node ID.
+ */
+ CellDetails getCellDetail(String nodeId){
+ EntityManagerFactory emfactory = Persistence
+ .createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+ CellDetails currentCell = null;
+
+ try{
+ currentCell = entitymanager.find(CellDetails.class, nodeId);
+ }catch(Exception e){
+ log.info("Exception in getCellDetail: " + e);
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ }
+ finally {
+ entitymanager.close();
+ emfactory.close();
+ }
+
+ return currentCell;
+
+ }
+
+ /**
+ *
+ * @param serverId
+ * @return
+ */
+ static NetconfServers getNetconfServer(String serverId){
+ EntityManagerFactory emfactory = Persistence
+ .createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+ NetconfServers ns = null;
+
+ try{
+ ns = entitymanager.find(NetconfServers.class, serverId);
+ }catch(Exception e){
+ log.info("Exception in getCellDetail: " + e);
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ }
+ finally {
+ entitymanager.close();
+ emfactory.close();
+ }
+
+ return ns;
+
+ }
+ CellNeighbor getCellNeighbor(String nodeId){
+ EntityManagerFactory emfactory = Persistence
+ .createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+ CellNeighbor ns = null;
+
+ try{
+ ns = entitymanager.find(CellNeighbor.class, nodeId);
+ }catch(Exception e){
+ log.info("Exception in getCellDetail: " + e);
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ }
+ finally {
+ entitymanager.close();
+ emfactory.close();
+ }
+
+ return ns;
+
+ }
+
+ void deleteCellDetails(CellDetails deleteCelldetail){
+ EntityManagerFactory emfactory = Persistence
+ .createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+
+
+
+ try{
+ if (deleteCelldetail.getServerId() != null) {
+ entitymanager.getTransaction().begin();
+ log.info("inside NetconfServers handling ....");
+ NetconfServers ns = entitymanager.find(NetconfServers.class, deleteCelldetail.getServerId());
+ ns.getCells().remove(deleteCelldetail);
+ entitymanager.merge(ns);
+ entitymanager.flush();
+ entitymanager.getTransaction().commit();
+
+ }
+ entitymanager.getTransaction().begin();
+ CellDetails cd = entitymanager.find(CellDetails.class, deleteCelldetail.getNodeId());
+ entitymanager.remove(cd);
+ entitymanager.flush();
+ entitymanager.getTransaction().commit();
+
+ }catch(Exception e){
+ log.info("Exception in getCellDetail: " + e);
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ }
+ finally {
+ entitymanager.close();
+ emfactory.close();
+ }
+ }
+
+ void deleteCellNeighbor(CellNeighbor deleteCellNeighbor){
+ EntityManagerFactory emfactory = Persistence
+ .createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+
+ entitymanager.getTransaction().begin();
+
+ try{
+ log.info("inside delete cel neighbor");
+ CellNeighbor cn = entitymanager.find(CellNeighbor.class, deleteCellNeighbor.getNodeId());
+ entitymanager.remove(cn);
+ entitymanager.flush();
+ entitymanager.getTransaction().commit();
+ log.info("removed cell neighbor from database");
+
+ }catch(Exception e){
+ log.info("Exception in deleteCellNeighbor: " + e);
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ }
+ finally {
+ entitymanager.close();
+ emfactory.close();
+ }
+ }
+
+ static void mergeCellDetails(CellDetails cellDetail){
+ EntityManagerFactory emfactory = Persistence.createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+ try{
+ entitymanager.getTransaction().begin();
+ entitymanager.merge(cellDetail);
+ log.info("updated in database....");
+ entitymanager.flush();
+ entitymanager.getTransaction().commit();
+ }catch (Exception eu) {
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ log.info("Exception:", eu);
+ } finally {
+ entitymanager.close();
+ emfactory.close();
+ }
+ }
+
+ void mergeNeighborDetails(NeighborDetails neighborDetails){
+ EntityManagerFactory emfactory = Persistence.createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+ try{
+ entitymanager.getTransaction().begin();
+ entitymanager.merge(neighborDetails);
+ log.info("updated in database....");
+ entitymanager.flush();
+ entitymanager.getTransaction().commit();
+ } catch (Exception eu) {
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ log.info("Exception:", eu);
+ } finally {
+ entitymanager.close();
+ emfactory.close();
+ }
+ }
+
+ void mergeNetconfServers(NetconfServers netconfServers){
+ EntityManagerFactory emfactory = Persistence.createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+ try{
+ entitymanager.getTransaction().begin();
+ entitymanager.merge(netconfServers);
+ log.info("updated in database....");
+ entitymanager.flush();
+ entitymanager.getTransaction().commit();
+ } catch (Exception eu) {
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ log.info("Exception:", eu);
+ } finally {
+ entitymanager.close();
+ emfactory.close();
+ }
+ }
+
+ void mergeCellNeighbor(CellNeighbor cellNeighbor){
+ EntityManagerFactory emfactory = Persistence.createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+ try{
+ entitymanager.getTransaction().begin();
+ log.info("updated in database....");
+ entitymanager.merge(cellNeighbor);
+ entitymanager.flush();
+ entitymanager.getTransaction().commit();
+ } catch (Exception eu) {
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ log.info("Exception:", eu);
+ } finally {
+ entitymanager.close();
+ emfactory.close();
+ }
+ }
+
+ List<CellDetails> getCellDetailsList(){
+ EntityManagerFactory emfactory = Persistence.createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+ List<CellDetails> cds = new ArrayList<CellDetails>();
+ try{
+ entitymanager.getTransaction().begin();
+ log.info("updated in database....");
+ Query query = entitymanager.createQuery("from CellDetails cd", CellDetails.class);
+ cds = query.getResultList();
+ entitymanager.flush();
+ entitymanager.getTransaction().commit();
+ } catch (Exception eu) {
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ log.info("Exception:", eu);
+ } finally {
+ entitymanager.close();
+ emfactory.close();
+ }
+
+ return cds;
+ }
+
+ List<CellDetails> getCellsWithNoServerIds(){
+ EntityManagerFactory emfactory = Persistence.createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+ List<CellDetails> cds = new ArrayList<CellDetails>();
+ try{
+ entitymanager.getTransaction().begin();
+ log.info("getCellswithNoServerIds: updated in database....");
+ TypedQuery<CellDetails> query = entitymanager.createQuery(
+ "SELECT n FROM CellDetails WHERE n.serverId is null", CellDetails.class);
+ cds = query.getResultList();
+ entitymanager.flush();
+ entitymanager.getTransaction().commit();
+ } catch (Exception eu) {
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ log.info("Exception:", eu);
+ } finally {
+ entitymanager.close();
+ emfactory.close();
+ }
+
+ return cds;
+ }
+
+ List<CellDetails> getCellsWithCollisionOrConfusion(){
+ EntityManagerFactory emfactory = Persistence.createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+ List<CellDetails> cds = new ArrayList<CellDetails>();
+ try{
+ entitymanager.getTransaction().begin();
+ log.info("getCellsWithCollisionOrConfusion: updated in database....");
+ Query query = entitymanager
+ .createQuery(
+ "from CellDetails cd where cd.pciCollisionDetected=true or cd.pciConfusionDetected=true",
+ CellDetails.class);
+ cds = query.getResultList();
+ entitymanager.flush();
+ entitymanager.getTransaction().commit();
+ } catch (Exception eu) {
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ log.info("Exception:", eu);
+ } finally {
+ entitymanager.close();
+ emfactory.close();
+ }
+
+ return cds;
+ }
+
+ List<OperationLog> getOperationLogList(){
+ EntityManagerFactory emfactory = Persistence.createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+ List<OperationLog> ols = new ArrayList<OperationLog>();
+ try{
+ entitymanager.getTransaction().begin();
+ log.info("updated in database....");
+ Query query = entitymanager.createQuery("from OperationLog ol", OperationLog.class);
+ ols = query.getResultList();
+ entitymanager.flush();
+ entitymanager.getTransaction().commit();
+ } catch (Exception eu) {
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ log.info("Exception:", eu);
+ } finally {
+ entitymanager.close();
+ emfactory.close();
+ }
+
+ return ols;
+ }
+
+ List<NetconfServers> getNetconfServersList(){
+ EntityManagerFactory emfactory = Persistence.createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+ List<NetconfServers> cnl = new ArrayList<NetconfServers>();
+ try{
+ log.info("updated in database....");
+ Query query = entitymanager.createQuery("from NetconfServers ns", NetconfServers.class);
+ cnl = query.getResultList();
+ } catch (Exception eu) {
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ log.info("Exception:", eu);
+ } finally {
+ entitymanager.close();
+ emfactory.close();
+ }
+
+ return cnl;
+ }
+
+ List<CellNeighbor> getCellNeighborList() {
+ EntityManagerFactory emfactory = Persistence.createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+ List<CellNeighbor> cellNeighborList = new ArrayList<CellNeighbor>();
+ try {
+ entitymanager.getTransaction().begin();
+ TypedQuery<CellNeighbor> query = entitymanager.createQuery("from CellNeighbor cn", CellNeighbor.class);
+ cellNeighborList = query.getResultList();
+ entitymanager.flush();
+ entitymanager.getTransaction().commit();
+ } catch (Exception eu) {
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ log.info("Exception:", eu);
+ } finally {
+ entitymanager.close();
+ emfactory.close();
+ }
+ return cellNeighborList;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimControllerServices.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimControllerServices.java
new file mode 100644
index 0000000..9fc130c
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimControllerServices.java
@@ -0,0 +1,730 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.controller;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.persistence.Query;
+
+import org.apache.log4j.Logger;
+import org.onap.ransim.rest.api.models.CellDetails;
+import org.onap.ransim.rest.api.models.CellNeighbor;
+import org.onap.ransim.rest.api.models.DeleteACellReq;
+import org.onap.ransim.rest.api.models.GetACellDetailReq;
+import org.onap.ransim.rest.api.models.GetNeighborList;
+import org.onap.ransim.rest.api.models.GetNeighborListReq;
+import org.onap.ransim.rest.api.models.GetNetconfServerDetailsReq;
+import org.onap.ransim.rest.api.models.GetPmDataReq;
+import org.onap.ransim.rest.api.models.ModifyACellReq;
+import org.onap.ransim.rest.api.models.NeighborDetails;
+import org.onap.ransim.rest.api.models.NeihborId;
+import org.onap.ransim.rest.api.models.NetconfServers;
+import org.onap.ransim.rest.api.models.OperationLog;
+import org.onap.ransim.rest.api.models.Topology;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+
+@RestController
+@Api(value = "Ran Simulator Controller Services")
+@RequestMapping("/")
+@CrossOrigin(origins = "*")
+public class RansimControllerServices {
+
+ static Logger log = Logger.getLogger(RansimControllerServices.class
+ .getName());
+
+ private static boolean isSimulationStarted = false;
+ private static boolean isPmDataGenerating = false;
+
+ private static RansimControllerServices rscServices = null;
+
+ ScheduledExecutorService execService = Executors.newScheduledThreadPool(5);
+
+ private RansimControllerServices() {
+
+ }
+
+ /**
+ * To accesss variable of this class from another class.
+ *
+ * @return returns rscServices constructor
+ */
+ public static synchronized RansimControllerServices getRansimControllerServices() {
+ if (rscServices == null) {
+ rscServices = new RansimControllerServices();
+ }
+ return rscServices;
+ }
+
+ RansimController rsCtrlr = RansimController.getRansimController();
+ RansimPciHandler rsPciHdlr = RansimPciHandler.getRansimPciHandler();
+
+ /**
+ * Start the RAN network simulation.
+ *
+ * @param req
+ * gets the necessary details as a request of class type
+ * StartSimulationReq
+ * @return returns Http status
+ * @throws Exception
+ * throws exceptions in the functions
+ */
+ @ApiOperation("Starts the RAN network simulation")
+ @RequestMapping(value = "/StartSimulation", method = RequestMethod.POST)
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"),
+ @ApiResponse(code = 500, message = "Cannot start the simulation") })
+ public ResponseEntity<String> startSimulation() throws Exception {
+
+ RansimControllerDatabase rsDb = new RansimControllerDatabase();
+
+ List<CellDetails> cellList = rsDb.getCellDetailsList();
+ if (!cellList.isEmpty()) {
+ return new ResponseEntity<>("Already simulation is running.",
+ HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+
+ try {
+ rsCtrlr.loadProperties();
+ long startTimeStartSimulation = System.currentTimeMillis();
+ rsCtrlr.generateClusterFromFile();
+ rsCtrlr.sendInitialConfigAll();
+ long endTimeStartSimulation = System.currentTimeMillis();
+ log.info("Time taken for start simulation : "
+ + (endTimeStartSimulation - startTimeStartSimulation));
+
+ return new ResponseEntity<String>(HttpStatus.OK);
+
+ } catch (Exception eu) {
+ log.info("/StartSimulation ", eu);
+ return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+
+ }
+
+ /**
+ * The performance Management Data of each cell will be sent to its netconf
+ * agent at a regular interval.
+ *
+ * @param req
+ * Contains the details of node ids which will have bad and poor
+ * pm values
+ * @return return HTTP status.
+ *
+ */
+ @ApiOperation("Generate PM data")
+ @RequestMapping(value = "/GeneratePmData", method = RequestMethod.POST)
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"),
+ @ApiResponse(code = 500, message = "Cannot start the simulation") })
+ public ResponseEntity<String> generatePmData(@RequestBody GetPmDataReq req)
+ throws Exception {
+
+ log.info("Inside generatePmData...");
+ log.info("nodeId_bad: " + req.getNodeIdBad());
+ log.info("nodeId_poor: " + req.getNodeIdPoor());
+
+ try {
+ rsPciHdlr.readPmParameters();
+ execService = Executors.newScheduledThreadPool(5);
+ execService.scheduleAtFixedRate(
+ () -> {
+
+ List<String> resp = rsPciHdlr.generatePmData(
+ req.getNodeIdBad(), req.getNodeIdPoor());
+ log.info("execService.isTerminated(): "
+ + execService.isTerminated());
+
+ }, 0, 300, TimeUnit.SECONDS);
+
+ isPmDataGenerating = true;
+
+ return new ResponseEntity<>("Request generated.", HttpStatus.OK);
+
+ } catch (Exception eu) {
+ log.info("Exception: ", eu);
+ return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
+
+ }
+
+ }
+
+ /**
+ * Terminates the ScheduledExecutorService which sends the PM data at
+ * regular interval.
+ *
+ * @return returns HTTP status
+ *
+ */
+ @ApiOperation("stop PM data")
+ @RequestMapping(value = "/stopPmData", method = RequestMethod.GET)
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"),
+ @ApiResponse(code = 500, message = "Cannot start the simulation") })
+ public ResponseEntity<String> stopPmData() throws Exception {
+
+ long startTime = (System.currentTimeMillis() / 1000);
+
+ try {
+ log.info("1. execService.isTerminated(): "
+ + execService.isTerminated());
+ if (!execService.isTerminated()) {
+ execService.shutdown();
+ log.info("2. execService.isTerminated(): "
+ + execService.isTerminated());
+
+ }
+ isPmDataGenerating = false;
+ return new ResponseEntity<>("PM data generated.", HttpStatus.OK);
+
+ } catch (Exception eu) {
+ return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+
+ }
+
+ /**
+ * Get the status of ScheduledExecutorService, whether active or terminated.
+ *
+ * @return return the status
+ *
+ */
+ @ApiOperation("get PM data status")
+ @RequestMapping(value = "/GetPmDataStatus", method = RequestMethod.GET)
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"),
+ @ApiResponse(code = 500, message = "Cannot get information") })
+ public boolean getPmDataStatus() throws Exception {
+
+ try {
+ return isPmDataGenerating;
+ } catch (Exception eu) {
+ return false;
+ }
+
+ }
+
+ /**
+ * The function retrieves RAN simulation network topology.
+ *
+ * @return returns Http status
+ * @throws Exception
+ * throws exceptions in the functions
+ *
+ */
+ @ApiOperation("Retrieves RAN simulation network topology")
+ @RequestMapping(value = "/GetTopology", method = RequestMethod.GET)
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Successful"),
+ @ApiResponse(code = 500, message = "Cannot retrieve the RAN simulation network topology details") })
+ public ResponseEntity<String> getTopology() throws Exception {
+ log.info("Inside getTopology...");
+ RansimControllerDatabase rsDb = new RansimControllerDatabase();
+ try {
+ rsPciHdlr.checkCollisionAfterModify();
+ List<CellDetails> cds = rsDb.getCellDetailsList();
+
+ Topology top = new Topology();
+
+ if (cds != null && cds.size() > 0) {
+ top.setMinScreenX(cds.get(0).getScreenX());
+ top.setMaxScreenX(cds.get(0).getScreenX());
+ top.setMinScreenY(cds.get(0).getScreenY());
+ top.setMaxScreenY(cds.get(0).getScreenY());
+
+ for (int i = 0; i < cds.size(); i++) {
+ if (cds.get(i).getScreenX() < top.getMinScreenX()) {
+ top.setMinScreenX(cds.get(i).getScreenX());
+ }
+ if (cds.get(i).getScreenY() < top.getMinScreenY()) {
+ top.setMinScreenY(cds.get(i).getScreenY());
+ }
+
+ if (cds.get(i).getScreenX() > top.getMaxScreenX()) {
+ top.setMaxScreenX(cds.get(i).getScreenX());
+ }
+ if (cds.get(i).getScreenY() > top.getMaxScreenY()) {
+ top.setMaxScreenY(cds.get(i).getScreenY());
+ }
+ }
+ top.setCellTopology(cds);
+ }
+ top.setGridSize(rsCtrlr.gridSize);
+
+ Gson gson = new Gson();
+ String jsonStr = gson.toJson(top);
+
+ return new ResponseEntity<>(jsonStr, HttpStatus.OK);
+
+ } catch (Exception eu) {
+ log.info("/GetTopology", eu);
+ return new ResponseEntity<>("Failure",
+ HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+
+ /**
+ * The function retrieves the neighbor list details for the cell with the
+ * mentioned nodeId.
+ *
+ * @param req
+ * gets the necessary details as a request of class type
+ * GetNeighborListReq
+ * @return returns Http status
+ * @throws Exception
+ * throws exceptions in the functions
+ */
+ @ApiOperation("Retrieves the neighbor list details for the cell with the mentioned nodeId")
+ @RequestMapping(value = "/GetNeighborList", method = RequestMethod.POST)
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Successful"),
+ @ApiResponse(code = 500, message = "Cannot Insert the given parameters") })
+ public ResponseEntity<String> getNeighborList(
+ @RequestBody GetNeighborListReq req) throws Exception {
+ log.info("Inside getNeighborList...");
+
+ try {
+ String jsonStr = "";
+
+ GetNeighborList message = rsPciHdlr.generateNeighborList(req
+ .getNodeId());
+
+ if (message != null) {
+
+ log.info("message.getNodeId(): " + message.getNodeId());
+
+ Gson gson = new Gson();
+ jsonStr = gson.toJson(message);
+ }
+ return new ResponseEntity<>(jsonStr, HttpStatus.OK);
+
+ } catch (Exception eu) {
+ log.info("/getNeighborList", eu);
+
+ return new ResponseEntity<>("Failure",
+ HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+
+ /**
+ * The function retrieves the neighbor list for the cell with the mentioned
+ * nodeId.
+ *
+ * @param req
+ * gets the necessary details as a request of class type
+ * GetNeighborListReq
+ * @return returns Http status
+ * @throws Exception
+ * throws exceptions in the functions
+ */
+ @ApiOperation("Retrieves the neighbor list details for the cell with the mentioned nodeId")
+ @RequestMapping(value = "/GetNeighborBlacklistDetails", method = RequestMethod.POST)
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Successful"),
+ @ApiResponse(code = 500, message = "Cannot Insert the given parameters") })
+ public ResponseEntity<String> getNeighborBlacklistDetails(
+ @RequestBody GetNeighborListReq req) throws Exception {
+ log.info("Inside getNeighborList...");
+
+ try {
+ String jsonStr = "";
+
+ RansimControllerDatabase rsDb = new RansimControllerDatabase();
+ CellNeighbor neighborList = rsDb.getCellNeighbor(req.getNodeId());
+
+ Map<String, String> result = new ConcurrentHashMap<String, String>();
+
+ for (NeighborDetails nd : neighborList.getNeighborList()) {
+
+ result.put(nd.getNeigbor().getNeighborCell(),
+ "" + nd.isBlacklisted());
+ }
+
+ if (result != null) {
+ Gson gson = new Gson();
+ jsonStr = gson.toJson(result);
+ }
+ return new ResponseEntity<>(jsonStr, HttpStatus.OK);
+
+ } catch (Exception eu) {
+ log.info("/getNeighborList", eu);
+
+ return new ResponseEntity<>("Failure",
+ HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+
+ /**
+ * Changes the pci number or nbr list for the given cell.
+ *
+ * @param req
+ * gets the necessary details as a request of class type
+ * ModifyACellReq
+ * @return returns Http status
+ * @throws Exception
+ * throws exceptions in the functions
+ */
+ @ApiOperation("Changes the pci number or nbr list for the given cell")
+ @RequestMapping(value = "/ModifyACell", method = RequestMethod.POST)
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Successful"),
+ @ApiResponse(code = 500, message = "Cannot update the PCI for the given cell") })
+ public ResponseEntity<String> modifyACell(@RequestBody ModifyACellReq req)
+ throws Exception {
+ log.info("Inside ModifyCell...");
+
+ try {
+ long startTimemodifyCell = System.currentTimeMillis();
+
+ String nbrsStr = req.getNewNbrs();
+ if (req.getNewNbrs() == null) {
+ nbrsStr = "";
+ }
+ String source = "GUI";
+ List<NeighborDetails> nbrsList = new ArrayList<NeighborDetails>();
+ String[] newNbrsArr = nbrsStr.split(",");
+
+ for (int i = 0; i < newNbrsArr.length; i++) {
+ NeighborDetails cell = new NeighborDetails(new NeihborId(
+ req.getNodeId(), newNbrsArr[i].trim()), false);
+ nbrsList.add(cell);
+ }
+
+ int result = rsPciHdlr.modifyCellFunction(req.getNodeId(),
+ req.getNewPhysicalCellId(), nbrsList, source);
+ log.info("Inside modify cell : " + (startTimemodifyCell));
+ log.info("Result:********************" + result);
+ rsCtrlr.handleModifyPciFromGui(req.getNodeId(),
+ req.getNewPhysicalCellId());
+ long endTimemodifyCell = System.currentTimeMillis();
+ log.info("Time taken to modify cell : "
+ + (endTimemodifyCell - startTimemodifyCell));
+
+ if (result == 200) {
+ return new ResponseEntity<String>(HttpStatus.OK);
+ } else if (result == 400) {
+ return new ResponseEntity<String>(HttpStatus.BAD_REQUEST);
+ } else {
+ return new ResponseEntity<String>(
+ HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+
+ } catch (Exception eu) {
+ log.info("Exception in modifyACell", eu);
+
+ return new ResponseEntity<>(
+ "Cannot update the PCI for the given cell",
+ HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+
+ }
+
+ /**
+ * The function changes the PCI number of the cell for the the mentioned
+ * nodeId.
+ *
+ * @param req
+ * gets the necessary details as a request of class type
+ * GetACellDetailReq
+ * @return returns Http status
+ * @throws Exception
+ * throws exceptions in the functions
+ */
+ @ApiOperation("Changes the pci number of the cell for the the mentioned nodeId")
+ @RequestMapping(value = "/GetACellDetail", method = RequestMethod.POST)
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Successful"),
+ @ApiResponse(code = 500, message = "Cannot retrive the cell details for the given cell") })
+ public ResponseEntity<String> getACellDetail(
+ @RequestBody GetACellDetailReq req) throws Exception {
+ log.info("Inside GetACellDetailReq...");
+ RansimControllerDatabase rsDb = new RansimControllerDatabase();
+ try {
+ String jsonStr = null;
+
+ CellDetails cd = rsDb.getCellDetail(req.getNodeId());
+
+ if (cd != null) {
+ Gson gson = new Gson();
+ jsonStr = gson.toJson(cd);
+ }
+ return new ResponseEntity<>(jsonStr, HttpStatus.OK);
+
+ } catch (Exception eu) {
+ log.info("Exception in modifyACell", eu);
+ return new ResponseEntity<>(
+ "Cannot update the PCI for the given cell",
+ HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+
+ /**
+ * The function deletes a cell with the mentioned nodeId.
+ *
+ * @param req
+ * gets the necessary details as a request of class type
+ * DeleteACellReq
+ * @return returns Http status
+ * @throws Exception
+ * throws exceptions in the functions
+ */
+ @ApiOperation("Deletes a cell with the mentioned nodeId")
+ @RequestMapping(value = "/DeleteACell", method = RequestMethod.POST)
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"),
+ @ApiResponse(code = 500, message = "Cannot delete the given cell") })
+ public ResponseEntity<String> deleteACell(@RequestBody DeleteACellReq req)
+ throws Exception {
+ log.info("Inside delete cell...");
+
+ try {
+ long startTimeDeleteCell = System.currentTimeMillis();
+ String result = rsCtrlr.deleteCellFunction(req.getNodeId());
+ log.info("deleted in database...." + result);
+ long endTimeDeleteCell = System.currentTimeMillis();
+ log.info("Time taken to delete cell : "
+ + (endTimeDeleteCell - startTimeDeleteCell));
+
+ return new ResponseEntity<String>(HttpStatus.OK);
+
+ } catch (Exception eu) {
+ log.info("Exception in deleteACell", eu);
+ return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+
+ /**
+ * The function stops RAN network simulation and deletes all the cell data
+ * from the database.
+ *
+ * @return returns Http status
+ * @throws Exception
+ * throws exceptions in the functions
+ */
+ @ApiOperation("Stops RAN network simulation and deletes all the cell data from the database")
+ @RequestMapping(value = "/StopSimulation", method = RequestMethod.DELETE)
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful"),
+ @ApiResponse(code = 500, message = "Cannot stop simulation") })
+ public ResponseEntity<String> stopSimulation() throws Exception {
+ log.info("Inside stopSimulation...");
+ EntityManagerFactory emfactory = Persistence
+ .createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+
+ Query query = entitymanager.createQuery("from CellDetails cd",
+ CellDetails.class);
+ if (query.getResultList() == null) {
+ return new ResponseEntity<>("No simulation is running.",
+ HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+
+ try {
+ entitymanager.getTransaction().begin();
+ long startTimStopSimulation = System.currentTimeMillis();
+ Query q3 = entitymanager
+ .createQuery("DELETE FROM NetconfServers ns");
+ q3.executeUpdate();
+
+ Query q2 = entitymanager.createQuery("DELETE FROM CellNeighbor cn");
+ q2.executeUpdate();
+
+ Query q4 = entitymanager
+ .createQuery("DELETE FROM NeighborDetails cn");
+ q4.executeUpdate();
+
+ log.info("Stop simulation : " + (startTimStopSimulation));
+ Query q1 = entitymanager.createQuery("DELETE FROM CellDetails cd");
+ q1.executeUpdate();
+
+ String result = rsCtrlr.stopAllCells();
+ log.info("All cell simulation are stopped...." + result);
+
+ entitymanager.flush();
+ entitymanager.getTransaction().commit();
+
+ long endTimStopSimulation = System.currentTimeMillis();
+ log.info("Time taken for stopping simulation : "
+ + (endTimStopSimulation - startTimStopSimulation));
+
+ isSimulationStarted = false;
+ return new ResponseEntity<>("Success", HttpStatus.OK);
+
+ } catch (Exception eu) {
+ log.info("Exception in stopSimulation", eu);
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ return new ResponseEntity<>("Failure",
+ HttpStatus.INTERNAL_SERVER_ERROR);
+ } finally {
+ entitymanager.close();
+ emfactory.close();
+ }
+
+ }
+
+ /**
+ * The function returns the details of a Netconf server for the mentioned
+ * server id.
+ *
+ * @param req
+ * gets the necessary details as a request of class type
+ * GetNetconfServerDetailsReq
+ * @return returns Http status
+ * @throws Exception
+ * throws exceptions in the functions
+ */
+ @ApiOperation("Returns the details of a Netconf server for the mentioned server id")
+ @RequestMapping(value = "/GetNetconfServerDetails", method = RequestMethod.POST)
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Successful"),
+ @ApiResponse(code = 500, message = "Failure in GetNetconfServerDetails API") })
+ public ResponseEntity<String> getNetconfServerDetails(
+ @RequestBody GetNetconfServerDetailsReq req) throws Exception {
+
+ EntityManagerFactory emfactory = Persistence
+ .createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+ try {
+ log.info("Inside GetNetconfServerDetails API...");
+ String result = "";
+ entitymanager.getTransaction().begin();
+ String input = req.getServerId();
+ if (input.startsWith("Chn")) {
+ CellDetails cds = entitymanager.find(CellDetails.class, input);
+ if (cds != null) {
+ Gson gson = new Gson();
+ String jsonStr = gson.toJson(cds);
+ result = "{\"serverId\":\"any\",\"cells\":[" + jsonStr
+ + "]}";
+ } else {
+ result = ("Cell Id does not exist");
+ }
+ } else {
+ NetconfServers ns = entitymanager.find(NetconfServers.class,
+ req.getServerId());
+ if (ns != null) {
+ Gson gson = new Gson();
+ String jsonStr = gson.toJson(ns);
+ result = jsonStr;
+ } else {
+ result = ("Server Id does not exist");
+ }
+ }
+ return new ResponseEntity<>(result, HttpStatus.OK);
+
+ } catch (Exception eu) {
+ log.info("/GetNetconfServers", eu);
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ return new ResponseEntity<>(
+ "Failure in GetNetconfServerDetails API",
+ HttpStatus.INTERNAL_SERVER_ERROR);
+ } finally {
+ entitymanager.close();
+ emfactory.close();
+ }
+ }
+
+ @ApiOperation("Returns the connection status of all netconf servers")
+ @RequestMapping(value = "/GetNetconfStatus", method = RequestMethod.GET)
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Successful"),
+ @ApiResponse(code = 500, message = "Failure in GetNetconfServerDetails API") })
+ public ResponseEntity<String> GetNetconfStatus() throws Exception {
+
+ RansimControllerDatabase rsDb = new RansimControllerDatabase();
+ try {
+ log.info("Inside GetNetconfServerDetails API...");
+ String result = "";
+
+ List<NetconfServers> ns = rsDb.getNetconfServersList();
+ if (ns != null) {
+ GsonBuilder gsonBuilder = new GsonBuilder();
+ gsonBuilder.serializeNulls();
+ Gson gson = gsonBuilder.create();
+ String jsonStr = gson.toJson(ns);
+ result = jsonStr;
+ } else {
+ result = ("Server Id does not exist");
+ }
+
+ return new ResponseEntity<>(result, HttpStatus.OK);
+
+ } catch (Exception eu) {
+ log.info("/GetNetconfServers", eu);
+ return new ResponseEntity<>(
+ "Failure in GetNetconfServerDetails API",
+ HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+
+ /**
+ * The function retrieves RAN simulation network topology.
+ *
+ * @return returns Http status
+ * @throws Exception
+ * throws exceptions in the functions
+ *
+ */
+ @ApiOperation("Retrieves operations log - Modify/Delete operations performed")
+ @RequestMapping(value = "/GetOperationLog", method = RequestMethod.GET)
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Successful"),
+ @ApiResponse(code = 500, message = "Cannot retrieve the Operation Logs") })
+ public ResponseEntity<String> getOperationLog() throws Exception {
+ log.info("Inside getOperationLog...");
+ RansimControllerDatabase rsDb = new RansimControllerDatabase();
+ try {
+ List<OperationLog> ols = rsDb.getOperationLogList();
+ if (ols != null && ols.size() > 0) {
+ Gson gson = new Gson();
+ String jsonStr = gson.toJson(ols);
+ return new ResponseEntity<>(jsonStr, HttpStatus.OK);
+ } else {
+ return new ResponseEntity<>("", HttpStatus.OK);
+ }
+ } catch (Exception eu) {
+ log.info("/GetOperationLog", eu);
+ return new ResponseEntity<>("Failure",
+ HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimPciHandler.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimPciHandler.java
new file mode 100644
index 0000000..e4796e8
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/controller/RansimPciHandler.java
@@ -0,0 +1,1011 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.controller;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.websocket.Session;
+
+import org.apache.log4j.Logger;
+import org.onap.ransim.rest.api.models.CellDetails;
+import org.onap.ransim.rest.api.models.CellNeighbor;
+import org.onap.ransim.rest.api.models.FmAlarmInfo;
+import org.onap.ransim.rest.api.models.GetNeighborList;
+import org.onap.ransim.rest.api.models.NeighborDetails;
+import org.onap.ransim.rest.api.models.NetconfServers;
+import org.onap.ransim.rest.api.models.OperationLog;
+import org.onap.ransim.rest.api.models.PmDataDump;
+import org.onap.ransim.rest.api.models.PmParameters;
+import org.onap.ransim.websocket.model.AdditionalMeasurements;
+import org.onap.ransim.websocket.model.CommonEventHeaderFm;
+import org.onap.ransim.websocket.model.CommonEventHeaderPm;
+import org.onap.ransim.websocket.model.EventFm;
+import org.onap.ransim.websocket.model.EventPm;
+import org.onap.ransim.websocket.model.FaultFields;
+import org.onap.ransim.websocket.model.FmMessage;
+import org.onap.ransim.websocket.model.Measurement;
+import org.onap.ransim.websocket.model.PmMessage;
+import org.onap.ransim.websocket.server.RansimWebSocketServer;
+
+import com.google.gson.Gson;
+
+public class RansimPciHandler {
+
+ private static RansimPciHandler rsPciHandler = null;
+
+ private RansimPciHandler() {
+
+ }
+
+ /**
+ * To accesss variable of this class from another class.
+ *
+ * @return returns rscontroller constructor
+ */
+ public static synchronized RansimPciHandler getRansimPciHandler() {
+ if (rsPciHandler == null) {
+ rsPciHandler = new RansimPciHandler();
+ }
+ return rsPciHandler;
+ }
+
+ static Logger log = Logger.getLogger(RansimPciHandler.class
+ .getName());
+
+ RansimController rsCtrlr = RansimController.getRansimController();
+
+ static Map<String, String> globalFmCellIdUuidMap = new ConcurrentHashMap<String, String>();
+ static Map<String, String> globalPmCellIdUuidMap = new ConcurrentHashMap<String, String>();
+
+ Set<String> cellsWithIssues = new HashSet<>();
+
+ List<PmParameters> pmParameters = new ArrayList<PmParameters>();
+ int next = 0;
+
+ static FmAlarmInfo setCollisionConfusionFromFile(String cellNodeId) {
+
+ FmAlarmInfo result = new FmAlarmInfo();
+ RansimControllerDatabase rsDb = new RansimControllerDatabase();
+
+ try {
+
+ boolean collisionDetected = false;
+ boolean confusionDetected = false;
+ List<Long> nbrPcis = new ArrayList<Long>();
+ List<Long> ConfusionPcis = new ArrayList<Long>();
+ int collisionCount = 0;
+ int confusionCount = 0;
+ CellDetails currentCell = rsDb.getCellDetail(cellNodeId);
+
+ log.info("Setting confusion/collision for Cell :" + cellNodeId);
+
+ GetNeighborList cellNbrDetails = generateNeighborList(cellNodeId);
+
+ for (CellDetails firstLevelNbr : cellNbrDetails.getCellsWithHo()) {
+ if (nbrPcis
+ .contains(new Long(firstLevelNbr.getPhysicalCellId()))) {
+ confusionDetected = true;
+ if (ConfusionPcis.contains(firstLevelNbr
+ .getPhysicalCellId())) {
+ confusionCount++;
+ } else {
+ ConfusionPcis.add(firstLevelNbr.getPhysicalCellId());
+ confusionCount = confusionCount + 2;
+ }
+
+ } else {
+ nbrPcis.add(new Long(firstLevelNbr.getPhysicalCellId()));
+ }
+
+ if (currentCell.getPhysicalCellId() == firstLevelNbr
+ .getPhysicalCellId()) {
+ collisionDetected = true;
+ collisionCount++;
+ }
+ }
+
+ currentCell.setPciCollisionDetected(collisionDetected);
+ currentCell.setPciConfusionDetected(confusionDetected);
+
+ if (!currentCell.isPciCollisionDetected()
+ && !currentCell.isPciConfusionDetected()) {
+ currentCell.setColor("#BFBFBF"); // GREY - No Issues
+ result.setProblem("No Issues");
+ } else if (currentCell.isPciCollisionDetected()
+ && currentCell.isPciConfusionDetected()) {
+ currentCell.setColor("#C30000"); // BROWN - Cell has both
+ // collision & confusion
+ result.setProblem("CollisionAndConfusion");
+
+ } else if (currentCell.isPciCollisionDetected()) {
+ currentCell.setColor("#FF0000"); // RED - Cell has collision
+ result.setProblem("Collision");
+
+ } else if (currentCell.isPciConfusionDetected()) {
+ currentCell.setColor("#E88B00"); // ORANGE - Cell has confusion
+ result.setProblem("Confusion");
+
+ } else {
+ currentCell.setColor("#BFBFBF"); // GREY - No Issues
+ result.setProblem("No Issues");
+ }
+
+ result.setCollisionCount("" + collisionCount);
+ result.setConfusionCount("" + confusionCount);
+
+ rsDb.mergeCellDetails(currentCell);
+
+ return result;
+
+ } catch (Exception e2) {
+ log.info("setCollisionConfusionFromFile :", e2);
+
+ return null;
+ }
+
+ }
+
+ /**
+ * Generates separate list of neighbors with and without hand-off for a
+ * cell.
+ *
+ * @param nodeId
+ * Node Id of cell for which the neighbor list is generated
+ * @return Returns GetNeighborList object
+ */
+ static GetNeighborList generateNeighborList(String nodeId) {
+
+ EntityManagerFactory emfactory = Persistence
+ .createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+ try {
+ log.info("inside generateNeighborList for: " + nodeId);
+ RansimControllerDatabase rsDb = new RansimControllerDatabase();
+ CellNeighbor neighborList = entitymanager.find(CellNeighbor.class,
+ nodeId);
+ GetNeighborList result = new GetNeighborList();
+
+ List<CellDetails> cellsWithNoHO = new ArrayList<CellDetails>();
+ List<CellDetails> cellsWithHO = new ArrayList<CellDetails>();
+
+ List<NeighborDetails> nbrList = new ArrayList<NeighborDetails>(
+ neighborList.getNeighborList());
+ long readCellDetail = 0;
+ long checkBlacklisted = 0;
+
+ for (int i = 0; i < nbrList.size(); i++) {
+
+ CellDetails nbr = entitymanager.find(CellDetails.class, nbrList
+ .get(i).getNeigbor().getNeighborCell());
+
+ if (nbrList.get(i).isBlacklisted()) {
+ cellsWithNoHO.add(nbr);
+ } else {
+ cellsWithHO.add(nbr);
+ }
+
+ }
+
+ result.setNodeId(nodeId);
+ result.setCellsWithHo(cellsWithHO);
+ result.setCellsWithNoHo(cellsWithNoHO);
+
+ return result;
+
+ } catch (Exception eu) {
+ log.info("/getNeighborList", eu);
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ return null;
+ } finally {
+ entitymanager.close();
+ emfactory.close();
+ }
+ }
+
+ static void checkCollisionAfterModify() {
+ RansimControllerDatabase rsDb = new RansimControllerDatabase();
+ try {
+ List<CellDetails> checkCollisionConfusion = rsDb
+ .getCellsWithCollisionOrConfusion();
+
+ for (int i = 0; i < checkCollisionConfusion.size(); i++) {
+ log.info(checkCollisionConfusion.get(i).getNodeId());
+ setCollisionConfusionFromFile(checkCollisionConfusion.get(i)
+ .getNodeId());
+ }
+ } catch (Exception eu) {
+ log.info("checkCollisionAfterModify", eu);
+ }
+ }
+
+ /**
+ * It updates the cell with its new neighbor list and PCI and updates the
+ * change in a database.
+ *
+ * @param nodeId
+ * node Id of the cell
+ * @param physicalCellId
+ * PCI number of the cell
+ * @param newNbrs
+ * List of new neighbors for the cell
+ * @param source
+ * The source from which cell modification has been triggered
+ * @return returns success or failure message
+ */
+ public int modifyCellFunction(String nodeId, long physicalCellId,
+ List<NeighborDetails> newNbrs, String source) {
+
+ int result = 111;
+
+ RansimControllerDatabase rsDb = new RansimControllerDatabase();
+ log.info("modifyCellFunction nodeId:" + nodeId + ", physicalCellId:"
+ + physicalCellId);
+ CellDetails modifyCell = rsDb.getCellDetail(nodeId);
+
+ if (modifyCell != null) {
+ if (physicalCellId < 0
+ || physicalCellId > rsCtrlr.maxPciValueAllowed) {
+ log.info("NewPhysicalCellId is empty or invalid");
+ result = 400;
+ } else {
+ long oldPciId = modifyCell.getPhysicalCellId();
+ if (physicalCellId != oldPciId) {
+ updatePciOperationsTable(nodeId, source, physicalCellId,
+ oldPciId);
+
+ modifyCell.setPhysicalCellId(physicalCellId);
+ rsDb.mergeCellDetails(modifyCell);
+ }
+
+ CellNeighbor neighbors = rsDb.getCellNeighbor(nodeId);
+ List<NeighborDetails> oldNbrList = new ArrayList<NeighborDetails>(
+ neighbors.getNeighborList());
+ List<NeighborDetails> oldNbrListWithHo = new ArrayList<NeighborDetails>();
+
+ for (NeighborDetails cell : oldNbrList) {
+ if (!cell.isBlacklisted()) {
+ oldNbrListWithHo.add(cell);
+ }
+ }
+
+ boolean flag = false;
+
+ List<NeighborDetails> addedNbrs = new ArrayList<NeighborDetails>();
+ List<NeighborDetails> deletedNbrs = new ArrayList<NeighborDetails>();
+
+ String nbrsDel = "";
+
+ List<String> oldNbrsArr = new ArrayList<String>();
+ for (NeighborDetails cell : oldNbrListWithHo) {
+ oldNbrsArr.add(cell.getNeigbor().getNeighborCell());
+ }
+
+ List<String> newNbrsArr = new ArrayList<String>();
+ for (NeighborDetails cell : newNbrs) {
+ newNbrsArr.add(cell.getNeigbor().getNeighborCell());
+ }
+
+ for (NeighborDetails cell : oldNbrListWithHo) {
+
+ if (!newNbrsArr.contains(cell.getNeigbor()
+ .getNeighborCell())) {
+ if (!flag) {
+ flag = true;
+ }
+ deletedNbrs.add(cell);
+ if (nbrsDel == "") {
+ nbrsDel = cell.getNeigbor().getNeighborCell();
+ } else {
+ nbrsDel += ","
+ + cell.getNeigbor().getNeighborCell();
+ }
+ log.info("deleted cell: "
+ + cell.getNeigbor().getNeighborCell()
+ + cell.isBlacklisted());
+
+ }
+ }
+
+ String nbrsAdd = "";
+
+ for (NeighborDetails cell : newNbrs) {
+ if (cell.isBlacklisted()) {
+ addedNbrs.add(cell);
+ } else {
+ if (!oldNbrsArr.contains(cell.getNeigbor()
+ .getNeighborCell())) {
+ addedNbrs.add(cell);
+ if (nbrsAdd == "") {
+ nbrsAdd = cell.getNeigbor().getNeighborCell();
+ } else {
+ nbrsAdd += ","
+ + cell.getNeigbor().getNeighborCell();
+ }
+ log.info("added cell: "
+ + cell.getNeigbor().getNeighborCell()
+ + cell.isBlacklisted());
+ }
+ }
+
+ }
+ List<NeighborDetails> newNeighborList = new ArrayList<NeighborDetails>(
+ oldNbrList);
+ for (NeighborDetails cell : deletedNbrs) {
+ NeighborDetails removeHo = new NeighborDetails(
+ cell.getNeigbor(), true);
+ rsDb.mergeNeighborDetails(removeHo);
+ newNeighborList.add(removeHo);
+ }
+
+ for (NeighborDetails cell : addedNbrs) {
+ rsDb.mergeNeighborDetails(cell);
+ newNeighborList.add(cell);
+ }
+
+ if (!flag) {
+ if (newNbrs.size() != oldNbrList.size()) {
+ flag = true;
+ }
+ }
+
+ if (flag) {
+ updateNbrsOperationsTable(nodeId, source, nbrsAdd, nbrsDel);
+ }
+
+ if (newNbrs != null) {
+ neighbors.getNeighborList().clear();
+ Set<NeighborDetails> updatedNbrList = new HashSet<NeighborDetails>(
+ newNeighborList);
+ neighbors.setNeighborList(updatedNbrList);
+ rsDb.mergeCellNeighbor(neighbors);
+ }
+
+ generateFmData(source, modifyCell, newNeighborList);
+
+ result = 200;
+ }
+
+
+ } else {
+ result = 400;
+ }
+
+ return result;
+ }
+
+ public void checkCellsWithIssue() {
+
+ EntityManagerFactory emfactory = Persistence
+ .createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+ try {
+
+ for (String id : cellsWithIssues) {
+ CellDetails currentCell = entitymanager.find(CellDetails.class,
+ id);
+ FmMessage fmDataMessage = new FmMessage();
+ List<EventFm> data = new ArrayList<EventFm>();
+
+ if (!currentCell.isPciCollisionDetected()) {
+ if (!currentCell.isPciConfusionDetected()) {
+
+ cellsWithIssues.remove(id);
+ CommonEventHeaderFm commonEventHeader = new CommonEventHeaderFm();
+ FaultFields faultFields = new FaultFields();
+
+ commonEventHeader.setStartEpochMicrosec(System
+ .currentTimeMillis() * 1000);
+ commonEventHeader
+ .setSourceName(currentCell.getNodeId());
+ commonEventHeader.setReportingEntityName(currentCell
+ .getServerId());
+ String uuid = globalFmCellIdUuidMap.get(currentCell
+ .getNodeId());
+ commonEventHeader.setSourceUuid(uuid);
+
+ faultFields
+ .setAlarmCondition("RanPciCollisionConfusionOccurred");
+ faultFields.setEventSeverity("NORMAL");
+ faultFields.setEventSourceType("other");
+ faultFields.setSpecificProblem("Problem Solved");
+
+ commonEventHeader.setLastEpochMicrosec(System
+ .currentTimeMillis() * 1000);
+
+ EventFm event = new EventFm();
+ event.setCommonEventHeader(commonEventHeader);
+ event.setFaultFields(faultFields);
+
+ data.add(event);
+ }
+ }
+
+ fmDataMessage.setFmEventList(data);
+
+ if (!data.isEmpty()) {
+ sendFmData(currentCell.getServerId(), fmDataMessage);
+ }
+
+ }
+
+ } catch (Exception eu) {
+ if (entitymanager.getTransaction().isActive()) {
+ entitymanager.getTransaction().rollback();
+ }
+ log.info("Exception:", eu);
+ } finally {
+ entitymanager.close();
+ emfactory.close();
+ }
+
+ }
+
+ void updatePciOperationsTable(String nodeId, String source, long physicalCellId, long oldPciId) {
+ EntityManagerFactory emfactory = Persistence.createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+ OperationLog operationLog = new OperationLog();
+
+ entitymanager.getTransaction().begin();
+ operationLog.setNodeId(nodeId);
+ operationLog.setFieldName("PCID");
+ operationLog.setOperation("Modify");
+ operationLog.setSource(source);
+ operationLog.setTime(System.currentTimeMillis());
+ operationLog.setMessage("PCID value changed from " + oldPciId + " to " + physicalCellId);
+ entitymanager.merge(operationLog);
+ entitymanager.flush();
+ entitymanager.getTransaction().commit();
+ }
+
+ void updateNbrsOperationsTable(String nodeId, String source, String addedNbrs, String deletedNbrs) {
+
+ EntityManagerFactory emfactory = Persistence.createEntityManagerFactory("ransimctrlrdb");
+ EntityManager entitymanager = emfactory.createEntityManager();
+ entitymanager.getTransaction().begin();
+ OperationLog operationLogNbrChng = new OperationLog();
+ operationLogNbrChng.setNodeId(nodeId);
+ operationLogNbrChng.setFieldName("Neighbors");
+ operationLogNbrChng.setOperation("Modify");
+ operationLogNbrChng.setSource(source);
+
+ log.info(" Neighbors added " + addedNbrs + ".");
+ log.info(" Neighbors removed " + deletedNbrs + ".");
+ String message = "";
+ if(!addedNbrs.equals("")){
+ message += " Neighbors added " + addedNbrs + "." ;
+ }
+
+ if(!deletedNbrs.equals("")){
+ message += " Neighbors removed " + deletedNbrs + "." ;
+ }
+
+ operationLogNbrChng.setMessage(message);
+ operationLogNbrChng.setTime(System.currentTimeMillis());
+ entitymanager.merge(operationLogNbrChng);
+ entitymanager.flush();
+ entitymanager.getTransaction().commit();
+
+ }
+
+ /**
+ * Sends PM message to the netconf agent through the websocket server.
+ *
+ * @param serverId
+ * Netconf agent - Server ID to which the message is sent.
+ * @param pmMessage
+ * PM message to be sent.
+ */
+ void sendPmdata(String serverId, String pmMessage) {
+
+ log.info("Sending PM message to netconf agent");
+
+ String ipPort = rsCtrlr.serverIdIpPortMapping.get(serverId);
+
+ if (ipPort != null && !ipPort.trim().equals("")) {
+
+ String[] ipPortArr = ipPort.split(":");
+ if (ipPort != null && !ipPort.trim().equals("")) {
+
+ Session clSess = rsCtrlr.webSocketSessions.get(ipPort);
+ log.info("PM message. Netconf agent IP:" + ipPort);
+ if (clSess != null) {
+ RansimWebSocketServer.sendPmMessage(pmMessage, clSess);
+ log.info("Pm Data jsonStr: " + pmMessage);
+ log.info("PM message sent to netconf agent");
+ } else {
+ log.info("No client session for " + ipPort);
+ }
+ } else {
+ log.info("Pm message not sent, ipPort is null");
+ }
+ } else {
+
+ log.info("Pm message not sent, ipPort is null. Server Id: "
+ + serverId);
+ }
+
+ }
+
+ /**
+ *
+ * Reads the values PM parameter values from a dump file.
+ *
+ */
+ public void readPmParameters() {
+
+ File dumpFile = null;
+ String kpiName = "";
+ PmDataDump pmDump = null;
+ String jsonString = "";
+ int next = 0;
+ dumpFile = new File("PM_Kpi_Data.json");
+
+ BufferedReader br = null;
+
+ try {
+ log.info("Reading dump file");
+ br = new BufferedReader(new FileReader(dumpFile));
+
+ StringBuilder sb = new StringBuilder();
+ String line = br.readLine();
+
+ while (line != null) {
+ sb.append(line);
+ sb.append("\n");
+ line = br.readLine();
+ }
+ jsonString = sb.toString();
+
+ pmDump = new Gson().fromJson(jsonString, PmDataDump.class);
+ log.info("Dump value: "
+ + pmDump.getKpiDump().get(0).getParameter1());
+ pmParameters = new ArrayList<PmParameters>(pmDump.getKpiDump());
+
+ } catch (Exception eu) {
+ log.info("Exception: ", eu);
+ }
+ }
+
+ private static String getUuid() {
+ return UUID.randomUUID().toString();
+ }
+
+ /**
+ * Sets values for all the parameters in the PM message
+ *
+ * @param nodeIdBad
+ * List of node Ids with bad performance values
+ * @param nodeIdPoor
+ * List of node Ids with poor performance values
+ * @return It returns the pm message
+ */
+ public List<String> generatePmData(String nodeIdBad, String nodeIdPoor) {
+
+ List<String> result = new ArrayList<>();
+ RansimControllerDatabase rcDb = new RansimControllerDatabase();
+
+ String parameter1 = "";
+ String successValue1 = "";
+ String badValue1 = "";
+ String poorValue1 = "";
+ String parameter2 = "";
+ String successValue2 = "";
+ String badValue2 = "";
+ String poorValue2 = "";
+
+ try {
+
+ if (next >= pmParameters.size()) {
+ next = 0;
+ log.info("next : " + next);
+ }
+ try {
+ log.info("next : " + next);
+ parameter1 = pmParameters.get(next).getParameter1();
+ successValue1 = pmParameters.get(next).getSuccessValue1();
+ badValue1 = pmParameters.get(next).getBadValue1();
+ poorValue1 = pmParameters.get(next).getPoorValue1();
+ parameter2 = pmParameters.get(next).getParameter2();
+ successValue2 = pmParameters.get(next).getSuccessValue2();
+ badValue2 = pmParameters.get(next).getBadValue2();
+ poorValue2 = pmParameters.get(next).getPoorValue2();
+ next++;
+ } catch (Exception e) {
+ log.info("Exception: ", e);
+ }
+
+ List<NetconfServers> cnl = rcDb.getNetconfServersList();
+ log.info("obtained data from db");
+ String[] cellIdsBad = null;
+ String[] cellIdsPoor = null;
+ Set<String> nodeIdsBad = new HashSet<String>();
+ Set<String> nodeIdsPoor = new HashSet<String>();
+
+ if (nodeIdBad != null) {
+ cellIdsBad = nodeIdBad.split(",");
+ for (int a = 0; a < cellIdsBad.length; a++) {
+ nodeIdsBad.add(cellIdsBad[a].trim());
+ }
+ }
+ if (nodeIdPoor != null) {
+ cellIdsPoor = nodeIdPoor.split(",");
+ for (int a = 0; a < cellIdsPoor.length; a++) {
+ nodeIdsPoor.add(cellIdsPoor[a].trim());
+ }
+ }
+
+ for (int i = 0; i < cnl.size(); i++) {
+
+ long startTime = System.currentTimeMillis();
+ List<CellDetails> cellList = new ArrayList<CellDetails>(cnl
+ .get(i).getCells());
+ List<EventPm> data = new ArrayList<EventPm>();
+
+ for (int j = 0; j < cellList.size(); j++) {
+
+ long startTimeCell = System.currentTimeMillis();
+ String nodeId = cellList.get(j).getNodeId();
+ EventPm event = new EventPm();
+ CommonEventHeaderPm commonEventHeader = new CommonEventHeaderPm();
+ commonEventHeader.setSourceName(nodeId);
+ commonEventHeader.setStartEpochMicrosec(System
+ .currentTimeMillis() * 1000);
+ String uuid = globalPmCellIdUuidMap.get(nodeId);
+ if (uuid == null) {
+ uuid = getUuid();
+ globalPmCellIdUuidMap.put(nodeId, uuid);
+ }
+ commonEventHeader.setSourceUuid(uuid);
+
+ Measurement measurement = new Measurement();
+ measurement.setMeasurementInterval(180);
+
+ GetNeighborList cellNbrList = generateNeighborList(nodeId);
+
+ long startTimeCheckBadPoor = System.currentTimeMillis();
+
+ boolean checkBad = false;
+ boolean checkPoor = false;
+ int countBad = 0;
+ int countPoor = 0;
+
+ if (nodeIdsBad.contains(nodeId)) {
+ checkBad = true;
+ countBad = (int) (cellNbrList.getCellsWithHo().size() * 0.2);
+ }
+ if (nodeIdsPoor.contains(nodeId)) {
+ checkPoor = true;
+ countPoor = (int) (cellNbrList.getCellsWithHo().size() * 0.2);
+ }
+
+ long endTimeCheckBadPoor = System.currentTimeMillis();
+
+ List<AdditionalMeasurements> additionalMeasurements = new ArrayList<AdditionalMeasurements>();
+ if (checkPoor || checkBad) {
+
+ Collections.sort(cellNbrList.getCellsWithHo());
+
+ for (int k = 0; k < cellNbrList.getCellsWithHo().size(); k++) {
+ AdditionalMeasurements addMsmnt = new AdditionalMeasurements();
+ addMsmnt.setName(cellNbrList.getCellsWithHo()
+ .get(k).getNodeId());
+ Map<String, String> hashMap = new HashMap<String, String>();
+ hashMap.put("networkId", cellNbrList
+ .getCellsWithHo().get(k).getNetworkId());
+
+ hashMap.put(parameter1, successValue1);
+
+ if (checkBad == true) {
+
+ if (countBad > 0) {
+ log.info("countBad: " + countBad);
+ hashMap.put(parameter2, badValue2);
+ countBad--;
+ } else {
+ hashMap.put(parameter2, successValue2);
+ }
+
+ } else if (checkPoor == true) {
+ if (countPoor > 0) {
+ log.info("countBad: " + countPoor);
+ hashMap.put(parameter2, poorValue2);
+ countPoor--;
+ } else {
+ hashMap.put(parameter2, successValue2);
+ }
+
+ }
+
+ addMsmnt.setHashMap(hashMap);
+
+ additionalMeasurements.add(addMsmnt);
+
+ }
+ } else {
+ for (int k = 0; k < cellNbrList.getCellsWithHo().size(); k++) {
+ AdditionalMeasurements addMsmnt = new AdditionalMeasurements();
+ addMsmnt.setName(cellNbrList.getCellsWithHo()
+ .get(k).getNodeId());
+ Map<String, String> hashMap = new HashMap<String, String>();
+
+ hashMap.put("networkId", cellNbrList
+ .getCellsWithHo().get(k).getNetworkId());
+
+ hashMap.put(parameter1, successValue1);
+
+ hashMap.put(parameter2, successValue2);
+
+ addMsmnt.setHashMap(hashMap);
+ additionalMeasurements.add(addMsmnt);
+ }
+ }
+
+ commonEventHeader.setLastEpochMicrosec(System
+ .currentTimeMillis() * 1000);
+ measurement
+ .setAdditionalMeasurements(additionalMeasurements);
+
+ event.setCommonEventHeader(commonEventHeader);
+ event.setMeasurement(measurement);
+
+ data.add(event);
+ long endTimeCell = System.currentTimeMillis();
+ }
+
+ long endTime = System.currentTimeMillis();
+ log.info("Time taken for generating PM data for "
+ + cnl.get(i).getServerId() + " : "
+ + (endTime - startTime));
+ PmMessage msg = new PmMessage();
+
+ if (data.size() > 0) {
+ msg.setEventPmList(data);
+ Gson gson = new Gson();
+ String jsonStr = gson.toJson(msg);
+ sendPmdata(cnl.get(i).getServerId(), jsonStr);
+
+ result.add(jsonStr);
+ }
+
+ }
+ } catch (Exception e) {
+ log.info("Exception in string builder", e);
+ }
+
+ return result;
+ }
+
+ /**
+ * Sets the value for all fields in the FM data for individual cell.
+ *
+ * @param networkId
+ * Network Id of the cell
+ * @param ncServer
+ * Server Id of the cell
+ * @param cellId
+ * Node Id of the cell
+ * @param issue
+ * Contains the collision/confusion details of the cess
+ * @return returns EventFm object, with all the necessary parameters.
+ */
+ public static EventFm setEventFm(String networkId, String ncServer,
+ String cellId, FmAlarmInfo issue) {
+
+ log.info("Inside generate FmData");
+ EventFm event = new EventFm();
+
+ try {
+
+ CommonEventHeaderFm commonEventHeader = new CommonEventHeaderFm();
+ FaultFields faultFields = new FaultFields();
+
+ commonEventHeader
+ .setStartEpochMicrosec(System.currentTimeMillis() * 1000);
+ commonEventHeader.setSourceName(cellId);
+ commonEventHeader.setReportingEntityName(ncServer);
+
+ String uuid = globalFmCellIdUuidMap.get(cellId);
+ if (uuid == null) {
+ uuid = getUuid();
+ globalFmCellIdUuidMap.put(cellId, uuid);
+ }
+ commonEventHeader.setSourceUuid(uuid);
+
+ if (issue.getProblem().equals("Collision")
+ || issue.getProblem().equals("Confusion")
+ || issue.getProblem().equals("CollisionAndConfusion")) {
+ faultFields
+ .setAlarmCondition("RanPciCollisionConfusionOccurred");
+ faultFields.setEventSeverity("CRITICAL");
+ faultFields.setEventSourceType("other");
+ faultFields.setSpecificProblem(issue.getProblem());
+
+ Map<String, String> alarmAdditionalInformation = new HashMap<String, String>();
+ alarmAdditionalInformation.put("networkId", networkId);
+ alarmAdditionalInformation.put("collisions",
+ issue.getCollisionCount());
+ alarmAdditionalInformation.put("confusions",
+ issue.getConfusionCount());
+
+ faultFields
+ .setAlarmAdditionalInformation(alarmAdditionalInformation);
+
+ }
+ commonEventHeader
+ .setLastEpochMicrosec(System.currentTimeMillis() * 1000);
+
+ event.setCommonEventHeader(commonEventHeader);
+ event.setFaultFields(faultFields);
+
+ } catch (Exception e) {
+ log.info("Exception: ", e);
+ }
+
+ return event;
+
+ }
+
+ /**
+ * It checks if the cell or any of its neighbors have collision/confusion
+ * issue. If there are any issues it generates the FM data for the entire
+ * cluster
+ *
+ * @param source
+ * The source from which the cell modification has been
+ * triggered.
+ * @param cell
+ * Details of the given cell.
+ * @param newNeighborList
+ * Neighbor list of the given cell.
+ */
+ public void generateFmData(String source, CellDetails cell,
+ List<NeighborDetails> newNeighborList) {
+
+ List<EventFm> listCellIssue = new ArrayList<EventFm>();
+ Set<String> ncs = new HashSet<>();
+ log.info("Generating Fm data");
+
+ RansimControllerDatabase rsDb = new RansimControllerDatabase();
+
+ FmAlarmInfo op1 = setCollisionConfusionFromFile(cell.getNodeId());
+
+ if (source.equals("GUI")) {
+ if (op1.getProblem().equals("CollisionAndConfusion")
+ || op1.getProblem().equals("Collision")
+ || op1.getProblem().equals("Confusion")) {
+ log.info("op1: " + op1);
+ EventFm lci = setEventFm(cell.getNetworkId(),
+ cell.getServerId(), cell.getNodeId(), op1);
+ listCellIssue.add(lci);
+ ncs.add(cell.getServerId());
+ log.info("Generating Fm data for: " + cell.getNodeId());
+ }
+ }
+
+ for (NeighborDetails cd : newNeighborList) {
+ FmAlarmInfo op2 = setCollisionConfusionFromFile(cd.getNeigbor()
+ .getNeighborCell());
+ CellDetails nbrCell = rsDb.getCellDetail(cd.getNeigbor()
+ .getNeighborCell());
+
+ if (source.equals("GUI")) {
+ if (op2.getProblem().equals("CollisionAndConfusion")
+ || op2.getProblem().equals("Collision")
+ || op2.getProblem().equals("Confusion")) {
+ EventFm lci = setEventFm(nbrCell.getNetworkId(),
+ nbrCell.getServerId(), nbrCell.getNodeId(), op2);
+ log.info("FmData added:" + nbrCell.getNodeId());
+ listCellIssue.add(lci);
+ ncs.add(nbrCell.getServerId());
+ log.info("Generating Fm data for: " + nbrCell.getNodeId());
+ }
+ }
+
+ }
+
+ if (source.equals("GUI")) {
+ for (String nc : ncs) {
+
+ FmMessage fmDataMessage = new FmMessage();
+ List<EventFm> data = new ArrayList<EventFm>();
+ log.info("listCellIssue.size(): " + listCellIssue.size());
+ for (EventFm cellIssue : listCellIssue) {
+ if (cellIssue.getCommonEventHeader()
+ .getReportingEntityName().equals(nc)) {
+ data.add(cellIssue);
+ if (!cellsWithIssues.contains(cellIssue
+ .getCommonEventHeader().getSourceName())) {
+ cellsWithIssues.add(cellIssue
+ .getCommonEventHeader().getSourceName());
+ }
+
+ }
+ }
+ log.info("data.size(): " + data.size());
+
+ if (data.size() > 0) {
+ fmDataMessage.setFmEventList(data);
+ log.info("Sending FM message: ");
+ sendFmData(nc, fmDataMessage);
+ }
+
+ }
+ }
+
+ }
+
+ /**
+ * Sends the FM data message to the netconf agent through the ransim
+ * websocket server.
+ *
+ * @param serverId
+ * server id of the netconf agent
+ * @param fmDataMessage
+ * FM message to be sent
+ */
+ public void sendFmData(String serverId, FmMessage fmDataMessage) {
+
+ log.info("inside sendFmData");
+ Gson gson = new Gson();
+ String jsonStr = gson.toJson(fmDataMessage);
+
+ log.info("Fm Data jsonStr: " + jsonStr);
+
+ String ipPort = rsCtrlr.serverIdIpPortMapping.get(serverId);
+
+ if (ipPort != null && !ipPort.trim().equals("")) {
+
+ String[] ipPortArr = ipPort.split(":");
+ log.info("Connection estabilished with ip: " + ipPort);
+ if (ipPort != null && !ipPort.trim().equals("")) {
+ Session clSess = rsCtrlr.webSocketSessions.get(ipPort);
+ if (clSess != null) {
+ log.info("FM message sent.");
+ RansimWebSocketServer.sendFmMessage(jsonStr, clSess);
+ } else {
+ log.info("No client session for " + ipPort);
+ }
+ } else {
+ log.info("No client for " + serverId);
+ }
+ } else {
+ log.info("No client for ");
+ }
+
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellData.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellData.java
new file mode 100644
index 0000000..3d9a70c
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellData.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+import java.util.List;
+
+public class CellData {
+
+ private CellInfo Cell;
+ private List<NbrDump> neighbor;
+
+ public CellData() {
+ super();
+ }
+
+ /**
+ * Constructor with all parameters
+ *
+ * @param cell
+ * Contains cell details.
+ * @param neighbor
+ * Contains list of neighbor details.
+ */
+ public CellData(CellInfo cell, List<NbrDump> neighbor) {
+ super();
+ Cell = cell;
+ this.neighbor = neighbor;
+ }
+
+ public CellInfo getCell() {
+ return Cell;
+ }
+
+ public void setCell(CellInfo cell) {
+ Cell = cell;
+ }
+
+ public List<NbrDump> getNeighbor() {
+ return neighbor;
+ }
+
+ public void setNeighbor(List<NbrDump> neighbor) {
+ this.neighbor = neighbor;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellDetails.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellDetails.java
new file mode 100644
index 0000000..697744c
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellDetails.java
@@ -0,0 +1,273 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "CellDetails")
+public class CellDetails implements Comparable<CellDetails>{
+
+ private String networkId;
+ private String nodeId;
+ private long physicalCellId;
+ private String nodeName;
+ private String nodeType;
+ private boolean pciCollisionDetected;
+ private boolean pciConfusionDetected;
+ private float gridX;
+ private float gridY;
+ private float screenX;
+ private float screenY;
+ private String latitude;
+ private String longitude;
+ private String serverId;
+ private int sectorNumber = 0;
+ private String color;
+
+ /**
+ * Constructor with cell Id, pci and server Id for test cases.
+ *
+ * @param nodeId
+ * Node Id of Cell
+ * @param physicalCellId
+ * Pci value of the cell.
+ * @param serverId
+ * Server Id of the cell.
+ */
+ public CellDetails(String nodeId, long physicalCellId, String serverId) {
+ super();
+ this.nodeId = nodeId;
+ this.physicalCellId = physicalCellId;
+ this.serverId = serverId;
+ }
+
+ /**
+ * A constructor for CellDetails( Database to store cell details).
+ *
+ * @param networkId
+ * network Id of the cell
+ * @param nodeId
+ * node Id of the cell
+ * @param physicalCellId
+ * PCI number of the cell
+ * @param nodeName
+ * node name
+ * @param nodeType
+ * node type based on the cluster
+ * @param pciCollisionDetected
+ * Checks if the cell has collision
+ * @param pciConfusionDetected
+ * Checks if the cell has confusion
+ *
+ * @param gridX
+ * --
+ * @param gridY
+ * --
+ * @param screenX
+ * x coordinate of the cell in the GUI
+ * @param screenY
+ * y coordinate of the cell in the GUI
+ * @param latitude
+ * latitude of the cell node
+ * @param longitude
+ * longitude of the cell node
+ * @param serverId
+ * server Id of the netconf server it belongs to
+ * @param sectorNumber
+ * sector number of the cell
+ * @param color
+ * color of the cell in the GUI
+ */
+ public CellDetails(String networkId, String nodeId, long physicalCellId, String nodeName,
+ String nodeType, boolean pciCollisionDetected, boolean pciConfusionDetected,
+ float gridX, float gridY, float screenX, float screenY, String latitude,
+ String longitude, String serverId, int sectorNumber, String color) {
+ super();
+ this.networkId = networkId;
+ this.nodeId = nodeId;
+ this.physicalCellId = physicalCellId;
+ this.nodeName = nodeName;
+ this.nodeType = nodeType;
+ this.pciCollisionDetected = pciCollisionDetected;
+ this.pciConfusionDetected = pciConfusionDetected;
+
+ this.gridX = gridX;
+ this.gridY = gridY;
+ this.screenX = screenX;
+ this.screenY = screenY;
+ this.latitude = latitude;
+ this.longitude = longitude;
+ this.serverId = serverId;
+ this.sectorNumber = sectorNumber;
+ this.color = color;
+ }
+
+ public CellDetails() {
+ super();
+ }
+
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ public void setNetworkId(String networkId) {
+ this.networkId = networkId;
+ }
+
+ @Id
+ @Column(name = "nodeId", unique = true, nullable = false, length = 50)
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ public long getPhysicalCellId() {
+ return physicalCellId;
+ }
+
+ public void setPhysicalCellId(long physicalCellId) {
+ this.physicalCellId = physicalCellId;
+ }
+
+ public String getNodeName() {
+ return nodeName;
+ }
+
+ public void setNodeName(String nodeName) {
+ this.nodeName = nodeName;
+ }
+
+ public String getNodeType() {
+ return nodeType;
+ }
+
+ public void setNodeType(String nodeType) {
+ this.nodeType = nodeType;
+ }
+
+ public boolean isPciCollisionDetected() {
+ return pciCollisionDetected;
+ }
+
+ public void setPciCollisionDetected(boolean pciCollisionDetected) {
+ this.pciCollisionDetected = pciCollisionDetected;
+ }
+
+ public boolean isPciConfusionDetected() {
+ return pciConfusionDetected;
+ }
+
+ public void setPciConfusionDetected(boolean pciConfusionDetected) {
+ this.pciConfusionDetected = pciConfusionDetected;
+ }
+
+ public float getGridX() {
+ return gridX;
+ }
+
+ public void setGridX(float gridX) {
+ this.gridX = gridX;
+ }
+
+ public float getGridY() {
+ return gridY;
+ }
+
+ public void setGridY(float gridY) {
+ this.gridY = gridY;
+ }
+
+ public float getScreenX() {
+ return screenX;
+ }
+
+ public void setScreenX(float screenX) {
+ this.screenX = screenX;
+ }
+
+ public float getScreenY() {
+ return screenY;
+ }
+
+ public void setScreenY(float screenY) {
+ this.screenY = screenY;
+ }
+
+ public String getServerId() {
+ return serverId;
+ }
+
+ public void setServerId(String serverId) {
+ this.serverId = serverId;
+ }
+
+ public int getSectorNumber() {
+ return sectorNumber;
+ }
+
+ public void setSectorNumber(int sectorNumber) {
+ this.sectorNumber = sectorNumber;
+ }
+
+ public String getColor() {
+ return color;
+ }
+
+ public void setColor(String color) {
+ this.color = color;
+ }
+
+ public String getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(String latitude) {
+ this.latitude = latitude;
+ }
+
+ public String getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(String longitude) {
+ this.longitude = longitude;
+ }
+
+ @Override
+ public String toString() {
+ return "Cell Details [networkId=" + networkId + ", nodeId=" + nodeId + ", physicalCellId="
+ + physicalCellId + ", nodeName=" + nodeName + ", nodeType=" + nodeType
+ + ", pciCollisionDetected=" + pciCollisionDetected + ", pciConfusionDetected="
+ + pciConfusionDetected + "]";
+ }
+
+ @Override
+ public int compareTo(CellDetails cd) {
+ return this.getNodeId().compareTo(cd.getNodeId());
+ }
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellInfo.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellInfo.java
new file mode 100644
index 0000000..e9dbbe0
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellInfo.java
@@ -0,0 +1,123 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+public class CellInfo {
+
+ private String networkId;
+ private String nodeId;
+ private long physicalCellId;
+ private String pnfName;
+ private int sectorNumber;
+ private String latitude;
+ private String longitude;
+
+ /**
+ * A constructor for CellInfo.
+ *
+ * @param networkId
+ * network Id of the cell
+ * @param nodeId
+ * node Id of the cell
+ * @param physicalCellId
+ * PCI number of the cell
+ * @param pnfName
+ * netconf server id
+ * @param sectorNumber
+ * sector number for the cell
+ * @param latitude
+ * latitude of the node
+ * @param longitude
+ * longitude of the node
+ */
+ public CellInfo(String networkId, String nodeId, long physicalCellId,
+ String pnfName, int sectorNumber, String latitude, String longitude) {
+ super();
+ this.networkId = networkId;
+ this.nodeId = nodeId;
+ this.physicalCellId = physicalCellId;
+ this.pnfName = pnfName;
+ this.sectorNumber = sectorNumber;
+ this.latitude = latitude;
+ this.longitude = longitude;
+ }
+
+ public CellInfo() {
+
+ }
+
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ public void setNetworkId(String networkId) {
+ this.networkId = networkId;
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ public long getPhysicalCellId() {
+ return physicalCellId;
+ }
+
+ public void setPhysicalCellId(long physicalCellId) {
+ this.physicalCellId = physicalCellId;
+ }
+
+ public String getPnfName() {
+ return pnfName;
+ }
+
+ public void setPnfName(String pnfName) {
+ this.pnfName = pnfName;
+ }
+
+ public int getSectorNumber() {
+ return sectorNumber;
+ }
+
+ public void setSectorNumber(int sectorNumber) {
+ this.sectorNumber = sectorNumber;
+ }
+
+ public String getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(String latitude) {
+ this.latitude = latitude;
+ }
+
+ public String getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(String longitude) {
+ this.longitude = longitude;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellNeighbor.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellNeighbor.java
new file mode 100644
index 0000000..aca96ca
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CellNeighbor.java
@@ -0,0 +1,96 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+import org.apache.log4j.Logger;
+import org.onap.ransim.rest.api.controller.RansimControllerServices;
+
+@Entity
+@Table(name = "CellNeighbor")
+public class CellNeighbor {
+
+ @Id
+ @Column(name = "nodeId", unique = true, nullable = false, length = 52)
+ private String nodeId;
+
+ /*
+ * @OneToMany(targetEntity = CellDetails.class) private Set<CellDetails>
+ * neighborList;
+ */
+
+ @OneToMany(targetEntity = NeighborDetails.class)
+ private Set<NeighborDetails> neighborList;
+
+ public CellNeighbor() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public CellNeighbor(String nodeId, Set<NeighborDetails> neighborList) {
+ super();
+ this.nodeId = nodeId;
+ this.neighborList = neighborList;
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ public Set<NeighborDetails> getNeighborList() {
+ return neighborList;
+ }
+
+ public void setNeighborList(Set<NeighborDetails> neighborList) {
+ this.neighborList = neighborList;
+ }
+
+ static Logger log = Logger.getLogger(RansimControllerServices.class.getName());
+
+ public void display() {
+
+ List<NeighborDetails> iterator = new ArrayList<>(neighborList);
+ for (int ii = 0; ii < iterator.size(); ii++) {
+ log.info("neighbors NeighborList: "
+ + iterator.get(ii).getNeigbor().getSourceCellNodeId() + " "
+ + iterator.get(ii).getNeigbor().getNeighborCell() + " "
+ + iterator.get(ii).isBlacklisted());
+ }
+
+ }
+ /*
+ * public void clearNeighborList() { this.neighborList.; }
+ */
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CreateACellReq.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CreateACellReq.java
new file mode 100644
index 0000000..34e23a5
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/CreateACellReq.java
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+import java.io.Serializable;
+
+public class CreateACellReq implements Serializable {
+
+ private long physicalCellId;
+
+ private int gridX;
+ private int gridY;
+
+ private static final long serialVersionUID = 3736300675426332512L;
+
+ public CreateACellReq() {
+ // Default constructor for CreateACellReq
+ }
+
+ /**
+ * A constructor for CreateACellReq.
+ *
+ * @param physicalCellId
+ * PCI number of the new cell
+ * @param gridX
+ * x coordinate value for the cell
+ * @param gridY
+ * y coordinate value for the cell
+ */
+ public CreateACellReq(long physicalCellId, int gridX, int gridY) {
+ super();
+
+ this.physicalCellId = physicalCellId;
+
+ this.gridX = gridX;
+ this.gridY = gridY;
+ }
+
+ public long getPhysicalCellId() {
+ return physicalCellId;
+ }
+
+ public void setPhysicalCellId(long physicalCellId) {
+ this.physicalCellId = physicalCellId;
+ }
+
+ public int getGridX() {
+ return gridX;
+ }
+
+ public void setGridX(int gridX) {
+ this.gridX = gridX;
+ }
+
+ public int getGridY() {
+ return gridY;
+ }
+
+ public void setGridY(int gridY) {
+ this.gridY = gridY;
+ }
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/DeleteACellReq.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/DeleteACellReq.java
new file mode 100644
index 0000000..a2a01ac
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/DeleteACellReq.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+public class DeleteACellReq {
+
+ private String nodeId;
+
+ /**
+ * A constructor for DeleteACellReq.
+ *
+ * @param nodeId
+ * node Id of the cell to be deleted
+ */
+ public DeleteACellReq(String nodeId) {
+ super();
+ this.nodeId = nodeId;
+ }
+
+ public DeleteACellReq() {
+
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/FmAlarmInfo.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/FmAlarmInfo.java
new file mode 100644
index 0000000..6a01498
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/FmAlarmInfo.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+public class FmAlarmInfo {
+
+ private String problem;
+ private String collisionCount;
+ private String confusionCount;
+
+ public FmAlarmInfo() {
+ super();
+ }
+
+ /**
+ * Constructor with all fields.
+ *
+ * @param problem
+ * Collision or Confusion
+ * @param collisionCount
+ * No of cells that causes collision.
+ * @param confusionCount
+ * No od cells that causes confusion.
+ */
+ public FmAlarmInfo(String problem, String collisionCount, String confusionCount) {
+ super();
+ this.problem = problem;
+ this.collisionCount = collisionCount;
+ this.confusionCount = confusionCount;
+ }
+
+ public String getProblem() {
+ return problem;
+ }
+
+ public void setProblem(String problem) {
+ this.problem = problem;
+ }
+
+ public String getCollisionCount() {
+ return collisionCount;
+ }
+
+ public void setCollisionCount(String collisionCount) {
+ this.collisionCount = collisionCount;
+ }
+
+ public String getConfusionCount() {
+ return confusionCount;
+ }
+
+ public void setConfusionCount(String confusionCount) {
+ this.confusionCount = confusionCount;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetACellDetailReq.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetACellDetailReq.java
new file mode 100644
index 0000000..a8104fe
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetACellDetailReq.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+public class GetACellDetailReq {
+
+ private String nodeId;
+
+ /**
+ * A constructor for GetACellDetailReq.
+ *
+ * @param nodeId
+ * node id of the cell
+ */
+ public GetACellDetailReq(String nodeId) {
+ super();
+ this.nodeId = nodeId;
+ }
+
+ public GetACellDetailReq() {
+
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNeighborList.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNeighborList.java
new file mode 100644
index 0000000..497df10
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNeighborList.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.ransim.rest.api.models;
+
+import java.util.List;
+
+public class GetNeighborList {
+
+ private String nodeId;
+ private List<CellDetails> cellsWithNoHo;
+ private List<CellDetails> cellsWithHo;
+
+ public GetNeighborList() {
+ super();
+ }
+
+ /**
+ * Constructor with all fields.
+ *
+ * @param nodeId
+ * Node Id of cell
+ * @param cellsWithNoHO
+ * List of neighbors with unsuccessful handover.
+ * @param cellsWithHO
+ * List of neighbors with successful handover.
+ */
+ public GetNeighborList(String nodeId, List<CellDetails> cellsWithNoHo,
+ List<CellDetails> cellsWithHo) {
+ super();
+ this.nodeId = nodeId;
+ this.cellsWithNoHo = cellsWithNoHo;
+ this.cellsWithHo = cellsWithHo;
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ public List<CellDetails> getCellsWithNoHo() {
+ return cellsWithNoHo;
+ }
+
+ public void setCellsWithNoHo(List<CellDetails> cellsWithNoHo) {
+ this.cellsWithNoHo = cellsWithNoHo;
+ }
+
+ public List<CellDetails> getCellsWithHo() {
+ return cellsWithHo;
+ }
+
+ public void setCellsWithHo(List<CellDetails> cellsWithHo) {
+ this.cellsWithHo = cellsWithHo;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNeighborListReq.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNeighborListReq.java
new file mode 100644
index 0000000..772211c
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNeighborListReq.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+public class GetNeighborListReq {
+
+ private String nodeId;
+
+ public GetNeighborListReq() {
+
+ }
+
+ /**
+ * A constructor for GetNeighborListReq.
+ *
+ * @param nodeId
+ * node Id of the cell who's neighbor list is required
+ */
+ public GetNeighborListReq(String nodeId) {
+ super();
+ this.nodeId = nodeId;
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNetconfServerDetailsReq.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNetconfServerDetailsReq.java
new file mode 100644
index 0000000..baddd09
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetNetconfServerDetailsReq.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+public class GetNetconfServerDetailsReq {
+
+ private String serverId;
+
+ /**
+ * A constructor for GetNetconfServerDetailsReq.
+ *
+ * @param serverId
+ * server Id of the netconf server
+ */
+ public GetNetconfServerDetailsReq(String serverId) {
+ super();
+ this.serverId = serverId;
+ }
+
+ public GetNetconfServerDetailsReq() {
+
+ // TODO Auto-generated constructor stub
+ }
+
+ public String getServerId() {
+ return serverId;
+ }
+
+ public void setServerId(String serverId) {
+ this.serverId = serverId;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetPmDataReq.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetPmDataReq.java
new file mode 100644
index 0000000..11ec0ca
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetPmDataReq.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.ransim.rest.api.models;
+
+public class GetPmDataReq {
+
+ private String nodeIdBad;
+ private String nodeIdPoor;
+
+ public GetPmDataReq() {
+ super();
+ }
+
+ /**
+ * Constructor with all fields.
+ *
+ * @param nodeIdBad
+ * Cells with bad PM value.
+ * @param nodeIdPoor
+ * Cells with poor PM value.
+ */
+ public GetPmDataReq(String nodeIdBad, String nodeIdPoor) {
+ super();
+ this.nodeIdBad = nodeIdBad;
+ this.nodeIdPoor = nodeIdPoor;
+ }
+
+ public String getNodeIdBad() {
+ return nodeIdBad;
+ }
+
+ public void setNodeIdBad(String nodeIdBad) {
+ this.nodeIdBad = nodeIdBad;
+ }
+
+ public String getNodeIdPoor() {
+ return nodeIdPoor;
+ }
+
+ public void setNodeIdPoor(String nodeIdPoor) {
+ this.nodeIdPoor = nodeIdPoor;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetTopology.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetTopology.java
new file mode 100644
index 0000000..1769a0c
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/GetTopology.java
@@ -0,0 +1,98 @@
+/* ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+public class GetTopology {
+
+ private CellDetails currentCell;
+ private int gridX;
+ private int gridY;
+ private String nodeId;
+ private long physicalCellId;
+
+ /**
+ * A constructor GetTopology.
+ *
+ * @param currentCell
+ * current cell details
+ * @param gridX
+ * x coordinate value for the cell
+ * @param gridY
+ * y coordinate value for the cell
+ * @param nodeId
+ * node id of the cell
+ * @param physicalCellId
+ * pci value for the cell
+ */
+ public GetTopology(CellDetails currentCell, int gridX, int gridY,
+ String nodeId, long physicalCellId) {
+ super();
+ this.currentCell = currentCell;
+ this.gridX = gridX;
+ this.gridY = gridY;
+ this.nodeId = nodeId;
+ this.physicalCellId = physicalCellId;
+ }
+
+ public GetTopology() {
+
+ }
+
+ public CellDetails getCurrentCell() {
+ return currentCell;
+ }
+
+ public void setCurrentCell(CellDetails currentCell) {
+ this.currentCell = currentCell;
+ }
+
+ public int getGridX() {
+ return gridX;
+ }
+
+ public void setGridX(int gridX) {
+ this.gridX = gridX;
+ }
+
+ public int getGridY() {
+ return gridY;
+ }
+
+ public void setGridY(int gridY) {
+ this.gridY = gridY;
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ public long getPhysicalCellId() {
+ return physicalCellId;
+ }
+
+ public void setPhysicalCellId(long physicalCellId) {
+ this.physicalCellId = physicalCellId;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/ModifyACellReq.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/ModifyACellReq.java
new file mode 100644
index 0000000..5e9dbc5
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/ModifyACellReq.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+public class ModifyACellReq {
+
+ private String nodeId;
+ private Long newPhysicalCellId;
+ private String newNbrs;
+
+ /**
+ * A constructor for ModifyACellReq.
+ *
+ * @param nodeId
+ * node Id of the cell which is to be modified
+ * @param newPhysicalCellId
+ * new PCI number for the cell
+ * @param newNbrs
+ * new neighbor list for the cell
+ */
+ public ModifyACellReq(String nodeId, Long newPhysicalCellId, String newNbrs) {
+ super();
+ this.nodeId = nodeId;
+ this.newPhysicalCellId = newPhysicalCellId;
+ this.newNbrs = newNbrs;
+
+ }
+
+ public ModifyACellReq() {
+
+ // Default constructor for ModifyCell
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ public Long getNewPhysicalCellId() {
+ return newPhysicalCellId;
+ }
+
+ public void setNewPhysicalCellId(Long newPhysicalCellId) {
+ this.newPhysicalCellId = newPhysicalCellId;
+ }
+
+ public String getNewNbrs() {
+ return newNbrs;
+ }
+
+ public void setNewNbrs(String newNbrs) {
+ this.newNbrs = newNbrs;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NbrDump.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NbrDump.java
new file mode 100644
index 0000000..8e2ffb9
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NbrDump.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.ransim.rest.api.models;
+
+public class NbrDump {
+
+ private String nodeId;
+ private String blacklisted;
+
+ public NbrDump() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public NbrDump(String nodeId, String blacklisted) {
+ super();
+ this.nodeId = nodeId;
+ this.blacklisted = blacklisted;
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ public String getBlacklisted() {
+ return blacklisted;
+ }
+
+ public void setBlacklisted(String blacklisted) {
+ this.blacklisted = blacklisted;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeighborDetails.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeighborDetails.java
new file mode 100644
index 0000000..92a03f1
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeighborDetails.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.ransim.rest.api.models;
+
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "NeighborDetails")
+public class NeighborDetails {
+
+ @EmbeddedId
+ private NeihborId neigbor;
+
+ private boolean blacklisted;
+
+ public NeighborDetails() {
+
+ }
+
+ public NeighborDetails(NeihborId neigbor, boolean blacklisted) {
+ super();
+ this.neigbor = neigbor;
+ this.blacklisted = blacklisted;
+ }
+
+
+ public NeihborId getNeigbor() {
+ return neigbor;
+ }
+
+ public void setNeigbor(NeihborId neigbor) {
+ this.neigbor = neigbor;
+ }
+
+ public boolean isBlacklisted() {
+ return blacklisted;
+ }
+
+ public void setBlacklisted(boolean blacklisted) {
+ this.blacklisted = blacklisted;
+ }
+
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeighborPmDetails.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeighborPmDetails.java
new file mode 100644
index 0000000..a5614f1
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeighborPmDetails.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.ransim.rest.api.models;
+
+public class NeighborPmDetails {
+
+ private String nbrCellId;
+ private String kpiName;
+ private int kpiValue;
+
+ public NeighborPmDetails(String nbrCellId, String kpiName, int kpiValue) {
+ super();
+ this.nbrCellId = nbrCellId;
+ this.kpiName = kpiName;
+ this.kpiValue = kpiValue;
+ }
+
+ public NeighborPmDetails() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public String getNbrCellId() {
+ return nbrCellId;
+ }
+
+ public void setNbrCellId(String nbrCellId) {
+ this.nbrCellId = nbrCellId;
+ }
+
+ public String getKpiName() {
+ return kpiName;
+ }
+
+ public void setKpiName(String kpiName) {
+ this.kpiName = kpiName;
+ }
+
+ public int getKpiValue() {
+ return kpiValue;
+ }
+
+ public void setKpiValue(int kpiValue) {
+ this.kpiValue = kpiValue;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeihborId.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeihborId.java
new file mode 100644
index 0000000..13bf9b7
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NeihborId.java
@@ -0,0 +1,93 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.ransim.rest.api.models;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+
+@Embeddable
+public class NeihborId implements Serializable {
+
+ @Column(name = "sourceCellNodeId")
+ private String sourceCellNodeId;
+
+ @Column(name = "neighborCellNodeId")
+ private String neighborCell;
+
+ public NeihborId() {
+ }
+
+ public NeihborId(String sourceCellNodeId, String neighborCell) {
+ this.sourceCellNodeId = sourceCellNodeId;
+ this.neighborCell = neighborCell;
+ }
+
+ public String getSourceCellNodeId() {
+ return sourceCellNodeId;
+ }
+
+ public String getNeighborCell() {
+ return neighborCell;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((neighborCell == null) ? 0 : neighborCell.hashCode());
+ result = prime
+ * result
+ + ((sourceCellNodeId == null) ? 0 : sourceCellNodeId.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ NeihborId other = (NeihborId) obj;
+ if (neighborCell == null) {
+ if (other.neighborCell != null) {
+ return false;
+ }
+ } else if (!neighborCell.equals(other.neighborCell))
+ return false;
+ if (sourceCellNodeId == null) {
+ if (other.sourceCellNodeId != null) {
+ return false;
+ }
+ } else if (!sourceCellNodeId.equals(other.sourceCellNodeId)) {
+ return false;
+ }
+ return true;
+ }
+} \ No newline at end of file
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NetconfServers.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NetconfServers.java
new file mode 100644
index 0000000..bf91f7b
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/NetconfServers.java
@@ -0,0 +1,104 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "NetconfServers")
+public class NetconfServers {
+
+ @Id
+ @Column(name = "serverId", unique = true, nullable = false, length = 20)
+ private String serverId;
+
+ private String ip;
+ private String netconfPort;
+
+ @OneToMany(targetEntity = CellDetails.class, orphanRemoval = true, cascade = { CascadeType.ALL })
+ // @OneToMany(targetEntity = CellDetails.class)
+ private Set<CellDetails> cells;
+
+ public NetconfServers() {
+
+ }
+
+ /**
+ * A constructor for Netconf server table class.
+ *
+ * @param serverId
+ * server Id of the netconf server
+ * @param ip
+ * ip address of the netconf server
+ * @param netconfPort
+ * port number of the netconf server
+ * @param cells
+ * List of cells belonging to the netconf server
+ */
+ public NetconfServers(String serverId, String ip, String netconfPort,
+ Set<CellDetails> cells) {
+ super();
+ this.serverId = serverId;
+ this.ip = ip;
+ this.netconfPort = netconfPort;
+ this.cells = cells;
+ }
+
+ public String getServerId() {
+ return serverId;
+ }
+
+ public void setServerId(String serverId) {
+ this.serverId = serverId;
+ }
+
+ public String getIp() {
+ return ip;
+ }
+
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ public String getNetconfPort() {
+ return netconfPort;
+ }
+
+ public void setNetconfPort(String netconfPort) {
+ this.netconfPort = netconfPort;
+ }
+
+ public Set<CellDetails> getCells() {
+ return cells;
+ }
+
+ public void setCells(Set<CellDetails> cells) {
+ this.cells = cells;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/OperationLog.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/OperationLog.java
new file mode 100644
index 0000000..cfc55ce
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/OperationLog.java
@@ -0,0 +1,108 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Column;
+import javax.persistence.GenerationType;
+
+@Entity
+@Table(name = "OperationLog")
+public class OperationLog {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private int rowId;
+ private long time;
+ private String nodeId;
+ private String source;
+
+ @Column(name = "message", length = 300)
+ private String message;
+ private String fieldName;
+ private String operation;
+ /*private String prevValue;
+
+ @Column(name = "currValue", length = 500)
+ private String currValue;*/
+
+ public int getRowId() {
+ return rowId;
+ }
+
+ public void setRowId(int rowId) {
+ this.rowId = rowId;
+ }
+
+ public long getTime() {
+ return time;
+ }
+
+
+ public String getSource() {
+ return source;
+ }
+
+ public void setSource(String source) {
+ this.source = source;
+ }
+
+ public void setTime(long time) {
+ this.time = time;
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ public void setFieldName(String fieldName) {
+ this.fieldName = fieldName;
+ }
+
+ public String getOperation() {
+ return operation;
+ }
+
+ public void setOperation(String operation) {
+ this.operation = operation;
+ }
+
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PmDataDump.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PmDataDump.java
new file mode 100644
index 0000000..745b475
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PmDataDump.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+import java.util.List;
+
+public class PmDataDump {
+
+ private List<PmParameters> kpiDump;
+
+ public PmDataDump() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public PmDataDump(List<PmParameters> kpiDump) {
+ super();
+ this.kpiDump = kpiDump;
+ }
+
+ public List<PmParameters> getKpiDump() {
+ return kpiDump;
+ }
+
+ public void setKpiDump(List<PmParameters> kpiDump) {
+ this.kpiDump = kpiDump;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PmParameters.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PmParameters.java
new file mode 100644
index 0000000..fc48e02
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PmParameters.java
@@ -0,0 +1,85 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+public class PmParameters {
+
+ private String parameter1;
+ private String successValue1;
+ private String badValue1;
+ private String poorValue1;
+ private String parameter2;
+ private String successValue2;
+ private String badValue2;
+ private String poorValue2;
+
+ public String getParameter1() {
+ return parameter1;
+ }
+ public void setParameter1(String parameter1) {
+ this.parameter1 = parameter1;
+ }
+ public String getSuccessValue1() {
+ return successValue1;
+ }
+ public void setSuccessValue1(String successValue1) {
+ this.successValue1 = successValue1;
+ }
+ public String getBadValue1() {
+ return badValue1;
+ }
+ public void setBadValue1(String badValue1) {
+ this.badValue1 = badValue1;
+ }
+ public String getPoorValue1() {
+ return poorValue1;
+ }
+ public void setPoorValue1(String poorValue1) {
+ this.poorValue1 = poorValue1;
+ }
+ public String getParameter2() {
+ return parameter2;
+ }
+ public void setParameter2(String parameter2) {
+ this.parameter2 = parameter2;
+ }
+ public String getSuccessValue2() {
+ return successValue2;
+ }
+ public void setSuccessValue2(String successValue2) {
+ this.successValue2 = successValue2;
+ }
+ public String getBadValue2() {
+ return badValue2;
+ }
+ public void setBadValue2(String badValue2) {
+ this.badValue2 = badValue2;
+ }
+ public String getPoorValue2() {
+ return poorValue2;
+ }
+ public void setPoorValue2(String poorValue2) {
+ this.poorValue2 = poorValue2;
+ }
+
+
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SetCollisionReq.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SetCollisionReq.java
new file mode 100644
index 0000000..2d51c83
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SetCollisionReq.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+public class SetCollisionReq {
+
+ private boolean collision;
+
+ /**
+ * A constructor for SetCollisionReq.
+ *
+ * @param collision
+ * to set if the new simulation has collision between the cells
+ */
+ public SetCollisionReq(boolean collision) {
+ super();
+ this.collision = collision;
+ }
+
+ public SetCollisionReq() {
+
+ }
+
+ public boolean isCollision() {
+ return collision;
+ }
+
+ public void setCollision(boolean collision) {
+ this.collision = collision;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SetConstants.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SetConstants.java
new file mode 100644
index 0000000..1d6d9d5
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/SetConstants.java
@@ -0,0 +1,112 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+public class SetConstants {
+
+ private int gridSize;
+ private int gridType;
+ private boolean collision;
+
+ private int processCapacity;
+ private int numberOfMachines;
+ private String serverIdPrefix;
+
+ public SetConstants() {
+
+ }
+
+ /**
+ * A constructor for SetConstants.
+ *
+ * @param gridSize
+ * grid dimension for the topology (number of cells along the side)
+ * @param gridType
+ * honeycomb or square grid
+ * @param collision
+ * to set if the new simulation has collision between the cells
+ * @param processCapacity
+ * number of netconf servers
+ * @param numberOfMachines
+ * number of machines running in one netconf server
+ * @param serverIdPrefix
+ * server id prefix
+ */
+ public SetConstants(int gridSize, int gridType, boolean collision, int processCapacity, int numberOfMachines,
+ String serverIdPrefix) {
+ super();
+ this.gridSize = gridSize;
+ this.gridType = gridType;
+ this.collision = collision;
+ this.processCapacity = processCapacity;
+ this.numberOfMachines = numberOfMachines;
+ this.serverIdPrefix = serverIdPrefix;
+ }
+
+ public int getGridSize() {
+ return gridSize;
+ }
+
+ public void setGridSize(int gridSize) {
+ this.gridSize = gridSize;
+ }
+
+ public int getGridType() {
+ return gridType;
+ }
+
+ public void setGridType(int gridType) {
+ this.gridType = gridType;
+ }
+
+ public boolean isCollision() {
+ return collision;
+ }
+
+ public void setCollision(boolean collision) {
+ this.collision = collision;
+ }
+
+ public int getProcessCapacity() {
+ return processCapacity;
+ }
+
+ public void setProcessCapacity(int processCapacity) {
+ this.processCapacity = processCapacity;
+ }
+
+ public int getNumberOfMachines() {
+ return numberOfMachines;
+ }
+
+ public void setNumberOfMachines(int numberOfMachines) {
+ this.numberOfMachines = numberOfMachines;
+ }
+
+ public String getServerIdPrefix() {
+ return serverIdPrefix;
+ }
+
+ public void setServerIdPrefix(String serverIdPrefix) {
+ this.serverIdPrefix = serverIdPrefix;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/Topology.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/Topology.java
new file mode 100644
index 0000000..87d575e
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/Topology.java
@@ -0,0 +1,112 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+import java.util.List;
+
+public class Topology {
+ int gridSize;
+ float minScreenX = 0;
+ float minScreenY = 0;
+ float maxScreenX = 10;
+ float maxScreenY = 10;
+ List<CellDetails> cellTopology;
+
+ /**
+ * A constructor for Topology.
+ *
+ * @param gridSize
+ * grid size
+ * @param minScreenX
+ * min value of screen X for a cell in the topology
+ * @param minScreenY
+ * min value of screen Y for a cell in the topology
+ * @param maxScreenX
+ * max value of screen X for a cell in the topology
+ * @param maxScreenY
+ * max value of screen Y for a cell in the topology
+ * @param cellTopology
+ * list of cells within the topology
+ */
+ public Topology(int gridSize, float minScreenX, float minScreenY, float maxScreenX, float maxScreenY,
+ List<CellDetails> cellTopology) {
+ super();
+ this.gridSize = gridSize;
+ this.minScreenX = minScreenX;
+ this.minScreenY = minScreenY;
+ this.maxScreenX = maxScreenX;
+ this.maxScreenY = maxScreenY;
+ this.cellTopology = cellTopology;
+ }
+
+ public Topology() {
+
+ }
+
+ public int getGridSize() {
+ return gridSize;
+ }
+
+ public void setGridSize(int gridSize) {
+ this.gridSize = gridSize;
+ }
+
+ public float getMinScreenX() {
+ return minScreenX;
+ }
+
+ public void setMinScreenX(float minScreenX) {
+ this.minScreenX = minScreenX;
+ }
+
+ public float getMinScreenY() {
+ return minScreenY;
+ }
+
+ public void setMinScreenY(float minScreenY) {
+ this.minScreenY = minScreenY;
+ }
+
+ public float getMaxScreenX() {
+ return maxScreenX;
+ }
+
+ public void setMaxScreenX(float maxScreenX) {
+ this.maxScreenX = maxScreenX;
+ }
+
+ public float getMaxScreenY() {
+ return maxScreenY;
+ }
+
+ public void setMaxScreenY(float maxScreenY) {
+ this.maxScreenY = maxScreenY;
+ }
+
+ public List<CellDetails> getCellTopology() {
+ return cellTopology;
+ }
+
+ public void setCellTopology(List<CellDetails> cellTopology) {
+ this.cellTopology = cellTopology;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/TopologyDump.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/TopologyDump.java
new file mode 100644
index 0000000..d7825f9
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/TopologyDump.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+import java.util.List;
+
+public class TopologyDump {
+
+ private List<CellData> cellList;
+
+ /**
+ * A constructor for TopologyDump.
+ *
+ * @param cellList
+ * list of cells
+ */
+ public TopologyDump(List<CellData> cellList) {
+
+ this.cellList = cellList;
+ }
+
+ public TopologyDump() {
+
+ }
+
+ public List<CellData> getCellList() {
+ return cellList;
+ }
+
+ public void setCellList(List<CellData> cellList) {
+ this.cellList = cellList;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/client/RestClient.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/client/RestClient.java
new file mode 100644
index 0000000..9e56045
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/client/RestClient.java
@@ -0,0 +1,122 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.client;
+
+import java.nio.charset.Charset;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.eclipse.persistence.internal.oxm.conversion.Base64;
+import org.onap.ransim.rest.api.controller.RansimControllerServices;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.RestTemplate;
+
+public class RestClient {
+
+ static Logger log = Logger.getLogger(RansimControllerServices.class.getName());
+
+ HttpHeaders createHeaders(String username, String password) {
+ return new HttpHeaders() {
+ {
+ String auth = username + ":" + password;
+ byte[] encodedAuth = Base64.base64Encode(auth.getBytes(Charset.forName("US-ASCII")));
+
+ String authHeader = "Basic " + new String(encodedAuth);
+ set("Authorization", authHeader);
+ set("Content-Type", "application/xml");
+ set("Accept", "application/xml");
+ }
+ };
+ }
+
+ /**
+ * Sends mount request to sdnr.
+ *
+ * @param serverId
+ * netconf server id name
+ * @param ip
+ * server ip address
+ * @param port
+ * port number
+ * @param agentIp
+ * agent ip address
+ * @param agentPort
+ * agent port number
+ * @param agentUsername
+ * agent username
+ * @param agentPassword
+ * agent password
+ * @return returns the message to be passed
+ */
+ public String sendMountRequestToSdnr(String serverId, String ip, int port, String agentIp, String agentPort,
+ String agentUsername, String agentPassword) {
+ String requestBody = "<node xmlns=\"urn:TBD:params:xml:ns:yang:network-topology\"> <node-id> " + serverId + " </node-id> <username xmlns=\"urn:opendaylight:netconf-node-topology\">admin</username> <password xmlns=\"urn:opendaylight:netconf-node-topology\">admin</password> <host xmlns=\"urn:opendaylight:netconf-node-topology\">" + agentIp + "</host> <schema-cache-directory xmlns=\"urn:opendaylight:netconf-node-topology\">" + serverId + "</schema-cache-directory> <port xmlns=\"urn:opendaylight:netconf-node-topology\">" + agentPort + "</port> <tcp-only xmlns=\"urn:opendaylight:netconf-node-topology\">false</tcp-only> <schemaless xmlns=\"urn:opendaylight:netconf-node-topology\">false</schemaless> <max-connection-attempts xmlns=\"urn:opendaylight:netconf-node-topology\">0</max-connection-attempts> <connection-timeout-millis xmlns=\"urn:opendaylight:netconf-node-topology\">20000</connection-timeout-millis> <default-request-timeout-millis xmlns=\"urn:opendaylight:netconf-node-topology\">60000</default-request-timeout-millis> <sleep-factor xmlns=\"urn:opendaylight:netconf-node-topology\">1.1</sleep-factor> <between-attempts-timeout-millis xmlns=\"urn:opendaylight:netconf-node-topology\">2000</between-attempts-timeout-millis> <reconnect-on-changed-schema xmlns=\"urn:opendaylight:netconf-node-topology\">false</reconnect-on-changed-schema> <keepalive-delay xmlns=\"urn:opendaylight:netconf-node-topology\">60</keepalive-delay> <concurrent-rpc-limit xmlns=\"urn:opendaylight:netconf-node-topology\">0</concurrent-rpc-limit> <actor-response-wait-time xmlns=\"urn:opendaylight:netconf-node-topology\">60</actor-response-wait-time></node>";
+
+ HttpHeaders headers = createHeaders(agentUsername, agentPassword);
+
+ log.info("request : " + requestBody);
+ log.info("headers : " + headers);
+ for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
+ log.info("Key:" + entry.getKey() + " , Value:" + entry.getValue());
+ }
+ RestTemplate restTemplate = new RestTemplate();
+ String url = "http://" + ip + ":" + port
+ + "/restconf/config/network-topology:network-topology/topology/topology-netconf/node/" + serverId;
+
+ HttpEntity<String> entity = new HttpEntity<String>(requestBody, headers);
+ ResponseEntity<String> result = restTemplate.exchange(url, HttpMethod.PUT, entity, String.class);
+
+ log.info("request sent, result: " + result);
+ return result.toString();
+ }
+
+ /**
+ * Sends an unmount request to sdnr.
+ *
+ * @param serverId
+ * netconf server id name
+ * @param ip
+ * ip address
+ * @param port
+ * port number
+ * @param sdnrUsername
+ * sdnr username
+ * @param sdnrPassword
+ * sdnr password
+ * @return returns the message to be passed
+ */
+ public String sendUnmountRequestToSdnr(String serverId, String ip, int port, String sdnrUsername,
+ String sdnrPassword) {
+ String url = "http://" + ip + ":" + port
+ + "/restconf/config/network-topology:network-topology/topology/topology-netconf/node/" + serverId;
+ RestTemplate restTemplate = new RestTemplate();
+
+ HttpHeaders headers = createHeaders(sdnrUsername, sdnrPassword);
+ HttpEntity<String> entity = new HttpEntity<String>("parameters", headers);
+ ResponseEntity<String> result = restTemplate.exchange(url, HttpMethod.DELETE, entity, String.class);
+ log.info("request sent, result: " + result);
+ return result.toString();
+ }
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/config/RansimRestConfig.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/config/RansimRestConfig.java
new file mode 100644
index 0000000..6e57945
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/config/RansimRestConfig.java
@@ -0,0 +1,99 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.config;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+
+import javax.annotation.PostConstruct;
+import javax.servlet.MultipartConfigElement;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@Configuration
+@EnableWebMvc
+@EnableSwagger2
+@ComponentScan(basePackages = { "org.onap.*", "com.*" })
+public class RansimRestConfig extends WebMvcConfigurerAdapter {
+
+ /**
+ * init.
+ */
+ @PostConstruct
+ public void init() {
+ Properties prop = new Properties();
+ try (InputStream input = new FileInputStream("rs.properties")) {
+ // load a properties file
+ prop.load(input);
+ } catch (Exception e) {
+ System.out.println("Exception Occured while loading properties file" + e);
+ }
+ }
+
+ @Override
+ public void addResourceHandlers(ResourceHandlerRegistry registry) {
+ registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
+ registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
+ }
+
+ private ApiInfo apiInfo() {
+ return new ApiInfoBuilder().title("Ran Simulator Controller REST API")
+ .description("This API helps to make queries against Ran Simulator Controller").version("3.0").build();
+ }
+
+ /**
+ * ransimappApi .
+ *
+ * @return returns api info
+ */
+ @Bean
+ public Docket ransimappApi() {
+ return new Docket(DocumentationType.SWAGGER_2).select()
+ .apis(RequestHandlerSelectors.basePackage("org.onap.ransim.rest.api")).paths(PathSelectors.any())
+ .build().apiInfo(apiInfo());
+ }
+
+ /**
+ * MultipartConfigElement.
+ *
+ * @return returns MultipartConfigElement
+ */
+ @Bean
+ public MultipartConfigElement multipartConfigElement() {
+ String location = System.getProperty("java.io.tmpdir");
+ MultipartConfigElement mp = new MultipartConfigElement(location);
+ return mp;
+ }
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/config/RansimRestInitializer.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/config/RansimRestInitializer.java
new file mode 100644
index 0000000..427e871
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/config/RansimRestInitializer.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.config;
+
+import javax.servlet.MultipartConfigElement;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRegistration;
+
+import org.springframework.web.WebApplicationInitializer;
+import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
+import org.springframework.web.servlet.DispatcherServlet;
+
+/**
+ * REST API configuration initialization.
+ *
+ * @version 0.1
+ */
+public class RansimRestInitializer implements WebApplicationInitializer {
+ @Override
+ public void onStartup(ServletContext container) throws ServletException {
+ AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
+ ctx.register(RansimRestConfig.class);
+ ctx.setServletContext(container);
+ ctx.refresh();
+ ServletRegistration.Dynamic servlet = container.addServlet("dispatcher", new DispatcherServlet(ctx));
+ servlet.setLoadOnStartup(1);
+ servlet.addMapping("/api/*");
+ servlet.setMultipartConfig(ctx.getBean(MultipartConfigElement.class));
+ }
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/AdditionalMeasurements.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/AdditionalMeasurements.java
new file mode 100644
index 0000000..650bfa8
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/AdditionalMeasurements.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.websocket.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class AdditionalMeasurements {
+
+ private String name;
+ private Map<String, String> hashMap = new HashMap<String, String>();
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Map<String, String> getHashMap() {
+ return hashMap;
+ }
+
+ public void setHashMap(Map<String, String> hashMap) {
+ this.hashMap = hashMap;
+ }
+
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/CommonEventHeaderFm.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/CommonEventHeaderFm.java
new file mode 100644
index 0000000..aa75009
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/CommonEventHeaderFm.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.websocket.model;
+
+public class CommonEventHeaderFm {
+
+ private String sourceName;
+ private String sourceUuid;
+ private String reportingEntityName;
+ private long startEpochMicrosec;
+ private long lastEpochMicrosec;
+
+ public CommonEventHeaderFm() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public CommonEventHeaderFm(String sourceName, String sourceUuid, String reportingEntityName,
+ long startEpochMicrosec, long lastEpochMicrosec) {
+ super();
+ this.sourceName = sourceName;
+ this.sourceUuid = sourceUuid;
+ this.reportingEntityName = reportingEntityName;
+ this.startEpochMicrosec = startEpochMicrosec;
+ this.lastEpochMicrosec = lastEpochMicrosec;
+ }
+
+ public String getSourceName() {
+ return sourceName;
+ }
+
+ public void setSourceName(String sourceName) {
+ this.sourceName = sourceName;
+ }
+
+ public String getSourceUuid() {
+ return sourceUuid;
+ }
+
+ public void setSourceUuid(String sourceUuid) {
+ this.sourceUuid = sourceUuid;
+ }
+
+ public long getStartEpochMicrosec() {
+ return startEpochMicrosec;
+ }
+
+ public void setStartEpochMicrosec(long startEpochMicrosec) {
+ this.startEpochMicrosec = startEpochMicrosec;
+ }
+
+ public long getLastEpochMicrosec() {
+ return lastEpochMicrosec;
+ }
+
+ public void setLastEpochMicrosec(long lastEpochMicrosec) {
+ this.lastEpochMicrosec = lastEpochMicrosec;
+ }
+
+ public String getReportingEntityName() {
+ return reportingEntityName;
+ }
+
+ public void setReportingEntityName(String reportingEntityName) {
+ this.reportingEntityName = reportingEntityName;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/CommonEventHeaderPm.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/CommonEventHeaderPm.java
new file mode 100644
index 0000000..9f87529
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/CommonEventHeaderPm.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.websocket.model;
+
+public class CommonEventHeaderPm {
+
+ private String sourceName;
+ private String sourceUuid;
+ private long startEpochMicrosec;
+ private long lastEpochMicrosec;
+
+ public String getSourceName() {
+ return sourceName;
+ }
+
+ public void setSourceName(String sourceName) {
+ this.sourceName = sourceName;
+ }
+
+ public String getSourceUuid() {
+ return sourceUuid;
+ }
+
+ public void setSourceUuid(String sourceUuid) {
+ this.sourceUuid = sourceUuid;
+ }
+
+ public long getStartEpochMicrosec() {
+ return startEpochMicrosec;
+ }
+
+ public void setStartEpochMicrosec(long startEpochMicrosec) {
+ this.startEpochMicrosec = startEpochMicrosec;
+ }
+
+ public long getLastEpochMicrosec() {
+ return lastEpochMicrosec;
+ }
+
+ public void setLastEpochMicrosec(long lastEpochMicrosec) {
+ this.lastEpochMicrosec = lastEpochMicrosec;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/DeviceData.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/DeviceData.java
new file mode 100644
index 0000000..5954408
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/DeviceData.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.websocket.model;
+
+import java.io.Serializable;
+
+public class DeviceData implements Serializable {
+
+ private static final long serialVersionUID = 4388248209444904611L;
+
+ private String type;
+ private String message;
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+} \ No newline at end of file
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/DeviceDataDecoder.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/DeviceDataDecoder.java
new file mode 100644
index 0000000..caddc59
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/DeviceDataDecoder.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.websocket.model;
+
+import javax.websocket.DecodeException;
+import javax.websocket.Decoder;
+import javax.websocket.EndpointConfig;
+
+public class DeviceDataDecoder implements Decoder.Text<DeviceData> {
+
+ // public class DeviceDataDecoder implements Decoder.Text<DeviceData>
+ @Override
+ public void destroy() {
+ }
+
+ @Override
+ public void init(EndpointConfig arg0) {
+ }
+
+ @Override
+ public DeviceData decode(String msgInfo) throws DecodeException {
+ DeviceData data = new DeviceData();
+ String[] strInfo = msgInfo.split(":", 2);
+ if (strInfo.length < 2) {
+ data.setMessage("");
+ } else {
+ data.setMessage(strInfo[1]);
+ }
+ data.setType(strInfo[0]);
+ return data;
+ }
+
+ @Override
+ public boolean willDecode(String arg0) {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/DeviceDataEncoder.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/DeviceDataEncoder.java
new file mode 100644
index 0000000..6c29929
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/DeviceDataEncoder.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.websocket.model;
+
+import javax.websocket.EncodeException;
+import javax.websocket.Encoder;
+import javax.websocket.EndpointConfig;
+
+public class DeviceDataEncoder implements Encoder.Text<DeviceData> {
+
+ @Override
+ public void destroy() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void init(EndpointConfig arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String encode(DeviceData msg) throws EncodeException {
+ String result = msg.getType() + ":" + msg.getMessage();
+ return result;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/EventFm.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/EventFm.java
new file mode 100644
index 0000000..ec340f5
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/EventFm.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.websocket.model;
+
+public class EventFm {
+
+ private CommonEventHeaderFm commonEventHeader;
+ private FaultFields faultFields;
+
+ public EventFm(CommonEventHeaderFm commonEventHeader, FaultFields faultFields) {
+ super();
+ this.commonEventHeader = commonEventHeader;
+ this.faultFields = faultFields;
+ }
+
+ public EventFm() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public CommonEventHeaderFm getCommonEventHeader() {
+ return commonEventHeader;
+ }
+
+ public void setCommonEventHeader(CommonEventHeaderFm commonEventHeader) {
+ this.commonEventHeader = commonEventHeader;
+ }
+
+ public FaultFields getFaultFields() {
+ return faultFields;
+ }
+
+ public void setFaultFields(FaultFields faultFields) {
+ this.faultFields = faultFields;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/EventPm.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/EventPm.java
new file mode 100644
index 0000000..f6dbb63
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/EventPm.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.websocket.model;
+
+public class EventPm {
+
+ private CommonEventHeaderPm commonEventHeader;
+ private Measurement measurement;
+
+ public CommonEventHeaderPm getCommonEventHeader() {
+ return commonEventHeader;
+ }
+
+ public void setCommonEventHeader(CommonEventHeaderPm commonEventHeader) {
+ this.commonEventHeader = commonEventHeader;
+ }
+
+ public Measurement getMeasurement() {
+ return measurement;
+ }
+
+ public void setMeasurement(Measurement measurement) {
+ this.measurement = measurement;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/FaultFields.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/FaultFields.java
new file mode 100644
index 0000000..ebf31f7
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/FaultFields.java
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.websocket.model;
+
+import java.util.Map;
+
+public class FaultFields {
+
+ private String alarmCondition;
+ private String eventSourceType;
+ private String specificProblem;
+ private String eventSeverity;
+ private Map<String, String> alarmAdditionalInformation;
+
+ public FaultFields() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public FaultFields(String alarmCondition, String eventSourceType, String specificProblem,
+ String eventSeverity, Map<String, String> alarmAdditionalInformation) {
+ super();
+ this.alarmCondition = alarmCondition;
+ this.eventSourceType = eventSourceType;
+ this.specificProblem = specificProblem;
+ this.eventSeverity = eventSeverity;
+ this.alarmAdditionalInformation = alarmAdditionalInformation;
+ }
+
+ public String getAlarmCondition() {
+ return alarmCondition;
+ }
+
+ public void setAlarmCondition(String alarmCondition) {
+ this.alarmCondition = alarmCondition;
+ }
+
+ public String getEventSourceType() {
+ return eventSourceType;
+ }
+
+ public void setEventSourceType(String eventSourceType) {
+ this.eventSourceType = eventSourceType;
+ }
+
+ public String getSpecificProblem() {
+ return specificProblem;
+ }
+
+ public void setSpecificProblem(String specificProblem) {
+ this.specificProblem = specificProblem;
+ }
+
+ public String getEventSeverity() {
+ return eventSeverity;
+ }
+
+ public void setEventSeverity(String eventSeverity) {
+ this.eventSeverity = eventSeverity;
+ }
+
+ public Map<String, String> getAlarmAdditionalInformation() {
+ return alarmAdditionalInformation;
+ }
+
+ public void setAlarmAdditionalInformation(Map<String, String> alarmAdditionalInformation) {
+ this.alarmAdditionalInformation = alarmAdditionalInformation;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/FmMessage.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/FmMessage.java
new file mode 100644
index 0000000..c11ab64
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/FmMessage.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.websocket.model;
+
+import java.util.List;
+
+public class FmMessage {
+
+ List<EventFm> fmEventList;
+
+ public void setFmEventList(List<EventFm> data) {
+ this.fmEventList = data;
+ }
+
+ public List<EventFm> getFmEventList() {
+ return fmEventList;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/Measurement.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/Measurement.java
new file mode 100644
index 0000000..8f9de10
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/Measurement.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.ransim.websocket.model;
+
+import java.util.List;
+
+public class Measurement {
+
+ private int measurementInterval;
+ private List<AdditionalMeasurements> additionalMeasurements;
+
+ public int getMeasurementInterval() {
+ return measurementInterval;
+ }
+
+ public void setMeasurementInterval(int measurementInterval) {
+ this.measurementInterval = measurementInterval;
+ }
+
+ public List<AdditionalMeasurements> getAdditionalMeasurements() {
+ return additionalMeasurements;
+ }
+
+ public void setAdditionalMeasurements(
+ List<AdditionalMeasurements> additionalMeasurements) {
+ this.additionalMeasurements = additionalMeasurements;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/MessageTypes.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/MessageTypes.java
new file mode 100644
index 0000000..da4bf92
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/MessageTypes.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.websocket.model;
+
+public class MessageTypes {
+ public final static String RC_TO_HC_FMDATA = "FmData";
+ public final static String RC_TO_HC_PMDATA = "PmData";
+ public final static String RC_TO_HC_SETCONFIGTOPO = "SetConfigTopology";
+ public final static String RC_TO_HC_UPDCELL = "UpdateCell";
+ public final static String RC_TO_HC_PING = "ping";
+
+ public final static String HC_TO_RC_MODPCI = "ModifyPci";
+ public final static String HC_TO_RC_MODANR = "ModifyAnr";
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/ModifyNeighbor.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/ModifyNeighbor.java
new file mode 100644
index 0000000..30ec5d0
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/ModifyNeighbor.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.websocket.model;
+
+import java.util.List;
+
+public class ModifyNeighbor {
+
+ private String pnfName;
+ private String cellId;
+ private List<NeighborHo> neighborList;
+
+ public String getPnfName() {
+ return pnfName;
+ }
+
+ public void setPnfName(String pnfName) {
+ this.pnfName = pnfName;
+ }
+
+ public String getCellId() {
+ return cellId;
+ }
+
+ public void setCellId(String cellId) {
+ this.cellId = cellId;
+ }
+
+ public List<NeighborHo> getNeighborList() {
+ return neighborList;
+ }
+
+ public void setNeighborList(List<NeighborHo> neighborList) {
+ this.neighborList = neighborList;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/ModifyPci.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/ModifyPci.java
new file mode 100644
index 0000000..6a52624
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/ModifyPci.java
@@ -0,0 +1,112 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.websocket.model;
+
+import java.util.List;
+
+public class ModifyPci {
+
+ private String pnfName;
+
+ private long pciId;
+
+ private String cellId;
+
+ private List<Neighbor> neighborList;
+
+ public long getPciId() {
+ return pciId;
+ }
+
+ public void setPciId(long pciId) {
+ this.pciId = pciId;
+ }
+
+ public String getCellId() {
+ return cellId;
+ }
+
+ public void setCellId(String cellId) {
+ this.cellId = cellId;
+ }
+
+ @Override
+ public String toString() {
+ return "ModifyPci [PnfName = " + pnfName + ", PciId = " + pciId + ", cellId = " + cellId + "neighborList:"
+ + neighborList + "]";
+ }
+
+ public ModifyPci() {
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * Modify Pci value from sdnr.
+ *
+ * @param pnfName
+ * server id name
+ * @param pciId
+ * pci number
+ * @param cellId
+ * node id for the cell
+ * @param neighborList
+ * neighbor list for the cell
+ */
+ public ModifyPci(String pnfName, long pciId, String cellId, List<Neighbor> neighborList) {
+ super();
+ this.pnfName = pnfName;
+ this.pciId = pciId;
+ this.cellId = cellId;
+ this.neighborList = neighborList;
+ }
+
+ public String getPnfName() {
+ return pnfName;
+ }
+
+ public void setPnfName(String pnfName) {
+ this.pnfName = pnfName;
+ }
+
+ public List<Neighbor> getNeighborList() {
+ return neighborList;
+ }
+
+ public void setNeighborList(List<Neighbor> neighborList) {
+ this.neighborList = neighborList;
+ }
+
+ /**
+ * Checks if all the parameters are set correctly .
+ *
+ * @return returns true if the parameter are set correctly
+ */
+ public boolean isAllSet() {
+ if (pnfName == null || pnfName.trim().equals("")) {
+ return false;
+ }
+ if (cellId == null || cellId.trim().equals("")) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/Neighbor.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/Neighbor.java
new file mode 100644
index 0000000..65c6940
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/Neighbor.java
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.websocket.model;
+
+public class Neighbor {
+
+ private String plmnId;
+ private String nodeId;
+ private long physicalCellId;
+ private String serverId;
+ private String pnfName;
+ private boolean blacklisted;
+
+ public String getPlmnId() {
+ return plmnId;
+ }
+
+ public void setPlmnId(String plmnId) {
+ this.plmnId = plmnId;
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ public long getPhysicalCellId() {
+ return physicalCellId;
+ }
+
+ public void setPhysicalCellId(long physicalCellId) {
+ this.physicalCellId = physicalCellId;
+ }
+
+ public String getServerId() {
+ return serverId;
+ }
+
+ public void setServerId(String serverId) {
+ this.serverId = serverId;
+ }
+
+ public String getPnfName() {
+ return pnfName;
+ }
+
+ public void setPnfName(String pnfName) {
+ this.pnfName = pnfName;
+ }
+
+ public Neighbor() {
+ // TODO Auto-generated constructor stub
+ }
+
+ public boolean isBlacklisted() {
+ return blacklisted;
+ }
+
+ public void setBlacklisted(boolean blacklisted) {
+ this.blacklisted = blacklisted;
+ }
+ @Override
+ public String toString() {
+ return "Neighbor [nodeId=" + nodeId + ", physicalCellId=" + physicalCellId + ", serverId=" + serverId
+ + ", pnfName=" + pnfName + "]";
+ }
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/NeighborHo.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/NeighborHo.java
new file mode 100644
index 0000000..5b7f41a
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/NeighborHo.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.websocket.model;
+
+public class NeighborHo {
+
+ private String nodeId;
+ private long pciId;
+ private boolean blacklisted;
+
+ public String getNodeId() {
+ return nodeId;
+ }
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ public long getPciId() {
+ return pciId;
+ }
+ public void setPciId(long pciId) {
+ this.pciId = pciId;
+ }
+ public boolean isBlacklisted() {
+ return blacklisted;
+ }
+ public void setBlacklisted(boolean blacklisted) {
+ this.blacklisted = blacklisted;
+ }
+
+
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/PmMessage.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/PmMessage.java
new file mode 100644
index 0000000..3fb63b7
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/PmMessage.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.websocket.model;
+
+import java.util.List;
+
+public class PmMessage {
+
+ List<EventPm> eventPmList;
+
+ public void setEventPmList(List<EventPm> data) {
+ this.eventPmList = data;
+ }
+
+ public List<EventPm> getEventPmList() {
+ return eventPmList;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/SetConfigTopology.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/SetConfigTopology.java
new file mode 100644
index 0000000..9b22ebd
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/SetConfigTopology.java
@@ -0,0 +1,97 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.websocket.model;
+
+import java.util.List;
+
+public class SetConfigTopology {
+
+ private String serverId;
+ private String uuid;
+ private String ip;
+ private String netconfPort;
+ private List<Topology> topology;
+
+ public SetConfigTopology() {
+
+ }
+
+ /**
+ * Cell details for the given netconf server.
+ *
+ * @param serverId
+ * netconf server id
+ * @param ip
+ * ip address
+ * @param netconfPort
+ * port number
+ * @param topology
+ * cell topology for given server id
+ */
+ public SetConfigTopology(String serverId, String ip, String netconfPort, List<Topology> topology) {
+ super();
+ this.serverId = serverId;
+ this.ip = ip;
+ this.netconfPort = netconfPort;
+ this.topology = topology;
+ }
+
+ public String getServerId() {
+ return serverId;
+ }
+
+ public void setServerId(String serverId) {
+ this.serverId = serverId;
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getIp() {
+ return ip;
+ }
+
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ public String getNetconfPort() {
+ return netconfPort;
+ }
+
+ public void setNetconfPort(String netconfPort) {
+ this.netconfPort = netconfPort;
+ }
+
+ public List<Topology> getTopology() {
+ return topology;
+ }
+
+ public void setTopology(List<Topology> topology) {
+ this.topology = topology;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/Topology.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/Topology.java
new file mode 100644
index 0000000..b99f64a
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/Topology.java
@@ -0,0 +1,96 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.websocket.model;
+
+import java.util.List;
+
+public class Topology {
+
+ private String pnfName;
+
+ private long pciId;
+
+ private String cellId;
+
+ private List<Neighbor> neighborList;
+
+ public long getPciId() {
+ return pciId;
+ }
+
+ public void setPciId(long pciId) {
+ this.pciId = pciId;
+ }
+
+ public String getCellId() {
+ return cellId;
+ }
+
+ public void setCellId(String cellId) {
+ this.cellId = cellId;
+ }
+
+ public List<Neighbor> getNeighborList() {
+ return neighborList;
+ }
+
+ public void setNeighborList(List<Neighbor> neighborList) {
+ this.neighborList = neighborList;
+ }
+
+ @Override
+ public String toString() {
+ return "Topology [PnfName = " + pnfName + ", PciId = " + pciId + ", cellId = " + cellId + ", neighborList = "
+ + neighborList + "]";
+ }
+
+ /**
+ * Contails the necessary cell details.
+ *
+ * @param pnfName
+ * server id name
+ * @param pciId
+ * pci number
+ * @param cellId
+ * node id for the cel
+ * @param neighborList
+ * neighbor list for the cell
+ */
+ public Topology(String pnfName, long pciId, String cellId, List<Neighbor> neighborList) {
+ super();
+ this.pnfName = pnfName;
+ this.pciId = pciId;
+ this.cellId = cellId;
+ this.neighborList = neighborList;
+ }
+
+ public Topology() {
+ }
+
+ public String getPnfName() {
+ return pnfName;
+ }
+
+ public void setPnfName(String pnfName) {
+ this.pnfName = pnfName;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/UpdateCell.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/UpdateCell.java
new file mode 100644
index 0000000..5794fb1
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/model/UpdateCell.java
@@ -0,0 +1,85 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.websocket.model;
+
+public class UpdateCell {
+
+ private String serverId;
+ private String ip;
+ private String netconfPort;
+ Topology oneCell;
+
+ public UpdateCell() {
+ }
+
+ public String getServerId() {
+ return serverId;
+ }
+
+ public void setServerId(String serverId) {
+ this.serverId = serverId;
+ }
+
+ public String getIp() {
+ return ip;
+ }
+
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ public String getNetconfPort() {
+ return netconfPort;
+ }
+
+ public void setNetconfPort(String netconfPort) {
+ this.netconfPort = netconfPort;
+ }
+
+ public Topology getOneCell() {
+ return oneCell;
+ }
+
+ public void setOneCell(Topology oneCell) {
+ this.oneCell = oneCell;
+ }
+
+ /**
+ * Update cell details based on input.
+ *
+ * @param serverId
+ * netconf server id
+ * @param ip
+ * ip address
+ * @param netconfPort
+ * port number
+ * @param oneCell
+ * topology details
+ */
+ public UpdateCell(String serverId, String ip, String netconfPort, Topology oneCell) {
+ super();
+ this.serverId = serverId;
+ this.ip = ip;
+ this.netconfPort = netconfPort;
+ this.oneCell = oneCell;
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/server/RansimWebSocketServer.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/server/RansimWebSocketServer.java
new file mode 100644
index 0000000..db94bfd
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/server/RansimWebSocketServer.java
@@ -0,0 +1,222 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.websocket.server;
+
+import java.io.IOException;
+
+import javax.websocket.CloseReason;
+import javax.websocket.OnClose;
+import javax.websocket.OnMessage;
+import javax.websocket.OnOpen;
+import javax.websocket.Session;
+import javax.websocket.server.PathParam;
+import javax.websocket.server.ServerEndpoint;
+import javax.websocket.EncodeException;
+
+import org.apache.log4j.Logger;
+import org.onap.ransim.rest.api.controller.RansimController;
+import org.onap.ransim.websocket.model.DeviceData;
+import org.onap.ransim.websocket.model.DeviceDataDecoder;
+import org.onap.ransim.websocket.model.DeviceDataEncoder;
+import org.onap.ransim.websocket.model.MessageTypes;
+
+@ServerEndpoint(value = "/RansimAgent/{IpPort}", encoders = { DeviceDataEncoder.class }, decoders = { DeviceDataDecoder.class })
+public class RansimWebSocketServer {
+
+ static Logger log = Logger.getLogger(RansimWebSocketServer.class.getName());
+
+ /**
+ * Set of actions to be done when connection is opened.
+ *
+ * @param session
+ * Session details
+ * @param ipPort
+ * ip address of the agent
+ */
+ @OnOpen
+ public void onOpen(Session session, @PathParam("IpPort") String ipPort) {
+ log.info("WSS Ransim client(" + ipPort + ") opened a connection with id " + session.getId());
+ try {
+ String serverId = RansimController.getRansimController().addWebSocketSessions(ipPort,
+ session);
+ if (serverId != null) {
+ log.info("New websocket session added for " + serverId);
+ RansimController.getRansimController().sendInitialConfigForNewAgent(ipPort,
+ serverId);
+ } else {
+ log.info("RansimWebSocketServer: No assigned ServerId found - No intial configuration sent to New Agent "
+ + ipPort);
+ }
+ } catch (Exception e) {
+ log.info("Exception in onOpen:", e);
+ }
+ }
+
+ /*
+ @OnMessage
+ public void onMessage(String messageStr, Session session, @PathParam("IpPort") String ipPort) {
+ log.info("WSS Str Message received from client(" + ipPort + ") with id " + session.getId());
+ try {
+ if (messageStr != null) {
+ DeviceData message = new DeviceDataDecoder().decode(messageStr);
+ if (message.getMessage() == null || message.getMessage().trim().equals("")) {
+ log.debug("Periodic ping message.... ignore");
+ return;
+ } else {
+
+ if (message.getType().equals(MessageTypes.HC_TO_RC_MODPCI)) {
+ RansimController.getRansimController().handleModifyPciFromSdnr(
+ message.getMessage(), session, ipPort);
+ } else if (message.getType().equals(MessageTypes.HC_TO_RC_MODANR)) {
+ RansimController.getRansimController().handleModifyNeighborFromSdnr(
+ message.getMessage(), session, ipPort);
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.info("Exception in onMessage:", e);
+ }
+ }
+ */
+
+
+ /**
+ * Handles the message sent from the agent.
+ *
+ * @param message
+ * message sent from the agent
+ * @param session
+ * session details
+ * @param ipPort
+ * ip address
+ * public void onMessage(DeviceData message, Session session, @PathParam("IpPort") String ipPort) {
+ */
+ @OnMessage
+ public void onMessage(final DeviceData message, final Session session, @PathParam("IpPort") String ipPort)
+ throws IOException, EncodeException {
+ log.info("WSS Obj Message received from client(" + ipPort + ") with id " + session.getId());
+ try {
+ if (message != null) {
+ if (message.getMessage() == null || message.getMessage().trim().equals("")) {
+ log.debug("Periodic ping message.... ignore");
+ return;
+ } else {
+
+ if (message.getType().equals(MessageTypes.HC_TO_RC_MODPCI)) {
+ log.info("Modify pci message received");
+ RansimController.getRansimController().handleModifyPciFromSdnr(
+ message.getMessage(), session, ipPort);
+ } else if (message.getType().equals(MessageTypes.HC_TO_RC_MODANR)) {
+ log.info("Modify anr message received");
+ RansimController.getRansimController().handleModifyNeighborFromSdnr(
+ message.getMessage(), session, ipPort);
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.info("Exception in onMessage:", e);
+ }
+ }
+
+ /**
+ * Set of actions to be done when connection is closed.
+ *
+ * @param reason
+ * reason the session was closed
+ * @param session
+ * session details
+ * @param ipPort
+ * ip address
+ */
+ @OnClose
+ public void onClose(CloseReason reason, Session session, @PathParam("IpPort") String ipPort) {
+ try {
+ log.info("WSS Closing client(" + ipPort + ") cxn with id " + session.getId() + "due to " + reason.getReasonPhrase());
+ RansimController.getRansimController().removeWebSocketSessions(ipPort);
+ } catch (Exception e) {
+ log.info("Exception in onClose:", e);
+ }
+ }
+
+ public static void sendUpdateCellMessage(String str, Session session) {
+ DeviceData data = new DeviceData();
+ data.setType(MessageTypes.RC_TO_HC_UPDCELL);
+ data.setMessage(str);
+ try {
+ sendMessage(data, session);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void sendPmMessage(String str, Session session) {
+ DeviceData data = new DeviceData();
+ data.setType(MessageTypes.RC_TO_HC_PMDATA);
+ data.setMessage(str);
+ log.info("data.setMessage: " + data.getMessage());
+ try {
+ sendMessage(data, session);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void sendFmMessage(String str, Session session) {
+ DeviceData data = new DeviceData();
+ data.setType(MessageTypes.RC_TO_HC_FMDATA);
+ data.setMessage(str);
+ try {
+ sendMessage(data, session);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void sendSetConfigTopologyMessage(String str, Session session) {
+ DeviceData data = new DeviceData();
+ data.setType(MessageTypes.RC_TO_HC_SETCONFIGTOPO);
+ data.setMessage(str);
+ try {
+ sendMessage(data, session);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void sendPingMessage(Session session) {
+ DeviceData data = new DeviceData();
+ data.setType(MessageTypes.RC_TO_HC_PING);
+ data.setMessage("");
+ try {
+ sendMessage(data, session);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static void sendMessage(DeviceData data, Session session) {
+ try {
+ session.getBasicRemote().sendObject(data);
+ } catch (Exception e) {
+ log.info("Exception in sendMessage:", e);
+ }
+ }
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/resources/META-INF/persistence.xml b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..bbfb0f3
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ONAP-PAP-REST
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+ version="2.0">
+ <persistence-unit name="ransimctrlrdb" transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+ <class>org.onap.ransim.rest.api.models.CellDetails</class>
+ <class>org.onap.ransim.rest.api.models.CellNeighbor</class>
+ <class>org.onap.ransim.rest.api.models.NetconfServers</class>
+ <class>org.onap.ransim.rest.api.models.OperationLog</class>
+ <class>org.onap.ransim.rest.api.models.NeighborDetails</class>
+
+ <properties>
+ <property name="javax.persistence.jdbc.driver" value="org.mariadb.jdbc.Driver" />
+ <property name="javax.persistence.jdbc.url" value="jdbc:mariadb://mariadb:3306/ransim_db"/>
+ <property name="javax.persistence.jdbc.user" value="root"/>
+ <property name="javax.persistence.jdbc.password" value="secret"/>
+ <property name="eclipselink.target-database" value="MySQL"/>
+ <property name="eclipselink.ddl-generation" value="create-or-extend-tables"/>
+ <property name="eclipselink.logging.level" value="FINEST"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/resources/log4j.properties b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/resources/log4j.properties
new file mode 100644
index 0000000..6042e35
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/resources/log4j.properties
@@ -0,0 +1,50 @@
+###
+# ============LICENSE_START=======================================================
+# ================================================================================
+# Copyright (C) 2020 Wipro Limited 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=========================================================
+###
+
+#
+# Use this properties for Deployments.
+#
+# Set root logger level to DEBUG and its only appender to FILE.
+log4j.rootLogger=DEBUG, FILE , CONSOLE
+
+# FILE appender
+log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.FILE.File=${catalina.base}/logs/ransim-rest.log
+log4j.appender.FILE.ImmediateFlush=true
+log4j.appender.FILE.Threshold=debug
+log4j.appender.FILE.append=true
+log4j.appender.FILE.DatePattern='.'yyyy-MM-dd
+log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
+log4j.appender.FILE.layout.ConversionPattern=%d{yyyy-MM-dd'T'HH:mm:ss}{GMT+0}+00:00|%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{instanceUuid}|%p|%X{severity}|%X{serverIpAddress}|%X{server}|%X{clientIpAddress}|%l||%m%n
+
+# for Developments and Debugging
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy_MM_dd_HH_mm_ss_SSS} [%t] %-5p %l- %m%n
+
+log4j.logger.auditLogger=DEBUG,AUDIT_LOG
+log4j.additivity.auditLogger=false
+
+log4j.appender.AUDIT_LOG=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.AUDIT_LOG.File=${catalina.base}/logs/audit.log
+log4j.appender.AUDIT_LOG.Append=true
+log4j.appender.AUDIT_LOG.DatePattern='.'yyyy-MM-dd
+log4j.appender.AUDIT_LOG.threshold=INFO
+log4j.appender.AUDIT_LOG.layout=org.apache.log4j.EnhancedPatternLayout
+log4j.appender.AUDIT_LOG.layout.ConversionPattern=%d{yyyy-MM-dd'T'HH:mm:ss}{GMT+0}+00:00|%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{instanceUuid}|%p|%X{severity}|%X{serverIpAddress}|%X{server}|%X{clientIpAddress}|%X{className}|%X{timer}|%m%n
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/resources/logback.xml b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/resources/logback.xml
new file mode 100644
index 0000000..fd36dc1
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/resources/logback.xml
@@ -0,0 +1,242 @@
+<!--
+ ============LICENSE_START=======================================================
+ ================================================================================
+ Copyright (C) 2020 Wipro Limited 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=========================================================
+ -->
+
+<configuration scan="true" scanPeriod="3 seconds" debug="true">
+ <!--<jmxConfigurator /> -->
+ <!-- directory path for all other type logs -->
+ <property name="logDir" value="logs" />
+
+ <!-- directory path for debugging type logs -->
+ <property name="debugDir" value="logs" />
+
+ <!-- specify the component name
+ <ONAP-component-name>::= "MSO" | "DCAE" | "ASDC " | "AAI" |"Policy" | "SDNC" | "AC" -->
+ <property name="componentName" value="Policy"></property>
+
+ <!-- log file names -->
+ <property name="errorLogName" value="error2" />
+ <property name="metricsLogName" value="metrics2" />
+ <property name="auditLogName" value="audit2" />
+ <property name="debugLogName" value="debug2" />
+
+
+ <!-- modified time stamp format -->
+
+ <!-- A U D I T
+ <property name="defaultAuditPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
+ <property name="defaultAuditPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{instanceUuid}|%p|%X{severity}|%X{serverIpAddress}|%X{ElapsedTime}|%X{server}|%X{clientIpAddress}|%c||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
+ -->
+ <property name="defaultAuditPattern" value="%X{TransactionBeginTimestamp}|%X{TransactionEndTimestamp}|%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{instanceUuid}|%p|%X{severity}|%X{serverIpAddress}|%X{TransactionElapsedTime}|%X{server}|%X{clientIpAddress}|%c||%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
+
+
+
+ <!-- M E T R I C
+ <property name="defaultMetricPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
+ -->
+ <property name="defaultMetricPattern" value="%X{MetricBeginTimestamp}|%X{MetricEndTimestamp}|%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%X{statusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%p|%X{severity}|%X{serverIpAddress}|%X{MetricElapsedTime}|%X{server}|%X{clientIpAddress}|%c||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
+
+
+
+ <!-- E R R O R
+ <property name="defaultErrorPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%X{RequestId}|%thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{ErrorCategory}|%X{ErrorCode}|%X{ErrorDesciption}|%msg%n" />
+ -->
+ <property name="defaultErrorPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%X{requestId}|%t|%X{serviceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{ErrorCategory}|%X{ErrorCode}|%X{ErrorDesciption}|%msg%n" />
+
+
+
+ <!-- D E B U G
+ <property name="debugLoggerPatternOld" value="%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{Timer}|[%caller{3}]|%msg%n" />
+ <property name="debugLoggerPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" /> -->
+ -->
+ <property name="debugLoggerPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%X{RequestId}|%msg%n" />
+
+
+
+ <!-- D E F A U L T
+ <property name="defaultPatternOld" value="%d{MM/dd-HH:mm:ss.SSS}|%logger|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Timer}|%msg%n" />
+ <property name="defaultPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
+ -->
+ <property name="defaultPattern" value="%d{&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&quot;, UTC}|%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{instanceUuid}|%p|%X{severity}|%X{serverIpAddress}|%X{server}|%X{clientIpAddress}|%c||%msg%n" />
+
+
+
+ <!-- P A T H
+ <property name="logDirectory" value="${logDir}/${componentName}/${subComponentName}" />
+ <property name="debugLogDirectory" value="${debugDir}/${componentName}/${subComponentName}" />
+
+ -->
+ <property name="logDirectory" value="${catalina.base}/${logDir}/${componentName}/${subComponentName}" />
+ <property name="debugLogDirectory" value="${catalina.base}/${debugDir}/${componentName}/${subComponentName}" />
+
+
+
+
+ <!-- Example evaluator filter applied against console appender -->
+ <appender name="STDOUT" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <appender-ref ref="EELFError"/>
+ </appender>
+
+ <!-- ============================================================================ -->
+ <!-- EELF Appenders -->
+ <!-- ============================================================================ -->
+
+ <!-- The EELFAppender is used to record events to the general application
+ log -->
+
+ <!-- EELF Audit Appender. This appender is used to record audit engine
+ related logging events. The audit logger and appender are specializations
+ of the EELF application root logger and appender. This can be used to segregate
+ Policy engine events from other components, or it can be eliminated to record
+ these events as part of the application root log. -->
+
+ <appender name="EELFAudit"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDirectory}/${auditLogName}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/${auditLogName}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
+
+ <!-- keep 30 days' worth of history capped at 3GB total size -->
+ <maxFileSize>50MB</maxFileSize>
+ <maxHistory>30</maxHistory>
+ <totalSizeCap>10GB</totalSizeCap>
+ </rollingPolicy>
+
+ <encoder>
+ <pattern>${defaultAuditPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="asyncEELFAudit" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>256</queueSize>
+ <appender-ref ref="EELFAudit" />
+ </appender>
+
+
+
+
+<appender name="EELFMetrics"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDirectory}/${metricsLogName}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/${metricsLogName}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
+
+ <!-- keep 30 days' worth of history capped at 3GB total size -->
+ <maxFileSize>50MB</maxFileSize>
+ <maxHistory>30</maxHistory>
+ <totalSizeCap>10GB</totalSizeCap>
+ </rollingPolicy>
+
+ <encoder>
+ <pattern>${defaultMetricPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="asyncEELFMetrics" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>256</queueSize>
+ <appender-ref ref="EELFMetrics"/>
+ </appender>
+
+
+
+
+ <appender name="EELFError"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDirectory}/${errorLogName}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/${errorLogName}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
+
+ <!-- keep 30 days' worth of history capped at 3GB total size -->
+ <maxFileSize>50MB</maxFileSize>
+ <maxHistory>30</maxHistory>
+ <totalSizeCap>10GB</totalSizeCap>
+ </rollingPolicy>
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>ERROR</level>
+ </filter>
+ <encoder>
+ <pattern>${defaultErrorPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="asyncEELFError" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>256</queueSize>
+ <appender-ref ref="EELFError"/>
+ </appender>
+
+
+
+ <appender name="EELFDebug"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${debugLogDirectory}/${debugLogName}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${debugLogDirectory}/${debugLogName}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
+
+ <!-- keep 30 days' worth of history capped at 3GB total size -->
+ <maxFileSize>50MB</maxFileSize>
+ <maxHistory>30</maxHistory>
+ <totalSizeCap>10GB</totalSizeCap>
+ </rollingPolicy>
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>DEBUG</level>
+ </filter>
+
+ <encoder>
+ <pattern>${debugLoggerPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="asyncEELFDebug" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>256</queueSize>
+ <appender-ref ref="EELFDebug" />
+ <includeCallerData>true</includeCallerData>
+ </appender>
+
+
+ <!-- ============================================================================ -->
+ <!-- EELF loggers -->
+ <!-- ============================================================================ -->
+
+ <logger name="com.att.eelf.audit" level="info" additivity="false">
+ <appender-ref ref="asyncEELFAudit" />
+ </logger>
+
+ <logger name="com.att.eelf.metrics" level="info" additivity="false">
+ <appender-ref ref="asyncEELFMetrics" />
+ </logger>
+
+ <logger name="com.att.eelf.error" level="error" additivity="false">
+ <appender-ref ref="asyncEELFError" />
+ </logger>
+
+ <logger name="com.att.eelf.debug" level="info" additivity="false">
+ <appender-ref ref="asyncEELFDebug" />
+ </logger>
+
+
+
+ <root level="DEBUG">
+ <appender-ref ref="asyncEELFDebug" />
+ <appender-ref ref="asyncEELFError" />
+ </root>
+
+</configuration>
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimController.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimController.java
new file mode 100644
index 0000000..ff88afa
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimController.java
@@ -0,0 +1,262 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.ransim.rest.api.controller;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import mockit.Mock;
+import mockit.MockUp;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+//import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.ransim.rest.api.models.CellDetails;
+import org.onap.ransim.rest.api.models.CellNeighbor;
+import org.onap.ransim.rest.api.models.FmAlarmInfo;
+import org.onap.ransim.rest.api.models.GetNeighborList;
+import org.onap.ransim.rest.api.models.NeighborDetails;
+import org.onap.ransim.rest.api.models.NeihborId;
+import org.onap.ransim.rest.api.models.NetconfServers;
+import org.onap.ransim.rest.client.RestClient;
+import org.onap.ransim.websocket.model.CommonEventHeaderFm;
+import org.onap.ransim.websocket.model.EventFm;
+import org.onap.ransim.websocket.model.FaultFields;
+import org.springframework.context.annotation.PropertySource;
+
+import com.google.gson.Gson;
+
+/**
+ * @author ubuntu16
+ *
+ */
+@RunWith(MockitoJUnitRunner.class)
+@PropertySource("classpath:ransim.properties")
+public class TestRansimController {
+ @Test
+ public void testGetRansimController() {
+
+ RansimController rc = RansimController.getRansimController();
+ assertNotNull(rc);
+ }
+
+ @Test
+ public void testsetNetconfServers() {
+ // fail("Not yet implemented");
+ RansimController rscontroller = Mockito.mock(RansimController.class);
+ CellDetails cell1 = new CellDetails("Chn01", 1, "nc1");
+ CellDetails cell2 = new CellDetails("Chn02", 2, "nc1");
+ CellDetails cell3 = new CellDetails("Chn03", 3, "nc1");
+ CellDetails cell4 = new CellDetails("Chn04", 4, "nc1");
+
+ Set<CellDetails> cells = new HashSet<CellDetails>();
+ cells.add(cell1);
+ cells.add(cell2);
+ cells.add(cell3);
+
+ NetconfServers server = new NetconfServers("nc1", null, null, cells);
+
+ new MockUp<RansimControllerDatabase>() {
+ @Mock
+ NetconfServers getNetconfServer(String serverId) {
+
+ return server;
+ }
+ };
+ new MockUp<RansimControllerDatabase>() {
+ @Mock
+ CellDetails getCellDetail(String nodeId) {
+
+ return cell4;
+ }
+ };
+ new MockUp<RansimControllerDatabase>() {
+ @Mock
+ void mergeNetconfServers(NetconfServers netconfServers) {
+
+ }
+ };
+
+ rscontroller.setNetconfServers("Chn04");
+
+ boolean check = server.getCells().contains(cell4);
+
+ assertTrue(check);
+
+ }
+
+ @Test
+ public void testGenerateNeighborList() {
+ // fail("Not yet implemented");
+ RansimController rscontroller = Mockito.mock(RansimController.class);
+ Set<NeighborDetails> neighborList = new HashSet<NeighborDetails>();
+ NeighborDetails nbr1 = new NeighborDetails(new NeihborId("Chn00", "Chn01"), false);
+ NeighborDetails nbr2 = new NeighborDetails(new NeihborId("Chn00", "Chn02"), false);
+ NeighborDetails nbr3 = new NeighborDetails(new NeihborId("Chn00", "Chn03"), true);
+
+ neighborList.add(nbr1);
+ neighborList.add(nbr2);
+ neighborList.add(nbr3);
+
+ CellDetails cell0 = new CellDetails("Chn00", 4, "nc1");
+ CellDetails cell1 = new CellDetails("Chn01", 1, "nc1");
+ CellDetails cell2 = new CellDetails("Chn02", 2, "nc1");
+ CellDetails cell3 = new CellDetails("Chn03", 3, "nc1");
+
+ CellNeighbor cellNbr = new CellNeighbor();
+ cellNbr.setNodeId("Chn00");
+ cellNbr.setNeighborList(neighborList);
+
+ new MockUp<RansimControllerDatabase>() {
+ @Mock
+ CellNeighbor getCellNeighbor(String nodeId) {
+ if (nodeId.equals("Chn00")) {
+ return cellNbr;
+ } else {
+ return null;
+ }
+
+ }
+ };
+
+ new MockUp<RansimControllerDatabase>() {
+ @Mock
+ CellDetails getCellDetail(String nodeId) {
+ if (nodeId.equals("Chn00")) {
+ return cell0;
+ } else if (nodeId.equals("Chn01")) {
+ return cell1;
+ } else if (nodeId.equals("Chn02")) {
+ return cell2;
+ } else if (nodeId.equals("Chn03")) {
+ return cell3;
+ } else {
+ return null;
+ }
+
+ }
+ };
+
+ /*
+ * GetNeighborList nbrListFct = rscontroller.generateNeighborList("Chn00");
+ *
+ * boolean result = false;
+ *
+ * if (nbrListFct.getCellsWithHo().contains(cell1)) { if
+ * (nbrListFct.getCellsWithHo().contains(cell2)) { if
+ * (nbrListFct.getCellsWithNoHo().contains(cell3)) { result = true; } } }
+ *
+ * assertTrue(result);
+ */
+
+ }
+
+ @Test
+ public void testSetEventFm() {
+ // fail("Not yet implemented");
+ RansimController rscontroller = Mockito.mock(RansimController.class);
+ Map<String, String> alarmAdditionalInformation = new HashMap<String, String>();
+ alarmAdditionalInformation.put("networkId", "abc");
+ alarmAdditionalInformation.put("collisions", "1");
+ alarmAdditionalInformation.put("confusions", "0");
+ CommonEventHeaderFm commonEventHeader = new CommonEventHeaderFm("Chn00", "", "nc1", 0, 0);
+ FaultFields faultFields = new FaultFields("RanPciCollisionConfusionOccurred", "other", "Collision", "CRITICAL",
+ alarmAdditionalInformation);
+ EventFm checkObj = new EventFm(commonEventHeader, faultFields);
+
+ new MockUp<RansimController>() {
+ @Mock
+ String getUuid() {
+ return "";
+ }
+ };
+ new MockUp<System>() {
+ @Mock
+ public long currentTimeMillis() {
+ return (long) 0;
+ }
+ };
+
+ String networkId = "abc";
+ String ncServer = "nc1";
+ String cellId = "Chn00";
+ FmAlarmInfo issue = new FmAlarmInfo("Collision", "1", "0");
+ /*
+ * EventFm eventObj = rscontroller.setEventFm(networkId, ncServer, cellId,
+ * issue);
+ *
+ * boolean result = false;
+ *
+ * Gson gson = new Gson(); String eventStr = gson.toJson(eventObj); String
+ * checkStr = gson.toJson(checkObj);
+ *
+ * System.out.println("eventStr: " + eventStr); System.out.println("checkStr: "
+ * + checkStr);
+ *
+ * if (eventStr.equals(checkStr)) { result = true; }
+ *
+ * assertTrue(result);
+ */
+ }
+
+
+
+ //@Test
+ public void testStopAllCells() {
+ RansimController rscontroller = Mockito.mock(RansimController.class);
+
+ new MockUp<RansimControllerDatabase>() {
+ @Mock
+ List<NetconfServers> getNetconfServersList() {
+ System.out.println("getNetconfServersList");
+ List<NetconfServers> ns = new ArrayList<NetconfServers>();
+ NetconfServers n1 = new NetconfServers("nc1", null, null, null);
+ NetconfServers n2 = new NetconfServers("nc2", null, null, null);
+ ns.add(n1);
+ ns.add(n2);
+ return ns;
+ }
+ };
+
+ new MockUp<RestClient>() {
+ @Mock
+ public String sendUnmountRequestToSdnr(String serverId, String ip, int port, String sdnrUsername,
+ String sdnrPassword) {
+ System.out.println("sendUnmountRequestToSdnr");
+ return "";
+ }
+ };
+
+ String result = rscontroller.stopAllCells();
+ System.out.println("testStopAllCells: " + result);
+ assertEquals("Netconf servers unmounted.", result);
+ }
+
+} \ No newline at end of file
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimControllerServices.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimControllerServices.java
new file mode 100644
index 0000000..af3659e
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/controller/TestRansimControllerServices.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.controller;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.TypedQuery;
+
+import mockit.Mock;
+import mockit.MockUp;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.ransim.rest.api.models.CellDetails;
+import org.springframework.http.ResponseEntity;
+
+public class TestRansimControllerServices {
+
+ @Test
+ public void testGetOperationLog() {
+ ResponseEntity<String> rsEntity = Mockito.mock(ResponseEntity.class);
+
+ EntityManagerFactory emfactory = Mockito.mock(EntityManagerFactory.class);
+ EntityManager entityManager = Mockito.mock(EntityManager.class);
+ Mockito.when(emfactory.createEntityManager()).thenReturn(entityManager);
+
+ TypedQuery<CellDetails> query = Mockito.mock(TypedQuery.class);
+ Mockito.when(entityManager.createQuery("from CellDetails cd", CellDetails.class)).thenReturn(query);
+
+ List<CellDetails> cellDetailList = new ArrayList<CellDetails>();
+ Mockito.when(query.getResultList()).thenReturn(cellDetailList);
+ assertNotNull(rsEntity);
+
+ }
+
+ @Test
+ public void testModifyACell() {
+
+ ResponseEntity<String> rsEntity = Mockito.mock(ResponseEntity.class);
+
+ EntityManagerFactory emfactory = Mockito.mock(EntityManagerFactory.class);
+ EntityManager entityManager = Mockito.mock(EntityManager.class);
+ Mockito.when(emfactory.createEntityManager()).thenReturn(entityManager);
+
+ TypedQuery<CellDetails> query = Mockito.mock(TypedQuery.class);
+ Mockito.when(entityManager.createQuery("from CellDetails cd", CellDetails.class)).thenReturn(query);
+
+
+ }
+
+
+} \ No newline at end of file
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/models/TestApiModels.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/models/TestApiModels.java
new file mode 100644
index 0000000..b9e24fd
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/java/org/onap/ransim/rest/api/models/TestApiModels.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Ran Simulator Controller
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ransim.rest.api.models;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.onap.ransim.rest.api.models.CellDetails;
+import org.onap.ransim.rest.api.models.ModifyACellReq;
+import org.onap.ransim.rest.api.models.NetconfServers;
+
+public class TestApiModels {
+
+ @Test
+ public void testsetNewPhysicalCellId() {
+ ModifyACellReq mcell = new ModifyACellReq();
+ mcell.setNewPhysicalCellId(001L);
+ assertTrue(mcell.getNewPhysicalCellId() == 001);
+ }
+
+ @Test
+ public void testsetNewPhysicalCellId1() {
+ ModifyACellReq mcell = new ModifyACellReq();
+ mcell.setNewPhysicalCellId(000L);
+ assertFalse(mcell.getNewPhysicalCellId() == 001);
+ }
+
+ @Test
+ public void testsetNetworkId() {
+ CellDetails cd = new CellDetails();
+ cd.setNetworkId("Ns001");
+ assertTrue(cd.getNetworkId() == "Ns001");
+ }
+
+ @Test
+ public void testsetServerId() {
+ NetconfServers ns = new NetconfServers();
+ ns.setServerId("ns0031");
+ assertTrue(ns.getServerId() == "ns0031");
+ }
+
+}
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/test/resources/META-INF/persistence.xml b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..1e194c6
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/resources/META-INF/persistence.xml
@@ -0,0 +1,43 @@
+<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
+ http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
+ version="2.1">
+
+ <persistence-unit name="templatePU" transaction-type="RESOURCE_LOCAL">
+
+ <description>Hibernate test case template Persistence Unit</description>
+ <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
+
+ <exclude-unlisted-classes>false</exclude-unlisted-classes>
+
+ <properties>
+ <property name="hibernate.archive.autodetection" value="class, hbm"/>
+
+ <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
+ <property name="hibernate.connection.driver_class" value="org.h2.Driver"/>
+ <property name="hibernate.connection.url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1"/>
+ <property name="hibernate.connection.username" value="sa"/>
+
+ <property name="hibernate.connection.pool_size" value="5"/>
+
+ <property name="hibernate.show_sql" value="true"/>
+ <property name="hibernate.format_sql" value="true"/>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+
+ <property name="hibernate.max_fetch_depth" value="5"/>
+
+ <property name="hibernate.cache.region_prefix" value="hibernate.test"/>
+ <property name="hibernate.cache.region.factory_class"
+ value="org.hibernate.testing.cache.CachingRegionFactory"/>
+
+ <!--NOTE: hibernate.jdbc.batch_versioned_data should be set to false when testing with Oracle-->
+ <property name="hibernate.jdbc.batch_versioned_data" value="true"/>
+
+ <property name="javax.persistence.validation.mode" value="NONE"/>
+ <property name="hibernate.service.allow_crawling" value="false"/>
+ <property name="hibernate.session.events.log" value="true"/>
+ </properties>
+
+ </persistence-unit>
+</persistence>
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/test/resources/hibernate.properties b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/resources/hibernate.properties
new file mode 100644
index 0000000..9b7d955
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/resources/hibernate.properties
@@ -0,0 +1,29 @@
+#
+# Hibernate, Relational Persistence for Idiomatic Java
+#
+# License: GNU Lesser General Public License (LGPL), version 2.1 or later.
+# See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
+#
+
+hibernate.dialect org.hibernate.dialect.H2Dialect
+hibernate.connection.driver_class org.h2.Driver
+#hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE
+hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1
+hibernate.connection.username sa
+
+hibernate.connection.pool_size 5
+
+hibernate.show_sql false
+hibernate.format_sql true
+
+hibernate.max_fetch_depth 5
+
+hibernate.cache.region_prefix hibernate.test
+hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
+
+# NOTE: hibernate.jdbc.batch_versioned_data should be set to false when testing with Oracle
+hibernate.jdbc.batch_versioned_data true
+
+javax.persistence.validation.mode=NONE
+hibernate.service.allow_crawling=false
+hibernate.session.events.log=true \ No newline at end of file
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/test/resources/log4j.properties b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/resources/log4j.properties
new file mode 100644
index 0000000..d42ce42
--- /dev/null
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/test/resources/log4j.properties
@@ -0,0 +1,8 @@
+# Root logger option
+log4j.rootLogger=INFO, stdout
+
+# Direct log messages to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n