Временные ряды #59
39
src/main/java/ru/ulstu/extractor/model/TimeSeries.java
Normal file
39
src/main/java/ru/ulstu/extractor/model/TimeSeries.java
Normal file
@ -0,0 +1,39 @@
|
||||
package ru.ulstu.extractor.model;
|
||||
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
public class TimeSeries extends BaseEntity {
|
||||
private String name;
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "time_series_id")
|
||||
@Fetch(FetchMode.SUBSELECT)
|
||||
private List<TimeSeriesValue> values = new ArrayList<>();
|
||||
|
||||
|
||||
public TimeSeries(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<TimeSeriesValue> getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setValues(List<TimeSeriesValue> values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
}
|
43
src/main/java/ru/ulstu/extractor/model/TimeSeriesValue.java
Normal file
43
src/main/java/ru/ulstu/extractor/model/TimeSeriesValue.java
Normal file
@ -0,0 +1,43 @@
|
||||
package ru.ulstu.extractor.model;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.ManyToOne;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
public class TimeSeriesValue extends BaseEntity {
|
||||
private Date date;
|
||||
private Integer value;
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
private TimeSeries timeSeries;
|
||||
|
||||
public TimeSeriesValue(Date date, Integer value) {
|
||||
this.date = date;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public void setValue(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public TimeSeries getTimeSeriesType() {
|
||||
return timeSeries;
|
||||
}
|
||||
|
||||
public void setTimeSeriesType(TimeSeries timeSeries) {
|
||||
this.timeSeries = timeSeries;
|
||||
}
|
||||
}
|
44
src/main/resources/db/changelog-20220422_120000-schema.xml
Normal file
44
src/main/resources/db/changelog-20220422_120000-schema.xml
Normal file
@ -0,0 +1,44 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||
<changeSet author="orion" id="20220422-120000-1">
|
||||
<createTable tableName="time_series">
|
||||
<column name="id" type="integer">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="name" type="varchar(255)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
</createTable>
|
||||
<addPrimaryKey columnNames="id" constraintName="pk_time_series" tableName="time_series"/>
|
||||
|
||||
<createTable tableName="time_series_value">
|
||||
<column name="id" type="integer">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="time_series_id" type="integer">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="date" type="timestamp">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="value" type="integer">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
</createTable>
|
||||
<addPrimaryKey columnNames="id" constraintName="pk_time_series_value" tableName="time_series_value"/>
|
||||
<addForeignKeyConstraint baseTableName="time_series_value" baseColumnNames="time_series_id"
|
||||
constraintName="fk_time_series"
|
||||
referencedTableName="time_series"
|
||||
referencedColumnNames="id"/>
|
||||
</changeSet>
|
||||
<changeSet author="orion" id="20220422-120000-2">
|
||||
<addColumn tableName="time_series">
|
||||
<column name="version" type="integer"/>
|
||||
</addColumn>
|
||||
<addColumn tableName="time_series_value">
|
||||
<column name="version" type="integer"/>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -12,4 +12,5 @@
|
||||
<include file="db/changelog-20210326_170000-schema.xml"/>
|
||||
<include file="db/changelog-20210329_120000-schema.xml"/>
|
||||
<include file="db/changelog-20210412_100000-schema.xml"/>
|
||||
<include file="db/changelog-20220422_120000-schema.xml"/>
|
||||
</databaseChangeLog>
|
||||
|
Loading…
Reference in New Issue
Block a user