Skip to content

Commit

Permalink
Merge origin/master
Browse files Browse the repository at this point in the history
  • Loading branch information
vertigo17 committed Jul 15, 2024
2 parents 3adcdba + 361c4b5 commit 2ff69d9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.cerberus.core.crud.dao.ITagStatisticDAO;
import org.cerberus.core.crud.entity.Application;
import org.cerberus.core.crud.entity.TagStatistic;
import org.cerberus.core.crud.entity.UserSystem;
import org.cerberus.core.crud.service.IApplicationService;
import org.cerberus.core.crud.service.ITagStatisticService;
import org.cerberus.core.crud.service.IUserSystemService;
import org.cerberus.core.exception.CerberusException;
import org.cerberus.core.util.ParameterParserUtil;
Expand Down Expand Up @@ -58,12 +58,10 @@ public class CampaignExecutionPrivateController {

@Autowired
private IUserSystemService userSystemService;

@Autowired
private IApplicationService applicationService;

@Autowired
private ITagStatisticDAO tagStatisticDAO;
private ITagStatisticService tagStatisticService;

@GetMapping(path = "/statistics", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> getTagStatistics(
Expand All @@ -78,7 +76,7 @@ public ResponseEntity<String> getTagStatistics(
toParam = ParameterParserUtil.parseStringParamAndDecode(toParam, new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'").format(new Date()), "UTF8");
List<String> systems = ParameterParserUtil.parseListParamAndDecode(systemsParam, new ArrayList<>(), "UTF8");
List<String> applications = ParameterParserUtil.parseListParamAndDecode(applicationsParam, new ArrayList<>(), "UTF8");
List<String> groups1 = ParameterParserUtil.parseListParamAndDecode(group1Param, new ArrayList<>(), "UTF8");
List<String> group1List = ParameterParserUtil.parseListParamAndDecode(group1Param, new ArrayList<>(), "UTF8");

String fromDateFormatted = formatDateForDb(fromParam);
String toDateFormatted = formatDateForDb(toParam);
Expand All @@ -98,7 +96,7 @@ public ResponseEntity<String> getTagStatistics(
systems.removeIf(param -> !systemsAllowed.contains(param));
applications.removeIf(param -> !applicationsAllowed.contains(param));

List<TagStatistic> tagStatistics = tagStatisticDAO.readByCriteria(systems, applications, groups1, fromDateFormatted, toDateFormatted).getDataList();
List<TagStatistic> tagStatistics = tagStatisticService.readByCriteria(systems, applications, group1List, fromDateFormatted, toDateFormatted).getDataList();
LOG.debug(tagStatistics);

Map<String, Map<String, JSONObject>> agregateByTag = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public Answer read(TagStatistic object) {
}

@Override
public AnswerList<TagStatistic> readByCriteria(List<String> systems, List<String> applications, List<String> groups1, String minDate, String maxDate) {
public AnswerList<TagStatistic> readByCriteria(List<String> systems, List<String> applications, List<String> group1List, String minDate, String maxDate) {
AnswerList<TagStatistic> response = new AnswerList<>();
MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
Expand All @@ -156,8 +156,8 @@ public AnswerList<TagStatistic> readByCriteria(List<String> systems, List<String
.collect(Collectors.joining("|"));
}

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

query.append(") AND tac.`DateStartExe` >= ? AND tac.`DateEndExe` <= ?");
Expand All @@ -171,8 +171,8 @@ public AnswerList<TagStatistic> readByCriteria(List<String> systems, List<String
preStat.setString(i++, systemRegex);
preStat.setString(i++, applicationRegex);

if (!groups1.isEmpty()) {
for (String group1 : groups1) {
if (!group1List.isEmpty()) {
for (String group1 : group1List) {
preStat.setString(i++, group1);
}
}
Expand All @@ -186,7 +186,6 @@ public AnswerList<TagStatistic> readByCriteria(List<String> systems, List<String
LOG.debug("Execute SQL Statement: {} ", preStat);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.cerberus.core.crud.entity.Tag;
import org.cerberus.core.crud.entity.TagStatistic;
import org.cerberus.core.crud.entity.TestCaseExecution;
import org.cerberus.core.util.answer.Answer;
import org.cerberus.core.util.answer.AnswerList;

import java.util.List;
Expand All @@ -33,6 +34,8 @@ public interface ITagStatisticService {
* @return AnswerList that contains data from database
*/
AnswerList<TagStatistic> readByTag(String tag);
Answer createWithMap(Map<String, TagStatistic> map);
AnswerList<TagStatistic> readByCriteria(List<String> systems, List<String> applications, List<String> groups1, String minDate, String maxDate);

/**
* Initialize TagStatistics objects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.cerberus.core.crud.service.ICampaignService;
import org.cerberus.core.crud.service.ITagStatisticService;
import org.cerberus.core.exception.CerberusException;
import org.cerberus.core.util.answer.Answer;
import org.cerberus.core.util.answer.AnswerList;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -58,6 +59,17 @@ public AnswerList<TagStatistic> readByTag(String tag) {
return tagStatisticDAO.readByTag(tag);
}

@Override
public AnswerList<TagStatistic> readByCriteria(List<String> systems, List<String> applications, List<String> group1List, String minDate, String maxDate) {
return tagStatisticDAO.readByCriteria(systems, applications, group1List, minDate, maxDate);
}

@Override
public Answer createWithMap(Map<String, TagStatistic> map) {
return tagStatisticDAO.createWithMap(map);
}


/**
* Initialize TagStatistics objects
* @param tag
Expand Down Expand Up @@ -109,7 +121,7 @@ public void populateTagStatisticsMap(Map<String, TagStatistic> tagStatistics, Li
tagStatistic.setUsrCreated(tag.getUsrCreated());
tagStatistic.setExecutions(null);
}
tagStatisticDAO.createWithMap(tagStatistics);
createWithMap(tagStatistics);
}

/**
Expand Down

0 comments on commit 2ff69d9

Please sign in to comment.