uoa-monitor-service/src/main/java/eu/dnetlib/uoamonitorservice/controllers/StakeholderController.java

297 lines
12 KiB
Java
Raw Normal View History

2019-11-04 10:03:49 +01:00
package eu.dnetlib.uoamonitorservice.controllers;
//import com.fasterxml.jackson.core.type.TypeReference;
//import com.fasterxml.jackson.databind.ObjectMapper;
import eu.dnetlib.uoamonitorservice.dao.*;
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
import eu.dnetlib.uoamonitorservice.entities.*;
import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException;
2019-11-04 10:03:49 +01:00
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@RestController
@CrossOrigin(origins = "*")
public class StakeholderController {
private final Logger log = Logger.getLogger(this.getClass());
@Autowired
private StakeholderDAO stakeholderDAO;
@Autowired
private TopicDAO topicDAO;
@Autowired
private CategoryDAO categoryDAO;
@Autowired
private SubCategoryDAO subCategoryDAO;
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
@Autowired
private IndicatorDAO indicatorDAO;
@Autowired
private TopicController topicController;
@RequestMapping(value = "/build-stakeholder", method = RequestMethod.POST)
public Stakeholder<Topic<Category<SubCategory<Indicator>>>> buildFullStakeholder(@RequestBody Stakeholder<Topic<Category<SubCategory<Indicator>>>> stakeholderFull) {
log.debug("build stakeholder");
Stakeholder<String> stakeholder = new Stakeholder<>(stakeholderFull);
List<String> topics = new ArrayList<>();
List<Topic<Category<SubCategory<Indicator>>>> topicsFull = new ArrayList<>();
for(Topic topic : stakeholderFull.getTopics()) {
Topic<Category<SubCategory<Indicator>>> topicFull = topicController.buildTopic(topic);
topicsFull.add(topicFull);
topics.add(topicFull.getId());
}
stakeholderFull.setTopics(topicsFull);
stakeholder.setTopics(topics);
Stakeholder<String> stakeholderSaved = stakeholderDAO.save(stakeholder);
stakeholderFull.setId(stakeholderSaved.getId());
return stakeholderFull;
//return null;
}
public Stakeholder setFullEntities(Stakeholder<String> stakeholder) {
Stakeholder<Topic> stakeholderFull = new Stakeholder<>(stakeholder);
List<Topic> topics = new ArrayList<>();
for (String topicId: (List<String>)stakeholder.getTopics()) {
Topic<String> topic = topicDAO.findById(topicId);
Topic<Category> topicFull = new Topic<Category>(topic);
List<Category> categories = new ArrayList<>();
for(String categoryId : topic.getCategories()) {
Category<String> category = categoryDAO.findById(categoryId);
Category<SubCategory> categoryFull = new Category<SubCategory>(category);
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
List<SubCategory> subCategories = new ArrayList<>();
for(String subCategoryId : category.getSubCategories()) {
SubCategory<String> subCategory = subCategoryDAO.findById(subCategoryId);
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
SubCategory subCategoryFull = new SubCategory<Indicator>(subCategory);
List<Indicator> charts = new ArrayList<>();
for(String indicatorId : subCategory.getCharts()) {
charts.add(indicatorDAO.findById(indicatorId));
}
subCategoryFull.setCharts(charts);
List<Indicator> numbers = new ArrayList<>();
for(String indicatorId : subCategory.getNumbers()) {
numbers.add(indicatorDAO.findById(indicatorId));
}
subCategoryFull.setNumbers(numbers);
subCategories.add(subCategoryFull);
}
categoryFull.setSubCategories(subCategories);
categories.add(categoryFull);
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
}
topicFull.setCategories(categories);
topics.add(topicFull);
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
}
stakeholderFull.setTopics(topics);
return stakeholderFull;
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
}
2019-11-04 10:03:49 +01:00
@RequestMapping(value = "/stakeholder/all", method = RequestMethod.GET)
public List<Stakeholder> getAllStakeholders(@RequestParam(required = false) String type) {
List<Stakeholder> stakeholders;
if(type == null) {
stakeholders = stakeholderDAO.findAll();
} else {
stakeholders = stakeholderDAO.findByType(type);
}
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
List<Stakeholder> stakeholdersFull = new ArrayList<>();
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
for(Stakeholder stakeholder : stakeholders) {
stakeholdersFull.add(this.setFullEntities(stakeholder));
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
}
return stakeholdersFull;
2019-11-04 10:03:49 +01:00
}
@RequestMapping(value = "/stakeholder/default", method = RequestMethod.GET)
public List<Stakeholder> getAllDefaultStakeholders(@RequestParam(required = false) String type) {
List<Stakeholder> stakeholders;
if(type == null) {
stakeholders = stakeholderDAO.findByIsDefaultProfile(true);
} else {
stakeholders = stakeholderDAO.findByIsDefaultProfileAndType(true, type);
}
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
List<Stakeholder> stakeholdersFull = new ArrayList<>();
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
for(Stakeholder stakeholder : stakeholders) {
stakeholdersFull.add(this.setFullEntities(stakeholder));
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
}
return stakeholdersFull;
2019-11-04 10:03:49 +01:00
}
@RequestMapping(value = "/stakeholder", method = RequestMethod.GET)
public List<Stakeholder> getAllRealStakeholders(@RequestParam(required = false) String type) {
List<Stakeholder> stakeholders;
if(type == null) {
stakeholders = stakeholderDAO.findByIsDefaultProfile(false);
} else {
stakeholders = stakeholderDAO.findByIsDefaultProfileAndType(false, type);
}
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
List<Stakeholder> stakeholdersFull = new ArrayList<>();
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
for(Stakeholder stakeholder : stakeholders) {
stakeholdersFull.add(this.setFullEntities(stakeholder));
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
}
2019-11-04 10:03:49 +01:00
log.debug(new Date());
return stakeholdersFull;
2019-11-04 10:03:49 +01:00
}
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
@RequestMapping(value = "/stakeholder/{alias}", method = RequestMethod.GET)
public Stakeholder getStakeholder(@PathVariable("alias") String alias) {
Stakeholder<String> stakeholder = stakeholderDAO.findByAlias(alias);
if(stakeholder == null) {
// EXCEPTION - Stakeholder not found
throw new EntityNotFoundException("Get stakeholder: Stakeholder with alias: "+alias+" not found");
}
return this.setFullEntities(stakeholder);
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
}
@RequestMapping(value = "/save", method = RequestMethod.POST)
public Stakeholder<Topic> saveStakeholder(@RequestBody Stakeholder<Topic> stakeholderFull) {
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
log.debug("save stakeholder");
// if(stakeholderFull == null) {
// log.debug("stakeholder null");
// // EXCEPTION - Parameter for Stakeholder is not accepted
// }
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
Stakeholder<String> stakeholder = new Stakeholder<>(stakeholderFull);
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
List<String> topics = new ArrayList<>();
for(Topic topic : stakeholderFull.getTopics()) {
topics.add(topic.getId());
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
}
stakeholder.setTopics(topics);
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
Stakeholder<String> stakeholderSaved = stakeholderDAO.save(stakeholder);
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
stakeholderFull.setId(stakeholderSaved.getId());
topics = null;
stakeholder = null;
stakeholderSaved = null;
return stakeholderFull;
}
@RequestMapping(value = "/{stakeholderId}/delete", method = RequestMethod.DELETE)
public boolean deleteStakeholder(@PathVariable("stakeholderId") String stakeholderId) {
log.debug("delete stakeholder");
Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
if(stakeholder != null) {
for(String topicId : stakeholder.getTopics()) {
Topic<String> topic = topicDAO.findById(topicId);
if (topic == null) {
// EXCEPTION - Topic not found
throw new EntityNotFoundException("Delete stakeholder: Topic with id: "+topicId+" not found (topic exists in stakeholder: "+stakeholderId+")");
}
for (String categoryId : topic.getCategories()) {
Category<String> category = categoryDAO.findById(categoryId);
if (category == null) {
// EXCEPTION - Category not found
throw new EntityNotFoundException("Delete stakeholder: Category with id: "+categoryId+" not found (category exists in topic: "+topicId+")");
}
for (String subCategoryId : category.getSubCategories()) {
SubCategory<String> subcategory = subCategoryDAO.findById(subCategoryId);
if (subcategory == null) {
// EXCEPTION - SubCategory not found
throw new EntityNotFoundException("Delete stakeholder: SubCategory with id: "+subCategoryId+" not found (subcategory exists in category: "+categoryId+")");
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
}
for (String chartId : subcategory.getCharts()) {
indicatorDAO.delete(chartId);
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
}
subcategory.setCharts(null);
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
for (String numberId : subcategory.getNumbers()) {
indicatorDAO.delete(numberId);
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
}
subcategory.setNumbers(null);
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
subCategoryDAO.delete(subCategoryId);
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
}
category.setSubCategories(null);
categoryDAO.delete(categoryId);
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
}
topic.setCategories(null);
topicDAO.delete(topicId);
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
}
stakeholder.setTopics(null);
stakeholderDAO.delete(stakeholderId);
log.debug("Stakeholder deleted!");
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
} else {
// EXCEPTION - Stakeholder not found
throw new EntityNotFoundException("Delete stakeholder: Stakeholder with id: "+stakeholderId+" not found");
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields. 2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields. 3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'. 4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' & make charts and numbers (List) generic (String or Indicator). 5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number". 6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image. 7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias) 8. StakeholderController.java: a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects (used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias)) b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias} c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id} e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
}
return true;
}
// The following are not supposed to be used
// @RequestMapping(value = "/stakeholder/dates", method = RequestMethod.GET)
// public List<Date> getAllStakeholderDates() {
// List<Stakeholder> profiles = stakeholderDAO.findAll();
// List<Date> profileDates = new ArrayList<>();
//
// int i=0;
// for(Stakeholder profile : profiles) {
// log.debug(profile.getCreationDate());
// profileDates.add(profile.getCreationDate());
// log.debug(profileDates.get(i));
// i++;
// }
// return profileDates;
// }
//
// @RequestMapping(value = "/stakeholder/dates1", method = RequestMethod.GET)
// public List<String> getAllStakeholderDates1() {
// List<Stakeholder> profiles = stakeholderDAO.findAll();
// List<String> profileDates = new ArrayList<>();
//
// for(Stakeholder profile : profiles) {
// log.debug(profile.getCreationDate().toString());
// profileDates.add(profile.getCreationDate().toString());
// }
// return profileDates;
// }
//
// @RequestMapping(value = "/stakeholder/dates2", method = RequestMethod.GET)
// public List<String> getAllStakeholderDates2() {
// List<Stakeholder> profiles = stakeholderDAO.findAll();
// List<String> profileDates = new ArrayList<>();
// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//
// for(Stakeholder profile : profiles) {
// log.debug(format.format(profile.getCreationDate()));
// profileDates.add(format.format(profile.getCreationDate()));
// }
// return profileDates;
// }
2019-11-04 10:03:49 +01:00
}