Project

General

Profile

« Previous | Next » 

Revision 58708

[Trunk | Monitor Service]:
1. Stakeholder.java: Field 'name' added.
2. Section.java: In method 'copyFromDefault()' initialize indicators (empty list).
3. StakeholderDAO.java & MongoDBStakeholderDAO.java: Added method 'Stakeholder findByTopicsContaining(String topic);' (needed to find in which Stakeholder a Topic belongs - section needs stakeholderAlias).
4. TopicDAO.java & MongoDBTopicDAO.java: Added method 'Topic findByCategoriesContaining(String category);' (needed to find in which Topic a Category belongs - section needs stakeholderAlias).
5. CategoryDAO.java & MongoDBCategoryDAO.java: Added method 'Category findBySubCategoriesContaining(String subCategory);' (needed to find in which Category a SubCategory belongs - section needs stakeholderAlias).
6. TopicController.java & CategoryController.java & SubCategoryController.java & SectionController.java & IndicatorController.java:
Bug fixes & changed logic for updates on default profile: When a value in a profile is same as the value in default, inherit changes in default value, otherwise keep local profile's options.

View differences:

CategoryController.java
66 66
        Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
67 67

  
68 68
        if(stakeholder != null) {
69
            Category<String> oldCategory = null;
70
            if(categoryFull.getId() != null) {
71
                oldCategory = categoryDAO.findById(categoryFull.getId());
72
            }
69 73

  
70 74
            Topic<String> topic = topicDAO.findById(topicId);
71 75
            if(topic != null) {
......
95 99
                        if(categoryFull.getId() == null) {
96 100
                            onSaveDefaultCategory(category, topicId);
97 101
                        } else {
98
                            onUpdateDefaultCategory(category);
102
                            onUpdateDefaultCategory(category, oldCategory);
99 103
                        }
100 104
                    }
101 105

  
......
146 150
        subCategoryController.onSaveDefaultSubCategory(subCategoryOverview, category.getId());
147 151
    }
148 152

  
149
    public void onUpdateDefaultCategory(Category category) {
153
    public void onUpdateDefaultCategory(Category category, Category oldCategory) {
150 154
        log.debug("On update default category");
151 155

  
152 156
        List<Category> categories = categoryDAO.findByDefaultId(category.getId());
153 157
        boolean changed = false;
154 158
        for(Category categoryBasedOnDefault : categories) {
155
            if(category.getName() != null && !category.getName().equals(categoryBasedOnDefault.getName())) {
159
            if(category.getName() != null && !category.getName().equals(categoryBasedOnDefault.getName())
160
                    && (oldCategory.getName() == null || oldCategory.getName().equals(categoryBasedOnDefault.getName()))) {
161

  
162
                categoryBasedOnDefault.setName(category.getName());
156 163
                changed = true;
157 164
            }
158
            if(category.getDescription() != null && !category.getDescription().equals(categoryBasedOnDefault.getDescription())) {
165
            if(category.getDescription() != null && !category.getDescription().equals(categoryBasedOnDefault.getDescription())
166
                    && (oldCategory.getDescription() == null || oldCategory.getDescription().equals(categoryBasedOnDefault.getDescription()))) {
167

  
168
                categoryBasedOnDefault.setDescription(category.getDescription());
159 169
                changed = true;
160 170
            }
161 171

  
162 172
            if(!changed) {
163
                break;
173
//                break;
174
                continue;
164 175
            }
165
            categoryBasedOnDefault.setName(category.getName());
166
            categoryBasedOnDefault.setDescription(category.getDescription());
176

  
177
//            categoryBasedOnDefault.setName(category.getName());
178
//            categoryBasedOnDefault.setDescription(category.getDescription());
167 179
            categoryDAO.save(categoryBasedOnDefault);
168 180
        }
169 181
    }

Also available in: Unified diff