WIP: страницы для правил #62
@ -23,7 +23,9 @@ public class RuleController {
|
|||||||
private final AntecedentValueService antecedentValueService;
|
private final AntecedentValueService antecedentValueService;
|
||||||
private final TimeSeriesService timeSeriesService;
|
private final TimeSeriesService timeSeriesService;
|
||||||
|
|
||||||
public RuleController(RuleService ruleService, AntecedentValueService antecedentValueService, TimeSeriesService timeSeriesService) {
|
public RuleController(RuleService ruleService,
|
||||||
|
AntecedentValueService antecedentValueService,
|
||||||
|
TimeSeriesService timeSeriesService) {
|
||||||
this.ruleService = ruleService;
|
this.ruleService = ruleService;
|
||||||
this.antecedentValueService = antecedentValueService;
|
this.antecedentValueService = antecedentValueService;
|
||||||
this.timeSeriesService = timeSeriesService;
|
this.timeSeriesService = timeSeriesService;
|
||||||
@ -38,7 +40,7 @@ public class RuleController {
|
|||||||
@GetMapping(ADD_RULE)
|
@GetMapping(ADD_RULE)
|
||||||
public String getAntecedent(Model model) {
|
public String getAntecedent(Model model) {
|
||||||
model.addAttribute("antecedentValues", antecedentValueService.getList());
|
model.addAttribute("antecedentValues", antecedentValueService.getList());
|
||||||
model.addAttribute("antecedents", timeSeriesService.getAllTimeSeries());
|
model.addAttribute("antecedents", timeSeriesService.getAllTimeSeriesTypes());
|
||||||
model.addAttribute("addRuleForm", new AddRuleForm());
|
model.addAttribute("addRuleForm", new AddRuleForm());
|
||||||
return ADD_RULE;
|
return ADD_RULE;
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@ package ru.ulstu.extractor.rule.model;
|
|||||||
|
|
||||||
public class AddRuleForm {
|
public class AddRuleForm {
|
||||||
private Integer firstAntecedentValueId;
|
private Integer firstAntecedentValueId;
|
||||||
private Integer firstAntecedentId;
|
private String firstAntecedentId;
|
||||||
private Integer secondAntecedentValueId;
|
private Integer secondAntecedentValueId;
|
||||||
private Integer secondAntecedentId;
|
private String secondAntecedentId;
|
||||||
private String consequent;
|
private String consequent;
|
||||||
|
|
||||||
public AddRuleForm() {
|
public AddRuleForm() {
|
||||||
@ -18,11 +18,11 @@ public class AddRuleForm {
|
|||||||
this.firstAntecedentValueId = firstAntecedentValueId;
|
this.firstAntecedentValueId = firstAntecedentValueId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getFirstAntecedentId() {
|
public String getFirstAntecedentId() {
|
||||||
return firstAntecedentId;
|
return firstAntecedentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFirstAntecedentId(Integer firstAntecedentId) {
|
public void setFirstAntecedentId(String firstAntecedentId) {
|
||||||
this.firstAntecedentId = firstAntecedentId;
|
this.firstAntecedentId = firstAntecedentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,11 +34,11 @@ public class AddRuleForm {
|
|||||||
this.secondAntecedentValueId = secondAntecedentValueId;
|
this.secondAntecedentValueId = secondAntecedentValueId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getSecondAntecedentId() {
|
public String getSecondAntecedentId() {
|
||||||
return secondAntecedentId;
|
return secondAntecedentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSecondAntecedentId(Integer secondAntecedentId) {
|
public void setSecondAntecedentId(String secondAntecedentId) {
|
||||||
this.secondAntecedentId = secondAntecedentId;
|
this.secondAntecedentId = secondAntecedentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package ru.ulstu.extractor.rule.model;
|
package ru.ulstu.extractor.rule.model;
|
||||||
|
|
||||||
import ru.ulstu.extractor.core.BaseEntity;
|
import ru.ulstu.extractor.core.BaseEntity;
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeries;
|
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EnumType;
|
||||||
|
import javax.persistence.Enumerated;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@ -11,14 +13,14 @@ public class Rule extends BaseEntity {
|
|||||||
@ManyToOne
|
@ManyToOne
|
||||||
private AntecedentValue firstAntecedentValue;
|
private AntecedentValue firstAntecedentValue;
|
||||||
|
|
||||||
@ManyToOne
|
@Enumerated(EnumType.STRING)
|
||||||
private TimeSeries firstAntecedent;
|
private TimeSeriesType firstAntecedent;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private AntecedentValue secondAntecedentValue;
|
private AntecedentValue secondAntecedentValue;
|
||||||
|
|
||||||
@ManyToOne
|
@Enumerated(EnumType.STRING)
|
||||||
private TimeSeries secondAntecedent;
|
private TimeSeriesType secondAntecedent;
|
||||||
|
|
||||||
private String consequent;
|
private String consequent;
|
||||||
|
|
||||||
@ -26,9 +28,9 @@ public class Rule extends BaseEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Rule(AntecedentValue firstAntecedentValue,
|
public Rule(AntecedentValue firstAntecedentValue,
|
||||||
TimeSeries firstAntecedent,
|
TimeSeriesType firstAntecedent,
|
||||||
AntecedentValue secondAntecedentValue,
|
AntecedentValue secondAntecedentValue,
|
||||||
TimeSeries secondAntecedent,
|
TimeSeriesType secondAntecedent,
|
||||||
String consequent) {
|
String consequent) {
|
||||||
this.firstAntecedentValue = firstAntecedentValue;
|
this.firstAntecedentValue = firstAntecedentValue;
|
||||||
this.firstAntecedent = firstAntecedent;
|
this.firstAntecedent = firstAntecedent;
|
||||||
@ -37,21 +39,6 @@ public class Rule extends BaseEntity {
|
|||||||
this.consequent = consequent;
|
this.consequent = consequent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rule(Integer id,
|
|
||||||
Integer version,
|
|
||||||
AntecedentValue firstAntecedentValue,
|
|
||||||
TimeSeries firstAntecedent,
|
|
||||||
AntecedentValue secondAntecedentValue,
|
|
||||||
TimeSeries secondAntecedent,
|
|
||||||
String consequent) {
|
|
||||||
super(id, version);
|
|
||||||
this.firstAntecedentValue = firstAntecedentValue;
|
|
||||||
this.firstAntecedent = firstAntecedent;
|
|
||||||
this.secondAntecedentValue = secondAntecedentValue;
|
|
||||||
this.secondAntecedent = secondAntecedent;
|
|
||||||
this.consequent = consequent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AntecedentValue getFirstAntecedentValue() {
|
public AntecedentValue getFirstAntecedentValue() {
|
||||||
return firstAntecedentValue;
|
return firstAntecedentValue;
|
||||||
}
|
}
|
||||||
@ -60,11 +47,11 @@ public class Rule extends BaseEntity {
|
|||||||
this.firstAntecedentValue = firstAntecedentValue;
|
this.firstAntecedentValue = firstAntecedentValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeSeries getFirstAntecedent() {
|
public TimeSeriesType getFirstAntecedent() {
|
||||||
return firstAntecedent;
|
return firstAntecedent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFirstAntecedent(TimeSeries firstAntecedent) {
|
public void setFirstAntecedent(TimeSeriesType firstAntecedent) {
|
||||||
this.firstAntecedent = firstAntecedent;
|
this.firstAntecedent = firstAntecedent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,11 +63,11 @@ public class Rule extends BaseEntity {
|
|||||||
this.secondAntecedentValue = secondAntecedentValue;
|
this.secondAntecedentValue = secondAntecedentValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeSeries getSecondAntecedent() {
|
public TimeSeriesType getSecondAntecedent() {
|
||||||
return secondAntecedent;
|
return secondAntecedent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSecondAntecedent(TimeSeries secondAntecedent) {
|
public void setSecondAntecedent(TimeSeriesType secondAntecedent) {
|
||||||
this.secondAntecedent = secondAntecedent;
|
this.secondAntecedent = secondAntecedent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import ru.ulstu.extractor.rule.model.AddRuleForm;
|
import ru.ulstu.extractor.rule.model.AddRuleForm;
|
||||||
import ru.ulstu.extractor.rule.model.Rule;
|
import ru.ulstu.extractor.rule.model.Rule;
|
||||||
import ru.ulstu.extractor.rule.repository.RuleRepository;
|
import ru.ulstu.extractor.rule.repository.RuleRepository;
|
||||||
|
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
||||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -28,9 +29,9 @@ public class RuleService {
|
|||||||
|
|
||||||
public void saveRule(AddRuleForm addRuleForm) {
|
public void saveRule(AddRuleForm addRuleForm) {
|
||||||
ruleRepository.save(new Rule(antecedentValueService.getById(addRuleForm.getFirstAntecedentValueId()),
|
ruleRepository.save(new Rule(antecedentValueService.getById(addRuleForm.getFirstAntecedentValueId()),
|
||||||
timeSeriesService.getById(addRuleForm.getFirstAntecedentId()),
|
TimeSeriesType.valueOf(addRuleForm.getFirstAntecedentId()),
|
||||||
antecedentValueService.getById(addRuleForm.getSecondAntecedentValueId()),
|
antecedentValueService.getById(addRuleForm.getSecondAntecedentValueId()),
|
||||||
timeSeriesService.getById(addRuleForm.getSecondAntecedentId()),
|
TimeSeriesType.valueOf(addRuleForm.getSecondAntecedentId()),
|
||||||
addRuleForm.getConsequent()));
|
addRuleForm.getConsequent()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import ru.ulstu.extractor.ts.util.TimeSeriesDateMapper;
|
|||||||
|
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@ -102,4 +103,8 @@ public class TimeSeriesService {
|
|||||||
return timeSeriesRepository.findById(tsId)
|
return timeSeriesRepository.findById(tsId)
|
||||||
.orElseThrow(() -> new RuntimeException("Time series not found by id " + tsId));
|
.orElseThrow(() -> new RuntimeException("Time series not found by id " + tsId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<TimeSeriesType> getAllTimeSeriesTypes() {
|
||||||
|
return Arrays.asList(TimeSeriesType.values());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,4 +49,35 @@
|
|||||||
<column name="time_series_type" type="varchar(100)"></column>
|
<column name="time_series_type" type="varchar(100)"></column>
|
||||||
</addColumn>
|
</addColumn>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
<changeSet author="orion" id="20221012-170000-3">
|
||||||
|
<dropForeignKeyConstraint baseTableName="rule" constraintName="fk_first_time_series"/>
|
||||||
|
<dropForeignKeyConstraint baseTableName="rule" constraintName="fk_second_antecedent_value"/>
|
||||||
|
<delete tableName="rule"/>
|
||||||
|
<dropColumn tableName="rule" columnName="first_antecedent_id"/>
|
||||||
|
<dropColumn tableName="rule" columnName="second_antecedent_id"/>
|
||||||
|
<addColumn tableName="rule">
|
||||||
|
<column name="first_antecedent" type="varchar(100)"/>
|
||||||
|
</addColumn>
|
||||||
|
<addColumn tableName="rule">
|
||||||
|
<column name="second_antecedent" type="varchar(100)"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
<changeSet author="orion" id="20221012-170000-4">
|
||||||
|
<delete tableName="antecedent_value"/>
|
||||||
|
<insert tableName="antecedent_value">
|
||||||
|
<column name="id" value="1"/>
|
||||||
|
<column name="version" value="0"/>
|
||||||
|
<column name="antecedent_value" value="спад"/>
|
||||||
|
</insert>
|
||||||
|
<insert tableName="antecedent_value">
|
||||||
|
<column name="id" value="2"/>
|
||||||
|
<column name="version" value="0"/>
|
||||||
|
<column name="antecedent_value" value="стабильно"/>
|
||||||
|
</insert>
|
||||||
|
<insert tableName="antecedent_value">
|
||||||
|
<column name="id" value="3"/>
|
||||||
|
<column name="version" value="0"/>
|
||||||
|
<column name="antecedent_value" value="рост"/>
|
||||||
|
</insert>
|
||||||
|
</changeSet>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
@ -12,6 +12,19 @@
|
|||||||
<div class="col-md-2 col-sm-12">
|
<div class="col-md-2 col-sm-12">
|
||||||
Если
|
Если
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md-6 col-sm-12">
|
||||||
|
<select id="select-antecedent" class="selectpicker" data-live-search="true"
|
||||||
|
th:field="*{firstAntecedentId}"
|
||||||
|
data-width="90%">
|
||||||
|
<option th:each="antecedent : ${antecedents}"
|
||||||
|
th:value="${antecedent}"
|
||||||
|
th:utext="${antecedent.description}">
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2 col-sm-12">
|
||||||
|
имеет тенденцию
|
||||||
|
</div>
|
||||||
<div class="col-md-2 col-sm-12">
|
<div class="col-md-2 col-sm-12">
|
||||||
<select id="select-measures" class="selectpicker" data-live-search="true"
|
<select id="select-measures" class="selectpicker" data-live-search="true"
|
||||||
th:field="*{firstAntecedentValueId}"
|
th:field="*{firstAntecedentValueId}"
|
||||||
@ -23,20 +36,20 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2 col-sm-12">
|
<div class="col-md-2 col-sm-12">
|
||||||
временной ряд
|
и
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6 col-sm-12">
|
<div class="col-md-6 col-sm-12">
|
||||||
<select id="select-antecedent" class="selectpicker" data-live-search="true"
|
<select id="select-second-antecedent" class="selectpicker" data-live-search="true"
|
||||||
th:field="*{firstAntecedentId}"
|
th:field="*{secondAntecedentId}"
|
||||||
data-width="90%">
|
data-width="90%">
|
||||||
<option th:each="antecedent : ${antecedents}"
|
<option th:each="antecedent : ${antecedents}"
|
||||||
th:value="${antecedent.id}"
|
th:value="${antecedent}"
|
||||||
th:utext="${antecedent.name}">
|
th:utext="${antecedent.description}">
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2 col-sm-12">
|
<div class="col-md-2 col-sm-12">
|
||||||
и
|
имеет тенденцию
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2 col-sm-12">
|
<div class="col-md-2 col-sm-12">
|
||||||
<select id="select-second-measures" class="selectpicker" data-live-search="true"
|
<select id="select-second-measures" class="selectpicker" data-live-search="true"
|
||||||
@ -48,26 +61,16 @@
|
|||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2 col-sm-12">
|
|
||||||
временной ряд
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6 col-sm-12">
|
|
||||||
<select id="select-second-antecedent" class="selectpicker" data-live-search="true"
|
|
||||||
th:field="*{secondAntecedentId}"
|
|
||||||
data-width="90%">
|
|
||||||
<option th:each="antecedent : ${antecedents}"
|
|
||||||
th:value="${antecedent.id}"
|
|
||||||
th:utext="${antecedent.name}">
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-2 col-sm-12">
|
<div class="col-md-2 col-sm-12">
|
||||||
то:
|
то:
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2 col-sm-12">
|
<div class="col-md-6 col-sm-12">
|
||||||
<input type="text" class="form-control" th:field="*{consequent}">
|
<input type="text" class="form-control" th:field="*{consequent}">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-8 col-sm-12">
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4 col-sm-12"></div>
|
||||||
|
<div class="col-md-4 col-sm-12">
|
||||||
<input type="submit" class="btn btn-outline-success" value="Создать правило"/>
|
<input type="submit" class="btn btn-outline-success" value="Создать правило"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr th:each="rule: ${rules}">
|
<tr th:each="rule: ${rules}">
|
||||||
<td><span class="badge badge-info">Если</span></td>
|
<td><span class="badge badge-info">Если</span></td>
|
||||||
<td><span class="badge badge-success" th:text="${rule.firstAntecedent.name}"></span></td>
|
<td><span class="badge badge-success" th:text="${rule.firstAntecedent.description}"></span></td>
|
||||||
<td><span class="badge badge-success" th:text="${rule.firstAntecedentValue.antecedentValue}"></span></td>
|
<td><span class="badge badge-success" th:text="${rule.firstAntecedentValue.antecedentValue}"></span></td>
|
||||||
<td><span class="badge badge-info">и</span></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.secondAntecedent.description }"></span></td>
|
||||||
<td><span class="badge badge-success" th:text="${rule.secondAntecedentValue.antecedentValue}"></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-info">то</span></td>
|
||||||
<td><span class="badge badge-warning" th:text="${rule.consequent}"></span></td>
|
<td><span class="badge badge-warning" th:text="${rule.consequent}"></span></td>
|
||||||
|
Loading…
Reference in New Issue
Block a user