1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.student.lum.lo.dao.impl; |
17 |
|
|
18 |
|
import java.util.List; |
19 |
|
|
20 |
|
import javax.persistence.EntityManager; |
21 |
|
import javax.persistence.PersistenceContext; |
22 |
|
import javax.persistence.Query; |
23 |
|
|
24 |
|
import org.kuali.student.common.dao.impl.AbstractSearchableCrudDaoImpl; |
25 |
|
import org.kuali.student.common.exceptions.DependentObjectsExistException; |
26 |
|
import org.kuali.student.common.exceptions.DoesNotExistException; |
27 |
|
import org.kuali.student.common.exceptions.UnsupportedActionException; |
28 |
|
import org.kuali.student.lum.lo.dao.LoDao; |
29 |
|
import org.kuali.student.lum.lo.entity.Lo; |
30 |
|
import org.kuali.student.lum.lo.entity.LoCategory; |
31 |
|
import org.kuali.student.lum.lo.entity.LoLoCategoryJoin; |
32 |
|
import org.kuali.student.lum.lo.entity.LoLoRelation; |
33 |
|
|
34 |
|
|
35 |
|
@author |
36 |
|
|
37 |
|
|
|
|
| 0% |
Uncovered Elements: 92 (92) |
Complexity: 21 |
Complexity Density: 0.3 |
|
38 |
|
public class LoDaoImpl extends AbstractSearchableCrudDaoImpl implements LoDao { |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
39 |
0
|
@PersistenceContext(unitName = "Lo")... |
40 |
|
@Override |
41 |
|
public void setEm(EntityManager em) { |
42 |
0
|
super.setEm(em); |
43 |
|
} |
44 |
|
|
45 |
|
|
46 |
|
@see |
47 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 2 |
Complexity Density: 0.18 |
|
48 |
0
|
@Override... |
49 |
|
public boolean addLoCategoryToLo(String loCategoryId, String loId) throws UnsupportedActionException, DoesNotExistException { |
50 |
0
|
Lo lo = fetch(Lo.class, loId); |
51 |
0
|
LoCategory loCategory = fetch(LoCategory.class, loCategoryId); |
52 |
0
|
String loRepoId = lo.getLoRepository().getId(); |
53 |
0
|
String loCategoryRepoId = loCategory.getLoRepository().getId(); |
54 |
|
|
55 |
0
|
if ( ! loRepoId.equals(loCategoryRepoId) ) { |
56 |
0
|
throw new UnsupportedActionException("The learning objective category is not associated with the learning objective's repository"); |
57 |
|
} |
58 |
0
|
LoLoCategoryJoin join = new LoLoCategoryJoin(); |
59 |
0
|
join.setLo(lo); |
60 |
0
|
join.setLoCategory(loCategory); |
61 |
0
|
create(join); |
62 |
0
|
return true; |
63 |
|
} |
64 |
|
|
65 |
|
|
66 |
|
@see |
67 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
68 |
0
|
@Override... |
69 |
|
public boolean removeLoCategoryFromLo(String loCategoryId, String loId) throws DoesNotExistException { |
70 |
0
|
Query query = em.createNamedQuery("Lo.getLoCategoryJoin"); |
71 |
0
|
query.setParameter("loCategoryId", loCategoryId); |
72 |
0
|
query.setParameter("loId", loId); |
73 |
0
|
LoLoCategoryJoin join = (LoLoCategoryJoin) query.getSingleResult(); |
74 |
0
|
delete(join); |
75 |
0
|
return true; |
76 |
|
} |
77 |
|
|
78 |
|
|
79 |
|
@see |
80 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
81 |
0
|
@Override... |
82 |
|
public List<Lo> getLoByIdList(List<String> loIds) { |
83 |
0
|
Query query = em.createNamedQuery("Lo.findLosByIdList"); |
84 |
0
|
query.setParameter("idList", loIds); |
85 |
0
|
@SuppressWarnings("unchecked") |
86 |
|
List<Lo> resultList = query.getResultList(); |
87 |
0
|
return resultList; |
88 |
|
} |
89 |
|
|
90 |
|
|
91 |
|
@see |
92 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
93 |
0
|
@Override... |
94 |
|
public boolean deleteLo(String loId) throws DoesNotExistException, DependentObjectsExistException { |
95 |
|
|
96 |
0
|
if ( ! getIncludedLos(loId).isEmpty() ) { |
97 |
0
|
throw new DependentObjectsExistException("Lo(" + |
98 |
|
loId+ |
99 |
|
") cannot be deleted without orphaning child Lo(s)."); |
100 |
|
} |
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
0
|
delete(Lo.class, loId); |
109 |
0
|
return true; |
110 |
|
} |
111 |
|
|
112 |
|
|
113 |
|
@see |
114 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
115 |
0
|
private List<Lo> getIncludedLos(String loId) throws DoesNotExistException {... |
116 |
0
|
return getRelatedLosByLoId(loId, "kuali.lo.relation.type.includes"); |
117 |
|
} |
118 |
|
|
119 |
|
|
120 |
|
@see |
121 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
122 |
0
|
private List<Lo> getIncludingLos(String loId) throws DoesNotExistException {... |
123 |
0
|
return getLosByRelatedLoId(loId, "kuali.lo.relation.type.includes"); |
124 |
|
} |
125 |
|
|
126 |
|
|
127 |
|
@see |
128 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
129 |
0
|
@Override... |
130 |
|
public List<Lo> getLosByLoCategory(String loCategoryId) { |
131 |
0
|
Query query = em.createNamedQuery("Lo.getLosByLoCategory"); |
132 |
0
|
query.setParameter("loCategoryId", loCategoryId); |
133 |
0
|
@SuppressWarnings("unchecked") |
134 |
|
List<Lo> resultList = query.getResultList(); |
135 |
0
|
return resultList; |
136 |
|
} |
137 |
|
|
138 |
|
|
139 |
|
@see |
140 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
141 |
0
|
@Override... |
142 |
|
public List<LoCategory> getLoCategories(String loRepositoryKey) { |
143 |
0
|
Query query = em.createNamedQuery("Lo.getLoCategories"); |
144 |
0
|
query.setParameter("repositoryId", loRepositoryKey); |
145 |
0
|
@SuppressWarnings("unchecked") |
146 |
|
List<LoCategory> resultList = query.getResultList(); |
147 |
0
|
return resultList; |
148 |
|
} |
149 |
|
|
150 |
|
|
151 |
|
@see |
152 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
153 |
0
|
@Override... |
154 |
|
public boolean deleteLoCategory(String loCategoryId) throws DoesNotExistException, DependentObjectsExistException { |
155 |
0
|
List<Lo> los = getLosByLoCategory(loCategoryId); |
156 |
0
|
if (null != los && !los.isEmpty()) { |
157 |
0
|
throw new DependentObjectsExistException("LoCategory(" + loCategoryId + ") still has " + los.size() + " Learning Objective(s) associated with it."); |
158 |
|
} |
159 |
0
|
delete(LoCategory.class, loCategoryId); |
160 |
0
|
return true; |
161 |
|
} |
162 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
163 |
0
|
@Override... |
164 |
|
public List<Lo> getRelatedLosByLoId(String loId, String loLoRelationTypeId) |
165 |
|
throws DoesNotExistException { |
166 |
0
|
Query query = em.createNamedQuery("Lo.getRelatedLosByLoId"); |
167 |
0
|
query.setParameter("loId", loId); |
168 |
0
|
query.setParameter("loLoRelationTypeId", loLoRelationTypeId); |
169 |
0
|
@SuppressWarnings("unchecked") |
170 |
|
List<Lo> resultList = query.getResultList(); |
171 |
0
|
return resultList; |
172 |
|
} |
173 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
174 |
0
|
@Override... |
175 |
|
public List<Lo> getLosByRelatedLoId(String relatedLoId, |
176 |
|
String loLoRelationTypeId) throws DoesNotExistException { |
177 |
0
|
Query query = em.createNamedQuery("Lo.getLosByRelatedLoId"); |
178 |
0
|
query.setParameter("relatedLoId", relatedLoId); |
179 |
0
|
query.setParameter("loLoRelationTypeId", loLoRelationTypeId); |
180 |
0
|
@SuppressWarnings("unchecked") |
181 |
|
List<Lo> resultList = query.getResultList(); |
182 |
0
|
return resultList; |
183 |
|
} |
184 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
185 |
0
|
@Override... |
186 |
|
public void deleteLoLoRelation(String loLoRelationId) throws DoesNotExistException { |
187 |
|
|
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
0
|
delete(LoLoRelation.class, loLoRelationId); |
197 |
|
} |
198 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
199 |
0
|
@Override... |
200 |
|
public List<LoCategory> getLoCategoriesForLo(String loId) { |
201 |
0
|
Query query = em.createNamedQuery("Lo.getLoCategoriesForLo"); |
202 |
0
|
query.setParameter("loId", loId); |
203 |
|
|
204 |
0
|
List<LoCategory> resultList = query.getResultList(); |
205 |
0
|
return resultList; |
206 |
|
} |
207 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
208 |
0
|
@Override... |
209 |
|
public List<String> getAllowedLoLoRelationTypesForLoType(String loTypeKey, String relatedLoTypeKey) { |
210 |
0
|
Query query = em.createNamedQuery("Lo.getAllowedLoLoRelationTypes"); |
211 |
0
|
query.setParameter("loTypeKey", loTypeKey); |
212 |
0
|
query.setParameter("relatedLoTypeKey", relatedLoTypeKey); |
213 |
0
|
@SuppressWarnings("unchecked") |
214 |
|
List<String> resultList = query.getResultList(); |
215 |
0
|
return resultList; |
216 |
|
} |
217 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
218 |
0
|
@Override... |
219 |
|
public List<Lo> getLosByRepository(String loRepositoryId) { |
220 |
0
|
Query query = em.createNamedQuery("Lo.getLosByRepository"); |
221 |
0
|
query.setParameter("loRepositoryId", loRepositoryId); |
222 |
0
|
@SuppressWarnings("unchecked") |
223 |
|
List<Lo> resultList = query.getResultList(); |
224 |
0
|
return resultList; |
225 |
|
} |
226 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
227 |
0
|
@Override... |
228 |
|
public List<LoLoRelation> getLoLoRelationsByLoId(String loId) { |
229 |
0
|
Query query = em.createNamedQuery("Lo.getLoLoRelationsByLoId"); |
230 |
0
|
query.setParameter("loId", loId); |
231 |
0
|
@SuppressWarnings("unchecked") |
232 |
|
List<LoLoRelation> resultList = query.getResultList(); |
233 |
0
|
return resultList; |
234 |
|
} |
235 |
|
|
236 |
|
|
237 |
|
|
238 |
|
|
239 |
|
|
240 |
|
@see |
241 |
|
|
242 |
|
|
243 |
|
|
244 |
|
|
245 |
|
|
246 |
|
|
247 |
|
|
248 |
|
|
249 |
|
@see |
250 |
|
|
251 |
|
|
252 |
|
|
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
|
|
261 |
|
|
262 |
|
|
263 |
|
|
264 |
|
|
265 |
|
|
266 |
|
|
267 |
|
|
268 |
|
|
269 |
|
|
270 |
|
|
271 |
|
|
272 |
|
|
273 |
|
|
274 |
|
@see |
275 |
|
|
276 |
|
|
277 |
|
|
278 |
|
|
279 |
|
|
280 |
|
|
281 |
|
|
282 |
|
|
283 |
|
|
284 |
|
|
285 |
|
|
286 |
|
|
287 |
|
|
288 |
|
@see |
289 |
|
|
290 |
|
|
291 |
|
|
292 |
|
|
293 |
|
|
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
|
299 |
|
|
300 |
|
|
301 |
|
|
302 |
|
|
303 |
|
@see |
304 |
|
|
305 |
|
|
306 |
|
|
307 |
|
|
308 |
|
|
309 |
|
|
310 |
|
|
311 |
|
|
312 |
|
|
313 |
|
|
314 |
|
@see |
315 |
|
|
316 |
|
|
317 |
|
|
318 |
|
|
319 |
|
|
320 |
|
|
321 |
|
|
322 |
|
|
323 |
|
|
324 |
|
|
325 |
|
|
326 |
|
|
327 |
|
|
328 |
|
|
329 |
|
|
330 |
|
|
331 |
|
|
332 |
|
|
333 |
|
|
334 |
|
|
335 |
|
|
336 |
|
|
337 |
|
|
338 |
|
|
339 |
|
@see |
340 |
|
|
341 |
|
|
342 |
|
|
343 |
|
|
344 |
|
|
345 |
|
|
346 |
|
|
347 |
|
|
348 |
|
|
349 |
|
|
350 |
|
|
351 |
|
|
352 |
|
|
353 |
|
|
354 |
|
|
355 |
|
|
356 |
|
|
357 |
|
@see |
358 |
|
|
359 |
|
|
360 |
|
|
361 |
|
|
362 |
|
|
363 |
|
|
364 |
|
|
365 |
|
|
366 |
|
|
367 |
|
|
368 |
|
|
369 |
|
|
370 |
|
} |