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:

TopicController.java
65 65
        Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
66 66

  
67 67
        if(stakeholder != null) {
68
            Topic<String> oldTopic = null;
69
            if(topicFull.getId() != null) {
70
                oldTopic = topicDAO.findById(topicFull.getId());
71
            }
68 72

  
69 73
            Topic<String> topic = new Topic<>(topicFull);
70 74

  
......
80 84
                if(topicFull.getId() == null) {
81 85
                    onSaveDefaultTopic(topic, stakeholderId);
82 86
                } else {
83
                    onUpdateDefaultTopic(topic);
87
                    onUpdateDefaultTopic(topic, oldTopic);
84 88
                }
85 89
            }
86 90

  
......
120 124
        }
121 125
    }
122 126

  
123
    public void onUpdateDefaultTopic(Topic topic) {
127
    public void onUpdateDefaultTopic(Topic topic, Topic oldTopic) {
124 128
        log.debug("On update default topic");
125 129

  
126 130
        List<Topic> topics = topicDAO.findByDefaultId(topic.getId());
127 131
        boolean changed = false;
128 132
        for(Topic topicBasedOnDefault : topics) {
129
            if(topic.getName() != null && !topic.getName().equals(topicBasedOnDefault.getName())) {
133
            if(topic.getName() != null && !topic.getName().equals(topicBasedOnDefault.getName())
134
                    && (oldTopic.getName() == null || oldTopic.getName().equals(topicBasedOnDefault.getName()))) {
135

  
136
                topicBasedOnDefault.setName(topic.getName());
130 137
                changed = true;
131 138
            }
132
            if(topic.getDescription() != null && !topic.getDescription().equals(topicBasedOnDefault.getDescription())) {
139
            if(topic.getDescription() != null && !topic.getDescription().equals(topicBasedOnDefault.getDescription())
140
                    && (oldTopic.getDescription() == null || oldTopic.getDescription().equals(topicBasedOnDefault.getDescription()))) {
141

  
142
                topicBasedOnDefault.setDescription(topic.getDescription());
133 143
                changed = true;
134 144
            }
135 145

  
136 146
            if(!changed) {
137
                break;
147
//                break;
148
                continue;
138 149
            }
139
            topicBasedOnDefault.setName(topic.getName());
140
            topicBasedOnDefault.setDescription(topic.getDescription());
150

  
151
//            topicBasedOnDefault.setName(topic.getName());
152
//            topicBasedOnDefault.setDescription(topic.getDescription());
141 153
            topicDAO.save(topicBasedOnDefault);
142 154
        }
143 155
    }

Also available in: Unified diff