1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.student.lum.lo.service.impl; |
17 |
|
|
18 |
|
import java.util.ArrayList; |
19 |
|
import java.util.HashMap; |
20 |
|
import java.util.Iterator; |
21 |
|
import java.util.List; |
22 |
|
import java.util.Map; |
23 |
|
|
24 |
|
import javax.jws.WebService; |
25 |
|
|
26 |
|
import org.kuali.student.common.dictionary.dto.ObjectStructureDefinition; |
27 |
|
import org.kuali.student.common.dictionary.service.DictionaryService; |
28 |
|
import org.kuali.student.common.dto.DtoConstants; |
29 |
|
import org.kuali.student.common.dto.StatusInfo; |
30 |
|
import org.kuali.student.common.exceptions.AlreadyExistsException; |
31 |
|
import org.kuali.student.common.exceptions.DataValidationErrorException; |
32 |
|
import org.kuali.student.common.exceptions.DependentObjectsExistException; |
33 |
|
import org.kuali.student.common.exceptions.DoesNotExistException; |
34 |
|
import org.kuali.student.common.exceptions.InvalidParameterException; |
35 |
|
import org.kuali.student.common.exceptions.MissingParameterException; |
36 |
|
import org.kuali.student.common.exceptions.OperationFailedException; |
37 |
|
import org.kuali.student.common.exceptions.PermissionDeniedException; |
38 |
|
import org.kuali.student.common.exceptions.UnsupportedActionException; |
39 |
|
import org.kuali.student.common.exceptions.VersionMismatchException; |
40 |
|
import org.kuali.student.common.search.dto.SearchCriteriaTypeInfo; |
41 |
|
import org.kuali.student.common.search.dto.SearchParam; |
42 |
|
import org.kuali.student.common.search.dto.SearchRequest; |
43 |
|
import org.kuali.student.common.search.dto.SearchResult; |
44 |
|
import org.kuali.student.common.search.dto.SearchResultCell; |
45 |
|
import org.kuali.student.common.search.dto.SearchResultRow; |
46 |
|
import org.kuali.student.common.search.dto.SearchResultTypeInfo; |
47 |
|
import org.kuali.student.common.search.dto.SearchTypeInfo; |
48 |
|
import org.kuali.student.common.search.service.SearchManager; |
49 |
|
import org.kuali.student.common.validation.dto.ValidationResultInfo; |
50 |
|
import org.kuali.student.common.validator.Validator; |
51 |
|
import org.kuali.student.common.validator.ValidatorFactory; |
52 |
|
import org.kuali.student.lum.lo.dao.LoDao; |
53 |
|
import org.kuali.student.lum.lo.dto.LoCategoryInfo; |
54 |
|
import org.kuali.student.lum.lo.dto.LoCategoryTypeInfo; |
55 |
|
import org.kuali.student.lum.lo.dto.LoInfo; |
56 |
|
import org.kuali.student.lum.lo.dto.LoLoRelationInfo; |
57 |
|
import org.kuali.student.lum.lo.dto.LoLoRelationTypeInfo; |
58 |
|
import org.kuali.student.lum.lo.dto.LoRepositoryInfo; |
59 |
|
import org.kuali.student.lum.lo.dto.LoTypeInfo; |
60 |
|
import org.kuali.student.lum.lo.entity.Lo; |
61 |
|
import org.kuali.student.lum.lo.entity.LoCategory; |
62 |
|
import org.kuali.student.lum.lo.entity.LoCategoryType; |
63 |
|
import org.kuali.student.lum.lo.entity.LoLoRelation; |
64 |
|
import org.kuali.student.lum.lo.entity.LoLoRelationType; |
65 |
|
import org.kuali.student.lum.lo.entity.LoRepository; |
66 |
|
import org.kuali.student.lum.lo.entity.LoType; |
67 |
|
import org.kuali.student.lum.lo.service.LearningObjectiveService; |
68 |
|
import org.springframework.transaction.annotation.Transactional; |
69 |
|
|
70 |
|
|
71 |
|
@author |
72 |
|
|
73 |
|
|
74 |
|
@WebService(endpointInterface = "org.kuali.student.lum.lo.service.LearningObjectiveService", serviceName = "LearningObjectiveService", portName = "LearningObjectiveService", targetNamespace = "http://student.kuali.org/wsdl/lo") |
75 |
|
@Transactional(readOnly=true,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
|
|
| 70.8% |
Uncovered Elements: 125 (428) |
Complexity: 109 |
Complexity Density: 0.36 |
|
76 |
|
public class LearningObjectiveServiceImpl implements LearningObjectiveService { |
77 |
|
private LoDao loDao; |
78 |
|
private SearchManager searchManager; |
79 |
|
private DictionaryService dictionaryServiceDelegate; |
80 |
|
private ValidatorFactory validatorFactory; |
81 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
82 |
0
|
public LoDao getLoDao() {... |
83 |
0
|
return loDao; |
84 |
|
} |
85 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
86 |
3
|
public void setLoDao(LoDao dao) {... |
87 |
3
|
this.loDao = dao; |
88 |
|
} |
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
90 |
3
|
public void setSearchManager(SearchManager searchManager) {... |
91 |
3
|
this.searchManager = searchManager; |
92 |
|
} |
93 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
94 |
3
|
public void setDictionaryServiceDelegate(DictionaryService dictionaryServiceDelegate) {... |
95 |
3
|
this.dictionaryServiceDelegate = dictionaryServiceDelegate; |
96 |
|
} |
97 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
98 |
0
|
public ValidatorFactory getValidatorFactory() {... |
99 |
0
|
return validatorFactory; |
100 |
|
} |
101 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
102 |
3
|
public void setValidatorFactory(ValidatorFactory validatorFactory) {... |
103 |
3
|
this.validatorFactory = validatorFactory; |
104 |
|
} |
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
@see |
109 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
110 |
1
|
@Override... |
111 |
|
public List<LoRepositoryInfo> getLoRepositories() |
112 |
|
throws OperationFailedException { |
113 |
1
|
List<LoRepository> repositories = loDao.find(LoRepository.class); |
114 |
1
|
return LearningObjectiveServiceAssembler.toLoRepositoryInfos(repositories); |
115 |
|
} |
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
@see |
120 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
121 |
2
|
@Override... |
122 |
|
public LoRepositoryInfo getLoRepository(String loRepositoryKey) |
123 |
|
throws DoesNotExistException, InvalidParameterException, |
124 |
|
MissingParameterException, OperationFailedException { |
125 |
2
|
checkForMissingParameter(loRepositoryKey, "loRepositoryKey"); |
126 |
1
|
return LearningObjectiveServiceAssembler.toLoRepositoryInfo(loDao.fetch(LoRepository.class, loRepositoryKey)); |
127 |
|
} |
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
@see |
132 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
133 |
1
|
@Override... |
134 |
|
public List<LoTypeInfo> getLoTypes() throws OperationFailedException { |
135 |
1
|
List<LoType> find = loDao.find(LoType.class); |
136 |
1
|
return LearningObjectiveServiceAssembler.toLoTypeInfos(find); |
137 |
|
} |
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
@see |
142 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
143 |
3
|
@Override... |
144 |
|
public LoTypeInfo getLoType(String loTypeKey) throws DoesNotExistException, |
145 |
|
InvalidParameterException, MissingParameterException, |
146 |
|
OperationFailedException { |
147 |
3
|
checkForMissingParameter(loTypeKey, "loTypeKey"); |
148 |
2
|
LoType fetch = loDao.fetch(LoType.class, loTypeKey); |
149 |
2
|
return LearningObjectiveServiceAssembler.toLoTypeInfo(fetch); |
150 |
|
} |
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
@see |
155 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
156 |
1
|
@Override... |
157 |
|
public List<LoLoRelationTypeInfo> getLoLoRelationTypes() |
158 |
|
throws OperationFailedException { |
159 |
1
|
List<LoLoRelationType> fetch = loDao.find(LoLoRelationType.class); |
160 |
1
|
return LearningObjectiveServiceAssembler.toLoLoRelationTypeInfos(fetch); |
161 |
|
} |
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
@see |
166 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
167 |
2
|
@Override... |
168 |
|
public LoLoRelationTypeInfo getLoLoRelationType(String loLoRelationTypeKey) |
169 |
|
throws OperationFailedException, MissingParameterException, DoesNotExistException { |
170 |
2
|
checkForMissingParameter(loLoRelationTypeKey, "loLoRelationTypeKey"); |
171 |
1
|
return LearningObjectiveServiceAssembler.toLoLoRelationTypeInfo(loDao.fetch(LoLoRelationType.class, loLoRelationTypeKey)); |
172 |
|
} |
173 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
174 |
2
|
@Override... |
175 |
|
public List<String> getAllowedLoLoRelationTypesForLoType(String loTypeKey, String relatedLoTypeKey) |
176 |
|
throws DoesNotExistException, InvalidParameterException, |
177 |
|
MissingParameterException, OperationFailedException { |
178 |
2
|
checkForMissingParameter(loTypeKey, "loTypeKey"); |
179 |
2
|
checkForMissingParameter(relatedLoTypeKey, "relatedLoTypeKey"); |
180 |
|
|
181 |
2
|
return loDao.getAllowedLoLoRelationTypesForLoType(loTypeKey, relatedLoTypeKey); |
182 |
|
} |
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
@see |
187 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
188 |
1291
|
@Override... |
189 |
|
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
190 |
|
public StatusInfo addLoCategoryToLo(String loCategoryId, String loId) |
191 |
|
throws AlreadyExistsException, DoesNotExistException, |
192 |
|
InvalidParameterException, MissingParameterException, |
193 |
|
OperationFailedException, PermissionDeniedException, |
194 |
|
UnsupportedActionException { |
195 |
1291
|
checkForMissingParameter(loCategoryId, "loCategoryId"); |
196 |
1291
|
checkForMissingParameter(loId, "loId"); |
197 |
1291
|
StatusInfo statusInfo = new StatusInfo(); |
198 |
1291
|
statusInfo.setSuccess(loDao.addLoCategoryToLo(loCategoryId, loId)); |
199 |
1291
|
return statusInfo; |
200 |
|
} |
201 |
|
|
202 |
|
|
203 |
|
@see |
204 |
|
|
|
|
| 85.7% |
Uncovered Elements: 4 (28) |
Complexity: 6 |
Complexity Density: 0.25 |
|
205 |
656
|
@Override... |
206 |
|
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
207 |
|
public LoInfo createLo(String repositoryId, String loType, LoInfo loInfo) |
208 |
|
throws DataValidationErrorException, DoesNotExistException, |
209 |
|
InvalidParameterException, MissingParameterException, |
210 |
|
OperationFailedException, PermissionDeniedException { |
211 |
656
|
checkForMissingParameter(repositoryId, "repositoryId"); |
212 |
655
|
checkForMissingParameter(loType, "loType"); |
213 |
654
|
checkForMissingParameter(loInfo, "loInfo"); |
214 |
|
|
215 |
|
|
216 |
|
|
217 |
653
|
List<ValidationResultInfo> val = validateLo("SYSTEM", loInfo); |
218 |
653
|
if(null != val && val.size() > 0) { |
219 |
1
|
for (ValidationResultInfo result : val) { |
220 |
1
|
System.err.println("Validation error. Element: " + result.getElement() + ", Value: " + result.getMessage()); |
221 |
|
} |
222 |
1
|
throw new DataValidationErrorException("Validation error!", val); |
223 |
|
} |
224 |
|
|
225 |
|
|
226 |
|
|
227 |
652
|
LoType type = null; |
228 |
652
|
LoRepository repository = null; |
229 |
652
|
try { |
230 |
652
|
type = loDao.fetch(LoType.class, loType); |
231 |
652
|
repository = loDao.fetch(LoRepository.class, repositoryId); |
232 |
|
} catch (DoesNotExistException dnee) { |
233 |
0
|
throw new DoesNotExistException("Specified " + (null == type ? "LoType" : "LoRepository") + " does not exist", dnee); |
234 |
|
} |
235 |
|
|
236 |
652
|
loInfo.setLoRepositoryKey(repositoryId); |
237 |
652
|
loInfo.setType(loType); |
238 |
|
|
239 |
652
|
Lo lo = null; |
240 |
652
|
try { |
241 |
652
|
lo = LearningObjectiveServiceAssembler.toLo(false, loInfo, loDao); |
242 |
|
} catch (VersionMismatchException vme) { |
243 |
|
|
244 |
0
|
throw new OperationFailedException("VersionMismatchException caught during Learning Objective creation"); |
245 |
|
} |
246 |
652
|
lo.setLoType(type); |
247 |
652
|
lo.setLoRepository(repository); |
248 |
652
|
loDao.create(lo); |
249 |
|
|
250 |
652
|
return LearningObjectiveServiceAssembler.toLoInfo(lo); |
251 |
|
} |
252 |
|
|
253 |
|
|
254 |
|
@see |
255 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
256 |
25
|
@Override... |
257 |
|
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
258 |
|
public StatusInfo deleteLo(String loId) |
259 |
|
throws DependentObjectsExistException, DoesNotExistException, |
260 |
|
InvalidParameterException, MissingParameterException, |
261 |
|
OperationFailedException, PermissionDeniedException { |
262 |
25
|
checkForMissingParameter(loId, "loId"); |
263 |
|
|
264 |
25
|
StatusInfo returnStatus = new StatusInfo(); |
265 |
25
|
returnStatus.setSuccess(loDao.deleteLo(loId)); |
266 |
24
|
return returnStatus; |
267 |
|
} |
268 |
|
|
269 |
|
|
270 |
|
@see |
271 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
272 |
6
|
@Override... |
273 |
|
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
274 |
|
public StatusInfo deleteLoCategory(String loCategoryId) |
275 |
|
throws DependentObjectsExistException, DoesNotExistException, |
276 |
|
InvalidParameterException, MissingParameterException, |
277 |
|
OperationFailedException, PermissionDeniedException { |
278 |
6
|
checkForMissingParameter(loCategoryId, "loCategoryId"); |
279 |
|
|
280 |
6
|
loDao.deleteLoCategory(loCategoryId); |
281 |
|
|
282 |
5
|
return new StatusInfo(); |
283 |
|
} |
284 |
|
|
285 |
|
|
286 |
|
@see |
287 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
288 |
86
|
@Override... |
289 |
|
public LoInfo getLo(String loId) throws DoesNotExistException, |
290 |
|
InvalidParameterException, MissingParameterException, |
291 |
|
OperationFailedException { |
292 |
86
|
checkForMissingParameter(loId, "loId"); |
293 |
|
|
294 |
85
|
return LearningObjectiveServiceAssembler.toLoInfo(loDao.fetch(Lo.class, loId)); |
295 |
|
} |
296 |
|
|
297 |
|
|
298 |
|
@see |
299 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
300 |
1
|
@Override... |
301 |
|
public List<LoInfo> getLoByIdList(List<String> loIds) |
302 |
|
throws InvalidParameterException, MissingParameterException, |
303 |
|
OperationFailedException { |
304 |
1
|
checkForMissingParameter(loIds, "loId"); |
305 |
1
|
checkForEmptyList(loIds, "loId"); |
306 |
1
|
List<Lo> los = loDao.getLoByIdList(loIds); |
307 |
1
|
return LearningObjectiveServiceAssembler.toLoInfos(los); |
308 |
|
} |
309 |
|
|
310 |
|
|
311 |
|
@see |
312 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
313 |
3
|
@Override... |
314 |
|
public List<LoCategoryInfo> getLoCategories(String loRepositoryKey) |
315 |
|
throws DoesNotExistException, InvalidParameterException, |
316 |
|
MissingParameterException, OperationFailedException { |
317 |
3
|
checkForMissingParameter(loRepositoryKey, "loRepositoryKey"); |
318 |
3
|
List<LoCategory> categories = loDao.getLoCategories(loRepositoryKey); |
319 |
3
|
return LearningObjectiveServiceAssembler.toLoCategoryInfos(categories); |
320 |
|
} |
321 |
|
|
322 |
|
|
323 |
|
@see |
324 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
325 |
446
|
@Override... |
326 |
|
public List<LoCategoryInfo> getLoCategoriesForLo(String loId) |
327 |
|
throws DoesNotExistException, InvalidParameterException, |
328 |
|
MissingParameterException, OperationFailedException { |
329 |
446
|
checkForMissingParameter(loId, "loId"); |
330 |
446
|
List<LoCategory> categories = loDao.getLoCategoriesForLo(loId); |
331 |
446
|
return LearningObjectiveServiceAssembler.toLoCategoryInfos(categories); |
332 |
|
} |
333 |
|
|
334 |
|
|
335 |
|
@see |
336 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
337 |
3
|
@Override... |
338 |
|
public LoCategoryInfo getLoCategory(String loCategoryId) |
339 |
|
throws DoesNotExistException, InvalidParameterException, |
340 |
|
MissingParameterException, OperationFailedException { |
341 |
3
|
checkForMissingParameter(loCategoryId, "loCategoryId"); |
342 |
|
|
343 |
3
|
return LearningObjectiveServiceAssembler.toLoCategoryInfo(loDao.fetch(LoCategory.class, loCategoryId)); |
344 |
|
} |
345 |
|
|
346 |
|
|
347 |
|
@see |
348 |
|
|
349 |
|
|
350 |
|
|
351 |
|
|
352 |
|
|
353 |
|
|
354 |
|
|
355 |
|
|
356 |
|
|
357 |
|
|
358 |
|
@see |
359 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
360 |
5
|
@Override... |
361 |
|
public List<LoInfo> getLosByLoCategory(String loCategoryId) |
362 |
|
throws DoesNotExistException, InvalidParameterException, |
363 |
|
MissingParameterException, OperationFailedException { |
364 |
5
|
checkForMissingParameter(loCategoryId, "loCategoryId"); |
365 |
5
|
List<Lo> los = loDao.getLosByLoCategory(loCategoryId); |
366 |
5
|
return LearningObjectiveServiceAssembler.toLoInfos(los); |
367 |
|
} |
368 |
|
|
369 |
|
|
370 |
|
@see |
371 |
|
|
372 |
|
|
373 |
|
|
374 |
|
|
375 |
|
|
376 |
|
|
377 |
|
|
378 |
|
|
379 |
|
|
380 |
|
|
381 |
|
|
382 |
|
@see |
383 |
|
|
384 |
|
|
385 |
|
|
386 |
|
|
387 |
|
|
388 |
|
|
389 |
|
|
390 |
|
|
391 |
|
|
392 |
|
|
393 |
|
|
394 |
|
@see |
395 |
|
|
396 |
|
|
397 |
|
|
398 |
|
|
399 |
|
|
400 |
|
|
401 |
|
|
402 |
|
|
403 |
|
|
404 |
|
|
405 |
|
|
406 |
|
|
407 |
|
|
408 |
|
|
409 |
|
|
410 |
|
|
411 |
|
@see |
412 |
|
|
413 |
|
|
414 |
|
|
415 |
|
|
416 |
|
|
417 |
|
|
418 |
|
|
419 |
|
|
420 |
|
|
421 |
|
|
422 |
|
|
423 |
|
|
424 |
|
|
425 |
|
|
426 |
|
|
427 |
|
|
428 |
|
@see |
429 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
430 |
44
|
@Override... |
431 |
|
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
432 |
|
public StatusInfo removeLoCategoryFromLo(String loCategoryId, String loId) |
433 |
|
throws DoesNotExistException, InvalidParameterException, |
434 |
|
MissingParameterException, OperationFailedException, |
435 |
|
PermissionDeniedException, UnsupportedActionException { |
436 |
44
|
checkForMissingParameter(loCategoryId, "loCategoryId"); |
437 |
44
|
checkForMissingParameter(loId, "loId"); |
438 |
|
|
439 |
44
|
StatusInfo statusInfo = new StatusInfo(); |
440 |
44
|
statusInfo.setSuccess(loDao.removeLoCategoryFromLo(loCategoryId, loId)); |
441 |
44
|
return statusInfo; |
442 |
|
} |
443 |
|
|
444 |
|
|
445 |
|
@see |
446 |
|
|
|
|
| 76.5% |
Uncovered Elements: 4 (17) |
Complexity: 4 |
Complexity Density: 0.31 |
|
447 |
25
|
@Override... |
448 |
|
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
449 |
|
public LoInfo updateLo(String loId, LoInfo loInfo) |
450 |
|
throws DataValidationErrorException, DoesNotExistException, |
451 |
|
InvalidParameterException, MissingParameterException, |
452 |
|
OperationFailedException, PermissionDeniedException, |
453 |
|
VersionMismatchException { |
454 |
25
|
checkForMissingParameter(loId, "loId"); |
455 |
24
|
checkForMissingParameter(loInfo, "loInfo"); |
456 |
|
|
457 |
|
|
458 |
23
|
List<ValidationResultInfo> val = validateLo("SYSTEM", loInfo); |
459 |
23
|
if(null != val && val.size() > 0) { |
460 |
0
|
for (ValidationResultInfo result : val) { |
461 |
0
|
System.err.println("Validation error. Element: " + result.getElement() + ", Value: " + result.getMessage()); |
462 |
|
} |
463 |
0
|
throw new DataValidationErrorException("Validation error!", val); |
464 |
|
} |
465 |
|
|
466 |
23
|
Lo lo = loDao.fetch(Lo.class, loId); |
467 |
|
|
468 |
23
|
if (!String.valueOf(lo.getVersionNumber()).equals(loInfo.getMetaInfo().getVersionInd())){ |
469 |
1
|
throw new VersionMismatchException("LO to be updated is not the current version"); |
470 |
|
} |
471 |
|
|
472 |
22
|
lo = LearningObjectiveServiceAssembler.toLo(true, lo, loInfo, loDao); |
473 |
22
|
loDao.update(lo); |
474 |
22
|
return LearningObjectiveServiceAssembler.toLoInfo(lo); |
475 |
|
} |
476 |
|
|
477 |
|
|
478 |
|
@see |
479 |
|
|
|
|
| 59.5% |
Uncovered Elements: 17 (42) |
Complexity: 11 |
Complexity Density: 0.39 |
|
480 |
3
|
@Override... |
481 |
|
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
482 |
|
public LoCategoryInfo updateLoCategory(String loCategoryId, |
483 |
|
LoCategoryInfo loCategoryInfo) throws DataValidationErrorException, |
484 |
|
DoesNotExistException, InvalidParameterException, |
485 |
|
MissingParameterException, OperationFailedException, |
486 |
|
PermissionDeniedException, VersionMismatchException { |
487 |
3
|
checkForMissingParameter(loCategoryId, "loCategoryId"); |
488 |
3
|
checkForMissingParameter(loCategoryInfo, "loCategoryInfo"); |
489 |
|
|
490 |
|
|
491 |
3
|
List<ValidationResultInfo> val = validateLoCategory("SYSTEM", loCategoryInfo); |
492 |
|
|
493 |
|
|
494 |
3
|
if (doesLoCategoryExist(loCategoryInfo.getLoRepository(), loCategoryInfo, loCategoryId)) { |
495 |
2
|
ValidationResultInfo vr = new ValidationResultInfo(); |
496 |
2
|
vr.setElement("LO Category Name"); |
497 |
2
|
vr.setError("LO Category already exists"); |
498 |
2
|
val.add(vr); |
499 |
|
} |
500 |
3
|
if(null != val && val.size() > 0) { |
501 |
2
|
for (ValidationResultInfo result : val) { |
502 |
2
|
System.err.println("Validation error. Element: " + result.getElement() + ", Value: " + result.getMessage()); |
503 |
|
} |
504 |
2
|
throw new DataValidationErrorException("Validation error!", val); |
505 |
|
} |
506 |
1
|
LoCategory loCategory = loDao.fetch(LoCategory.class, loCategoryId); |
507 |
|
|
508 |
1
|
if (!String.valueOf(loCategory.getVersionNumber()).equals(loCategoryInfo.getMetaInfo().getVersionInd())){ |
509 |
0
|
throw new VersionMismatchException("LoCategory to be updated is not the current version"); |
510 |
|
} |
511 |
|
|
512 |
|
|
513 |
1
|
if (loCategory.getState().equals("active") && ( ! loCategoryInfo.getState().equals("active") )) { |
514 |
|
|
515 |
|
|
516 |
0
|
List<LoInfo> loInfos = getLosByLoCategory(loCategoryId); |
517 |
0
|
if (null != loInfos) { |
518 |
|
|
519 |
0
|
for (LoInfo info : loInfos) { |
520 |
0
|
if (info.getState().equals("active")) { |
521 |
0
|
try { |
522 |
0
|
removeLoCategoryFromLo(loCategoryId, info.getId()); |
523 |
|
} catch (UnsupportedActionException uaee) { |
524 |
0
|
throw new OperationFailedException("Unable to update LoCategory: could not remove association with active LearningObjective", uaee); |
525 |
|
} |
526 |
|
} |
527 |
|
} |
528 |
|
} |
529 |
|
} |
530 |
|
|
531 |
|
|
532 |
1
|
if ( ! loCategory.getLoCategoryType().getId().equals(loCategoryInfo.getType()) ) { |
533 |
1
|
loCategory = cloneLoCategory(loCategory, loCategoryInfo); |
534 |
|
} else { |
535 |
0
|
loCategory = LearningObjectiveServiceAssembler.toLoCategory(loCategory, loCategoryInfo, loDao); |
536 |
0
|
loDao.update(loCategory); |
537 |
|
} |
538 |
1
|
return LearningObjectiveServiceAssembler.toLoCategoryInfo(loCategory); |
539 |
|
} |
540 |
|
|
541 |
|
|
542 |
|
|
543 |
|
|
|
|
| 88.2% |
Uncovered Elements: 2 (17) |
Complexity: 3 |
Complexity Density: 0.18 |
|
544 |
1
|
private LoCategory cloneLoCategory(LoCategory loCategory, LoCategoryInfo loCategoryInfo) throws DoesNotExistException, InvalidParameterException, OperationFailedException {... |
545 |
1
|
LoCategoryType catType = null; |
546 |
|
|
547 |
1
|
try { |
548 |
1
|
catType = loDao.fetch(LoCategoryType.class, loCategoryInfo.getType()); |
549 |
|
} catch (DoesNotExistException dnee) { |
550 |
0
|
throw new DoesNotExistException("Attempt to set LoCategory's type to nonexistent LoCategoryType", dnee); |
551 |
|
} |
552 |
|
|
553 |
|
|
554 |
1
|
LoCategoryInfo newLoCategoryInfo = LearningObjectiveServiceAssembler.toLoCategoryInfo(loCategory); |
555 |
1
|
newLoCategoryInfo.setType(catType.getId()); |
556 |
1
|
newLoCategoryInfo.setName(loCategoryInfo.getName()); |
557 |
1
|
LoCategory newLoCategory = loDao.create(LearningObjectiveServiceAssembler.toLoCategory(newLoCategoryInfo, loDao)); |
558 |
|
|
559 |
|
|
560 |
1
|
List<Lo> catsLos = loDao.getLosByLoCategory(loCategory.getId()); |
561 |
1
|
for (Lo lo : catsLos) { |
562 |
2
|
try { |
563 |
|
|
564 |
2
|
loDao.addLoCategoryToLo(newLoCategory.getId(), lo.getId()); |
565 |
|
|
566 |
2
|
loDao.removeLoCategoryFromLo(loCategory.getId(), lo.getId()); |
567 |
|
} catch (UnsupportedActionException uae) { |
568 |
0
|
throw new OperationFailedException(uae.getMessage(), uae); |
569 |
|
} |
570 |
|
} |
571 |
|
|
572 |
|
|
573 |
1
|
loCategory.setState("Suspended"); |
574 |
1
|
loDao.update(loCategory); |
575 |
|
|
576 |
1
|
return newLoCategory; |
577 |
|
} |
578 |
|
|
579 |
|
|
580 |
|
@see |
581 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
582 |
676
|
@Override... |
583 |
|
public List<ValidationResultInfo> validateLo(String validationType, |
584 |
|
LoInfo loInfo) throws DoesNotExistException, |
585 |
|
InvalidParameterException, MissingParameterException, |
586 |
|
OperationFailedException { |
587 |
676
|
checkForMissingParameter(validationType, "validationType"); |
588 |
676
|
checkForMissingParameter(loInfo, "loInfo"); |
589 |
|
|
590 |
|
|
591 |
|
|
592 |
|
|
593 |
|
|
594 |
|
|
595 |
|
|
596 |
|
|
597 |
|
|
598 |
676
|
ObjectStructureDefinition objStructure = this.getObjectStructure(LoInfo.class.getName()); |
599 |
676
|
Validator validator = validatorFactory.getValidator(); |
600 |
676
|
return validator.validateObject(loInfo, objStructure); |
601 |
|
} |
602 |
|
|
603 |
|
|
604 |
|
@see |
605 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
606 |
10
|
@Override... |
607 |
|
public List<ValidationResultInfo> validateLoCategory(String validationType, |
608 |
|
LoCategoryInfo loCategoryInfo) throws DoesNotExistException, |
609 |
|
InvalidParameterException, MissingParameterException, |
610 |
|
OperationFailedException { |
611 |
10
|
checkForMissingParameter(validationType, "validationType"); |
612 |
10
|
checkForMissingParameter(loCategoryInfo, "loCategoryInfo"); |
613 |
|
|
614 |
|
|
615 |
|
|
616 |
|
|
617 |
|
|
618 |
|
|
619 |
|
|
620 |
|
|
621 |
|
|
622 |
10
|
ObjectStructureDefinition objStructure = this.getObjectStructure(LoCategoryInfo.class.getName()); |
623 |
10
|
Validator validator = validatorFactory.getValidator(); |
624 |
10
|
return validator.validateObject(loCategoryInfo, objStructure); |
625 |
|
|
626 |
|
} |
627 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
628 |
554
|
@Override... |
629 |
|
public List<ValidationResultInfo> validateLoLoRelation( |
630 |
|
String validationType, LoLoRelationInfo loLoRelationInfo) |
631 |
|
throws DoesNotExistException, InvalidParameterException, |
632 |
|
MissingParameterException, OperationFailedException { |
633 |
|
|
634 |
554
|
ObjectStructureDefinition objStructure = this.getObjectStructure(LoLoRelationInfo.class.getName()); |
635 |
554
|
Validator validator = validatorFactory.getValidator(); |
636 |
554
|
return validator.validateObject(loLoRelationInfo, objStructure); |
637 |
|
} |
638 |
|
|
639 |
|
|
640 |
|
|
641 |
|
|
642 |
|
@param |
643 |
|
@param |
644 |
|
@throws |
645 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
646 |
9706
|
private void checkForMissingParameter(Object param, String paramName)... |
647 |
|
throws MissingParameterException { |
648 |
9706
|
if (param == null) { |
649 |
16
|
throw new MissingParameterException(paramName + " can not be null"); |
650 |
|
} |
651 |
|
} |
652 |
|
|
653 |
|
|
654 |
|
@param |
655 |
|
@param |
656 |
|
@throws |
657 |
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 4 |
Complexity Density: 2 |
|
658 |
1
|
private void checkForEmptyList(Object param, String paramName)... |
659 |
|
throws MissingParameterException { |
660 |
1
|
if (param != null && param instanceof List && ((List<?>)param).size() == 0) { |
661 |
0
|
throw new MissingParameterException(paramName + " can not be an empty list"); |
662 |
|
} |
663 |
|
} |
664 |
|
|
665 |
|
|
666 |
|
|
667 |
|
|
668 |
|
|
669 |
|
|
670 |
|
|
671 |
|
|
672 |
|
|
673 |
|
|
674 |
|
|
675 |
|
|
676 |
|
|
677 |
|
|
678 |
|
|
679 |
|
|
680 |
|
@param |
681 |
|
@param |
682 |
|
@param |
683 |
|
@throws |
684 |
|
|
|
|
| 95.7% |
Uncovered Elements: 2 (47) |
Complexity: 9 |
Complexity Density: 0.26 |
|
685 |
10
|
private boolean doesLoCategoryExist(String loRepositoryKey, LoCategoryInfo loCategoryInfo, String loCategoryId)... |
686 |
|
throws MissingParameterException, DataValidationErrorException { |
687 |
10
|
if (loCategoryInfo.getName() == null) |
688 |
|
{ |
689 |
1
|
return false; |
690 |
|
} |
691 |
9
|
boolean exists = false; |
692 |
9
|
SearchRequest request = new SearchRequest(); |
693 |
9
|
request.setSearchKey("lo.search.loCategoriesByNameRepoTypeState"); |
694 |
|
|
695 |
9
|
List<SearchParam> searchParams = new ArrayList<SearchParam>(); |
696 |
9
|
SearchParam qpv1 = new SearchParam(); |
697 |
9
|
qpv1.setKey("lo.queryParam.loCategoryName"); |
698 |
9
|
qpv1.setValue(loCategoryInfo.getName().toLowerCase()); |
699 |
9
|
searchParams.add(qpv1); |
700 |
9
|
SearchParam qpv2 = new SearchParam(); |
701 |
9
|
qpv2.setKey("lo.queryParam.loCategoryRepo"); |
702 |
9
|
qpv2.setValue(loRepositoryKey); |
703 |
9
|
searchParams.add(qpv2); |
704 |
9
|
SearchParam qpv3 = new SearchParam(); |
705 |
9
|
qpv3.setKey("lo.queryParam.loCategoryType"); |
706 |
9
|
qpv3.setValue(loCategoryInfo.getType()); |
707 |
9
|
searchParams.add(qpv3); |
708 |
9
|
SearchParam qpv4 = new SearchParam(); |
709 |
9
|
qpv4.setKey("lo.queryParam.loCategoryState"); |
710 |
9
|
qpv4.setValue(loCategoryInfo.getState()); |
711 |
9
|
searchParams.add(qpv4); |
712 |
|
|
713 |
9
|
request.setParams(searchParams); |
714 |
|
|
715 |
9
|
SearchResult result = search(request); |
716 |
|
|
717 |
9
|
if(loCategoryId != null && !loCategoryId.trim().equals("")){ |
718 |
3
|
if (result.getRows().size() > 0) { |
719 |
2
|
for(SearchResultRow srrow : result.getRows()){ |
720 |
2
|
List<SearchResultCell> srCells = srrow.getCells(); |
721 |
2
|
if(srCells != null && srCells.size() > 0){ |
722 |
2
|
for(SearchResultCell srcell : srCells){ |
723 |
2
|
if(!srcell.getValue().equals(loCategoryId)) { |
724 |
2
|
exists = true; |
725 |
|
} |
726 |
|
} |
727 |
|
} |
728 |
|
} |
729 |
|
} |
730 |
|
} |
731 |
|
else{ |
732 |
6
|
if (result.getRows().size() > 0) { |
733 |
2
|
exists = true; |
734 |
|
} |
735 |
|
} |
736 |
9
|
return exists; |
737 |
|
} |
738 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
739 |
1240
|
@Override... |
740 |
|
public ObjectStructureDefinition getObjectStructure(String objectTypeKey) { |
741 |
1240
|
return dictionaryServiceDelegate.getObjectStructure(objectTypeKey); |
742 |
|
} |
743 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
744 |
0
|
@Override... |
745 |
|
public List<String> getObjectTypes() { |
746 |
0
|
return dictionaryServiceDelegate.getObjectTypes(); |
747 |
|
} |
748 |
|
|
749 |
|
|
750 |
|
@see |
751 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
752 |
0
|
@Override... |
753 |
|
public SearchCriteriaTypeInfo getSearchCriteriaType( |
754 |
|
String searchCriteriaTypeKey) throws DoesNotExistException, |
755 |
|
InvalidParameterException, MissingParameterException, |
756 |
|
OperationFailedException { |
757 |
|
|
758 |
0
|
return searchManager.getSearchCriteriaType(searchCriteriaTypeKey); |
759 |
|
} |
760 |
|
|
761 |
|
|
762 |
|
@see |
763 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
764 |
0
|
@Override... |
765 |
|
public List<SearchCriteriaTypeInfo> getSearchCriteriaTypes() |
766 |
|
throws OperationFailedException { |
767 |
0
|
return searchManager.getSearchCriteriaTypes(); |
768 |
|
} |
769 |
|
|
770 |
|
|
771 |
|
@see |
772 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
773 |
0
|
@Override... |
774 |
|
public SearchResultTypeInfo getSearchResultType(String searchResultTypeKey) |
775 |
|
throws DoesNotExistException, InvalidParameterException, |
776 |
|
MissingParameterException, OperationFailedException { |
777 |
0
|
checkForMissingParameter(searchResultTypeKey, "searchResultTypeKey"); |
778 |
0
|
return searchManager.getSearchResultType(searchResultTypeKey); |
779 |
|
} |
780 |
|
|
781 |
|
|
782 |
|
@see |
783 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
784 |
0
|
@Override... |
785 |
|
public List<SearchResultTypeInfo> getSearchResultTypes() |
786 |
|
throws OperationFailedException { |
787 |
0
|
return searchManager.getSearchResultTypes(); |
788 |
|
} |
789 |
|
|
790 |
|
|
791 |
|
@see |
792 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
793 |
0
|
@Override... |
794 |
|
public SearchTypeInfo getSearchType(String searchTypeKey) |
795 |
|
throws DoesNotExistException, InvalidParameterException, |
796 |
|
MissingParameterException, OperationFailedException { |
797 |
0
|
checkForMissingParameter(searchTypeKey, "searchTypeKey"); |
798 |
0
|
return searchManager.getSearchType(searchTypeKey); |
799 |
|
} |
800 |
|
|
801 |
|
|
802 |
|
@see |
803 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
804 |
0
|
@Override... |
805 |
|
public List<SearchTypeInfo> getSearchTypes() |
806 |
|
throws OperationFailedException { |
807 |
0
|
return searchManager.getSearchTypes(); |
808 |
|
} |
809 |
|
|
810 |
|
|
811 |
|
@see |
812 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
813 |
0
|
@Override... |
814 |
|
public List<SearchTypeInfo> getSearchTypesByCriteria( |
815 |
|
String searchCriteriaTypeKey) throws DoesNotExistException, |
816 |
|
InvalidParameterException, MissingParameterException, |
817 |
|
OperationFailedException { |
818 |
0
|
checkForMissingParameter(searchCriteriaTypeKey, "searchCriteriaTypeKey"); |
819 |
0
|
return searchManager.getSearchTypesByCriteria(searchCriteriaTypeKey); |
820 |
|
} |
821 |
|
|
822 |
|
|
823 |
|
@see |
824 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
825 |
0
|
@Override... |
826 |
|
public List<SearchTypeInfo> getSearchTypesByResult( |
827 |
|
String searchResultTypeKey) throws DoesNotExistException, |
828 |
|
InvalidParameterException, MissingParameterException, |
829 |
|
OperationFailedException { |
830 |
0
|
checkForMissingParameter(searchResultTypeKey, "searchResultTypeKey"); |
831 |
0
|
return searchManager.getSearchTypesByResult(searchResultTypeKey); |
832 |
|
} |
833 |
|
|
|
|
| 83.3% |
Uncovered Elements: 5 (30) |
Complexity: 5 |
Complexity Density: 0.19 |
|
834 |
558
|
@Override... |
835 |
|
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
836 |
|
public LoLoRelationInfo createLoLoRelation(String loId, String relatedLoId, |
837 |
|
String loLoRelationType, LoLoRelationInfo loLoRelationInfo) |
838 |
|
throws AlreadyExistsException, |
839 |
|
DataValidationErrorException, DoesNotExistException, |
840 |
|
InvalidParameterException, MissingParameterException, |
841 |
|
OperationFailedException, PermissionDeniedException { |
842 |
558
|
checkForMissingParameter(loId, "loId"); |
843 |
557
|
checkForMissingParameter(relatedLoId, "relatedLoId"); |
844 |
556
|
checkForMissingParameter(loLoRelationType, "loLoRelationType"); |
845 |
555
|
checkForMissingParameter(loLoRelationInfo, "loLoRelationInfo"); |
846 |
|
|
847 |
|
|
848 |
554
|
List<ValidationResultInfo> val = validateLoLoRelation("SYSTEM", loLoRelationInfo); |
849 |
554
|
if(null != val && val.size() > 0) { |
850 |
0
|
for (ValidationResultInfo result : val) { |
851 |
0
|
System.err.println("Validation error. Element: " + result.getElement() + ", Value: " + result.getMessage()); |
852 |
|
} |
853 |
0
|
throw new DataValidationErrorException("Validation error!", val); |
854 |
|
} |
855 |
|
|
856 |
554
|
if (null == loLoRelationInfo.getState()) { |
857 |
2
|
loLoRelationInfo.setState(DtoConstants.STATE_DRAFT); |
858 |
|
} |
859 |
554
|
Lo lo = loDao.fetch(Lo.class, loId); |
860 |
554
|
Lo relatedLo = loDao.fetch(Lo.class, relatedLoId); |
861 |
554
|
LoLoRelationType type = loDao.fetch(LoLoRelationType.class, loLoRelationType); |
862 |
554
|
loLoRelationInfo.setLoId(loId); |
863 |
554
|
loLoRelationInfo.setRelatedLoId(relatedLoId); |
864 |
554
|
loLoRelationInfo.setType(loLoRelationType); |
865 |
|
|
866 |
554
|
LoLoRelation relation = null; |
867 |
554
|
try { |
868 |
554
|
relation = LearningObjectiveServiceAssembler.toLoLoRelation(false, loLoRelationInfo, loDao); |
869 |
|
} catch (VersionMismatchException vme) { |
870 |
|
|
871 |
0
|
throw new OperationFailedException("VersionMismatchException caught during LoLoRelation creation"); |
872 |
|
} |
873 |
554
|
relation.setLo(lo); |
874 |
554
|
relation.setRelatedLo(relatedLo); |
875 |
554
|
relation.setLoLoRelationType(type); |
876 |
|
|
877 |
554
|
relation = loDao.create(relation); |
878 |
|
|
879 |
554
|
return LearningObjectiveServiceAssembler.toLoLoRelationInfo(relation); |
880 |
|
} |
881 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
882 |
18
|
@Override... |
883 |
|
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
884 |
|
public StatusInfo deleteLoLoRelation(String loLoRelationId) |
885 |
|
throws DoesNotExistException, InvalidParameterException, |
886 |
|
MissingParameterException, OperationFailedException, |
887 |
|
PermissionDeniedException { |
888 |
18
|
checkForMissingParameter(loLoRelationId, "loLoRelationId"); |
889 |
|
|
890 |
18
|
loDao.deleteLoLoRelation(loLoRelationId); |
891 |
|
|
892 |
18
|
return new StatusInfo(); |
893 |
|
} |
894 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
895 |
4
|
@Override... |
896 |
|
public LoLoRelationInfo getLoLoRelation(String loLoRelationId) |
897 |
|
throws DoesNotExistException, InvalidParameterException, |
898 |
|
MissingParameterException, OperationFailedException { |
899 |
4
|
checkForMissingParameter(loLoRelationId, "loLoRelationId"); |
900 |
3
|
return LearningObjectiveServiceAssembler.toLoLoRelationInfo(loDao.fetch(LoLoRelation.class, loLoRelationId)); |
901 |
|
} |
902 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
903 |
52
|
@Override... |
904 |
|
public List<LoLoRelationInfo> getLoLoRelationsByLoId(String loId) |
905 |
|
throws DoesNotExistException, InvalidParameterException, |
906 |
|
MissingParameterException, OperationFailedException { |
907 |
52
|
List<LoLoRelation> llRelations = loDao.getLoLoRelationsByLoId(loId); |
908 |
52
|
return LearningObjectiveServiceAssembler.toLoLoRelationInfos(llRelations); |
909 |
|
} |
910 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
911 |
0
|
@Override... |
912 |
|
public List<LoInfo> getLosByRelatedLoId(String relatedLoId, |
913 |
|
String loLoRelationType) throws DoesNotExistException, |
914 |
|
InvalidParameterException, MissingParameterException, |
915 |
|
OperationFailedException { |
916 |
0
|
List<Lo> relatedLos = loDao.getLosByRelatedLoId(relatedLoId, loLoRelationType); |
917 |
0
|
return LearningObjectiveServiceAssembler.toLoInfos(relatedLos); |
918 |
|
} |
919 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
920 |
390
|
@Override... |
921 |
|
public List<LoInfo> getRelatedLosByLoId(String loId, String loLoRelationTypeKey) |
922 |
|
throws DoesNotExistException, InvalidParameterException, |
923 |
|
MissingParameterException, OperationFailedException { |
924 |
390
|
checkForMissingParameter(loId, "loId"); |
925 |
389
|
checkForMissingParameter(loLoRelationTypeKey, "loLoRelationTypeKey"); |
926 |
388
|
List<Lo> relatedLos = loDao.getRelatedLosByLoId(loId, loLoRelationTypeKey); |
927 |
388
|
return LearningObjectiveServiceAssembler.toLoInfos(relatedLos); |
928 |
|
} |
929 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
930 |
0
|
@Override... |
931 |
|
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
932 |
|
public LoLoRelationInfo updateLoLoRelation(String loLoRelationId, |
933 |
|
LoLoRelationInfo loLoRelationInfo) |
934 |
|
throws DataValidationErrorException, DoesNotExistException, |
935 |
|
InvalidParameterException, MissingParameterException, |
936 |
|
OperationFailedException, PermissionDeniedException, |
937 |
|
VersionMismatchException { |
938 |
|
|
939 |
|
|
940 |
|
|
941 |
0
|
List<ValidationResultInfo> val = validateLoLoRelation("SYSTEM", loLoRelationInfo); |
942 |
0
|
if(null != val && val.size() > 0) { |
943 |
0
|
throw new DataValidationErrorException("Validation error!", val); |
944 |
|
} |
945 |
|
|
946 |
|
|
947 |
0
|
return null; |
948 |
|
} |
949 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (24) |
Complexity: 4 |
Complexity Density: 0.2 |
|
950 |
7
|
@Override... |
951 |
|
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
952 |
|
public LoCategoryInfo createLoCategory(String loRepositoryKey, |
953 |
|
String loCategoryTypeKey, LoCategoryInfo loCategoryInfo) |
954 |
|
throws DataValidationErrorException, DoesNotExistException, |
955 |
|
InvalidParameterException, MissingParameterException, |
956 |
|
OperationFailedException, PermissionDeniedException { |
957 |
7
|
checkForMissingParameter(loRepositoryKey, "loRepositoryKey"); |
958 |
7
|
checkForMissingParameter(loCategoryTypeKey, "loCategoryTypeKey"); |
959 |
7
|
checkForMissingParameter(loCategoryInfo, "loCategoryInfo"); |
960 |
|
|
961 |
|
|
962 |
7
|
List<ValidationResultInfo> val = validateLoCategory("SYSTEM", loCategoryInfo); |
963 |
|
|
964 |
|
|
965 |
7
|
if (doesLoCategoryExist(loRepositoryKey, loCategoryInfo, null)) { |
966 |
2
|
ValidationResultInfo vr = new ValidationResultInfo(); |
967 |
2
|
vr.setElement("LO Category Name"); |
968 |
2
|
vr.setError("LO Category already exists"); |
969 |
2
|
val.add(vr); |
970 |
|
} |
971 |
7
|
if(null != val && val.size() > 0) { |
972 |
3
|
for (ValidationResultInfo result : val) { |
973 |
3
|
System.err.println("Validation error. Element: " + result.getElement() + ", Value: " + result.getMessage()); |
974 |
|
} |
975 |
3
|
throw new DataValidationErrorException("Validation error!", val); |
976 |
|
} |
977 |
|
|
978 |
4
|
LoCategory category = LearningObjectiveServiceAssembler.toLoCategory(loCategoryInfo, loDao); |
979 |
4
|
LoCategoryType loCatType = loDao.fetch(LoCategoryType.class, loCategoryTypeKey); |
980 |
4
|
category.setLoCategoryType(loCatType); |
981 |
4
|
LoRepository loRepository = loDao.fetch(LoRepository.class, loRepositoryKey); |
982 |
4
|
category.setLoRepository(loRepository); |
983 |
4
|
loDao.create(category); |
984 |
4
|
return LearningObjectiveServiceAssembler.toLoCategoryInfo(category); |
985 |
|
} |
986 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
987 |
0
|
@Override... |
988 |
|
public LoCategoryTypeInfo getLoCategoryType(String loCategoryTypeKey) |
989 |
|
throws DoesNotExistException, InvalidParameterException, |
990 |
|
MissingParameterException, OperationFailedException { |
991 |
0
|
checkForMissingParameter(loCategoryTypeKey, "loCategoryTypeKey"); |
992 |
0
|
LoCategoryType loCatType = loDao.fetch(LoCategoryType.class, loCategoryTypeKey); |
993 |
0
|
return LearningObjectiveServiceAssembler.toLoCategoryTypeInfo(loCatType); |
994 |
|
} |
995 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
996 |
1
|
@Override... |
997 |
|
public List<LoCategoryTypeInfo> getLoCategoryTypes() |
998 |
|
throws OperationFailedException { |
999 |
1
|
List<LoCategoryType> categoryTypes = loDao.find(LoCategoryType.class); |
1000 |
1
|
return LearningObjectiveServiceAssembler.toLoCategoryTypeInfos(categoryTypes); |
1001 |
|
} |
1002 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
1003 |
0
|
@Override... |
1004 |
|
public List<LoInfo> getLosByRepository(String loRepositoryKey, |
1005 |
|
String loTypeKey, String loStateKey) |
1006 |
|
throws InvalidParameterException, MissingParameterException, |
1007 |
|
OperationFailedException { |
1008 |
0
|
checkForMissingParameter(loRepositoryKey, "loRepositoryKey"); |
1009 |
0
|
List<Lo> los = loDao.getLosByRepository(loRepositoryKey); |
1010 |
0
|
return LearningObjectiveServiceAssembler.toLoInfos(los); |
1011 |
|
} |
1012 |
|
|
|
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
1013 |
10
|
@Override... |
1014 |
|
public SearchResult search(SearchRequest searchRequest) throws MissingParameterException { |
1015 |
10
|
checkForMissingParameter(searchRequest, "searchRequest"); |
1016 |
10
|
SearchResult result = searchManager.search(searchRequest, loDao); |
1017 |
10
|
if("lo.search.loByCategory".equals(searchRequest.getSearchKey())){ |
1018 |
|
|
1019 |
|
|
1020 |
0
|
groupCategories(result); |
1021 |
|
|
1022 |
|
|
1023 |
|
} |
1024 |
|
|
1025 |
10
|
return result; |
1026 |
|
} |
1027 |
|
|
1028 |
|
|
|
|
| 0% |
Uncovered Elements: 42 (42) |
Complexity: 12 |
Complexity Density: 0.5 |
|
1029 |
0
|
private void groupCategories(SearchResult result) {... |
1030 |
0
|
Map<String,SearchResultCell> idToCellMap = new HashMap<String,SearchResultCell>(); |
1031 |
0
|
for(Iterator<SearchResultRow> iter = result.getRows().iterator();iter.hasNext();){ |
1032 |
0
|
SearchResultRow row = iter.next(); |
1033 |
0
|
SearchResultCell categoryCell = null; |
1034 |
0
|
String loId = null; |
1035 |
|
|
1036 |
0
|
for(SearchResultCell cell:row.getCells()){ |
1037 |
0
|
if("lo.resultColumn.categoryName".equals(cell.getKey())){ |
1038 |
0
|
categoryCell = cell; |
1039 |
0
|
break; |
1040 |
0
|
}else if("lo.resultColumn.loId".equals(cell.getKey())){ |
1041 |
0
|
loId = cell.getValue(); |
1042 |
|
} |
1043 |
|
} |
1044 |
|
|
1045 |
0
|
if(loId!=null){ |
1046 |
0
|
if(idToCellMap.containsKey(loId)){ |
1047 |
0
|
SearchResultCell cell = idToCellMap.get(loId); |
1048 |
0
|
if(cell == null){ |
1049 |
0
|
cell = new SearchResultCell("lo.resultColumn.categoryName",""); |
1050 |
0
|
idToCellMap.put(loId, cell); |
1051 |
|
} |
1052 |
0
|
if(categoryCell!=null){ |
1053 |
0
|
if(cell.getValue()==null||cell.getValue().isEmpty()){ |
1054 |
0
|
cell.setValue(categoryCell.getValue()); |
1055 |
0
|
}else if(categoryCell.getValue()!=null && !categoryCell.getValue().isEmpty()){ |
1056 |
0
|
cell.setValue(cell.getValue()+", "+categoryCell.getValue()); |
1057 |
|
} |
1058 |
|
} |
1059 |
|
|
1060 |
0
|
iter.remove(); |
1061 |
|
} else { |
1062 |
|
|
1063 |
0
|
idToCellMap.put(loId, categoryCell); |
1064 |
|
} |
1065 |
|
} |
1066 |
|
} |
1067 |
|
} |
1068 |
|
|
1069 |
|
} |