1
|
package vldc.aswi.domain.parameter;
|
2
|
|
3
|
import com.fasterxml.jackson.annotation.JsonBackReference;
|
4
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
5
|
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
6
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
7
|
import lombok.Data;
|
8
|
import lombok.EqualsAndHashCode;
|
9
|
import lombok.NoArgsConstructor;
|
10
|
import lombok.ToString;
|
11
|
import vldc.aswi.domain.*;
|
12
|
import javax.persistence.*;
|
13
|
import java.util.List;
|
14
|
|
15
|
/**
|
16
|
* Domain entity representing Parameter in application.
|
17
|
*/
|
18
|
@Entity(name = "Parametr")
|
19
|
@Data
|
20
|
@EqualsAndHashCode(callSuper = true)
|
21
|
@NoArgsConstructor
|
22
|
public class Parameter extends EntityParent {
|
23
|
|
24
|
/** Name of parameter in SQL query. */
|
25
|
@Column(name = "nazev")
|
26
|
private String name;
|
27
|
|
28
|
/** Admin-defined name of parameter, which will be used in assembly. */
|
29
|
@Column(name = "nazev_select")
|
30
|
private String nameOfSelect;
|
31
|
|
32
|
/** Specific assembly, in which this parameter will be part of. */
|
33
|
@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
|
34
|
@JoinColumn(name = "sestava_id")
|
35
|
private Assembly assembly;
|
36
|
|
37
|
/** Specific type of parameter, which represents type of entry. */
|
38
|
@ManyToOne(fetch=FetchType.LAZY, cascade = {CascadeType.ALL})
|
39
|
@JoinColumn(name = "parametr_typ_id")
|
40
|
private ParameterType parameterType;
|
41
|
|
42
|
/** Default value of this parameter. */
|
43
|
@Column(name = "default_hodnota")
|
44
|
private String defaultValue;
|
45
|
|
46
|
/** List of parametersInConfiguration, which using this parameter. */
|
47
|
@OneToMany(mappedBy = "parameter", cascade = {CascadeType.ALL})
|
48
|
private List<ParameterInConfiguration> parametersInConfiguration;
|
49
|
|
50
|
/** List of parametersInConfiguration, which using this parameter. */
|
51
|
@OneToMany(mappedBy = "parameter", cascade = {CascadeType.ALL})
|
52
|
private List<ParameterValue> parameterValues;
|
53
|
|
54
|
/**
|
55
|
* Creating new table with M:N relationship between Parameter and Location.
|
56
|
* Specify which locations can be used for parameter.
|
57
|
*/
|
58
|
@ManyToMany(cascade = {CascadeType.ALL})
|
59
|
@JoinTable(
|
60
|
name = "Parametr_ma_Umisteni",
|
61
|
joinColumns = @JoinColumn(name = "parametr_id"),
|
62
|
inverseJoinColumns = @JoinColumn(name = "umisteni_id")
|
63
|
)
|
64
|
private List<Location> locations;
|
65
|
|
66
|
/**
|
67
|
* Creating new table with M:N relationship between Parameter and Function.
|
68
|
* Specify which functions can be used for parameter.
|
69
|
*/
|
70
|
@ManyToMany(cascade = {CascadeType.ALL})
|
71
|
@JoinTable(
|
72
|
name = "Parametr_ma_Funkce",
|
73
|
joinColumns = @JoinColumn(name = "parametr_id"),
|
74
|
inverseJoinColumns = @JoinColumn(name = "funkce_id")
|
75
|
)
|
76
|
private List<Function> functions;
|
77
|
|
78
|
/**
|
79
|
* Creating new table with M:N relationship between Parameter and Operator.
|
80
|
* Specify which operators can be used for parameter.
|
81
|
*/
|
82
|
@ManyToMany(cascade = {CascadeType.ALL})
|
83
|
@JoinTable(
|
84
|
name = "Parametr_ma_Operator",
|
85
|
joinColumns = @JoinColumn(name = "parametr_id"),
|
86
|
inverseJoinColumns = @JoinColumn(name = "operator_id")
|
87
|
)
|
88
|
private List<Operator> operators;
|
89
|
|
90
|
/**
|
91
|
* Constructor.
|
92
|
* @param name - Name of parameter in SQL query.
|
93
|
* @param nameOfSelect - Admin-defined name of parameter, which will be used in assembly.
|
94
|
* @param defaultValue - Default value of this parameter.
|
95
|
*/
|
96
|
public Parameter(String name, String nameOfSelect, String defaultValue) {
|
97
|
this.setName(name);
|
98
|
this.setNameOfSelect(nameOfSelect);
|
99
|
this.setDefaultValue(defaultValue);
|
100
|
}
|
101
|
|
102
|
@Override
|
103
|
public String toString() {
|
104
|
return "Parameter[name=" + name + ", nameOfSelect=" + nameOfSelect + ", defaultHodnota=" + defaultValue + "]";
|
105
|
}
|
106
|
|
107
|
@Override
|
108
|
public boolean equals(Object obj) {
|
109
|
return super.equals(obj);
|
110
|
}
|
111
|
}
|