Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
bcivel committed Jul 10, 2024
2 parents 806ad34 + 75c1893 commit d0a8949
Show file tree
Hide file tree
Showing 8 changed files with 878 additions and 0 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.cerberus.core.util.answer.Answer;
import org.cerberus.core.util.answer.AnswerList;

import java.util.List;
import java.util.Map;

/**
Expand Down Expand Up @@ -53,6 +54,7 @@ public interface ITagStatisticDAO {
* @return
*/
Answer read(TagStatistic object);
AnswerList<TagStatistic> readByCriteria(List<String> systems, List<String> applications, List<String> groups1, String minDate, String maxDate);

/**
* Get a TagStatistics list by tag from database
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.cerberus.core.engine.entity.MessageEvent;
import org.cerberus.core.enums.MessageEventEnum;
import org.cerberus.core.util.ParameterParserUtil;
import org.cerberus.core.util.SqlUtil;
import org.cerberus.core.util.answer.Answer;
import org.cerberus.core.util.answer.AnswerList;
import org.springframework.stereotype.Repository;
Expand All @@ -36,6 +37,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@AllArgsConstructor
@Repository
Expand Down Expand Up @@ -126,6 +128,95 @@ public Answer read(TagStatistic object) {
return null;
}

@Override
public AnswerList<TagStatistic> readByCriteria(List<String> systems, List<String> applications, List<String> groups1, String minDate, String maxDate) {
AnswerList<TagStatistic> response = new AnswerList<>();
MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
List<TagStatistic> tagStatistics = new ArrayList<>();

StringBuilder query = new StringBuilder();

query.append("SELECT * from tagstatistic tac WHERE `Campaign` IN (SELECT DISTINCT `Campaign` FROM tagstatistic tac");

String systemRegex = "";
String applicationRegex = "";

if (!systems.isEmpty()) {
systemRegex = systems.stream()
.map(sys -> "\"" + sys + "\"")
.collect(Collectors.joining("|"));
query.append(" WHERE tac.`SystemList` REGEXP ?");
}

if (!applications.isEmpty()) {
query.append(" AND tac.`ApplicationList` REGEXP ?");
applicationRegex = applications.stream()
.map(app -> "\"" + app + "\"")
.collect(Collectors.joining("|"));
}

if (!groups1.isEmpty()) {
query.append(" AND ").append(SqlUtil.generateInClause("CampaignGroup1", groups1));
}

query.append(") AND tac.`DateStartExe` >= ? AND tac.`DateEndExe` <= ?");

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query.toString());
Statement stm = connection.createStatement()) {

int i = 1;

preStat.setString(i++, systemRegex);
preStat.setString(i++, applicationRegex);

if (!groups1.isEmpty()) {
for (String group1 : groups1) {
preStat.setString(i++, group1);
}
}

preStat.setString(i++, minDate);
preStat.setString(i++, maxDate);

try (ResultSet resultSet = preStat.executeQuery();
ResultSet rowSet = stm.executeQuery("SELECT FOUND_ROWS()")) {

LOG.debug("Execute SQL Statement: {} ", preStat);

while (resultSet.next()) {
LOG.debug(resultSet);
tagStatistics.add(this.loadFromResultSet(resultSet));
}

int nrTotalRows = 0;
if (rowSet != null && rowSet.next()) {
nrTotalRows = rowSet.getInt(1);
}

if (tagStatistics.size() >= MAX_ROW_SELECTED) { // Result of SQl was limited by MAX_ROW_SELECTED constrain. That means that we may miss some lines in the resultList.
LOG.error("Partial Result in the query.");
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_WARNING_PARTIAL_RESULT);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Maximum row reached : " + MAX_ROW_SELECTED));
} else if (tagStatistics.isEmpty()) {
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);
} else {
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "SELECT"));
}
response = new AnswerList<>(tagStatistics, nrTotalRows);
}
} catch (SQLException exception) {
LOG.error("Unable to execute query : {}", exception.toString());
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
}
response.setResultMessage(msg);
response.setDataList(tagStatistics);
return response;
}

/**
* Get a TagStatistics list by tag from database
* @param tag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2484,6 +2484,8 @@ public ArrayList<String> getSqlDocumentation() {
b.append(",('page_header','menuReportingCampaignOverTime','','en','Campaign Report Over Time','',NULL)");
b.append(",('page_header','menuReportingCampaignOverTime','','fr','Rapport de Campagne dans le temps','',NULL)");
b.append(",('page_header','menuReportingCampaignOverTime','','fa','گزارش در طول زمان کمپین','',NULL)");
b.append(",('page_header','menuReportingCampaignStatistic','','en','Campaign Statistics','',NULL)");
b.append(",('page_header','menuReportingCampaignStatistic','','fr','Statistiques de Campagne','',NULL)");
b.append(",('page_header','menuReportingExecutionList','','en','Execution List','',NULL)");
b.append(",('page_header','menuReportingExecutionList','','fr','Liste d\\'Execution','',NULL)");
b.append(",('page_header','menuReportingExecutionList','','fa','فهرست اجرا','',NULL)");
Expand Down Expand Up @@ -2793,6 +2795,42 @@ public ArrayList<String> getSqlDocumentation() {
b.append(",('page_campaignreportovertime','title','','en','Campaign Execution reporting over Time','This page provide some execution stats over time.',NULL)");
b.append(",('page_campaignreportovertime','title','','fa','گزارش اجرای کمپین در طول زمان','این صفحه برخی از آمارهای اجرا را در طول زمان ارائه می دهد.',NULL)");
b.append(",('page_campaignreportovertime','title','','fr','Rapport d\\'execution des campagnes dans le temps','Cette page génère des rapports d\\'evolution de compteurs d\\'execution sur la durée',NULL)");
b.append(",('page_campaignstatistics','title','','en','Campaign Statistics','This page provide some statistics at a campaign level to follow up.',NULL)");
b.append(",('page_campaignstatistics','title','','fr','Statistiques de campagnes','Cette page propose des statistiques de campagne pour permettre le suivi.',NULL)");
b.append(",('page_campaignstatistics','labelSystemSelect','','fr','Système','',NULL)");
b.append(",('page_campaignstatistics','labelSystemSelect','','en','System','',NULL)");
b.append(",('page_campaignstatistics','labelApplicationSelect','','fr','Application','',NULL)");
b.append(",('page_campaignstatistics','labelApplicationSelect','','en','Application','',NULL)");
b.append(",('page_campaignstatistics','labelGroup1Select','','fr','Groupe 1 de campagne','',NULL)");
b.append(",('page_campaignstatistics','labelGroup1Select','','en','Campaign Group 1','',NULL)");
b.append(",('page_campaignstatistics','labelFromPicker','','fr','Du','',NULL)");
b.append(",('page_campaignstatistics','labelFromPicker','','en','From','',NULL)");
b.append(",('page_campaignstatistics','labelToPicker','','fr','Au','',NULL)");
b.append(",('page_campaignstatistics','labelToPicker','','en','To','',NULL)");
b.append(",('page_campaignstatistics','buttonDetailByCountryEnv','','fr','Détail par environnement et pays','',NULL)");
b.append(",('page_campaignstatistics','buttonDetailByCountryEnv','','en','Detail by country and environment','',NULL)");
b.append(",('page_campaignstatistics','buttonLoad','','fr','Charger','',NULL)");
b.append(",('page_campaignstatistics','buttonLoad','','en','Load','',NULL)");
b.append(",('page_campaignstatistics','campaign_col','','fr','Campagne','',NULL)");
b.append(",('page_campaignstatistics','campaign_col','','en','Campaign','',NULL)");
b.append(",('page_campaignstatistics','systems_col','','fr','Systèmes','',NULL)");
b.append(",('page_campaignstatistics','systems_col','','en','Systems','',NULL)");
b.append(",('page_campaignstatistics','applications_col','','fr','Applications','',NULL)");
b.append(",('page_campaignstatistics','applications_col','','en','Applications','',NULL)");
b.append(",('page_campaignstatistics','group1_col','','fr','Groupe 1','',NULL)");
b.append(",('page_campaignstatistics','group1_col','','en','Group 1','',NULL)");
b.append(",('page_campaignstatistics','minDateStart_col','','fr','Date de début minimale de la première exécution','',NULL)");
b.append(",('page_campaignstatistics','minDateStart_col','','en','Minimum start date','',NULL)");
b.append(",('page_campaignstatistics','maxDateEnd_col','','fr','Date de fin maximale de la dernière exécution','',NULL)");
b.append(",('page_campaignstatistics','maxDateEnd_col','','en','Maximum end date','',NULL)");
b.append(",('page_campaignstatistics','avgOK_col','','fr','Pourcentage moyen de OK','',NULL)");
b.append(",('page_campaignstatistics','avgOK_col','','en','Average percentage of OK','',NULL)");
b.append(",('page_campaignstatistics','avgDuration_col','','fr','Durée moyenne','',NULL)");
b.append(",('page_campaignstatistics','avgDuration_col','','en','Average duration','',NULL)");
b.append(",('page_campaignstatistics','avgReliability_col','','fr','Fiabilité moyenne','',NULL)");
b.append(",('page_campaignstatistics','avgReliability_col','','en','Average reliability','',NULL)");
b.append(",('page_campaignstatistics','avgNbExeUsefull_col','','fr','Nombre moyen d\\'exécutions utiles','',NULL)");
b.append(",('page_campaignstatistics','avgNbExeUsefull_col','','en','Average number of usefull executions','',NULL)");
b.append(",('page_robot','button_create','','en','Create new Robot','',NULL)");
b.append(",('page_robot','button_create','','fa','ایجاد ربات جدید','',NULL)");
b.append(",('page_robot','button_create','','fr','Créer un nouveau Robot','',NULL)");
Expand Down
107 changes: 107 additions & 0 deletions source/src/main/webapp/ReportingCampaignStatistics.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<%--
Cerberus Copyright (C) 2013 - 2017 cerberustesting
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This file is part of Cerberus.
Cerberus is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Cerberus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Cerberus. If not, see <http://www.gnu.org/licenses/>.
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="include/global/dependenciesInclusions.html" %>
<title id="pageTitle">Campaign statistics</title>
<script type="text/javascript" src="dependencies/Tinymce-6.7.0/tinymce.min.js"></script>
<script type="text/javascript" src="dependencies/Moment-2.30.1/moment-with-locales.min.js"></script>
<script type="text/javascript" src="dependencies/Bootstrap-datetimepicker-4.17.47/bootstrap-datetimepicker.min.js"></script>
<link rel="stylesheet" href="dependencies/Bootstrap-datetimepicker-4.17.47/bootstrap-datetimepicker.min.css" />
<script type="text/javascript" src="js/pages/ReportingCampaignStatistics.js"></script>
</head>
<body>
<%@ include file="include/global/header.html" %>
<div class="container-fluid center" id="page-layout">
<%@ include file="include/global/messagesArea.html"%>
<%@ include file="include/utils/modal-confirmation.html"%>

<h1 class="page-title-line" id="title">Campaign Statistics</h1>
<div class="panel panel-default">
<div class="panel-body" id="filters">
<div class='col-md-4'>
<div class="form-group">
<label for="system-select" id="labelSystemSelect">Système</label>
<select id="system-select" class="form-control" multiple="multiple">
</select>
</div>
</div>
<div class='col-md-4'>
<div class="form-group">
<label for="application-select" id="labelApplicationSelect">Application</label>
<select id="application-select" class="form-control" multiple="multiple">
</select>
</div>
</div>
<div class='col-md-4'>
<div class="form-group">
<label for="group1-select" id="labelGroup1Select">Group 1</label>
<select id="group1-select" class="form-control" multiple="multiple">
</select>
</div>
</div>
<div class='col-md-4'>
<div class="form-group">
<label for="frompicker" id="labelFromPicker">From</label>
<div class='input-group date' id='frompicker'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<div class='col-md-4'>
<div class="form-group">
<label for="topicker" id="labelToPicker">To</label>
<div class='input-group date' id='topicker'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<div class="col-sm-2 col-md-2">
<div class="input-group-btn ">
<button type="button" class="btn btn-primary btn-block marginTop20" id="loadbutton">Load</button>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-body" id="tagStatisticList">
<table id="tagStatisticTable" class="table table-bordered table-hover display" name="tagStatisticTable"></table>
<div class="marginBottom20"></div>
</div>
</div>
<footer class="footer">
<div class="container-fluid" id="footer"></div>
</footer>
</div>
<script>
</script>
</body>
</html>
1 change: 1 addition & 0 deletions source/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
<url-pattern>/ReportingExecutionByTag.jsp</url-pattern>
<url-pattern>/ReportingExecutionOverTime.jsp</url-pattern>
<url-pattern>/ReportingCampaignOverTime.jsp</url-pattern>
<url-pattern>/ReportingCampaignStatistics.jsp</url-pattern>
<url-pattern>/TestCaseExecutionQueueList.jsp</url-pattern>
<url-pattern>/Test.jsp</url-pattern>
<url-pattern>/TestCaseScript.jsp</url-pattern>
Expand Down
1 change: 1 addition & 0 deletions source/src/main/webapp/include/global/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<li><a name="menu" id="menuReportingExecutionOverTime" href="ReportingExecutionOverTime.jsp">Execution Report Over Time</a></li>
<li><a name="menu" id="menuReportingExecutionByTag" href="ReportingExecutionByTag.jsp">Campaign Execution Report</a></li>
<li><a name="menu" id="menuReportingCampaignOverTime" href="ReportingCampaignOverTime.jsp">Campaign Report Over Time</a></li>
<!--<li><a name="menu" id="menuReportingCampaignStatistic" href="ReportingCampaignStatistics.jsp">Campaign Statistics</a></li>-->
</ul>
</li>
<li class ="navbar-side-choice IntegratorRO navlist" id="navMenuApplication" style="display:none">
Expand Down
Loading

0 comments on commit d0a8949

Please sign in to comment.