#2 -- Add inference dtos #22
@ -46,8 +46,7 @@ dependencies {
|
||||
implementation group: 'org.webjars', name: 'jquery', version: '3.6.0'
|
||||
implementation group: 'org.webjars', name: 'bootstrap', version: '4.6.0'
|
||||
implementation group: 'org.webjars', name: 'bootstrap-select', version: '1.13.8'
|
||||
implementation group: 'org.webjars', name: 'font-awesome', version: '4.7.0'
|
||||
implementation group: 'org.webjars', name: 'highcharts', version: '7.0.0'
|
||||
implementation 'org.webjars.npm:bootstrap-icons:1.11.3'
|
||||
|
||||
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-test'
|
||||
}
|
||||
|
@ -24,4 +24,18 @@ public class ProjectVariableService {
|
||||
}
|
||||
return variableRepository.findByProject(projectService.getById(projectId));
|
||||
}
|
||||
|
||||
public List<Variable> getInputByProjectId(Integer projectId) {
|
||||
if (projectId == null || projectId == 0) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return variableRepository.findInputByProject(projectService.getById(projectId));
|
||||
}
|
||||
|
||||
public List<Variable> getOutputByProjectId(Integer projectId) {
|
||||
if (projectId == null || projectId == 0) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return variableRepository.findOutputByProject(projectService.getById(projectId));
|
||||
}
|
||||
}
|
||||
|
@ -7,22 +7,34 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import ru.ulstu.fc.project.service.ProjectRulesService;
|
||||
import ru.ulstu.fc.rule.model.FuzzyRule;
|
||||
import ru.ulstu.fc.rule.model.FuzzyRuleForm;
|
||||
import ru.ulstu.fc.rule.service.FuzzyRuleService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("fuzzyRuleRest")
|
||||
public class FuzzyRuleRestController {
|
||||
private final FuzzyRuleService ruleService;
|
||||
private final ProjectRulesService projectRulesService;
|
||||
|
||||
public FuzzyRuleRestController(FuzzyRuleService ruleService) {
|
||||
public FuzzyRuleRestController(FuzzyRuleService ruleService,
|
||||
ProjectRulesService projectRulesService) {
|
||||
this.ruleService = ruleService;
|
||||
this.projectRulesService = projectRulesService;
|
||||
}
|
||||
|
||||
@GetMapping("/get/{projectId}/{ruleId}")
|
||||
public FuzzyRule get(@PathVariable(value = "projectId") Integer projectId,
|
||||
@PathVariable(value = "ruleId") Integer id) {
|
||||
@GetMapping("/getAll/{projectId}")
|
||||
public List<FuzzyRule> getAll(@PathVariable(value = "projectId") Integer projectId) {
|
||||
//TODO: return dto
|
||||
return projectRulesService.getByProjectId(projectId);
|
||||
}
|
||||
|
||||
@GetMapping("/get/{ruleId}")
|
||||
public FuzzyRule get(@PathVariable(value = "ruleId") Integer id) {
|
||||
//TODO: return dto
|
||||
return ruleService.getById(id);
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import java.util.List;
|
||||
public class VariableDto {
|
||||
private Integer id;
|
||||
private String name;
|
||||
private boolean input;
|
||||
private List<FuzzyTermDto> terms = new ArrayList<>();
|
||||
|
||||
public VariableDto() {
|
||||
@ -17,6 +18,7 @@ public class VariableDto {
|
||||
this.id = variable.getId();
|
||||
this.name = variable.getName();
|
||||
this.terms = variable.getFuzzyTerms().stream().map(FuzzyTermDto::new).toList();
|
||||
this.input = variable.isInput();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@ -42,4 +44,12 @@ public class VariableDto {
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public boolean isInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
public void setInput(boolean input) {
|
||||
this.input = input;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package ru.ulstu.fc.rule.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import ru.ulstu.fc.project.model.Project;
|
||||
import ru.ulstu.fc.rule.model.Variable;
|
||||
|
||||
@ -11,4 +13,10 @@ public interface VariableRepository extends JpaRepository<Variable, Integer> {
|
||||
List<Variable> findByProject(Project project);
|
||||
|
||||
List<Variable> getByProject(Project project);
|
||||
|
||||
@Query("SELECT v FROM Variable v WHERE v.project = :project AND v.input = true")
|
||||
List<Variable> findInputByProject(@Param("project") Project project);
|
||||
|
||||
@Query("SELECT v FROM Variable v WHERE v.project = :project AND v.input = false")
|
||||
List<Variable> findOutputByProject(@Param("project") Project project);
|
||||
}
|
||||
|
@ -11,7 +11,8 @@
|
||||
<script type="text/javascript" src="/webjars/bootstrap-select/1.13.8/js/bootstrap-select.min.js"></script>
|
||||
<link rel="stylesheet" href="/webjars/bootstrap/4.6.0/css/bootstrap.min.css"/>
|
||||
<link rel="stylesheet" href="/webjars/bootstrap-select/1.13.8/css/bootstrap-select.min.css"/>
|
||||
<link rel="stylesheet" href="/webjars/font-awesome/4.7.0/css/font-awesome.min.css"/>
|
||||
<link rel="stylesheet" href="/webjars/bootstrap-icons/1.11.3/font/bootstrap-icons.min.css"/>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -35,7 +35,13 @@
|
||||
<div class="row" th:each="v, iter : ${variables}">
|
||||
<div class="col col-md-12">
|
||||
<a th:href="@{'/variable/edit/' + ${projectId}+'/'+${v.id}}">
|
||||
<span class="badge badge-light" th:text="${iter.index+1} + '. ' + ${v.name}"></span>
|
||||
<h3>
|
||||
<span class="badge badge-light">
|
||||
<span th:text="${iter.index+1} + '. ' + ${v.name}"></span>
|
||||
<i th:if="${v.input}" class="bi bi-box-arrow-in-right"></i>
|
||||
<i th:if="! ${v.input}" class="bi bi-box-arrow-right"></i>
|
||||
</span>
|
||||
</h3>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@ -48,7 +54,7 @@
|
||||
<div class="row" th:each="r, iter : ${rules}">
|
||||
<div class="col col-md-12">
|
||||
<a th:href="@{'/rule/edit/' + ${projectId}+'/'+${r.id}}">
|
||||
<div class="rule row" th:text="${r.content}"></div>
|
||||
<div class="rule row d-none" th:text="${r.content}"></div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@ -70,9 +76,9 @@
|
||||
} else {
|
||||
ruleHtml += "<div class='col col-md-1'></div>";
|
||||
}
|
||||
ruleHtml += "<div class='col col-md-4'><span class='badge badge-primary'>"+getVariable(a)+"</span></div>";
|
||||
ruleHtml += "<div class='col col-md-4'><span class='badge badge-primary'>" + getVariable(a) + "</span></div>";
|
||||
ruleHtml += "<div class='col col-md-3'><span class='badge badge-light'>есть</span></div>";
|
||||
ruleHtml += "<div class='col col-md-4'><span class='badge badge-success'>"+getVariableValue(a)+"</span></div>";
|
||||
ruleHtml += "<div class='col col-md-4'><span class='badge badge-success'>" + getVariableValue(a) + "</span></div>";
|
||||
}
|
||||
ruleHtml += "<div class='col col-md-12'><span class='badge badge-light'>То</span></div>"
|
||||
for (let i = 0; i < consequentComponents.length; i++) {
|
||||
@ -87,11 +93,12 @@
|
||||
ruleHtml += "<div class='col col-md-4'><span class='badge badge-success'>" + getVariableValue(c) + "</span></div>";
|
||||
}
|
||||
$(el).html(ruleHtml);
|
||||
$(el).removeClass('d-none');
|
||||
}
|
||||
$('.rule').each(function(index) {
|
||||
|
||||
$('.rule').each(function (index) {
|
||||
addRule(index, $(this), $(this).text());
|
||||
});
|
||||
|
||||
</script>
|
||||
</div>
|
||||
|
||||
|
@ -7,16 +7,19 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
</head>
|
||||
<div class="container" layout:fragment="content">
|
||||
<a href="/project/edit/0" class="btn btn-outline-dark">
|
||||
<i class="fa fa-plus-square" aria-hidden="true">Добавить проект</i>
|
||||
</a>
|
||||
|
||||
<ul>
|
||||
<li th:each="p : ${projects}">
|
||||
<a th:href="@{'/project/edit/' + ${p.id}}">
|
||||
<span th:text="${p.name} + ' от ' + ${#dates.format(p.createDate, 'dd.MM.yyyy HH:mm')}"></span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="form-group">
|
||||
<a href="/project/edit/0" class="btn btn-outline-dark">
|
||||
<i class="bi bi-plus-square" aria-hidden="true"></i> Добавить проект
|
||||
</a>
|
||||
</div>
|
||||
<div th:each="p : ${projects}">
|
||||
<a th:href="@{'/project/edit/' + ${p.id}}">
|
||||
<h3>
|
||||
<span class="badge badge-light"
|
||||
th:text="${p.name} + ' от ' + ${#dates.format(p.createDate, 'dd.MM.yyyy HH:mm')}">
|
||||
</span>
|
||||
</h3>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</html>
|
||||
|
@ -1,30 +0,0 @@
|
||||
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
|
||||
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
|
||||
<head>
|
||||
<title>Список правил</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
</head>
|
||||
<div class="container" layout:fragment="content">
|
||||
<h3> Список правил</h3>
|
||||
<div class="rowд">
|
||||
<div class="col col-md-12">
|
||||
<span class="badge badge-light">1. Если</span>
|
||||
</div>
|
||||
<div class="col col-md-3">
|
||||
<span class="badge badge-primary">Переменная</span>
|
||||
</div>
|
||||
<div class="col col-md-3">
|
||||
<span class="badge badge-light">есть</span>
|
||||
</div>
|
||||
<div class="col col-md-3">
|
||||
<span class="badge badge-success">значение</span>
|
||||
</div>
|
||||
<div class="col col-md-3">
|
||||
<span class="badge badge-danger">И / ИЛИ</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</html>
|
@ -39,8 +39,10 @@
|
||||
<div class="row" th:each="t, iter : ${fuzzyTerms}">
|
||||
<div class="col col-md-12">
|
||||
<a th:href="@{'/fuzzyTerm/edit/' + ${projectId} + '/' + ${variableId}+'/'+${t.id}}">
|
||||
<span class="badge badge-light"
|
||||
th:text="${iter.index+1} + '. ' + ${t.description}"></span>
|
||||
<h3>
|
||||
<span class="badge badge-light"
|
||||
th:text="${iter.index+1} + '. ' + ${t.description}"></span>
|
||||
</h3>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user