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

224 lines
9.7 KiB
Java
Raw Normal View History

package eu.dnetlib.uoamonitorservice.controllers;
import eu.dnetlib.uoamonitorservice.dto.TopicFull;
import eu.dnetlib.uoamonitorservice.entities.Stakeholder;
import eu.dnetlib.uoamonitorservice.entities.Topic;
import eu.dnetlib.uoamonitorservice.primitives.Visibility;
import eu.dnetlib.uoamonitorservice.service.StakeholderService;
import eu.dnetlib.uoamonitorservice.service.TopicService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@RestController
@CrossOrigin(origins = "*")
public class TopicController {
private final Logger log = LogManager.getLogger(this.getClass());
private TopicService topicService;
private StakeholderService stakeholderService;
@Autowired
public TopicController(TopicService topicService, StakeholderService stakeholderService) {
this.topicService = topicService;
this.stakeholderService = stakeholderService;
}
/*@PreAuthorize("isAuthenticated()")
@RequestMapping(value = "/{stakeholderId}/save", method = RequestMethod.POST)
public Topic<Category> saveTopic(@PathVariable("stakeholderId") String stakeholderId,
@RequestBody Topic<Category> topicFull) {
log.debug("save topic");
1. pom.xml: Add dependency for "uoa-help-texts-library" (will be renamed). 2. UoaMonitorServiceApplication.java: Add @PropertySource path used in dl170. 3. MongoConnection.java: @EnableMongoRepositories not only from: eu.dnetlib.uoamonitorservice.dao, but also: eu.dnetlib.uoahelptexts.dao. 4. GoogleConfig.java & MailConfig.java: [Deleted]: Functionality available on library project. 5. EmailController.java: [New]: Used for contact-us page in portal. 6. ExceptionsHandler.java & /controllers/: Add more and detailed logs. 7. Stakeholder.java: a. Field 'logoUrl' added. b. Method 'getType()' returns type.name() and 'setType()' gets String and converts it into StakeholderType. 8. Topic.java & Category.java & SubCategory.java & Indicator.java: a. Field 'boolean isDefault' changed to 'String defaultId'. b. Method copyFromDefault() added to create a clone from default entity (topic, category, subcategory, indicator). 9. Category.java & SubCategory.java: Field 'String description' added. 10. SubCategory.java: Field 'String stakeholderId' added | method createOverviewSubCategory(Category) added. 11. Indicator.java & IndicatorPath.java: Method 'getType()' returns type.name() and 'setType()' gets String and converts it into IndicatorType / IndicatorPathType. 12. IndicatorPath.java: Constructor and copy constructor added. 13. StakeholderDAO.java & MongoDBStakeholderDAO.java: a. Method findByIsDefaultProfile() changed to: findByDefaultId() & findByDefaultIdNot(). b. Method findByIsDefaultProfileAndType() changed to: findByDefaultIdAndType() & findByDefaultIdNotAndType(). 14. SubCategoryDAO.java & MongoDBSubCategoryDAO.java & IndicatorDAO.java & MongoDBSubCategoryDAO.java: Method 'findByDefaultId()' added. 15. StakeholderController.java: Handle creationDate and updateDate | Add more exceptional cases. 16. TopicController.java: a. Helper method 'onSaveDefaultTopic()' added (save cloned topic on stakeholders based on this default Stakeholder). b. Helper method 'onUpdateDefaultTopic()' added (update cloned topics based on this default topic). 17. CategoryController.java: a. Remove 'subCategory.setIsDefault(true);' when a category is created. b. Helper method 'onSaveDefaultCategory()' added (save cloned category on topics based on this default Topic). c. Helper method 'onUpdateDefaultCategory()' added (update cloned categories based on this default category). 18. SubCategoryController.java: a. Helper method 'onSaveDefaultSubCategory()' added (save cloned subCategory on topics based on this default Category). b. Helper method 'onUpdateDefaultSubCategory()' added (update cloned subCategories based on this default subCategory). 19. IndicatorController.java: a. Helper method 'onSaveDefaultIndicator()' added (save cloned indicator on subCategories based on this default SubCategory). b. Helper method 'onUpdateDefaultIndicator()' added (update cloned indicators based on this default indicator). c. Helper method 'parameterMapping()' added to map correct parameter values on parameters depending on stakeholder info. d. Method 'toggleIndicatorStatus()' added to toggle 'isActive' field. e. Method 'toggleIndicatorAccess()' added to toggle 'isPublic' field. f. Helper method 'toggleIndicator()' added to update indicator when a field is toggled.
2019-12-19 16:04:25 +01:00
log.debug("Alias: "+topicFull.getAlias() + " - Id: "+topicFull.getId()+ " - Stakeholder: "+stakeholderId);
Stakeholder stakeholder = stakeholderDAO.findById(stakeholderId);
if(stakeholder != null) {
2023-07-04 15:02:34 +02:00
if(!rolesUtils.hasUpdateAuthority(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("Save Topic: You are not authorized to update stakeholder with id: "+stakeholderId);
}
Topic<String> topic = new Topic<>(topicFull);
Date date = new Date();
topic.setUpdateDate(date);
topicFull.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> categories = new ArrayList<>();
Topic<String> oldTopic = null;
if(topicFull.getId() != null) {
oldTopic = topicDAO.findById(topicFull.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(oldTopic == null) {
// EXCEPTION - Topic not found
throw new EntityNotFoundException("save topic: Topic with id: "+topicFull.getId()+" not found");
}
for(String categoryId : oldTopic.getCategories()) {
Category category = categoryDAO.findById(categoryId);
if (category == null) {
// EXCEPTION - Category not found
throw new EntityNotFoundException("Save topic: Category with id: "+categoryId+" not found (category exists in topic: "+topic.getId()+")");
}
categories.add(category.getId());
}
} else { // topic does not exist in DB
topic.setCreationDate(date);
topicFull.setCreationDate(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
for(Category category : topicFull.getCategories()) {
categories.add(category.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
topic.setCategories(categories);
1. pom.xml: Add dependency for "uoa-help-texts-library" (will be renamed). 2. UoaMonitorServiceApplication.java: Add @PropertySource path used in dl170. 3. MongoConnection.java: @EnableMongoRepositories not only from: eu.dnetlib.uoamonitorservice.dao, but also: eu.dnetlib.uoahelptexts.dao. 4. GoogleConfig.java & MailConfig.java: [Deleted]: Functionality available on library project. 5. EmailController.java: [New]: Used for contact-us page in portal. 6. ExceptionsHandler.java & /controllers/: Add more and detailed logs. 7. Stakeholder.java: a. Field 'logoUrl' added. b. Method 'getType()' returns type.name() and 'setType()' gets String and converts it into StakeholderType. 8. Topic.java & Category.java & SubCategory.java & Indicator.java: a. Field 'boolean isDefault' changed to 'String defaultId'. b. Method copyFromDefault() added to create a clone from default entity (topic, category, subcategory, indicator). 9. Category.java & SubCategory.java: Field 'String description' added. 10. SubCategory.java: Field 'String stakeholderId' added | method createOverviewSubCategory(Category) added. 11. Indicator.java & IndicatorPath.java: Method 'getType()' returns type.name() and 'setType()' gets String and converts it into IndicatorType / IndicatorPathType. 12. IndicatorPath.java: Constructor and copy constructor added. 13. StakeholderDAO.java & MongoDBStakeholderDAO.java: a. Method findByIsDefaultProfile() changed to: findByDefaultId() & findByDefaultIdNot(). b. Method findByIsDefaultProfileAndType() changed to: findByDefaultIdAndType() & findByDefaultIdNotAndType(). 14. SubCategoryDAO.java & MongoDBSubCategoryDAO.java & IndicatorDAO.java & MongoDBSubCategoryDAO.java: Method 'findByDefaultId()' added. 15. StakeholderController.java: Handle creationDate and updateDate | Add more exceptional cases. 16. TopicController.java: a. Helper method 'onSaveDefaultTopic()' added (save cloned topic on stakeholders based on this default Stakeholder). b. Helper method 'onUpdateDefaultTopic()' added (update cloned topics based on this default topic). 17. CategoryController.java: a. Remove 'subCategory.setIsDefault(true);' when a category is created. b. Helper method 'onSaveDefaultCategory()' added (save cloned category on topics based on this default Topic). c. Helper method 'onUpdateDefaultCategory()' added (update cloned categories based on this default category). 18. SubCategoryController.java: a. Helper method 'onSaveDefaultSubCategory()' added (save cloned subCategory on topics based on this default Category). b. Helper method 'onUpdateDefaultSubCategory()' added (update cloned subCategories based on this default subCategory). 19. IndicatorController.java: a. Helper method 'onSaveDefaultIndicator()' added (save cloned indicator on subCategories based on this default SubCategory). b. Helper method 'onUpdateDefaultIndicator()' added (update cloned indicators based on this default indicator). c. Helper method 'parameterMapping()' added to map correct parameter values on parameters depending on stakeholder info. d. Method 'toggleIndicatorStatus()' added to toggle 'isActive' field. e. Method 'toggleIndicatorAccess()' added to toggle 'isPublic' field. f. Helper method 'toggleIndicator()' added to update indicator when a field is toggled.
2019-12-19 16:04:25 +01:00
if(stakeholder.getDefaultId() == null) {
if(topicFull.getId() == null) {
topicDAO.save(topic);
1. pom.xml: Add dependency for "uoa-help-texts-library" (will be renamed). 2. UoaMonitorServiceApplication.java: Add @PropertySource path used in dl170. 3. MongoConnection.java: @EnableMongoRepositories not only from: eu.dnetlib.uoamonitorservice.dao, but also: eu.dnetlib.uoahelptexts.dao. 4. GoogleConfig.java & MailConfig.java: [Deleted]: Functionality available on library project. 5. EmailController.java: [New]: Used for contact-us page in portal. 6. ExceptionsHandler.java & /controllers/: Add more and detailed logs. 7. Stakeholder.java: a. Field 'logoUrl' added. b. Method 'getType()' returns type.name() and 'setType()' gets String and converts it into StakeholderType. 8. Topic.java & Category.java & SubCategory.java & Indicator.java: a. Field 'boolean isDefault' changed to 'String defaultId'. b. Method copyFromDefault() added to create a clone from default entity (topic, category, subcategory, indicator). 9. Category.java & SubCategory.java: Field 'String description' added. 10. SubCategory.java: Field 'String stakeholderId' added | method createOverviewSubCategory(Category) added. 11. Indicator.java & IndicatorPath.java: Method 'getType()' returns type.name() and 'setType()' gets String and converts it into IndicatorType / IndicatorPathType. 12. IndicatorPath.java: Constructor and copy constructor added. 13. StakeholderDAO.java & MongoDBStakeholderDAO.java: a. Method findByIsDefaultProfile() changed to: findByDefaultId() & findByDefaultIdNot(). b. Method findByIsDefaultProfileAndType() changed to: findByDefaultIdAndType() & findByDefaultIdNotAndType(). 14. SubCategoryDAO.java & MongoDBSubCategoryDAO.java & IndicatorDAO.java & MongoDBSubCategoryDAO.java: Method 'findByDefaultId()' added. 15. StakeholderController.java: Handle creationDate and updateDate | Add more exceptional cases. 16. TopicController.java: a. Helper method 'onSaveDefaultTopic()' added (save cloned topic on stakeholders based on this default Stakeholder). b. Helper method 'onUpdateDefaultTopic()' added (update cloned topics based on this default topic). 17. CategoryController.java: a. Remove 'subCategory.setIsDefault(true);' when a category is created. b. Helper method 'onSaveDefaultCategory()' added (save cloned category on topics based on this default Topic). c. Helper method 'onUpdateDefaultCategory()' added (update cloned categories based on this default category). 18. SubCategoryController.java: a. Helper method 'onSaveDefaultSubCategory()' added (save cloned subCategory on topics based on this default Category). b. Helper method 'onUpdateDefaultSubCategory()' added (update cloned subCategories based on this default subCategory). 19. IndicatorController.java: a. Helper method 'onSaveDefaultIndicator()' added (save cloned indicator on subCategories based on this default SubCategory). b. Helper method 'onUpdateDefaultIndicator()' added (update cloned indicators based on this default indicator). c. Helper method 'parameterMapping()' added to map correct parameter values on parameters depending on stakeholder info. d. Method 'toggleIndicatorStatus()' added to toggle 'isActive' field. e. Method 'toggleIndicatorAccess()' added to toggle 'isPublic' field. f. Helper method 'toggleIndicator()' added to update indicator when a field is toggled.
2019-12-19 16:04:25 +01:00
onSaveDefaultTopic(topic, stakeholderId);
} else {
onUpdateDefaultTopic(topic, oldTopic);
topicDAO.save(topic);
1. pom.xml: Add dependency for "uoa-help-texts-library" (will be renamed). 2. UoaMonitorServiceApplication.java: Add @PropertySource path used in dl170. 3. MongoConnection.java: @EnableMongoRepositories not only from: eu.dnetlib.uoamonitorservice.dao, but also: eu.dnetlib.uoahelptexts.dao. 4. GoogleConfig.java & MailConfig.java: [Deleted]: Functionality available on library project. 5. EmailController.java: [New]: Used for contact-us page in portal. 6. ExceptionsHandler.java & /controllers/: Add more and detailed logs. 7. Stakeholder.java: a. Field 'logoUrl' added. b. Method 'getType()' returns type.name() and 'setType()' gets String and converts it into StakeholderType. 8. Topic.java & Category.java & SubCategory.java & Indicator.java: a. Field 'boolean isDefault' changed to 'String defaultId'. b. Method copyFromDefault() added to create a clone from default entity (topic, category, subcategory, indicator). 9. Category.java & SubCategory.java: Field 'String description' added. 10. SubCategory.java: Field 'String stakeholderId' added | method createOverviewSubCategory(Category) added. 11. Indicator.java & IndicatorPath.java: Method 'getType()' returns type.name() and 'setType()' gets String and converts it into IndicatorType / IndicatorPathType. 12. IndicatorPath.java: Constructor and copy constructor added. 13. StakeholderDAO.java & MongoDBStakeholderDAO.java: a. Method findByIsDefaultProfile() changed to: findByDefaultId() & findByDefaultIdNot(). b. Method findByIsDefaultProfileAndType() changed to: findByDefaultIdAndType() & findByDefaultIdNotAndType(). 14. SubCategoryDAO.java & MongoDBSubCategoryDAO.java & IndicatorDAO.java & MongoDBSubCategoryDAO.java: Method 'findByDefaultId()' added. 15. StakeholderController.java: Handle creationDate and updateDate | Add more exceptional cases. 16. TopicController.java: a. Helper method 'onSaveDefaultTopic()' added (save cloned topic on stakeholders based on this default Stakeholder). b. Helper method 'onUpdateDefaultTopic()' added (update cloned topics based on this default topic). 17. CategoryController.java: a. Remove 'subCategory.setIsDefault(true);' when a category is created. b. Helper method 'onSaveDefaultCategory()' added (save cloned category on topics based on this default Topic). c. Helper method 'onUpdateDefaultCategory()' added (update cloned categories based on this default category). 18. SubCategoryController.java: a. Helper method 'onSaveDefaultSubCategory()' added (save cloned subCategory on topics based on this default Category). b. Helper method 'onUpdateDefaultSubCategory()' added (update cloned subCategories based on this default subCategory). 19. IndicatorController.java: a. Helper method 'onSaveDefaultIndicator()' added (save cloned indicator on subCategories based on this default SubCategory). b. Helper method 'onUpdateDefaultIndicator()' added (update cloned indicators based on this default indicator). c. Helper method 'parameterMapping()' added to map correct parameter values on parameters depending on stakeholder info. d. Method 'toggleIndicatorStatus()' added to toggle 'isActive' field. e. Method 'toggleIndicatorAccess()' added to toggle 'isPublic' field. f. Helper method 'toggleIndicator()' added to update indicator when a field is toggled.
2019-12-19 16:04:25 +01:00
}
} else {
topicDAO.save(topic);
1. pom.xml: Add dependency for "uoa-help-texts-library" (will be renamed). 2. UoaMonitorServiceApplication.java: Add @PropertySource path used in dl170. 3. MongoConnection.java: @EnableMongoRepositories not only from: eu.dnetlib.uoamonitorservice.dao, but also: eu.dnetlib.uoahelptexts.dao. 4. GoogleConfig.java & MailConfig.java: [Deleted]: Functionality available on library project. 5. EmailController.java: [New]: Used for contact-us page in portal. 6. ExceptionsHandler.java & /controllers/: Add more and detailed logs. 7. Stakeholder.java: a. Field 'logoUrl' added. b. Method 'getType()' returns type.name() and 'setType()' gets String and converts it into StakeholderType. 8. Topic.java & Category.java & SubCategory.java & Indicator.java: a. Field 'boolean isDefault' changed to 'String defaultId'. b. Method copyFromDefault() added to create a clone from default entity (topic, category, subcategory, indicator). 9. Category.java & SubCategory.java: Field 'String description' added. 10. SubCategory.java: Field 'String stakeholderId' added | method createOverviewSubCategory(Category) added. 11. Indicator.java & IndicatorPath.java: Method 'getType()' returns type.name() and 'setType()' gets String and converts it into IndicatorType / IndicatorPathType. 12. IndicatorPath.java: Constructor and copy constructor added. 13. StakeholderDAO.java & MongoDBStakeholderDAO.java: a. Method findByIsDefaultProfile() changed to: findByDefaultId() & findByDefaultIdNot(). b. Method findByIsDefaultProfileAndType() changed to: findByDefaultIdAndType() & findByDefaultIdNotAndType(). 14. SubCategoryDAO.java & MongoDBSubCategoryDAO.java & IndicatorDAO.java & MongoDBSubCategoryDAO.java: Method 'findByDefaultId()' added. 15. StakeholderController.java: Handle creationDate and updateDate | Add more exceptional cases. 16. TopicController.java: a. Helper method 'onSaveDefaultTopic()' added (save cloned topic on stakeholders based on this default Stakeholder). b. Helper method 'onUpdateDefaultTopic()' added (update cloned topics based on this default topic). 17. CategoryController.java: a. Remove 'subCategory.setIsDefault(true);' when a category is created. b. Helper method 'onSaveDefaultCategory()' added (save cloned category on topics based on this default Topic). c. Helper method 'onUpdateDefaultCategory()' added (update cloned categories based on this default category). 18. SubCategoryController.java: a. Helper method 'onSaveDefaultSubCategory()' added (save cloned subCategory on topics based on this default Category). b. Helper method 'onUpdateDefaultSubCategory()' added (update cloned subCategories based on this default subCategory). 19. IndicatorController.java: a. Helper method 'onSaveDefaultIndicator()' added (save cloned indicator on subCategories based on this default SubCategory). b. Helper method 'onUpdateDefaultIndicator()' added (update cloned indicators based on this default indicator). c. Helper method 'parameterMapping()' added to map correct parameter values on parameters depending on stakeholder info. d. Method 'toggleIndicatorStatus()' added to toggle 'isActive' field. e. Method 'toggleIndicatorAccess()' added to toggle 'isPublic' field. f. Helper method 'toggleIndicator()' added to update indicator when a field is toggled.
2019-12-19 16:04:25 +01:00
}
List<String> topics = stakeholder.getTopics();
1. pom.xml: Add dependency for "uoa-help-texts-library" (will be renamed). 2. UoaMonitorServiceApplication.java: Add @PropertySource path used in dl170. 3. MongoConnection.java: @EnableMongoRepositories not only from: eu.dnetlib.uoamonitorservice.dao, but also: eu.dnetlib.uoahelptexts.dao. 4. GoogleConfig.java & MailConfig.java: [Deleted]: Functionality available on library project. 5. EmailController.java: [New]: Used for contact-us page in portal. 6. ExceptionsHandler.java & /controllers/: Add more and detailed logs. 7. Stakeholder.java: a. Field 'logoUrl' added. b. Method 'getType()' returns type.name() and 'setType()' gets String and converts it into StakeholderType. 8. Topic.java & Category.java & SubCategory.java & Indicator.java: a. Field 'boolean isDefault' changed to 'String defaultId'. b. Method copyFromDefault() added to create a clone from default entity (topic, category, subcategory, indicator). 9. Category.java & SubCategory.java: Field 'String description' added. 10. SubCategory.java: Field 'String stakeholderId' added | method createOverviewSubCategory(Category) added. 11. Indicator.java & IndicatorPath.java: Method 'getType()' returns type.name() and 'setType()' gets String and converts it into IndicatorType / IndicatorPathType. 12. IndicatorPath.java: Constructor and copy constructor added. 13. StakeholderDAO.java & MongoDBStakeholderDAO.java: a. Method findByIsDefaultProfile() changed to: findByDefaultId() & findByDefaultIdNot(). b. Method findByIsDefaultProfileAndType() changed to: findByDefaultIdAndType() & findByDefaultIdNotAndType(). 14. SubCategoryDAO.java & MongoDBSubCategoryDAO.java & IndicatorDAO.java & MongoDBSubCategoryDAO.java: Method 'findByDefaultId()' added. 15. StakeholderController.java: Handle creationDate and updateDate | Add more exceptional cases. 16. TopicController.java: a. Helper method 'onSaveDefaultTopic()' added (save cloned topic on stakeholders based on this default Stakeholder). b. Helper method 'onUpdateDefaultTopic()' added (update cloned topics based on this default topic). 17. CategoryController.java: a. Remove 'subCategory.setIsDefault(true);' when a category is created. b. Helper method 'onSaveDefaultCategory()' added (save cloned category on topics based on this default Topic). c. Helper method 'onUpdateDefaultCategory()' added (update cloned categories based on this default category). 18. SubCategoryController.java: a. Helper method 'onSaveDefaultSubCategory()' added (save cloned subCategory on topics based on this default Category). b. Helper method 'onUpdateDefaultSubCategory()' added (update cloned subCategories based on this default subCategory). 19. IndicatorController.java: a. Helper method 'onSaveDefaultIndicator()' added (save cloned indicator on subCategories based on this default SubCategory). b. Helper method 'onUpdateDefaultIndicator()' added (update cloned indicators based on this default indicator). c. Helper method 'parameterMapping()' added to map correct parameter values on parameters depending on stakeholder info. d. Method 'toggleIndicatorStatus()' added to toggle 'isActive' field. e. Method 'toggleIndicatorAccess()' added to toggle 'isPublic' field. f. Helper method 'toggleIndicator()' added to update indicator when a field is toggled.
2019-12-19 16:04:25 +01:00
int index = topics.indexOf(topic.getId());
if(index == -1) {
1. pom.xml: Add dependency for "uoa-help-texts-library" (will be renamed). 2. UoaMonitorServiceApplication.java: Add @PropertySource path used in dl170. 3. MongoConnection.java: @EnableMongoRepositories not only from: eu.dnetlib.uoamonitorservice.dao, but also: eu.dnetlib.uoahelptexts.dao. 4. GoogleConfig.java & MailConfig.java: [Deleted]: Functionality available on library project. 5. EmailController.java: [New]: Used for contact-us page in portal. 6. ExceptionsHandler.java & /controllers/: Add more and detailed logs. 7. Stakeholder.java: a. Field 'logoUrl' added. b. Method 'getType()' returns type.name() and 'setType()' gets String and converts it into StakeholderType. 8. Topic.java & Category.java & SubCategory.java & Indicator.java: a. Field 'boolean isDefault' changed to 'String defaultId'. b. Method copyFromDefault() added to create a clone from default entity (topic, category, subcategory, indicator). 9. Category.java & SubCategory.java: Field 'String description' added. 10. SubCategory.java: Field 'String stakeholderId' added | method createOverviewSubCategory(Category) added. 11. Indicator.java & IndicatorPath.java: Method 'getType()' returns type.name() and 'setType()' gets String and converts it into IndicatorType / IndicatorPathType. 12. IndicatorPath.java: Constructor and copy constructor added. 13. StakeholderDAO.java & MongoDBStakeholderDAO.java: a. Method findByIsDefaultProfile() changed to: findByDefaultId() & findByDefaultIdNot(). b. Method findByIsDefaultProfileAndType() changed to: findByDefaultIdAndType() & findByDefaultIdNotAndType(). 14. SubCategoryDAO.java & MongoDBSubCategoryDAO.java & IndicatorDAO.java & MongoDBSubCategoryDAO.java: Method 'findByDefaultId()' added. 15. StakeholderController.java: Handle creationDate and updateDate | Add more exceptional cases. 16. TopicController.java: a. Helper method 'onSaveDefaultTopic()' added (save cloned topic on stakeholders based on this default Stakeholder). b. Helper method 'onUpdateDefaultTopic()' added (update cloned topics based on this default topic). 17. CategoryController.java: a. Remove 'subCategory.setIsDefault(true);' when a category is created. b. Helper method 'onSaveDefaultCategory()' added (save cloned category on topics based on this default Topic). c. Helper method 'onUpdateDefaultCategory()' added (update cloned categories based on this default category). 18. SubCategoryController.java: a. Helper method 'onSaveDefaultSubCategory()' added (save cloned subCategory on topics based on this default Category). b. Helper method 'onUpdateDefaultSubCategory()' added (update cloned subCategories based on this default subCategory). 19. IndicatorController.java: a. Helper method 'onSaveDefaultIndicator()' added (save cloned indicator on subCategories based on this default SubCategory). b. Helper method 'onUpdateDefaultIndicator()' added (update cloned indicators based on this default indicator). c. Helper method 'parameterMapping()' added to map correct parameter values on parameters depending on stakeholder info. d. Method 'toggleIndicatorStatus()' added to toggle 'isActive' field. e. Method 'toggleIndicatorAccess()' added to toggle 'isPublic' field. f. Helper method 'toggleIndicator()' added to update indicator when a field is toggled.
2019-12-19 16:04:25 +01:00
topics.add(topic.getId());
stakeholderDAO.save(stakeholder);
log.debug("Topic saved!");
1. pom.xml: Add dependency for "uoa-help-texts-library" (will be renamed). 2. UoaMonitorServiceApplication.java: Add @PropertySource path used in dl170. 3. MongoConnection.java: @EnableMongoRepositories not only from: eu.dnetlib.uoamonitorservice.dao, but also: eu.dnetlib.uoahelptexts.dao. 4. GoogleConfig.java & MailConfig.java: [Deleted]: Functionality available on library project. 5. EmailController.java: [New]: Used for contact-us page in portal. 6. ExceptionsHandler.java & /controllers/: Add more and detailed logs. 7. Stakeholder.java: a. Field 'logoUrl' added. b. Method 'getType()' returns type.name() and 'setType()' gets String and converts it into StakeholderType. 8. Topic.java & Category.java & SubCategory.java & Indicator.java: a. Field 'boolean isDefault' changed to 'String defaultId'. b. Method copyFromDefault() added to create a clone from default entity (topic, category, subcategory, indicator). 9. Category.java & SubCategory.java: Field 'String description' added. 10. SubCategory.java: Field 'String stakeholderId' added | method createOverviewSubCategory(Category) added. 11. Indicator.java & IndicatorPath.java: Method 'getType()' returns type.name() and 'setType()' gets String and converts it into IndicatorType / IndicatorPathType. 12. IndicatorPath.java: Constructor and copy constructor added. 13. StakeholderDAO.java & MongoDBStakeholderDAO.java: a. Method findByIsDefaultProfile() changed to: findByDefaultId() & findByDefaultIdNot(). b. Method findByIsDefaultProfileAndType() changed to: findByDefaultIdAndType() & findByDefaultIdNotAndType(). 14. SubCategoryDAO.java & MongoDBSubCategoryDAO.java & IndicatorDAO.java & MongoDBSubCategoryDAO.java: Method 'findByDefaultId()' added. 15. StakeholderController.java: Handle creationDate and updateDate | Add more exceptional cases. 16. TopicController.java: a. Helper method 'onSaveDefaultTopic()' added (save cloned topic on stakeholders based on this default Stakeholder). b. Helper method 'onUpdateDefaultTopic()' added (update cloned topics based on this default topic). 17. CategoryController.java: a. Remove 'subCategory.setIsDefault(true);' when a category is created. b. Helper method 'onSaveDefaultCategory()' added (save cloned category on topics based on this default Topic). c. Helper method 'onUpdateDefaultCategory()' added (update cloned categories based on this default category). 18. SubCategoryController.java: a. Helper method 'onSaveDefaultSubCategory()' added (save cloned subCategory on topics based on this default Category). b. Helper method 'onUpdateDefaultSubCategory()' added (update cloned subCategories based on this default subCategory). 19. IndicatorController.java: a. Helper method 'onSaveDefaultIndicator()' added (save cloned indicator on subCategories based on this default SubCategory). b. Helper method 'onUpdateDefaultIndicator()' added (update cloned indicators based on this default indicator). c. Helper method 'parameterMapping()' added to map correct parameter values on parameters depending on stakeholder info. d. Method 'toggleIndicatorStatus()' added to toggle 'isActive' field. e. Method 'toggleIndicatorAccess()' added to toggle 'isPublic' field. f. Helper method 'toggleIndicator()' added to update indicator when a field is toggled.
2019-12-19 16:04:25 +01:00
topicFull.setId(topic.getId());
}
} else {
// EXCEPTION - Stakeholder not found
throw new EntityNotFoundException("Save topic: Stakeholder with id: "+stakeholderId+" not found");
}
return topicFull;
}
1. pom.xml: Add dependency for "uoa-help-texts-library" (will be renamed). 2. UoaMonitorServiceApplication.java: Add @PropertySource path used in dl170. 3. MongoConnection.java: @EnableMongoRepositories not only from: eu.dnetlib.uoamonitorservice.dao, but also: eu.dnetlib.uoahelptexts.dao. 4. GoogleConfig.java & MailConfig.java: [Deleted]: Functionality available on library project. 5. EmailController.java: [New]: Used for contact-us page in portal. 6. ExceptionsHandler.java & /controllers/: Add more and detailed logs. 7. Stakeholder.java: a. Field 'logoUrl' added. b. Method 'getType()' returns type.name() and 'setType()' gets String and converts it into StakeholderType. 8. Topic.java & Category.java & SubCategory.java & Indicator.java: a. Field 'boolean isDefault' changed to 'String defaultId'. b. Method copyFromDefault() added to create a clone from default entity (topic, category, subcategory, indicator). 9. Category.java & SubCategory.java: Field 'String description' added. 10. SubCategory.java: Field 'String stakeholderId' added | method createOverviewSubCategory(Category) added. 11. Indicator.java & IndicatorPath.java: Method 'getType()' returns type.name() and 'setType()' gets String and converts it into IndicatorType / IndicatorPathType. 12. IndicatorPath.java: Constructor and copy constructor added. 13. StakeholderDAO.java & MongoDBStakeholderDAO.java: a. Method findByIsDefaultProfile() changed to: findByDefaultId() & findByDefaultIdNot(). b. Method findByIsDefaultProfileAndType() changed to: findByDefaultIdAndType() & findByDefaultIdNotAndType(). 14. SubCategoryDAO.java & MongoDBSubCategoryDAO.java & IndicatorDAO.java & MongoDBSubCategoryDAO.java: Method 'findByDefaultId()' added. 15. StakeholderController.java: Handle creationDate and updateDate | Add more exceptional cases. 16. TopicController.java: a. Helper method 'onSaveDefaultTopic()' added (save cloned topic on stakeholders based on this default Stakeholder). b. Helper method 'onUpdateDefaultTopic()' added (update cloned topics based on this default topic). 17. CategoryController.java: a. Remove 'subCategory.setIsDefault(true);' when a category is created. b. Helper method 'onSaveDefaultCategory()' added (save cloned category on topics based on this default Topic). c. Helper method 'onUpdateDefaultCategory()' added (update cloned categories based on this default category). 18. SubCategoryController.java: a. Helper method 'onSaveDefaultSubCategory()' added (save cloned subCategory on topics based on this default Category). b. Helper method 'onUpdateDefaultSubCategory()' added (update cloned subCategories based on this default subCategory). 19. IndicatorController.java: a. Helper method 'onSaveDefaultIndicator()' added (save cloned indicator on subCategories based on this default SubCategory). b. Helper method 'onUpdateDefaultIndicator()' added (update cloned indicators based on this default indicator). c. Helper method 'parameterMapping()' added to map correct parameter values on parameters depending on stakeholder info. d. Method 'toggleIndicatorStatus()' added to toggle 'isActive' field. e. Method 'toggleIndicatorAccess()' added to toggle 'isPublic' field. f. Helper method 'toggleIndicator()' added to update indicator when a field is toggled.
2019-12-19 16:04:25 +01:00
public void onSaveDefaultTopic(Topic topic, String stakeholderId) {
log.debug("On save default topic");
List<Stakeholder> stakeholders = stakeholderDAO.findByDefaultId(stakeholderId);
for(Stakeholder _stakeholder : stakeholders) {
Topic topicNew = new Topic();
topicNew.copyFromDefault(topic);
topicDAO.save(topicNew);
List<String> topics = _stakeholder.getTopics();
topics.add(topicNew.getId());
stakeholderDAO.save(_stakeholder);
}
}
public void onUpdateDefaultTopic(Topic topic, Topic oldTopic) {
1. pom.xml: Add dependency for "uoa-help-texts-library" (will be renamed). 2. UoaMonitorServiceApplication.java: Add @PropertySource path used in dl170. 3. MongoConnection.java: @EnableMongoRepositories not only from: eu.dnetlib.uoamonitorservice.dao, but also: eu.dnetlib.uoahelptexts.dao. 4. GoogleConfig.java & MailConfig.java: [Deleted]: Functionality available on library project. 5. EmailController.java: [New]: Used for contact-us page in portal. 6. ExceptionsHandler.java & /controllers/: Add more and detailed logs. 7. Stakeholder.java: a. Field 'logoUrl' added. b. Method 'getType()' returns type.name() and 'setType()' gets String and converts it into StakeholderType. 8. Topic.java & Category.java & SubCategory.java & Indicator.java: a. Field 'boolean isDefault' changed to 'String defaultId'. b. Method copyFromDefault() added to create a clone from default entity (topic, category, subcategory, indicator). 9. Category.java & SubCategory.java: Field 'String description' added. 10. SubCategory.java: Field 'String stakeholderId' added | method createOverviewSubCategory(Category) added. 11. Indicator.java & IndicatorPath.java: Method 'getType()' returns type.name() and 'setType()' gets String and converts it into IndicatorType / IndicatorPathType. 12. IndicatorPath.java: Constructor and copy constructor added. 13. StakeholderDAO.java & MongoDBStakeholderDAO.java: a. Method findByIsDefaultProfile() changed to: findByDefaultId() & findByDefaultIdNot(). b. Method findByIsDefaultProfileAndType() changed to: findByDefaultIdAndType() & findByDefaultIdNotAndType(). 14. SubCategoryDAO.java & MongoDBSubCategoryDAO.java & IndicatorDAO.java & MongoDBSubCategoryDAO.java: Method 'findByDefaultId()' added. 15. StakeholderController.java: Handle creationDate and updateDate | Add more exceptional cases. 16. TopicController.java: a. Helper method 'onSaveDefaultTopic()' added (save cloned topic on stakeholders based on this default Stakeholder). b. Helper method 'onUpdateDefaultTopic()' added (update cloned topics based on this default topic). 17. CategoryController.java: a. Remove 'subCategory.setIsDefault(true);' when a category is created. b. Helper method 'onSaveDefaultCategory()' added (save cloned category on topics based on this default Topic). c. Helper method 'onUpdateDefaultCategory()' added (update cloned categories based on this default category). 18. SubCategoryController.java: a. Helper method 'onSaveDefaultSubCategory()' added (save cloned subCategory on topics based on this default Category). b. Helper method 'onUpdateDefaultSubCategory()' added (update cloned subCategories based on this default subCategory). 19. IndicatorController.java: a. Helper method 'onSaveDefaultIndicator()' added (save cloned indicator on subCategories based on this default SubCategory). b. Helper method 'onUpdateDefaultIndicator()' added (update cloned indicators based on this default indicator). c. Helper method 'parameterMapping()' added to map correct parameter values on parameters depending on stakeholder info. d. Method 'toggleIndicatorStatus()' added to toggle 'isActive' field. e. Method 'toggleIndicatorAccess()' added to toggle 'isPublic' field. f. Helper method 'toggleIndicator()' added to update indicator when a field is toggled.
2019-12-19 16:04:25 +01:00
log.debug("On update default topic");
List<Topic> topics = topicDAO.findByDefaultId(topic.getId());
boolean changed = false;
for(Topic topicBasedOnDefault : topics) {
if(topic.getName() != null && !topic.getName().equals(topicBasedOnDefault.getName())
&& (oldTopic.getName() == null || oldTopic.getName().equals(topicBasedOnDefault.getName()))) {
topicBasedOnDefault.setName(topic.getName());
topicBasedOnDefault.setAlias(topic.getAlias());
1. pom.xml: Add dependency for "uoa-help-texts-library" (will be renamed). 2. UoaMonitorServiceApplication.java: Add @PropertySource path used in dl170. 3. MongoConnection.java: @EnableMongoRepositories not only from: eu.dnetlib.uoamonitorservice.dao, but also: eu.dnetlib.uoahelptexts.dao. 4. GoogleConfig.java & MailConfig.java: [Deleted]: Functionality available on library project. 5. EmailController.java: [New]: Used for contact-us page in portal. 6. ExceptionsHandler.java & /controllers/: Add more and detailed logs. 7. Stakeholder.java: a. Field 'logoUrl' added. b. Method 'getType()' returns type.name() and 'setType()' gets String and converts it into StakeholderType. 8. Topic.java & Category.java & SubCategory.java & Indicator.java: a. Field 'boolean isDefault' changed to 'String defaultId'. b. Method copyFromDefault() added to create a clone from default entity (topic, category, subcategory, indicator). 9. Category.java & SubCategory.java: Field 'String description' added. 10. SubCategory.java: Field 'String stakeholderId' added | method createOverviewSubCategory(Category) added. 11. Indicator.java & IndicatorPath.java: Method 'getType()' returns type.name() and 'setType()' gets String and converts it into IndicatorType / IndicatorPathType. 12. IndicatorPath.java: Constructor and copy constructor added. 13. StakeholderDAO.java & MongoDBStakeholderDAO.java: a. Method findByIsDefaultProfile() changed to: findByDefaultId() & findByDefaultIdNot(). b. Method findByIsDefaultProfileAndType() changed to: findByDefaultIdAndType() & findByDefaultIdNotAndType(). 14. SubCategoryDAO.java & MongoDBSubCategoryDAO.java & IndicatorDAO.java & MongoDBSubCategoryDAO.java: Method 'findByDefaultId()' added. 15. StakeholderController.java: Handle creationDate and updateDate | Add more exceptional cases. 16. TopicController.java: a. Helper method 'onSaveDefaultTopic()' added (save cloned topic on stakeholders based on this default Stakeholder). b. Helper method 'onUpdateDefaultTopic()' added (update cloned topics based on this default topic). 17. CategoryController.java: a. Remove 'subCategory.setIsDefault(true);' when a category is created. b. Helper method 'onSaveDefaultCategory()' added (save cloned category on topics based on this default Topic). c. Helper method 'onUpdateDefaultCategory()' added (update cloned categories based on this default category). 18. SubCategoryController.java: a. Helper method 'onSaveDefaultSubCategory()' added (save cloned subCategory on topics based on this default Category). b. Helper method 'onUpdateDefaultSubCategory()' added (update cloned subCategories based on this default subCategory). 19. IndicatorController.java: a. Helper method 'onSaveDefaultIndicator()' added (save cloned indicator on subCategories based on this default SubCategory). b. Helper method 'onUpdateDefaultIndicator()' added (update cloned indicators based on this default indicator). c. Helper method 'parameterMapping()' added to map correct parameter values on parameters depending on stakeholder info. d. Method 'toggleIndicatorStatus()' added to toggle 'isActive' field. e. Method 'toggleIndicatorAccess()' added to toggle 'isPublic' field. f. Helper method 'toggleIndicator()' added to update indicator when a field is toggled.
2019-12-19 16:04:25 +01:00
changed = true;
}
if(topic.getDescription() != null && !topic.getDescription().equals(topicBasedOnDefault.getDescription())
&& (oldTopic.getDescription() == null || oldTopic.getDescription().equals(topicBasedOnDefault.getDescription()))) {
topicBasedOnDefault.setDescription(topic.getDescription());
1. pom.xml: Add dependency for "uoa-help-texts-library" (will be renamed). 2. UoaMonitorServiceApplication.java: Add @PropertySource path used in dl170. 3. MongoConnection.java: @EnableMongoRepositories not only from: eu.dnetlib.uoamonitorservice.dao, but also: eu.dnetlib.uoahelptexts.dao. 4. GoogleConfig.java & MailConfig.java: [Deleted]: Functionality available on library project. 5. EmailController.java: [New]: Used for contact-us page in portal. 6. ExceptionsHandler.java & /controllers/: Add more and detailed logs. 7. Stakeholder.java: a. Field 'logoUrl' added. b. Method 'getType()' returns type.name() and 'setType()' gets String and converts it into StakeholderType. 8. Topic.java & Category.java & SubCategory.java & Indicator.java: a. Field 'boolean isDefault' changed to 'String defaultId'. b. Method copyFromDefault() added to create a clone from default entity (topic, category, subcategory, indicator). 9. Category.java & SubCategory.java: Field 'String description' added. 10. SubCategory.java: Field 'String stakeholderId' added | method createOverviewSubCategory(Category) added. 11. Indicator.java & IndicatorPath.java: Method 'getType()' returns type.name() and 'setType()' gets String and converts it into IndicatorType / IndicatorPathType. 12. IndicatorPath.java: Constructor and copy constructor added. 13. StakeholderDAO.java & MongoDBStakeholderDAO.java: a. Method findByIsDefaultProfile() changed to: findByDefaultId() & findByDefaultIdNot(). b. Method findByIsDefaultProfileAndType() changed to: findByDefaultIdAndType() & findByDefaultIdNotAndType(). 14. SubCategoryDAO.java & MongoDBSubCategoryDAO.java & IndicatorDAO.java & MongoDBSubCategoryDAO.java: Method 'findByDefaultId()' added. 15. StakeholderController.java: Handle creationDate and updateDate | Add more exceptional cases. 16. TopicController.java: a. Helper method 'onSaveDefaultTopic()' added (save cloned topic on stakeholders based on this default Stakeholder). b. Helper method 'onUpdateDefaultTopic()' added (update cloned topics based on this default topic). 17. CategoryController.java: a. Remove 'subCategory.setIsDefault(true);' when a category is created. b. Helper method 'onSaveDefaultCategory()' added (save cloned category on topics based on this default Topic). c. Helper method 'onUpdateDefaultCategory()' added (update cloned categories based on this default category). 18. SubCategoryController.java: a. Helper method 'onSaveDefaultSubCategory()' added (save cloned subCategory on topics based on this default Category). b. Helper method 'onUpdateDefaultSubCategory()' added (update cloned subCategories based on this default subCategory). 19. IndicatorController.java: a. Helper method 'onSaveDefaultIndicator()' added (save cloned indicator on subCategories based on this default SubCategory). b. Helper method 'onUpdateDefaultIndicator()' added (update cloned indicators based on this default indicator). c. Helper method 'parameterMapping()' added to map correct parameter values on parameters depending on stakeholder info. d. Method 'toggleIndicatorStatus()' added to toggle 'isActive' field. e. Method 'toggleIndicatorAccess()' added to toggle 'isPublic' field. f. Helper method 'toggleIndicator()' added to update indicator when a field is toggled.
2019-12-19 16:04:25 +01:00
changed = true;
}
if(topic.getIcon() != null && !topic.getIcon().equals(topicBasedOnDefault.getIcon())
&& (oldTopic.getIcon() == null || oldTopic.getIcon().equals(topicBasedOnDefault.getIcon()))) {
topicBasedOnDefault.setIcon(topic.getIcon());
changed = true;
}
1. pom.xml: Add dependency for "uoa-help-texts-library" (will be renamed). 2. UoaMonitorServiceApplication.java: Add @PropertySource path used in dl170. 3. MongoConnection.java: @EnableMongoRepositories not only from: eu.dnetlib.uoamonitorservice.dao, but also: eu.dnetlib.uoahelptexts.dao. 4. GoogleConfig.java & MailConfig.java: [Deleted]: Functionality available on library project. 5. EmailController.java: [New]: Used for contact-us page in portal. 6. ExceptionsHandler.java & /controllers/: Add more and detailed logs. 7. Stakeholder.java: a. Field 'logoUrl' added. b. Method 'getType()' returns type.name() and 'setType()' gets String and converts it into StakeholderType. 8. Topic.java & Category.java & SubCategory.java & Indicator.java: a. Field 'boolean isDefault' changed to 'String defaultId'. b. Method copyFromDefault() added to create a clone from default entity (topic, category, subcategory, indicator). 9. Category.java & SubCategory.java: Field 'String description' added. 10. SubCategory.java: Field 'String stakeholderId' added | method createOverviewSubCategory(Category) added. 11. Indicator.java & IndicatorPath.java: Method 'getType()' returns type.name() and 'setType()' gets String and converts it into IndicatorType / IndicatorPathType. 12. IndicatorPath.java: Constructor and copy constructor added. 13. StakeholderDAO.java & MongoDBStakeholderDAO.java: a. Method findByIsDefaultProfile() changed to: findByDefaultId() & findByDefaultIdNot(). b. Method findByIsDefaultProfileAndType() changed to: findByDefaultIdAndType() & findByDefaultIdNotAndType(). 14. SubCategoryDAO.java & MongoDBSubCategoryDAO.java & IndicatorDAO.java & MongoDBSubCategoryDAO.java: Method 'findByDefaultId()' added. 15. StakeholderController.java: Handle creationDate and updateDate | Add more exceptional cases. 16. TopicController.java: a. Helper method 'onSaveDefaultTopic()' added (save cloned topic on stakeholders based on this default Stakeholder). b. Helper method 'onUpdateDefaultTopic()' added (update cloned topics based on this default topic). 17. CategoryController.java: a. Remove 'subCategory.setIsDefault(true);' when a category is created. b. Helper method 'onSaveDefaultCategory()' added (save cloned category on topics based on this default Topic). c. Helper method 'onUpdateDefaultCategory()' added (update cloned categories based on this default category). 18. SubCategoryController.java: a. Helper method 'onSaveDefaultSubCategory()' added (save cloned subCategory on topics based on this default Category). b. Helper method 'onUpdateDefaultSubCategory()' added (update cloned subCategories based on this default subCategory). 19. IndicatorController.java: a. Helper method 'onSaveDefaultIndicator()' added (save cloned indicator on subCategories based on this default SubCategory). b. Helper method 'onUpdateDefaultIndicator()' added (update cloned indicators based on this default indicator). c. Helper method 'parameterMapping()' added to map correct parameter values on parameters depending on stakeholder info. d. Method 'toggleIndicatorStatus()' added to toggle 'isActive' field. e. Method 'toggleIndicatorAccess()' added to toggle 'isPublic' field. f. Helper method 'toggleIndicator()' added to update indicator when a field is toggled.
2019-12-19 16:04:25 +01:00
if(!changed) {
continue;
1. pom.xml: Add dependency for "uoa-help-texts-library" (will be renamed). 2. UoaMonitorServiceApplication.java: Add @PropertySource path used in dl170. 3. MongoConnection.java: @EnableMongoRepositories not only from: eu.dnetlib.uoamonitorservice.dao, but also: eu.dnetlib.uoahelptexts.dao. 4. GoogleConfig.java & MailConfig.java: [Deleted]: Functionality available on library project. 5. EmailController.java: [New]: Used for contact-us page in portal. 6. ExceptionsHandler.java & /controllers/: Add more and detailed logs. 7. Stakeholder.java: a. Field 'logoUrl' added. b. Method 'getType()' returns type.name() and 'setType()' gets String and converts it into StakeholderType. 8. Topic.java & Category.java & SubCategory.java & Indicator.java: a. Field 'boolean isDefault' changed to 'String defaultId'. b. Method copyFromDefault() added to create a clone from default entity (topic, category, subcategory, indicator). 9. Category.java & SubCategory.java: Field 'String description' added. 10. SubCategory.java: Field 'String stakeholderId' added | method createOverviewSubCategory(Category) added. 11. Indicator.java & IndicatorPath.java: Method 'getType()' returns type.name() and 'setType()' gets String and converts it into IndicatorType / IndicatorPathType. 12. IndicatorPath.java: Constructor and copy constructor added. 13. StakeholderDAO.java & MongoDBStakeholderDAO.java: a. Method findByIsDefaultProfile() changed to: findByDefaultId() & findByDefaultIdNot(). b. Method findByIsDefaultProfileAndType() changed to: findByDefaultIdAndType() & findByDefaultIdNotAndType(). 14. SubCategoryDAO.java & MongoDBSubCategoryDAO.java & IndicatorDAO.java & MongoDBSubCategoryDAO.java: Method 'findByDefaultId()' added. 15. StakeholderController.java: Handle creationDate and updateDate | Add more exceptional cases. 16. TopicController.java: a. Helper method 'onSaveDefaultTopic()' added (save cloned topic on stakeholders based on this default Stakeholder). b. Helper method 'onUpdateDefaultTopic()' added (update cloned topics based on this default topic). 17. CategoryController.java: a. Remove 'subCategory.setIsDefault(true);' when a category is created. b. Helper method 'onSaveDefaultCategory()' added (save cloned category on topics based on this default Topic). c. Helper method 'onUpdateDefaultCategory()' added (update cloned categories based on this default category). 18. SubCategoryController.java: a. Helper method 'onSaveDefaultSubCategory()' added (save cloned subCategory on topics based on this default Category). b. Helper method 'onUpdateDefaultSubCategory()' added (update cloned subCategories based on this default subCategory). 19. IndicatorController.java: a. Helper method 'onSaveDefaultIndicator()' added (save cloned indicator on subCategories based on this default SubCategory). b. Helper method 'onUpdateDefaultIndicator()' added (update cloned indicators based on this default indicator). c. Helper method 'parameterMapping()' added to map correct parameter values on parameters depending on stakeholder info. d. Method 'toggleIndicatorStatus()' added to toggle 'isActive' field. e. Method 'toggleIndicatorAccess()' added to toggle 'isPublic' field. f. Helper method 'toggleIndicator()' added to update indicator when a field is toggled.
2019-12-19 16:04:25 +01:00
}
topicBasedOnDefault.setUpdateDate(topic.getUpdateDate());
1. pom.xml: Add dependency for "uoa-help-texts-library" (will be renamed). 2. UoaMonitorServiceApplication.java: Add @PropertySource path used in dl170. 3. MongoConnection.java: @EnableMongoRepositories not only from: eu.dnetlib.uoamonitorservice.dao, but also: eu.dnetlib.uoahelptexts.dao. 4. GoogleConfig.java & MailConfig.java: [Deleted]: Functionality available on library project. 5. EmailController.java: [New]: Used for contact-us page in portal. 6. ExceptionsHandler.java & /controllers/: Add more and detailed logs. 7. Stakeholder.java: a. Field 'logoUrl' added. b. Method 'getType()' returns type.name() and 'setType()' gets String and converts it into StakeholderType. 8. Topic.java & Category.java & SubCategory.java & Indicator.java: a. Field 'boolean isDefault' changed to 'String defaultId'. b. Method copyFromDefault() added to create a clone from default entity (topic, category, subcategory, indicator). 9. Category.java & SubCategory.java: Field 'String description' added. 10. SubCategory.java: Field 'String stakeholderId' added | method createOverviewSubCategory(Category) added. 11. Indicator.java & IndicatorPath.java: Method 'getType()' returns type.name() and 'setType()' gets String and converts it into IndicatorType / IndicatorPathType. 12. IndicatorPath.java: Constructor and copy constructor added. 13. StakeholderDAO.java & MongoDBStakeholderDAO.java: a. Method findByIsDefaultProfile() changed to: findByDefaultId() & findByDefaultIdNot(). b. Method findByIsDefaultProfileAndType() changed to: findByDefaultIdAndType() & findByDefaultIdNotAndType(). 14. SubCategoryDAO.java & MongoDBSubCategoryDAO.java & IndicatorDAO.java & MongoDBSubCategoryDAO.java: Method 'findByDefaultId()' added. 15. StakeholderController.java: Handle creationDate and updateDate | Add more exceptional cases. 16. TopicController.java: a. Helper method 'onSaveDefaultTopic()' added (save cloned topic on stakeholders based on this default Stakeholder). b. Helper method 'onUpdateDefaultTopic()' added (update cloned topics based on this default topic). 17. CategoryController.java: a. Remove 'subCategory.setIsDefault(true);' when a category is created. b. Helper method 'onSaveDefaultCategory()' added (save cloned category on topics based on this default Topic). c. Helper method 'onUpdateDefaultCategory()' added (update cloned categories based on this default category). 18. SubCategoryController.java: a. Helper method 'onSaveDefaultSubCategory()' added (save cloned subCategory on topics based on this default Category). b. Helper method 'onUpdateDefaultSubCategory()' added (update cloned subCategories based on this default subCategory). 19. IndicatorController.java: a. Helper method 'onSaveDefaultIndicator()' added (save cloned indicator on subCategories based on this default SubCategory). b. Helper method 'onUpdateDefaultIndicator()' added (update cloned indicators based on this default indicator). c. Helper method 'parameterMapping()' added to map correct parameter values on parameters depending on stakeholder info. d. Method 'toggleIndicatorStatus()' added to toggle 'isActive' field. e. Method 'toggleIndicatorAccess()' added to toggle 'isPublic' field. f. Helper method 'toggleIndicator()' added to update indicator when a field is toggled.
2019-12-19 16:04:25 +01:00
topicDAO.save(topicBasedOnDefault);
}
}*/
1. pom.xml: Add dependency for "uoa-help-texts-library" (will be renamed). 2. UoaMonitorServiceApplication.java: Add @PropertySource path used in dl170. 3. MongoConnection.java: @EnableMongoRepositories not only from: eu.dnetlib.uoamonitorservice.dao, but also: eu.dnetlib.uoahelptexts.dao. 4. GoogleConfig.java & MailConfig.java: [Deleted]: Functionality available on library project. 5. EmailController.java: [New]: Used for contact-us page in portal. 6. ExceptionsHandler.java & /controllers/: Add more and detailed logs. 7. Stakeholder.java: a. Field 'logoUrl' added. b. Method 'getType()' returns type.name() and 'setType()' gets String and converts it into StakeholderType. 8. Topic.java & Category.java & SubCategory.java & Indicator.java: a. Field 'boolean isDefault' changed to 'String defaultId'. b. Method copyFromDefault() added to create a clone from default entity (topic, category, subcategory, indicator). 9. Category.java & SubCategory.java: Field 'String description' added. 10. SubCategory.java: Field 'String stakeholderId' added | method createOverviewSubCategory(Category) added. 11. Indicator.java & IndicatorPath.java: Method 'getType()' returns type.name() and 'setType()' gets String and converts it into IndicatorType / IndicatorPathType. 12. IndicatorPath.java: Constructor and copy constructor added. 13. StakeholderDAO.java & MongoDBStakeholderDAO.java: a. Method findByIsDefaultProfile() changed to: findByDefaultId() & findByDefaultIdNot(). b. Method findByIsDefaultProfileAndType() changed to: findByDefaultIdAndType() & findByDefaultIdNotAndType(). 14. SubCategoryDAO.java & MongoDBSubCategoryDAO.java & IndicatorDAO.java & MongoDBSubCategoryDAO.java: Method 'findByDefaultId()' added. 15. StakeholderController.java: Handle creationDate and updateDate | Add more exceptional cases. 16. TopicController.java: a. Helper method 'onSaveDefaultTopic()' added (save cloned topic on stakeholders based on this default Stakeholder). b. Helper method 'onUpdateDefaultTopic()' added (update cloned topics based on this default topic). 17. CategoryController.java: a. Remove 'subCategory.setIsDefault(true);' when a category is created. b. Helper method 'onSaveDefaultCategory()' added (save cloned category on topics based on this default Topic). c. Helper method 'onUpdateDefaultCategory()' added (update cloned categories based on this default category). 18. SubCategoryController.java: a. Helper method 'onSaveDefaultSubCategory()' added (save cloned subCategory on topics based on this default Category). b. Helper method 'onUpdateDefaultSubCategory()' added (update cloned subCategories based on this default subCategory). 19. IndicatorController.java: a. Helper method 'onSaveDefaultIndicator()' added (save cloned indicator on subCategories based on this default SubCategory). b. Helper method 'onUpdateDefaultIndicator()' added (update cloned indicators based on this default indicator). c. Helper method 'parameterMapping()' added to map correct parameter values on parameters depending on stakeholder info. d. Method 'toggleIndicatorStatus()' added to toggle 'isActive' field. e. Method 'toggleIndicatorAccess()' added to toggle 'isPublic' field. f. Helper method 'toggleIndicator()' added to update indicator when a field is toggled.
2019-12-19 16:04:25 +01:00
@PreAuthorize("isAuthenticated()")
@RequestMapping(value = "/{stakeholderId}/{topicId}/delete", method = RequestMethod.DELETE)
public boolean deleteTopic(@PathVariable("stakeholderId") String stakeholderId,
@PathVariable("topicId") String topicId,
@RequestParam(required = false) String children) {
log.debug("delete topic");
log.debug("Id: " + topicId + " - Stakeholder: " + stakeholderId);
Stakeholder stakeholder = stakeholderService.findById(stakeholderId);
Topic topic = this.topicService.findByPath(stakeholder, topicId);
this.topicService.delete(stakeholder.getType(), topic, true);
return true;
}
/*@PreAuthorize("isAuthenticated()")
@RequestMapping(value = "/{stakeholderId}/reorder", method = RequestMethod.POST)
public List<Topic> reorderTopics(@PathVariable("stakeholderId") String stakeholderId,
@RequestBody List<String> topics) {
log.debug("reorder topics");
log.debug("Stakeholder: "+stakeholderId);
Stakeholder stakeholder = stakeholderDAO.findById(stakeholderId);
if(stakeholder != null) {
2023-07-04 15:02:34 +02:00
if(!rolesUtils.hasUpdateAuthority(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("Reorder topics: You are not authorized to update stakeholder with id: "+stakeholderId);
}
[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> oldTopics = stakeholder.getTopics();
for (String topicId : oldTopics) {
if (!topics.contains(topicId)) {
topics.add(topicId);
}
}
stakeholder.setTopics(topics);
List<Topic> topicsFull = new ArrayList<>();
for (String topicId : topics) {
[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
Topic topic = topicDAO.findById(topicId);
if(topic == null) {
// EXCEPTION - Topic not found
throw new EntityNotFoundException("Reorder Topics: Topic with id: " + topicId + " not found");
}
topicsFull.add(topic);
}
[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
stakeholderDAO.save(stakeholder);
log.debug("Topics reordered!");
return topicsFull;
} else {
// EXCEPTION - Stakeholder not found
throw new EntityNotFoundException("Reorder topics: Stakeholder with id: "+stakeholderId+" not found");
}
}*/
@PreAuthorize("isAuthenticated()")
@RequestMapping(value = "/{stakeholderId}/{topicId}/change-visibility", method = RequestMethod.POST)
public TopicFull changeTopicVisibility(@PathVariable("stakeholderId") String stakeholderId,
@PathVariable("topicId") String topicId,
@RequestParam("visibility") Visibility visibility, @RequestParam(required = false) Boolean propagate) {
log.debug("change topic visibility: " + visibility + " - toggle propagate: " + ((propagate != null && propagate) ? "true" : "false"));
log.debug("Stakeholder: " + stakeholderId + " - Topic: " + topicId);
Stakeholder stakeholder = this.stakeholderService.findById(stakeholderId);
return this.topicService.changeVisibility(stakeholder.getType(), stakeholder.getAlias(), topicId, visibility, propagate);
}
}