Revision 57683
Added by Konstantina Galouni over 4 years ago
IndicatorController.java | ||
---|---|---|
265 | 265 |
return true; |
266 | 266 |
} |
267 | 267 |
|
268 |
// @RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/{subcategoryId}/{type}/reorder", method = RequestMethod.POST) |
|
269 |
// public boolean reorderIndicators(@PathVariable("stakeholderId") String stakeholderId, |
|
270 |
// @PathVariable("topicId") String topicId, |
|
271 |
// @PathVariable("categoryId") String categoryId, |
|
272 |
// @PathVariable("subcategoryId") String subcategoryId, |
|
273 |
// @PathVariable("type") String type, |
|
274 |
// @RequestBody List<Indicator> indicatorsFull) { |
|
275 |
// log.debug("reorder indicators"); |
|
276 |
// |
|
277 |
// Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId); |
|
278 |
// |
|
279 |
// if (stakeholder != null) { |
|
280 |
// |
|
281 |
// Topic<String> topic = topicDAO.findById(topicId); |
|
282 |
// if (topic != null) { |
|
283 |
// if (stakeholder.getTopics().contains(topicId)) { |
|
284 |
// |
|
285 |
// Category<String> category = categoryDAO.findById(categoryId); |
|
286 |
// if (category != null) { |
|
287 |
// if (topic.getCategories().contains(categoryId)) { |
|
288 |
// |
|
289 |
// SubCategory<String> subcategory = subCategoryDAO.findById(subcategoryId); |
|
290 |
// if (subcategory != null) { |
|
291 |
// if (category.getSubCategories().contains(subcategoryId)) { |
|
292 |
// |
|
293 |
// List<String> indicators = new ArrayList<>(); |
|
294 |
// for(Indicator indicator : indicatorsFull) { |
|
295 |
// indicators.add(indicator.getId()); |
|
296 |
// } |
|
297 |
// |
|
298 |
// if(type.equals("chart")) { |
|
299 |
// subcategory.setCharts(indicators); |
|
300 |
// } else if(type.equals("number")) { |
|
301 |
// subcategory.setNumbers(indicators); |
|
302 |
// } |
|
303 |
// |
|
304 |
// subCategoryDAO.save(subcategory); |
|
305 |
// indicators = null; |
|
306 |
// log.debug("Indicators reordered!"); |
|
307 |
// } else { |
|
308 |
// // EXCEPTION - SubCategory not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias(); -> Category: category.getAlias(); |
|
309 |
// throw new PathNotValidException("Reorder indicators: SubCategory with id: "+subcategoryId+" not found in Category: "+categoryId); |
|
310 |
// } |
|
311 |
// } else { |
|
312 |
// // EXCEPTION - SubCategory not found |
|
313 |
// throw new EntityNotFoundException("Reorder indicators: SubCategory with id: "+subcategoryId+" not found"); |
|
314 |
// } |
|
315 |
// } else { |
|
316 |
// // EXCEPTION - Category not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias(); |
|
317 |
// throw new PathNotValidException("Reorder indicators: Category with id: "+categoryId+" not found in Topic: "+topicId); |
|
318 |
// } |
|
319 |
// } else { |
|
320 |
// // EXCEPTION - Category not found |
|
321 |
// throw new EntityNotFoundException("Reorder indicators: Category with id: "+categoryId+" not found"); |
|
322 |
// } |
|
323 |
// } else { |
|
324 |
// // EXCEPTION - Topic not found in Stakeholder: stakeholder.getAlias(); |
|
325 |
// throw new PathNotValidException("Reorder indicators: Topic with id: "+topicId+" not found in Stakeholder: "+stakeholderId); |
|
326 |
// } |
|
327 |
// } else { |
|
328 |
// // EXCEPTION - Topic not found |
|
329 |
// throw new EntityNotFoundException("Reorder indicators: Topic with id: "+topicId+" not found"); |
|
330 |
// } |
|
331 |
// } else { |
|
332 |
// // EXCEPTION - Stakeholder not found |
|
333 |
// throw new EntityNotFoundException("Reorder indicators: Stakeholder with id: "+stakeholderId+" not found"); |
|
334 |
// } |
|
335 |
// return true; |
|
336 |
// } |
|
337 |
|
|
268 | 338 |
@RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/{subcategoryId}/{type}/reorder", method = RequestMethod.POST) |
269 |
public boolean reorderIndicators(@PathVariable("stakeholderId") String stakeholderId,
|
|
270 |
@PathVariable("topicId") String topicId,
|
|
271 |
@PathVariable("categoryId") String categoryId,
|
|
272 |
@PathVariable("subcategoryId") String subcategoryId,
|
|
273 |
@PathVariable("type") String type,
|
|
274 |
@RequestBody List<Indicator> indicatorsFull) {
|
|
339 |
public List<Indicator> reorderIndicators(@PathVariable("stakeholderId") String stakeholderId,
|
|
340 |
@PathVariable("topicId") String topicId, |
|
341 |
@PathVariable("categoryId") String categoryId, |
|
342 |
@PathVariable("subcategoryId") String subcategoryId, |
|
343 |
@PathVariable("type") String type, |
|
344 |
@RequestBody List<String> indicators) {
|
|
275 | 345 |
log.debug("reorder indicators"); |
276 | 346 |
|
277 | 347 |
Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId); |
... | ... | |
289 | 359 |
SubCategory<String> subcategory = subCategoryDAO.findById(subcategoryId); |
290 | 360 |
if (subcategory != null) { |
291 | 361 |
if (category.getSubCategories().contains(subcategoryId)) { |
292 |
|
|
293 |
List<String> indicators = new ArrayList<>(); |
|
294 |
for(Indicator indicator : indicatorsFull) { |
|
295 |
indicators.add(indicator.getId()); |
|
296 |
} |
|
297 |
|
|
298 | 362 |
if(type.equals("chart")) { |
299 | 363 |
subcategory.setCharts(indicators); |
300 | 364 |
} else if(type.equals("number")) { |
... | ... | |
302 | 366 |
} |
303 | 367 |
|
304 | 368 |
subCategoryDAO.save(subcategory); |
305 |
indicators = null; |
|
306 | 369 |
log.debug("Indicators reordered!"); |
307 | 370 |
} else { |
308 | 371 |
// EXCEPTION - SubCategory not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias(); -> Category: category.getAlias(); |
... | ... | |
332 | 395 |
// EXCEPTION - Stakeholder not found |
333 | 396 |
throw new EntityNotFoundException("Reorder indicators: Stakeholder with id: "+stakeholderId+" not found"); |
334 | 397 |
} |
335 |
return true; |
|
398 |
|
|
399 |
List<Indicator> indicatorsFull = new ArrayList<>(); |
|
400 |
for(String indicatorId : indicators) { |
|
401 |
indicatorsFull.add(indicatorDAO.findById(indicatorId)); |
|
402 |
} |
|
403 |
return indicatorsFull; |
|
336 | 404 |
} |
337 | 405 |
} |
Also available in: Unified diff
1. IndicatorController.java: Reorder method changed (parameter is List<String> and return value is List<Indicator>).
2. CategoryController.java: Default subcategory has name "Overview", alias "overview" and isDefault is true.