Revision 57964
Added by Konstantina Galouni about 4 years ago
CategoryController.java | ||
---|---|---|
29 | 29 |
private SubCategoryDAO subCategoryDAO; |
30 | 30 |
|
31 | 31 |
@Autowired |
32 |
private SectionDAO sectionDAO; |
|
33 |
|
|
34 |
@Autowired |
|
32 | 35 |
private IndicatorDAO indicatorDAO; |
33 | 36 |
|
34 | 37 |
@Autowired |
... | ... | |
39 | 42 |
|
40 | 43 |
List<String> subCategories = new ArrayList<>(); |
41 | 44 |
List<SubCategory> subCategoriesFull = new ArrayList<>(); |
42 |
for(SubCategory<Indicator> subCategory : categoryFull.getSubCategories()) {
|
|
43 |
SubCategory<Indicator> subcategoryFull = subCategoryController.buildSubCategory(subCategory);
|
|
45 |
for(SubCategory<Section<Indicator>> subCategory : categoryFull.getSubCategories()) {
|
|
46 |
SubCategory<Section<Indicator>> subcategoryFull = subCategoryController.buildSubCategory(subCategory);
|
|
44 | 47 |
subCategoriesFull.add(subcategoryFull); |
45 | 48 |
subCategories.add(subcategoryFull.getId()); |
46 | 49 |
} |
... | ... | |
192 | 195 |
// EXCEPTION - SubCategory not found |
193 | 196 |
throw new EntityNotFoundException("Delete category: SubCategory with id: "+subCategoryId+" not found (subcategory exists in category: "+categoryId+")"); |
194 | 197 |
} |
195 |
for(String chartId : subcategory.getCharts()) { |
|
196 |
indicatorDAO.delete(chartId); |
|
198 |
|
|
199 |
for(String chartSectionId : subcategory.getCharts()) { |
|
200 |
Section<String> chartSection = sectionDAO.findById(chartSectionId); |
|
201 |
if (chartSection == null) { |
|
202 |
// EXCEPTION - Section not found |
|
203 |
throw new EntityNotFoundException("Delete topic: Section with id: "+chartSectionId+" not found (section exists in subcategory: "+subCategoryId+")"); |
|
204 |
} |
|
205 |
|
|
206 |
for (String chartId : chartSection.getIndicators()) { |
|
207 |
indicatorDAO.delete(chartId); |
|
208 |
} |
|
209 |
subcategory.setCharts(null); |
|
210 |
sectionDAO.delete(chartSectionId); |
|
197 | 211 |
} |
198 |
subcategory.setCharts(null); |
|
199 | 212 |
|
200 |
for(String numberId : subcategory.getNumbers()) { |
|
201 |
indicatorDAO.delete(numberId); |
|
213 |
for(String numberSectionId : subcategory.getNumbers()) { |
|
214 |
Section<String> numberSection = sectionDAO.findById(numberSectionId); |
|
215 |
if (numberSection == null) { |
|
216 |
// EXCEPTION - Section not found |
|
217 |
throw new EntityNotFoundException("Delete topic: Section with id: "+numberSectionId+" not found (section exists in subcategory: "+subCategoryId+")"); |
|
218 |
} |
|
219 |
|
|
220 |
for (String numberId : numberSection.getIndicators()) { |
|
221 |
indicatorDAO.delete(numberId); |
|
222 |
} |
|
223 |
subcategory.setNumbers(null); |
|
224 |
sectionDAO.delete(numberSectionId); |
|
202 | 225 |
} |
203 |
subcategory.setNumbers(null); |
|
204 | 226 |
|
205 | 227 |
subCategoryDAO.delete(subCategoryId); |
206 | 228 |
} |
Also available in: Unified diff
[Trunk | Monitor Service]:
1. Section entity level added. Hierarchy changed from: Stakeholder > Topic > Category > SubCategory > Indicator to: Stakeholder > Topic > Category > SubCategory > Section > Indicator.
2. Section.java & SectionDAO.java & MongoDBSectionDAO.java & SectionController.java: New entity 'Section', DAOs for Section, Controller for section added.
3. In all controllers fix hierarchy of model to include Section.
4. SubCategoryController.java & IndicatorController.java: Helper method 'checkForExceptions()' added (instead of checking in every method separately).