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
### 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
+
- 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.
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:
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:
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.
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:
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:
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)
- 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
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)
);
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
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,
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)
);
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;
<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>
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;
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;
@Service
public final class NexusExecutorClient {
+ @Autowired
+ DbResultAdapter dbAdapter;
+
private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(NexusExecutorClient.class);
private final Client client;
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 {
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 {
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);
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");
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;
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;
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 {
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;
}
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;
}
}
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;
+++ /dev/null
-/*
- * 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;
- }
-
-}
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;
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;
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;
}
}
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;
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));
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;
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);
}
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;
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) {
@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) {
}
@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) {
}
@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);
}
@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 {
@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) {
@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<>(
}
@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 {
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;
}
@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));
}
}
@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));
}
}
@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));
}
Blueprint getBlueprint(Integer blueprintId);
+ Blueprint getBlueprint(String name);
+
void deleteBlueprint(Blueprint blueprint);
void deleteAll();
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();
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();
import java.util.List;
-import org.akraino.validation.ui.data.Lab;
import org.akraino.validation.ui.entity.LabInfo;
public interface LabDAO {
LabInfo getLab(Integer labId);
- LabInfo getLab(Lab lab);
+ LabInfo getLab(String lab);
+
+ LabInfo getLabBasedOnSilo(String silo);
void deleteLab(LabInfo lab);
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;
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);
@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
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;
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;
}
@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();
}
}
--- /dev/null
+/*
+ * 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");
+ }
+ }
+
+}
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;
@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
+++ /dev/null
-/*
- * 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();
- }
- }
-
-}
@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);
}
@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
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;
@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));
@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));
}
@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);
@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);
@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();
}
@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);
}
+++ /dev/null
-/*
- * 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
-}
+++ /dev/null
-/*
- * 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
-}
+++ /dev/null
-/*
- * 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;
- }
-}
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 {
/**
*
@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;
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;
- }
}
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 {
/**
*
@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;
- }
}
import javax.persistence.Id;
import javax.persistence.Table;
-import org.akraino.validation.ui.data.Lab;
-
@Entity
@Table(name = "lab")
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;
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;
+ }
+
}
*/
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);
+
/**
*
*/
@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;
}
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);
+ }
+ }
+
}
@ManyToOne
@JoinColumn(name = "lab_id")
- private LabInfo lab;
+ private LabInfo labInfo;
public void setTimeslotId(int timeslotId) {
this.timeslotId = timeslotId;
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;
}
}
*/
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 {
@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")
@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;
}
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() {
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);
+ }
+ }
+
}
*/
package org.akraino.validation.ui.entity;
+import java.io.IOException;
import java.io.Serializable;
import javax.persistence.Column;
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 {
@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;
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);
+ }
+
+ }
}
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() {
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();
}
}
blueprintDAO.saveOrUpdate(blueprint);
}
+ public Blueprint getBlueprint(String name) {
+ return blueprintDAO.getBlueprint(name);
+ }
+
public List<Blueprint> getBlueprints() {
return blueprintDAO.getBlueprints();
}
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
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);
}
}
wRobotResults = wRobotDAO.getWRobotTestResult(vDbTimestamp);
if (wRobotResults != null && wRobotResults.size() > 0) {
for (WRobotDbTestResult wRobotResult : wRobotResults) {
- wRobotResult.setValidationTestResult(vDbSubmission);
+ wRobotResult.setValidationDbTestResult(vDbSubmission);
wRobotDAO.saveOrUpdate(wRobotResult);
}
}
}
}
- 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);
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;
}
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;
}
vTestResultDAO.deleteValidationTestResult(vDbResult);
}
}
-
}
}
}
}
- 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);
}
}
}
}
+ 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);
}
}
- 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;
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(),
+ " 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;
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;
+ }
+
}
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;
public class DbSubmissionAdapter {
private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(DbSubmissionAdapter.class);
+ private static final Object LOCK = new Object();
@Autowired
private SubmissionDAO submissionDAO;
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");
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));
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;
@Autowired
private DbSubmissionAdapter submissionService;
- @Autowired
- private SiloService siloService;
-
@Autowired
NexusExecutorClient nexusService;
@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 {
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));
}
}
});
- 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));
}
}
});
- return vNexusResults.get(0);
+ return vDbResults.get(0);
}
return this.getLastResultBasedOnOutcomeFromNexus(name, version, lab, layers, optional, outcome);
}
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;
@Autowired
private DbSubmissionAdapter submissionService;
- @Autowired
- private SiloService siloService;
-
@Autowired
private DbResultAdapter dbAdapter;
@Autowired
private IntegratedResultService iService;
+ @Autowired
+ private LabService labService;
+
@Autowired
private ValidationTestResultDAO vTestResultDAO;
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);
}
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;
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();
}
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
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
'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'
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);
+ */
+
+ });
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>
$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;
});
}
$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;
});
}
$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;
});
}
$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;
});
}
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());
}
});
});
* + " 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 = [];
$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;
}
$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' ];
}
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);
<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>
<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>
<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>
<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>
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);
});
}
$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);
});
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;
<br> <br> <br>
- <div
- ng-hide="selectedLayer == null || selectedTestSuiteName == null">
+ <div ng-hide="!selectedLayer || !selectedTestSuiteName">
<div>
<h2 class="heading-small"></h2>
<div class="box">
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
$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;
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;
$scope.descending = true;
}
- $scope.dateTimeSort = function(validationNexusTestResult) {
- return new Date(validationNexusTestResult.dateOfStorage)
+ $scope.dateTimeSort = function(validationDbTestResult) {
+ return new Date(validationDbTestResult.dateStorage)
.getTime();
}
}
$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,
</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>