Revize 93fff090
Přidáno uživatelem Vojtěch Danišík před téměř 5 roky(ů)
src/main/java/vldc/aswi/dao/AssemblyRepository.java | ||
---|---|---|
1 | 1 |
package vldc.aswi.dao; |
2 | 2 |
|
3 |
import org.springframework.data.jpa.repository.JpaRepository; |
|
3 | 4 |
import org.springframework.data.repository.CrudRepository; |
4 | 5 |
import org.springframework.stereotype.Repository; |
5 | 6 |
import vldc.aswi.domain.Assembly; |
... | ... | |
16 | 17 |
* @return Assembly if ID is present in database. |
17 | 18 |
*/ |
18 | 19 |
Assembly getById(Long Id); |
20 |
|
|
21 |
// TODO |
|
22 |
Assembly findFirst1ByOrderByAssemblyOrder(); |
|
19 | 23 |
} |
src/main/java/vldc/aswi/dao/parameter/ParameterTypeRepository.java | ||
---|---|---|
16 | 16 |
* @return ParameterType if ID is present in database. |
17 | 17 |
*/ |
18 | 18 |
ParameterType getById(Long Id); |
19 |
|
|
20 |
ParameterType findByName(String name); |
|
19 | 21 |
} |
src/main/java/vldc/aswi/domain/Assembly.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
/** Specific order of assembly in list of assemblies. */ |
29 | 29 |
@Column(name = "poradi") |
30 |
private int order;
|
|
30 |
private int assemblyOrder;
|
|
31 | 31 |
|
32 | 32 |
@Column(name = "verejny") |
33 | 33 |
private int isPublic; |
34 | 34 |
|
35 | 35 |
/** List of configurations, which using this assembly. */ |
36 |
@OneToMany(mappedBy = "assembly") |
|
36 |
@OneToMany(mappedBy = "assembly", cascade = {CascadeType.ALL})
|
|
37 | 37 |
private List<Configuration> configurations; |
38 | 38 |
|
39 | 39 |
/** List of parameters, which using this assembly. */ |
40 |
@OneToMany(mappedBy = "assembly") |
|
40 |
@OneToMany(mappedBy = "assembly", cascade = {CascadeType.ALL})
|
|
41 | 41 |
private List<Parameter> parameters; |
42 | 42 |
|
43 | 43 |
/** |
44 | 44 |
* Creating new table with M:N relationship between Assembly and Role. |
45 | 45 |
* Every assembly can be used by 0 - every role. |
46 | 46 |
*/ |
47 |
@ManyToMany |
|
47 |
@ManyToMany(cascade = {CascadeType.ALL})
|
|
48 | 48 |
@JoinTable( |
49 | 49 |
name = "Sestava_ma_Role", |
50 | 50 |
joinColumns = @JoinColumn(name = "sestava_id"), |
... | ... | |
56 | 56 |
* Constructor. |
57 | 57 |
* @param name - Name of Assembly. |
58 | 58 |
* @param SQLQuery - SQL query which gets data from database. |
59 |
* @param order - Specific order of assembly in list of assemblies.
|
|
59 |
* @param assemblyOrder - Specific order of assembly in list of assemblies.
|
|
60 | 60 |
*/ |
61 |
public Assembly(String name, String SQLQuery, int order, int isPublic) {
|
|
61 |
public Assembly(String name, String SQLQuery, int assemblyOrder, int isPublic) {
|
|
62 | 62 |
this.setName(name); |
63 | 63 |
this.setSQLQuery(SQLQuery); |
64 |
this.setOrder(order);
|
|
64 |
this.setAssemblyOrder(assemblyOrder);
|
|
65 | 65 |
this.setIsPublic(isPublic); |
66 | 66 |
} |
67 |
|
|
68 |
@Override |
|
69 |
public boolean equals(Object obj) { |
|
70 |
return super.equals(obj); |
|
71 |
} |
|
67 | 72 |
} |
src/main/java/vldc/aswi/domain/Configuration.java | ||
---|---|---|
26 | 26 |
private String tableName; |
27 | 27 |
|
28 | 28 |
/** Specific user, which created this configuration. */ |
29 |
@ManyToOne(fetch= FetchType.LAZY) |
|
29 |
@ManyToOne(fetch= FetchType.LAZY, cascade = {CascadeType.ALL})
|
|
30 | 30 |
@JoinColumn(name = "uzivatel_id") |
31 | 31 |
private User user; |
32 | 32 |
|
33 | 33 |
/** Used assembly as template in configuration. */ |
34 |
@ManyToOne(fetch= FetchType.LAZY) |
|
34 |
@ManyToOne(fetch= FetchType.LAZY, cascade = {CascadeType.ALL})
|
|
35 | 35 |
@JoinColumn(name = "sestava_id") |
36 | 36 |
private Assembly assembly; |
37 | 37 |
|
38 | 38 |
/** List of parametersInConfiguration, which is part of this configuration. */ |
39 |
@OneToMany(mappedBy = "configuration") |
|
39 |
@OneToMany(mappedBy = "configuration", cascade = {CascadeType.ALL})
|
|
40 | 40 |
private List<ParameterInConfiguration> parametersInConfiguration; |
41 | 41 |
|
42 | 42 |
/** |
... | ... | |
48 | 48 |
this.setName(name); |
49 | 49 |
this.setTableName(tableName); |
50 | 50 |
} |
51 |
|
|
52 |
@Override |
|
53 |
public boolean equals(Object obj) { |
|
54 |
return super.equals(obj); |
|
55 |
} |
|
51 | 56 |
} |
src/main/java/vldc/aswi/domain/EntityParent.java | ||
---|---|---|
1 | 1 |
package vldc.aswi.domain; |
2 | 2 |
|
3 |
import javax.persistence.GeneratedValue; |
|
4 |
import javax.persistence.GenerationType; |
|
5 |
import javax.persistence.Id; |
|
6 |
import javax.persistence.MappedSuperclass; |
|
3 |
import javax.persistence.*; |
|
7 | 4 |
|
8 | 5 |
import lombok.Data; |
6 |
import org.apache.poi.ss.formula.functions.T; |
|
7 |
import vldc.aswi.domain.parameter.Parameter; |
|
8 |
|
|
9 |
import java.util.LinkedList; |
|
10 |
import java.util.List; |
|
9 | 11 |
|
10 | 12 |
/** |
11 | 13 |
* Class which is extended for all domain entities containing common attributes. |
... | ... | |
16 | 18 |
|
17 | 19 |
/** Specific identificator for every table. */ |
18 | 20 |
@Id |
19 |
@GeneratedValue(strategy = GenerationType.AUTO) |
|
21 |
@Column(name="ID") |
|
22 |
@GeneratedValue(strategy=GenerationType.IDENTITY) |
|
20 | 23 |
private Long id; |
24 |
|
|
25 |
@Override |
|
26 |
public boolean equals(Object obj) |
|
27 |
{ |
|
28 |
if(this == obj) { |
|
29 |
return true; |
|
30 |
} |
|
31 |
|
|
32 |
if(obj == null || obj.getClass()!= this.getClass()) { |
|
33 |
return false; |
|
34 |
} |
|
35 |
|
|
36 |
// type casting of the argument. |
|
37 |
EntityParent parent = (EntityParent) obj; |
|
38 |
|
|
39 |
if (parent.getId() == null) { |
|
40 |
return false; |
|
41 |
} |
|
42 |
|
|
43 |
return (parent.getId() == this.getId()); |
|
44 |
} |
|
21 | 45 |
} |
src/main/java/vldc/aswi/domain/Function.java | ||
---|---|---|
6 | 6 |
import vldc.aswi.domain.parameter.Parameter; |
7 | 7 |
import vldc.aswi.domain.parameter.ParameterInConfiguration; |
8 | 8 |
|
9 |
import javax.persistence.CascadeType; |
|
9 | 10 |
import javax.persistence.Column; |
10 | 11 |
import javax.persistence.Entity; |
11 | 12 |
import javax.persistence.ManyToMany; |
... | ... | |
25 | 26 |
private String name; |
26 | 27 |
|
27 | 28 |
/** List of parameters, which defined that this function can be used. */ |
28 |
@ManyToMany(mappedBy = "functions") |
|
29 |
@ManyToMany(mappedBy = "functions", cascade = {CascadeType.ALL})
|
|
29 | 30 |
private List<Parameter> parameters; |
30 | 31 |
|
31 | 32 |
/** List of parametersInConfigurations, which using this function. */ |
32 |
@ManyToMany(mappedBy = "functions") |
|
33 |
@ManyToMany(mappedBy = "functions", cascade = {CascadeType.ALL})
|
|
33 | 34 |
private List<ParameterInConfiguration> parametersInConfigurations; |
34 | 35 |
|
35 | 36 |
/** |
... | ... | |
39 | 40 |
public Function(String name) { |
40 | 41 |
this.setName(name); |
41 | 42 |
} |
43 |
|
|
44 |
@Override |
|
45 |
public boolean equals(Object obj) { |
|
46 |
return super.equals(obj); |
|
47 |
} |
|
42 | 48 |
} |
src/main/java/vldc/aswi/domain/Location.java | ||
---|---|---|
6 | 6 |
import vldc.aswi.domain.parameter.Parameter; |
7 | 7 |
import vldc.aswi.domain.parameter.ParameterInConfiguration; |
8 | 8 |
|
9 |
import javax.persistence.Column; |
|
10 |
import javax.persistence.Entity; |
|
11 |
import javax.persistence.ManyToMany; |
|
12 |
import javax.persistence.OneToMany; |
|
9 |
import javax.persistence.*; |
|
13 | 10 |
import java.util.List; |
14 | 11 |
|
15 | 12 |
/** |
... | ... | |
26 | 23 |
private String name; |
27 | 24 |
|
28 | 25 |
/** List of parameters which allows this location. */ |
29 |
@ManyToMany(mappedBy = "locations") |
|
26 |
@ManyToMany(mappedBy = "locations", cascade = {CascadeType.ALL})
|
|
30 | 27 |
private List<Parameter> parameters; |
31 | 28 |
|
32 | 29 |
/** List of parametersInConfiguration which using this location. */ |
33 |
@OneToMany(mappedBy = "location") |
|
30 |
@OneToMany(mappedBy = "location", cascade = {CascadeType.ALL})
|
|
34 | 31 |
private List<ParameterInConfiguration> parametersInConfiguration; |
35 | 32 |
|
36 | 33 |
/** |
... | ... | |
40 | 37 |
public Location(String name) { |
41 | 38 |
this.setName(name); |
42 | 39 |
} |
40 |
|
|
41 |
@Override |
|
42 |
public boolean equals(Object obj) { |
|
43 |
return super.equals(obj); |
|
44 |
} |
|
43 | 45 |
} |
src/main/java/vldc/aswi/domain/Operator.java | ||
---|---|---|
6 | 6 |
import vldc.aswi.domain.parameter.Parameter; |
7 | 7 |
import vldc.aswi.domain.parameter.ParameterInConfiguration; |
8 | 8 |
|
9 |
import javax.persistence.Column; |
|
10 |
import javax.persistence.Entity; |
|
11 |
import javax.persistence.ManyToMany; |
|
12 |
import javax.persistence.OneToMany; |
|
9 |
import javax.persistence.*; |
|
13 | 10 |
import java.util.List; |
14 | 11 |
|
15 | 12 |
/** |
... | ... | |
26 | 23 |
private String name; |
27 | 24 |
|
28 | 25 |
/** List of parameters which allowing this operator to be used. */ |
29 |
@ManyToMany(mappedBy = "operators") |
|
26 |
@ManyToMany(mappedBy = "operators", cascade = {CascadeType.ALL})
|
|
30 | 27 |
private List<Parameter> parameters; |
31 | 28 |
|
32 | 29 |
/** List of parametersInConfiguration using this operator. */ |
33 |
@OneToMany(mappedBy = "operator") |
|
30 |
@OneToMany(mappedBy = "operator", cascade = {CascadeType.ALL})
|
|
34 | 31 |
private List<ParameterInConfiguration> parametersInConfiguration; |
35 | 32 |
|
36 | 33 |
/** |
... | ... | |
40 | 37 |
public Operator(String name) { |
41 | 38 |
this.setName(name); |
42 | 39 |
} |
40 |
|
|
41 |
@Override |
|
42 |
public boolean equals(Object obj) { |
|
43 |
return super.equals(obj); |
|
44 |
} |
|
43 | 45 |
} |
src/main/java/vldc/aswi/domain/Role.java | ||
---|---|---|
4 | 4 |
import lombok.EqualsAndHashCode; |
5 | 5 |
import lombok.NoArgsConstructor; |
6 | 6 |
|
7 |
import javax.persistence.Column; |
|
8 |
import javax.persistence.Entity; |
|
9 |
import javax.persistence.ManyToMany; |
|
10 |
import javax.persistence.OneToMany; |
|
7 |
import javax.persistence.*; |
|
11 | 8 |
import java.util.List; |
12 | 9 |
|
13 | 10 |
/** |
... | ... | |
24 | 21 |
private String name; |
25 | 22 |
|
26 | 23 |
/** List of assemblies, which using this role. */ |
27 |
@ManyToMany(mappedBy = "roles") |
|
24 |
@ManyToMany(mappedBy = "roles", cascade = {CascadeType.ALL})
|
|
28 | 25 |
private List<Assembly> assemblies; |
29 | 26 |
|
30 | 27 |
/** List of users with this role. */ |
31 |
@OneToMany(mappedBy = "role") |
|
28 |
@OneToMany(mappedBy = "role", cascade = {CascadeType.ALL})
|
|
32 | 29 |
private List<User> users; |
33 | 30 |
|
34 | 31 |
/** |
... | ... | |
39 | 36 |
this.setName(name); |
40 | 37 |
} |
41 | 38 |
|
39 |
@Override |
|
40 |
public boolean equals(Object obj) { |
|
41 |
return super.equals(obj); |
|
42 |
} |
|
42 | 43 |
} |
src/main/java/vldc/aswi/domain/User.java | ||
---|---|---|
27 | 27 |
private String password; |
28 | 28 |
|
29 | 29 |
/** Role of user. */ |
30 |
@ManyToOne(fetch=FetchType.LAZY) |
|
30 |
@ManyToOne(fetch=FetchType.LAZY, cascade = {CascadeType.ALL})
|
|
31 | 31 |
@JoinColumn(name = "role_id") |
32 | 32 |
private Role role; |
33 | 33 |
|
34 | 34 |
/** List of user configurations. */ |
35 |
@OneToMany(mappedBy = "user") |
|
35 |
@OneToMany(mappedBy = "user", cascade = {CascadeType.ALL})
|
|
36 | 36 |
private List<Configuration> configurations; |
37 | 37 |
|
38 | 38 |
/** |
... | ... | |
44 | 44 |
this.setUsername(username); |
45 | 45 |
this.setPassword(password); |
46 | 46 |
} |
47 |
|
|
48 |
@Override |
|
49 |
public boolean equals(Object obj) { |
|
50 |
return super.equals(obj); |
|
51 |
} |
|
47 | 52 |
} |
src/main/java/vldc/aswi/domain/parameter/Parameter.java | ||
---|---|---|
1 | 1 |
package vldc.aswi.domain.parameter; |
2 | 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; |
|
3 | 7 |
import lombok.Data; |
4 | 8 |
import lombok.EqualsAndHashCode; |
5 | 9 |
import lombok.NoArgsConstructor; |
10 |
import lombok.ToString; |
|
6 | 11 |
import vldc.aswi.domain.*; |
7 | 12 |
import javax.persistence.*; |
8 | 13 |
import java.util.List; |
... | ... | |
25 | 30 |
private String nameOfSelect; |
26 | 31 |
|
27 | 32 |
/** Specific assembly, in which this parameter will be part of. */ |
28 |
@ManyToOne(fetch = FetchType.LAZY) |
|
33 |
@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
|
|
29 | 34 |
@JoinColumn(name = "sestava_id") |
30 | 35 |
private Assembly assembly; |
31 | 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 |
|
|
32 | 42 |
/** Default value of this parameter. */ |
33 | 43 |
@Column(name = "default_hodnota") |
34 | 44 |
private String defaultValue; |
35 | 45 |
|
36 | 46 |
/** List of parametersInConfiguration, which using this parameter. */ |
37 |
@OneToMany(mappedBy = "parameter") |
|
47 |
@OneToMany(mappedBy = "parameter", cascade = {CascadeType.ALL})
|
|
38 | 48 |
private List<ParameterInConfiguration> parametersInConfiguration; |
39 | 49 |
|
40 | 50 |
/** List of parametersInConfiguration, which using this parameter. */ |
41 |
@OneToMany(mappedBy = "parameter") |
|
51 |
@OneToMany(mappedBy = "parameter", cascade = {CascadeType.ALL})
|
|
42 | 52 |
private List<ParameterValue> parameterValues; |
43 | 53 |
|
44 |
/** Specific type of parameter, which represents type of entry. */ |
|
45 |
@ManyToOne(fetch=FetchType.LAZY) |
|
46 |
@JoinColumn(name = "parametr_typ_id") |
|
47 |
private ParameterType parameterType; |
|
48 |
|
|
49 | 54 |
/** |
50 | 55 |
* Creating new table with M:N relationship between Parameter and Location. |
51 | 56 |
* Specify which locations can be used for parameter. |
52 | 57 |
*/ |
53 |
@ManyToMany |
|
58 |
@ManyToMany(cascade = {CascadeType.ALL})
|
|
54 | 59 |
@JoinTable( |
55 | 60 |
name = "Parametr_ma_Umisteni", |
56 | 61 |
joinColumns = @JoinColumn(name = "parametr_id"), |
... | ... | |
62 | 67 |
* Creating new table with M:N relationship between Parameter and Function. |
63 | 68 |
* Specify which functions can be used for parameter. |
64 | 69 |
*/ |
65 |
@ManyToMany |
|
70 |
@ManyToMany(cascade = {CascadeType.ALL})
|
|
66 | 71 |
@JoinTable( |
67 | 72 |
name = "Parametr_ma_Funkce", |
68 | 73 |
joinColumns = @JoinColumn(name = "parametr_id"), |
... | ... | |
74 | 79 |
* Creating new table with M:N relationship between Parameter and Operator. |
75 | 80 |
* Specify which operators can be used for parameter. |
76 | 81 |
*/ |
77 |
@ManyToMany |
|
82 |
@ManyToMany(cascade = {CascadeType.ALL})
|
|
78 | 83 |
@JoinTable( |
79 | 84 |
name = "Parametr_ma_Operator", |
80 | 85 |
joinColumns = @JoinColumn(name = "parametr_id"), |
... | ... | |
93 | 98 |
this.setNameOfSelect(nameOfSelect); |
94 | 99 |
this.setDefaultValue(defaultValue); |
95 | 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 |
} |
|
96 | 111 |
} |
src/main/java/vldc/aswi/domain/parameter/ParameterInConfiguration.java | ||
---|---|---|
17 | 17 |
public class ParameterInConfiguration extends EntityParent { |
18 | 18 |
|
19 | 19 |
/** Specific configuration in which is this parameterConfiguration presented. */ |
20 |
@ManyToOne(fetch = FetchType.LAZY) |
|
20 |
@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
|
|
21 | 21 |
@JoinColumn(name = "konfigurace_id") |
22 | 22 |
private Configuration configuration; |
23 | 23 |
|
24 | 24 |
/** Specific parameter of configuration, which is used as template. */ |
25 |
@ManyToOne(fetch=FetchType.LAZY) |
|
25 |
@ManyToOne(fetch=FetchType.LAZY, cascade = {CascadeType.ALL})
|
|
26 | 26 |
@JoinColumn(name = "parametr_id") |
27 | 27 |
private Parameter parameter; |
28 | 28 |
|
... | ... | |
31 | 31 |
private String operatorValue; |
32 | 32 |
|
33 | 33 |
/** Specific location in which this parameterConfiguration will be used. */ |
34 |
@ManyToOne(fetch=FetchType.LAZY) |
|
34 |
@ManyToOne(fetch=FetchType.LAZY, cascade = {CascadeType.ALL})
|
|
35 | 35 |
@JoinColumn(name = "umisteni_id") |
36 | 36 |
private Location location; |
37 | 37 |
|
... | ... | |
40 | 40 |
private String columnName; |
41 | 41 |
|
42 | 42 |
/** Specific operator which will be aplied onto data. */ |
43 |
@ManyToOne(fetch=FetchType.LAZY) |
|
43 |
@ManyToOne(fetch=FetchType.LAZY, cascade = {CascadeType.ALL})
|
|
44 | 44 |
@JoinColumn(name = "operator_id") |
45 | 45 |
private Operator operator; |
46 | 46 |
|
... | ... | |
48 | 48 |
* Creating new table with M:N relationship between ParameterInConfiguration and Function. |
49 | 49 |
* On every ParameterInConfiguration can be applied 0 - every function. |
50 | 50 |
*/ |
51 |
@ManyToMany |
|
51 |
@ManyToMany(cascade = {CascadeType.ALL})
|
|
52 | 52 |
@JoinTable( |
53 | 53 |
name = "Parametr_konfigurace_ma_Funkce", |
54 | 54 |
joinColumns = @JoinColumn(name = "parametr_konfigurace_id"), |
... | ... | |
65 | 65 |
this.setOperatorValue(operatorValue); |
66 | 66 |
this.setColumnName(columnName); |
67 | 67 |
} |
68 |
|
|
69 |
@Override |
|
70 |
public boolean equals(Object obj) { |
|
71 |
return super.equals(obj); |
|
72 |
} |
|
68 | 73 |
} |
src/main/java/vldc/aswi/domain/parameter/ParameterType.java | ||
---|---|---|
5 | 5 |
import lombok.NoArgsConstructor; |
6 | 6 |
import vldc.aswi.domain.EntityParent; |
7 | 7 |
|
8 |
import javax.persistence.CascadeType; |
|
8 | 9 |
import javax.persistence.Column; |
9 | 10 |
import javax.persistence.Entity; |
10 | 11 |
import javax.persistence.OneToMany; |
... | ... | |
24 | 25 |
private String name; |
25 | 26 |
|
26 | 27 |
/** List of parameterInConfigurations, which using this parameter type. */ |
27 |
@OneToMany(mappedBy = "parameterType") |
|
28 |
@OneToMany(mappedBy = "parameterType", cascade = {CascadeType.ALL})
|
|
28 | 29 |
private List<Parameter> parameters; |
29 | 30 |
|
30 | 31 |
/** |
... | ... | |
34 | 35 |
public ParameterType(String name) { |
35 | 36 |
this.setName(name); |
36 | 37 |
} |
38 |
|
|
39 |
@Override |
|
40 |
public boolean equals(Object obj) { |
|
41 |
return super.equals(obj); |
|
42 |
} |
|
37 | 43 |
} |
src/main/java/vldc/aswi/domain/parameter/ParameterValue.java | ||
---|---|---|
18 | 18 |
public class ParameterValue extends EntityParent { |
19 | 19 |
|
20 | 20 |
/** Specific parameter which can use this value. */ |
21 |
@ManyToOne(fetch = FetchType.LAZY) |
|
21 |
@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
|
|
22 | 22 |
@JoinColumn(name = "parametr_id") |
23 | 23 |
private Parameter parameter; |
24 | 24 |
|
... | ... | |
33 | 33 |
public ParameterValue(String value) { |
34 | 34 |
this.setValue(value); |
35 | 35 |
} |
36 |
|
|
37 |
@Override |
|
38 |
public boolean equals(Object obj) { |
|
39 |
return super.equals(obj); |
|
40 |
} |
|
36 | 41 |
} |
src/main/java/vldc/aswi/service/AssemblyManager.java | ||
---|---|---|
1 | 1 |
package vldc.aswi.service; |
2 | 2 |
|
3 | 3 |
import vldc.aswi.domain.Assembly; |
4 |
import vldc.aswi.domain.Role; |
|
5 |
import vldc.aswi.domain.parameter.Parameter; |
|
4 | 6 |
|
5 | 7 |
import java.util.List; |
6 | 8 |
|
... | ... | |
16 | 18 |
List<Assembly> getAssemblies(); |
17 | 19 |
|
18 | 20 |
Assembly getAssemblyById(Long id); |
21 |
|
|
22 |
Long updateAssembly(Assembly updatedAssemblyValues); |
|
23 |
|
|
24 |
void updateAssemblyOrder(Long id, int order); |
|
25 |
|
|
26 |
Long createAssembly(Assembly assemblyValues); |
|
19 | 27 |
} |
src/main/java/vldc/aswi/service/AssemblyManagerImpl.java | ||
---|---|---|
7 | 7 |
import org.springframework.core.annotation.Order; |
8 | 8 |
import org.springframework.stereotype.Service; |
9 | 9 |
import vldc.aswi.dao.AssemblyRepository; |
10 |
import vldc.aswi.dao.RoleRepository; |
|
10 | 11 |
import vldc.aswi.domain.Assembly; |
12 |
import vldc.aswi.domain.Role; |
|
11 | 13 |
|
12 | 14 |
import javax.transaction.Transactional; |
13 | 15 |
import java.util.LinkedList; |
... | ... | |
21 | 23 |
@Autowired |
22 | 24 |
private AssemblyRepository assemblyRepository; |
23 | 25 |
|
26 |
@Autowired |
|
27 |
private RoleRepository roleRepository; |
|
28 |
|
|
24 | 29 |
/** |
25 | 30 |
* Initialization setup for assembly manager. Check if assembly repository contains |
26 | 31 |
* records and if not, initialize default values. |
... | ... | |
52 | 57 |
public Assembly getAssemblyById(Long id) { |
53 | 58 |
return assemblyRepository.getById(id); |
54 | 59 |
} |
60 |
|
|
61 |
@Override |
|
62 |
public void updateAssemblyOrder(Long id, int order) { |
|
63 |
Assembly assembly = getAssemblyById(id); |
|
64 |
assembly.setAssemblyOrder(order); |
|
65 |
this.assemblyRepository.save(assembly); |
|
66 |
} |
|
67 |
|
|
68 |
@Override |
|
69 |
public Long updateAssembly(Assembly updatedAssemblyValues) { |
|
70 |
// TODO: test it. |
|
71 |
Assembly assembly = getAssemblyById(updatedAssemblyValues.getId()); |
|
72 |
assembly.setName(updatedAssemblyValues.getName()); |
|
73 |
assembly.setSQLQuery(updatedAssemblyValues.getSQLQuery()); |
|
74 |
assembly.setAssemblyOrder(updatedAssemblyValues.getAssemblyOrder()); |
|
75 |
assembly.setIsPublic(updatedAssemblyValues.getIsPublic()); |
|
76 |
this.assemblyRepository.save(assembly); |
|
77 |
|
|
78 |
updateAssemblyRoles(updatedAssemblyValues.getId(), updatedAssemblyValues.getRoles()); |
|
79 |
|
|
80 |
return assembly.getId(); |
|
81 |
} |
|
82 |
|
|
83 |
private void updateAssemblyRoles(Long id, List<Role> updatedRoles) { |
|
84 |
// TODO: test it. |
|
85 |
Assembly assembly = getAssemblyById(id); |
|
86 |
List<Role> currentRoles = assembly.getRoles(); |
|
87 |
|
|
88 |
// Find new roles. |
|
89 |
List<Role> currentRolesNew = new LinkedList<>(currentRoles); |
|
90 |
List<Role> updatedRolesNew = new LinkedList<>(updatedRoles); |
|
91 |
updatedRolesNew.removeAll(currentRolesNew); |
|
92 |
|
|
93 |
// Find deleted roles. |
|
94 |
List<Role> currentRolesDeleted = new LinkedList<>(currentRoles); |
|
95 |
List<Role> updatedRolesDeleted = new LinkedList<>(updatedRoles); |
|
96 |
currentRolesDeleted.removeAll(updatedRolesDeleted); |
|
97 |
|
|
98 |
// If no role has been deleted or added, then updating is unnecessary. |
|
99 |
if (updatedRolesNew.size() == 0 && currentRolesDeleted.size() == 0) return; |
|
100 |
|
|
101 |
// Add new roles and remove deleted roles. |
|
102 |
for (Role newRole : updatedRolesNew) { |
|
103 |
currentRoles.add(this.roleRepository.getById(newRole.getId())); |
|
104 |
} |
|
105 |
currentRoles.removeAll(currentRolesDeleted); |
|
106 |
|
|
107 |
// Save updates to database. |
|
108 |
this.assemblyRepository.save(assembly); |
|
109 |
} |
|
110 |
|
|
111 |
@Override |
|
112 |
public Long createAssembly(Assembly assemblyValues) { |
|
113 |
// TODO: test it. |
|
114 |
Assembly assembly = new Assembly(); |
|
115 |
assembly.setName(assemblyValues.getName()); |
|
116 |
assembly.setSQLQuery(assemblyValues.getSQLQuery()); |
|
117 |
assembly.setAssemblyOrder(this.assemblyRepository.findFirst1ByOrderByAssemblyOrder().getAssemblyOrder() + 1); |
|
118 |
assembly.setIsPublic(assemblyValues.getIsPublic()); |
|
119 |
List<Role> roles = new LinkedList<>(); |
|
120 |
|
|
121 |
if (assemblyValues.getRoles() != null && assemblyValues.getRoles().size() > 0) { |
|
122 |
for (Role newRole : assemblyValues.getRoles()) { |
|
123 |
roles.add(this.roleRepository.getById(newRole.getId())); |
|
124 |
} |
|
125 |
} |
|
126 |
|
|
127 |
assembly.setRoles(roles); |
|
128 |
this.assemblyRepository.save(assembly); |
|
129 |
|
|
130 |
return assembly.getId(); |
|
131 |
} |
|
55 | 132 |
} |
src/main/java/vldc/aswi/service/parameter/ParameterManager.java | ||
---|---|---|
14 | 14 |
* @return List of parameters. |
15 | 15 |
*/ |
16 | 16 |
List<Parameter> getParameters(); |
17 |
|
|
18 |
void addParameters(Long assemblyId, List<Parameter> parameterValuesList); |
|
19 |
|
|
20 |
void updateParameters(Long assemblyId, List<Parameter> newAssemblyParameters); |
|
17 | 21 |
} |
src/main/java/vldc/aswi/service/parameter/ParameterManagerImpl.java | ||
---|---|---|
6 | 6 |
import org.springframework.context.event.EventListener; |
7 | 7 |
import org.springframework.core.annotation.Order; |
8 | 8 |
import org.springframework.stereotype.Service; |
9 |
import vldc.aswi.dao.AssemblyRepository; |
|
10 |
import vldc.aswi.dao.FunctionRepository; |
|
11 |
import vldc.aswi.dao.LocationRepository; |
|
12 |
import vldc.aswi.dao.OperatorRepository; |
|
9 | 13 |
import vldc.aswi.dao.parameter.ParameterRepository; |
14 |
import vldc.aswi.dao.parameter.ParameterTypeRepository; |
|
15 |
import vldc.aswi.dao.parameter.ParameterValueRepository; |
|
16 |
import vldc.aswi.domain.*; |
|
10 | 17 |
import vldc.aswi.domain.parameter.Parameter; |
18 |
import vldc.aswi.domain.parameter.ParameterType; |
|
19 |
import vldc.aswi.domain.parameter.ParameterValue; |
|
20 |
import vldc.aswi.service.FunctionManager; |
|
21 |
import vldc.aswi.service.LocationManager; |
|
22 |
import vldc.aswi.service.OperatorManager; |
|
11 | 23 |
|
12 | 24 |
import javax.transaction.Transactional; |
25 |
import java.util.ArrayList; |
|
13 | 26 |
import java.util.LinkedList; |
14 | 27 |
import java.util.List; |
15 | 28 |
|
... | ... | |
21 | 34 |
@Autowired |
22 | 35 |
private ParameterRepository parameterRepository; |
23 | 36 |
|
37 |
@Autowired |
|
38 |
private AssemblyRepository assemblyRepository; |
|
39 |
|
|
40 |
@Autowired |
|
41 |
private ParameterTypeRepository parameterTypeRepository; |
|
42 |
|
|
43 |
@Autowired |
|
44 |
private LocationRepository locationRepository; |
|
45 |
|
|
46 |
@Autowired |
|
47 |
private FunctionRepository functionRepository; |
|
48 |
|
|
49 |
@Autowired |
|
50 |
private OperatorRepository operatorRepository; |
|
51 |
|
|
52 |
@Autowired |
|
53 |
private ParameterValueRepository parameterValueRepository; |
|
54 |
|
|
24 | 55 |
/** |
25 | 56 |
* Initialization setup for parameter manager. Check if parameter repository contains |
26 | 57 |
* records and if not, initialize default values. |
... | ... | |
47 | 78 |
this.parameterRepository.findAll().forEach(retVal::add); |
48 | 79 |
return retVal; |
49 | 80 |
} |
81 |
|
|
82 |
@Override |
|
83 |
public void addParameters(Long assemblyId, List<Parameter> parameterValuesList) { |
|
84 |
Assembly assembly = this.assemblyRepository.getById(assemblyId); |
|
85 |
// TODO: test it. |
|
86 |
if (parameterValuesList == null) return; |
|
87 |
|
|
88 |
for (Parameter parameterValues : parameterValuesList) { |
|
89 |
Parameter parameter = new Parameter(); |
|
90 |
parameter.setName(parameterValues.getNameOfSelect()); |
|
91 |
parameter.setNameOfSelect(parameterValues.getNameOfSelect()); |
|
92 |
parameter.setAssembly(assembly); |
|
93 |
parameter.setParameterType(this.parameterTypeRepository.findByName(parameterValues.getParameterType().getName())); |
|
94 |
parameter.setDefaultValue(parameterValues.getDefaultValue()); |
|
95 |
|
|
96 |
List<Location> locationList = new LinkedList<>(); |
|
97 |
List<Function> functionList = new LinkedList<>(); |
|
98 |
List<Operator> operatorList = new LinkedList<>(); |
|
99 |
|
|
100 |
if (parameterValues.getLocations() != null && parameterValues.getLocations().size() > 0) { |
|
101 |
for (Location location : parameterValues.getLocations()) { |
|
102 |
locationList.add(this.locationRepository.getById(location.getId())); |
|
103 |
} |
|
104 |
} |
|
105 |
|
|
106 |
if (parameterValues.getFunctions() != null && parameterValues.getFunctions().size() > 0) { |
|
107 |
for (Function function : parameterValues.getFunctions()) { |
|
108 |
functionList.add(this.functionRepository.getById(function.getId())); |
|
109 |
} |
|
110 |
} |
|
111 |
|
|
112 |
if (parameterValues.getOperators() != null && parameterValues.getOperators().size() > 0) { |
|
113 |
for (Operator operator : parameterValues.getOperators()) { |
|
114 |
operatorList.add(this.operatorRepository.getById(operator.getId())); |
|
115 |
} |
|
116 |
} |
|
117 |
|
|
118 |
parameter.setLocations(locationList); |
|
119 |
parameter.setFunctions(functionList); |
|
120 |
parameter.setOperators(operatorList); |
|
121 |
|
|
122 |
this.parameterRepository.save(parameter); |
|
123 |
} |
|
124 |
} |
|
125 |
|
|
126 |
@Override |
|
127 |
public void updateParameters(Long assemblyId, List<Parameter> newAssemblyParameters) { |
|
128 |
// TODO: test it. |
|
129 |
Assembly assembly = this.assemblyRepository.getById(assemblyId); |
|
130 |
List<Parameter> currentAssemblyParameters = assembly.getParameters(); |
|
131 |
|
|
132 |
// Find new parameters; |
|
133 |
List<Parameter> currentAssemblyParametersNew = new LinkedList<>(currentAssemblyParameters); |
|
134 |
List<Parameter> newAssemblyParametersNew = new LinkedList<>(newAssemblyParameters); |
|
135 |
newAssemblyParametersNew.removeAll(currentAssemblyParametersNew); |
|
136 |
|
|
137 |
// Find deleted parameters |
|
138 |
List<Parameter> currentAssemblyParametersDeleted = new LinkedList<>(currentAssemblyParameters); |
|
139 |
List<Parameter> newAssemblyParametersDeleted = new LinkedList<>(newAssemblyParameters); |
|
140 |
currentAssemblyParametersDeleted.removeAll(newAssemblyParametersDeleted); |
|
141 |
|
|
142 |
// Find duplicate elements - for updating. |
|
143 |
List<Parameter> currentAssemblyParametersUpdated = new LinkedList<>(currentAssemblyParameters); |
|
144 |
List<Parameter> newAssemblyParametersUpdated = new LinkedList<>(newAssemblyParameters); |
|
145 |
newAssemblyParametersUpdated.retainAll(currentAssemblyParametersUpdated); |
|
146 |
|
|
147 |
// If no parameter has been deleted or added, then updating is unnecessary. |
|
148 |
if (newAssemblyParametersNew.size() == 0 && currentAssemblyParametersDeleted.size() == 0 && newAssemblyParametersUpdated.size() == currentAssemblyParameters.size()) return; |
|
149 |
|
|
150 |
// Remove deleted parameters. |
|
151 |
for (Parameter parameter : currentAssemblyParametersDeleted) { |
|
152 |
for (ParameterValue parameterValue : parameter.getParameterValues()) { |
|
153 |
this.parameterValueRepository.delete(parameterValue); |
|
154 |
} |
|
155 |
|
|
156 |
this.parameterRepository.delete(parameter); |
|
157 |
} |
|
158 |
|
|
159 |
// Update rest parameters. |
|
160 |
updateParameters(newAssemblyParametersUpdated); |
|
161 |
|
|
162 |
// Add new parameters |
|
163 |
addParameters(assemblyId, newAssemblyParametersNew); |
|
164 |
} |
|
165 |
|
|
166 |
private void updateParameters(List<Parameter> parameterValuesList) { |
|
167 |
// TODO: test it. |
|
168 |
for (Parameter parameterValues : parameterValuesList) { |
|
169 |
Parameter parameter = this.parameterRepository.getById(parameterValues.getId()); |
|
170 |
parameter.setName(parameterValues.getName()); |
|
171 |
parameter.setNameOfSelect(parameterValues.getNameOfSelect()); |
|
172 |
parameter.setAssembly(this.assemblyRepository.getById(parameterValues.getAssembly().getId())); |
|
173 |
parameter.setParameterType(this.parameterTypeRepository.getById(parameterValues.getParameterType().getId())); |
|
174 |
parameter.setDefaultValue(parameterValues.getDefaultValue()); |
|
175 |
this.parameterRepository.save(parameter); |
|
176 |
|
|
177 |
updateParameterValues(parameterValues.getId(), parameterValues.getParameterValues()); |
|
178 |
updateParameterLocations(parameterValues.getId(), parameterValues.getLocations()); |
|
179 |
updateParameterFunctions(parameterValues.getId(), parameterValues.getFunctions()); |
|
180 |
updateParameterOperators(parameterValues.getId(), parameterValues.getOperators()); |
|
181 |
} |
|
182 |
} |
|
183 |
|
|
184 |
private void updateParameterLocations(Long id, List<Location> updatedLocations) { |
|
185 |
// TODO: test it. |
|
186 |
Parameter parameter = this.parameterRepository.getById(id); |
|
187 |
List<Location> currentLocations = parameter.getLocations(); |
|
188 |
|
|
189 |
List<Location> currentLocationsNew = new LinkedList<>(currentLocations); |
|
190 |
List<Location> updatedLocationsNew = new LinkedList<>(updatedLocations); |
|
191 |
updatedLocationsNew.removeAll(currentLocationsNew); |
|
192 |
|
|
193 |
List<Location> currentLocationsDeleted = new LinkedList<>(currentLocations); |
|
194 |
List<Location> updatedLocationsDeleted = new LinkedList<>(updatedLocations); |
|
195 |
currentLocationsDeleted.removeAll(updatedLocationsDeleted); |
|
196 |
|
|
197 |
if (updatedLocationsNew.size() == 0 && currentLocationsDeleted.size() == 0) return; |
|
198 |
|
|
199 |
for (Location newLocation : updatedLocationsNew) { |
|
200 |
currentLocations.add(this.locationRepository.getById(newLocation.getId())); |
|
201 |
} |
|
202 |
currentLocations.removeAll(currentLocationsDeleted); |
|
203 |
|
|
204 |
this.parameterRepository.save(parameter); |
|
205 |
} |
|
206 |
|
|
207 |
private void updateParameterFunctions(Long id, List<Function> updatedFunctions) { |
|
208 |
// TODO: test it. |
|
209 |
Parameter parameter = this.parameterRepository.getById(id); |
|
210 |
List<Function> currentFunctions = parameter.getFunctions(); |
|
211 |
|
|
212 |
List<Function> currentFunctionsNew = new LinkedList<>(currentFunctions); |
|
213 |
List<Function> updatedFunctionsNew = new LinkedList<>(updatedFunctions); |
|
214 |
updatedFunctionsNew.removeAll(currentFunctionsNew); |
|
215 |
|
|
216 |
List<Function> currentFunctionsDeleted = new LinkedList<>(currentFunctions); |
|
217 |
List<Function> updatedFunctionsDeleted = new LinkedList<>(updatedFunctions); |
|
218 |
currentFunctionsDeleted.removeAll(updatedFunctionsDeleted); |
|
219 |
|
|
220 |
if (updatedFunctionsNew.size() == 0 && currentFunctionsDeleted.size() == 0) return; |
|
221 |
|
|
222 |
for (Function newFunction : updatedFunctionsNew) { |
|
223 |
currentFunctions.add(this.functionRepository.getById(newFunction.getId())); |
|
224 |
} |
|
225 |
currentFunctions.removeAll(currentFunctionsDeleted); |
|
226 |
|
|
227 |
this.parameterRepository.save(parameter); |
|
228 |
} |
|
229 |
|
|
230 |
private void updateParameterOperators(Long id, List<Operator> updatedOperators) { |
|
231 |
// TODO: test it. |
|
232 |
Parameter parameter = this.parameterRepository.getById(id); |
|
233 |
List<Operator> currentOperators = parameter.getOperators(); |
|
234 |
|
|
235 |
List<Operator> currentOperatorsNew = new LinkedList<>(currentOperators); |
|
236 |
List<Operator> updatedOperatorsNew = new LinkedList<>(updatedOperators); |
|
237 |
updatedOperatorsNew.removeAll(currentOperatorsNew); |
|
238 |
|
|
239 |
List<Operator> currentOperatorsDeleted = new LinkedList<>(currentOperators); |
|
240 |
List<Operator> updatedOperatorsDeleted = new LinkedList<>(updatedOperators); |
|
241 |
currentOperatorsDeleted.removeAll(updatedOperatorsDeleted); |
|
242 |
|
|
243 |
if (updatedOperatorsNew.size() == 0 && currentOperatorsDeleted.size() == 0) return; |
|
244 |
|
|
245 |
for (Operator newOperator : updatedOperatorsNew) { |
|
246 |
currentOperators.add(this.operatorRepository.getById(newOperator.getId())); |
|
247 |
} |
|
248 |
currentOperators.removeAll(currentOperatorsDeleted); |
|
249 |
|
|
250 |
this.parameterRepository.save(parameter); |
|
251 |
} |
|
252 |
|
|
253 |
private void updateParameterValues(Long parameterId, List<ParameterValue> newParameterValues) { |
|
254 |
// TODO: test it. |
|
255 |
Parameter parameter = this.parameterRepository.getById(parameterId); |
|
256 |
List<ParameterValue> currentParameterValues = parameter.getParameterValues(); |
|
257 |
|
|
258 |
List<ParameterValue> currentParameterValuesNew = new LinkedList<>(currentParameterValues); |
|
259 |
List<ParameterValue> newParameterValuesNew = new LinkedList<>(newParameterValues); |
|
260 |
newParameterValuesNew.removeAll(currentParameterValuesNew); |
|
261 |
|
|
262 |
List<ParameterValue> currentParameterValuesDeleted = new LinkedList<>(currentParameterValues); |
|
263 |
List<ParameterValue> newParameterValuesDeleted = new LinkedList<>(newParameterValues); |
|
264 |
currentParameterValuesDeleted.removeAll(newParameterValuesDeleted); |
|
265 |
|
|
266 |
List<ParameterValue> currentParameterValuesUpdated = new LinkedList<>(currentParameterValues); |
|
267 |
List<ParameterValue> newParameterValuesUpdated = new LinkedList<>(newParameterValues); |
|
268 |
newParameterValuesUpdated.retainAll(currentParameterValuesUpdated); |
|
269 |
|
|
270 |
if (newParameterValuesNew.size() == 0 && currentParameterValuesDeleted.size() == 0 && newParameterValuesUpdated.size() == currentParameterValues.size()) return; |
|
271 |
|
|
272 |
for (ParameterValue parameterValue : currentParameterValuesDeleted) { |
|
273 |
this.parameterValueRepository.delete(parameterValue); |
|
274 |
} |
|
275 |
|
|
276 |
updateParameterValueValues(newParameterValuesUpdated); |
|
277 |
|
|
278 |
addParameterValueValues(parameterId, newParameterValuesNew); |
|
279 |
} |
|
280 |
|
|
281 |
private void updateParameterValueValues(List<ParameterValue> updatedParameterValuesList) { |
|
282 |
// TODO: test it. |
|
283 |
for (ParameterValue parameterValueValues : updatedParameterValuesList) { |
|
284 |
ParameterValue parameterValue = this.parameterValueRepository.getById(parameterValueValues.getId()); |
|
285 |
parameterValue.setValue(parameterValueValues.getValue()); |
|
286 |
|
|
287 |
this.parameterValueRepository.save(parameterValue); |
|
288 |
} |
|
289 |
} |
|
290 |
|
|
291 |
private void addParameterValueValues(Long parameterId, List<ParameterValue> newParameterValuesNew) { |
|
292 |
// TODO: test it. |
|
293 |
Parameter parameter = this.parameterRepository.getById(parameterId); |
|
294 |
|
|
295 |
for (ParameterValue parameterValueValues : newParameterValuesNew) { |
|
296 |
ParameterValue parameterValue = new ParameterValue(); |
|
297 |
parameterValue.setValue(parameterValueValues.getValue()); |
|
298 |
parameterValue.setParameter(parameter); |
|
299 |
|
|
300 |
this.parameterValueRepository.save(parameterValue); |
|
301 |
} |
|
302 |
} |
|
50 | 303 |
} |
src/main/java/vldc/aswi/service/parameter/ParameterValueManager.java | ||
---|---|---|
14 | 14 |
* @return List of parameter values. |
15 | 15 |
*/ |
16 | 16 |
List<ParameterValue> getParameterValues(); |
17 |
|
|
18 |
void createParameterValues(Long parameterId, List<ParameterValue> parameterValues); |
|
19 |
|
|
20 |
void updateParameterValues(Long parameterId, List<ParameterValue> parameterValues); |
|
21 |
|
|
22 |
void addParameterValues(Long parameterId, List<ParameterValue> newParameterValuesNew); |
|
17 | 23 |
} |
src/main/java/vldc/aswi/service/parameter/ParameterValueManagerImpl.java | ||
---|---|---|
6 | 6 |
import org.springframework.context.event.EventListener; |
7 | 7 |
import org.springframework.core.annotation.Order; |
8 | 8 |
import org.springframework.stereotype.Service; |
9 |
import vldc.aswi.dao.parameter.ParameterRepository; |
|
9 | 10 |
import vldc.aswi.dao.parameter.ParameterValueRepository; |
11 |
import vldc.aswi.domain.parameter.Parameter; |
|
10 | 12 |
import vldc.aswi.domain.parameter.ParameterValue; |
11 | 13 |
|
12 | 14 |
import javax.transaction.Transactional; |
... | ... | |
21 | 23 |
@Autowired |
22 | 24 |
private ParameterValueRepository parameterValueRepository; |
23 | 25 |
|
26 |
@Autowired |
|
27 |
private ParameterRepository parameterRepository; |
|
28 |
|
|
24 | 29 |
/** |
25 | 30 |
* Initialization setup for parameter value manager. Check if parameter value repository contains |
26 | 31 |
* records and if not, initialize default values. |
... | ... | |
47 | 52 |
this.parameterValueRepository.findAll().forEach(retVal::add); |
48 | 53 |
return retVal; |
49 | 54 |
} |
55 |
|
|
56 |
|
|
57 |
@Override |
|
58 |
public void createParameterValues(Long parameterId, List<ParameterValue> parameterValues) { |
|
59 |
Parameter parameter = this.parameterRepository.getById(parameterId); |
|
60 |
|
|
61 |
for (ParameterValue newParameterValue : parameterValues) { |
|
62 |
ParameterValue parameterValue = new ParameterValue(); |
|
63 |
parameterValue.setValue(newParameterValue.getValue()); |
|
64 |
parameterValue.setParameter(parameter); |
|
65 |
|
|
66 |
this.parameterValueRepository.save(parameterValue); |
|
67 |
} |
|
68 |
} |
|
69 |
|
|
70 |
@Override |
|
71 |
public void updateParameterValues(Long parameterId, List<ParameterValue> newParameterValues) { |
|
72 |
Parameter parameter = this.parameterRepository.getById(parameterId); |
|
73 |
List<ParameterValue> currentParameterValues = parameter.getParameterValues(); |
|
74 |
|
|
75 |
List<ParameterValue> currentParameterValuesNew = new LinkedList<>(currentParameterValues); |
|
76 |
List<ParameterValue> newParameterValuesNew = new LinkedList<>(newParameterValues); |
|
77 |
newParameterValuesNew.removeAll(currentParameterValuesNew); |
|
78 |
|
|
79 |
List<ParameterValue> currentParameterValuesDeleted = new LinkedList<>(currentParameterValues); |
|
80 |
List<ParameterValue> newParameterValuesDeleted = new LinkedList<>(newParameterValues); |
|
81 |
currentParameterValuesDeleted.removeAll(newParameterValuesDeleted); |
|
82 |
|
|
83 |
List<ParameterValue> currentParameterValuesUpdated = new LinkedList<>(currentParameterValues); |
|
84 |
List<ParameterValue> newParameterValuesUpdated = new LinkedList<>(newParameterValues); |
|
85 |
newParameterValuesUpdated.retainAll(currentParameterValuesUpdated); |
|
86 |
|
|
87 |
if (newParameterValuesNew.size() == 0 && currentParameterValuesDeleted.size() == 0 && newParameterValuesUpdated.size() == currentParameterValues.size()) return; |
|
88 |
|
|
89 |
for (ParameterValue parameterValue : currentParameterValuesDeleted) { |
|
90 |
this.parameterValueRepository.delete(parameterValue); |
|
91 |
} |
|
92 |
|
|
93 |
updateParameterValues(newParameterValuesUpdated); |
|
94 |
|
|
95 |
addParameterValues(parameterId, newParameterValuesNew); |
|
96 |
} |
|
97 |
|
|
98 |
private void updateParameterValues(List<ParameterValue> updatedParameterValuesList) { |
|
99 |
for (ParameterValue parameterValueValues : updatedParameterValuesList) { |
|
100 |
ParameterValue parameterValue = this.parameterValueRepository.getById(parameterValueValues.getId()); |
|
101 |
parameterValue.setValue(parameterValueValues.getValue()); |
|
102 |
|
|
103 |
this.parameterValueRepository.save(parameterValue); |
|
104 |
} |
|
105 |
} |
|
106 |
|
|
107 |
@Override |
|
108 |
public void addParameterValues(Long parameterId, List<ParameterValue> newParameterValuesNew) { |
|
109 |
Parameter parameter = this.parameterRepository.getById(parameterId); |
|
110 |
|
|
111 |
for (ParameterValue parameterValueValues : newParameterValuesNew) { |
|
112 |
ParameterValue parameterValue = new ParameterValue(); |
|
113 |
parameterValue.setValue(parameterValueValues.getValue()); |
|
114 |
parameterValue.setParameter(parameter); |
|
115 |
|
|
116 |
this.parameterValueRepository.save(parameterValue); |
|
117 |
} |
|
118 |
} |
|
119 |
|
|
50 | 120 |
} |
src/main/java/vldc/aswi/web/controller/AssemblyController.java | ||
---|---|---|
1 | 1 |
package vldc.aswi.web.controller; |
2 | 2 |
|
3 |
import oracle.jdbc.proxy.annotation.Post; |
|
4 | 3 |
import org.springframework.beans.factory.annotation.Autowired; |
5 | 4 |
import org.springframework.stereotype.Controller; |
5 |
import org.springframework.ui.Model; |
|
6 | 6 |
import org.springframework.ui.ModelMap; |
7 | 7 |
import org.springframework.validation.BindingResult; |
8 | 8 |
import org.springframework.web.bind.annotation.GetMapping; |
... | ... | |
11 | 11 |
import org.springframework.web.servlet.ModelAndView; |
12 | 12 |
import org.springframework.web.servlet.mvc.support.RedirectAttributes; |
13 | 13 |
import vldc.aswi.domain.Assembly; |
14 |
import vldc.aswi.domain.Role; |
|
14 |
import vldc.aswi.domain.Function; |
|
15 |
import vldc.aswi.domain.Location; |
|
16 |
import vldc.aswi.domain.parameter.Parameter; |
|
15 | 17 |
import vldc.aswi.service.*; |
18 |
import vldc.aswi.service.parameter.ParameterManager; |
|
16 | 19 |
import vldc.aswi.service.parameter.ParameterTypeManager; |
20 |
import vldc.aswi.service.parameter.ParameterValueManager; |
|
17 | 21 |
|
18 | 22 |
import javax.validation.Valid; |
19 |
import java.util.ArrayList; |
|
23 |
import java.beans.PropertyEditorSupport; |
|
24 |
import java.util.LinkedList; |
|
20 | 25 |
import java.util.List; |
21 | 26 |
|
22 | 27 |
@Controller |
... | ... | |
43 | 48 |
@Autowired |
44 | 49 |
private LocationManager locationManager; |
45 | 50 |
|
51 |
@Autowired |
|
52 |
private ParameterManager parameterManager; |
|
53 |
|
|
54 |
@Autowired |
|
55 |
private ParameterValueManager parameterValueManager; |
|
56 |
|
|
46 | 57 |
@GetMapping("/assembly") |
47 | 58 |
public ModelAndView assemblyIndex(@Valid @ModelAttribute("assemblyID") String id) { |
48 | 59 |
ModelAndView modelAndView = new ModelAndView("assembly"); |
49 | 60 |
|
50 | 61 |
ModelMap modelMap = modelAndView.getModelMap(); |
51 | 62 |
|
52 |
Assembly assembly = assemblyManager.getAssemblyById(Long.parseLong(id)); |
|
63 |
Assembly assembly = this.assemblyManager.getAssemblyById(Long.parseLong(id));
|
|
53 | 64 |
|
54 |
modelMap.addAttribute("assemblies", assemblyManager.getAssemblies()); |
|
65 |
modelMap.addAttribute("assemblies", this.assemblyManager.getAssemblies());
|
|
55 | 66 |
modelMap.addAttribute("assembly", assembly); |
56 | 67 |
|
57 | 68 |
return modelAndView; |
... | ... | |
66 | 77 |
|
67 | 78 |
long assemblyID = assembly.getId(); |
68 | 79 |
|
69 |
Assembly assembly2 = assemblyManager.getAssemblyById(assemblyID); |
|
80 |
Assembly assembly2 = this.assemblyManager.getAssemblyById(assemblyID);
|
|
70 | 81 |
|
71 |
modelMap.addAttribute("assemblies", assemblyManager.getAssemblies()); |
|
82 |
modelMap.addAttribute("assemblies", this.assemblyManager.getAssemblies());
|
|
72 | 83 |
modelMap.addAttribute("assembly", assembly2); |
73 |
modelMap.addAttribute("contingencyTableRows", sqlQueryManager.getContingencyTableRow(assembly2.getSQLQuery())); |
|
84 |
modelMap.addAttribute("contingencyTableRows", this.sqlQueryManager.getContingencyTableRow(assembly2.getSQLQuery()));
|
|
74 | 85 |
|
75 | 86 |
return modelAndView; |
76 | 87 |
} |
... | ... | |
81 | 92 |
|
82 | 93 |
ModelMap modelMap = modelAndView.getModelMap(); |
83 | 94 |
|
84 |
Assembly assembly = assemblyManager.getAssemblyById(Long.parseLong(id)); |
|
95 |
Assembly assembly = this.assemblyManager.getAssemblyById(Long.parseLong(id));
|
|
85 | 96 |
|
86 | 97 |
modelMap.addAttribute("assembly", assembly); |
87 |
modelMap.addAttribute("roles", roleManager.getRoles()); |
|
88 |
modelMap.addAttribute("rolesWithAccess", assembly.getRoles()); |
|
89 |
modelMap.addAttribute("parameters", assembly.getParameters()); |
|
90 |
modelMap.addAttribute("parameterTypes", parameterTypeManager.getParameterTypes()); |
|
91 |
modelMap.addAttribute("functions", functionManager.getFunctions()); |
|
92 |
modelMap.addAttribute("operators", operatorManager.getOperators()); |
|
93 |
modelMap.addAttribute("locations", locationManager.getLocations()); |
|
98 |
modelMap.addAttribute("allRoles", this.roleManager.getRoles()); |
|
99 |
modelMap.addAttribute("allParameterTypes", this.parameterTypeManager.getParameterTypes()); |
|
100 |
modelMap.addAttribute("allFunctions", this.functionManager.getFunctions()); |
|
101 |
modelMap.addAttribute("allOperators", this.operatorManager.getOperators()); |
|
102 |
modelMap.addAttribute("allLocations", this.locationManager.getLocations()); |
|
103 |
|
|
104 |
return modelAndView; |
|
105 |
} |
|
106 |
|
|
107 |
@PostMapping("/assembly_edit") |
|
108 |
public ModelAndView assemblyEditPostIndex(@Valid @ModelAttribute("assembly") Assembly assembly, @Valid @ModelAttribute("checkboxPublic") String assemblyIsPublic) { |
|
109 |
|
|
110 |
ModelAndView modelAndView = new ModelAndView("assembly_manage"); |
|
111 |
|
|
112 |
ModelMap modelMap = modelAndView.getModelMap(); |
|
113 |
if (assemblyIsPublic.equals("on")) assembly.setIsPublic(1); |
|
114 |
else assembly.setIsPublic(0); |
|
115 |
|
|
116 |
Long assemblyID = this.assemblyManager.updateAssembly(assembly); |
|
117 |
this.parameterManager.updateParameters(assemblyID, assembly.getParameters()); |
|
118 |
Assembly updatedAssembly = this.assemblyManager.getAssemblyById(assembly.getId()); |
|
119 |
|
|
120 |
// TODO: vyzkoušet jestli se dobře vrací ID parameterType a zda se vypisuje název v selectboxu namísto ID !! |
|
121 |
// TODO: chybí defaultValue. |
|
122 |
|
|
123 |
|
|
124 |
modelMap.addAttribute("assembly", updatedAssembly); |
|
125 |
modelMap.addAttribute("allRoles", this.roleManager.getRoles()); |
|
126 |
modelMap.addAttribute("allParameterTypes", this.parameterTypeManager.getParameterTypes()); |
|
127 |
modelMap.addAttribute("allFunctions", this.functionManager.getFunctions()); |
|
128 |
modelMap.addAttribute("allOperators", this.operatorManager.getOperators()); |
|
129 |
modelMap.addAttribute("allLocations", this.locationManager.getLocations()); |
|
94 | 130 |
|
95 | 131 |
return modelAndView; |
96 | 132 |
} |
... | ... | |
102 | 138 |
ModelMap modelMap = modelAndView.getModelMap(); |
103 | 139 |
|
104 | 140 |
modelMap.addAttribute("assembly", new Assembly()); |
105 |
modelMap.addAttribute("roles", roleManager.getRoles()); |
|
141 |
modelMap.addAttribute("allRoles", this.roleManager.getRoles()); |
|
142 |
modelMap.addAttribute("allParameterTypes", this.parameterTypeManager.getParameterTypes()); |
|
143 |
modelMap.addAttribute("allFunctions", this.functionManager.getFunctions()); |
|
144 |
modelMap.addAttribute("allOperators", this.operatorManager.getOperators()); |
|
145 |
modelMap.addAttribute("allLocations", this.locationManager.getLocations()); |
|
106 | 146 |
|
107 | 147 |
return modelAndView; |
108 | 148 |
} |
109 | 149 |
|
110 | 150 |
@PostMapping("/assembly_new") |
111 |
public ModelAndView assemblyNewIndexPost() { |
|
112 |
ModelAndView modelAndView = new ModelAndView("assembly_manage");
|
|
151 |
public ModelAndView assemblyNewIndexPost(@Valid @ModelAttribute("assembly") Assembly assembly) {
|
|
152 |
ModelAndView modelAndView = new ModelAndView(); |
|
113 | 153 |
|
114 | 154 |
ModelMap modelMap = modelAndView.getModelMap(); |
115 | 155 |
|
116 |
modelMap.addAttribute("assembly", new Assembly());
|
|
117 |
modelMap.addAttribute("roles", roleManager.getRoles());
|
|
156 |
Long assemblyId = this.assemblyManager.createAssembly(assembly);
|
|
157 |
this.parameterManager.addParameters(assemblyId, assembly.getParameters());
|
|
118 | 158 |
|
159 |
modelAndView.setViewName("redirect:/assembly_edit?assemblyID=" + assembly.getId()); |
|
119 | 160 |
return modelAndView; |
120 | 161 |
} |
121 | 162 |
} |
src/main/resources/application.properties | ||
---|---|---|
1 |
# Tell hibernate to use oracle dialect.
|
|
2 |
spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
|
|
1 |
# Tell hibernate to use oracle 12c dialect (allowing to use IDENTITY for ID, ....).
|
|
2 |
spring.jpa.database-platform=org.hibernate.dialect.Oracle12cDialect
|
|
3 | 3 |
|
4 | 4 |
# TNS format of connection to ORACLE 12c database. |
5 | 5 |
oracle.url=jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=atreus-v.zcu.cz)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=DEMO_SERVICE))) |
src/main/webapp/WEB-INF/templates/assembly.html | ||
---|---|---|
24 | 24 |
<main role="main"> |
25 | 25 |
|
26 | 26 |
<div class="container"> |
27 |
<input type=button onclick="history.back()" class="btn btn-success mb-2" value="Zpět">
|
|
27 |
<a href="/" class="btn btn-success mb-2">Zpět</a>
|
|
28 | 28 |
<h1> |
29 | 29 |
Sestava - Studenti - studijní programy |
30 | 30 |
</h1> |
src/main/webapp/WEB-INF/templates/assembly_manage.html | ||
---|---|---|
24 | 24 |
<main role="main"> |
25 | 25 |
|
26 | 26 |
<div class="container"> |
27 |
<input type=button onclick="history.back()" class="btn btn-success mb-2" value="Zpět">
|
|
27 |
<a href="/" class="btn btn-success mb-2">Zpět</a>
|
|
28 | 28 |
<h1> |
29 | 29 |
Editace - Studenti - studijní programy |
30 | 30 |
</h1> |
31 | 31 |
</div> |
32 | 32 |
|
33 |
<form> |
|
33 |
<form th:object="${assembly}" th:action="${assembly.id} != null ? @{/assembly_edit(assemblyID=${assembly.id})} : @{/assembly_new}" method="post"> |
|
34 |
<input type="hidden" th:field="*{id}" th:value="*{id}" /> |
|
34 | 35 |
<div class="container box"> |
35 | 36 |
<div class="col-md-12"> |
36 | 37 |
<div class="form-group row"> |
37 | 38 |
<label for="name" class="col-sm-2 col-form-label">Název sestavy:</label> |
38 | 39 |
<div class="col-sm-10"> |
39 |
<input type="text" class="form-control" id="name" th:value="${assembly.name}">
|
|
40 |
<input type="text" class="form-control" id="name" th:field="*{name}" th:value="*{name}">
|
|
40 | 41 |
</div> |
41 | 42 |
</div> |
42 | 43 |
<div class="form-group row"> |
43 | 44 |
<label for="sql_query" class="col-sm-2 col-form-label">SQL dotaz:</label> |
44 | 45 |
<div class="col-sm-10"> |
45 |
<textarea class="form-control" id="sql_query" rows="6" th:text="${assembly.SQLQuery}"></textarea>
|
|
46 |
<textarea class="form-control" id="sql_query" rows="6" th:field="*{SQLQuery}" th:text="*{SQLQuery}"></textarea>
|
|
46 | 47 |
</div> |
47 | 48 |
</div> |
48 | 49 |
<div class="form-group row"> |
49 | 50 |
<label class="form-check-label col-sm-2" for="checkboxPublic">Veřejný:</label> |
50 | 51 |
<div class="col-sm-10"> |
51 | 52 |
<div class="form-check"> |
52 |
<input class="form-check-input" type="checkbox" value="" th:checked="${assembly.isPublic} == 1" id="checkboxPublic">
|
|
53 |
<input class="form-check-input" type="checkbox" th:checked="*{isPublic} == 1" name="checkboxPublic" id="checkboxPublic">
|
|
53 | 54 |
</div> |
54 | 55 |
</div> |
55 | 56 |
</div> |
... | ... | |
64 | 65 |
<button type="button" class="btn btn-success"><i class="fas fa-plus"></i> Přidat parametr</button> |
65 | 66 |
</div> |
66 | 67 |
|
67 |
<div th:each="parameter : ${parameters}" class="panel-group" id="accordion"> |
|
68 |
<div th:each="parameter, i : *{parameters}" class="panel-group" id="accordion"> |
|
69 |
<input type="hidden" th:field="*{parameters[__${i.index}__]}" th:value="*{parameters[__${i.index}__].id}" /> |
|
68 | 70 |
<div class="panel panel-default"> |
69 | 71 |
<div class="panel-heading"> |
70 | 72 |
<span class="panel-title"> |
71 |
<a data-toggle="collapse" data-parent="#accordion" th:attr="href='#collapse' + ${parameter.id}">
|
|
72 |
<i class="fas fa-angle-right"></i> <span th:text="${parameter.name}"></span>
|
|
73 |
<a data-toggle="collapse" data-parent="#accordion" th:attr="href='#collapse' + *{parameters[__${i.index}__].id}">
|
|
74 |
<i class="fas fa-angle-right"></i> <span th:text="*{parameters[__${i.index}__].name}"></span>
|
|
73 | 75 |
</a> |
74 | 76 |
<span class="align-right collapse-actions"> |
75 | 77 |
<span class="action-padding input-action-margin-collapse sort-icon"> |
... | ... | |
81 | 83 |
</span> |
82 | 84 |
</span> |
83 | 85 |
</div> |
84 |
<div th:id="'collapse' + ${parameter.id}" class="panel-collapse collapse">
|
|
86 |
<div th:id="'collapse' + *{parameters[__${i.index}__].id}" class="panel-collapse collapse">
|
|
85 | 87 |
<div class="panel-body"> |
86 | 88 |
<div class="form-group row"> |
87 | 89 |
<label for="name" class="col-sm-2 col-form-label">Název:</label> |
88 | 90 |
<div class="col-sm-10"> |
89 |
<input type="text" class="form-control" id="name" th:value="${parameter.name}">
|
|
91 |
<input type="text" class="form-control" id="name" th:field="*{parameters[__${i.index}__].name}" th:value="*{parameters[__${i.index}__].name}">
|
|
90 | 92 |
</div> |
91 | 93 |
</div> |
92 | 94 |
<div class="form-group row"> |
93 | 95 |
<label for="name" class="col-sm-2 col-form-label">V SQL:</label> |
94 | 96 |
<div class="col-sm-10"> |
95 |
<input type="text" class="form-control" id="name" th:value="${parameter.nameOfSelect}">
|
|
97 |
<input type="text" class="form-control" id="name" th:field="*{parameters[__${i.index}__].nameOfSelect}" th:value="*{parameters[__${i.index}__].nameOfSelect}">
|
|
96 | 98 |
</div> |
97 | 99 |
</div> |
98 | 100 |
<div class="form-group row"> |
99 | 101 |
<label for="exampleFormControlSelect1" class="col-sm-2">Typ:</label> |
100 | 102 |
<div class="col-sm-10"> |
101 |
<select class="form-control" id="exampleFormControlSelect1"> |
|
102 |
<option th:each="parameterType : ${parameterTypes}" th:value="newParameterType + ${parameterType.name}" th:text="${parameterType.name}"></option>
|
|
103 |
<select th:field="*{parameters[__${i.index}__].parameterType.name}" class="form-control" id="exampleFormControlSelect1">
|
|
104 |
<option th:each="parameterType : ${allParameterTypes}" th:value="${parameterType.id}" th:text="${parameterType.name}"></option>
|
|
103 | 105 |
</select> |
104 | 106 |
</div> |
105 | 107 |
</div> |
106 | 108 |
|
107 |
<div class="enum_box"> |
|
109 |
<div th:if="*{parameters[__${i.index}__].parameterType.name.equals('Výčet')}" class="enum_box">
|
|
108 | 110 |
Hodnoty: |
109 | 111 |
<div class="enum_values col-md-8"> |
110 |
<div class="input-action-box input-border-bottom"> |
|
111 |
<input type="text" readonly class="form-control-plaintext" id="staticEmail" value="Doktorský"> |
|
112 |
|
|
113 |
<span class="action-padding input-action-margin sort-icon"> |
|
114 |
<i class="fas fa-sort"></i> |
|
115 |
</span> |
|
116 |
<span class="action-padding action-button input-action-margin"> |
|
117 |
<a href=# class="action-link far fa-trash-alt"></a> |
|
118 |
</span> |
|
119 |
</div> |
|
120 |
<div class="input-action-box input-border-bottom"> |
|
121 |
<input type="text" readonly class="form-control-plaintext" id="staticEmail" value="Navazující"> |
|
122 |
|
|
123 |
<span class="action-padding input-action-margin sort-icon"> |
|
124 |
<i class="fas fa-sort"></i> |
|
125 |
</span> |
|
126 |
<span class="action-padding action-button input-action-margin"> |
|
127 |
<a href=# class="action-link far fa-trash-alt"></a> |
|
128 |
</span> |
|
129 |
|
|
130 |
</div> |
|
131 |
<div class="input-action-box input-border-bottom"> |
|
132 |
<input type="text" readonly class="form-control-plaintext" id="staticEmail" value="Bakalářský"> |
|
112 |
<div th:each="parameterValue, j : *{parameters[__${i.index}__].parameterValues}" class="input-action-box input-border-bottom"> |
|
113 |
<input type="text" class="form-control-plaintext" th:field="*{parameters[__${i.index}__].parameterValues[__${j.index}__].value}" th:value="*{parameters[__${i.index}__].parameterValues[__${j.index}__].value}"> |
|
133 | 114 |
|
134 | 115 |
<span class="action-padding input-action-margin sort-icon"> |
135 | 116 |
<i class="fas fa-sort"></i> |
... | ... | |
151 | 132 |
<div class="form-group row"> |
152 | 133 |
<label for="exampleFormControlSelect1" class="col-sm-2">Umístění:</label> |
153 | 134 |
<div class="col-sm-10"> |
154 |
<div th:each="location : ${locations}" class="form-check form-check-inline">
|
|
155 |
<input class="form-check-input" type="checkbox" th:id="'checkbox' + ${location.name}" th:value="${location.name}" th:checked="${parameter.locations.contains(location)}">
|
|
156 |
<label class="form-check-label" th:for="checkbox + ${location.name}" th:text="${location.name}"></label>
|
|
135 |
<div th:each="location, j : ${allLocations}" class="form-check form-check-inline">
|
|
136 |
<input class="form-check-input" th:field="*{parameters[__${i.index}__].locations}" type="checkbox" th:value="${location.id}" >
|
|
137 |
<label class="form-check-label" th:for="${location.name}" th:text="${location.name}"></label> |
|
157 | 138 |
</div> |
158 | 139 |
</div> |
159 | 140 |
</div> |
160 | 141 |
<div class="form-group row"> |
161 | 142 |
<label for="exampleFormControlSelect1" class="col-sm-2">Funkce:</label> |
162 | 143 |
<div class="col-sm-10"> |
163 |
<select class="mbSelect selectpicker" multiple data-live-search="true"> |
|
164 |
<option th:each="function : ${functions}" th:value="'selectedFunction' + ${function.name}" th:text="${function.name}" th:selected="${parameter.functions.contains(function)}"></option>
|
|
144 |
<select th:field="*{parameters[__${i.index}__].functions}" class="mbSelect selectpicker" multiple data-live-search="true">
|
|
145 |
<option th:each="function : ${allFunctions}" th:value="${{function.id}}" th:text="${function.name}"></option>
|
|
165 | 146 |
</select> |
166 | 147 |
</div> |
167 | 148 |
</div> |
168 | 149 |
<div class="form-group row"> |
169 | 150 |
<label for="exampleFormControlSelect1" class="col-sm-2">Operátory:</label> |
170 | 151 |
<div class="col-sm-10"> |
171 |
<select class="mbSelect selectpicker" multiple data-live-search="true"> |
|
172 |
<option th:each="operator : ${operators}" th:value="'selectedOperator' + ${operator.name}" th:text="${operator.name}" th:selected="${parameter.operators.contains(operator)}"></option>
|
|
152 |
<select th:field="*{parameters[__${i.index}__].operators}" class="mbSelect selectpicker" multiple data-live-search="true">
|
|
153 |
<option th:each="operator : ${allOperators}" th:value="${{operator.id}}" th:text="${operator.name}"></option>
|
|
173 | 154 |
</select> |
174 | 155 |
</div> |
175 | 156 |
</div> |
... | ... | |
185 | 166 |
<div class="box-header"> |
186 | 167 |
<h3 class="box-title">Oprávnění</h3> |
187 | 168 |
</div> |
188 |
|
|
189 |
<div th:each="roleWithAccess : ${rolesWithAccess}" class="input-action-box input-border-bottom">
|
|
190 |
<input type="text" readonly class="form-control-plaintext" th:id="selectedRole + ${roleWithAccess.name}" th:value="${roleWithAccess.name}"> |
|
169 |
<div th:each="roleWithAccess, i : ${assembly.roles}" class="input-action-box input-border-bottom"> |
|
170 |
<input type="hidden" th:field="${assembly.roles[__${i.index}__].id}" th:value="${roleWithAccess.id}">
|
|
171 |
<input type="text" readonly class="form-control-plaintext" th:field="${assembly.roles[__${i.index}__].name}" th:id="selectedRole + ${roleWithAccess.name}" th:value="${roleWithAccess.name}">
|
|
191 | 172 |
|
192 | 173 |
<span class="action-padding input-action-margin sort-icon"> |
193 | 174 |
<i class="fas fa-sort"></i> |
... | ... | |
200 | 181 |
<div class="form-group row form-add-item"> |
201 | 182 |
<div class="col-md-9"> |
202 | 183 |
<select class="form-control " id="selectNewRole"> |
203 |
<option th:each="role : ${roles}" th:value="newRole + ${role.name}" th:text="${role.name}"></option>
|
|
184 |
<option th:each="role : ${allRoles}" th:value="${role.id}" th:text="${role.name}"></option>
|
|
204 | 185 |
</select> |
205 | 186 |
</div> |
206 | 187 |
<button type="submit" class="btn btn-primary mb-2">Přidat</button> |
Také k dispozici: Unified diff
re #7886 Adding + Editing parameters in assembly (only logic + pushing into database, which is not tested -> need JS implementation for adding new parameter).
Updated hibernate dialect from oracle 10 to oracle 12c.
Equals method comparing domain by id.