ts types #73
@ -23,7 +23,9 @@ public class RuleController {
|
||||
private final AntecedentValueService antecedentValueService;
|
||||
private final TimeSeriesService timeSeriesService;
|
||||
|
||||
public RuleController(RuleService ruleService, AntecedentValueService antecedentValueService, TimeSeriesService timeSeriesService) {
|
||||
public RuleController(RuleService ruleService,
|
||||
AntecedentValueService antecedentValueService,
|
||||
TimeSeriesService timeSeriesService) {
|
||||
this.ruleService = ruleService;
|
||||
this.antecedentValueService = antecedentValueService;
|
||||
this.timeSeriesService = timeSeriesService;
|
||||
@ -38,7 +40,7 @@ public class RuleController {
|
||||
@GetMapping(ADD_RULE)
|
||||
public String getAntecedent(Model model) {
|
||||
model.addAttribute("antecedentValues", antecedentValueService.getList());
|
||||
model.addAttribute("antecedents", timeSeriesService.getAllTimeSeries());
|
||||
model.addAttribute("antecedents", timeSeriesService.getAllTimeSeriesTypes());
|
||||
model.addAttribute("addRuleForm", new AddRuleForm());
|
||||
return ADD_RULE;
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ package ru.ulstu.extractor.rule.model;
|
||||
|
||||
public class AddRuleForm {
|
||||
private Integer firstAntecedentValueId;
|
||||
private Integer firstAntecedentId;
|
||||
private String firstAntecedentId;
|
||||
private Integer secondAntecedentValueId;
|
||||
private Integer secondAntecedentId;
|
||||
private String secondAntecedentId;
|
||||
private String consequent;
|
||||
|
||||
public AddRuleForm() {
|
||||
@ -18,11 +18,11 @@ public class AddRuleForm {
|
||||
this.firstAntecedentValueId = firstAntecedentValueId;
|
||||
}
|
||||
|
||||
public Integer getFirstAntecedentId() {
|
||||
public String getFirstAntecedentId() {
|
||||
return firstAntecedentId;
|
||||
}
|
||||
|
||||
public void setFirstAntecedentId(Integer firstAntecedentId) {
|
||||
public void setFirstAntecedentId(String firstAntecedentId) {
|
||||
this.firstAntecedentId = firstAntecedentId;
|
||||
}
|
||||
|
||||
@ -34,11 +34,11 @@ public class AddRuleForm {
|
||||
this.secondAntecedentValueId = secondAntecedentValueId;
|
||||
}
|
||||
|
||||
public Integer getSecondAntecedentId() {
|
||||
public String getSecondAntecedentId() {
|
||||
return secondAntecedentId;
|
||||
}
|
||||
|
||||
public void setSecondAntecedentId(Integer secondAntecedentId) {
|
||||
public void setSecondAntecedentId(String secondAntecedentId) {
|
||||
this.secondAntecedentId = secondAntecedentId;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
package ru.ulstu.extractor.rule.model;
|
||||
|
||||
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.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
@ -11,14 +13,14 @@ public class Rule extends BaseEntity {
|
||||
@ManyToOne
|
||||
private AntecedentValue firstAntecedentValue;
|
||||
|
||||
@ManyToOne
|
||||
private TimeSeries firstAntecedent;
|
||||
@Enumerated(EnumType.STRING)
|
||||
private TimeSeriesType firstAntecedent;
|
||||
|
||||
@ManyToOne
|
||||
private AntecedentValue secondAntecedentValue;
|
||||
|
||||
@ManyToOne
|
||||
private TimeSeries secondAntecedent;
|
||||
@Enumerated(EnumType.STRING)
|
||||
private TimeSeriesType secondAntecedent;
|
||||
|
||||
private String consequent;
|
||||
|
||||
@ -26,9 +28,9 @@ public class Rule extends BaseEntity {
|
||||
}
|
||||
|
||||
public Rule(AntecedentValue firstAntecedentValue,
|
||||
TimeSeries firstAntecedent,
|
||||
TimeSeriesType firstAntecedent,
|
||||
AntecedentValue secondAntecedentValue,
|
||||
TimeSeries secondAntecedent,
|
||||
TimeSeriesType secondAntecedent,
|
||||
String consequent) {
|
||||
this.firstAntecedentValue = firstAntecedentValue;
|
||||
this.firstAntecedent = firstAntecedent;
|
||||
@ -37,21 +39,6 @@ public class Rule extends BaseEntity {
|
||||
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() {
|
||||
return firstAntecedentValue;
|
||||
}
|
||||
@ -60,11 +47,11 @@ public class Rule extends BaseEntity {
|
||||
this.firstAntecedentValue = firstAntecedentValue;
|
||||
}
|
||||
|
||||
public TimeSeries getFirstAntecedent() {
|
||||
public TimeSeriesType getFirstAntecedent() {
|
||||
return firstAntecedent;
|
||||
}
|
||||
|
||||
public void setFirstAntecedent(TimeSeries firstAntecedent) {
|
||||
public void setFirstAntecedent(TimeSeriesType firstAntecedent) {
|
||||
this.firstAntecedent = firstAntecedent;
|
||||
}
|
||||
|
||||
@ -76,11 +63,11 @@ public class Rule extends BaseEntity {
|
||||
this.secondAntecedentValue = secondAntecedentValue;
|
||||
}
|
||||
|
||||
public TimeSeries getSecondAntecedent() {
|
||||
public TimeSeriesType getSecondAntecedent() {
|
||||
return secondAntecedent;
|
||||
}
|
||||
|
||||
public void setSecondAntecedent(TimeSeries secondAntecedent) {
|
||||
public void setSecondAntecedent(TimeSeriesType 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.Rule;
|
||||
import ru.ulstu.extractor.rule.repository.RuleRepository;
|
||||
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
||||
|
||||
import java.util.List;
|
||||
@ -28,9 +29,9 @@ public class RuleService {
|
||||
|
||||
public void saveRule(AddRuleForm addRuleForm) {
|
||||
ruleRepository.save(new Rule(antecedentValueService.getById(addRuleForm.getFirstAntecedentValueId()),
|
||||
timeSeriesService.getById(addRuleForm.getFirstAntecedentId()),
|
||||
TimeSeriesType.valueOf(addRuleForm.getFirstAntecedentId()),
|
||||
antecedentValueService.getById(addRuleForm.getSecondAntecedentValueId()),
|
||||
timeSeriesService.getById(addRuleForm.getSecondAntecedentId()),
|
||||
TimeSeriesType.valueOf(addRuleForm.getSecondAntecedentId()),
|
||||
addRuleForm.getConsequent()));
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import ru.ulstu.extractor.ts.util.TimeSeriesDateMapper;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -102,4 +103,8 @@ public class TimeSeriesService {
|
||||
return timeSeriesRepository.findById(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>
|
||||
</addColumn>
|
||||
</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>
|
@ -12,6 +12,19 @@
|
||||
<div class="col-md-2 col-sm-12">
|
||||
Если
|
||||
</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">
|
||||
<select id="select-measures" class="selectpicker" data-live-search="true"
|
||||
th:field="*{firstAntecedentValueId}"
|
||||
@ -23,20 +36,20 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2 col-sm-12">
|
||||
временной ряд
|
||||
и
|
||||
</div>
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<select id="select-antecedent" class="selectpicker" data-live-search="true"
|
||||
th:field="*{firstAntecedentId}"
|
||||
<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}">
|
||||
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">
|
||||
<select id="select-second-measures" class="selectpicker" data-live-search="true"
|
||||
@ -48,26 +61,16 @@
|
||||
</option>
|
||||
</select>
|
||||
</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>
|
||||
<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}">
|
||||
</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="Создать правило"/>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -16,10 +16,10 @@
|
||||
<tbody>
|
||||
<tr th:each="rule: ${rules}">
|
||||
<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-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-info">то</span></td>
|
||||
<td><span class="badge badge-warning" th:text="${rule.consequent}"></span></td>
|
||||
|
Loading…
Reference in New Issue
Block a user