2019-11-04 10:03:49 +01:00
package eu.dnetlib.uoamonitorservice.controllers ;
2021-02-24 20:22:19 +01:00
import eu.dnetlib.uoaadmintoolslibrary.handlers.utils.RolesUtils ;
2019-11-22 16:50:59 +01:00
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.* ;
2019-11-22 16:50:59 +01:00
import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException ;
[Trunk | Monitor Service]:
1. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java && SectionController.java && IndicatorController.java:
a. Comment logs for get requests.
b. Use "ForbiddenException" instead of "AccessDeniedException"
c. On /save, if full entity has id (already in DB), if not found in DB throw EntityNotFoundException.
d. Get children (e.g. when saving a Topic, get its categories) from DB.
2. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java:
In /reorder, if there are in DB, ids that are missing from reordered list, do reordering and add in the end of list the missing ids.
3. ReorderEvent.java: [NEW] Added class ReorderEvent with fields "action" (String), "target" (String), "ids" (List<String>) (used in IndicatorController.java).
4. IndicatorController.java:
a. In /reorder, @RequestBody changed from List<String> indicators to ReorderEvent reorderEvent.
b. If there are in DB, ids that are missing from reordered list AND missing id is not moved to other section (action = removed and target = missing id), do reordering and add in the end of list the missing ids.
5. ExceptionsHandler.java: exception handler methods "invalidInput()", "nullPointerException()", "notFoundException()" moved to "Admin Tools Library" - "accessDeniedException()" is removed.
6. responses/ExceptionResponse.java: File and folder deleted (moved to "Admin Tools Library").
7. RolesUtils.java: Added method "isLoggedIn()" (checks if no roles for user, or user has role "ROLE_ANONYMOUS").
2020-12-09 15:24:27 +01:00
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException ;
2019-11-04 10:03:49 +01:00
import org.apache.log4j.Logger ;
import org.springframework.beans.factory.annotation.Autowired ;
2020-11-11 13:45:59 +01:00
import org.springframework.security.access.AccessDeniedException ;
[Trunk | Monitor Service]:
1. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java && SectionController.java && IndicatorController.java:
a. Comment logs for get requests.
b. Use "ForbiddenException" instead of "AccessDeniedException"
c. On /save, if full entity has id (already in DB), if not found in DB throw EntityNotFoundException.
d. Get children (e.g. when saving a Topic, get its categories) from DB.
2. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java:
In /reorder, if there are in DB, ids that are missing from reordered list, do reordering and add in the end of list the missing ids.
3. ReorderEvent.java: [NEW] Added class ReorderEvent with fields "action" (String), "target" (String), "ids" (List<String>) (used in IndicatorController.java).
4. IndicatorController.java:
a. In /reorder, @RequestBody changed from List<String> indicators to ReorderEvent reorderEvent.
b. If there are in DB, ids that are missing from reordered list AND missing id is not moved to other section (action = removed and target = missing id), do reordering and add in the end of list the missing ids.
5. ExceptionsHandler.java: exception handler methods "invalidInput()", "nullPointerException()", "notFoundException()" moved to "Admin Tools Library" - "accessDeniedException()" is removed.
6. responses/ExceptionResponse.java: File and folder deleted (moved to "Admin Tools Library").
7. RolesUtils.java: Added method "isLoggedIn()" (checks if no roles for user, or user has role "ROLE_ANONYMOUS").
2020-12-09 15:24:27 +01:00
import org.springframework.security.access.AuthorizationServiceException ;
2020-11-11 13:45:59 +01:00
import org.springframework.security.access.prepost.PreAuthorize ;
2019-11-04 10:03:49 +01:00
import org.springframework.web.bind.annotation.* ;
import java.util.ArrayList ;
import java.util.Date ;
2020-11-11 13:45:59 +01:00
import java.util.Iterator ;
2019-11-04 10:03:49 +01:00
import java.util.List ;
@RestController
@CrossOrigin ( origins = " * " )
public class StakeholderController {
private final Logger log = Logger . getLogger ( this . getClass ( ) ) ;
2020-11-11 13:45:59 +01:00
@Autowired
private RolesUtils rolesUtils ;
2019-11-04 10:03:49 +01:00
@Autowired
private StakeholderDAO stakeholderDAO ;
2019-11-22 16:50:59 +01:00
@Autowired
private TopicDAO topicDAO ;
@Autowired
private CategoryDAO categoryDAO ;
@Autowired
private SubCategoryDAO subCategoryDAO ;
2020-01-10 11:48:24 +01:00
@Autowired
private SectionDAO sectionDAO ;
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 ;
2019-11-22 16:50:59 +01:00
@Autowired
private TopicController topicController ;
[Trunk | Monitor Service]:
1. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java && SectionController.java && IndicatorController.java:
a. Comment logs for get requests.
b. Use "ForbiddenException" instead of "AccessDeniedException"
c. On /save, if full entity has id (already in DB), if not found in DB throw EntityNotFoundException.
d. Get children (e.g. when saving a Topic, get its categories) from DB.
2. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java:
In /reorder, if there are in DB, ids that are missing from reordered list, do reordering and add in the end of list the missing ids.
3. ReorderEvent.java: [NEW] Added class ReorderEvent with fields "action" (String), "target" (String), "ids" (List<String>) (used in IndicatorController.java).
4. IndicatorController.java:
a. In /reorder, @RequestBody changed from List<String> indicators to ReorderEvent reorderEvent.
b. If there are in DB, ids that are missing from reordered list AND missing id is not moved to other section (action = removed and target = missing id), do reordering and add in the end of list the missing ids.
5. ExceptionsHandler.java: exception handler methods "invalidInput()", "nullPointerException()", "notFoundException()" moved to "Admin Tools Library" - "accessDeniedException()" is removed.
6. responses/ExceptionResponse.java: File and folder deleted (moved to "Admin Tools Library").
7. RolesUtils.java: Added method "isLoggedIn()" (checks if no roles for user, or user has role "ROLE_ANONYMOUS").
2020-12-09 15:24:27 +01:00
@PreAuthorize ( " isAuthenticated() " )
@RequestMapping ( value = " /stakeholder/alias " , method = RequestMethod . GET )
public List < String > getAllReservedStakeholderAlias ( ) {
// log.debug("get all stakeholder reserved alias-es");
List < String > stakeholderAlias = new ArrayList < > ( ) ;
List < Stakeholder > stakeholders = stakeholderDAO . findAll ( ) ;
if ( stakeholders ! = null ) {
stakeholders . forEach ( stakeholder - > {
stakeholderAlias . add ( stakeholder . getAlias ( ) ) ;
} ) ;
}
stakeholderAlias . add ( " all " ) ;
stakeholderAlias . add ( " default " ) ;
stakeholderAlias . add ( " alias " ) ;
return stakeholderAlias ;
}
2020-11-11 13:45:59 +01:00
// @PreAuthorize("isAuthenticated()")
@PreAuthorize ( " hasAnyAuthority( " +
" @AuthorizationService.PORTAL_ADMIN, " +
" @AuthorizationService.curator(#stakeholderFull.getType())) " )
2019-11-22 16:50:59 +01:00
@RequestMapping ( value = " /build-stakeholder " , method = RequestMethod . POST )
2020-01-10 11:48:24 +01:00
public Stakeholder < Topic < Category < SubCategory < Section < Indicator > > > > > buildFullStakeholder ( @RequestBody Stakeholder < Topic < Category < SubCategory < Section < Indicator > > > > > stakeholderFull ) {
2019-11-22 16:50:59 +01:00
log . debug ( " build stakeholder " ) ;
2019-12-19 16:04:25 +01:00
log . debug ( " Alias: " + stakeholderFull . getAlias ( ) ) ;
2019-11-22 16:50:59 +01:00
Stakeholder < String > stakeholder = new Stakeholder < > ( stakeholderFull ) ;
List < String > topics = new ArrayList < > ( ) ;
2020-01-10 11:48:24 +01:00
List < Topic < Category < SubCategory < Section < Indicator > > > > > topicsFull = new ArrayList < > ( ) ;
2019-11-22 16:50:59 +01:00
for ( Topic topic : stakeholderFull . getTopics ( ) ) {
2020-01-10 11:48:24 +01:00
Topic < Category < SubCategory < Section < Indicator > > > > topicFull = topicController . buildTopic ( topic ) ;
2019-11-22 16:50:59 +01:00
topicsFull . add ( topicFull ) ;
topics . add ( topicFull . getId ( ) ) ;
}
stakeholderFull . setTopics ( topicsFull ) ;
stakeholder . setTopics ( topics ) ;
2019-12-19 16:04:25 +01:00
Date date = new Date ( ) ;
stakeholder . setCreationDate ( date ) ;
stakeholder . setUpdateDate ( date ) ;
stakeholderFull . setCreationDate ( date ) ;
stakeholderFull . setUpdateDate ( date ) ;
2019-11-22 16:50:59 +01:00
Stakeholder < String > stakeholderSaved = stakeholderDAO . save ( stakeholder ) ;
stakeholderFull . setId ( stakeholderSaved . getId ( ) ) ;
return stakeholderFull ;
//return null;
}
2020-11-11 13:45:59 +01:00
public Stakeholder setFullEntities ( Stakeholder < String > stakeholder , List < String > roles ) {
boolean addAll = false ;
boolean addPublicAndRestricted = false ;
// if(roles == null
// || roles.contains(authorizationService.PORTAL_ADMIN)
// || roles.contains(authorizationService.curator(stakeholder.getType()))
// || roles.contains(authorizationService.manager(stakeholder.getType(), stakeholder.getAlias()))) {
if ( rolesUtils . hasUpdateAuthority ( roles , stakeholder . getType ( ) , stakeholder . getAlias ( ) ) ) {
//if(visibility == null || visibility == (Visibility.PRIVATE)) {
addAll = true ;
//}
//if(visibility == null || visibility == (Visibility.PRIVATE) || visibility == (Visibility.RESTRICTED)) {
addPublicAndRestricted = true ;
//}
// } else if(roles != null && roles.contains(authorizationService.member(stakeholder.getType(), stakeholder.getAlias()))) {
} else if ( rolesUtils . isMember ( roles , stakeholder . getType ( ) , stakeholder . getAlias ( ) ) ) {
//if(visibility == null || visibility == (Visibility.PRIVATE) || visibility == (Visibility.RESTRICTED)) {
addPublicAndRestricted = true ;
//}
}
2019-11-22 16:50:59 +01:00
Stakeholder < Topic > stakeholderFull = new Stakeholder < > ( stakeholder ) ;
List < Topic > topics = new ArrayList < > ( ) ;
for ( String topicId : ( List < String > ) stakeholder . getTopics ( ) ) {
Topic < String > topic = topicDAO . findById ( topicId ) ;
2019-12-19 16:04:25 +01:00
if ( topic = = null ) {
// EXCEPTION - Topic not found
throw new EntityNotFoundException ( " Get stakeholder: Topic with id: " + topicId + " not found (topic exists in stakeholder: " + stakeholder . getId ( ) + " ) " ) ;
}
2020-11-11 13:45:59 +01:00
if ( ( ! addAll & & topic . getVisibility ( ) = = Visibility . PRIVATE )
| | ( ! addPublicAndRestricted & & topic . getVisibility ( ) = = Visibility . RESTRICTED ) ) {
continue ;
}
2019-11-22 16:50:59 +01:00
Topic < Category > topicFull = new Topic < Category > ( topic ) ;
List < Category > categories = new ArrayList < > ( ) ;
for ( String categoryId : topic . getCategories ( ) ) {
Category < String > category = categoryDAO . findById ( categoryId ) ;
2019-12-19 16:04:25 +01:00
if ( category = = null ) {
// EXCEPTION - Category not found
throw new EntityNotFoundException ( " Get stakeholder: Category with id: " + categoryId + " not found (category exists in topic: " + topicId + " ) " ) ;
}
2020-11-11 13:45:59 +01:00
if ( ( ! addAll & & category . getVisibility ( ) = = Visibility . PRIVATE )
| | ( ! addPublicAndRestricted & & category . getVisibility ( ) = = Visibility . RESTRICTED ) ) {
continue ;
}
2019-11-22 16:50:59 +01:00
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 < > ( ) ;
2019-11-22 16:50:59 +01:00
for ( String subCategoryId : category . getSubCategories ( ) ) {
SubCategory < String > subCategory = subCategoryDAO . findById ( subCategoryId ) ;
2019-12-19 16:04:25 +01:00
if ( subCategory = = null ) {
// EXCEPTION - SubCategory not found
throw new EntityNotFoundException ( " Get stakeholder: SubCategory with id: " + subCategoryId + " not found (subCategory exists in category: " + categoryId + " ) " ) ;
}
2020-11-11 13:45:59 +01:00
if ( ( ! addAll & & subCategory . getVisibility ( ) = = Visibility . PRIVATE )
| | ( ! addPublicAndRestricted & & subCategory . getVisibility ( ) = = Visibility . RESTRICTED ) ) {
continue ;
}
2020-01-10 11:48:24 +01:00
SubCategory subCategoryFull = new SubCategory < Section < Indicator > > ( subCategory ) ;
List < Section > sectionsCharts = new ArrayList < > ( ) ;
for ( String sectionId : subCategory . getCharts ( ) ) {
2020-11-11 13:45:59 +01:00
sectionsCharts . add ( getSectionFull ( sectionId , subCategoryId , addAll , addPublicAndRestricted ) ) ;
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
}
2020-01-10 11:48:24 +01:00
subCategoryFull . setCharts ( sectionsCharts ) ;
List < Section > sectionsNumbers = new ArrayList < > ( ) ;
for ( String sectionId : subCategory . getNumbers ( ) ) {
2020-11-11 13:45:59 +01:00
sectionsNumbers . add ( getSectionFull ( sectionId , subCategoryId , addAll , addPublicAndRestricted ) ) ;
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
}
2020-01-10 11:48:24 +01:00
subCategoryFull . setNumbers ( sectionsNumbers ) ;
// List<Indicator> charts = new ArrayList<>();
// for(String indicatorId : subCategory.getCharts()) {
// Indicator indicator = indicatorDAO.findById(indicatorId);
// if(indicator == null) {
// // EXCEPTION - Indicator not found
// throw new EntityNotFoundException("Get stakeholder: Indicator with id: "+indicatorId+" not found (indicator exists in subCategory: "+subCategoryId+")");
// }
// charts.add(indicator);
// }
// subCategoryFull.setCharts(charts);
//
// List<Indicator> numbers = new ArrayList<>();
// for (String indicatorId : subCategory.getNumbers()) {
// Indicator indicator = indicatorDAO.findById(indicatorId);
// if (indicator == null) {
// // EXCEPTION - Indicator not found
// throw new EntityNotFoundException("Get stakeholder: Indicator with id: " + indicatorId + " not found (indicator exists in subCategory: " + subCategoryId + ")");
// }
// numbers.add(indicator);
// }
// subCategoryFull.setNumbers(numbers);
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
subCategories . add ( subCategoryFull ) ;
}
2019-11-22 16:50:59 +01:00
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
}
2019-11-22 16:50:59 +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
}
2019-11-22 16:50:59 +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
}
[Trunk | Monitor Service]:
1. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java && SectionController.java && IndicatorController.java:
a. Comment logs for get requests.
b. Use "ForbiddenException" instead of "AccessDeniedException"
c. On /save, if full entity has id (already in DB), if not found in DB throw EntityNotFoundException.
d. Get children (e.g. when saving a Topic, get its categories) from DB.
2. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java:
In /reorder, if there are in DB, ids that are missing from reordered list, do reordering and add in the end of list the missing ids.
3. ReorderEvent.java: [NEW] Added class ReorderEvent with fields "action" (String), "target" (String), "ids" (List<String>) (used in IndicatorController.java).
4. IndicatorController.java:
a. In /reorder, @RequestBody changed from List<String> indicators to ReorderEvent reorderEvent.
b. If there are in DB, ids that are missing from reordered list AND missing id is not moved to other section (action = removed and target = missing id), do reordering and add in the end of list the missing ids.
5. ExceptionsHandler.java: exception handler methods "invalidInput()", "nullPointerException()", "notFoundException()" moved to "Admin Tools Library" - "accessDeniedException()" is removed.
6. responses/ExceptionResponse.java: File and folder deleted (moved to "Admin Tools Library").
7. RolesUtils.java: Added method "isLoggedIn()" (checks if no roles for user, or user has role "ROLE_ANONYMOUS").
2020-12-09 15:24:27 +01:00
// private SubCategory setFullSubcategory(SubCategory subCategory) {
// SubCategory subCategoryFull = new SubCategory<Section<Indicator>>(subCategory);
//
// List<Section> sectionsCharts = new ArrayList<>();
//
// for(String sectionId : subCategory.getCharts()) {
// sectionsCharts.add(getSectionFull(sectionId, subCategoryId, addAll, addPublicAndRestricted));
// }
// subCategoryFull.setCharts(sectionsCharts);
//
// List<Section> sectionsNumbers = new ArrayList<>();
//
// for(String sectionId : subCategory.getNumbers()) {
// sectionsNumbers.add(getSectionFull(sectionId, subCategoryId, addAll, addPublicAndRestricted));
// }
// subCategoryFull.setNumbers(sectionsNumbers);
// }
2020-11-11 13:45:59 +01:00
private Section getSectionFull ( String sectionId , String subCategoryId , boolean addAll , boolean addPublicAndRestricted ) {
2020-01-10 11:48:24 +01:00
Section < String > section = sectionDAO . findById ( sectionId ) ;
if ( section = = null ) {
// EXCEPTION - Section not found
throw new EntityNotFoundException ( " Get stakeholder: Section with id: " + sectionId + " not found (section exists in subCategory: " + subCategoryId + " ) " ) ;
}
2020-11-11 13:45:59 +01:00
2020-01-10 11:48:24 +01:00
Section sectionFull = new Section < Indicator > ( section ) ;
List < Indicator > indicators = new ArrayList < > ( ) ;
for ( String indicatorId : section . getIndicators ( ) ) {
Indicator indicator = indicatorDAO . findById ( indicatorId ) ;
if ( indicator = = null ) {
// EXCEPTION - Indicator not found
throw new EntityNotFoundException ( " Get stakeholder: Indicator with id: " + indicatorId + " not found (indicator exists in section: " + sectionId + " ) " ) ;
}
2020-11-11 13:45:59 +01:00
if ( ( ! addAll & & indicator . getVisibility ( ) = = Visibility . PRIVATE )
| | ( ! addPublicAndRestricted & & indicator . getVisibility ( ) = = Visibility . RESTRICTED ) ) {
continue ;
}
2020-01-10 11:48:24 +01:00
indicators . add ( indicator ) ;
}
sectionFull . setIndicators ( indicators ) ;
return sectionFull ;
}
2020-11-11 13:45:59 +01:00
@PreAuthorize ( " hasAnyAuthority( " +
" @AuthorizationService.PORTAL_ADMIN) " )
2019-11-04 10:03:49 +01:00
@RequestMapping ( value = " /stakeholder/all " , method = RequestMethod . GET )
public List < Stakeholder > getAllStakeholders ( @RequestParam ( required = false ) String type ) {
[Trunk | Monitor Service]:
1. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java && SectionController.java && IndicatorController.java:
a. Comment logs for get requests.
b. Use "ForbiddenException" instead of "AccessDeniedException"
c. On /save, if full entity has id (already in DB), if not found in DB throw EntityNotFoundException.
d. Get children (e.g. when saving a Topic, get its categories) from DB.
2. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java:
In /reorder, if there are in DB, ids that are missing from reordered list, do reordering and add in the end of list the missing ids.
3. ReorderEvent.java: [NEW] Added class ReorderEvent with fields "action" (String), "target" (String), "ids" (List<String>) (used in IndicatorController.java).
4. IndicatorController.java:
a. In /reorder, @RequestBody changed from List<String> indicators to ReorderEvent reorderEvent.
b. If there are in DB, ids that are missing from reordered list AND missing id is not moved to other section (action = removed and target = missing id), do reordering and add in the end of list the missing ids.
5. ExceptionsHandler.java: exception handler methods "invalidInput()", "nullPointerException()", "notFoundException()" moved to "Admin Tools Library" - "accessDeniedException()" is removed.
6. responses/ExceptionResponse.java: File and folder deleted (moved to "Admin Tools Library").
7. RolesUtils.java: Added method "isLoggedIn()" (checks if no roles for user, or user has role "ROLE_ANONYMOUS").
2020-12-09 15:24:27 +01:00
// log.debug("get all stakeholders" + (type != null ? " with type: "+type : ""));
2019-12-19 16:04:25 +01:00
2019-11-04 10:03:49 +01:00
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
2019-11-22 16:50:59 +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 ) {
2020-11-11 13:45:59 +01:00
List < String > roles = rolesUtils . getRoles ( ) ;
stakeholdersFull . add ( this . setFullEntities ( stakeholder , roles ) ) ;
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-22 16:50:59 +01:00
return stakeholdersFull ;
2019-11-04 10:03:49 +01:00
}
2020-11-11 13:45:59 +01:00
@PreAuthorize ( " isAuthenticated() " )
2019-11-04 10:03:49 +01:00
@RequestMapping ( value = " /stakeholder/default " , method = RequestMethod . GET )
public List < Stakeholder > getAllDefaultStakeholders ( @RequestParam ( required = false ) String type ) {
[Trunk | Monitor Service]:
1. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java && SectionController.java && IndicatorController.java:
a. Comment logs for get requests.
b. Use "ForbiddenException" instead of "AccessDeniedException"
c. On /save, if full entity has id (already in DB), if not found in DB throw EntityNotFoundException.
d. Get children (e.g. when saving a Topic, get its categories) from DB.
2. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java:
In /reorder, if there are in DB, ids that are missing from reordered list, do reordering and add in the end of list the missing ids.
3. ReorderEvent.java: [NEW] Added class ReorderEvent with fields "action" (String), "target" (String), "ids" (List<String>) (used in IndicatorController.java).
4. IndicatorController.java:
a. In /reorder, @RequestBody changed from List<String> indicators to ReorderEvent reorderEvent.
b. If there are in DB, ids that are missing from reordered list AND missing id is not moved to other section (action = removed and target = missing id), do reordering and add in the end of list the missing ids.
5. ExceptionsHandler.java: exception handler methods "invalidInput()", "nullPointerException()", "notFoundException()" moved to "Admin Tools Library" - "accessDeniedException()" is removed.
6. responses/ExceptionResponse.java: File and folder deleted (moved to "Admin Tools Library").
7. RolesUtils.java: Added method "isLoggedIn()" (checks if no roles for user, or user has role "ROLE_ANONYMOUS").
2020-12-09 15:24:27 +01:00
// log.debug("get all default stakeholders" + (type != null ? " with type: "+type : ""));
2019-12-19 16:04:25 +01:00
2019-11-04 10:03:49 +01:00
List < Stakeholder > stakeholders ;
if ( type = = null ) {
2019-12-19 16:04:25 +01:00
stakeholders = stakeholderDAO . findByDefaultId ( null ) ;
2019-11-04 10:03:49 +01:00
} else {
2019-12-19 16:04:25 +01:00
stakeholders = stakeholderDAO . findByDefaultIdAndType ( null , type ) ;
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
2019-11-22 16:50:59 +01:00
List < Stakeholder > stakeholdersFull = new ArrayList < > ( ) ;
2020-11-11 13:45:59 +01:00
// Remove stakeholders for which i do not have authority
if ( stakeholders ! = null & & stakeholders . size ( ) > 0 ) {
List < String > roles = rolesUtils . getRoles ( ) ;
// log.debug("ROLES: ");
// roles.forEach(role -> log.debug(role));
//
// if (roles.contains(authorizationService.PORTAL_ADMIN)) {
if ( rolesUtils . isPortalAdmin ( roles ) ) {
for ( Stakeholder stakeholder : stakeholders ) {
stakeholdersFull . add ( this . setFullEntities ( stakeholder , roles ) ) ;
}
return stakeholdersFull ;
}
Iterator < Stakeholder > stakeholderIterator = stakeholders . iterator ( ) ;
while ( stakeholderIterator . hasNext ( ) ) {
Stakeholder stakeholder = stakeholderIterator . next ( ) ;
// if(roles.contains(authorizationService.curator(stakeholder.getType()))) {
if ( rolesUtils . isCurator ( roles , stakeholder . getType ( ) ) ) {
stakeholdersFull . add ( this . setFullEntities ( stakeholder , roles ) ) ;
continue ;
}
stakeholderIterator . remove ( ) ;
}
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
}
2020-11-11 13:45:59 +01:00
2019-11-22 16:50:59 +01:00
return stakeholdersFull ;
2019-11-04 10:03:49 +01:00
}
@RequestMapping ( value = " /stakeholder " , method = RequestMethod . GET )
2021-02-24 20:22:19 +01:00
public List < Stakeholder > getAllRealStakeholders ( @RequestParam ( required = false ) String type ,
@RequestParam ( required = false ) String defaultId ) {
[Trunk | Monitor Service]:
1. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java && SectionController.java && IndicatorController.java:
a. Comment logs for get requests.
b. Use "ForbiddenException" instead of "AccessDeniedException"
c. On /save, if full entity has id (already in DB), if not found in DB throw EntityNotFoundException.
d. Get children (e.g. when saving a Topic, get its categories) from DB.
2. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java:
In /reorder, if there are in DB, ids that are missing from reordered list, do reordering and add in the end of list the missing ids.
3. ReorderEvent.java: [NEW] Added class ReorderEvent with fields "action" (String), "target" (String), "ids" (List<String>) (used in IndicatorController.java).
4. IndicatorController.java:
a. In /reorder, @RequestBody changed from List<String> indicators to ReorderEvent reorderEvent.
b. If there are in DB, ids that are missing from reordered list AND missing id is not moved to other section (action = removed and target = missing id), do reordering and add in the end of list the missing ids.
5. ExceptionsHandler.java: exception handler methods "invalidInput()", "nullPointerException()", "notFoundException()" moved to "Admin Tools Library" - "accessDeniedException()" is removed.
6. responses/ExceptionResponse.java: File and folder deleted (moved to "Admin Tools Library").
7. RolesUtils.java: Added method "isLoggedIn()" (checks if no roles for user, or user has role "ROLE_ANONYMOUS").
2020-12-09 15:24:27 +01:00
// log.debug("get all NOT default stakeholders" + (type != null ? " with type: "+type : ""));
2019-12-19 16:04:25 +01:00
2019-11-04 10:03:49 +01:00
List < Stakeholder > stakeholders ;
2021-02-24 20:22:19 +01:00
if ( type ! = null & & defaultId ! = null ) {
stakeholders = stakeholderDAO . findByDefaultIdAndType ( defaultId , type ) ;
} else if ( defaultId ! = null ) {
stakeholders = stakeholderDAO . findByDefaultId ( defaultId ) ;
} else if ( type ! = null ) {
2019-12-19 16:04:25 +01:00
stakeholders = stakeholderDAO . findByDefaultIdNotAndType ( null , type ) ;
2021-02-24 20:22:19 +01:00
} else {
stakeholders = stakeholderDAO . findByDefaultIdNot ( null ) ;
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
2020-11-11 13:45:59 +01:00
//List<Stakeholder> stakeholdersFull = new ArrayList<>();
if ( stakeholders ! = null & & stakeholders . size ( ) > 0 ) {
// List<String> roles = authorizationService.getRoles();
List < String > roles = rolesUtils . getRoles ( ) ;
// if (roles.contains(authorizationService.PORTAL_ADMIN)) {
if ( rolesUtils . isPortalAdmin ( roles ) ) {
// for(Stakeholder stakeholder : stakeholders) {
// stakeholdersFull.add(this.setFullEntities(stakeholder));
// }
// return stakeholdersFull;
return stakeholders ;
}
Iterator < Stakeholder > stakeholderIterator = stakeholders . iterator ( ) ;
while ( stakeholderIterator . hasNext ( ) ) {
Stakeholder stakeholder = stakeholderIterator . next ( ) ;
// if(roles.contains(authorizationService.curator(stakeholder.getType()))
// || roles.contains(authorizationService.manager(stakeholder.getType(), stakeholder.getAlias()))
// || stakeholder.getVisibility() == Visibility.PUBLIC
// || (stakeholder.getVisibility() == Visibility.RESTRICTED && roles.contains(authorizationService.member(stakeholder.getType(), stakeholder.getAlias())))) {
if ( rolesUtils . isCurator ( roles , stakeholder . getType ( ) )
| | rolesUtils . isManager ( roles , stakeholder . getType ( ) , stakeholder . getAlias ( ) )
| | stakeholder . getVisibility ( ) = = Visibility . PUBLIC
| | ( stakeholder . getVisibility ( ) = = Visibility . RESTRICTED & & rolesUtils . isMember ( roles , stakeholder . getType ( ) , stakeholder . getAlias ( ) ) ) ) {
//stakeholdersFull.add(this.setFullEntities(stakeholder));
continue ;
}
stakeholderIterator . remove ( ) ;
}
}
// log.debug(new Date());
// return stakeholdersFull;
return stakeholders ;
}
@PreAuthorize ( " isAuthenticated() " )
@RequestMapping ( value = " /my-stakeholder " , method = RequestMethod . GET )
public List < Stakeholder > getMyRealStakeholders ( @RequestParam ( required = false ) String type ) {
[Trunk | Monitor Service]:
1. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java && SectionController.java && IndicatorController.java:
a. Comment logs for get requests.
b. Use "ForbiddenException" instead of "AccessDeniedException"
c. On /save, if full entity has id (already in DB), if not found in DB throw EntityNotFoundException.
d. Get children (e.g. when saving a Topic, get its categories) from DB.
2. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java:
In /reorder, if there are in DB, ids that are missing from reordered list, do reordering and add in the end of list the missing ids.
3. ReorderEvent.java: [NEW] Added class ReorderEvent with fields "action" (String), "target" (String), "ids" (List<String>) (used in IndicatorController.java).
4. IndicatorController.java:
a. In /reorder, @RequestBody changed from List<String> indicators to ReorderEvent reorderEvent.
b. If there are in DB, ids that are missing from reordered list AND missing id is not moved to other section (action = removed and target = missing id), do reordering and add in the end of list the missing ids.
5. ExceptionsHandler.java: exception handler methods "invalidInput()", "nullPointerException()", "notFoundException()" moved to "Admin Tools Library" - "accessDeniedException()" is removed.
6. responses/ExceptionResponse.java: File and folder deleted (moved to "Admin Tools Library").
7. RolesUtils.java: Added method "isLoggedIn()" (checks if no roles for user, or user has role "ROLE_ANONYMOUS").
2020-12-09 15:24:27 +01:00
// log.debug("get my NOT default stakeholders" + (type != null ? " with type: "+type : ""));
2020-11-11 13:45:59 +01:00
List < Stakeholder > stakeholders ;
if ( type = = null ) {
stakeholders = stakeholderDAO . findByDefaultIdNot ( null ) ;
} else {
stakeholders = stakeholderDAO . findByDefaultIdNotAndType ( null , type ) ;
}
2019-11-22 16:50:59 +01:00
List < Stakeholder > stakeholdersFull = new ArrayList < > ( ) ;
2020-11-11 13:45:59 +01:00
if ( stakeholders ! = null & & stakeholders . size ( ) > 0 ) {
// List<String> roles = authorizationService.getRoles();
List < String > roles = rolesUtils . getRoles ( ) ;
// log.debug("ROLES: ");
// roles.forEach(role -> log.debug(role));
// if (roles.contains(authorizationService.PORTAL_ADMIN)) {
if ( rolesUtils . isPortalAdmin ( roles ) ) {
2020-12-22 10:29:17 +01:00
// for(Stakeholder stakeholder : stakeholders) {
// stakeholdersFull.add(this.setFullEntities(stakeholder, roles));
// }
// return stakeholdersFull;
return stakeholders ;
2020-11-11 13:45:59 +01:00
}
Iterator < Stakeholder > stakeholderIterator = stakeholders . iterator ( ) ;
while ( stakeholderIterator . hasNext ( ) ) {
Stakeholder stakeholder = stakeholderIterator . next ( ) ;
// if(roles.contains(authorizationService.curator(stakeholder.getType()))
// || roles.contains(authorizationService.manager(stakeholder.getType(), stakeholder.getAlias()))) {
if ( rolesUtils . isCurator ( roles , stakeholder . getType ( ) )
| | rolesUtils . isManager ( roles , stakeholder . getType ( ) , stakeholder . getAlias ( ) ) ) {
2020-12-22 10:29:17 +01:00
//stakeholdersFull.add(this.setFullEntities(stakeholder, roles));
2020-11-11 13:45:59 +01:00
continue ;
2020-12-22 10:29:17 +01:00
} else {
stakeholderIterator . remove ( ) ;
2020-11-11 13:45:59 +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
}
2020-11-11 13:45:59 +01:00
// log.debug(new Date());
2019-11-04 10:03:49 +01:00
2020-12-22 10:29:17 +01:00
return stakeholders ;
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 ) {
[Trunk | Monitor Service]:
1. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java && SectionController.java && IndicatorController.java:
a. Comment logs for get requests.
b. Use "ForbiddenException" instead of "AccessDeniedException"
c. On /save, if full entity has id (already in DB), if not found in DB throw EntityNotFoundException.
d. Get children (e.g. when saving a Topic, get its categories) from DB.
2. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java:
In /reorder, if there are in DB, ids that are missing from reordered list, do reordering and add in the end of list the missing ids.
3. ReorderEvent.java: [NEW] Added class ReorderEvent with fields "action" (String), "target" (String), "ids" (List<String>) (used in IndicatorController.java).
4. IndicatorController.java:
a. In /reorder, @RequestBody changed from List<String> indicators to ReorderEvent reorderEvent.
b. If there are in DB, ids that are missing from reordered list AND missing id is not moved to other section (action = removed and target = missing id), do reordering and add in the end of list the missing ids.
5. ExceptionsHandler.java: exception handler methods "invalidInput()", "nullPointerException()", "notFoundException()" moved to "Admin Tools Library" - "accessDeniedException()" is removed.
6. responses/ExceptionResponse.java: File and folder deleted (moved to "Admin Tools Library").
7. RolesUtils.java: Added method "isLoggedIn()" (checks if no roles for user, or user has role "ROLE_ANONYMOUS").
2020-12-09 15:24:27 +01:00
// log.debug("get stakeholder: "+alias);
2019-12-19 16:04:25 +01:00
2019-11-22 16:50:59 +01:00
Stakeholder < String > stakeholder = stakeholderDAO . findByAlias ( alias ) ;
if ( stakeholder = = null ) {
// EXCEPTION - Stakeholder not found
throw new EntityNotFoundException ( " Get stakeholder: Stakeholder with alias: " + alias + " not found " ) ;
}
2020-11-11 13:45:59 +01:00
// List<String> roles = authorizationService.getRoles();
List < String > roles = rolesUtils . getRoles ( ) ;
[Trunk | Monitor Service]:
1. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java && SectionController.java && IndicatorController.java:
a. Comment logs for get requests.
b. Use "ForbiddenException" instead of "AccessDeniedException"
c. On /save, if full entity has id (already in DB), if not found in DB throw EntityNotFoundException.
d. Get children (e.g. when saving a Topic, get its categories) from DB.
2. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java:
In /reorder, if there are in DB, ids that are missing from reordered list, do reordering and add in the end of list the missing ids.
3. ReorderEvent.java: [NEW] Added class ReorderEvent with fields "action" (String), "target" (String), "ids" (List<String>) (used in IndicatorController.java).
4. IndicatorController.java:
a. In /reorder, @RequestBody changed from List<String> indicators to ReorderEvent reorderEvent.
b. If there are in DB, ids that are missing from reordered list AND missing id is not moved to other section (action = removed and target = missing id), do reordering and add in the end of list the missing ids.
5. ExceptionsHandler.java: exception handler methods "invalidInput()", "nullPointerException()", "notFoundException()" moved to "Admin Tools Library" - "accessDeniedException()" is removed.
6. responses/ExceptionResponse.java: File and folder deleted (moved to "Admin Tools Library").
7. RolesUtils.java: Added method "isLoggedIn()" (checks if no roles for user, or user has role "ROLE_ANONYMOUS").
2020-12-09 15:24:27 +01:00
if ( stakeholder . getDefaultId ( ) = = null & & ! rolesUtils . isLoggedIn ( roles ) ) {
// EXCEPTION - Unauthorized
throw new AccessDeniedException ( " Get stakeholder: You are not authorized (not logged in) to access stakeholder with alias: " + alias ) ;
}
if ( stakeholder . getDefaultId ( ) = = null & & ! rolesUtils . hasCreateAndDeleteAuthority ( roles , stakeholder . getType ( ) ) ) {
// EXCEPTION - Access denied
throw new ForbiddenException ( " Get stakeholder: You are not authorized to access stakeholder with alias: " + alias ) ;
}
2020-11-11 13:45:59 +01:00
if ( ( stakeholder . getVisibility ( ) = = Visibility . PRIVATE & & ! rolesUtils . hasUpdateAuthority ( roles , stakeholder . getType ( ) , stakeholder . getAlias ( ) )
| | ( stakeholder . getVisibility ( ) = = Visibility . RESTRICTED & & ! rolesUtils . hasUpdateAuthority ( roles , stakeholder . getType ( ) , stakeholder . getAlias ( ) ) & & ! rolesUtils . isMember ( roles , stakeholder . getType ( ) , stakeholder . getAlias ( ) ) ) ) ) {
// // EXCEPTION - Access denied
[Trunk | Monitor Service]:
1. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java && SectionController.java && IndicatorController.java:
a. Comment logs for get requests.
b. Use "ForbiddenException" instead of "AccessDeniedException"
c. On /save, if full entity has id (already in DB), if not found in DB throw EntityNotFoundException.
d. Get children (e.g. when saving a Topic, get its categories) from DB.
2. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java:
In /reorder, if there are in DB, ids that are missing from reordered list, do reordering and add in the end of list the missing ids.
3. ReorderEvent.java: [NEW] Added class ReorderEvent with fields "action" (String), "target" (String), "ids" (List<String>) (used in IndicatorController.java).
4. IndicatorController.java:
a. In /reorder, @RequestBody changed from List<String> indicators to ReorderEvent reorderEvent.
b. If there are in DB, ids that are missing from reordered list AND missing id is not moved to other section (action = removed and target = missing id), do reordering and add in the end of list the missing ids.
5. ExceptionsHandler.java: exception handler methods "invalidInput()", "nullPointerException()", "notFoundException()" moved to "Admin Tools Library" - "accessDeniedException()" is removed.
6. responses/ExceptionResponse.java: File and folder deleted (moved to "Admin Tools Library").
7. RolesUtils.java: Added method "isLoggedIn()" (checks if no roles for user, or user has role "ROLE_ANONYMOUS").
2020-12-09 15:24:27 +01:00
// throw new ForbiddenException("Get stakeholder: You are not authorized to get stakeholder with alias: "+alias);
2020-11-11 13:45:59 +01:00
List < String > topicsEmpty = stakeholder . getTopics ( ) ;
topicsEmpty . clear ( ) ;
stakeholder . setTopics ( topicsEmpty ) ;
stakeholder . setVisibility ( Visibility . PRIVATE ) ;
return stakeholder ;
}
return this . setFullEntities ( stakeholder , roles ) ;
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
}
2020-11-11 13:45:59 +01:00
// @PreAuthorize("isAuthenticated()")
[Trunk | Monitor Service]:
1. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java && SectionController.java && IndicatorController.java:
a. Comment logs for get requests.
b. Use "ForbiddenException" instead of "AccessDeniedException"
c. On /save, if full entity has id (already in DB), if not found in DB throw EntityNotFoundException.
d. Get children (e.g. when saving a Topic, get its categories) from DB.
2. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java:
In /reorder, if there are in DB, ids that are missing from reordered list, do reordering and add in the end of list the missing ids.
3. ReorderEvent.java: [NEW] Added class ReorderEvent with fields "action" (String), "target" (String), "ids" (List<String>) (used in IndicatorController.java).
4. IndicatorController.java:
a. In /reorder, @RequestBody changed from List<String> indicators to ReorderEvent reorderEvent.
b. If there are in DB, ids that are missing from reordered list AND missing id is not moved to other section (action = removed and target = missing id), do reordering and add in the end of list the missing ids.
5. ExceptionsHandler.java: exception handler methods "invalidInput()", "nullPointerException()", "notFoundException()" moved to "Admin Tools Library" - "accessDeniedException()" is removed.
6. responses/ExceptionResponse.java: File and folder deleted (moved to "Admin Tools Library").
7. RolesUtils.java: Added method "isLoggedIn()" (checks if no roles for user, or user has role "ROLE_ANONYMOUS").
2020-12-09 15:24:27 +01:00
@PreAuthorize ( " hasAnyAuthority( "
+ " @AuthorizationService.PORTAL_ADMIN, "
2020-12-22 10:29:17 +01:00
+ " @AuthorizationService.curator(#_stakeholder.getType()), "
+ " @AuthorizationService.manager(#_stakeholder.getType(), #_stakeholder.getAlias()) "
[Trunk | Monitor Service]:
1. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java && SectionController.java && IndicatorController.java:
a. Comment logs for get requests.
b. Use "ForbiddenException" instead of "AccessDeniedException"
c. On /save, if full entity has id (already in DB), if not found in DB throw EntityNotFoundException.
d. Get children (e.g. when saving a Topic, get its categories) from DB.
2. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java:
In /reorder, if there are in DB, ids that are missing from reordered list, do reordering and add in the end of list the missing ids.
3. ReorderEvent.java: [NEW] Added class ReorderEvent with fields "action" (String), "target" (String), "ids" (List<String>) (used in IndicatorController.java).
4. IndicatorController.java:
a. In /reorder, @RequestBody changed from List<String> indicators to ReorderEvent reorderEvent.
b. If there are in DB, ids that are missing from reordered list AND missing id is not moved to other section (action = removed and target = missing id), do reordering and add in the end of list the missing ids.
5. ExceptionsHandler.java: exception handler methods "invalidInput()", "nullPointerException()", "notFoundException()" moved to "Admin Tools Library" - "accessDeniedException()" is removed.
6. responses/ExceptionResponse.java: File and folder deleted (moved to "Admin Tools Library").
7. RolesUtils.java: Added method "isLoggedIn()" (checks if no roles for user, or user has role "ROLE_ANONYMOUS").
2020-12-09 15:24:27 +01:00
+ " ) " )
2019-11-22 16:50:59 +01:00
@RequestMapping ( value = " /save " , method = RequestMethod . POST )
2020-12-22 10:29:17 +01:00
public Stakeholder saveStakeholder ( @RequestBody Stakeholder _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
log . debug ( " save stakeholder " ) ;
2020-12-22 10:29:17 +01:00
log . debug ( " Alias: " + _stakeholder . getAlias ( ) + " - Id: " + _stakeholder . 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
2020-12-22 10:29:17 +01:00
// if(_stakeholder == null) {
2019-11-22 16:50:59 +01:00
// 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
2020-12-22 10:29:17 +01:00
Stakeholder < String > stakeholder = new Stakeholder < > ( _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-12-19 16:04:25 +01:00
Date date = new Date ( ) ;
stakeholder . setUpdateDate ( date ) ;
[Trunk | Monitor Service]:
1. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java && SectionController.java && IndicatorController.java:
a. Comment logs for get requests.
b. Use "ForbiddenException" instead of "AccessDeniedException"
c. On /save, if full entity has id (already in DB), if not found in DB throw EntityNotFoundException.
d. Get children (e.g. when saving a Topic, get its categories) from DB.
2. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java:
In /reorder, if there are in DB, ids that are missing from reordered list, do reordering and add in the end of list the missing ids.
3. ReorderEvent.java: [NEW] Added class ReorderEvent with fields "action" (String), "target" (String), "ids" (List<String>) (used in IndicatorController.java).
4. IndicatorController.java:
a. In /reorder, @RequestBody changed from List<String> indicators to ReorderEvent reorderEvent.
b. If there are in DB, ids that are missing from reordered list AND missing id is not moved to other section (action = removed and target = missing id), do reordering and add in the end of list the missing ids.
5. ExceptionsHandler.java: exception handler methods "invalidInput()", "nullPointerException()", "notFoundException()" moved to "Admin Tools Library" - "accessDeniedException()" is removed.
6. responses/ExceptionResponse.java: File and folder deleted (moved to "Admin Tools Library").
7. RolesUtils.java: Added method "isLoggedIn()" (checks if no roles for user, or user has role "ROLE_ANONYMOUS").
2020-12-09 15:24:27 +01:00
List < String > topics = new ArrayList < > ( ) ;
2019-12-19 16:04:25 +01:00
// stakeholder does not exist in DB
2020-12-22 10:29:17 +01:00
if ( _stakeholder . getId ( ) = = null ) {
2019-12-19 16:04:25 +01:00
stakeholder . setCreationDate ( date ) ;
2020-12-22 10:29:17 +01:00
// for(Topic topic : _stakeholder.getTopics()) {
// topics.add(topic.getId());
// }
[Trunk | Monitor Service]:
1. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java && SectionController.java && IndicatorController.java:
a. Comment logs for get requests.
b. Use "ForbiddenException" instead of "AccessDeniedException"
c. On /save, if full entity has id (already in DB), if not found in DB throw EntityNotFoundException.
d. Get children (e.g. when saving a Topic, get its categories) from DB.
2. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java:
In /reorder, if there are in DB, ids that are missing from reordered list, do reordering and add in the end of list the missing ids.
3. ReorderEvent.java: [NEW] Added class ReorderEvent with fields "action" (String), "target" (String), "ids" (List<String>) (used in IndicatorController.java).
4. IndicatorController.java:
a. In /reorder, @RequestBody changed from List<String> indicators to ReorderEvent reorderEvent.
b. If there are in DB, ids that are missing from reordered list AND missing id is not moved to other section (action = removed and target = missing id), do reordering and add in the end of list the missing ids.
5. ExceptionsHandler.java: exception handler methods "invalidInput()", "nullPointerException()", "notFoundException()" moved to "Admin Tools Library" - "accessDeniedException()" is removed.
6. responses/ExceptionResponse.java: File and folder deleted (moved to "Admin Tools Library").
7. RolesUtils.java: Added method "isLoggedIn()" (checks if no roles for user, or user has role "ROLE_ANONYMOUS").
2020-12-09 15:24:27 +01:00
} else {
2020-12-22 10:29:17 +01:00
Stakeholder < String > oldStakeholder = stakeholderDAO . findById ( _stakeholder . getId ( ) ) ;
[Trunk | Monitor Service]:
1. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java && SectionController.java && IndicatorController.java:
a. Comment logs for get requests.
b. Use "ForbiddenException" instead of "AccessDeniedException"
c. On /save, if full entity has id (already in DB), if not found in DB throw EntityNotFoundException.
d. Get children (e.g. when saving a Topic, get its categories) from DB.
2. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java:
In /reorder, if there are in DB, ids that are missing from reordered list, do reordering and add in the end of list the missing ids.
3. ReorderEvent.java: [NEW] Added class ReorderEvent with fields "action" (String), "target" (String), "ids" (List<String>) (used in IndicatorController.java).
4. IndicatorController.java:
a. In /reorder, @RequestBody changed from List<String> indicators to ReorderEvent reorderEvent.
b. If there are in DB, ids that are missing from reordered list AND missing id is not moved to other section (action = removed and target = missing id), do reordering and add in the end of list the missing ids.
5. ExceptionsHandler.java: exception handler methods "invalidInput()", "nullPointerException()", "notFoundException()" moved to "Admin Tools Library" - "accessDeniedException()" is removed.
6. responses/ExceptionResponse.java: File and folder deleted (moved to "Admin Tools Library").
7. RolesUtils.java: Added method "isLoggedIn()" (checks if no roles for user, or user has role "ROLE_ANONYMOUS").
2020-12-09 15:24:27 +01:00
if ( oldStakeholder = = null ) {
// EXCEPTION - Stakeholder not found
2020-12-22 10:29:17 +01:00
throw new EntityNotFoundException ( " save stakeholder: Stakeholder with id: " + _stakeholder . getId ( ) + " not found " ) ;
[Trunk | Monitor Service]:
1. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java && SectionController.java && IndicatorController.java:
a. Comment logs for get requests.
b. Use "ForbiddenException" instead of "AccessDeniedException"
c. On /save, if full entity has id (already in DB), if not found in DB throw EntityNotFoundException.
d. Get children (e.g. when saving a Topic, get its categories) from DB.
2. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java:
In /reorder, if there are in DB, ids that are missing from reordered list, do reordering and add in the end of list the missing ids.
3. ReorderEvent.java: [NEW] Added class ReorderEvent with fields "action" (String), "target" (String), "ids" (List<String>) (used in IndicatorController.java).
4. IndicatorController.java:
a. In /reorder, @RequestBody changed from List<String> indicators to ReorderEvent reorderEvent.
b. If there are in DB, ids that are missing from reordered list AND missing id is not moved to other section (action = removed and target = missing id), do reordering and add in the end of list the missing ids.
5. ExceptionsHandler.java: exception handler methods "invalidInput()", "nullPointerException()", "notFoundException()" moved to "Admin Tools Library" - "accessDeniedException()" is removed.
6. responses/ExceptionResponse.java: File and folder deleted (moved to "Admin Tools Library").
7. RolesUtils.java: Added method "isLoggedIn()" (checks if no roles for user, or user has role "ROLE_ANONYMOUS").
2020-12-09 15:24:27 +01:00
}
for ( String topicId : oldStakeholder . getTopics ( ) ) {
Topic topic = topicDAO . findById ( topicId ) ;
if ( topic = = null ) {
// EXCEPTION - Topic not found
throw new EntityNotFoundException ( " Save stakeholder: Topic with id: " + topicId + " not found (topic exists in stakeholder: " + stakeholder . getId ( ) + " ) " ) ;
}
topics . add ( topic . getId ( ) ) ;
}
// stakeholder.setTopics(topics);
2020-12-22 10:29:17 +01:00
// _stakeholder = this.setFullEntities(stakeholder, rolesUtils.getRoles());
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
}
[Trunk | Monitor Service]:
1. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java && SectionController.java && IndicatorController.java:
a. Comment logs for get requests.
b. Use "ForbiddenException" instead of "AccessDeniedException"
c. On /save, if full entity has id (already in DB), if not found in DB throw EntityNotFoundException.
d. Get children (e.g. when saving a Topic, get its categories) from DB.
2. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java:
In /reorder, if there are in DB, ids that are missing from reordered list, do reordering and add in the end of list the missing ids.
3. ReorderEvent.java: [NEW] Added class ReorderEvent with fields "action" (String), "target" (String), "ids" (List<String>) (used in IndicatorController.java).
4. IndicatorController.java:
a. In /reorder, @RequestBody changed from List<String> indicators to ReorderEvent reorderEvent.
b. If there are in DB, ids that are missing from reordered list AND missing id is not moved to other section (action = removed and target = missing id), do reordering and add in the end of list the missing ids.
5. ExceptionsHandler.java: exception handler methods "invalidInput()", "nullPointerException()", "notFoundException()" moved to "Admin Tools Library" - "accessDeniedException()" is removed.
6. responses/ExceptionResponse.java: File and folder deleted (moved to "Admin Tools Library").
7. RolesUtils.java: Added method "isLoggedIn()" (checks if no roles for user, or user has role "ROLE_ANONYMOUS").
2020-12-09 15:24:27 +01:00
2019-11-22 16:50:59 +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
2019-11-22 16:50:59 +01:00
Stakeholder < String > stakeholderSaved = stakeholderDAO . save ( stakeholder ) ;
2020-12-22 10:29:17 +01:00
_stakeholder . setId ( stakeholderSaved . getId ( ) ) ;
_stakeholder . setCreationDate ( stakeholderSaved . getCreationDate ( ) ) ;
_stakeholder . setUpdateDate ( stakeholderSaved . getUpdateDate ( ) ) ;
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-22 16:50:59 +01:00
topics = null ;
stakeholder = null ;
stakeholderSaved = null ;
2019-11-19 14:05:43 +01:00
2020-12-22 10:29:17 +01:00
return _stakeholder ;
2019-11-19 14:05:43 +01:00
}
2020-11-11 13:45:59 +01:00
@PreAuthorize ( " isAuthenticated() " )
2019-11-22 16:50:59 +01:00
@RequestMapping ( value = " /{stakeholderId}/delete " , method = RequestMethod . DELETE )
public boolean deleteStakeholder ( @PathVariable ( " stakeholderId " ) String stakeholderId ) {
log . debug ( " delete stakeholder " ) ;
2019-12-19 16:04:25 +01:00
log . debug ( " Id: " + stakeholderId ) ;
2019-11-19 14:05:43 +01:00
2019-11-22 16:50:59 +01:00
Stakeholder < String > stakeholder = stakeholderDAO . findById ( stakeholderId ) ;
2019-11-19 14:05:43 +01:00
2019-11-22 16:50:59 +01:00
if ( stakeholder ! = null ) {
2020-11-11 13:45:59 +01:00
// List<String> roles = authorizationService.getRoles();
List < String > roles = rolesUtils . getRoles ( ) ;
// if(!roles.contains(authorizationService.PORTAL_ADMIN)
// && !roles.contains(authorizationService.curator(stakeholder.getType()))) {
if ( ! rolesUtils . hasCreateAndDeleteAuthority ( roles , stakeholder . getType ( ) ) ) {
// EXCEPTION - Access denied
[Trunk | Monitor Service]:
1. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java && SectionController.java && IndicatorController.java:
a. Comment logs for get requests.
b. Use "ForbiddenException" instead of "AccessDeniedException"
c. On /save, if full entity has id (already in DB), if not found in DB throw EntityNotFoundException.
d. Get children (e.g. when saving a Topic, get its categories) from DB.
2. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java:
In /reorder, if there are in DB, ids that are missing from reordered list, do reordering and add in the end of list the missing ids.
3. ReorderEvent.java: [NEW] Added class ReorderEvent with fields "action" (String), "target" (String), "ids" (List<String>) (used in IndicatorController.java).
4. IndicatorController.java:
a. In /reorder, @RequestBody changed from List<String> indicators to ReorderEvent reorderEvent.
b. If there are in DB, ids that are missing from reordered list AND missing id is not moved to other section (action = removed and target = missing id), do reordering and add in the end of list the missing ids.
5. ExceptionsHandler.java: exception handler methods "invalidInput()", "nullPointerException()", "notFoundException()" moved to "Admin Tools Library" - "accessDeniedException()" is removed.
6. responses/ExceptionResponse.java: File and folder deleted (moved to "Admin Tools Library").
7. RolesUtils.java: Added method "isLoggedIn()" (checks if no roles for user, or user has role "ROLE_ANONYMOUS").
2020-12-09 15:24:27 +01:00
throw new ForbiddenException ( " Delete stakeholder: You are not authorized to delete stakeholder with id: " + stakeholderId ) ;
2020-11-11 13:45:59 +01:00
}
2019-11-19 14:05:43 +01:00
2020-06-22 21:58:40 +02:00
// 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+")");
// }
//
// for(String chartSectionId : subcategory.getCharts()) {
// Section<String> chartSection = sectionDAO.findById(chartSectionId);
// if (chartSection == null) {
// // EXCEPTION - Section not found
// throw new EntityNotFoundException("Delete topic: Section with id: "+chartSectionId+" not found (section exists in subcategory: "+subCategoryId+")");
// }
//
// for (String chartId : chartSection.getIndicators()) {
// indicatorDAO.delete(chartId);
// }
// subcategory.setCharts(null);
// sectionDAO.delete(chartSectionId);
// }
//
// for(String numberSectionId : subcategory.getNumbers()) {
// Section<String> numberSection = sectionDAO.findById(numberSectionId);
// if (numberSection == null) {
// // EXCEPTION - Section not found
// throw new EntityNotFoundException("Delete topic: Section with id: "+numberSectionId+" not found (section exists in subcategory: "+subCategoryId+")");
// }
//
// for (String numberId : numberSection.getIndicators()) {
// indicatorDAO.delete(numberId);
// }
// subcategory.setNumbers(null);
// sectionDAO.delete(numberSectionId);
// }
//
// subCategoryDAO.delete(subCategoryId);
// }
// category.setSubCategories(null);
// categoryDAO.delete(categoryId);
// }
// topic.setCategories(null);
// topicDAO.delete(topicId);
// }
2019-11-19 14:05:43 +01:00
2020-06-22 21:58:40 +02:00
topicController . deleteTree ( stakeholder ) ;
2019-11-19 14:05:43 +01:00
2019-11-22 16:50:59 +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
2019-11-22 16:50:59 +01:00
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 ;
}
2020-11-11 13:45:59 +01:00
// @RequestMapping(value = "/{stakeholderId}/toggle-status", method = RequestMethod.POST)
// public Boolean toggleStakeholderStatus(@PathVariable("stakeholderId") String stakeholderId) {
// log.debug("toggle stakeholder status (isActive)");
// log.debug("Stakeholder: "+stakeholderId);
//
// Stakeholder stakeholder = stakeholderDAO.findById(stakeholderId);
// if (stakeholder == null) {
// // EXCEPTION - Stakeholder not found
// throw new EntityNotFoundException("Toggle stakeholder status: Stakeholder with id: "+stakeholderId+" not found");
// }
// stakeholder.setIsActive(!stakeholder.getIsActive());
//
// stakeholderDAO.save(stakeholder);
// log.debug("Stakeholder toggled!");
//
// return stakeholder.getIsActive();
// }
//
// @RequestMapping(value = "/{stakeholderId}/toggle-access", method = RequestMethod.POST)
// public Boolean toggleStakeholderAccess(@PathVariable("stakeholderId") String stakeholderId) {
// log.debug("toggle stakeholder access (isPublic)");
// log.debug("Stakeholder: "+stakeholderId);
//
// Stakeholder stakeholder = stakeholderDAO.findById(stakeholderId);
// if (stakeholder == null) {
// // EXCEPTION - Stakeholder not found
// throw new EntityNotFoundException("Toggle stakeholder access: Stakeholder with id: "+stakeholderId+" not found");
// }
// stakeholder.setIsPublic(!stakeholder.getIsPublic());
//
// stakeholderDAO.save(stakeholder);
// log.debug("Stakeholder toggled!");
//
// return stakeholder.getIsPublic();
// }
@PreAuthorize ( " isAuthenticated() " )
@RequestMapping ( value = " /{stakeholderId}/change-visibility " , method = RequestMethod . POST )
public Visibility toggleStakeholderAccess ( @PathVariable ( " stakeholderId " ) String stakeholderId ,
@RequestParam ( " visibility " ) Visibility visibility ) {
log . debug ( " change stakeholder visibility: " + visibility ) ;
2019-12-23 12:45:07 +01:00
log . debug ( " Stakeholder: " + stakeholderId ) ;
Stakeholder stakeholder = stakeholderDAO . findById ( stakeholderId ) ;
if ( stakeholder = = null ) {
// EXCEPTION - Stakeholder not found
2020-11-11 13:45:59 +01:00
throw new EntityNotFoundException ( " Change stakeholder visibility: Stakeholder with id: " + stakeholderId + " not found " ) ;
2019-12-23 12:45:07 +01:00
}
2020-11-11 13:45:59 +01:00
// List<String> roles = authorizationService.getRoles();
List < String > roles = rolesUtils . getRoles ( ) ;
2019-12-23 12:45:07 +01:00
2020-11-11 13:45:59 +01:00
// if(!roles.contains(authorizationService.PORTAL_ADMIN)
// && !roles.contains(authorizationService.curator(stakeholder.getType()))
// && !roles.contains(authorizationService.manager(stakeholder.getType(), stakeholder.getAlias()))) {
if ( ! rolesUtils . hasUpdateAuthority ( roles , stakeholder . getType ( ) , stakeholder . getAlias ( ) ) ) {
// EXCEPTION - Access denied
[Trunk | Monitor Service]:
1. StakeholderController.java & TopicController.java & CategoryController.java & SubCategoryController.java && SectionController.java && IndicatorController.java:
a. Comment logs for get requests.
b. Use "ForbiddenException" instead of "AccessDeniedException"
c. On /save, if full entity has id (already in DB), if not found in DB throw EntityNotFoundException.
d. Get children (e.g. when saving a Topic, get its categories) from DB.
2. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java:
In /reorder, if there are in DB, ids that are missing from reordered list, do reordering and add in the end of list the missing ids.
3. ReorderEvent.java: [NEW] Added class ReorderEvent with fields "action" (String), "target" (String), "ids" (List<String>) (used in IndicatorController.java).
4. IndicatorController.java:
a. In /reorder, @RequestBody changed from List<String> indicators to ReorderEvent reorderEvent.
b. If there are in DB, ids that are missing from reordered list AND missing id is not moved to other section (action = removed and target = missing id), do reordering and add in the end of list the missing ids.
5. ExceptionsHandler.java: exception handler methods "invalidInput()", "nullPointerException()", "notFoundException()" moved to "Admin Tools Library" - "accessDeniedException()" is removed.
6. responses/ExceptionResponse.java: File and folder deleted (moved to "Admin Tools Library").
7. RolesUtils.java: Added method "isLoggedIn()" (checks if no roles for user, or user has role "ROLE_ANONYMOUS").
2020-12-09 15:24:27 +01:00
throw new ForbiddenException ( " Change stakeholder visibility: You are not authorized to update stakeholder with id: " + stakeholderId ) ;
2019-12-23 12:45:07 +01:00
}
2020-11-11 13:45:59 +01:00
stakeholder . setVisibility ( visibility ) ;
2019-12-23 12:45:07 +01:00
stakeholderDAO . save ( stakeholder ) ;
log . debug ( " Stakeholder toggled! " ) ;
2020-11-11 13:45:59 +01:00
return stakeholder . getVisibility ( ) ;
2019-12-23 12:45:07 +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
// The following are not supposed to be used
2019-11-22 16:50:59 +01:00
// @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
}