1
1
package org .cgiar .ccafs .csa .domain ;
2
2
3
- import org .apache .commons .lang3 .StringUtils ;
4
3
import org .joda .time .LocalDate ;
5
4
import org .springframework .format .annotation .DateTimeFormat ;
6
5
11
10
import java .util .Date ;
12
11
import java .util .List ;
13
12
13
+ import static org .cgiar .ccafs .csa .domain .AbstractInformationEntity .joiner ;
14
14
import static org .springframework .format .annotation .DateTimeFormat .ISO .DATE ;
15
15
16
16
@@ -31,27 +31,23 @@ public class ExperimentArticle implements Serializable {
31
31
32
32
private String code ;
33
33
34
- @ Column (length = 100000 )
34
+ @ Column (length = 100000 )
35
35
private String title ;
36
36
37
- @ Column (length = 100000 )
37
+ @ Column (length = 100000 )
38
38
private String outline ;
39
39
40
40
private String link ;
41
41
42
42
private Integer rating ;
43
43
44
- @ ManyToOne
45
- @ JoinColumn (name = "farming_system_id" )
46
- private FarmingSystem farmingSystem ;
47
-
48
- @ Column (length =100000 )
44
+ @ Column (length = 100000 )
49
45
private String authors ;
50
46
51
47
@ Transient
52
48
private List <String > authorsList = new ArrayList <>();
53
49
54
- @ Column (length = 100000 )
50
+ @ Column (length = 100000 )
55
51
private String contacts ;
56
52
57
53
@ Transient
@@ -68,14 +64,7 @@ public class ExperimentArticle implements Serializable {
68
64
69
65
@ ManyToOne
70
66
@ JoinColumn (name = "theme_id" )
71
- private PracticeTheme practiceTheme ;
72
-
73
- @ ManyToOne
74
- @ JoinColumn (name = "location_id" )
75
- private Location location ;
76
-
77
- @ OneToMany (mappedBy = "experimentArticle" , fetch = FetchType .EAGER )
78
- private List <InitialCondition > initialConditions = new ArrayList <>();
67
+ private PracticeTheme theme ;
79
68
80
69
@ ManyToMany (fetch = FetchType .EAGER )
81
70
@ JoinTable (
@@ -89,8 +78,8 @@ public class ExperimentArticle implements Serializable {
89
78
)
90
79
private List <ContextValue > contextValues = new ArrayList <>();
91
80
92
- @ OneToMany (mappedBy = "experimentArticle " , fetch = FetchType .EAGER )
93
- private List <Treatment > treatments ;
81
+ @ OneToMany (mappedBy = "experiment " , fetch = FetchType .EAGER )
82
+ private List <ExperimentContext > contexts = new ArrayList <>() ;
94
83
95
84
// Methods //
96
85
@@ -122,43 +111,20 @@ public void setOutline(String outline) {
122
111
this .outline = outline ;
123
112
}
124
113
125
- public Integer getRating () {
126
- return this .rating ;
127
- }
128
-
129
- public void setRating (Integer rating ) {
130
- this .rating = rating ;
131
- }
132
-
133
- public FarmingSystem getFarmingSystem () {
134
- return farmingSystem ;
135
- }
136
-
137
- public void setFarmingSystem (FarmingSystem farmingSystem ) {
138
- this .farmingSystem = farmingSystem ;
114
+ public String getLink () {
115
+ return link ;
139
116
}
140
117
141
- public List <Treatment > getTreatments () {
142
- if (treatments == null ) {
143
- treatments = new ArrayList <>();
144
- }
145
- return treatments ;
118
+ public void setLink (String link ) {
119
+ this .link = link ;
146
120
}
147
121
148
- public void setTreatments (List <Treatment > treatments ) {
149
- this .treatments = treatments ;
150
- }
151
-
152
- public Treatment addTreatment (Treatment treatment ) {
153
- getTreatments ().add (treatment );
154
- treatment .setExperiment (this );
155
- return treatment ;
122
+ public Integer getRating () {
123
+ return this .rating ;
156
124
}
157
125
158
- public Treatment removeTreatment (Treatment treatment ) {
159
- getTreatments ().remove (treatment );
160
- treatment .setExperiment (null );
161
- return treatment ;
126
+ public void setRating (Integer rating ) {
127
+ this .rating = rating ;
162
128
}
163
129
164
130
public List <String > getAuthorsList () {
@@ -173,30 +139,38 @@ public List<String> getContactsList() {
173
139
return this .contactsList ;
174
140
}
175
141
176
- public void addContact (String author ) {
177
- getContactsList ().add (author );
142
+ public void addContact (String contactEmail ) {
143
+ getContactsList ().add (contactEmail );
178
144
}
179
145
180
146
@ PrePersist
181
147
@ PreUpdate
182
148
protected void recordSaved () {
183
- authors = StringUtils .join (getAuthorsList (), ";" );
184
- contacts = StringUtils .join (getAuthorsList (), ";" );
149
+ authors = joiner .join (getAuthorsList ());
150
+ contacts = joiner .join (getContactsList () );
185
151
}
186
152
187
153
@ PostLoad
188
154
protected void recordLoaded () {
189
- if (authors != null && authors .trim ().length () = = 0 ) {
155
+ if (authors != null && authors .trim ().length () ! = 0 ) {
190
156
String [] data = authors .split (";" );
191
157
authorsList = Arrays .asList (data );
192
158
}
193
159
194
- if (contacts != null && contacts .trim ().length () = = 0 ) {
160
+ if (contacts != null && contacts .trim ().length () ! = 0 ) {
195
161
String [] data = contacts .split (";" );
196
162
contactsList = Arrays .asList (data );
197
163
}
198
164
}
199
165
166
+ public Language getLanguage () {
167
+ return language ;
168
+ }
169
+
170
+ public void setLanguage (Language language ) {
171
+ this .language = language ;
172
+ }
173
+
200
174
public LocalDate getPublicationDate () {
201
175
return new LocalDate (this .publicationDate );
202
176
}
@@ -205,40 +179,40 @@ public void setPublicationDate(LocalDate publicationDate) {
205
179
this .publicationDate = publicationDate .toDate ();
206
180
}
207
181
208
- public PracticeTheme getPracticeTheme () {
209
- return practiceTheme ;
182
+ public PracticeTheme getTheme () {
183
+ return theme ;
210
184
}
211
185
212
- public void setPracticeTheme (PracticeTheme practiceTheme ) {
213
- this .practiceTheme = practiceTheme ;
186
+ public void setTheme (PracticeTheme theme ) {
187
+ this .theme = theme ;
214
188
}
215
189
216
- public Location getLocation () {
217
- return this .location ;
190
+ public List < ContextValue > getContextValues () {
191
+ return this .contextValues ;
218
192
}
219
193
220
- public void setLocation (Location location ) {
221
- this .location = location ;
194
+ public ContextValue setContextVariable (ContextValue contextValue ) {
195
+ if (contextValue != null ) getContextValues ().add (contextValue );
196
+ return contextValue ;
222
197
}
223
198
224
- public List < ContextValue > getContextValues ( ) {
225
- return this . contextValues ;
199
+ public boolean unsetContextVariable ( ContextValue contextValue ) {
200
+ return getContextValues (). remove ( contextValue ) ;
226
201
}
227
202
228
- public List <InitialCondition > getInitialConditions () {
229
- return this . initialConditions ;
203
+ public List <ExperimentContext > getContexts () {
204
+ return contexts ;
230
205
}
231
206
232
- public InitialCondition addInitialCondition ( InitialCondition initialCondition ) {
233
- getInitialConditions ().add (initialCondition );
234
- initialCondition .setExperiment (this );
235
- return initialCondition ;
207
+ public ExperimentContext addContext ( ExperimentContext context ) {
208
+ getContexts ().add (context );
209
+ context .setExperiment (this );
210
+ return context ;
236
211
}
237
212
238
- public InitialCondition removeInitialCondition ( InitialCondition initialCondition ) {
239
- getInitialConditions ().remove (initialCondition );
240
- initialCondition .setExperiment (null );
241
- return initialCondition ;
213
+ public ExperimentContext removeExperimentContext ( ExperimentContext context ) {
214
+ getContexts ().remove (context );
215
+ context .setExperiment (null );
216
+ return context ;
242
217
}
243
-
244
218
}
0 commit comments