66-derivation-of-rules #67

Merged
romanov73 merged 1 commits from 66-derivation-of-rules into master 2022-10-14 11:29:16 +04:00
6 changed files with 68 additions and 12 deletions

View File

@ -16,6 +16,7 @@ public class Route {
public static final String INDEXING_NEW_REPOSITORY = "indexNewRepository"; public static final String INDEXING_NEW_REPOSITORY = "indexNewRepository";
public static final String FILTER_COMMITS = "filterCommits"; public static final String FILTER_COMMITS = "filterCommits";
public static final String STATISTIC = "statistic"; public static final String STATISTIC = "statistic";
public static final String LIST_RULE = "listRules";
public static String getLIST_INDEXED_REPOSITORIES() { public static String getLIST_INDEXED_REPOSITORIES() {
return LIST_INDEXED_REPOSITORIES; return LIST_INDEXED_REPOSITORIES;

View File

@ -0,0 +1,25 @@
package ru.ulstu.extractor.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import ru.ulstu.extractor.service.RuleService;
import springfox.documentation.annotations.ApiIgnore;
import static ru.ulstu.extractor.controller.Route.LIST_RULE;
@Controller
@ApiIgnore
public class RuleController {
private RuleService ruleService;
public RuleController(RuleService ruleService) {
this.ruleService = ruleService;
}
@GetMapping(LIST_RULE)
public String getList(Model model) {
model.addAttribute("rules", ruleService.getList());
return LIST_RULE;
}
}

View File

@ -31,11 +31,11 @@ public class Rule extends BaseEntity {
this.consequent = consequent; this.consequent = consequent;
} }
public AntecedentValue getFirstValue() { public AntecedentValue getFirstAntecedentValue() {
return firstAntecedentValue; return firstAntecedentValue;
} }
public void setFirstValue(AntecedentValue firstAntecedentValue) { public void setFirstAntecedentValue(AntecedentValue firstAntecedentValue) {
this.firstAntecedentValue = firstAntecedentValue; this.firstAntecedentValue = firstAntecedentValue;
} }
@ -47,11 +47,11 @@ public class Rule extends BaseEntity {
this.firstAntecedent = firstAntecedent; this.firstAntecedent = firstAntecedent;
} }
public AntecedentValue getSecondValue() { public AntecedentValue getSecondAntecedentValue() {
return secondAntecedentValue; return secondAntecedentValue;
} }
public void setSecondValue(AntecedentValue secondAntecedentValue) { public void setSecondAntecedentValue(AntecedentValue secondAntecedentValue) {
this.secondAntecedentValue = secondAntecedentValue; this.secondAntecedentValue = secondAntecedentValue;
} }

View File

@ -0,0 +1,7 @@
package ru.ulstu.extractor.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import ru.ulstu.extractor.model.Rule;
public interface RuleRepository extends JpaRepository<Rule, Integer> {
}

View File

@ -0,0 +1,20 @@
package ru.ulstu.extractor.service;
import org.springframework.stereotype.Service;
import ru.ulstu.extractor.model.Rule;
import ru.ulstu.extractor.repository.RuleRepository;
import java.util.List;
@Service
public class RuleService {
private final RuleRepository ruleRepository;
public RuleService(RuleRepository ruleRepository) {
this.ruleRepository = ruleRepository;
}
public List<Rule> getList() {
return ruleRepository.findAll();
}
}

View File

@ -1,6 +1,6 @@
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd"> <!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html <html
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.w3.org/1999/xhtml"
layout:decorate="~{default}"> layout:decorate="~{default}">
<head> <head>
<title>Простая обработка формы на Spring MVC</title> <title>Простая обработка формы на Spring MVC</title>
@ -10,16 +10,19 @@
<table class="table table-striped"> <table class="table table-striped">
<thead class="thead-dark"> <thead class="thead-dark">
<tr> <tr>
<th scope="col">Правила</th> <th scope="col" colspan="8">Правила</th>
<th width="10%"></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr th:each="rule: ${rules}">
<td>Если задач много, а коммитов мало, то увеличить колличество авторов</td> <td><span class="badge badge-info">Если</span></td>
</tr> <td><span class="badge badge-success" th:text="${rule.firstAntecedent.name}"></span></td>
<tr> <td><span class="badge badge-success" th:text="${rule.firstAntecedentValue.antecedentValue}"></span></td>
<td>Если авторов много, задач мало, оценнить эффективность авторов</td> <td><span class="badge badge-info">и</span></td>
<td><span class="badge badge-success" th:text="${rule.secondAntecedent.name}"></span></td>
<td><span class="badge badge-success" th:text="${rule.secondAntecedentValue.antecedentValue}"></span></td>
<td><span class="badge badge-info">то</span></td>
<td><span class="badge badge-warning" th:text="${rule.consequent}"></span></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>