[UI] Common class for results 84/1584/2
authorIoakeim Samaras <ioakeim.samaras@ericsson.com>
Mon, 16 Sep 2019 12:57:59 +0000 (15:57 +0300)
committerIoakeim Samaras <ioakeim.samaras@ericsson.com>
Mon, 16 Sep 2019 14:03:38 +0000 (17:03 +0300)
A common class for Nexus and database results
is used.

JIRA: VAL-49

Signed-off-by: Ioakeim Samaras <ioakeim.samaras@ericsson.com>
Change-Id: I62e68091b0a978d721f6468a7b2bf73d899c4027

63 files changed:
.coafile
ui/CHANGELOG.md
ui/README.rst
ui/db-scripts/akraino_blueprint_validation_db.sql
ui/db-scripts/examples/initialize_db_example.sql
ui/pom.xml
ui/src/main/java/org/akraino/validation/ui/client/nexus/NexusExecutorClient.java
ui/src/main/java/org/akraino/validation/ui/client/nexus/resources/ValidationNexusTestResult.java [deleted file]
ui/src/main/java/org/akraino/validation/ui/client/nexus/resources/WRobotNexusTestResult.java
ui/src/main/java/org/akraino/validation/ui/conf/ValidationTestResultsGetter.java [moved from ui/src/main/java/org/akraino/validation/ui/conf/ValidationNexusTestResultsGetter.java with 56% similarity]
ui/src/main/java/org/akraino/validation/ui/controller/BlueprintInstanceController.java [moved from ui/src/main/java/org/akraino/validation/ui/controller/BlueprintInstanceForValidationController.java with 74% similarity]
ui/src/main/java/org/akraino/validation/ui/controller/LabController.java [moved from ui/src/main/java/org/akraino/validation/ui/controller/SiloController.java with 75% similarity]
ui/src/main/java/org/akraino/validation/ui/controller/ResultController.java
ui/src/main/java/org/akraino/validation/ui/controller/SubmissionController.java
ui/src/main/java/org/akraino/validation/ui/dao/BlueprintDAO.java
ui/src/main/java/org/akraino/validation/ui/dao/BlueprintInstanceDAO.java [moved from ui/src/main/java/org/akraino/validation/ui/dao/BlueprintInstanceForValidationDAO.java with 58% similarity]
ui/src/main/java/org/akraino/validation/ui/dao/BlueprintLayerDAO.java [moved from ui/src/main/java/org/akraino/validation/ui/dao/SiloDAO.java with 63% similarity]
ui/src/main/java/org/akraino/validation/ui/dao/LabDAO.java
ui/src/main/java/org/akraino/validation/ui/dao/ValidationTestResultDAO.java
ui/src/main/java/org/akraino/validation/ui/daoimpl/BlueprintDAOImpl.java
ui/src/main/java/org/akraino/validation/ui/daoimpl/BlueprintInstanceDAOImpl.java [moved from ui/src/main/java/org/akraino/validation/ui/daoimpl/BlueprintInstanceForValidationDAOImpl.java with 52% similarity]
ui/src/main/java/org/akraino/validation/ui/daoimpl/BlueprintLayerDAOImpl.java [new file with mode: 0644]
ui/src/main/java/org/akraino/validation/ui/daoimpl/LabDAOImpl.java
ui/src/main/java/org/akraino/validation/ui/daoimpl/SiloDAOImpl.java [deleted file]
ui/src/main/java/org/akraino/validation/ui/daoimpl/SubmissionDAOImpl.java
ui/src/main/java/org/akraino/validation/ui/daoimpl/TimeslotDAOImpl.java
ui/src/main/java/org/akraino/validation/ui/daoimpl/ValidationTestResultDAOImpl.java
ui/src/main/java/org/akraino/validation/ui/daoimpl/WRobotTestResultDAOImpl.java
ui/src/main/java/org/akraino/validation/ui/data/BlueprintLayer.java [deleted file]
ui/src/main/java/org/akraino/validation/ui/data/Lab.java [deleted file]
ui/src/main/java/org/akraino/validation/ui/data/SubmissionData.java [deleted file]
ui/src/main/java/org/akraino/validation/ui/entity/Blueprint.java
ui/src/main/java/org/akraino/validation/ui/entity/BlueprintInstance.java [moved from ui/src/main/java/org/akraino/validation/ui/entity/BlueprintInstanceForValidation.java with 68% similarity]
ui/src/main/java/org/akraino/validation/ui/entity/BlueprintLayer.java [moved from ui/src/main/java/org/akraino/validation/ui/entity/LabSilo.java with 63% similarity]
ui/src/main/java/org/akraino/validation/ui/entity/LabInfo.java
ui/src/main/java/org/akraino/validation/ui/entity/Submission.java
ui/src/main/java/org/akraino/validation/ui/entity/Timeslot.java
ui/src/main/java/org/akraino/validation/ui/entity/ValidationDbTestResult.java
ui/src/main/java/org/akraino/validation/ui/entity/WRobotDbTestResult.java
ui/src/main/java/org/akraino/validation/ui/service/BlueprintInstanceService.java [moved from ui/src/main/java/org/akraino/validation/ui/service/BlueprintInstanceForValidationService.java with 59% similarity]
ui/src/main/java/org/akraino/validation/ui/service/BlueprintLayerService.java [moved from ui/src/main/java/org/akraino/validation/ui/service/SiloService.java with 59% similarity]
ui/src/main/java/org/akraino/validation/ui/service/BlueprintService.java
ui/src/main/java/org/akraino/validation/ui/service/DbResultAdapter.java
ui/src/main/java/org/akraino/validation/ui/service/DbSubmissionAdapter.java
ui/src/main/java/org/akraino/validation/ui/service/IntegratedResultService.java
ui/src/main/java/org/akraino/validation/ui/service/JenkinsJobNotificationService.java
ui/src/main/java/org/akraino/validation/ui/service/LabService.java
ui/src/main/resources/portal.properties
ui/src/main/webapp/app/BluvalUI/App.Config.js
ui/src/main/webapp/app/BluvalUI/CommittedSubmissions/CommittedSubmissions.Services.js
ui/src/main/webapp/app/BluvalUI/CommittedSubmissions/CommittedSubmissionsController.js
ui/src/main/webapp/app/BluvalUI/CommittedSubmissions/CommittedSubmissionsTemplate.html
ui/src/main/webapp/app/BluvalUI/GetBasedOnDate/GetBasedOnDateController.js
ui/src/main/webapp/app/BluvalUI/GetByTimestamp/GetByTimestampController.js
ui/src/main/webapp/app/BluvalUI/GetLastRun/GetLastRunController.js
ui/src/main/webapp/app/BluvalUI/GetMostRecent/GetMostRecentController.js
ui/src/main/webapp/app/BluvalUI/NewSubmission/NewSubmissionController.js
ui/src/main/webapp/app/BluvalUI/NewSubmission/NewSubmissionTemplate.html
ui/src/main/webapp/app/BluvalUI/ValidationResults/TestSuiteResults/TestSuiteResultsController.js
ui/src/main/webapp/app/BluvalUI/ValidationResults/TestSuiteResults/TestSuiteResultsModal.html
ui/src/main/webapp/app/BluvalUI/ValidationResults/ValidationResults.Services.js
ui/src/main/webapp/app/BluvalUI/ValidationResults/ValidationResultsController.js
ui/src/main/webapp/app/BluvalUI/ValidationResults/ValidationResultsTemplate.html

index ba91275..739b21f 100644 (file)
--- a/.coafile
+++ b/.coafile
@@ -55,10 +55,12 @@ ignore = ui/target/**,
     ui/src/main/java/org/akraino/validation/ui/filter/SecurityXssFilter.java,
     ui/src/main/java/org/akraino/validation/ui/client/jenkins/resources/**.java,
     ui/src/main/java/org/akraino/validation/ui/client/nexus/resources/**.java,
-    ui/src/main/java/org/akraino/validation/ui/data/SubmissionData.java,
     ui/src/main/java/org/akraino/validation/ui/service/DbResultAdapter.java,
     ui/src/main/java/org/akraino/validation/ui/client/nexus/NexusExecutorClient.java,
-    ui/src/main/java/org/akraino/validation/ui/daoimpl/ValidationTestResultDAOImpl.java
+    ui/src/main/java/org/akraino/validation/ui/daoimpl/ValidationTestResultDAOImpl.java,
+    ui/src/main/java/org/akraino/validation/ui/entity/ValidationDbTestResult.java,
+    ui/src/main/java/org/akraino/validation/ui/entity/WRobotDbTestResult.java,
+    ui/src/main/java/org/akraino/validation/ui/entity/Submission.java
 
 [all.JS]
 bears = ESLintBear,JSComplexityBear
index 0e636d2..16e6352 100644 (file)
@@ -154,3 +154,13 @@ All notable changes to this project will be documented in this file.
 
 ### Removed
 
+## [0.2.1-SNAPSHOT] - 16 September 2019
+### Added
+- Blueprint names and versions are retrieved from Nexus and stored in database.
+
+### Changed
+- A common class is used for manipulating the Nexus and database validation results.
+- If a result had been fetched in the past from Nexus, it is not being fetched again.
+
+### Removed
+
index 8006953..100624e 100644 (file)
@@ -41,23 +41,20 @@ In order for the blueprint validation UI to be functional, the following items a
 - An appropriate mariadb instance is up and running (look at the Database subsection).
   This prerequisite concerns both of the UI modes.
 
-- The available labs for blueprint validation execution are defined by the corresponding lab owners (look at the Database subsection). It is their responsibility to publish them. Currently, this data is statically stored in the blueprint validation UI mariadb database. In order for a lab owner to update them, he/her must update the corresponding table entries. This inconvenience will be handled in the future.
+- The available labs and their silos (i.e. which silo is used by a lab in order to store results in Nexus) for blueprint validation execution are defined by the corresponding lab owners (look at the Database subsection). It is their responsibility to publish them. Currently, this data is statically stored in the blueprint validation UI mariadb database. In order for a lab owner to update them, he/her must update the corresponding table entries. This inconvenience will be handled in the future.
   This prerequisite concerns only the full control loop mode.
 
 - The available timeslots for blueprint validation execution of every lab are defined by the corresponding lab owners (look at the Database subsection). It is their responsibility to publish them. Currently, this data is statically stored in the blueprint validation UI mariadb database. In order for a lab owner to update them, he/her must update the corresponding table entries. This inconvenience will be handled in the future.
   This prerequisite concerns only the full control loop mode.
 
-- The data of the lab silos (i.e. which silo is used by a lab in order to store results in Nexus) is stored in the mariadb database (look at the Database subsection). It is the blueprint owner's responsibility to publish it. Currently, this data is statically stored in the blueprint validation UI mariadb database. In order for a blueprint owner to update it, he/her must update the corresponding table entries. This inconvenience will be handled in the future.
+- The data of available blueprints (i.e. blueprint name) is stored in the mariadb database (look at the Database subsection). This data is automatically updated using info from Nexus. If a blueprint owner's is not satisfied with this info, he/her must update the corresponding table entries.
   This prerequisite concerns only the full control loop mode.
 
-- The data of available blueprints (i.e. blueprint name) is stored in the mariadb database (look at the Database subsection). It is the blueprint owner's responsibility to publish it. Currently, this data is statically stored in the blueprint validation UI mariadb database. In order for a blueprint owner to update it, he/her must update the corresponding table entries. This inconvenience will be handled in the future.
-  This prerequisite concerns only the full control loop mode.
-
-- The data of an available blueprint instance for validation (i.e. version, layer and description of the layer) is stored in the mariadb database (look at the Database subsection). It is the blueprint owner's responsibility to publish it. Currently, this data is statically stored in the blueprint validation UI mariadb database. In order for a blueprint owner to update it, he/her must update the corresponding table entries. This inconvenience will be handled in the future.
+- The data of an available blueprint instance for validation (i.e. version and layer) is stored in the mariadb database (look at the Database subsection). This data is automatically updated using info from Nexus. If a blueprint owner's is not satisfied with this info, he/her must update the corresponding table entries.
   This prerequisite concerns only the full control loop mode.
 
 - A Jenkins instance exists capable of executing blueprint validation tests on the specified lab and storing the results to Nexus server (look at the Jenkins configuration subsection).
-  This prerequisite concerns only the full control loop mode.
+  Also, this data is updated using info from results fetched from Nexus. This prerequisite concerns only the full control loop mode.
 
 - A Nexus server exists where all the blueprint validation results are stored (look at the Nexus subsection).
   This prerequisite concerns both of the UI modes.
@@ -236,44 +233,48 @@ To this end, after the image build process, the following commands should be exe
 
 In the context of the full control loop mode, the following tables must be initialized with appropriate data:
 
-- lab (here every lab owner should store the name of the lab)
+- lab (here every lab owner should store the name of the lab and the silo used for storing results in Nexus)
 - timeslot (here every lab owner should register the available timeslots that can be used for blueprint validation test execution)
-- silo (here every lab owner should register the silo which is used for storing results in Nexus, for example for AT&T lab the value is 'att-blu-val')
+- blueprint_layer (here all the blueprint layers should be registered. These layers will be referenced by the blueprint instances)
 - blueprint (here every blueprint owner should register the name of the blueprint)
-- blueprint_instance_for_validation (here every blueprint owner should register the blueprint instances for validation, i.e. version, layer and description of a layer)
+- blueprint_instance_for_validation (here every blueprint owner should register the blueprint instances for validation, i.e. version and layer)
+- blueprint_instance_blueprint_layer (here the many-to-many relationship between blueprint instances and layers is formulated)
 
-The following file can be used for initializing the aforementioned data (as it was performed in the above example using the 'mysql -p<MARIADB_AKRAINO_PASSWORD> -uakraino -h <IP of the mariadb container> < ../../ui/db-scripts/examples/initialize_db_example.sql' command):
+As it has been already mentioned, these tables are initialized automatically by the UI by fetching data from Nexus.
+
+However, a user may wish to extend or change this data (for example a new blueprint has been created and no results have been pushed to Nexus yet). To this end, the following file can be used (that's why the command 'mysql -p<MARIADB_AKRAINO_PASSWORD> -uakraino -h <IP of the mariadb container> < ../../ui/db-scripts/examples/initialize_db_example.sql' has been used previously):
 
     db-scripts/examples/initialize_db_example.sql
 
-Some of this data is illustrated below (refer to 'org.akraino.validation.ui.data' package for more info regarding available values):
+Some of this data is illustrated below:
 
 .. code-block:: console
 
-    Lab
-    id:1, lab:0 (0 stands for AT&T)
+    Labs:
+    id:1, lab:'att', silo:'att-blu-val'
 
     Timeslots:
     id:1 , start date and time: 'now', duration: null, lab: 1
 
-    Silo
-    id:1, silo: 'att-blu-val', lab: 1
+    Blueprint layers:
+    id:1, layer: 'hardware';
 
     Blueprints:
-    id: 3 , name : 'REC'
+    id: 2 , blueprint_name : 'rec'
 
     Blueprint Instances:
-    id: 2, blueprint_id: 3 (i.e. REC), version: "latest", layer: 0 (i.e. Hardware), layer_description: "AT&T Hardware"
+    id: 2, blueprint_id: 2 (i.e. rec), version: "master"
+    
+    blueprint_instances_blueprint_layers
+    blueprint_id: 2 (i.e. rec), layer_id: 1 (i.e. hardware)
 
 It should be noted that currently the start date and time and the duration of the timeslot are not taken into account by the UI (see limitation section). Therefore, a user should define 'now' and null respectively for their content.
 
 Based on this data, the UI enables the user to select an appropriate blueprint instance for validation.
 
-Currently, this data cannot be retrieved dynamically by the UI (see limitations subsection). For this reason, in cases of new data, a user should define new entries in this database.
-
 For example, if a user wants to define a new lab with the following data:
 
-    lab: Community
+    lab: community, silo : 'community' 
 
 the following file should be created:
 
@@ -281,9 +282,7 @@ name: dbscript
 content:
     SET FOREIGN_KEY_CHECKS=1;
     use akraino;
-    insert into lab values(2, 2);
-
-2 stands for community lab. Refer to 'org.akraino.validation.ui.data' package for more info.
+    insert into lab (id, lab, silo) values(2, 'community', 'community');
 
 Then, the following command should be executed:
 
@@ -301,27 +300,7 @@ name: dbscript
 content:
     SET FOREIGN_KEY_CHECKS=1;
     use akraino;
-    insert into timeslot values(2, 'now', null, 1);
-
-1 is the id of the AT&T lab.
-
-Then, the following command should be executed:
-
-.. code-block:: console
-
-    mysql -p<MARIADB_AKRAINO_PASSWORD> -uakraino -h <IP of the mariadb container> < ./dbscript.sql
-
-For example, if a user wants to define a new silo with the following data:
-
-    silo: 'community-blu-val', lab: AT&T
-
-the following file should be created:
-
-name: dbscript
-content:
-    SET FOREIGN_KEY_CHECKS=1;
-    use akraino;
-    insert into silo values(2, 'community-blu-val', 2);
+    insert into timeslot values(2, 'now', null, 2);
 
 2 is the id of the community lab.
 
@@ -333,7 +312,7 @@ Then, the following command should be executed:
 
 Furthermore, if a user wants to define a new blueprint, namely "newBlueprint" and a new instance of this blueprint with the following data:
 
-    version: "latest", layer: 2 (i.e. K8s), layer_description: "K8s with High Availability Ingress controller"
+    version: "master", layer: k8s
 
 the following file should be created:
 
@@ -341,8 +320,10 @@ name: dbscript
 content:
     SET FOREIGN_KEY_CHECKS=1;
     use akraino;
-    insert into blueprint (blueprint_id, blueprint_name) values(4, 'newBlueprint');
-    insert into blueprint_instance (blueprint_instance_id, blueprint_id, version, layer, layer_description) values(6, 4, 'latest', 2, 'K8s with High Availability Ingress controller');
+    insert into blueprint (id, blueprint_name) values(3, 'newBlueprint');
+    insert into blueprint_instance (id, blueprint_id, version) values(3, 3, 'master');
+    insert into blueprint_layer (id, layer) values(4, 'k8s');
+    insert into blueprint_instance_blueprint_layer (blueprint_instance_id, blueprint_layer_id) values(3, 4);
 
 Then, the following command should be executed:
 
@@ -360,9 +341,9 @@ It should be noted that it is not the UI responsibility to deploy a Jenkins inst
 
 Furthermore, this instance must have the following option enabled: "Manage Jenkins -> Configure Global Security -> Prevent Cross Site Request Forgery exploits".
 
-Also, currently, the corresponding Jenkins job should accept the following as input parameters: "SUBMISSION_ID", "BLUEPRINT", "VERSION", "LAYER", "LAB" and "UI_IP".
+Also, currently, the corresponding Jenkins job should accept the following as input parameters: "SUBMISSION_ID", "BLUEPRINT", "VERSION", "LAYER", "OPTIONAL", "LAB" and "UI_IP".
 The "SUBMISSION_ID" and "UI_IP" parameters (i.e. IP address of the UI host machine-this is needed by the Jenkins instance in order to send back Job completion notification) are created and provided by the back-end part of the UI.
-The "BLUEPRINT", "VERSION", "LAYER" and "LAB" parameters are configured by the UI user.
+The "BLUEPRINT", "VERSION", "LAYER" and "LAB" parameters are configured by the UI user. The parameter "OPTIONAL" defines whether the optional test cases should be included or not.
 
 Moreover, as the Jenkins notification plugin (https://wiki.jenkins.io/display/JENKINS/Notification+Plugin) seems to ignore proxy settings, the corresponding Jenkins job must be configured to execute the following commands at the end (Post-build Actions)
 
@@ -455,4 +436,3 @@ Limitations
 - The UI has been tested using Chrome and Firefox browsers.
 - The back-end part of the UI does not take into account the start date and time and duration of the configured timeslot. It immediately triggers the corresponding Jenkins Job.
 - Results data manipulation (filtering, graphical representation, indexing in time order, etc) is not supported.
-- The silos, labs, and the available blueprints and timeslots must be manually configured in the mariadb database.
\ No newline at end of file
index 6b94c2c..a9ccae3 100644 (file)
@@ -18,18 +18,20 @@ SET FOREIGN_KEY_CHECKS=1;
 
 use akraino;
 
-DROP TABLE IF EXISTS blueprint_instance_for_validation;
-DROP TABLE IF EXISTS blueprint;
-DROP TABLE IF EXISTS silo;
-DROP TABLE IF EXISTS timeslot;
-DROP TABLE IF EXISTS lab;
 DROP TABLE IF EXISTS w_robot_test_result;
 DROP TABLE IF EXISTS validation_test_result;
 DROP TABLE IF EXISTS submission;
+DROP TABLE IF EXISTS blueprint_instance_blueprint_layer;
+DROP TABLE IF EXISTS blueprint_instance;
+DROP TABLE IF EXISTS blueprint_layer;
+DROP TABLE IF EXISTS blueprint;
+DROP TABLE IF EXISTS timeslot;
+DROP TABLE IF EXISTS lab;
 
 create table lab (
    id bigint not NULL AUTO_INCREMENT,
    lab text not NULL unique,
+   silo text not NULL unique,
    CONSTRAINT id_pk PRIMARY KEY (id)
 );
 
@@ -41,38 +43,47 @@ create table timeslot (
    CONSTRAINT id_pk PRIMARY KEY (id),
    CONSTRAINT lab_id_fk FOREIGN KEY (lab_id)
       REFERENCES lab (id) MATCH SIMPLE
-      ON UPDATE NO ACTION ON DELETE NO ACTION
+      ON UPDATE NO ACTION ON DELETE NO ACTION,
+   unique (start_date_time, lab_id)
 );
 
-create table silo (
+CREATE TABLE blueprint
+(
    id bigint not NULL AUTO_INCREMENT,
-   silo text not NULL,
-   lab_id bigint not NULL unique,
-   CONSTRAINT id_pk PRIMARY KEY (id),
-   CONSTRAINT lab_id_fk2 FOREIGN KEY (lab_id)
-      REFERENCES lab (id) MATCH SIMPLE
-      ON UPDATE NO ACTION ON DELETE NO ACTION
+   blueprint_name varchar(20) not NULL unique,
+   CONSTRAINT id_pk PRIMARY KEY (id)
 );
 
-CREATE TABLE blueprint
+CREATE TABLE blueprint_layer
 (
    id bigint not NULL AUTO_INCREMENT,
-   blueprint_name varchar(20) not NULL unique,
+   layer text not NULL unique,
    CONSTRAINT id_pk PRIMARY KEY (id)
 );
 
-CREATE TABLE blueprint_instance_for_validation
+CREATE TABLE blueprint_instance
 (
    id bigint not NULL AUTO_INCREMENT,
    blueprint_id bigint not NULL,
    version text not NULL,
-   layer text not NULL,
-   layer_description text not NULL,
    CONSTRAINT id_pk PRIMARY KEY (id),
    CONSTRAINT blueprint_id_fk FOREIGN KEY (blueprint_id)
       REFERENCES blueprint (id) MATCH SIMPLE
       ON UPDATE NO ACTION ON DELETE NO ACTION,
-   unique (version, layer, blueprint_id)
+   unique (version, blueprint_id)
+);
+
+CREATE TABLE blueprint_instance_blueprint_layer
+(
+   blueprint_instance_id bigint not NULL,
+   blueprint_layer_id bigint not NULL,
+   CONSTRAINT blueprint_instance_id_fk2 FOREIGN KEY (blueprint_instance_id)
+      REFERENCES blueprint_instance (id) MATCH SIMPLE
+      ON UPDATE NO ACTION ON DELETE NO ACTION,
+   CONSTRAINT blueprint_layer_id_fk FOREIGN KEY (blueprint_layer_id)
+      REFERENCES blueprint_layer (id) MATCH SIMPLE
+      ON UPDATE NO ACTION ON DELETE NO ACTION,
+   unique (blueprint_instance_id, blueprint_layer_id)
 );
 
 CREATE TABLE submission
@@ -89,11 +100,10 @@ CREATE TABLE submission
 CREATE TABLE validation_test_result
 (
    id bigint not NULL AUTO_INCREMENT,
-   blueprint_name varchar(20) not NULL,
-   version text not NULL,
+   blueprint_instance_id bigint not NULL,
+   all_layers boolean,
    lab_id bigint not NULL,
    timestamp text,
-   all_layers boolean,
    optional boolean,
    result boolean,
    submission_id bigint,
@@ -105,6 +115,9 @@ CREATE TABLE validation_test_result
    CONSTRAINT submission_id_fk FOREIGN KEY (submission_id)
       REFERENCES submission (id) MATCH SIMPLE
       ON UPDATE NO ACTION ON DELETE NO ACTION,
+   CONSTRAINT blueprint_instance_id_fk FOREIGN KEY (blueprint_instance_id)
+      REFERENCES blueprint_instance (id) MATCH SIMPLE
+      ON UPDATE NO ACTION ON DELETE NO ACTION,
    unique (timestamp, lab_id)
 );
 
index 1273ae6..694c3cb 100644 (file)
@@ -18,20 +18,26 @@ SET FOREIGN_KEY_CHECKS=1;
 
 use akraino;
 
-insert into lab values(1, 0); /* 0 stands for AT&T lab */
+insert into lab (id, lab, silo) values(1, 'att', 'att-blu-val');
 
 insert into timeslot values(1, 'now', null, 1);
 
-insert into silo values(1, 'att-blu-val', 1);
-
 insert into blueprint (id, blueprint_name) values(1, 'dummy');
-insert into blueprint (id, blueprint_name) values(2, 'unicycle');
-insert into blueprint (id, blueprint_name) values(3, 'rec');
-
-insert into blueprint_instance_for_validation (id, blueprint_id, version, layer, layer_description) values(1, 1, 'master', 0, 'Dummy Hardware');  /* 0 Stands for hardware layer */
-insert into blueprint_instance_for_validation (id, blueprint_id, version, layer, layer_description) values(2, 3, 'master', 0, 'AT&T Hardware'); /* 0 Stands for hardware layer */
-insert into blueprint_instance_for_validation (id, blueprint_id, version, layer, layer_description) values(3, 3, 'master', 1, 'OS of the AT&T platform'); /* 1 Stands for OS layer */
-insert into blueprint_instance_for_validation (id, blueprint_id, version, layer, layer_description) values(4, 3, 'master', 2, 'K8s of the AT&T platform'); /* 2 Stands for K8s layer */
-insert into blueprint_instance_for_validation (id, blueprint_id, version, layer, layer_description) values(6, 2, 'master', 0, 'Unicycle Hardware'); /* 0 Stands for hardware layer */
+insert into blueprint (id, blueprint_name) values(2, 'rec');
+
+insert into blueprint_layer (id, layer) values(1, 'hardware');
+insert into blueprint_layer (id, layer) values(2, 'os');
+insert into blueprint_layer (id, layer) values(3, 'container');
+insert into blueprint_layer (id, layer) values(4, 'k8s');
+insert into blueprint_layer (id, layer) values(5, 'helm');
+insert into blueprint_layer (id, layer) values(6, 'openstack');
+
+insert into blueprint_instance (id, blueprint_id, version) values(1, 1, 'master'); /* master version is assigned to dummy */
+insert into blueprint_instance (id, blueprint_id, version) values(2, 2, 'master'); /* master version is assigned to rec */
+
+insert into blueprint_instance_blueprint_layer (blueprint_instance_id, blueprint_layer_id) values(1, 1); /* hardware layer is assigned to dummy*/
+insert into blueprint_instance_blueprint_layer (blueprint_instance_id, blueprint_layer_id) values(2, 1); /* hardware layer is assigned to rec*/
+insert into blueprint_instance_blueprint_layer (blueprint_instance_id, blueprint_layer_id) values(2, 2); /* os layer is assigned to rec*/
+insert into blueprint_instance_blueprint_layer (blueprint_instance_id, blueprint_layer_id) values(2, 4); /* k8s layer is assigned to rec*/
 
 commit;
index f3f0c97..6baa507 100644 (file)
@@ -14,7 +14,7 @@
 
     <groupId>org.akraino.validation</groupId>
     <artifactId>ui</artifactId>
-    <version>0.2.0-SNAPSHOT</version>
+    <version>0.2.1-SNAPSHOT</version>
     <name>Bluval UI Maven Webapp</name>
     <packaging>war</packaging>
 
index 30206bf..33e53db 100644 (file)
@@ -32,15 +32,20 @@ import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Locale;
+import java.util.NoSuchElementException;
 
 import javax.annotation.Nonnull;
 
 import org.akraino.validation.ui.client.nexus.resources.RobotTestResult;
 import org.akraino.validation.ui.client.nexus.resources.Status;
 import org.akraino.validation.ui.client.nexus.resources.TestInfoYaml;
-import org.akraino.validation.ui.client.nexus.resources.ValidationNexusTestResult;
 import org.akraino.validation.ui.client.nexus.resources.WRobotNexusTestResult;
-import org.akraino.validation.ui.data.BlueprintLayer;
+import org.akraino.validation.ui.entity.Blueprint;
+import org.akraino.validation.ui.entity.BlueprintInstance;
+import org.akraino.validation.ui.entity.LabInfo;
+import org.akraino.validation.ui.entity.ValidationDbTestResult;
+import org.akraino.validation.ui.entity.WRobotDbTestResult;
+import org.akraino.validation.ui.service.DbResultAdapter;
 import org.apache.commons.httpclient.HttpException;
 import org.json.JSONObject;
 import org.json.XML;
@@ -50,6 +55,7 @@ import org.jsoup.nodes.Element;
 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.onap.portalsdk.core.onboarding.util.PortalApiProperties;
 import org.onap.portalsdk.core.web.support.UserUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.fasterxml.jackson.annotation.JsonInclude.Include;
@@ -72,6 +78,9 @@ import com.sun.jersey.client.urlconnection.URLConnectionClientHandler;
 @Service
 public final class NexusExecutorClient {
 
+    @Autowired
+    DbResultAdapter dbAdapter;
+
     private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(NexusExecutorClient.class);
 
     private final Client client;
@@ -145,7 +154,7 @@ public final class NexusExecutorClient {
         return this.getResource(endpoint);
     }
 
-    public ValidationNexusTestResult getResult(@Nonnull String name, @Nonnull String version, @Nonnull String siloText,
+    public ValidationDbTestResult getResult(@Nonnull String name, @Nonnull String version, @Nonnull String siloText,
             @Nonnull String timestamp)
                     throws ClientHandlerException, UniformInterfaceException, JsonParseException, JsonMappingException,
                     IOException, KeyManagementException, NoSuchAlgorithmException, ParseException, NullPointerException {
@@ -165,29 +174,46 @@ public final class NexusExecutorClient {
         if (element == null) {
             return null;
         }
-        ValidationNexusTestResult vNexusResult = new ValidationNexusTestResult();
-        vNexusResult.setBlueprintName(name);
-        vNexusResult.setSilo(siloText);
-        vNexusResult.setVersion(version);
-        vNexusResult.setTimestamp(timestamp);
+        ValidationDbTestResult vDbResult = new ValidationDbTestResult();
+        Blueprint blueprint = new Blueprint();
+        blueprint.setBlueprintName(name);
+        BlueprintInstance blueInst = new BlueprintInstance();
+        blueInst.setBlueprint(blueprint);
+        blueInst.setVersion(version);
+        vDbResult.setBlueprintInstance(blueInst);
+        LabInfo lab = new LabInfo();
+        lab.setSilo(siloText);
+        vDbResult.setLab(lab);
+        vDbResult.setTimestamp(timestamp);
         String lastModified = element.getElementsByTag("td").get(1).text();
-        vNexusResult.setDateOfStorage(lastModified);
+        vDbResult.setDateStorage(lastModified);
         TestInfoYaml testInfo = getTestInfo(webResource.getURI().toString() + timestamp);
         if (testInfo != null) {
             if (testInfo.gettest_info().getLayer().equals("all")) {
-                vNexusResult.setAllLayers(true);
+                vDbResult.setAllLayers(true);
             } else {
-                vNexusResult.setAllLayers(false);
+                vDbResult.setAllLayers(false);
             }
-            vNexusResult.setOptional(testInfo.gettest_info().getOptional());
+            vDbResult.setOptional(testInfo.gettest_info().getOptional());
         }
         List<WRobotNexusTestResult> wTestResults = getWRobotTestResults(name, version, siloText, timestamp);
-        vNexusResult.setwRobotNexusTestResults(wTestResults);
-        vNexusResult.setResult(determineResult(wTestResults));
-        return vNexusResult;
+        if (wTestResults.size() < 1) {
+            throw new RuntimeException("No robot test results could be obtained.");
+        }
+        vDbResult.setResult(determineResult(wTestResults));
+        List<WRobotDbTestResult> wDbResults = new ArrayList<WRobotDbTestResult>();
+        for (WRobotNexusTestResult wTestResult : wTestResults) {
+            WRobotDbTestResult wDbResult = new WRobotDbTestResult();
+            wDbResult.setLayer(wTestResult.getLayer());
+            ObjectMapper mapper = new ObjectMapper();
+            wDbResult.setRobotTestResults(mapper.writeValueAsString(wTestResult.getRobotNexusTestResults()));
+            wDbResults.add(wDbResult);
+        }
+        vDbResult.setWRobotDbTestResults(new HashSet<WRobotDbTestResult>(wDbResults));
+        return vDbResult;
     }
 
-    public List<ValidationNexusTestResult> getResults(@Nonnull String name, @Nonnull String version,
+    public List<ValidationDbTestResult> getResults(@Nonnull String name, @Nonnull String version,
             @Nonnull String siloText, int noOfLastElements)
                     throws ClientHandlerException, UniformInterfaceException, JsonParseException, JsonMappingException,
                     IOException, KeyManagementException, NoSuchAlgorithmException, ParseException {
@@ -200,31 +226,49 @@ public final class NexusExecutorClient {
             throw new HttpException("Could not retrieve validation Nexus test results. HTTP error code : "
                     + response.getStatus() + " and message: " + response.getEntity(String.class));
         }
-        List<ValidationNexusTestResult> vNexusResults = new ArrayList<ValidationNexusTestResult>();
+        List<ValidationDbTestResult> vDbResults = new ArrayList<ValidationDbTestResult>();
         Document document = Jsoup.parse(response.getEntity(String.class));
         List<Element> elements = document.getElementsByTag("body").get(0).getElementsByTag("table").get(0)
                 .getElementsByTag("tbody").get(0).getElementsByTag("tr");
         elements = findLastElementsByDate(elements.subList(2, elements.size()), noOfLastElements);
         for (int i = 0; i < elements.size(); i++) {
+            String timestamp = null;
             try {
-                String timestamp = elements.get(i).getElementsByTag("td").get(0).getElementsByTag("a").get(0).text();
+                timestamp = elements.get(i).getElementsByTag("td").get(0).getElementsByTag("a").get(0).text();
                 timestamp = timestamp.substring(0, timestamp.length() - 1);
-                ValidationNexusTestResult vNexusResult = this.getResult(name, version, siloText, timestamp);
-                vNexusResults.add(vNexusResult);
-            } catch (HttpException ex) {
-                LOGGER.warn(EELFLoggerDelegate.auditLogger, "Exception occured while retrieving timestamp results");
+                ValidationDbTestResult vDbResult = dbAdapter.getValidationTestResult(siloText, timestamp);
+                if (vDbResult == null || vDbResult.getDateStorage() == null) {
+                    vDbResults.add(this.getResult(name, version, siloText, timestamp));
+                } else {
+                    // Just to avoid deletion of already received validation timestamp results
+                    vDbResult = new ValidationDbTestResult();
+                    Blueprint blueprint = new Blueprint();
+                    blueprint.setBlueprintName(name);
+                    BlueprintInstance blueInst = new BlueprintInstance();
+                    blueInst.setBlueprint(blueprint);
+                    blueInst.setVersion(version);
+                    vDbResult.setBlueprintInstance(blueInst);
+                    LabInfo lab = new LabInfo();
+                    lab.setSilo(siloText);
+                    vDbResult.setLab(lab);
+                    vDbResult.setTimestamp(timestamp);
+                    vDbResults.add(vDbResult);
+                }
+            } catch (IllegalArgumentException | HttpException | NullPointerException | NoSuchElementException ex) {
+                LOGGER.warn(EELFLoggerDelegate.auditLogger, "Exception occured while retrieving timestamp : "
+                        + timestamp + " result." + UserUtils.getStackTrace(ex));
                 continue;
             }
         }
-        return vNexusResults;
+        return vDbResults;
     }
 
-    public List<ValidationNexusTestResult> getResults(@Nonnull String name, @Nonnull String version,
+    public List<ValidationDbTestResult> getResults(@Nonnull String name, @Nonnull String version,
             @Nonnull String siloText, @Nonnull Date date)
                     throws ClientHandlerException, UniformInterfaceException, JsonParseException, JsonMappingException,
                     IOException, KeyManagementException, NoSuchAlgorithmException, ParseException, NullPointerException {
         String nexusUrl = this.baseurl + "/" + siloText + "/" + name + "/" + version;
-        LOGGER.info(EELFLoggerDelegate.applicationLogger, "Trying to get validation Nexus results based on date");
+        LOGGER.debug(EELFLoggerDelegate.applicationLogger, "Trying to get validation Nexus results based on date");
         WebResource webResource = this.client.resource(nexusUrl + "/");
         LOGGER.debug(EELFLoggerDelegate.debugLogger, "Request URI of get: " + webResource.getURI().toString());
         ClientResponse response = webResource.get(ClientResponse.class);
@@ -232,7 +276,7 @@ public final class NexusExecutorClient {
             throw new HttpException("Could not retrieve validation Nexus results based on date. HTTP error code : "
                     + response.getStatus() + " and message: " + response.getEntity(String.class));
         }
-        List<ValidationNexusTestResult> vNexusResults = new ArrayList<ValidationNexusTestResult>();
+        List<ValidationDbTestResult> vDbResults = new ArrayList<ValidationDbTestResult>();
         Document document = Jsoup.parse(response.getEntity(String.class));
         List<Element> elements = document.getElementsByTag("body").get(0).getElementsByTag("table").get(0)
                 .getElementsByTag("tbody").get(0).getElementsByTag("tr");
@@ -241,18 +285,19 @@ public final class NexusExecutorClient {
             try {
                 String timestamp = elements.get(i).getElementsByTag("td").get(0).getElementsByTag("a").get(0).text();
                 timestamp = timestamp.substring(0, timestamp.length() - 1);
-                ValidationNexusTestResult vNexusResult = this.getResult(name, version, siloText, timestamp);
-                vNexusResults.add(vNexusResult);
-            } catch (HttpException ex) {
-                LOGGER.warn(EELFLoggerDelegate.auditLogger, "Exception occured while retrieving timestamp results");
+                ValidationDbTestResult vDbResult = this.getResult(name, version, siloText, timestamp);
+                vDbResults.add(vDbResult);
+            } catch (IllegalArgumentException | HttpException | NullPointerException ex) {
+                LOGGER.warn(EELFLoggerDelegate.auditLogger,
+                        "Exception occured while retrieving timestamp results. " + UserUtils.getStackTrace(ex));
                 continue;
             }
         }
-        return vNexusResults;
+        return vDbResults;
     }
 
-    public ValidationNexusTestResult getLastResultBasedOnOutcome(@Nonnull String name, @Nonnull String version,
-            @Nonnull String siloText, List<BlueprintLayer> layers, Boolean optional, boolean outcome)
+    public ValidationDbTestResult getLastResultBasedOnOutcome(@Nonnull String name, @Nonnull String version,
+            @Nonnull String siloText, List<String> layers, Boolean optional, boolean outcome)
                     throws ClientHandlerException, UniformInterfaceException, JsonParseException, JsonMappingException,
                     IOException, KeyManagementException, NoSuchAlgorithmException, ParseException, NullPointerException {
         String nexusUrl = this.baseurl + "/" + siloText + "/" + name + "/" + version;
@@ -289,24 +334,24 @@ public final class NexusExecutorClient {
             try {
                 String elementTimestamp = element.getElementsByTag("td").get(0).getElementsByTag("a").get(0).text();
                 elementTimestamp = elementTimestamp.substring(0, elementTimestamp.length() - 1);
-                ValidationNexusTestResult vNexusResult = this.getResult(name, version, siloText, elementTimestamp);
-                if (vNexusResult.getResult() != outcome) {
+                ValidationDbTestResult vDbResult = this.getResult(name, version, siloText, elementTimestamp);
+                if (vDbResult.getResult() != outcome) {
                     continue;
                 }
-                if (optional != null && vNexusResult.getOptional() != optional) {
+                if (optional != null && vDbResult.getOptional() != optional) {
                     continue;
                 }
                 if (layers != null) {
-                    List<BlueprintLayer> storedLayers = new ArrayList<BlueprintLayer>();
-                    for (WRobotNexusTestResult wRobot : vNexusResult.getwRobotNexusTestResults()) {
-                        storedLayers.add(wRobot.getBlueprintLayer());
+                    List<String> storedLayers = new ArrayList<String>();
+                    for (WRobotDbTestResult wRobot : vDbResult.getWRobotDbTestResults()) {
+                        storedLayers.add(wRobot.getLayer());
                     }
                     if (!new HashSet<>(storedLayers).equals(new HashSet<>(layers))) {
                         continue;
                     }
                 }
-                return vNexusResult;
-            } catch (HttpException ex) {
+                return vDbResult;
+            } catch (IllegalArgumentException | HttpException | NullPointerException ex) {
                 LOGGER.warn(EELFLoggerDelegate.auditLogger,
                         "Error when trying to retrieve results. " + UserUtils.getStackTrace(ex));
                 continue;
@@ -315,7 +360,7 @@ public final class NexusExecutorClient {
         return null;
     }
 
-    public ValidationNexusTestResult getLastResultBasedOnOutcome(@Nonnull String name, @Nonnull String version,
+    public ValidationDbTestResult getLastResultBasedOnOutcome(@Nonnull String name, @Nonnull String version,
             @Nonnull String siloText, Boolean allLayers, Boolean optional, boolean outcome)
                     throws ClientHandlerException, UniformInterfaceException, JsonParseException, JsonMappingException,
                     IOException, KeyManagementException, NoSuchAlgorithmException, ParseException, NullPointerException {
@@ -353,18 +398,18 @@ public final class NexusExecutorClient {
             try {
                 String elementTimestamp = element.getElementsByTag("td").get(0).getElementsByTag("a").get(0).text();
                 elementTimestamp = elementTimestamp.substring(0, elementTimestamp.length() - 1);
-                ValidationNexusTestResult vNexusResult = this.getResult(name, version, siloText, elementTimestamp);
-                if (vNexusResult.getResult() != outcome) {
+                ValidationDbTestResult vDbResult = this.getResult(name, version, siloText, elementTimestamp);
+                if (vDbResult.getResult() != outcome) {
                     continue;
                 }
-                if (optional != null && vNexusResult.getOptional() != optional) {
+                if (optional != null && vDbResult.getOptional() != optional) {
                     continue;
                 }
-                if (allLayers != null && vNexusResult.getAllLayers() != allLayers) {
+                if (allLayers != null && vDbResult.getAllLayers() != allLayers) {
                     continue;
                 }
-                return vNexusResult;
-            } catch (HttpException ex) {
+                return vDbResult;
+            } catch (IllegalArgumentException | HttpException | NullPointerException ex) {
                 LOGGER.warn(EELFLoggerDelegate.auditLogger,
                         "Error when trying to retrieve results. " + UserUtils.getStackTrace(ex));
                 continue;
@@ -399,11 +444,12 @@ public final class NexusExecutorClient {
                 }
                 List<RobotTestResult> robotTestResults = getRobotTestResults(nexusUrl + "/" + layer);
                 WRobotNexusTestResult wrapper = new WRobotNexusTestResult();
-                wrapper.setBlueprintLayer(BlueprintLayer.valueOf(layer));
-                wrapper.setRobotTestResults(robotTestResults);
+                wrapper.setLayer(layer);
+                wrapper.setRobotNexusTestResults(robotTestResults);
                 listOfwrappers.add(wrapper);
-            } catch (HttpException | IllegalArgumentException ex) {
-                LOGGER.warn(EELFLoggerDelegate.auditLogger, "Exception occured while retrieving robot results");
+            } catch (IllegalArgumentException | HttpException | NullPointerException ex) {
+                LOGGER.warn(EELFLoggerDelegate.auditLogger,
+                        "Exception occured while retrieving robot results. " + UserUtils.getStackTrace(ex));
                 continue;
             }
         }
@@ -451,7 +497,7 @@ public final class NexusExecutorClient {
     private boolean determineResult(List<WRobotNexusTestResult> wTestResults) {
         boolean result = true;
         for (WRobotNexusTestResult wTestResult : wTestResults) {
-            for (RobotTestResult robotTestResult : wTestResult.getRobotTestResults()) {
+            for (RobotTestResult robotTestResult : wTestResult.getRobotNexusTestResults()) {
                 for (Status status : robotTestResult.getRobot().getStatistics().getTotal().getStat()) {
                     if (status.getContent().trim().equals("All Tests") && status.getFail() > 0) {
                         result = false;
diff --git a/ui/src/main/java/org/akraino/validation/ui/client/nexus/resources/ValidationNexusTestResult.java b/ui/src/main/java/org/akraino/validation/ui/client/nexus/resources/ValidationNexusTestResult.java
deleted file mode 100644 (file)
index 59a3592..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (c) 2019 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.
- */
-package org.akraino.validation.ui.client.nexus.resources;
-
-import java.util.List;
-
-public class ValidationNexusTestResult {
-
-    private int resultId;
-
-    private String blueprintName;
-
-    private String version;
-
-    private String silo;
-
-    private Boolean allLayers;
-
-    private Boolean optional;
-
-    private boolean result;
-
-    private String dateOfStorage;
-
-    private String timestamp;
-
-    private String submissionId;
-
-    private List<WRobotNexusTestResult> wRobotNexusTestResults;
-
-    public ValidationNexusTestResult() {
-
-    }
-
-    public Integer getResultId() {
-        return this.resultId;
-    }
-
-    public void setResultId(Integer resultId) {
-        this.resultId = resultId;
-    }
-
-    public String getBlueprintName() {
-        return this.blueprintName;
-    }
-
-    public void setBlueprintName(String blueprintName) {
-        this.blueprintName = blueprintName;
-    }
-
-    public String getVersion() {
-        return this.version;
-    }
-
-    public void setVersion(String version) {
-        this.version = version;
-    }
-
-    public String getSilo() {
-        return this.silo;
-    }
-
-    public void setSilo(String silo) {
-        this.silo = silo;
-    }
-
-    public Boolean getAllLayers() {
-        return this.allLayers;
-    }
-
-    public void setAllLayers(Boolean allLayers) {
-        this.allLayers = allLayers;
-    }
-
-    public Boolean getOptional() {
-        return this.optional;
-    }
-
-    public void setOptional(Boolean optional) {
-        this.optional = optional;
-    }
-
-    public boolean getResult() {
-        return this.result;
-    }
-
-    public void setResult(boolean result) {
-        this.result = result;
-    }
-
-    public String getDateOfStorage() {
-        return this.dateOfStorage;
-    }
-
-    public void setDateOfStorage(String dateOfStorage) {
-        this.dateOfStorage = dateOfStorage;
-    }
-
-    public String getTimestamp() {
-        return this.timestamp;
-    }
-
-    public void setTimestamp(String timestamp) {
-        this.timestamp = timestamp;
-    }
-
-    public String getSubmissionId() {
-        return this.submissionId;
-    }
-
-    public void setSubmissionId(String submissionId) {
-        this.submissionId = submissionId;
-    }
-
-    public List<WRobotNexusTestResult> getwRobotNexusTestResults() {
-        return this.wRobotNexusTestResults;
-    }
-
-    public void setwRobotNexusTestResults(List<WRobotNexusTestResult> wRobotNexusTestResults) {
-        this.wRobotNexusTestResults = wRobotNexusTestResults;
-    }
-
-}
index 7cfdbd8..17a628d 100644 (file)
@@ -17,32 +17,22 @@ package org.akraino.validation.ui.client.nexus.resources;
 
 import java.util.List;
 
-import org.akraino.validation.ui.data.BlueprintLayer;
+import org.akraino.validation.ui.entity.WRobotDbTestResult;
 
-public class WRobotNexusTestResult {
+public class WRobotNexusTestResult extends WRobotDbTestResult {
 
-    private BlueprintLayer blueprintLayer;
-
-    private List<RobotTestResult> robotTestResult;
+    private List<RobotTestResult> robotNexusTestResult;
 
     public WRobotNexusTestResult() {
 
     }
 
-    public BlueprintLayer getBlueprintLayer() {
-        return this.blueprintLayer;
-    }
-
-    public void setBlueprintLayer(BlueprintLayer blueprintLayer) {
-        this.blueprintLayer = blueprintLayer;
-    }
-
-    public List<RobotTestResult> getRobotTestResults() {
-        return this.robotTestResult;
+    public List<RobotTestResult> getRobotNexusTestResults() {
+        return this.robotNexusTestResult;
     }
 
-    public void setRobotTestResults(List<RobotTestResult> robotTestResult) {
-        this.robotTestResult = robotTestResult;
+    public void setRobotNexusTestResults(List<RobotTestResult> robotNexusTestResult) {
+        this.robotNexusTestResult = robotNexusTestResult;
     }
 
 }
  */
 package org.akraino.validation.ui.conf;
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ExecutorService;
 
-import org.akraino.validation.ui.client.nexus.resources.ValidationNexusTestResult;
-import org.akraino.validation.ui.data.Lab;
+import org.akraino.validation.ui.entity.ValidationDbTestResult;
 import org.akraino.validation.ui.service.DbResultAdapter;
 import org.akraino.validation.ui.service.IntegratedResultService;
 import org.akraino.validation.ui.service.utils.PrioritySupplier;
@@ -36,10 +34,9 @@ import org.springframework.context.event.ContextRefreshedEvent;
 import org.springframework.stereotype.Component;
 
 @Component
-public class ValidationNexusTestResultsGetter implements ApplicationListener<ContextRefreshedEvent> {
+public class ValidationTestResultsGetter implements ApplicationListener<ContextRefreshedEvent> {
 
-    private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate
-            .getLogger(ValidationNexusTestResultsGetter.class);
+    private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(ValidationTestResultsGetter.class);
 
     @Autowired
     IntegratedResultService integratedService;
@@ -51,59 +48,64 @@ public class ValidationNexusTestResultsGetter implements ApplicationListener<Con
     public void onApplicationEvent(final ContextRefreshedEvent event) {
         ApplicationContext context = new AnnotationConfigApplicationContext(ExecutorServiceInitializer.class);
         ExecutorService service = (ExecutorService) context.getBean("executorService");
-        ValidationNexusTestResultsGetterExecution task = new ValidationNexusTestResultsGetterExecution();
-        CompletableFuture<List<List<ValidationNexusTestResult>>> completableFuture = CompletableFuture
+        ValidationTestResultsGetterExecution task = new ValidationTestResultsGetterExecution();
+        CompletableFuture<Boolean> completableFuture = CompletableFuture
                 .supplyAsync(new PrioritySupplier<>(1, task::execute), service);
-        completableFuture.thenAcceptAsync(results -> this.callbackNotify(results));
+        completableFuture.thenAcceptAsync(callOutcome -> this.callbackNotify(callOutcome));
     }
 
-    private void callbackNotify(List<List<ValidationNexusTestResult>> results) {
+    private void callbackNotify(Boolean outcome) {
+        LOGGER.debug(EELFLoggerDelegate.debugLogger, "Result of validation result getter execution: " + outcome);
         try {
-            for (List<ValidationNexusTestResult> result : results) {
-
-                LOGGER.debug(EELFLoggerDelegate.debugLogger,
-                        "Validation test results retrieved from nexus with size : " + result.size());
-                dbAdapter.deleteUnreferencedEntries(result);
-                dbAdapter.storeResultInDb(result);
-            }
             Thread.sleep(Integer.valueOf(PortalApiProperties.getProperty("thread_sleep")));
         } catch (Exception e) {
-            LOGGER.error(EELFLoggerDelegate.errorLogger,
-                    "Error in callback notification. " + UserUtils.getStackTrace(e));
+            LOGGER.error(EELFLoggerDelegate.errorLogger, "Error in thread sleep. " + UserUtils.getStackTrace(e));
         }
         // Trigger the next retrieval of results
         ApplicationContext context = new AnnotationConfigApplicationContext(ExecutorServiceInitializer.class);
         ExecutorService service = (ExecutorService) context.getBean("executorService");
-        ValidationNexusTestResultsGetterExecution task = new ValidationNexusTestResultsGetterExecution();
-        CompletableFuture<List<List<ValidationNexusTestResult>>> completableFuture = CompletableFuture
+        ValidationTestResultsGetterExecution task = new ValidationTestResultsGetterExecution();
+        CompletableFuture<Boolean> completableFuture = CompletableFuture
                 .supplyAsync(new PrioritySupplier<>(1, task::execute), service);
-        completableFuture.thenAcceptAsync(newResults -> this.callbackNotify(newResults));
+        completableFuture.thenAcceptAsync(callOutcome -> this.callbackNotify(callOutcome));
     }
 
-    private class ValidationNexusTestResultsGetterExecution {
+    private class ValidationTestResultsGetterExecution {
 
-        public ValidationNexusTestResultsGetterExecution() {
+        public ValidationTestResultsGetterExecution() {
         }
 
-        public List<List<ValidationNexusTestResult>> execute() {
-            List<List<ValidationNexusTestResult>> results = new ArrayList<List<ValidationNexusTestResult>>();
+        public Boolean execute() {
             try {
-                for (Lab lab : integratedService.getLabsFromNexus()) {
+                for (String lab : integratedService.getLabsFromNexus()) {
                     for (String blueprintName : integratedService.getBlueprintNamesOfLabFromNexus(lab)) {
                         for (String version : integratedService.getBlueprintVersionsFromNexus(blueprintName, lab)) {
                             LOGGER.debug(EELFLoggerDelegate.debugLogger,
-                                    "Trying to retrieve validation test result from nexus for: blueprint name: "
-                                            + blueprintName + ", version: " + version + " and lab: " + lab.name());
-                            results.add(integratedService.getResultsFromNexus(blueprintName, version, lab,
-                                    Integer.valueOf(PortalApiProperties.getProperty("no_last_timestamps"))));
+                                    "Trying to retrieve validation test result from nexus for blueprint name: "
+                                            + blueprintName + ", version: " + version + " and lab: " + lab);
+                            try {
+                                List<ValidationDbTestResult> results = integratedService.getResultsFromNexus(
+                                        blueprintName, version, lab,
+                                        Integer.valueOf(PortalApiProperties.getProperty("no_last_timestamps")));
+                                LOGGER.debug(EELFLoggerDelegate.debugLogger,
+                                        "Validation test results retrieved from nexus with size : " + results.size());
+                                dbAdapter.deleteUnreferencedEntries(results);
+                                dbAdapter.storeResultsInDb(results);
+                            } catch (Exception e) {
+                                LOGGER.error(EELFLoggerDelegate.errorLogger,
+                                        "Error when trying to receive results from nexus for blueprint name: "
+                                                + blueprintName + ", version: " + version + " and lab: " + lab + ". "
+                                                + UserUtils.getStackTrace(e));
+                            }
                         }
                     }
                 }
             } catch (Exception e) {
                 LOGGER.error(EELFLoggerDelegate.errorLogger,
                         "Error when retrieving Nexus results. " + UserUtils.getStackTrace(e));
+                return false;
             }
-            return results;
+            return true;
         }
     }
 
@@ -18,8 +18,8 @@ package org.akraino.validation.ui.controller;
 
 import java.util.List;
 
-import org.akraino.validation.ui.entity.BlueprintInstanceForValidation;
-import org.akraino.validation.ui.service.BlueprintInstanceForValidationService;
+import org.akraino.validation.ui.entity.BlueprintInstance;
+import org.akraino.validation.ui.service.BlueprintInstanceService;
 import org.onap.portalsdk.core.controller.RestrictedBaseController;
 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.onap.portalsdk.core.web.support.UserUtils;
@@ -31,23 +31,22 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 
 @Controller
-@RequestMapping("/api/v1/blueprintinstanceforvalidation")
-public class BlueprintInstanceForValidationController extends RestrictedBaseController {
+@RequestMapping("/api/v1/blueprintinstance")
+public class BlueprintInstanceController extends RestrictedBaseController {
 
-    private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate
-            .getLogger(BlueprintInstanceForValidationController.class);
+    private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(BlueprintInstanceController.class);
 
     @Autowired
-    BlueprintInstanceForValidationService service;
+    BlueprintInstanceService service;
 
-    public BlueprintInstanceForValidationController() {
+    public BlueprintInstanceController() {
         super();
     }
 
     @RequestMapping(value = { "/" }, method = RequestMethod.GET)
-    public ResponseEntity<List<BlueprintInstanceForValidation>> getBlueprintInstancesForValidation() {
+    public ResponseEntity<List<BlueprintInstance>> getBlueprintInstances() {
         try {
-            return new ResponseEntity<>(service.getBlueprintInstancesForValidation(), HttpStatus.OK);
+            return new ResponseEntity<>(service.getBlueprintInstances(), HttpStatus.OK);
         } catch (Exception e) {
             LOGGER.error(EELFLoggerDelegate.errorLogger,
                     "Error when trying to get blueprint instances for validation. " + UserUtils.getStackTrace(e));
@@ -18,8 +18,8 @@ package org.akraino.validation.ui.controller;
 
 import java.util.List;
 
-import org.akraino.validation.ui.entity.LabSilo;
-import org.akraino.validation.ui.service.SiloService;
+import org.akraino.validation.ui.entity.LabInfo;
+import org.akraino.validation.ui.service.LabService;
 import org.onap.portalsdk.core.controller.RestrictedBaseController;
 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.onap.portalsdk.core.web.support.UserUtils;
@@ -31,25 +31,25 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 
 @Controller
-@RequestMapping("/api/v1/silo")
-public class SiloController extends RestrictedBaseController {
+@RequestMapping("/api/v1/lab")
+public class LabController extends RestrictedBaseController {
 
-    private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(SiloController.class);
+    private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(LabController.class);
 
     @Autowired
-    SiloService service;
+    LabService service;
 
-    public SiloController() {
+    public LabController() {
         super();
     }
 
     @RequestMapping(value = { "/" }, method = RequestMethod.GET)
-    public ResponseEntity<List<LabSilo>> getSilos() {
+    public ResponseEntity<List<LabInfo>> getLabs() {
         try {
-            return new ResponseEntity<>(service.getSilos(), HttpStatus.OK);
+            return new ResponseEntity<>(service.getLabs(), HttpStatus.OK);
         } catch (Exception e) {
             LOGGER.error(EELFLoggerDelegate.errorLogger,
-                    "Error when trying to get lab silos. " + UserUtils.getStackTrace(e));
+                    "Error when trying to get labs. " + UserUtils.getStackTrace(e));
         }
         return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
     }
index f9c205a..b923d61 100644 (file)
@@ -20,9 +20,7 @@ import java.text.SimpleDateFormat;
 import java.util.List;
 import java.util.Set;
 
-import org.akraino.validation.ui.client.nexus.resources.ValidationNexusTestResult;
-import org.akraino.validation.ui.data.BlueprintLayer;
-import org.akraino.validation.ui.data.Lab;
+import org.akraino.validation.ui.entity.ValidationDbTestResult;
 import org.akraino.validation.ui.service.DbResultAdapter;
 import org.akraino.validation.ui.service.IntegratedResultService;
 import org.onap.portalsdk.core.controller.RestrictedBaseController;
@@ -52,18 +50,8 @@ public class ResultController extends RestrictedBaseController {
         super();
     }
 
-    @RequestMapping(value = { "/getlabs/" }, method = RequestMethod.GET)
-    public ResponseEntity<Set<Lab>> getLabs() {
-        try {
-            return new ResponseEntity<>(resultService.getLabsFromDb(), HttpStatus.OK);
-        } catch (Exception e) {
-            LOGGER.error(EELFLoggerDelegate.errorLogger, "Error when retrieving labs. " + UserUtils.getStackTrace(e));
-        }
-        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
-    }
-
     @RequestMapping(value = { "/getblueprintnamesoflab/{lab}" }, method = RequestMethod.GET)
-    public ResponseEntity<Set<String>> getBlueprintNamesOfLab(@PathVariable("lab") Lab lab) {
+    public ResponseEntity<Set<String>> getBlueprintNamesOfLab(@PathVariable("lab") String lab) {
         try {
             return new ResponseEntity<>(resultService.getBlueprintNamesOfLabFromDb(lab), HttpStatus.OK);
         } catch (Exception e) {
@@ -75,7 +63,7 @@ public class ResultController extends RestrictedBaseController {
 
     @RequestMapping(value = { "/getblueprintversions/{name}/{lab}" }, method = RequestMethod.GET)
     public ResponseEntity<Set<String>> getBlueprintVersions(@PathVariable("name") String name,
-            @PathVariable("lab") Lab lab) {
+            @PathVariable("lab") String lab) {
         try {
             return new ResponseEntity<>(resultService.getBlueprintVersionsFromDb(name, lab), HttpStatus.OK);
         } catch (Exception e) {
@@ -86,7 +74,7 @@ public class ResultController extends RestrictedBaseController {
     }
 
     @RequestMapping(value = { "/getbysubmissionid/{id}" }, method = RequestMethod.GET)
-    public ResponseEntity<ValidationNexusTestResult> getBySubmissionId(@PathVariable("id") String submissionId) {
+    public ResponseEntity<ValidationDbTestResult> getBySubmissionId(@PathVariable("id") String submissionId) {
         try {
             return new ResponseEntity<>(resultService.getResults(submissionId), HttpStatus.OK);
         } catch (Exception e) {
@@ -97,8 +85,8 @@ public class ResultController extends RestrictedBaseController {
     }
 
     @RequestMapping(value = { "/getmostrecent/{name}/{version}/{lab}" }, method = RequestMethod.GET)
-    public ResponseEntity<List<ValidationNexusTestResult>> getMostRecent(@PathVariable("name") String name,
-            @PathVariable("version") String version, @PathVariable("lab") Lab lab) {
+    public ResponseEntity<List<ValidationDbTestResult>> getMostRecent(@PathVariable("name") String name,
+            @PathVariable("version") String version, @PathVariable("lab") String lab) {
         try {
             return new ResponseEntity<>(dbAdapter.readResultFromDb(name, version, lab, null, null, null, null),
                     HttpStatus.OK);
@@ -110,7 +98,7 @@ public class ResultController extends RestrictedBaseController {
     }
 
     @RequestMapping(value = { "/getbytimestamp/{lab}/{name}/{version}/{timestamp}" }, method = RequestMethod.GET)
-    public ResponseEntity<ValidationNexusTestResult> getByTimestamp(@PathVariable("lab") Lab lab,
+    public ResponseEntity<ValidationDbTestResult> getByTimestamp(@PathVariable("lab") String lab,
             @PathVariable("name") String name, @PathVariable("version") String version,
             @PathVariable("timestamp") String timestamp) {
         try {
@@ -124,7 +112,7 @@ public class ResultController extends RestrictedBaseController {
 
     @RequestMapping(value = {
     "/getlastrun/{lab}/{name}/{version}/{allLayers}/{optional}/{outcome}" }, method = RequestMethod.GET)
-    public ResponseEntity<ValidationNexusTestResult> getLastRun(@PathVariable("lab") Lab lab,
+    public ResponseEntity<ValidationDbTestResult> getLastRun(@PathVariable("lab") String lab,
             @PathVariable("name") String name, @PathVariable("version") String version,
             @PathVariable("allLayers") Boolean allLayers, @PathVariable("optional") Boolean optional,
             @PathVariable("outcome") boolean outcome) {
@@ -141,9 +129,9 @@ public class ResultController extends RestrictedBaseController {
 
     @RequestMapping(value = {
     "/getlastrunoflayers/{lab}/{name}/{version}/{layers}/{optional}/{outcome}" }, method = RequestMethod.GET)
-    public ResponseEntity<ValidationNexusTestResult> getLastRunOfLayers(@PathVariable("lab") Lab lab,
+    public ResponseEntity<ValidationDbTestResult> getLastRunOfLayers(@PathVariable("lab") String lab,
             @PathVariable("name") String name, @PathVariable("version") String version,
-            @PathVariable("layers") List<BlueprintLayer> layers, @PathVariable("optional") Boolean optional,
+            @PathVariable("layers") List<String> layers, @PathVariable("optional") Boolean optional,
             @PathVariable("outcome") boolean outcome) {
         try {
             return new ResponseEntity<>(
@@ -157,7 +145,7 @@ public class ResultController extends RestrictedBaseController {
     }
 
     @RequestMapping(value = { "/getbasedondate/{lab}/{name}/{version}/{date}" }, method = RequestMethod.GET)
-    public ResponseEntity<List<ValidationNexusTestResult>> getBasedOnDate(@PathVariable("lab") Lab lab,
+    public ResponseEntity<List<ValidationDbTestResult>> getBasedOnDate(@PathVariable("lab") String lab,
             @PathVariable("name") String name, @PathVariable("version") String version,
             @PathVariable("date") String date) {
         try {
index 49215b1..a60cfbf 100644 (file)
@@ -17,7 +17,7 @@ package org.akraino.validation.ui.controller;
 
 import java.util.List;
 
-import org.akraino.validation.ui.data.SubmissionData;
+import org.akraino.validation.ui.entity.Submission;
 import org.akraino.validation.ui.service.DbSubmissionAdapter;
 import org.onap.portalsdk.core.controller.RestrictedBaseController;
 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
@@ -45,9 +45,9 @@ public class SubmissionController extends RestrictedBaseController {
     }
 
     @RequestMapping(value = { "/" }, method = RequestMethod.GET)
-    public ResponseEntity<List<SubmissionData>> getSubmissions() {
+    public ResponseEntity<List<Submission>> getSubmissions() {
         try {
-            return new ResponseEntity<>(service.getSubmissionDatas(), HttpStatus.OK);
+            return new ResponseEntity<>(service.getSubmissions(), HttpStatus.OK);
         } catch (Exception e) {
             LOGGER.error(EELFLoggerDelegate.errorLogger, "Get of submissions failed. " + UserUtils.getStackTrace(e));
         }
@@ -55,9 +55,9 @@ public class SubmissionController extends RestrictedBaseController {
     }
 
     @RequestMapping(value = { "/{id}" }, method = RequestMethod.GET)
-    public ResponseEntity<SubmissionData> getSubmission(@PathVariable("id") String submissionId) {
+    public ResponseEntity<Submission> getSubmission(@PathVariable("id") String submissionId) {
         try {
-            return new ResponseEntity<>(service.getSubmissionData(submissionId), HttpStatus.OK);
+            return new ResponseEntity<>(service.getSubmission(submissionId), HttpStatus.OK);
         } catch (Exception e) {
             LOGGER.error(EELFLoggerDelegate.errorLogger, "Get of submission failed. " + UserUtils.getStackTrace(e));
         }
@@ -65,9 +65,9 @@ public class SubmissionController extends RestrictedBaseController {
     }
 
     @RequestMapping(value = { "/" }, method = RequestMethod.POST)
-    public ResponseEntity<SubmissionData> postSubmission(@RequestBody SubmissionData submissionData) {
+    public ResponseEntity<Submission> postSubmission(@RequestBody Submission submission) {
         try {
-            return new ResponseEntity<>(service.saveSubmission(submissionData), HttpStatus.OK);
+            return new ResponseEntity<>(service.saveSubmission(submission), HttpStatus.OK);
         } catch (Exception e) {
             LOGGER.error(EELFLoggerDelegate.errorLogger, "Post of submission failed. " + UserUtils.getStackTrace(e));
         }
index 537d298..62dc96b 100644 (file)
@@ -29,6 +29,8 @@ public interface BlueprintDAO {
 
     Blueprint getBlueprint(Integer blueprintId);
 
+    Blueprint getBlueprint(String name);
+
     void deleteBlueprint(Blueprint blueprint);
 
     void deleteAll();
@@ -17,19 +17,22 @@ package org.akraino.validation.ui.dao;
 
 import java.util.List;
 
-import org.akraino.validation.ui.entity.BlueprintInstanceForValidation;
+import org.akraino.validation.ui.entity.Blueprint;
+import org.akraino.validation.ui.entity.BlueprintInstance;
 
-public interface BlueprintInstanceForValidationDAO {
+public interface BlueprintInstanceDAO {
 
-    void saveOrUpdate(BlueprintInstanceForValidation blueprintInst);
+    void saveOrUpdate(BlueprintInstance blueprintInst);
 
-    void merge(BlueprintInstanceForValidation blueprintInst);
+    void merge(BlueprintInstance blueprintInst);
 
-    List<BlueprintInstanceForValidation> getBlueprintInstancesForValidation();
+    List<BlueprintInstance> getBlueprintInstances();
 
-    BlueprintInstanceForValidation getBlueprintInstanceForValidation(Integer instId);
+    BlueprintInstance getBlueprintInstance(Integer instId);
 
-    void deleteBlueprintInstanceForValidation(BlueprintInstanceForValidation blueprintInst);
+    BlueprintInstance getBlueprintInstance(Blueprint blueprint, String version);
+
+    void deleteBlueprintInstance(BlueprintInstance blueprintInst);
 
     void deleteAll();
 
@@ -17,19 +17,21 @@ package org.akraino.validation.ui.dao;
 
 import java.util.List;
 
-import org.akraino.validation.ui.entity.LabSilo;
+import org.akraino.validation.ui.entity.BlueprintLayer;
 
-public interface SiloDAO {
+public interface BlueprintLayerDAO {
 
-    void saveOrUpdate(LabSilo silo);
+    void saveOrUpdate(BlueprintLayer blueprintLayer);
 
-    void merge(LabSilo silo);
+    void merge(BlueprintLayer blueprintLayer);
 
-    List<LabSilo> getSilos();
+    List<BlueprintLayer> getBlueprintLayers();
 
-    LabSilo getSilo(Integer siloId);
+    BlueprintLayer getBlueprintLayer(Integer bluLayerId);
 
-    void deleteSilo(LabSilo silo);
+    BlueprintLayer getBlueprintLayer(String layer);
+
+    void deleteBlueprintLayer(BlueprintLayer blueprintLayer);
 
     void deleteAll();
 
index 6929f5f..e43e3b9 100644 (file)
@@ -17,7 +17,6 @@ package org.akraino.validation.ui.dao;
 
 import java.util.List;
 
-import org.akraino.validation.ui.data.Lab;
 import org.akraino.validation.ui.entity.LabInfo;
 
 public interface LabDAO {
@@ -30,7 +29,9 @@ public interface LabDAO {
 
     LabInfo getLab(Integer labId);
 
-    LabInfo getLab(Lab lab);
+    LabInfo getLab(String lab);
+
+    LabInfo getLabBasedOnSilo(String silo);
 
     void deleteLab(LabInfo lab);
 
index 6325606..680ac19 100644 (file)
@@ -17,6 +17,7 @@ package org.akraino.validation.ui.dao;
 
 import java.util.List;
 
+import org.akraino.validation.ui.entity.BlueprintInstance;
 import org.akraino.validation.ui.entity.LabInfo;
 import org.akraino.validation.ui.entity.Submission;
 import org.akraino.validation.ui.entity.ValidationDbTestResult;
@@ -31,7 +32,7 @@ public interface ValidationTestResultDAO {
 
     ValidationDbTestResult getValidationTestResult(Integer resultId);
 
-    List<ValidationDbTestResult> getValidationTestResults(String blueprintName, String version, LabInfo labInfo,
+    List<ValidationDbTestResult> getValidationTestResults(BlueprintInstance bluInst, LabInfo labInfo,
             Boolean allLayers, Boolean optional, Boolean outcome);
 
     ValidationDbTestResult getValidationTestResult(LabInfo labInfo, String timestamp);
index a349bcf..6c751ad 100644 (file)
@@ -44,14 +44,24 @@ public class BlueprintDAOImpl implements BlueprintDAO {
     @Override
     public List<Blueprint> getBlueprints() {
         Criteria criteria = getSession().createCriteria(Blueprint.class);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
         return criteria.list();
     }
 
     @Override
     public Blueprint getBlueprint(@Nonnull Integer blueprintId) {
         Criteria criteria = getSession().createCriteria(Blueprint.class);
-        criteria.add(Restrictions.eq("id", String.valueOf(blueprintId)));
-        return criteria.list() == null ? null : (Blueprint) criteria.list().get(0);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
+        criteria.add(Restrictions.eq("id", blueprintId));
+        return criteria.list() == null || criteria.list().size() < 1 ? null : (Blueprint) criteria.list().get(0);
+    }
+
+    @Override
+    public Blueprint getBlueprint(String name) {
+        Criteria criteria = getSession().createCriteria(Blueprint.class);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
+        criteria.add(Restrictions.eq("blueprintName", name));
+        return criteria.list() == null || criteria.list().size() < 1 ? null : (Blueprint) criteria.list().get(0);
     }
 
     @Override
@@ -19,8 +19,9 @@ import java.util.List;
 
 import javax.annotation.Nonnull;
 
-import org.akraino.validation.ui.dao.BlueprintInstanceForValidationDAO;
-import org.akraino.validation.ui.entity.BlueprintInstanceForValidation;
+import org.akraino.validation.ui.dao.BlueprintInstanceDAO;
+import org.akraino.validation.ui.entity.Blueprint;
+import org.akraino.validation.ui.entity.BlueprintInstance;
 import org.hibernate.Criteria;
 import org.hibernate.Session;
 import org.hibernate.SessionFactory;
@@ -30,10 +31,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Repository;
 
 @Repository
-public class BlueprintInstanceForValidationDAOImpl implements BlueprintInstanceForValidationDAO {
+public class BlueprintInstanceDAOImpl implements BlueprintInstanceDAO {
 
-    private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate
-            .getLogger(BlueprintInstanceForValidationDAOImpl.class);
+    private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(BlueprintInstanceDAOImpl.class);
 
     @Autowired
     private SessionFactory sessionFactory;
@@ -43,41 +43,57 @@ public class BlueprintInstanceForValidationDAOImpl implements BlueprintInstanceF
     }
 
     @Override
-    public List<BlueprintInstanceForValidation> getBlueprintInstancesForValidation() {
-        Criteria criteria = getSession().createCriteria(BlueprintInstanceForValidation.class);
+    public List<BlueprintInstance> getBlueprintInstances() {
+        Criteria criteria = getSession().createCriteria(BlueprintInstance.class);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
         return criteria.list();
     }
 
     @Override
-    public BlueprintInstanceForValidation getBlueprintInstanceForValidation(@Nonnull Integer instId) {
-        Criteria criteria = getSession().createCriteria(BlueprintInstanceForValidation.class);
-        criteria.add(Restrictions.eq("id", String.valueOf(instId)));
-        return criteria.list() == null ? null : (BlueprintInstanceForValidation) criteria.list().get(0);
+    public BlueprintInstance getBlueprintInstance(@Nonnull Integer instId) {
+        Criteria criteria = getSession().createCriteria(BlueprintInstance.class);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
+        criteria.add(Restrictions.eq("id", instId));
+        return criteria.list() == null || criteria.list().size() < 1 ? null
+                : (BlueprintInstance) criteria.list().get(0);
     }
 
     @Override
-    public void saveOrUpdate(@Nonnull BlueprintInstanceForValidation blueprintInst) {
+    public BlueprintInstance getBlueprintInstance(Blueprint blueprint, String version) {
+        Criteria criteria = getSession().createCriteria(BlueprintInstance.class);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
+        if (blueprint != null) {
+            criteria.add(Restrictions.eq("blueprint", blueprint));
+        }
+        if (version != null) {
+            criteria.add(Restrictions.eq("version", version));
+        }
+        return criteria.list() == null || criteria.list().size() < 1 ? null
+                : (BlueprintInstance) criteria.list().get(0);
+    }
+
+    @Override
+    public void saveOrUpdate(@Nonnull BlueprintInstance blueprintInst) {
         getSession().saveOrUpdate(blueprintInst);
         getSession().flush();
     }
 
     @Override
-    public void merge(@Nonnull BlueprintInstanceForValidation blueprintInst) {
+    public void merge(@Nonnull BlueprintInstance blueprintInst) {
         getSession().merge(blueprintInst);
         getSession().flush();
     }
 
     @Override
-    public void deleteBlueprintInstanceForValidation(@Nonnull BlueprintInstanceForValidation blueprintInst) {
+    public void deleteBlueprintInstance(@Nonnull BlueprintInstance blueprintInst) {
         getSession().delete(blueprintInst);
         getSession().flush();
     }
 
     @Override
     public void deleteAll() {
-        if (getSession().createQuery("delete from BlueprintInstanceForValidation").executeUpdate() > 0) {
-            LOGGER.info(EELFLoggerDelegate.applicationLogger,
-                    "All blueprint instances for validation entries are cleaned up");
+        if (getSession().createQuery("delete from BlueprintInstance").executeUpdate() > 0) {
+            LOGGER.info(EELFLoggerDelegate.applicationLogger, "All blueprint instances entries are cleaned up");
             getSession().flush();
         }
     }
diff --git a/ui/src/main/java/org/akraino/validation/ui/daoimpl/BlueprintLayerDAOImpl.java b/ui/src/main/java/org/akraino/validation/ui/daoimpl/BlueprintLayerDAOImpl.java
new file mode 100644 (file)
index 0000000..dad10ac
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2019 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.
+ */
+package org.akraino.validation.ui.daoimpl;
+
+import java.util.List;
+
+import org.akraino.validation.ui.dao.BlueprintLayerDAO;
+import org.akraino.validation.ui.entity.BlueprintLayer;
+import org.hibernate.Criteria;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.criterion.Restrictions;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class BlueprintLayerDAOImpl implements BlueprintLayerDAO {
+
+    private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(BlueprintLayerDAOImpl.class);
+
+    @Autowired
+    private SessionFactory sessionFactory;
+
+    protected Session getSession() {
+        return sessionFactory.getCurrentSession();
+    }
+
+    @Override
+    public List<BlueprintLayer> getBlueprintLayers() {
+        Criteria criteria = getSession().createCriteria(BlueprintLayer.class);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
+        return criteria.list();
+    }
+
+    @Override
+    public BlueprintLayer getBlueprintLayer(Integer bluLayerId) {
+        Criteria criteria = getSession().createCriteria(BlueprintLayer.class);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
+        criteria.add(Restrictions.eq("id", bluLayerId));
+        return criteria.list() == null || criteria.list().size() < 1 ? null : (BlueprintLayer) criteria.list().get(0);
+    }
+
+    @Override
+    public BlueprintLayer getBlueprintLayer(String layer) {
+        Criteria criteria = getSession().createCriteria(BlueprintLayer.class);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
+        criteria.add(Restrictions.eq("layer", layer));
+        return criteria.list() == null || criteria.list().size() < 1 ? null : (BlueprintLayer) criteria.list().get(0);
+    }
+
+    @Override
+    public void saveOrUpdate(BlueprintLayer blueprintLayer) {
+        getSession().saveOrUpdate(blueprintLayer);
+        getSession().flush();
+    }
+
+    @Override
+    public void merge(BlueprintLayer blueprintLayer) {
+        getSession().merge(blueprintLayer);
+        getSession().flush();
+    }
+
+    @Override
+    public void deleteBlueprintLayer(BlueprintLayer blueprintLayer) {
+        getSession().delete(blueprintLayer);
+        getSession().flush();
+    }
+
+    @Override
+    public void deleteAll() {
+        if (getSession().createQuery("delete from BlueprintLayer").executeUpdate() > 0) {
+            getSession().flush();
+            LOGGER.info(EELFLoggerDelegate.applicationLogger, "All blueprint layers are cleaned up");
+        }
+    }
+
+}
index 36512ab..1bfc231 100644 (file)
@@ -20,7 +20,6 @@ import java.util.List;
 import javax.annotation.Nonnull;
 
 import org.akraino.validation.ui.dao.LabDAO;
-import org.akraino.validation.ui.data.Lab;
 import org.akraino.validation.ui.entity.LabInfo;
 import org.hibernate.Criteria;
 import org.hibernate.Session;
@@ -45,21 +44,32 @@ public class LabDAOImpl implements LabDAO {
     @Override
     public List<LabInfo> getLabs() {
         Criteria criteria = getSession().createCriteria(LabInfo.class);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
         return criteria.list();
     }
 
     @Override
     public LabInfo getLab(@Nonnull Integer labId) {
         Criteria criteria = getSession().createCriteria(LabInfo.class);
-        criteria.add(Restrictions.eq("id", String.valueOf(labId)));
-        return criteria.list() == null ? null : (LabInfo) criteria.list().get(0);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
+        criteria.add(Restrictions.eq("id", labId));
+        return criteria.list() == null || criteria.list().size() < 1 ? null : (LabInfo) criteria.list().get(0);
     }
 
     @Override
-    public LabInfo getLab(@Nonnull Lab lab) {
+    public LabInfo getLab(@Nonnull String lab) {
         Criteria criteria = getSession().createCriteria(LabInfo.class);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
         criteria.add(Restrictions.eq("lab", lab));
-        return criteria.list() == null ? null : (LabInfo) criteria.list().get(0);
+        return criteria.list() == null || criteria.list().size() < 1 ? null : (LabInfo) criteria.list().get(0);
+    }
+
+    @Override
+    public LabInfo getLabBasedOnSilo(String silo) {
+        Criteria criteria = getSession().createCriteria(LabInfo.class);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
+        criteria.add(Restrictions.eq("silo", silo));
+        return criteria.list() == null || criteria.list().size() < 1 ? null : (LabInfo) criteria.list().get(0);
     }
 
     @Override
diff --git a/ui/src/main/java/org/akraino/validation/ui/daoimpl/SiloDAOImpl.java b/ui/src/main/java/org/akraino/validation/ui/daoimpl/SiloDAOImpl.java
deleted file mode 100644 (file)
index 8d3dffd..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2019 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.
- */
-package org.akraino.validation.ui.daoimpl;
-
-import java.util.List;
-
-import javax.annotation.Nonnull;
-
-import org.akraino.validation.ui.dao.SiloDAO;
-import org.akraino.validation.ui.entity.LabSilo;
-import org.hibernate.Criteria;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.criterion.Restrictions;
-import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Repository;
-
-@Repository
-public class SiloDAOImpl implements SiloDAO {
-
-    private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(SiloDAOImpl.class);
-
-    @Autowired
-    private SessionFactory sessionFactory;
-
-    protected Session getSession() {
-        return sessionFactory.getCurrentSession();
-    }
-
-    @Override
-    public List<LabSilo> getSilos() {
-        Criteria criteria = getSession().createCriteria(LabSilo.class);
-        return criteria.list();
-    }
-
-    @Override
-    public LabSilo getSilo(@Nonnull Integer siloId) {
-        Criteria criteria = getSession().createCriteria(LabSilo.class);
-        criteria.add(Restrictions.eq("id", String.valueOf(siloId)));
-        return criteria.list() == null ? null : (LabSilo) criteria.list().get(0);
-    }
-
-    @Override
-    public void saveOrUpdate(@Nonnull LabSilo silo) {
-        getSession().saveOrUpdate(silo);
-        getSession().flush();
-    }
-
-    @Override
-    public void merge(@Nonnull LabSilo silo) {
-        getSession().merge(silo);
-        getSession().flush();
-    }
-
-    @Override
-    public void deleteSilo(@Nonnull LabSilo silo) {
-        getSession().delete(silo);
-        getSession().flush();
-    }
-
-    @Override
-    public void deleteAll() {
-        if (getSession().createQuery("delete from Silo").executeUpdate() > 0) {
-            LOGGER.info(EELFLoggerDelegate.applicationLogger, "All silo entries are cleaned up");
-            getSession().flush();
-        }
-    }
-
-}
index 73e6e42..eb737b2 100644 (file)
@@ -44,12 +44,14 @@ public class SubmissionDAOImpl implements SubmissionDAO {
     @Override
     public List<Submission> getSubmissions() {
         Criteria criteria = getSession().createCriteria(Submission.class);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
         return criteria.list();
     }
 
     @Override
     public Submission getSubmission(@Nonnull Integer submissionId) {
         Criteria criteria = getSession().createCriteria(Submission.class);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
         criteria.add(Restrictions.eq("id", submissionId));
         return criteria.list() == null || criteria.list().size() < 1 ? null : (Submission) criteria.list().get(0);
     }
index f155944..92dfae4 100644 (file)
@@ -44,14 +44,16 @@ public class TimeslotDAOImpl implements TimeslotDAO {
     @Override
     public List<Timeslot> getTimeslots() {
         Criteria criteria = getSession().createCriteria(Timeslot.class);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
         return criteria.list();
     }
 
     @Override
     public Timeslot getTimeslot(@Nonnull Integer timeslotId) {
         Criteria criteria = getSession().createCriteria(Timeslot.class);
-        criteria.add(Restrictions.eq("id", String.valueOf(timeslotId)));
-        return criteria.list() == null ? null : (Timeslot) criteria.list().get(0);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
+        criteria.add(Restrictions.eq("id", timeslotId));
+        return criteria.list() == null || criteria.list().size() < 1 ? null : (Timeslot) criteria.list().get(0);
     }
 
     @Override
index ab5e180..e4d7f88 100644 (file)
@@ -20,6 +20,7 @@ import java.util.List;
 import javax.annotation.Nonnull;
 
 import org.akraino.validation.ui.dao.ValidationTestResultDAO;
+import org.akraino.validation.ui.entity.BlueprintInstance;
 import org.akraino.validation.ui.entity.LabInfo;
 import org.akraino.validation.ui.entity.Submission;
 import org.akraino.validation.ui.entity.ValidationDbTestResult;
@@ -46,25 +47,26 @@ public class ValidationTestResultDAOImpl implements ValidationTestResultDAO {
     @Override
     public List<ValidationDbTestResult> getValidationTestResults() {
         Criteria criteria = getSession().createCriteria(ValidationDbTestResult.class);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
         return criteria.list();
     }
 
     @Override
     public ValidationDbTestResult getValidationTestResult(@Nonnull Integer resultId) {
         Criteria criteria = getSession().createCriteria(ValidationDbTestResult.class);
-        criteria.add(Restrictions.eq("id", String.valueOf(resultId)));
-        return criteria.list() == null ? null : (ValidationDbTestResult) criteria.list().get(0);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
+        criteria.add(Restrictions.eq("id", resultId));
+        return (criteria.list() == null || criteria.list().size() < 1) ? null
+                : (ValidationDbTestResult) criteria.list().get(0);
     }
 
     @Override
-    public List<ValidationDbTestResult> getValidationTestResults(String blueprintName, String version, LabInfo labInfo,
+    public List<ValidationDbTestResult> getValidationTestResults(BlueprintInstance bluInst, LabInfo labInfo,
             Boolean allLayers, Boolean optional, Boolean outcome) {
         Criteria criteria = getSession().createCriteria(ValidationDbTestResult.class);
-        if (blueprintName != null) {
-            criteria.add(Restrictions.eq("blueprintName", String.valueOf(blueprintName)));
-        }
-        if (version != null) {
-            criteria.add(Restrictions.eq("version", String.valueOf(version)));
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
+        if (bluInst != null) {
+            criteria.add(Restrictions.eq("blueprintInstance", bluInst));
         }
         if (labInfo != null) {
             criteria.add(Restrictions.eq("lab", labInfo));
@@ -85,6 +87,7 @@ public class ValidationTestResultDAOImpl implements ValidationTestResultDAO {
     @Override
     public ValidationDbTestResult getValidationTestResult(LabInfo labInfo, String timestamp) {
         Criteria criteria = getSession().createCriteria(ValidationDbTestResult.class);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
         if (labInfo != null) {
             criteria.add(Restrictions.eq("lab", labInfo));
         }
@@ -98,6 +101,7 @@ public class ValidationTestResultDAOImpl implements ValidationTestResultDAO {
     @Override
     public ValidationDbTestResult getValidationTestResult(@Nonnull Submission submission) {
         Criteria criteria = getSession().createCriteria(ValidationDbTestResult.class);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
         criteria.add(Restrictions.eq("submission", submission));
         return criteria.list() == null || criteria.list().size() == 0 ? null
                 : (ValidationDbTestResult) criteria.list().get(0);
index 6c7a4c1..c8b1c5f 100644 (file)
@@ -45,12 +45,14 @@ public class WRobotTestResultDAOImpl implements WRobotTestResultDAO {
     @Override
     public List<WRobotDbTestResult> getWRobotTestResults() {
         Criteria criteria = getSession().createCriteria(WRobotDbTestResult.class);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
         return criteria.list();
     }
 
     @Override
     public WRobotDbTestResult getWRobotTestResult(@Nonnull Integer wRobotResultId) {
         Criteria criteria = getSession().createCriteria(WRobotDbTestResult.class);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
         criteria.add(Restrictions.eq("id", wRobotResultId));
         return criteria.list() == null || criteria.list().size() < 1 ? null
                 : (WRobotDbTestResult) criteria.list().get(0);
@@ -59,7 +61,8 @@ public class WRobotTestResultDAOImpl implements WRobotTestResultDAO {
     @Override
     public List<WRobotDbTestResult> getWRobotTestResult(@Nonnull ValidationDbTestResult vResult) {
         Criteria criteria = getSession().createCriteria(WRobotDbTestResult.class);
-        criteria.add(Restrictions.eq("vResult", vResult));
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
+        criteria.add(Restrictions.eq("validationDbTestResult", vResult));
         return criteria.list() == null || criteria.list().size() == 0 ? null
                 : (List<WRobotDbTestResult>) criteria.list();
     }
@@ -67,8 +70,9 @@ public class WRobotTestResultDAOImpl implements WRobotTestResultDAO {
     @Override
     public WRobotDbTestResult getWRobotTestResult(@Nonnull String layer, @Nonnull ValidationDbTestResult vResult) {
         Criteria criteria = getSession().createCriteria(WRobotDbTestResult.class);
+        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
         criteria.add(Restrictions.eq("layer", layer));
-        criteria.add(Restrictions.eq("vResult", vResult));
+        criteria.add(Restrictions.eq("validationDbTestResult", vResult));
         return criteria.list() == null || criteria.list().size() < 1 ? null
                 : (WRobotDbTestResult) criteria.list().get(0);
     }
diff --git a/ui/src/main/java/org/akraino/validation/ui/data/BlueprintLayer.java b/ui/src/main/java/org/akraino/validation/ui/data/BlueprintLayer.java
deleted file mode 100644 (file)
index 6a67943..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (c) 2019 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.
- */
-package org.akraino.validation.ui.data;
-
-public enum BlueprintLayer {
-    hardware, os, k8s, kubeless, openstack, vnf, application, networking
-}
diff --git a/ui/src/main/java/org/akraino/validation/ui/data/Lab.java b/ui/src/main/java/org/akraino/validation/ui/data/Lab.java
deleted file mode 100644 (file)
index c25d240..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (c) 2019 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.
- */
-package org.akraino.validation.ui.data;
-
-public enum Lab {
-    att, ericsson, community, arm
-}
diff --git a/ui/src/main/java/org/akraino/validation/ui/data/SubmissionData.java b/ui/src/main/java/org/akraino/validation/ui/data/SubmissionData.java
deleted file mode 100644 (file)
index d5b8223..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2019 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.
- */
-package org.akraino.validation.ui.data;
-
-import org.akraino.validation.ui.client.nexus.resources.ValidationNexusTestResult;
-import org.akraino.validation.ui.entity.Timeslot;
-
-public class SubmissionData {
-
-    private int submissionId;
-
-    private SubmissionStatus status;
-
-    private Timeslot timeslot;
-
-    private ValidationNexusTestResult validationNexusTestResult;
-
-    public SubmissionData() {
-
-    }
-
-    public int getSubmissionId() {
-        return this.submissionId;
-    }
-
-    public void setSubmissionId(int submissionId) {
-        this.submissionId = submissionId;
-    }
-
-    public SubmissionStatus getStatus() {
-        return this.status;
-    }
-
-    public void setStatus(SubmissionStatus status) {
-        this.status = status;
-    }
-
-    public Timeslot getTimeslot() {
-        return this.timeslot;
-    }
-
-    public void setTimeslot(Timeslot timeslot) {
-        this.timeslot = timeslot;
-    }
-
-    public ValidationNexusTestResult getValidationNexusTestResult() {
-        return this.validationNexusTestResult;
-    }
-
-    public void setValidationNexusTestResult(ValidationNexusTestResult validationNexusTestResult) {
-        this.validationNexusTestResult = validationNexusTestResult;
-    }
-}
index 262eecd..46f7e3a 100644 (file)
@@ -34,7 +34,7 @@ public class Blueprint implements Serializable {
     private static final long serialVersionUID = 1L;
 
     @Id
-    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
     @Column(name = "id")
     private int blueprintId;
 
 package org.akraino.validation.ui.entity;
 
 import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
 
+import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Entity;
+import javax.persistence.FetchType;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
 import javax.persistence.ManyToOne;
 import javax.persistence.Table;
 
-import org.akraino.validation.ui.data.BlueprintLayer;
-
 @Entity
-@Table(name = "blueprint_instance_for_validation")
-public class BlueprintInstanceForValidation implements Serializable {
+@Table(name = "blueprint_instance")
+public class BlueprintInstance implements Serializable {
 
     /**
      *
@@ -49,11 +53,11 @@ public class BlueprintInstanceForValidation implements Serializable {
     @Column(name = "version")
     private String version;
 
-    @Column(name = "layer")
-    private BlueprintLayer layer;
-
-    @Column(name = "layer_description")
-    private String layerDescription;
+    @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+    @JoinTable(name = "blueprint_instance_blueprint_layer", joinColumns = {
+            @JoinColumn(name = "blueprint_instance_id") }, inverseJoinColumns = {
+                    @JoinColumn(name = "blueprint_layer_id") })
+    private Set<BlueprintLayer> blueprintLayers = new HashSet<>();
 
     public int getBlueprintInstanceId() {
         return blueprintInstId;
@@ -79,19 +83,12 @@ public class BlueprintInstanceForValidation implements Serializable {
         return version;
     }
 
-    public BlueprintLayer getLayer() {
-        return layer;
+    public Set<BlueprintLayer> getBlueprintLayers() {
+        return blueprintLayers;
     }
 
-    public void setLayer(BlueprintLayer layer) {
-        this.layer = layer;
+    public void setBlueprintLayers(Set<BlueprintLayer> blueprintLayers) {
+        this.blueprintLayers = blueprintLayers;
     }
 
-    public void setLayerDescription(String layerDescription) {
-        this.layerDescription = layerDescription;
-    }
-
-    public String getLayerDescription() {
-        return layerDescription;
-    }
 }
@@ -22,13 +22,11 @@ import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
 import javax.persistence.Table;
 
 @Entity
-@Table(name = "silo")
-public class LabSilo implements Serializable {
+@Table(name = "blueprint_layer")
+public class BlueprintLayer implements Serializable {
 
     /**
      *
@@ -38,36 +36,25 @@ public class LabSilo implements Serializable {
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     @Column(name = "id")
-    private int siloId;
+    private int blueprintLayerId;
 
-    @Column(name = "silo")
-    private String silo;
+    @Column(name = "layer")
+    private String layer;
 
-    @ManyToOne
-    @JoinColumn(name = "lab_id")
-    private LabInfo lab;
-
-    public void setSiloId(int siloId) {
-        this.siloId = siloId;
-    }
-
-    public int getSiloId() {
-        return siloId;
+    public int getBlueprintLayerId() {
+        return blueprintLayerId;
     }
 
-    public void setSilo(String silo) {
-        this.silo = silo;
+    public void setblueprintLayerId(int blueprintLayerId) {
+        this.blueprintLayerId = blueprintLayerId;
     }
 
-    public String getSilo() {
-        return silo;
+    public String getLayer() {
+        return layer;
     }
 
-    public void setLab(LabInfo lab) {
-        this.lab = lab;
+    public void setLayer(String layer) {
+        this.layer = layer;
     }
 
-    public LabInfo getLab() {
-        return lab;
-    }
 }
index 0d4801a..3b768f9 100644 (file)
@@ -24,8 +24,6 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
-import org.akraino.validation.ui.data.Lab;
-
 @Entity
 @Table(name = "lab")
 public class LabInfo implements Serializable {
@@ -41,7 +39,10 @@ public class LabInfo implements Serializable {
     private int labId;
 
     @Column(name = "lab")
-    private Lab lab;
+    private String lab;
+
+    @Column(name = "silo")
+    private String silo;
 
     public int getLabId() {
         return labId;
@@ -51,11 +52,20 @@ public class LabInfo implements Serializable {
         this.labId = labId;
     }
 
-    public Lab getLab() {
+    public String getLab() {
         return lab;
     }
 
-    public void setLab(Lab lab) {
+    public void setLab(String lab) {
         this.lab = lab;
     }
+
+    public String getSilo() {
+        return silo;
+    }
+
+    public void setSilo(String silo) {
+        this.silo = silo;
+    }
+
 }
index bdbe535..a4c797c 100644 (file)
  */
 package org.akraino.validation.ui.entity;
 
+import java.io.IOException;
 import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
 
 import javax.persistence.Column;
 import javax.persistence.Entity;
+import javax.persistence.FetchType;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.JoinColumn;
 import javax.persistence.ManyToOne;
+import javax.persistence.OneToOne;
 import javax.persistence.Table;
 
 import org.akraino.validation.ui.data.SubmissionStatus;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.web.support.UserUtils;
+
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
 
 @Entity
 @Table(name = "submission")
 public class Submission implements Serializable {
 
+    private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(Submission.class);
+
     /**
      *
      */
@@ -49,6 +62,10 @@ public class Submission implements Serializable {
     @JoinColumn(name = "timeslot_id")
     private Timeslot timeslot;
 
+    @OneToOne(mappedBy = "submission", targetEntity = ValidationDbTestResult.class, fetch = FetchType.EAGER)
+    @JsonSerialize(using = ValidationDbTestResultSerializer.class)
+    private ValidationDbTestResult validationDbTestResult;
+
     public void setSubmissionId(int submissionId) {
         this.submissionId = submissionId;
     }
@@ -73,4 +90,55 @@ public class Submission implements Serializable {
         return this.timeslot;
     }
 
+    public void setValidationDbTestResult(ValidationDbTestResult validationDbTestResult) {
+        this.validationDbTestResult = validationDbTestResult;
+    }
+
+    public ValidationDbTestResult getValidationDbTestResult() {
+        return validationDbTestResult;
+    }
+
+    static class ValidationDbTestResultSerializer extends StdSerializer<ValidationDbTestResult> {
+
+        public ValidationDbTestResultSerializer() {
+            this(null);
+        }
+
+        public ValidationDbTestResultSerializer(Class<ValidationDbTestResult> t) {
+            super(t);
+        }
+
+        @Override
+        public void serialize(ValidationDbTestResult validationDbTestResult,
+                com.fasterxml.jackson.core.JsonGenerator gen, SerializerProvider provider) throws IOException {
+            ValidationDbTestResult result = new ValidationDbTestResult();
+            try {
+                result.setResultId(validationDbTestResult.getResultId());
+                result.setAllLayers(validationDbTestResult.getAllLayers());
+                result.setBlueprintInstance(validationDbTestResult.getBlueprintInstance());
+                result.setDateStorage(validationDbTestResult.getDateStorage());
+                result.setLab(validationDbTestResult.getLab());
+                result.setOptional(validationDbTestResult.getOptional());
+                result.setResult(validationDbTestResult.getResult());
+                result.setTimestamp(validationDbTestResult.getTimestamp());
+                Set<WRobotDbTestResult> wRobotDbTestResults = new HashSet<WRobotDbTestResult>();
+                if (validationDbTestResult.getWRobotDbTestResults() != null
+                        && validationDbTestResult.getWRobotDbTestResults().size() > 0) {
+                    for (WRobotDbTestResult wRobotDbTestResult : validationDbTestResult.getWRobotDbTestResults()) {
+                        WRobotDbTestResult temp = new WRobotDbTestResult();
+                        temp.setLayer(wRobotDbTestResult.getLayer());
+                        // No need for robot results when fetching submissions
+                        // temp.setRobotTestResults(wRobotDbTestResult.getRobotTestResults());
+                        temp.setWRobotResultId(wRobotDbTestResult.getWRobotResultId());
+                        wRobotDbTestResults.add(temp);
+                    }
+                }
+                result.setWRobotDbTestResults(wRobotDbTestResults);
+            } catch (Exception ex) {
+                LOGGER.error(EELFLoggerDelegate.errorLogger, "Error when serializing." + UserUtils.getStackTrace(ex));
+            }
+            gen.writeObject(result);
+        }
+    }
+
 }
index ee23efb..be2f250 100644 (file)
@@ -48,7 +48,7 @@ public class Timeslot implements Serializable {
 
     @ManyToOne
     @JoinColumn(name = "lab_id")
-    private LabInfo lab;
+    private LabInfo labInfo;
 
     public void setTimeslotId(int timeslotId) {
         this.timeslotId = timeslotId;
@@ -74,11 +74,11 @@ public class Timeslot implements Serializable {
         return duration;
     }
 
-    public void setLab(LabInfo lab) {
-        this.lab = lab;
+    public void setLabInfo(LabInfo labInfo) {
+        this.labInfo = labInfo;
     }
 
-    public LabInfo getLab() {
-        return lab;
+    public LabInfo getLabInfo() {
+        return labInfo;
     }
 }
index 6a447eb..9f4a1a7 100644 (file)
  */
 package org.akraino.validation.ui.entity;
 
+import java.io.IOException;
 import java.io.Serializable;
+import java.util.Set;
 
 import javax.persistence.Column;
 import javax.persistence.Entity;
+import javax.persistence.FetchType;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.JoinColumn;
 import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
 import javax.persistence.OneToOne;
 import javax.persistence.Table;
 
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+
 @Entity
 @Table(name = "validation_test_result")
 public class ValidationDbTestResult implements Serializable {
@@ -41,11 +50,9 @@ public class ValidationDbTestResult implements Serializable {
     @Column(name = "id")
     private int resultId;
 
-    @Column(name = "blueprint_name")
-    private String blueprintName;
-
-    @Column(name = "version")
-    private String version;
+    @ManyToOne
+    @JoinColumn(name = "blueprint_instance_id")
+    private BlueprintInstance blueprintInstance;
 
     @ManyToOne
     @JoinColumn(name = "lab_id")
@@ -68,8 +75,12 @@ public class ValidationDbTestResult implements Serializable {
 
     @OneToOne
     @JoinColumn(name = "submission_id")
+    @JsonSerialize(using = SubmissionSerializer.class)
     private Submission submission;
 
+    @OneToMany(mappedBy = "validationDbTestResult", targetEntity = WRobotDbTestResult.class, fetch = FetchType.EAGER)
+    private Set<WRobotDbTestResult> wRobotDbTestResults;
+
     public int getResultId() {
         return resultId;
     }
@@ -78,20 +89,12 @@ public class ValidationDbTestResult implements Serializable {
         this.resultId = resultId;
     }
 
-    public String getBlueprintName() {
-        return blueprintName;
+    public BlueprintInstance getBlueprintInstance() {
+        return blueprintInstance;
     }
 
-    public void setBlueprintName(String blueprintName) {
-        this.blueprintName = blueprintName;
-    }
-
-    public String getVersion() {
-        return version;
-    }
-
-    public void setVersion(String version) {
-        this.version = version;
+    public void setBlueprintInstance(BlueprintInstance blueprintInstance) {
+        this.blueprintInstance = blueprintInstance;
     }
 
     public Boolean getAllLayers() {
@@ -150,4 +153,33 @@ public class ValidationDbTestResult implements Serializable {
         this.submission = submission;
     }
 
+    public Set<WRobotDbTestResult> getWRobotDbTestResults() {
+        return this.wRobotDbTestResults;
+    }
+
+    public void setWRobotDbTestResults(Set<WRobotDbTestResult> wRobotDbTestResults) {
+        this.wRobotDbTestResults = wRobotDbTestResults;
+    }
+
+    static class SubmissionSerializer extends StdSerializer<Submission> {
+
+        public SubmissionSerializer() {
+            this(null);
+        }
+
+        public SubmissionSerializer(Class<Submission> t) {
+            super(t);
+        }
+
+        @Override
+        public void serialize(Submission submission, JsonGenerator gen, SerializerProvider provider)
+                throws IOException {
+            Submission result = new Submission();
+            result.setSubmissionId(submission.getSubmissionId());
+            result.setSubmissionStatus(submission.getSubmissionStatus());
+            result.setTimeslot(submission.getTimeslot());
+            gen.writeObject(result);
+        }
+    }
+
 }
index 282a83e..4962293 100644 (file)
@@ -15,6 +15,7 @@
  */
 package org.akraino.validation.ui.entity;
 
+import java.io.IOException;
 import java.io.Serializable;
 
 import javax.persistence.Column;
@@ -26,6 +27,11 @@ import javax.persistence.JoinColumn;
 import javax.persistence.ManyToOne;
 import javax.persistence.Table;
 
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+
 @Entity
 @Table(name = "w_robot_test_result")
 public class WRobotDbTestResult implements Serializable {
@@ -45,10 +51,11 @@ public class WRobotDbTestResult implements Serializable {
 
     @ManyToOne
     @JoinColumn(name = "validation_test_result_id")
-    private ValidationDbTestResult vResult;
+    @JsonSerialize(using = ValidationDbTestResultSerializer.class)
+    private ValidationDbTestResult validationDbTestResult;
 
     @Column(name = "robot_test_results")
-    private String rResults;
+    private String robotTestResults;
 
     public int getWRobotResultId() {
         return wRobotResultId;
@@ -66,20 +73,37 @@ public class WRobotDbTestResult implements Serializable {
         this.layer = layer;
     }
 
-    public ValidationDbTestResult getValidationTestResult() {
-        return vResult;
+    public ValidationDbTestResult getValidationDbTestResult() {
+        return validationDbTestResult;
     }
 
-    public void setValidationTestResult(ValidationDbTestResult vResult) {
-        this.vResult = vResult;
+    public void setValidationDbTestResult(ValidationDbTestResult validationDbTestResult) {
+        this.validationDbTestResult = validationDbTestResult;
     }
 
     public String getRobotTestResults() {
-        return rResults;
+        return robotTestResults;
     }
 
-    public void setRobotTestResults(String rResults) {
-        this.rResults = rResults;
+    public void setRobotTestResults(String robotTestResults) {
+        this.robotTestResults = robotTestResults;
     }
 
+    static class ValidationDbTestResultSerializer extends StdSerializer<ValidationDbTestResult> {
+
+        public ValidationDbTestResultSerializer() {
+            this(null);
+        }
+
+        public ValidationDbTestResultSerializer(Class<ValidationDbTestResult> t) {
+            super(t);
+        }
+
+        @Override
+        public void serialize(ValidationDbTestResult validationDbTestResult, JsonGenerator gen,
+                SerializerProvider provider) throws IOException {
+            gen.writeObject(null);
+        }
+
+    }
 }
@@ -17,25 +17,34 @@ package org.akraino.validation.ui.service;
 
 import java.util.List;
 
-import org.akraino.validation.ui.dao.BlueprintInstanceForValidationDAO;
-import org.akraino.validation.ui.entity.BlueprintInstanceForValidation;
+import org.akraino.validation.ui.dao.BlueprintInstanceDAO;
+import org.akraino.validation.ui.entity.Blueprint;
+import org.akraino.validation.ui.entity.BlueprintInstance;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 @Service
 @Transactional
-public class BlueprintInstanceForValidationService {
+public class BlueprintInstanceService {
 
     @Autowired
-    private BlueprintInstanceForValidationDAO dao;
+    private BlueprintInstanceDAO dao;
 
-    public void saveBlueprintInstance(BlueprintInstanceForValidation blueprintIns) {
+    public void saveBlueprintInstance(BlueprintInstance blueprintIns) {
         dao.saveOrUpdate(blueprintIns);
     }
 
-    public List<BlueprintInstanceForValidation> getBlueprintInstancesForValidation() {
-        return dao.getBlueprintInstancesForValidation();
+    public List<BlueprintInstance> getBlueprintInstances() {
+        return dao.getBlueprintInstances();
+    }
+
+    public BlueprintInstance getBlueprintInstance(int instId) {
+        return dao.getBlueprintInstance(instId);
+    }
+
+    public BlueprintInstance getBlueprintInstance(Blueprint blueprint, String version) {
+        return dao.getBlueprintInstance(blueprint, version);
     }
 
     public void deleteAll() {
@@ -17,29 +17,37 @@ package org.akraino.validation.ui.service;
 
 import java.util.List;
 
-import org.akraino.validation.ui.dao.SiloDAO;
-import org.akraino.validation.ui.entity.LabSilo;
+import org.akraino.validation.ui.dao.BlueprintLayerDAO;
+import org.akraino.validation.ui.entity.BlueprintLayer;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 @Service
 @Transactional
-public class SiloService {
+public class BlueprintLayerService {
 
     @Autowired
-    private SiloDAO siloDAO;
+    private BlueprintLayerDAO layerDAO;
 
-    public void saveSilo(LabSilo silo) {
-        siloDAO.saveOrUpdate(silo);
+    public void saveBlueprintLayer(BlueprintLayer layer) {
+        layerDAO.saveOrUpdate(layer);
     }
 
-    public List<LabSilo> getSilos() {
-        return siloDAO.getSilos();
+    public BlueprintLayer getBlueprintLayer(Integer layerId) {
+        return layerDAO.getBlueprintLayer(layerId);
+    }
+
+    public BlueprintLayer getBlueprintLayer(String layerData) {
+        return layerDAO.getBlueprintLayer(layerData);
+    }
+
+    public List<BlueprintLayer> getBlueprintLayers() {
+        return layerDAO.getBlueprintLayers();
     }
 
     public void deleteAll() {
-        siloDAO.deleteAll();
+        layerDAO.deleteAll();
     }
 
 }
index 37e2c0b..ed5aa75 100644 (file)
@@ -34,6 +34,10 @@ public class BlueprintService {
         blueprintDAO.saveOrUpdate(blueprint);
     }
 
+    public Blueprint getBlueprint(String name) {
+        return blueprintDAO.getBlueprint(name);
+    }
+
     public List<Blueprint> getBlueprints() {
         return blueprintDAO.getBlueprints();
     }
index 7e8687f..dcb3bac 100644 (file)
@@ -4,34 +4,27 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import javax.annotation.Nonnull;
 
-import org.akraino.validation.ui.client.nexus.resources.RobotTestResult;
-import org.akraino.validation.ui.client.nexus.resources.ValidationNexusTestResult;
-import org.akraino.validation.ui.client.nexus.resources.WRobotNexusTestResult;
 import org.akraino.validation.ui.dao.ValidationTestResultDAO;
 import org.akraino.validation.ui.dao.WRobotTestResultDAO;
-import org.akraino.validation.ui.data.BlueprintLayer;
 import org.akraino.validation.ui.data.JnksJobNotify;
-import org.akraino.validation.ui.data.Lab;
-import org.akraino.validation.ui.data.SubmissionData;
+import org.akraino.validation.ui.entity.Blueprint;
+import org.akraino.validation.ui.entity.BlueprintInstance;
+import org.akraino.validation.ui.entity.BlueprintLayer;
 import org.akraino.validation.ui.entity.LabInfo;
-import org.akraino.validation.ui.entity.LabSilo;
 import org.akraino.validation.ui.entity.Submission;
 import org.akraino.validation.ui.entity.ValidationDbTestResult;
 import org.akraino.validation.ui.entity.WRobotDbTestResult;
 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.portalsdk.core.web.support.UserUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
 
 @Service
 @Transactional
@@ -50,97 +43,93 @@ public class DbResultAdapter {
     private WRobotTestResultDAO wRobotDAO;
 
     @Autowired
-    private SiloService siloService;
+    DbSubmissionAdapter subService;
 
     @Autowired
-    DbSubmissionAdapter subService;
+    BlueprintService blueprintService;
+
+    @Autowired
+    BlueprintInstanceService blueprintInstService;
 
-    public void associateSubmissionWithValidationResult(SubmissionData submissionData)
+    @Autowired
+    BlueprintLayerService layerService;
+
+    public void associateSubmissionWithValidationResult(Submission submission)
             throws JsonParseException, JsonMappingException, IOException {
         synchronized (LOCK) {
-            ValidationDbTestResult vDbTestResult = this
-                    .convertValidationNexusToDb(submissionData.getValidationNexusTestResult());
-            Submission submission = new Submission();
-            submission.setSubmissionId(submissionData.getSubmissionId());
-            vDbTestResult.setSubmission(submission);
-            vTestResultDAO.saveOrUpdate(vDbTestResult);
-            List<WRobotDbTestResult> vRobotDbResults = this.convertWRobotNexusResultsToDb(
-                    submissionData.getValidationNexusTestResult().getwRobotNexusTestResults());
-            if (vRobotDbResults != null) {
-                for (WRobotDbTestResult vRobotDbResult : vRobotDbResults) {
-                    vRobotDbResult.setValidationTestResult(vDbTestResult);
+            if (!compareBluInstances(submission.getValidationDbTestResult().getBlueprintInstance(),
+                    blueprintInstService.getBlueprintInstance(
+                            submission.getValidationDbTestResult().getBlueprintInstance().getBlueprintInstanceId()))) {
+                throw new RuntimeException("Blueprint instance data changed.");
+            }
+            submission.getValidationDbTestResult().setSubmission(submission);
+            vTestResultDAO.saveOrUpdate(submission.getValidationDbTestResult());
+            if (submission.getValidationDbTestResult().getWRobotDbTestResults() != null) {
+                for (WRobotDbTestResult vRobotDbResult : submission.getValidationDbTestResult()
+                        .getWRobotDbTestResults()) {
+                    vRobotDbResult.setValidationDbTestResult(submission.getValidationDbTestResult());
                     wRobotDAO.saveOrUpdate(vRobotDbResult);
                 }
             }
         }
     }
 
-    public void storeResultInDb(List<ValidationNexusTestResult> vNexusResults) {
+    public void storeResultsInDb(List<ValidationDbTestResult> vNexusResults) {
         synchronized (LOCK) {
             if (vNexusResults == null || vNexusResults.size() < 1) {
                 return;
             }
-            for (ValidationNexusTestResult vNexusResult : vNexusResults) {
-                if (!checkValidityOfValidationNexusTestResult(vNexusResult)) {
+            for (ValidationDbTestResult vNexusResult : vNexusResults) {
+                if (vNexusResult.getWRobotDbTestResults() == null) {
                     continue;
                 }
-                LabInfo labInfo = null;
-                for (LabSilo silo : siloService.getSilos()) {
-                    if (silo.getSilo().equals(vNexusResult.getSilo())) {
-                        labInfo = silo.getLab();
-                    }
+                if (!checkValidityOfNexusResult(vNexusResult)) {
+                    continue;
                 }
+                LabInfo labInfo = labService.getLabBasedOnSilo(vNexusResult.getLab().getSilo());
                 ValidationDbTestResult vDbResult = vTestResultDAO.getValidationTestResult(labInfo,
                         vNexusResult.getTimestamp());
                 if (vDbResult == null) {
-                    vDbResult = new ValidationDbTestResult();
+                    vDbResult = vNexusResult;
                     vDbResult.setLab(labInfo);
-                    vDbResult.setTimestamp(vNexusResult.getTimestamp());
-                    vDbResult.setBlueprintName(vNexusResult.getBlueprintName());
-                    vDbResult.setVersion(vNexusResult.getVersion());
-                    vDbResult.setAllLayers(vNexusResult.getAllLayers());
-                    vDbResult.setOptional(vNexusResult.getOptional());
+                    Blueprint blueprint = blueprintService
+                            .getBlueprint(vNexusResult.getBlueprintInstance().getBlueprint().getBlueprintName());
+                    if (blueprint == null) {
+                        blueprint = vNexusResult.getBlueprintInstance().getBlueprint();
+                        blueprintService.saveBlueprint(blueprint);
+                    }
+                    BlueprintInstance blueprintInst = blueprintInstService.getBlueprintInstance(blueprint,
+                            (vNexusResult.getBlueprintInstance().getVersion()));
+                    if (blueprintInst == null) {
+                        blueprintInst = vNexusResult.getBlueprintInstance();
+                        blueprintInst.setBlueprint(blueprint);
+                        blueprintInstService.saveBlueprintInstance(blueprintInst);
+                    }
+                    vDbResult.setBlueprintInstance(blueprintInst);
                 }
+                updateBlueInstLayers(vNexusResult);
                 vDbResult.setResult(vNexusResult.getResult());
-                vDbResult.setDateStorage(vNexusResult.getDateOfStorage());
+                vDbResult.setDateStorage(vNexusResult.getDateStorage());
                 LOGGER.debug(EELFLoggerDelegate.debugLogger,
-                        "Storing validation test result with keys: blueprint name: " + vNexusResult.getBlueprintName()
-                        + ", version: " + vNexusResult.getVersion() + ", lab: " + vNexusResult.getSilo()
-                        + ", timestamp: " + vNexusResult.getTimestamp());
+                        "Storing validation test result with keys: blueprint name: "
+                                + vNexusResult.getBlueprintInstance().getBlueprint().getBlueprintName() + ", version: "
+                                + vNexusResult.getBlueprintInstance().getVersion() + ", lab: "
+                                + vNexusResult.getLab().getSilo() + ", timestamp: " + vNexusResult.getTimestamp());
                 vTestResultDAO.saveOrUpdate(vDbResult);
                 List<org.akraino.validation.ui.entity.WRobotDbTestResult> wRobotDbResults = wRobotDAO
                         .getWRobotTestResult(vDbResult);
                 if (wRobotDbResults == null) {
                     // Store the new wrapper robot rest results in db
-                    for (WRobotNexusTestResult wNexusResult : vNexusResult.getwRobotNexusTestResults()) {
-                        WRobotDbTestResult wRobotDbResult = new WRobotDbTestResult();
-                        wRobotDbResult.setLayer(wNexusResult.getBlueprintLayer().name());
-                        wRobotDbResult.setValidationTestResult(vDbResult);
-                        ObjectMapper mapper = new ObjectMapper();
-                        try {
-                            wRobotDbResult
-                            .setRobotTestResults(mapper.writeValueAsString(wNexusResult.getRobotTestResults()));
-                        } catch (JsonProcessingException e) {
-                            LOGGER.error(EELFLoggerDelegate.errorLogger,
-                                    "Error while converting POJO to string. " + UserUtils.getStackTrace(e));
-                            continue;
-                        }
-                        wRobotDAO.saveOrUpdate(wRobotDbResult);
+                    for (WRobotDbTestResult wNexusResult : vNexusResult.getWRobotDbTestResults()) {
+                        wNexusResult.setValidationDbTestResult(vDbResult);
+                        wRobotDAO.saveOrUpdate(wNexusResult);
                     }
                 } else if (vDbResult.getSubmission() != null) {
                     // update validation result related to submission
-                    for (WRobotNexusTestResult wNexusResult : vNexusResult.getwRobotNexusTestResults()) {
-                        WRobotDbTestResult wRobotDbResult = wRobotDAO
-                                .getWRobotTestResult(wNexusResult.getBlueprintLayer().name(), vDbResult);
-                        ObjectMapper mapper = new ObjectMapper();
-                        try {
-                            wRobotDbResult
-                            .setRobotTestResults(mapper.writeValueAsString(wNexusResult.getRobotTestResults()));
-                        } catch (JsonProcessingException e) {
-                            LOGGER.error(EELFLoggerDelegate.errorLogger,
-                                    "Error while converting POJO to string. " + UserUtils.getStackTrace(e));
-                            continue;
-                        }
+                    for (WRobotDbTestResult wNexusResult : vNexusResult.getWRobotDbTestResults()) {
+                        WRobotDbTestResult wRobotDbResult = wRobotDAO.getWRobotTestResult(wNexusResult.getLayer(),
+                                vDbResult);
+                        wRobotDbResult.setRobotTestResults(wNexusResult.getRobotTestResults());
                         wRobotDAO.saveOrUpdate(wRobotDbResult);
                     }
                 }
@@ -173,7 +162,7 @@ public class DbResultAdapter {
             wRobotResults = wRobotDAO.getWRobotTestResult(vDbTimestamp);
             if (wRobotResults != null && wRobotResults.size() > 0) {
                 for (WRobotDbTestResult wRobotResult : wRobotResults) {
-                    wRobotResult.setValidationTestResult(vDbSubmission);
+                    wRobotResult.setValidationDbTestResult(vDbSubmission);
                     wRobotDAO.saveOrUpdate(wRobotResult);
                 }
             }
@@ -186,38 +175,55 @@ public class DbResultAdapter {
         }
     }
 
-    public List<ValidationNexusTestResult> readResultFromDb(String blueprintName, String version, Lab lab,
-            List<BlueprintLayer> layers, Boolean allLayers, Boolean optional, Boolean outcome)
+    public List<ValidationDbTestResult> readResultFromDb(String blueprintName, String version, String lab,
+            List<String> layers, Boolean allLayers, Boolean optional, Boolean outcome)
                     throws JsonParseException, JsonMappingException, IOException {
         synchronized (LOCK) {
-            LabInfo actualLabInfo = labService.getLab(lab);
-            List<ValidationDbTestResult> vDbResults = vTestResultDAO.getValidationTestResults(blueprintName, version,
+            LabInfo actualLabInfo = null;
+            if (lab != null) {
+                actualLabInfo = labService.getLab(lab);
+                if (actualLabInfo == null) {
+                    return null;
+                }
+            }
+            Blueprint blueprint = null;
+            if (blueprintName != null) {
+                blueprint = blueprintService.getBlueprint(blueprintName);
+                if (blueprint == null) {
+                    return null;
+                }
+            }
+            BlueprintInstance blueprintInst = blueprintInstService.getBlueprintInstance(blueprint, version);
+            if (blueprintInst == null) {
+                return null;
+            }
+            List<ValidationDbTestResult> vDbResults = vTestResultDAO.getValidationTestResults(blueprintInst,
                     actualLabInfo, allLayers, optional, outcome);
             if (vDbResults == null || vDbResults.size() < 1) {
                 return null;
             }
-            List<ValidationNexusTestResult> vNexusResults = new ArrayList<ValidationNexusTestResult>();
+            List<ValidationDbTestResult> actualResults = new ArrayList<ValidationDbTestResult>();
             for (ValidationDbTestResult vDbResult : vDbResults) {
                 if (layers != null && layers.size() > 0) {
-                    List<BlueprintLayer> storedLayers = new ArrayList<BlueprintLayer>();
+                    List<String> storedLayers = new ArrayList<String>();
                     List<WRobotDbTestResult> wDbResults = wRobotDAO.getWRobotTestResult(vDbResult);
                     if (wDbResults == null || wDbResults.size() < 1) {
                         continue;
                     }
                     for (WRobotDbTestResult wRobot : wDbResults) {
-                        storedLayers.add(BlueprintLayer.valueOf(wRobot.getLayer()));
+                        storedLayers.add(wRobot.getLayer());
                     }
                     if (!new HashSet<>(storedLayers).equals(new HashSet<>(layers))) {
                         continue;
                     }
                 }
-                vNexusResults.add(convertValidationDbToNexus(vDbResult));
+                actualResults.add(vDbResult);
             }
-            return vNexusResults;
+            return actualResults;
         }
     }
 
-    public ValidationNexusTestResult readResultFromDb(@Nonnull Lab lab, @Nonnull String timestamp)
+    public ValidationDbTestResult readResultFromDb(@Nonnull String lab, @Nonnull String timestamp)
             throws JsonParseException, JsonMappingException, IOException {
         synchronized (LOCK) {
             LabInfo actualLabInfo = labService.getLab(lab);
@@ -225,39 +231,38 @@ public class DbResultAdapter {
             if (vDbResult == null) {
                 return null;
             }
-            return convertValidationDbToNexus(vDbResult);
+            return vDbResult;
         }
     }
 
-    public ValidationNexusTestResult readResultFromDb(@Nonnull String submissionId)
+    public ValidationDbTestResult readResultFromDb(@Nonnull String submissionId)
             throws JsonParseException, JsonMappingException, IOException {
         synchronized (LOCK) {
-            ValidationDbTestResult vDbResult = vTestResultDAO
-                    .getValidationTestResult(subService.getSubmission(submissionId));
-            if (vDbResult == null) {
-                return null;
-            }
-            return convertValidationDbToNexus(vDbResult);
+            return vTestResultDAO.getValidationTestResult(subService.getSubmission(submissionId));
         }
     }
 
-    public void deleteUnreferencedEntries(List<ValidationNexusTestResult> vNexusResults) {
+    public void deleteUnreferencedEntries(List<ValidationDbTestResult> vNexusResults) {
         synchronized (LOCK) {
             if (vNexusResults == null || vNexusResults.size() < 1) {
                 return;
             }
-            LabInfo labInfo = null;
-            for (LabSilo silo : siloService.getSilos()) {
-                if (silo.getSilo().equals(vNexusResults.get(0).getSilo())) {
-                    labInfo = silo.getLab();
-                }
-            }
+            LabInfo labInfo = labService.getLabBasedOnSilo(vNexusResults.get(0).getLab().getSilo());
             if (labInfo == null) {
                 return;
             }
-            List<ValidationDbTestResult> vDbResults = vTestResultDAO.getValidationTestResults(
-                    vNexusResults.get(0).getBlueprintName(), vNexusResults.get(0).getVersion(), labInfo, null, null,
-                    null);
+            Blueprint blueprint = blueprintService
+                    .getBlueprint(vNexusResults.get(0).getBlueprintInstance().getBlueprint().getBlueprintName());
+            if (blueprint == null) {
+                return;
+            }
+            BlueprintInstance blueInst = blueprintInstService.getBlueprintInstance(blueprint,
+                    vNexusResults.get(0).getBlueprintInstance().getVersion());
+            if (blueInst == null) {
+                return;
+            }
+            List<ValidationDbTestResult> vDbResults = vTestResultDAO.getValidationTestResults(blueInst, labInfo, null,
+                    null, null);
             if (vDbResults == null || vDbResults.size() < 1) {
                 return;
             }
@@ -268,13 +273,8 @@ public class DbResultAdapter {
                 boolean deletion = true;
                 String dbTimestamp = vDbResult.getTimestamp();
                 LabInfo dbLabInfo = vDbResult.getLab();
-                for (ValidationNexusTestResult vNexusResult : vNexusResults) {
-                    LabInfo nexusLabInfo = null;
-                    for (LabSilo silo : siloService.getSilos()) {
-                        if (silo.getSilo().equals(vNexusResult.getSilo())) {
-                            nexusLabInfo = silo.getLab();
-                        }
-                    }
+                for (ValidationDbTestResult vNexusResult : vNexusResults) {
+                    LabInfo nexusLabInfo = labService.getLabBasedOnSilo(vNexusResult.getLab().getSilo());
                     if (nexusLabInfo == null) {
                         continue;
                     }
@@ -293,7 +293,6 @@ public class DbResultAdapter {
                     vTestResultDAO.deleteValidationTestResult(vDbResult);
                 }
             }
-
         }
     }
 
@@ -309,11 +308,21 @@ public class DbResultAdapter {
         }
     }
 
-    public List<ValidationDbTestResult> getValidationTestResults(String blueprintName, String version, LabInfo labInfo,
-            Boolean allLayers, Boolean optional, Boolean outcome) {
+    public List<ValidationDbTestResult> getValidationTestResults(String blueprintName, @Nonnull String version,
+            LabInfo labInfo, Boolean allLayers, Boolean optional, Boolean outcome) {
         synchronized (LOCK) {
-            return vTestResultDAO.getValidationTestResults(blueprintName, version, labInfo, allLayers, optional,
-                    outcome);
+            Blueprint blueprint = null;
+            if (blueprintName != null) {
+                blueprint = blueprintService.getBlueprint(blueprintName);
+                if (blueprint == null) {
+                    return null;
+                }
+            }
+            BlueprintInstance bluInst = blueprintInstService.getBlueprintInstance(blueprint, version);
+            if (bluInst == null) {
+                return null;
+            }
+            return vTestResultDAO.getValidationTestResults(bluInst, labInfo, allLayers, optional, outcome);
         }
     }
 
@@ -323,6 +332,12 @@ public class DbResultAdapter {
         }
     }
 
+    public ValidationDbTestResult getValidationTestResult(String labSilo, String timestamp) {
+        synchronized (LOCK) {
+            return vTestResultDAO.getValidationTestResult(labService.getLabBasedOnSilo(labSilo), timestamp);
+        }
+    }
+
     public ValidationDbTestResult getValidationTestResult(@Nonnull Submission submission) {
         synchronized (LOCK) {
             return vTestResultDAO.getValidationTestResult(submission);
@@ -347,134 +362,76 @@ public class DbResultAdapter {
         }
     }
 
-    private ValidationNexusTestResult convertValidationDbToNexus(ValidationDbTestResult vDbResult)
-            throws JsonParseException, JsonMappingException, IOException {
-        ValidationNexusTestResult vNexusResult = new ValidationNexusTestResult();
-        vNexusResult.setResultId(vDbResult.getResultId());
-        vNexusResult.setBlueprintName(vDbResult.getBlueprintName());
-        vNexusResult.setVersion(vDbResult.getVersion());
-        vNexusResult.setAllLayers(vDbResult.getAllLayers());
-        vNexusResult.setDateOfStorage(vDbResult.getDateStorage());
-        vNexusResult.setOptional(vDbResult.getOptional());
-        vNexusResult.setResult(vDbResult.getResult());
-        String siloText = null;
-        for (LabSilo silo : siloService.getSilos()) {
-            if (silo.getLab().getLab().equals(vDbResult.getLab().getLab())) {
-                siloText = silo.getSilo();
-            }
-        }
-        if (siloText == null) {
-            throw new IllegalArgumentException("Lab does not exist: " + vDbResult.getLab().toString());
-        }
-        vNexusResult.setSilo(siloText);
-        vNexusResult.setTimestamp(vDbResult.getTimestamp());
-        if (vDbResult.getSubmission() != null) {
-            vNexusResult.setSubmissionId(String.valueOf(vDbResult.getSubmission().getSubmissionId()));
-        }
-        List<WRobotNexusTestResult> wNexusResults = new ArrayList<WRobotNexusTestResult>();
-        List<WRobotDbTestResult> wDbResults = wRobotDAO.getWRobotTestResult(vDbResult);
-        if (wDbResults != null && wDbResults.size() > 0) {
-            for (WRobotDbTestResult wRobot : wDbResults) {
-                WRobotNexusTestResult wNexusResult = new WRobotNexusTestResult();
-                wNexusResult.setBlueprintLayer(BlueprintLayer.valueOf(wRobot.getLayer()));
-                if (wRobot.getRobotTestResults() != null) {
-                    ObjectMapper mapper = new ObjectMapper();
-                    wNexusResult.setRobotTestResults(
-                            mapper.readValue(wRobot.getRobotTestResults(), new TypeReference<List<RobotTestResult>>() {
-                            }));
-                }
-                wNexusResults.add(wNexusResult);
-            }
-            vNexusResult.setwRobotNexusTestResults(wNexusResults);
-        }
-        return vNexusResult;
-    }
-
-    private ValidationDbTestResult convertValidationNexusToDb(ValidationNexusTestResult vNexusResult)
-            throws JsonParseException, JsonMappingException, IOException {
-        LabInfo labInfo = null;
-        for (LabSilo silo : siloService.getSilos()) {
-            if (silo.getSilo().equals(vNexusResult.getSilo())) {
-                labInfo = silo.getLab();
-            }
+    public boolean checkValidityOfNexusResult(ValidationDbTestResult vNexusResult) {
+        if (vNexusResult == null) {
+            return true;
         }
+        LabInfo labInfo = labService.getLabBasedOnSilo(vNexusResult.getLab().getSilo());
         if (labInfo == null) {
-            return null;
-        }
-        ValidationDbTestResult vDbResult = new ValidationDbTestResult();
-        vDbResult.setBlueprintName(vNexusResult.getBlueprintName());
-        vDbResult.setVersion(vNexusResult.getVersion());
-        vDbResult.setLab(labInfo);
-        vDbResult.setOptional(vNexusResult.getOptional());
-        vDbResult.setAllLayers(vNexusResult.getAllLayers());
-        vDbResult.setDateStorage(vNexusResult.getDateOfStorage());
-        vDbResult.setResult(vNexusResult.getResult());
-        vDbResult.setTimestamp(vNexusResult.getTimestamp());
-        return vDbResult;
-    }
-
-    private List<WRobotDbTestResult> convertWRobotNexusResultsToDb(List<WRobotNexusTestResult> wRobotNexusResults) {
-        if (wRobotNexusResults == null || wRobotNexusResults.size() < 1) {
-            return null;
-        }
-        List<WRobotDbTestResult> wDbResults = new ArrayList<WRobotDbTestResult>();
-        for (WRobotNexusTestResult wRobotNexusResult : wRobotNexusResults) {
-            WRobotDbTestResult wDbResult = new WRobotDbTestResult();
-            if (wRobotNexusResult.getBlueprintLayer() != null) {
-                wDbResult.setLayer(wRobotNexusResult.getBlueprintLayer().toString());
-            }
-            ObjectMapper mapper = new ObjectMapper();
-            if (wRobotNexusResult.getRobotTestResults() != null && wRobotNexusResult.getRobotTestResults().size() > 0) {
-                try {
-                    wDbResult.setRobotTestResults(mapper.writeValueAsString(wRobotNexusResult.getRobotTestResults()));
-                } catch (JsonProcessingException e) {
-                    LOGGER.error(EELFLoggerDelegate.errorLogger,
-                            "Error while converting POJO to string. " + UserUtils.getStackTrace(e));
-                    continue;
-                }
-            }
-            wDbResults.add(wDbResult);
+            throw new RuntimeException("Lab silo : " + vNexusResult.getLab().getSilo() + " not found");
         }
-        return wDbResults;
-    }
-
-    private boolean checkValidityOfValidationNexusTestResult(ValidationNexusTestResult vNexusResult) {
-        LabInfo labInfo = null;
-        for (LabSilo silo : siloService.getSilos()) {
-            if (silo.getSilo().equals(vNexusResult.getSilo())) {
-                labInfo = silo.getLab();
+        ValidationDbTestResult vDbResult = vTestResultDAO.getValidationTestResult(
+                labService.getLabBasedOnSilo(vNexusResult.getLab().getSilo()), vNexusResult.getTimestamp());
+        Blueprint blueprint = null;
+        BlueprintInstance bluInst = null;
+        List<WRobotDbTestResult> wRobotDbResults = null;
+        if (vDbResult != null) {
+            blueprint = vDbResult.getBlueprintInstance().getBlueprint();
+            labInfo = vDbResult.getLab();
+            wRobotDbResults = wRobotDAO.getWRobotTestResult(vDbResult);
+        } else {
+            blueprint = blueprintService
+                    .getBlueprint(vNexusResult.getBlueprintInstance().getBlueprint().getBlueprintName());
+        }
+        if (blueprint != null) {
+            if (vDbResult != null) {
+                bluInst = vDbResult.getBlueprintInstance();
+            } else {
+                bluInst = blueprintInstService.getBlueprintInstance(blueprint,
+                        vNexusResult.getBlueprintInstance().getVersion());
             }
         }
-        if (labInfo == null) {
-            LOGGER.error(EELFLoggerDelegate.errorLogger, "No lab Info found for silo. " + vNexusResult.getSilo());
+        // Start comparison, be elastic with allLayers and optional
+        if (!labInfo.getSilo().equals(vNexusResult.getLab().getSilo())) {
+            LOGGER.error(EELFLoggerDelegate.errorLogger,
+                    "Nexus has different data for blueprint : "
+                            + vDbResult.getBlueprintInstance().getBlueprint().getBlueprintName() + ", version: "
+                            + vDbResult.getBlueprintInstance().getVersion() + " and lab: " + vDbResult.getLab().getLab()
+                            + ". Lab inconsistency : " + vDbResult.getLab() + " " + labInfo);
             return false;
         }
-        ValidationDbTestResult vDbResult = vTestResultDAO.getValidationTestResult(labInfo, vNexusResult.getTimestamp());
-        if (vDbResult != null) {
-            // Be elastic for allLayers and optional
-            if (!vDbResult.getBlueprintName().equals(vNexusResult.getBlueprintName())
-                    || !vDbResult.getVersion().equals(vNexusResult.getVersion()) || !vDbResult.getLab().equals(labInfo)
-                    || !vDbResult.getTimestamp().equals(vNexusResult.getTimestamp())) {
+        if (blueprint != null) {
+            if (!blueprint.getBlueprintName()
+                    .equals(vNexusResult.getBlueprintInstance().getBlueprint().getBlueprintName())) {
+                LOGGER.error(EELFLoggerDelegate.errorLogger,
+                        "Nexus has different data for blueprint : " + blueprint.getBlueprintName()
+                        + ". Name inconsistency : " + blueprint.getBlueprintName() + " "
+                        + vNexusResult.getBlueprintInstance().getBlueprint().getBlueprintName());
+                return false;
+            }
+        }
+        if (bluInst != null) {
+            if (!bluInst.getVersion().equals(vNexusResult.getBlueprintInstance().getVersion())) {
                 LOGGER.error(EELFLoggerDelegate.errorLogger,
-                        "Nexus has different data for blueprint : " + vDbResult.getBlueprintName() + ", version: "
-                                + vDbResult.getVersion() + " and lab: " + vDbResult.getLab().getLab().name());
+                        "Nexus has different data for blueprint : " + bluInst.getBlueprint().getBlueprintName()
+                        + ", version: " + bluInst.getVersion() + ". Version inconsistency : "
+                        + bluInst.getVersion() + " " + vNexusResult.getBlueprintInstance().getVersion());
                 return false;
             }
         }
-        List<org.akraino.validation.ui.entity.WRobotDbTestResult> wRobotDbResults = wRobotDAO
-                .getWRobotTestResult(vDbResult);
         if (wRobotDbResults != null) {
-            if (vDbResult.getSubmission() != null) {
-                for (WRobotNexusTestResult wNexusResult : vNexusResult.getwRobotNexusTestResults()) {
-                    WRobotDbTestResult wRobotDbResult = wRobotDAO
-                            .getWRobotTestResult(wNexusResult.getBlueprintLayer().name(), vDbResult);
-                    if (wRobotDbResult == null) {
-                        LOGGER.error(EELFLoggerDelegate.errorLogger,
-                                "Nexus has different layer results for submission id: "
-                                        + vDbResult.getSubmission().getSubmissionId());
-                        return false;
-                    }
-                }
+            List<String> storedLayers1 = new ArrayList<String>();
+            for (WRobotDbTestResult wNexusResult : vNexusResult.getWRobotDbTestResults()) {
+                storedLayers1.add(wNexusResult.getLayer());
+            }
+            List<String> storedLayers2 = new ArrayList<String>();
+            for (WRobotDbTestResult wDbResult : wRobotDbResults) {
+                storedLayers2.add(wDbResult.getLayer());
+            }
+            if (!new HashSet<>(storedLayers1).equals(new HashSet<>(storedLayers2))) {
+                LOGGER.error(EELFLoggerDelegate.errorLogger,
+                        "Nexus has different layer results for validation result id: " + vDbResult.getResultId());
+                return false;
             }
         }
         return true;
@@ -484,6 +441,14 @@ public class DbResultAdapter {
         ValidationDbTestResult vDbSubmission = vTestResultDAO
                 .getValidationTestResult(subService.getSubmission(String.valueOf(jnksJobNotify.getSubmissionId())));
         if (vDbSubmission == null) {
+            LOGGER.error(EELFLoggerDelegate.errorLogger, "Received timestamp for submission id : "
+                    + jnksJobNotify.getSubmissionId() + " which has not validation result associated with it");
+            return false;
+        }
+        if (!vDbSubmission.getAllLayers() && (vDbSubmission.getWRobotDbTestResults() == null
+                || vDbSubmission.getWRobotDbTestResults().size() < 1)) {
+            LOGGER.error(EELFLoggerDelegate.errorLogger, "Received timestamp for submission id : "
+                    + jnksJobNotify.getSubmissionId() + " which is not stored correctly");
             return false;
         }
         ValidationDbTestResult vDbTimestamp = vTestResultDAO.getValidationTestResult(vDbSubmission.getLab(),
@@ -497,9 +462,32 @@ public class DbResultAdapter {
             + " from nexus for submission id: " + jnksJobNotify.getSubmissionId());
             return false;
         }
-        // Be elastic for allLayers and optional
-        if (!vDbSubmission.getBlueprintName().equals(vDbTimestamp.getBlueprintName())
-                || !vDbSubmission.getVersion().equals(vDbTimestamp.getVersion())
+        if (!vDbSubmission.getAllLayers()) {
+            if (wRobotDAO.getWRobotTestResult(vDbSubmission).size() != wRobotDAO.getWRobotTestResult(vDbTimestamp)
+                    .size()) {
+                LOGGER.error(EELFLoggerDelegate.errorLogger, "No consistency exists in stored layers records.");
+                return false;
+            }
+            List<String> storedLayers1 = new ArrayList<String>();
+            List<String> storedLayers2 = new ArrayList<String>();
+            List<WRobotDbTestResult> wDbResults = wRobotDAO.getWRobotTestResult(vDbSubmission);
+            for (WRobotDbTestResult wRobot : wDbResults) {
+                storedLayers1.add(wRobot.getLayer());
+            }
+            wDbResults = wRobotDAO.getWRobotTestResult(vDbTimestamp);
+            for (WRobotDbTestResult wRobot : wDbResults) {
+                storedLayers2.add(wRobot.getLayer());
+            }
+            if (!new HashSet<>(storedLayers1).equals(new HashSet<>(storedLayers2))) {
+                LOGGER.error(EELFLoggerDelegate.errorLogger, "No consistency exists in stored layers records.");
+                return false;
+            }
+        }
+        // Be elastic with allLayers and optional
+        if (!vDbSubmission.getBlueprintInstance().getBlueprint().getBlueprintName()
+                .equals(vDbTimestamp.getBlueprintInstance().getBlueprint().getBlueprintName())
+                || !vDbSubmission.getBlueprintInstance().getVersion()
+                .equals(vDbTimestamp.getBlueprintInstance().getVersion())
                 || !vDbSubmission.getLab().equals(vDbTimestamp.getLab())) {
             LOGGER.error(EELFLoggerDelegate.errorLogger, "No consistency exists in database records.");
             return false;
@@ -507,4 +495,77 @@ public class DbResultAdapter {
         return true;
     }
 
+    private void updateBlueInstLayers(ValidationDbTestResult vNexusResult) {
+        for (BlueprintInstance blueprintInst : blueprintInstService.getBlueprintInstances()) {
+            if (!blueprintInst.getBlueprint().getBlueprintName()
+                    .equals(vNexusResult.getBlueprintInstance().getBlueprint().getBlueprintName())) {
+                continue;
+            }
+            Set<BlueprintLayer> blueprintLayers = blueprintInst.getBlueprintLayers();
+            if (blueprintLayers == null) {
+                blueprintLayers = new HashSet<BlueprintLayer>();
+            }
+            for (WRobotDbTestResult nexusResult : vNexusResult.getWRobotDbTestResults()) {
+                BlueprintLayer layer = layerService.getBlueprintLayer(nexusResult.getLayer());
+                if (layer == null) {
+                    layer = new BlueprintLayer();
+                    layer.setLayer(nexusResult.getLayer());
+                    layerService.saveBlueprintLayer(layer);
+                }
+                if (!blueprintLayers.contains(layer)) {
+                    blueprintLayers.add(layer);
+                }
+            }
+            blueprintInst.setBlueprintLayers(blueprintLayers);
+            blueprintInstService.saveBlueprintInstance(blueprintInst);
+        }
+    }
+
+    private boolean compareBluInstances(BlueprintInstance inst1, BlueprintInstance inst2) {
+        if (!inst1.getVersion().equals(inst2.getVersion())) {
+            return false;
+        }
+        if (inst1.getBlueprintInstanceId() != inst2.getBlueprintInstanceId()) {
+            return false;
+        }
+        Set<BlueprintLayer> layers1 = inst1.getBlueprintLayers();
+        Set<BlueprintLayer> layers2 = inst2.getBlueprintLayers();
+        if (!(layers1 == null && layers2 == null)) {
+            if (layers1 != null && layers2 == null) {
+                return false;
+            }
+            if (layers1 == null && layers2 != null) {
+                return false;
+            }
+            if (!(layers1.size() == layers2.size())) {
+                return false;
+            }
+            boolean overallLayerEquality = true;
+            for (BlueprintLayer blulayer1 : layers1) {
+                boolean layerEquality = false;
+                for (BlueprintLayer blulayer2 : layers2) {
+                    if (blulayer1.getLayer().equals(blulayer2.getLayer())) {
+                        layerEquality = true;
+                    }
+                }
+                if (!layerEquality) {
+                    overallLayerEquality = false;
+                    break;
+                }
+            }
+            if (!overallLayerEquality) {
+                return false;
+            }
+        }
+        Blueprint blueprint1 = inst1.getBlueprint();
+        Blueprint blueprint2 = inst2.getBlueprint();
+        if (blueprint1.getBlueprintId() != blueprint2.getBlueprintId()) {
+            return false;
+        }
+        if (!blueprint1.getBlueprintName().equals(blueprint2.getBlueprintName())) {
+            return false;
+        }
+        return true;
+    }
+
 }
index 977e89d..70955c0 100644 (file)
@@ -29,9 +29,7 @@ import org.akraino.validation.ui.client.jenkins.resources.Parameter;
 import org.akraino.validation.ui.client.jenkins.resources.Parameters;
 import org.akraino.validation.ui.conf.ExecutorServiceInitializer;
 import org.akraino.validation.ui.dao.SubmissionDAO;
-import org.akraino.validation.ui.data.SubmissionData;
 import org.akraino.validation.ui.data.SubmissionStatus;
-import org.akraino.validation.ui.entity.LabSilo;
 import org.akraino.validation.ui.entity.Submission;
 import org.akraino.validation.ui.service.utils.PrioritySupplier;
 import org.akraino.validation.ui.service.utils.SubmissionHelper;
@@ -51,6 +49,7 @@ import com.fasterxml.jackson.databind.JsonMappingException;
 public class DbSubmissionAdapter {
 
     private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(DbSubmissionAdapter.class);
+    private static final Object LOCK = new Object();
 
     @Autowired
     private SubmissionDAO submissionDAO;
@@ -65,136 +64,98 @@ public class DbSubmissionAdapter {
     private DbResultAdapter dbAdapter;
 
     @Autowired
-    SiloService siloService;
+    BlueprintInstanceService bluInstService;
 
-    public SubmissionData saveSubmission(SubmissionData submissionData)
+    public Submission saveSubmission(Submission submission)
             throws JsonParseException, JsonMappingException, IOException {
-        Submission submission = new Submission();
-        submission.setSubmissionStatus(SubmissionStatus.Submitted);
-        submission.setTimeslot(submissionData.getTimeslot());
-        submissionDAO.saveOrUpdate(submission);
-        submissionData.setSubmissionId(submission.getSubmissionId());
-        String siloText = null;
-        for (LabSilo silo : siloService.getSilos()) {
-            if (silo.getLab().getLab().equals(submissionData.getTimeslot().getLab().getLab())) {
-                siloText = silo.getSilo();
-            }
-        }
-        if (siloText == null) {
-            throw new IllegalArgumentException(
-                    "Lab does not exist: " + submissionData.getTimeslot().getLab().toString());
+        synchronized (LOCK) {
+            submission.setSubmissionStatus(SubmissionStatus.Submitted);
+            submissionDAO.saveOrUpdate(submission);
+            dbAdapter.associateSubmissionWithValidationResult(submission);
+            ApplicationContext context = new AnnotationConfigApplicationContext(ExecutorServiceInitializer.class);
+            ExecutorService service = (ExecutorService) context.getBean("executorService");
+            JenkinsTriggerSubmissionJob task = new JenkinsTriggerSubmissionJob(submission);
+            CompletableFuture<Submission> completableFuture = CompletableFuture
+                    .supplyAsync(new PrioritySupplier<>(1, task::execute), service);
+            completableFuture.thenAcceptAsync(result -> this.callbackNotify(result));
+            return submission;
         }
-        submissionData.getValidationNexusTestResult().setSilo(siloText);
-        dbAdapter.associateSubmissionWithValidationResult(submissionData);
-        ApplicationContext context = new AnnotationConfigApplicationContext(ExecutorServiceInitializer.class);
-        ExecutorService service = (ExecutorService) context.getBean("executorService");
-        JenkinsTriggerSubmissionJob task = new JenkinsTriggerSubmissionJob(submissionData);
-        CompletableFuture<SubmissionData> completableFuture = CompletableFuture
-                .supplyAsync(new PrioritySupplier<>(1, task::execute), service);
-        completableFuture.thenAcceptAsync(result -> this.callbackNotify(result));
-        submissionData.setSubmissionId(submission.getSubmissionId());
-        return submissionData;
     }
 
     public List<Submission> getSubmissions() {
-        return submissionDAO.getSubmissions();
-    }
-
-    public List<SubmissionData> getSubmissionDatas() throws JsonParseException, JsonMappingException, IOException {
-        List<Submission> submissions = submissionDAO.getSubmissions();
-        if (submissions == null || submissions.size() < 1) {
-            return null;
-        }
-        List<SubmissionData> datas = new ArrayList<SubmissionData>();
-        for (Submission submission : submissions) {
-            SubmissionData submissionData = new SubmissionData();
-            submissionData.setStatus(submission.getSubmissionStatus());
-            submissionData.setSubmissionId(submission.getSubmissionId());
-            submissionData.setTimeslot(submission.getTimeslot());
-            submissionData.setValidationNexusTestResult(
-                    dbAdapter.readResultFromDb(String.valueOf(submission.getSubmissionId())));
-            datas.add(submissionData);
-        }
-        return datas;
-    }
-
-    public SubmissionData getSubmissionData(String submissionId)
-            throws JsonParseException, JsonMappingException, IOException {
-        Submission submission = submissionDAO.getSubmission(Integer.valueOf(submissionId));
-        if (submission == null) {
-            return null;
+        synchronized (LOCK) {
+            return submissionDAO.getSubmissions();
         }
-        SubmissionData submissionData = new SubmissionData();
-        submissionData.setStatus(submission.getSubmissionStatus());
-        submissionData.setSubmissionId(submission.getSubmissionId());
-        submissionData.setTimeslot(submission.getTimeslot());
-        submissionData.setValidationNexusTestResult(dbAdapter.readResultFromDb(submissionId));
-        return submissionData;
     }
 
     public Submission getSubmission(String submissionId) {
-        return submissionDAO.getSubmission(Integer.valueOf(submissionId));
+        synchronized (LOCK) {
+            return submissionDAO.getSubmission(Integer.valueOf(submissionId));
+        }
     }
 
     public void deleteSubmission(Integer submissionId) {
-        submissionDAO.deleteSubmission(submissionId);
+        synchronized (LOCK) {
+            submissionDAO.deleteSubmission(submissionId);
+        }
     }
 
     public void deleteAll() {
-        submissionDAO.deleteAll();
+        synchronized (LOCK) {
+            submissionDAO.deleteAll();
+        }
     }
 
-    private void callbackNotify(SubmissionData submissionData) {
-        if (submissionData == null) {
+    private void callbackNotify(Submission submission) {
+        if (submission == null) {
             return;
         }
-        Submission submission = submissionHelper.getSubmission(submissionData.getSubmissionId());
         submission.setSubmissionStatus(SubmissionStatus.Running);
         submissionHelper.saveSubmission(submission);
     }
 
     private class JenkinsTriggerSubmissionJob {
 
-        private SubmissionData submissionData;
+        private Submission submission;
 
-        public JenkinsTriggerSubmissionJob(SubmissionData submissionData) {
-            this.submissionData = submissionData;
+        public JenkinsTriggerSubmissionJob(Submission submission) {
+            this.submission = submission;
         }
 
-        public SubmissionData execute() {
+        public Submission execute() {
             try (final DatagramSocket socket = new DatagramSocket()) {
                 String jobName = System.getenv("JENKINS_JOB_NAME");
                 List<Parameter> listOfParameters = new ArrayList<Parameter>();
                 Parameters parameters = new Parameters();
                 Parameter parameter = new Parameter();
                 parameter.setName("SUBMISSION_ID");
-                parameter.setValue(String.valueOf(submissionData.getSubmissionId()));
+                parameter.setValue(String.valueOf(submission.getSubmissionId()));
                 listOfParameters.add(parameter);
                 parameter = new Parameter();
                 parameter.setName("BLUEPRINT");
-                parameter.setValue(submissionData.getValidationNexusTestResult().getBlueprintName());
+                parameter.setValue(submission.getValidationDbTestResult().getBlueprintInstance().getBlueprint()
+                        .getBlueprintName());
                 listOfParameters.add(parameter);
                 parameter = new Parameter();
                 parameter.setName("LAYER");
-                if (submissionData.getValidationNexusTestResult().getAllLayers()) {
+                if (submission.getValidationDbTestResult().getAllLayers()) {
                     parameter.setValue("all");
                 } else {
-                    parameter.setValue(submissionData.getValidationNexusTestResult().getwRobotNexusTestResults().get(0)
-                            .getBlueprintLayer().name().toLowerCase());
+                    parameter.setValue(submission.getValidationDbTestResult().getBlueprintInstance()
+                            .getBlueprintLayers().iterator().next().getLayer().toLowerCase());
                 }
                 listOfParameters.add(parameter);
                 parameter = new Parameter();
                 parameter.setName("VERSION");
-                parameter.setValue(submissionData.getValidationNexusTestResult().getVersion());
+                parameter.setValue(submission.getValidationDbTestResult().getBlueprintInstance().getVersion());
                 listOfParameters.add(parameter);
                 parameter = new Parameter();
                 parameter.setName("LAB");
-                parameter.setValue(submissionData.getTimeslot().getLab().getLab().name());
+                parameter.setValue(submission.getTimeslot().getLabInfo().getLab());
                 listOfParameters.add(parameter);
                 parameter = new Parameter();
                 parameter.setName("OPTIONAL");
-                parameter.setValue(
-                        String.valueOf(submissionData.getValidationNexusTestResult().getOptional().toString()));
+                parameter.setValue(String.valueOf(submission.getValidationDbTestResult().getOptional().toString()));
                 listOfParameters.add(parameter);
                 parameter = new Parameter();
                 parameter.setName("UI_IP");
@@ -206,7 +167,7 @@ public class DbSubmissionAdapter {
                 listOfParameters.add(parameter);
                 parameters.setParameter(listOfParameters);
                 jenkinsService.postJobWithQueryParams(jobName, parameters).toString();
-                return submissionData;
+                return submission;
             } catch (Exception e) {
                 LOGGER.error(EELFLoggerDelegate.errorLogger,
                         "Error when triggering Jenkins job. " + UserUtils.getStackTrace(e));
index 0015590..e97b5d1 100644 (file)
@@ -33,12 +33,8 @@ import java.util.Set;
 import javax.annotation.Nonnull;
 
 import org.akraino.validation.ui.client.nexus.NexusExecutorClient;
-import org.akraino.validation.ui.client.nexus.resources.ValidationNexusTestResult;
-import org.akraino.validation.ui.data.BlueprintLayer;
-import org.akraino.validation.ui.data.Lab;
-import org.akraino.validation.ui.data.SubmissionData;
 import org.akraino.validation.ui.entity.LabInfo;
-import org.akraino.validation.ui.entity.LabSilo;
+import org.akraino.validation.ui.entity.Submission;
 import org.akraino.validation.ui.entity.ValidationDbTestResult;
 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.onap.portalsdk.core.web.support.UserUtils;
@@ -60,9 +56,6 @@ public class IntegratedResultService {
     @Autowired
     private DbSubmissionAdapter submissionService;
 
-    @Autowired
-    private SiloService siloService;
-
     @Autowired
     NexusExecutorClient nexusService;
 
@@ -72,194 +65,174 @@ public class IntegratedResultService {
     @Autowired
     DbResultAdapter dbAdapter;
 
-    public List<Lab> getLabsFromNexus()
+    public List<String> getLabsFromNexus()
             throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException,
             UniformInterfaceException, NoSuchAlgorithmException, IOException, IllegalArgumentException, ParseException {
-        List<Lab> labs = new ArrayList<Lab>();
+        List<String> labs = new ArrayList<String>();
         for (String cLabSilo : nexusService.getResource(null)) {
-            for (LabSilo silo : siloService.getSilos()) {
-                if (silo.getSilo().equals(cLabSilo)) {
-                    labs.add(silo.getLab().getLab());
+            for (LabInfo labInfo : labService.getLabs()) {
+                if (labInfo.getSilo().equals(cLabSilo)) {
+                    labs.add(labInfo.getLab());
                 }
             }
         }
         return labs;
     }
 
-    public List<String> getBlueprintNamesOfLabFromNexus(@Nonnull Lab lab)
+    public List<String> getBlueprintNamesOfLabFromNexus(@Nonnull String lab)
             throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException,
             UniformInterfaceException, NoSuchAlgorithmException, IOException, IllegalArgumentException, ParseException {
-        String siloText = null;
-        for (LabSilo silo : siloService.getSilos()) {
-            if (silo.getLab().getLab().equals(lab)) {
-                siloText = silo.getSilo();
-            }
-        }
-        if (siloText == null) {
-            throw new IllegalArgumentException("Could not retrieve blueprint names of lab : " + lab.toString());
+        LabInfo labInfo = labService.getLab(lab);
+        if (labInfo == null) {
+            throw new IllegalArgumentException("Could not retrieve lab : " + lab.toString());
         }
-        List<String> blueprintNames = new ArrayList<String>();
-        List<String> cBlueprintNames = nexusService.getResource(siloText);
-        for (String cBlueprintName : cBlueprintNames) {
-            if (!cBlueprintName.equals("job")) {
-                blueprintNames.add(cBlueprintName);
+        List<String> cNames = nexusService.getResource(labService.getLab(lab).getSilo());
+        List<String> rNames = new ArrayList<String>();
+        for (String cName : cNames) {
+            if (cName.equals("family") || cName.equals("ta") || cName.equals("job")) {
+                continue;
             }
+            rNames.add(cName);
         }
-        return blueprintNames;
+        return rNames;
     }
 
-    public List<String> getBlueprintVersionsFromNexus(@Nonnull String name, @Nonnull Lab lab)
+    public List<String> getBlueprintVersionsFromNexus(@Nonnull String name, @Nonnull String lab)
             throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException,
             UniformInterfaceException, NoSuchAlgorithmException, IOException, IllegalArgumentException, ParseException {
-        String siloText = null;
-        for (LabSilo silo : siloService.getSilos()) {
-            if (silo.getLab().getLab().equals(lab)) {
-                siloText = silo.getSilo();
-            }
-        }
-        if (siloText == null) {
-            throw new IllegalArgumentException("Could not retrieve silo of the lab : " + lab.toString());
+        LabInfo labInfo = labService.getLab(lab);
+        if (labInfo == null) {
+            throw new IllegalArgumentException("Could not retrieve lab : " + lab.toString());
         }
-        return nexusService.getResource(siloText, name);
+        return nexusService.getResource(labInfo.getSilo(), name);
     }
 
-    public List<String> getBlueprintTimeStampsFromNexus(@Nonnull String name, @Nonnull String version, @Nonnull Lab lab)
-            throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException,
-            UniformInterfaceException, NoSuchAlgorithmException, IOException, ParseException {
-        String siloText = null;
-        for (LabSilo silo : siloService.getSilos()) {
-            if (silo.getLab().getLab().equals(lab)) {
-                siloText = silo.getSilo();
-            }
+    public List<String> getBlueprintTimeStampsFromNexus(@Nonnull String name, @Nonnull String version,
+            @Nonnull String lab) throws JsonParseException, JsonMappingException, KeyManagementException,
+    ClientHandlerException, UniformInterfaceException, NoSuchAlgorithmException, IOException, ParseException {
+        LabInfo labInfo = labService.getLab(lab);
+        if (labInfo == null) {
+            throw new IllegalArgumentException("Could not retrieve lab : " + lab.toString());
         }
-        if (siloText == null) {
-            throw new IllegalArgumentException("Could not retrieve silo of the lab : " + lab.toString());
-        }
-        return nexusService.getResource(siloText, name, version);
+        return nexusService.getResource(labInfo.getSilo(), name, version);
     }
 
-    public List<ValidationNexusTestResult> getResultsFromNexus(@Nonnull String name, @Nonnull String version,
-            @Nonnull Lab lab, int noTimestamps)
+    public List<ValidationDbTestResult> getResultsFromNexus(@Nonnull String name, @Nonnull String version,
+            @Nonnull String lab, int noTimestamps)
                     throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException,
                     UniformInterfaceException, NoSuchAlgorithmException, IOException, IllegalArgumentException, ParseException {
-        String siloText = null;
-        for (LabSilo silo : siloService.getSilos()) {
-            if (silo.getLab().getLab().equals(lab)) {
-                siloText = silo.getSilo();
-            }
+        LabInfo labInfo = labService.getLab(lab);
+        if (labInfo == null) {
+            throw new IllegalArgumentException("Could not retrieve lab : " + lab.toString());
         }
-        if (siloText == null) {
-            throw new IllegalArgumentException("Could not retrieve silo of the lab : " + lab.toString());
-        }
-        return nexusService.getResults(name, version, siloText, noTimestamps);
+        return nexusService.getResults(name, version, labInfo.getSilo(), noTimestamps);
     }
 
-    public ValidationNexusTestResult getResultFromNexus(@Nonnull String name, @Nonnull String version, @Nonnull Lab lab,
+    public ValidationDbTestResult getResultFromNexus(@Nonnull String name, @Nonnull String version, @Nonnull String lab,
             @Nonnull String timestamp) throws JsonParseException, JsonMappingException, IOException,
     KeyManagementException, ClientHandlerException, UniformInterfaceException, NoSuchAlgorithmException,
     NullPointerException, ParseException {
-        String siloText = null;
-        for (LabSilo silo : siloService.getSilos()) {
-            if (silo.getLab().getLab().equals(lab)) {
-                siloText = silo.getSilo();
-            }
+        LabInfo labInfo = labService.getLab(lab);
+        if (labInfo == null) {
+            throw new IllegalArgumentException("Could not retrieve lab : " + lab.toString());
         }
-        if (siloText == null) {
-            throw new IllegalArgumentException("Could not retrieve silo of the lab : " + lab.toString());
+        ValidationDbTestResult vNexusResult = nexusService.getResult(name, version, labInfo.getSilo(), timestamp);
+        if (!dbAdapter.checkValidityOfNexusResult(vNexusResult)) {
+            return null;
         }
-        return nexusService.getResult(name, version, siloText, timestamp);
+        vNexusResult.setLab(labInfo);
+        return vNexusResult;
     }
 
-    public ValidationNexusTestResult getLastResultBasedOnOutcomeFromNexus(@Nonnull String name, @Nonnull String version,
-            @Nonnull Lab lab, Boolean allLayers, Boolean optional, boolean outcome)
+    public ValidationDbTestResult getLastResultBasedOnOutcomeFromNexus(@Nonnull String name, @Nonnull String version,
+            @Nonnull String lab, Boolean allLayers, Boolean optional, boolean outcome)
                     throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException,
                     UniformInterfaceException, NoSuchAlgorithmException, NullPointerException, IOException, ParseException {
-        String siloText = null;
-        for (LabSilo silo : siloService.getSilos()) {
-            if (silo.getLab().getLab().equals(lab)) {
-                siloText = silo.getSilo();
-            }
+        LabInfo labInfo = labService.getLab(lab);
+        if (labInfo == null) {
+            throw new IllegalArgumentException("Could not retrieve lab : " + lab.toString());
         }
-        if (siloText == null) {
-            throw new IllegalArgumentException("Lab does not exist: " + lab.toString());
+        ValidationDbTestResult vNexusResult = nexusService.getLastResultBasedOnOutcome(name, version, labInfo.getSilo(),
+                allLayers, optional, outcome);
+        if (!dbAdapter.checkValidityOfNexusResult(vNexusResult)) {
+            return null;
         }
-        return nexusService.getLastResultBasedOnOutcome(name, version, siloText, allLayers, optional, outcome);
+        vNexusResult.setLab(labInfo);
+        return vNexusResult;
     }
 
-    public ValidationNexusTestResult getLastResultBasedOnOutcomeFromNexus(@Nonnull String name, @Nonnull String version,
-            @Nonnull Lab lab, @Nonnull List<BlueprintLayer> layers, Boolean optional, boolean outcome)
+    public ValidationDbTestResult getLastResultBasedOnOutcomeFromNexus(@Nonnull String name, @Nonnull String version,
+            @Nonnull String lab, @Nonnull List<String> layers, Boolean optional, boolean outcome)
                     throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException,
                     UniformInterfaceException, NoSuchAlgorithmException, NullPointerException, IOException, ParseException {
-        String siloText = null;
-        for (LabSilo silo : siloService.getSilos()) {
-            if (silo.getLab().getLab().equals(lab)) {
-                siloText = silo.getSilo();
-            }
+        LabInfo labInfo = labService.getLab(lab);
+        if (labInfo == null) {
+            throw new IllegalArgumentException("Could not retrieve lab : " + lab.toString());
         }
-        if (siloText == null) {
-            throw new IllegalArgumentException("Lab does not exist: " + lab.toString());
+        ValidationDbTestResult vNexusResult = nexusService.getLastResultBasedOnOutcome(name, version, labInfo.getSilo(),
+                layers, optional, outcome);
+        if (!dbAdapter.checkValidityOfNexusResult(vNexusResult)) {
+            return null;
         }
-        return nexusService.getLastResultBasedOnOutcome(name, version, siloText, layers, optional, outcome);
+        vNexusResult.setLab(labInfo);
+        return vNexusResult;
     }
 
-    public List<ValidationNexusTestResult> getBasedOnDateFromNexus(@Nonnull String name, @Nonnull String version,
-            @Nonnull Lab lab, @Nonnull Date date)
+    public List<ValidationDbTestResult> getBasedOnDateFromNexus(@Nonnull String name, @Nonnull String version,
+            @Nonnull String lab, @Nonnull Date date)
                     throws JsonParseException, JsonMappingException, IOException, ParseException, KeyManagementException,
                     ClientHandlerException, UniformInterfaceException, NoSuchAlgorithmException, NullPointerException {
-        String siloText = null;
-        for (LabSilo silo : siloService.getSilos()) {
-            if (silo.getLab().getLab().equals(lab)) {
-                siloText = silo.getSilo();
-            }
-        }
-        if (siloText == null) {
-            throw new IllegalArgumentException("Lab does not exist: " + lab.toString());
+        LabInfo labInfo = labService.getLab(lab);
+        if (labInfo == null) {
+            throw new IllegalArgumentException("Could not retrieve lab : " + lab.toString());
         }
-        return nexusService.getResults(name, version, siloText, date);
-    }
-
-    public Set<Lab> getLabsFromDb() {
-        Set<Lab> labs = new HashSet<Lab>();
-        for (ValidationDbTestResult result : dbAdapter.getValidationTestResults()) {
-            labs.add(result.getLab().getLab());
+        List<ValidationDbTestResult> vNexusResults = new ArrayList<ValidationDbTestResult>();
+        List<ValidationDbTestResult> vResults = nexusService.getResults(name, version, labInfo.getSilo(), date);
+        if (vResults != null && vResults.size() > 1) {
+            for (ValidationDbTestResult vNexusResult : vResults) {
+                if (dbAdapter.checkValidityOfNexusResult(vNexusResult)) {
+                    vNexusResult.setLab(labInfo);
+                    vNexusResults.add(vNexusResult);
+                }
+            }
         }
-        return labs;
+        return vNexusResults;
     }
 
-    public Set<String> getBlueprintNamesOfLabFromDb(Lab lab) {
+    public Set<String> getBlueprintNamesOfLabFromDb(String lab) {
         Set<String> blueprintNames = new HashSet<String>();
         for (ValidationDbTestResult result : dbAdapter.getValidationTestResults()) {
             if (result.getLab().getLab().equals(lab)) {
-                blueprintNames.add(result.getBlueprintName());
+                blueprintNames.add(result.getBlueprintInstance().getBlueprint().getBlueprintName());
             }
         }
         return blueprintNames;
     }
 
-    public Set<String> getBlueprintVersionsFromDb(String name, Lab lab) {
+    public Set<String> getBlueprintVersionsFromDb(String name, String lab) {
         Set<String> blueprintVersions = new HashSet<String>();
         for (ValidationDbTestResult result : dbAdapter.getValidationTestResults()) {
-            if (result.getLab().getLab().equals(lab) && result.getBlueprintName().equals(name)) {
-                blueprintVersions.add(result.getVersion());
+            if (result.getLab().getLab().equals(lab)
+                    && result.getBlueprintInstance().getBlueprint().getBlueprintName().equals(name)) {
+                blueprintVersions.add(result.getBlueprintInstance().getVersion());
             }
         }
         return blueprintVersions;
     }
 
-    public ValidationNexusTestResult getResults(@Nonnull String submissionId)
+    public ValidationDbTestResult getResults(@Nonnull String submissionId)
             throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException,
             UniformInterfaceException, NoSuchAlgorithmException, IOException, NullPointerException, ParseException {
-        SubmissionData submissionData = submissionService.getSubmissionData(submissionId);
-        ValidationNexusTestResult vNexusResult = dbAdapter.readResultFromDb(submissionId);
-        return vNexusResult == null
-                ? this.getResultFromNexus(submissionData.getValidationNexusTestResult().getBlueprintName(),
-                        submissionData.getValidationNexusTestResult().getVersion(),
-                        submissionData.getTimeslot().getLab().getLab(),
-                        submissionData.getValidationNexusTestResult().getTimestamp())
-                        : vNexusResult;
+        Submission submission = submissionService.getSubmission(submissionId);
+        ValidationDbTestResult vDbResult = dbAdapter.readResultFromDb(submissionId);
+        return vDbResult == null ? this.getResultFromNexus(
+                submission.getValidationDbTestResult().getBlueprintInstance().getBlueprint().getBlueprintName(),
+                submission.getValidationDbTestResult().getBlueprintInstance().getVersion(),
+                submission.getTimeslot().getLabInfo().getLab(), submission.getValidationDbTestResult().getTimestamp())
+                : vDbResult;
     }
 
-    public ValidationNexusTestResult getResult(@Nonnull String name, @Nonnull String version, @Nonnull Lab lab,
+    public ValidationDbTestResult getResult(@Nonnull String name, @Nonnull String version, @Nonnull String lab,
             @Nonnull String timestamp)
                     throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException,
                     UniformInterfaceException, NoSuchAlgorithmException, NullPointerException, IOException, ParseException {
@@ -267,29 +240,29 @@ public class IntegratedResultService {
         if (actualLabInfo == null) {
             return null;
         }
-        ValidationNexusTestResult vNexusResult = dbAdapter.readResultFromDb(lab, timestamp);
-        return vNexusResult == null ? this.getResultFromNexus(name, version, lab, timestamp) : vNexusResult;
+        ValidationDbTestResult vDbResult = dbAdapter.readResultFromDb(lab, timestamp);
+        return vDbResult == null ? this.getResultFromNexus(name, version, lab, timestamp) : vDbResult;
     }
 
-    public ValidationNexusTestResult getLastResultBasedOnOutcome(@Nonnull String name, @Nonnull String version,
-            @Nonnull Lab lab, Boolean allLayers, Boolean optional, boolean outcome)
+    public ValidationDbTestResult getLastResultBasedOnOutcome(@Nonnull String name, @Nonnull String version,
+            @Nonnull String lab, Boolean allLayers, Boolean optional, boolean outcome)
                     throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException,
                     UniformInterfaceException, NoSuchAlgorithmException, IOException, NullPointerException, ParseException {
         LabInfo actualLabInfo = labService.getLab(lab);
         if (actualLabInfo == null) {
             return null;
         }
-        List<ValidationNexusTestResult> vNexusResults = dbAdapter.readResultFromDb(name, version, lab, null, allLayers,
+        List<ValidationDbTestResult> vDbResults = dbAdapter.readResultFromDb(name, version, lab, null, allLayers,
                 optional, outcome);
-        if (vNexusResults != null) {
-            vNexusResults.removeIf(entry -> entry.getDateOfStorage() == null);
+        if (vDbResults != null) {
+            vDbResults.removeIf(entry -> entry.getDateStorage() == null);
             DateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
-            Collections.sort(vNexusResults, new Comparator<ValidationNexusTestResult>() {
+            Collections.sort(vDbResults, new Comparator<ValidationDbTestResult>() {
                 @Override
-                public int compare(ValidationNexusTestResult vNexusResult1, ValidationNexusTestResult vNexusResult2) {
+                public int compare(ValidationDbTestResult vDbResult1, ValidationDbTestResult vDbResult2) {
                     try {
-                        return dateFormat.parse(vNexusResult2.getDateOfStorage())
-                                .compareTo(dateFormat.parse(vNexusResult1.getDateOfStorage()));
+                        return dateFormat.parse(vDbResult2.getDateStorage())
+                                .compareTo(dateFormat.parse(vDbResult1.getDateStorage()));
                     } catch (ParseException e) {
                         LOGGER.error(EELFLoggerDelegate.errorLogger,
                                 "Error when parsing date. " + UserUtils.getStackTrace(e));
@@ -297,30 +270,30 @@ public class IntegratedResultService {
                     }
                 }
             });
-            return vNexusResults.get(0);
+            return vDbResults.get(0);
         }
         return this.getLastResultBasedOnOutcomeFromNexus(name, version, lab, allLayers, optional, outcome);
     }
 
-    public ValidationNexusTestResult getLastResultBasedOnOutcome(@Nonnull String name, @Nonnull String version,
-            @Nonnull Lab lab, List<BlueprintLayer> layers, Boolean optional, boolean outcome)
+    public ValidationDbTestResult getLastResultBasedOnOutcome(@Nonnull String name, @Nonnull String version,
+            @Nonnull String lab, List<String> layers, Boolean optional, boolean outcome)
                     throws JsonParseException, JsonMappingException, KeyManagementException, ClientHandlerException,
                     UniformInterfaceException, NoSuchAlgorithmException, IOException, NullPointerException, ParseException {
         LabInfo actualLabInfo = labService.getLab(lab);
         if (actualLabInfo == null) {
             return null;
         }
-        List<ValidationNexusTestResult> vNexusResults = dbAdapter.readResultFromDb(name, version, lab, layers, null,
-                optional, outcome);
-        if (vNexusResults != null) {
-            vNexusResults.removeIf(entry -> entry.getDateOfStorage() == null);
+        List<ValidationDbTestResult> vDbResults = dbAdapter.readResultFromDb(name, version, lab, layers, null, optional,
+                outcome);
+        if (vDbResults != null && vDbResults.size() > 0) {
+            vDbResults.removeIf(entry -> entry.getDateStorage() == null);
             DateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
-            Collections.sort(vNexusResults, new Comparator<ValidationNexusTestResult>() {
+            Collections.sort(vDbResults, new Comparator<ValidationDbTestResult>() {
                 @Override
-                public int compare(ValidationNexusTestResult vNexusResult1, ValidationNexusTestResult vNexusResult2) {
+                public int compare(ValidationDbTestResult vDbResult1, ValidationDbTestResult vDbResult2) {
                     try {
-                        return dateFormat.parse(vNexusResult2.getDateOfStorage())
-                                .compareTo(dateFormat.parse(vNexusResult1.getDateOfStorage()));
+                        return dateFormat.parse(vDbResult2.getDateStorage())
+                                .compareTo(dateFormat.parse(vDbResult2.getDateStorage()));
                     } catch (ParseException e) {
                         LOGGER.error(EELFLoggerDelegate.errorLogger,
                                 "Error when parsing date. " + UserUtils.getStackTrace(e));
@@ -328,7 +301,7 @@ public class IntegratedResultService {
                     }
                 }
             });
-            return vNexusResults.get(0);
+            return vDbResults.get(0);
         }
         return this.getLastResultBasedOnOutcomeFromNexus(name, version, lab, layers, optional, outcome);
     }
index 429696a..c292b79 100644 (file)
@@ -18,15 +18,16 @@ package org.akraino.validation.ui.service;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.akraino.validation.ui.client.nexus.resources.ValidationNexusTestResult;
 import org.akraino.validation.ui.dao.ValidationTestResultDAO;
 import org.akraino.validation.ui.data.JnksJobNotify;
 import org.akraino.validation.ui.data.SubmissionStatus;
-import org.akraino.validation.ui.entity.LabSilo;
+import org.akraino.validation.ui.entity.LabInfo;
 import org.akraino.validation.ui.entity.Submission;
 import org.akraino.validation.ui.entity.ValidationDbTestResult;
 import org.akraino.validation.ui.service.utils.SubmissionHelper;
+import org.apache.commons.httpclient.HttpException;
 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.web.support.UserUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -43,15 +44,15 @@ public class JenkinsJobNotificationService {
     @Autowired
     private DbSubmissionAdapter submissionService;
 
-    @Autowired
-    private SiloService siloService;
-
     @Autowired
     private DbResultAdapter dbAdapter;
 
     @Autowired
     private IntegratedResultService iService;
 
+    @Autowired
+    private LabService labService;
+
     @Autowired
     private ValidationTestResultDAO vTestResultDAO;
 
@@ -65,29 +66,32 @@ public class JenkinsJobNotificationService {
             LOGGER.debug(EELFLoggerDelegate.debugLogger, "No related submission was found");
             return;
         }
-        String siloText = null;
-        for (LabSilo silo : siloService.getSilos()) {
-            if (silo.getLab().getLab().equals(submission.getTimeslot().getLab().getLab())) {
-                siloText = silo.getSilo();
-            }
-        }
-        if (siloText == null) {
-            throw new IllegalArgumentException("Could not retrieve silo of the selected lab : "
-                    + submission.getTimeslot().getLab().getLab().toString());
+        LabInfo labInfo = labService.getLab(submission.getTimeslot().getLabInfo().getLab());
+        if (labInfo == null) {
+            throw new IllegalArgumentException(
+                    "Could not retrieve lab : " + submission.getTimeslot().getLabInfo().getLab().toString());
         }
         LOGGER.info(EELFLoggerDelegate.applicationLogger,
                 "Updating submission with id: " + submission.getSubmissionId());
         submission.setSubmissionStatus(SubmissionStatus.Completed);
         submissionHelper.saveSubmission(submission);
         ValidationDbTestResult vDbResult = vTestResultDAO.getValidationTestResult(submission);
-        if (vDbResult != null) {
-            ValidationNexusTestResult vNexusResult = iService.getResult(vDbResult.getBlueprintName(),
-                    vDbResult.getVersion(), vDbResult.getLab().getLab(), jnksJobNotify.getTimestamp());
-            if (vNexusResult != null) {
-                List<ValidationNexusTestResult> vNexusResults = new ArrayList<ValidationNexusTestResult>();
-                vNexusResults.add(vNexusResult);
-                dbAdapter.storeResultInDb(vNexusResults);
+        try {
+            if (vDbResult != null) {
+                // Fetch submission result from nexus
+                ValidationDbTestResult vNexusResult = iService.getResult(
+                        vDbResult.getBlueprintInstance().getBlueprint().getBlueprintName(),
+                        vDbResult.getBlueprintInstance().getVersion(), vDbResult.getLab().getLab(),
+                        jnksJobNotify.getTimestamp());
+                if (vNexusResult != null) {
+                    List<ValidationDbTestResult> vNexusResults = new ArrayList<ValidationDbTestResult>();
+                    vNexusResults.add(vNexusResult);
+                    dbAdapter.storeResultsInDb(vNexusResults);
+                }
             }
+        } catch (HttpException ex) {
+            LOGGER.error(EELFLoggerDelegate.errorLogger,
+                    "Error when retrieving Nexus results. " + UserUtils.getStackTrace(ex));
         }
         dbAdapter.updateTimestamp(jnksJobNotify);
     }
index 4280f37..81fe7b1 100644 (file)
@@ -18,7 +18,6 @@ package org.akraino.validation.ui.service;
 import java.util.List;
 
 import org.akraino.validation.ui.dao.LabDAO;
-import org.akraino.validation.ui.data.Lab;
 import org.akraino.validation.ui.entity.LabInfo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -35,10 +34,14 @@ public class LabService {
         labDAO.saveOrUpdate(lab);
     }
 
-    public LabInfo getLab(Lab lab) {
+    public LabInfo getLab(String lab) {
         return labDAO.getLab(lab);
     }
 
+    public LabInfo getLabBasedOnSilo(String silo) {
+        return labDAO.getLabBasedOnSilo(silo);
+    }
+
     public List<LabInfo> getLabs() {
         return labDAO.getLabs();
     }
index b6c0dc1..ae39f8f 100644 (file)
@@ -79,4 +79,4 @@ nexus_url = https://nexus.akraino.org/content/sites/logs
 thread_sleep = 5000
 
 # Number of last timestamps to retrieve proactively from Nexus
-no_last_timestamps = 50
\ No newline at end of file
+no_last_timestamps = 100
\ No newline at end of file
index 8ae0487..dc98ae9 100644 (file)
@@ -16,4 +16,4 @@
 
 var config_module = angular.module('App.Config', []);
 config_module.constant('appContext', '/bluvalui');
-config_module.constant('refreshPeriod', '12000'); // in msecs
+config_module.constant('refreshPeriod', '30000'); // in msecs
index dd4f699..105fa28 100644 (file)
@@ -21,74 +21,51 @@ app
                 'committedSubmissionsSvc',
                 [ function() {
                     var svc = [];
-                    svc.getLayer = function(validationNexusTestResult) {
-                        if (validationNexusTestResult.allLayers) {
+                    svc.getLayer = function(validationDbTestResult) {
+                        if (!validationDbTestResult) {
+                            return null;
+                        }
+                        if (validationDbTestResult.allLayers) {
                             return "all";
                         }
                         var layers = [];
-                        angular
-                                .forEach(
-                                        validationNexusTestResult.wRobotNexusTestResults,
-                                        function(result) {
-                                            layers.push(result.blueprintLayer);
-                                        });
+                        angular.forEach(
+                                validationDbTestResult.wrobotDbTestResults,
+                                function(result) {
+                                    layers.push(result.layer);
+                                });
                         return layers;
                     };
-                    svc.getResultUrl = function(submissionData) {
-                        if (submissionData.status !== "Completed") {
+                    svc.getResultUrl = function(submission) {
+                        if (submission.submissionStatus !== "Completed") {
                             return null;
                         }
-                        if (!submissionData.validationNexusTestResult.wRobotNexusTestResults) {
+                        if (!submission.validationDbTestResult) {
                             return null;
                         }
-                        if (submissionData.validationNexusTestResult.wRobotNexusTestResults.length === 0) {
+                        if (!submission.validationDbTestResult.wrobotDbTestResults) {
                             return null;
                         }
-                        var resultExistence = false;
-                        angular
-                                .forEach(
-                                        submissionData.validationNexusTestResult.wRobotNexusTestResults,
-                                        function(result) {
-                                            if (result.robotTestResults
-                                                    && result.robotTestResults.length > 0) {
-                                                resultExistence = true;
-                                            }
-                                        });
-                        if (resultExistence) {
+                        if (submission.validationDbTestResult.wrobotDbTestResults.length === 0) {
+                            return null;
+                        }
+                        if (submission.validationDbTestResult.dateStorage) {
                             return "https://nexus.akraino.org/content/sites/logs/"
-                                    + submissionData.validationNexusTestResult.silo
+                                    + submission.timeslot.labInfo.silo
                                     + "/"
-                                    + submissionData.validationNexusTestResult.blueprintName
+                                    + submission.validationDbTestResult.blueprintInstance.blueprint.blueprintName
                                     + "/"
-                                    + submissionData.validationNexusTestResult.version
+                                    + submission.validationDbTestResult.blueprintInstance.version
                                     + "/"
-                                    + submissionData.validationNexusTestResult.timestamp
+                                    + submission.validationDbTestResult.timestamp
                                     + "/";
                         }
                         return null;
                     };
-                    svc.mapResult = function(validationNexusTestResult) {
-                        if (!validationNexusTestResult.timestamp) {
-                            return null;
-                        }
-                        if (!validationNexusTestResult.wRobotNexusTestResults) {
-                            return null;
-                        }
-                        if (validationNexusTestResult.wRobotNexusTestResults.length === 0) {
-                            return null;
-                        }
-                        var resultExistence = false;
-                        angular
-                                .forEach(
-                                        validationNexusTestResult.wRobotNexusTestResults,
-                                        function(result) {
-                                            if (result.robotTestResults
-                                                    && result.robotTestResults.length > 0) {
-                                                resultExistence = true;
-                                            }
-                                        });
-                        if (resultExistence) {
-                            if (validationNexusTestResult.result === true) {
+                    svc.mapResult = function(validationDbTestResult) {
+                        if (validationDbTestResult
+                                && validationDbTestResult.dateStorage) {
+                            if (validationDbTestResult.result === true) {
                                 return 'SUCCESS';
                             }
                             return 'FAILURE'
index 8f7a8a3..f9b1a16 100644 (file)
 
 var app = angular.module('CommittedSubmissions');
 
-app.controller('CommittedSubmissionsController', function($scope, restAPISvc,
-        $interval, refreshPeriod, committedSubmissionsSvc, NgTableParams,
-        appContext, $window) {
-
-    $scope.getLayer = committedSubmissionsSvc.getLayer;
-    $scope.getResultUrl = committedSubmissionsSvc.getResultUrl;
-    $scope.mapResult = committedSubmissionsSvc.mapResult;
-
-    initialize();
-
-    function initialize() {
-        restAPISvc.getRestAPI("/api/v1/submission/", function(submissions) {
-            $scope.submissionDatas = submissions;
-            var data = submissions;
-            $scope.tableParams = new NgTableParams({
-                page : 1,
-                count : 5
-            }, {
-                dataset : data
-            });
-        });
-    }
-
-    $scope.refreshCommittedSubmissions = function() {
-        initialize();
-    }
-
-    $scope.getValidationResults = function(submissionData) {
-        if (!submissionData.validationNexusTestResult.timestamp) {
-            return;
-        }
-        $window.location.href = appContext
-                + "/validationresults#?submissionId="
-                + submissionData.submissionId;
-    }
-
-    $interval(function() {
-        $scope.refreshCommittedSubmissions();
-    }, refreshPeriod);
-
-});
+app
+        .controller(
+                'CommittedSubmissionsController',
+                function($scope, restAPISvc, $interval, refreshPeriod,
+                        committedSubmissionsSvc, NgTableParams, appContext,
+                        $window) {
+
+                    $scope.getLayer = committedSubmissionsSvc.getLayer;
+                    $scope.getResultUrl = committedSubmissionsSvc.getResultUrl;
+                    $scope.mapResult = committedSubmissionsSvc.mapResult;
+
+                    initialize();
+
+                    function initialize() {
+                        restAPISvc.getRestAPI("/api/v1/submission/", function(
+                                submissions) {
+                            $scope.submissions = submissions;
+                            var data = submissions;
+                            $scope.tableParams = new NgTableParams({
+                                page : 1,
+                                count : 5
+                            }, {
+                                dataset : data
+                            });
+                        });
+                    }
+
+                    $scope.refreshCommittedSubmissions = function() {
+                        initialize();
+                    }
+
+                    $scope.getValidationResults = function(submission) {
+                        if (!submission.validationDbTestResult
+                                || !submission.validationDbTestResult.timestamp
+                                || !submission.validationDbTestResult.wrobotDbTestResults
+                                || submission.validationDbTestResult.wrobotDbTestResults.length === 0) {
+                            return;
+                        }
+                        $window.location.href = appContext
+                                + "/validationresults#?submissionId="
+                                + submission.submissionId;
+                    }
+
+                    /*
+                     * $interval(function() {
+                     * $scope.refreshCommittedSubmissions(); }, refreshPeriod);
+                     */
+
+                });
index cdb6de9..cf4254d 100644 (file)
@@ -35,36 +35,37 @@ body {
                 ng-click="refreshCommittedSubmissions()">Refresh</button>
         </div>
         <table ng-table="tableParams" class="table" show-filter="true">
-            <tr ng-repeat="submissionData in $data">
+            <tr ng-repeat="submission in $data">
                 <td title="'Id'" filter="{ submissionId: 'text'}"
                     sortable="'submissionId'">{{
-                    submissionData.submissionId }}</td>
+                    submission.submissionId }}</td>
                 <td title="'Timeslot'" filter="{ timeslot: 'text'}"
                     sortable="'timeslot'">Lab: {{
-                    submissionData.timeslot.lab.lab }} Start date and
-                    time: {{ submissionData.timeslot.startDateTime }} <!-- duration(in sec) :
+                    submission.timeslot.labInfo.lab }} Start date and
+                    time: {{ submission.timeslot.startDateTime }} <!-- duration(in sec) :
                                 {{submission.timeslot.duration}}-->
                 </td>
                 <td title="'Blueprint Name'">{{
-                    submissionData.validationNexusTestResult.blueprintName
+                    submission.validationDbTestResult.blueprintInstance.blueprint.blueprintName
                     }}</td>
                 <td title="'Version'">{{
-                    submissionData.validationNexusTestResult.version }}</td>
-                <td title="'Layer(s)'">{{
-                    getLayer(submissionData.validationNexusTestResult)
+                    submission.validationDbTestResult.blueprintInstance.version
                     }}</td>
+                <td title="'Layer(s)'">{{
+                    getLayer(submission.validationDbTestResult) }}</td>
                 <td title="'Optional Test Cases'">{{
-                    submissionData.validationNexusTestResult.optional}}</td>
+                    submission.validationDbTestResult.optional}}</td>
                 <td title="'Status'" filter="{ status: 'text'}"
-                    sortable="'status'">{{ submissionData.status }}</td>
+                    sortable="'status'">{{
+                    submission.submissionStatus }}</td>
                 <td title="'Nexus URL result'"><a
-                    href="{{getResultUrl(submissionData)}}">{{getResultUrl(submissionData)}}</a></td>
+                    href="{{getResultUrl(submission)}}">{{getResultUrl(submission)}}</a></td>
                 <td title="'Result'">
                     <button
                         style="margin-left: 25px; margin-top: 4px; float: right; background-color: #337ab7;"
                         type="submit" class="btn-alt btn-small"
-                        ng-click="getValidationResults(submissionData);">{{
-                        mapResult(submissionData.validationNexusTestResult)}}</button>
+                        ng-click="getValidationResults(submission);">{{
+                        mapResult(submission.validationDbTestResult)}}</button>
                 </td>
             </tr>
         </table>
index 607634b..d6bf3da 100644 (file)
@@ -24,8 +24,11 @@ app.controller('GetBasedOnDateController', function($scope, restAPISvc,
         $scope.loadingLabs = true;
         $scope.loadingBlueprints = false;
         $scope.loadingVersions = false;
-        restAPISvc.getRestAPI("/api/v1/results/getlabs/", function(data) {
-            $scope.labs = data;
+        $scope.labs = [];
+        restAPISvc.getRestAPI("/api/v1/lab/", function(data) {
+            angular.forEach(data, function(lab) {
+                $scope.labs.push(lab.lab);
+            });
             $scope.loadingLabs = false;
         });
     }
index cb75d5c..1243f7e 100644 (file)
@@ -24,8 +24,11 @@ function($scope, restAPISvc, $window, appContext) {
         $scope.loadingLabs = true;
         $scope.loadingBlueprints = false;
         $scope.loadingVersions = false;
-        restAPISvc.getRestAPI("/api/v1/results/getlabs/", function(data) {
-            $scope.labs = data;
+        $scope.labs = [];
+        restAPISvc.getRestAPI("/api/v1/lab/", function(data) {
+            angular.forEach(data, function(lab) {
+                $scope.labs.push(lab.lab);
+            });
             $scope.loadingLabs = false;
         });
     }
index 65f727e..5091f3c 100644 (file)
@@ -24,8 +24,11 @@ function($scope, restAPISvc, $window, appContext) {
         $scope.loadingLabs = true;
         $scope.loadingBlueprints = false;
         $scope.loadingVersions = false;
-        restAPISvc.getRestAPI("/api/v1/results/getlabs/", function(data) {
-            $scope.labs = data;
+        $scope.labs = [];
+        restAPISvc.getRestAPI("/api/v1/lab/", function(data) {
+            angular.forEach(data, function(lab) {
+                $scope.labs.push(lab.lab);
+            });
             $scope.loadingLabs = false;
         });
     }
index 76307eb..9e636b5 100644 (file)
@@ -26,8 +26,11 @@ app.controller('GetMostRecentController', function($scope, restAPISvc, $window,
         $scope.loadingBlueprints = false;
         $scope.loadingVersions = false;
         $scope.loadingResults = false;
-        restAPISvc.getRestAPI("/api/v1/results/getlabs/", function(data) {
-            $scope.labs = data;
+        $scope.labs = [];
+        restAPISvc.getRestAPI("/api/v1/lab/", function(data) {
+            angular.forEach(data, function(lab) {
+                $scope.labs.push(lab.lab);
+            });
             $scope.loadingLabs = false;
         });
     }
index 1f65975..f0ac27c 100644 (file)
@@ -23,21 +23,31 @@ app
                     initialize();
 
                     function initialize() {
+                        $scope.blueprintInstances = [];
+                        $scope.blueprintNames = [];
+                        $scope.blueprintVersions = [];
+                        $scope.blueprintLayers = [];
+                        $scope.optionals = [];
+                        $scope.selectedBlueprintName = {};
+                        $scope.selectedBlueprintVersion = {};
+                        $scope.selectedBlueprintLayer = {};
+                        $scope.selectedOptional = "";
                         restAPISvc
                                 .getRestAPI(
-                                        "/api/v1/blueprintinstanceforvalidation/",
+                                        "/api/v1/blueprintinstance/",
                                         function(data) {
-                                            $scope.blueprintInstancesForValidation = data;
-                                            $scope.blueprintNames = [];
+                                            $scope.blueprintInstances = data;
                                             angular
                                                     .forEach(
-                                                            $scope.blueprintInstancesForValidation,
+                                                            $scope.blueprintInstances,
                                                             function(
                                                                     blueprintInstance) {
                                                                 if ($scope.blueprintNames
-                                                                        .indexOf(blueprintInstance["blueprint"]["blueprintName"]) === -1) {
+                                                                        .indexOf(blueprintInstance["blueprint"]["blueprintName"]
+                                                                                .trim()) === -1) {
                                                                     $scope.blueprintNames
-                                                                            .push(blueprintInstance["blueprint"]["blueprintName"]);
+                                                                            .push(blueprintInstance["blueprint"]["blueprintName"]
+                                                                                    .trim());
                                                                 }
                                                             });
                                         });
@@ -54,12 +64,14 @@ app
                                                  * + " duration(in sec) :" +
                                                  * blueprintInstance["timeslot"].duration
                                                  */
-                                                + " lab :" + timeslot.lab.lab;
+                                                + " lab :"
+                                                + timeslot.labInfo.lab;
                                         $scope.declerativeTimeslots.push(temp);
                                     });
                         });
                     }
-                    $scope.selectedBluePrintNameChange = function() {
+
+                    $scope.selectedBlueprintNameChange = function() {
                         $scope.blueprintVersions = [];
                         $scope.blueprintLayers = [];
                         $scope.optionals = [];
@@ -68,18 +80,22 @@ app
                         $scope.selectedOptional = "";
                         angular
                                 .forEach(
-                                        $scope.blueprintInstancesForValidation,
+                                        $scope.blueprintInstances,
                                         function(blueprintInstance) {
-                                            if ($scope.selectedBlueprintName === blueprintInstance["blueprint"]["blueprintName"]) {
+                                            if ($scope.selectedBlueprintName
+                                                    .trim() === blueprintInstance["blueprint"]["blueprintName"]
+                                                    .trim()) {
                                                 if ($scope.blueprintVersions
-                                                        .indexOf(blueprintInstance["version"]) === -1) {
+                                                        .indexOf(blueprintInstance["version"]
+                                                                .trim()) === -1) {
                                                     $scope.blueprintVersions
-                                                            .push(blueprintInstance["version"]);
+                                                            .push(blueprintInstance["version"]
+                                                                    .trim());
                                                 }
                                             }
                                         });
                     }
-                    $scope.selectedBluePrintVersionChange = function() {
+                    $scope.selectedBlueprintVersionChange = function() {
                         if (!$scope.selectedBlueprintName) {
                             return;
                         }
@@ -89,22 +105,29 @@ app
                         $scope.selectedOptional = "";
                         angular
                                 .forEach(
-                                        $scope.blueprintInstancesForValidation,
+                                        $scope.blueprintInstances,
                                         function(blueprintInstance) {
-                                            if ($scope.selectedBlueprintName === blueprintInstance["blueprint"]["blueprintName"]) {
-                                                if ($scope.selectedBlueprintVersion === blueprintInstance["version"]) {
-                                                    if ($scope.blueprintLayers
-                                                            .indexOf(blueprintInstance["layer"]) === -1) {
-                                                        $scope.blueprintLayers
-                                                                .push(blueprintInstance["layer"]);
-                                                    }
+                                            if ($scope.selectedBlueprintName
+                                                    .trim() === blueprintInstance["blueprint"]["blueprintName"]
+                                                    .trim()) {
+                                                if ($scope.selectedBlueprintVersion
+                                                        .trim() === blueprintInstance["version"]
+                                                        .trim()) {
+                                                    angular
+                                                            .forEach(
+                                                                    blueprintInstance.blueprintLayers,
+                                                                    function(
+                                                                            layer) {
+                                                                        $scope.blueprintLayers
+                                                                                .push(layer.layer);
+                                                                    });
                                                 }
                                             }
                                         });
                         $scope.blueprintLayers.push("all");
                     }
 
-                    $scope.selectedBluePrintLayerChange = function() {
+                    $scope.selectedBlueprintLayerChange = function() {
                         $scope.optionals = [ 'true', 'false' ];
                     }
 
@@ -138,30 +161,45 @@ app
                         if ($scope.selectedBlueprintLayer === 'all') {
                             allLayers = "true";
                         }
-                        var wRobotTestResults = [];
+                        var wrobotTestResults = [];
                         if (allLayers === "false") {
-                            wRobotTestResults = [ {
-                                "blueprintLayer" : $scope.selectedBlueprintLayer
+                            wrobotTestResults = [ {
+                                "layer" : $scope.selectedBlueprintLayer
                             } ];
                         }
 
-                        var validationNexusTestResult = {
-                            "blueprintName" : $scope.selectedBlueprintName,
-                            "version" : $scope.selectedBlueprintVersion,
+                        var blueprintInstanceData = "";
+                        angular
+                                .forEach(
+                                        $scope.blueprintInstances,
+                                        function(blueprintInstance) {
+                                            if ($scope.selectedBlueprintName
+                                                    .trim() === blueprintInstance["blueprint"]["blueprintName"]
+                                                    .trim()) {
+                                                if ($scope.selectedBlueprintVersion
+                                                        .trim() === blueprintInstance["version"]
+                                                        .trim()) {
+                                                    blueprintInstanceData = blueprintInstance;
+                                                }
+                                            }
+                                        });
+                        var validationDbTestResult = {
+                            "blueprintInstance" : blueprintInstanceData,
                             "allLayers" : allLayers,
-                            "wRobotNexusTestResults" : wRobotTestResults,
-                            "optional" : $scope.selectedOptional
+                            "wrobotDbTestResults" : wrobotTestResults,
+                            "optional" : $scope.selectedOptional,
+                            "lab" : finalTimeslot.labInfo
                         };
-                        var submissionData = {
-                            "validationNexusTestResult" : validationNexusTestResult,
+                        var submission = {
+                            "validationDbTestResult" : validationDbTestResult,
                             "timeslot" : finalTimeslot
                         };
                         restAPISvc
                                 .postRestAPI(
                                         "/api/v1/submission/",
-                                        submissionData,
+                                        submission,
                                         function(data) {
-                                            if (data !== undefined) {
+                                            if (data) {
                                                 var confirmText = "The blueprint instance for validation has been submitted successfully. Submission id:"
                                                         + data.submissionId;
                                                 confirm(confirmText);
index 049c8bc..82dda0f 100644 (file)
@@ -23,7 +23,7 @@ limitations under the License.
             <div class="form-row">
                 <label for="textinputID-3a">Select Blueprint: </label> <select
                     ng-model="selectedBlueprintName"
-                    ng-change="selectedBluePrintNameChange()"
+                    ng-change="selectedBlueprintNameChange()"
                     ng-options="n for n in blueprintNames">
                 </select>
             </div>
@@ -35,7 +35,7 @@ limitations under the License.
                 <label for="textinputID-3a">Select Blueprint
                     Version: </label> <select
                     ng-model="selectedBlueprintVersion"
-                    ng-change="selectedBluePrintVersionChange()"
+                    ng-change="selectedBlueprintVersionChange()"
                     ng-options="y for y in blueprintVersions">
                 </select>
             </div>
@@ -46,7 +46,7 @@ limitations under the License.
             <div class="form-row">
                 <label for="textinputID-3a">Select Blueprint
                     Layer: </label> <select ng-model="selectedBlueprintLayer"
-                    ng-change="selectedBluePrintLayerChange()"
+                    ng-change="selectedBlueprintLayerChange()"
                     ng-options="l for l in blueprintLayers">
                 </select>
             </div>
@@ -55,7 +55,8 @@ limitations under the License.
 
         <div>
             <div class="form-row">
-                <label for="textinputID-3a">Optional Test Cases: </label> <select ng-model="selectedOptional"
+                <label for="textinputID-3a">Optional Test Cases:
+                </label> <select ng-model="selectedOptional"
                     ng-change="selectedOptionalChange()"
                     ng-options="l for l in optionals">
                 </select>
index 8804de8..958d06e 100644 (file)
@@ -22,24 +22,23 @@ app.controller('TestSuiteResultsController', function($scope,
 
     function initialize() {
         $scope.showTestSuitesResults = false;
-        $scope.wRobotTestResults = [];
-        $scope.selectedTestId = null;
-        $scope.selectedTest = null;
+        $scope.wrobotTestResults = [];
+        $scope.selectedTestId = '';
+        $scope.selectedTest = '';
         $scope.resultsLayers = [];
         $scope.resultsLayerTestSuitesNames = [];
-        $scope.selectedRobotTestResult = [];
-        $scope.selectedLayer = [];
-        $scope.selectedTestSuiteName = [];
-
-        $scope.validationNexusTestResult = $scope.params;
-        $scope.wRobotTestResults = $scope.params.wRobotNexusTestResults;
+        $scope.selectedRobotTestResult = '';
+        $scope.selectedLayer = '';
+        $scope.selectedTestSuiteName = '';
+        $scope.validationDbTestResult = $scope.params;
+        $scope.wrobotTestResults = $scope.params.wrobotDbTestResults;
         if (generalValidationResultsSvc
-                .mapResult($scope.validationNexusTestResult) === null) {
+                .mapResult($scope.validationDbTestResult) === null) {
             confirm("No data was found");
         } else {
             $scope.showTestSuitesResults = true;
-            angular.forEach($scope.wRobotTestResults, function(result) {
-                $scope.resultsLayers.push(result.blueprintLayer);
+            angular.forEach($scope.wrobotTestResults, function(result) {
+                $scope.resultsLayers.push(result.layer);
             });
         }
 
@@ -50,15 +49,16 @@ app.controller('TestSuiteResultsController', function($scope,
         $scope.selectedTest = null;
         $scope.resultsLayerTestSuitesNames = [];
         $scope.robotTestResults = [];
-        $scope.selectedRobotTestResult = [];
-        $scope.selectedTestSuiteName = [];
+        $scope.selectedRobotTestResult = '';
+        $scope.selectedTestSuiteName = '';
         var selectedLayerResult = [];
-        angular.forEach($scope.wRobotTestResults, function(result) {
-            if (result.blueprintLayer === selectedLayer) {
+        angular.forEach($scope.wrobotTestResults, function(result) {
+            if (result.layer === selectedLayer) {
                 selectedLayerResult = result;
             }
         });
-        $scope.robotTestResults = selectedLayerResult.robotTestResults;
+        $scope.robotTestResults = angular
+                .fromJson(selectedLayerResult.robotTestResults);
         angular.forEach($scope.robotTestResults, function(robotTestResult) {
             $scope.resultsLayerTestSuitesNames.push(robotTestResult.name);
         });
@@ -68,8 +68,8 @@ app.controller('TestSuiteResultsController', function($scope,
         if (!selectedTestSuiteName) {
             return;
         }
-        $scope.selectedTestId = null;
-        $scope.selectedTest = null;
+        $scope.selectedTestId = '';
+        $scope.selectedTest = '';
         angular.forEach($scope.robotTestResults, function(robotTestResult) {
             if (robotTestResult.name.trim() === selectedTestSuiteName.trim()) {
                 $scope.selectedRobotTestResult = robotTestResult;
index 82eb5fe..507bd5b 100644 (file)
@@ -90,8 +90,7 @@ div.box {
 
         <br> <br> <br>
 
-        <div
-            ng-hide="selectedLayer == null || selectedTestSuiteName == null">
+        <div ng-hide="!selectedLayer || !selectedTestSuiteName">
             <div>
                 <h2 class="heading-small"></h2>
                 <div class="box">
index bfda0b1..eb545eb 100644 (file)
 
 var app = angular.module('ValidationResults');
 
-app.factory('generalValidationResultsSvc', [ function() {
-    var svc = [];
-    svc.getBlueprintLayers = function(wRobotNexusTestResults) {
-        var layers = [];
-        angular.forEach(wRobotNexusTestResults,
-                function(wRobotNexusTestResult) {
-                    if (wRobotNexusTestResult.blueprintLayer !== undefined) {
-                        layers.push(wRobotNexusTestResult.blueprintLayer);
+app
+        .factory(
+                'generalValidationResultsSvc',
+                [ function() {
+                    var svc = [];
+                    svc.getBlueprintLayers = function(wrobotDbTestResults) {
+                        if (!wrobotDbTestResults
+                                || wrobotDbTestResults.length === 0) {
+                            return null;
+                        }
+                        var layers = [];
+                        angular
+                                .forEach(
+                                        angular.fromJson(wrobotDbTestResults),
+                                        function(wrobotDbTestResult) {
+                                            if (wrobotDbTestResult.layer !== undefined) {
+                                                layers
+                                                        .push(wrobotDbTestResult.layer);
+                                            }
+                                        });
+                        return layers;
+                    };
+                    svc.mapResult = function(validationDbTestResult) {
+                        if (validationDbTestResult
+                                && validationDbTestResult.dateStorage) {
+                            if (validationDbTestResult.result === true) {
+                                return 'SUCCESS';
+                            }
+                            return 'FAILURE'
+                        }
+                        return null;
+                    };
+                    svc.filterWithLayer = function(validationDbTestResults,
+                            filterLayer) {
+                        if (filterLayer === undefined || filterLayer === '') {
+                            return validationDbTestResults;
+                        }
+                        var filteredResults = [];
+                        angular
+                                .forEach(
+                                        validationDbTestResults,
+                                        function(validationDbTestResult) {
+                                            angular
+                                                    .forEach(
+                                                            angular
+                                                                    .fromJson(validationDbTestResult.wrobotDbTestResults),
+                                                            function(
+                                                                    wrobotDbTestResult) {
+                                                                if (wrobotDbTestResult.layer
+                                                                        .toLowerCase()
+                                                                        .includes(
+                                                                                filterLayer
+                                                                                        .toLowerCase())) {
+                                                                    filteredResults
+                                                                            .push(validationDbTestResult);
+                                                                }
+                                                            });
+                                        });
+                        return filteredResults;
                     }
-                });
-        return layers;
-    };
-    svc.mapResult = function(validationNexusTestResult) {
-        if (!validationNexusTestResult.timestamp) {
-            return null;
-        }
-        if (!validationNexusTestResult.wRobotNexusTestResults) {
-            return null;
-        }
-        if (validationNexusTestResult.wRobotNexusTestResults.length === 0) {
-            return null;
-        }
-        var resultExistence = false;
-        angular.forEach(validationNexusTestResult.wRobotNexusTestResults,
-                function(result) {
-                    if (result.robotTestResults
-                            && result.robotTestResults.length > 0) {
-                        resultExistence = true;
+                    svc.filterWithResult = function(validationDbTestResults,
+                            filterResult) {
+                        if (filterResult === undefined || filterResult === '') {
+                            return validationDbTestResults;
+                        }
+                        var filteredResults = [];
+                        angular.forEach(validationDbTestResults, function(
+                                validationDbTestResult) {
+                            if (validationDbTestResult.result === true
+                                    && 'success'.includes(filterResult
+                                            .toLowerCase())) {
+                                filteredResults.push(validationDbTestResult);
+                            } else if (validationDbTestResult.result === false
+                                    && 'failure'.includes(filterResult
+                                            .toLowerCase())) {
+                                filteredResults.push(validationDbTestResult);
+                            }
+                        });
+                        return filteredResults;
                     }
-                });
-        if (resultExistence) {
-            if (validationNexusTestResult.result === true) {
-                return 'SUCCESS';
-            }
-            return 'FAILURE'
-        }
-        return null;
-    };
-    svc.filterWithLayer = function(validationNexusTestResults, filterLayer) {
-        if (filterLayer === undefined || filterLayer === '') {
-            return validationNexusTestResults;
-        }
-        var filteredResults = [];
-        angular.forEach(validationNexusTestResults, function(
-                validationNexusTestResult) {
-            angular.forEach(validationNexusTestResult.wRobotNexusTestResults,
-                    function(wRobotNexusTestResult) {
-                        if (wRobotNexusTestResult.blueprintLayer.toLowerCase()
-                                .includes(filterLayer.toLowerCase())) {
-                            filteredResults.push(validationNexusTestResult);
+                    svc.filterWithTimestamp = function(validationDbTestResults,
+                            filterTimestamp) {
+                        if (filterTimestamp === undefined
+                                || filterTimestamp === '') {
+                            return validationDbTestResults;
                         }
-                    });
-        });
-        return filteredResults;
-    }
-    svc.filterWithResult = function(validationNexusTestResults, filterResult) {
-        if (filterResult === undefined || filterResult === '') {
-            return validationNexusTestResults;
-        }
-        var filteredResults = [];
-        angular.forEach(validationNexusTestResults, function(
-                validationNexusTestResult) {
-            if (validationNexusTestResult.result === true
-                    && 'success'.includes(filterResult.toLowerCase())) {
-                filteredResults.push(validationNexusTestResult);
-            } else if (validationNexusTestResult.result === false
-                    && 'failure'.includes(filterResult.toLowerCase())) {
-                filteredResults.push(validationNexusTestResult);
-            }
-        });
-        return filteredResults;
-    }
-    svc.getLab = function(silo, silos) {
-        var lab = null;
-        angular.forEach(silos, function(siloData) {
-            if (silo === siloData.silo) {
-                lab = siloData.lab.lab;
-            }
-        });
-        return lab;
-    }
-    return svc;
-} ]);
\ No newline at end of file
+                        var filteredResults = [];
+                        angular.forEach(validationDbTestResults, function(
+                                validationDbTestResult) {
+                            if (validationDbTestResult.timestamp
+                                    && validationDbTestResult.timestamp
+                                            .toLowerCase().includes(
+                                                    filterTimestamp
+                                                            .toLowerCase())) {
+                                filteredResults.push(validationDbTestResult);
+                            }
+                        });
+                        return filteredResults;
+                    }
+                    return svc;
+                } ]);
\ No newline at end of file
index c4e9e72..dd2a2d9 100644 (file)
@@ -25,13 +25,13 @@ app
                     $scope.mapResult = generalValidationResultsSvc.mapResult;
                     $scope.filterWithLayer = generalValidationResultsSvc.filterWithLayer;
                     $scope.filterWithResult = generalValidationResultsSvc.filterWithResult;
-                    $scope.getLab = generalValidationResultsSvc.getLab;
+                    $scope.filterWithTimestamp = generalValidationResultsSvc.filterWithTimestamp;
 
                     initialize();
 
                     function initialize() {
                         $scope.loadingResults = true;
-                        $scope.validationNexusTestResults = [];
+                        $scope.validationDbTestResults = [];
                         $scope.silos = [];
                         var searchObject = $location.search();
                         var submissionId = searchObject.submissionId;
@@ -77,21 +77,13 @@ app
                                         reqUrl,
                                         function(resultData) {
                                             if (resultData) {
-                                                restAPISvc
-                                                        .getRestAPI(
-                                                                "/api/v1/silo/",
-                                                                function(
-                                                                        siloData) {
-                                                                    $scope.silos = siloData;
-                                                                    $scope.loadingResults = false;
-                                                                    if (!Array
-                                                                            .isArray(resultData)) {
-                                                                        $scope.validationNexusTestResults
-                                                                                .push(resultData);
-                                                                    } else {
-                                                                        $scope.validationNexusTestResults = resultData;
-                                                                    }
-                                                                });
+                                                $scope.loadingResults = false;
+                                                if (!Array.isArray(resultData)) {
+                                                    $scope.validationDbTestResults
+                                                            .push(resultData);
+                                                } else {
+                                                    $scope.validationDbTestResults = resultData;
+                                                }
                                             } else {
                                                 confirm("No data was found");
                                                 $scope.loadingResults = false;
@@ -100,8 +92,8 @@ app
                         $scope.descending = true;
                     }
 
-                    $scope.dateTimeSort = function(validationNexusTestResult) {
-                        return new Date(validationNexusTestResult.dateOfStorage)
+                    $scope.dateTimeSort = function(validationDbTestResult) {
+                        return new Date(validationDbTestResult.dateStorage)
                                 .getTime();
                     }
 
@@ -118,13 +110,13 @@ app
                     }
 
                     $scope.getTestSuiteResults = function(
-                            validationNexusTestResult) {
+                            validationDbTestResult) {
                         if (!generalValidationResultsSvc
-                                .mapResult(validationNexusTestResult)) {
+                                .mapResult(validationDbTestResult)) {
                             return;
                         }
                         var scope = $rootScope.$new();
-                        scope.params = validationNexusTestResult;
+                        scope.params = validationDbTestResult;
                         $modal
                                 .open({
                                     scope : scope,
index a327ca0..8ae3109 100644 (file)
@@ -188,46 +188,48 @@ table {
             </thead>
             <tbody>
                 <tr class="border_bottom"
-                    ng-repeat="validationNexusTestResult in filterWithResult(filterWithLayer(validationNexusTestResults,filterLayer), filterResult) | filter:filtertimestamp | orderBy:dateTimeSort:descending"
-                    ng-class="{success: (validationNexusTestResult.result===true), warning: (validationNexusTestResult.result===false)}">
+                    ng-repeat="validationDbTestResult in filterWithResult(filterWithLayer(filterWithTimestamp(validationDbTestResults,filtertimestamp.timestamp),filterLayer), filterResult) | orderBy:dateTimeSort:descending"
+                    ng-class="{'success': validationDbTestResult.result===true, 'warning': validationDbTestResult.result===false || !validationDbTestResult.dateStorage}">
                     <td class
                         style="padding-left: 10px; font-size: 15px; width: 13%;">
-                        {{ getLab(validationNexusTestResult.silo, silos)
-                        }}</td>
+                        {{ validationDbTestResult.lab.lab }}</td>
                     <td class
                         style="padding-left: 10px; font-size: 15px; width: 13%;">{{
-                        validationNexusTestResult.blueprintName }}</td>
+                        validationDbTestResult.blueprintInstance.blueprint.blueprintName
+                        }}</td>
                     <td class
                         style="padding-left: 10px; font-size: 15px; width: 13%;">{{
-                        validationNexusTestResult.version }}</td>
+                        validationDbTestResult.blueprintInstance.version
+                        }}</td>
                     <td class
                         style="padding-left: 10px; font-size: 15px; width: 13%;">{{
-                        validationNexusTestResult.timestamp }}</td>
+                        validationDbTestResult.timestamp }}</td>
                     <td class
                         style="padding-left: 10px; font-size: 15px; width: 13%;">{{
-                        validationNexusTestResult.dateOfStorage }}</td>
+                        validationDbTestResult.dateStorage }}</td>
                     <td class
                         style="padding-left: 10px; font-size: 15px; width: 13%;">{{
-                        validationNexusTestResult.optional }}</td>
+                        validationDbTestResult.optional }}</td>
                     <td class
                         style="padding-left: 10px; font-size: 15px; width: 13%;">{{
-                        validationNexusTestResult.allLayers }}</td>
+                        validationDbTestResult.allLayers }}</td>
                     <td class
                         style="padding-left: 10px; font-size: 15px; width: 13%;">
                         <div
-                            ng-repeat="layer in  getBlueprintLayers(validationNexusTestResult.wRobotNexusTestResults)">
+                            ng-repeat="layer in  getBlueprintLayers(validationDbTestResult.wrobotDbTestResults)">
                             {{layer}}</div>
                     </td>
                     <td class
                         style="padding-left: 10px; font-size: 15px; width: 13%;">{{
-                        validationNexusTestResult.submissionId }}</td>
+                        validationDbTestResult.submission.submissionId
+                        }}</td>
                     <td class
                         style="padding-left: 10px; font-size: 15px; width: 13%;">
                         <button
                             style="margin-left: 25px; margin-top: 4px;"
                             type="submit" class="btn btn-alt btn-small"
-                            ng-click="getTestSuiteResults(validationNexusTestResult);">{{
-                            mapResult(validationNexusTestResult)}}</button>
+                            ng-click="getTestSuiteResults(validationDbTestResult);">{{
+                            mapResult(validationDbTestResult)}}</button>
                         </button>
                     </td>
                 </tr>