Revision 58954
Added by Konstantina Galouni almost 4 years ago
IndicatorController.java | ||
---|---|---|
146 | 146 |
|
147 | 147 |
// Check if there are changes in indicator path and update existing indicators if needed |
148 | 148 |
log.debug("update indicator path: "+i); |
149 |
if(!indicatorPath.getType().equals(indicatorPathBasedOnDefault.getType()) |
|
149 |
log.debug("indicatorPath.getType(): "+indicatorPath.getType()); |
|
150 |
log.debug("indicatorPathBasedOnDefault.getType(): "+indicatorPathBasedOnDefault.getType()); |
|
151 |
log.debug("oldIndicatorPath.getType(): "+oldIndicatorPath.getType()); |
|
152 |
|
|
153 |
if(indicatorPath.getType() != null |
|
154 |
&& !indicatorPath.getType().equals(indicatorPathBasedOnDefault.getType()) |
|
150 | 155 |
&& (oldIndicatorPath.getType().equals(indicatorPathBasedOnDefault.getType()))) { |
151 | 156 |
|
152 | 157 |
indicatorPathBasedOnDefault.setType(indicatorPath.getType()); |
... | ... | |
154 | 159 |
} |
155 | 160 |
log.debug("After type check: "+changed); |
156 | 161 |
|
157 |
if(!indicatorPath.getSource().equals(indicatorPathBasedOnDefault.getSource()) |
|
162 |
if(indicatorPath.getSource() != null |
|
163 |
&& !indicatorPath.getSource().equals(indicatorPathBasedOnDefault.getSource()) |
|
158 | 164 |
&& (oldIndicatorPath.getSource().equals(indicatorPathBasedOnDefault.getSource()))) { |
159 | 165 |
|
160 | 166 |
indicatorPathBasedOnDefault.setSource(indicatorPath.getSource()); |
... | ... | |
162 | 168 |
} |
163 | 169 |
log.debug("After source check: "+changed); |
164 | 170 |
|
165 |
if(!indicatorPath.getUrl().equals(indicatorPathBasedOnDefault.getUrl()) |
|
171 |
if(indicatorPath.getUrl() != null |
|
172 |
&& !indicatorPath.getUrl().equals(indicatorPathBasedOnDefault.getUrl()) |
|
166 | 173 |
&& (oldIndicatorPath.getUrl().equals(indicatorPathBasedOnDefault.getUrl()))) { |
167 | 174 |
|
168 | 175 |
indicatorPathBasedOnDefault.setUrl(indicatorPath.getUrl()); |
... | ... | |
170 | 177 |
} |
171 | 178 |
log.debug("After url check: "+changed); |
172 | 179 |
|
173 |
if(!indicatorPath.getChartObject().equals(indicatorPathBasedOnDefault.getChartObject()) |
|
180 |
if(indicatorPath.getChartObject() != null |
|
181 |
&& !indicatorPath.getChartObject().equals(indicatorPathBasedOnDefault.getChartObject()) |
|
174 | 182 |
&& (oldIndicatorPath.getChartObject().equals(indicatorPathBasedOnDefault.getChartObject()))) { |
175 | 183 |
|
176 | 184 |
indicatorPathBasedOnDefault.setChartObject(indicatorPath.getChartObject()); |
... | ... | |
243 | 251 |
} |
244 | 252 |
|
245 | 253 |
public void parameterMapping(IndicatorPath indicatorPath, Stakeholder stakeholder) throws UnsupportedEncodingException { |
246 |
if (indicatorPath.getParameters().containsKey("index_name")) { |
|
247 |
indicatorPath.getParameters().put("index_name", stakeholder.getIndex_name()); |
|
248 |
} else if (indicatorPath.getParameters().containsKey("index_shortName")) { |
|
249 |
indicatorPath.getParameters().put("index_shortName", stakeholder.getIndex_name().toLowerCase()); |
|
250 |
} else if (indicatorPath.getParameters().containsKey("index_id")) { |
|
251 |
indicatorPath.getParameters().put("index_id", stakeholder.getIndex_id()); |
|
254 |
if (indicatorPath.getParameters() != null) { |
|
255 |
if (indicatorPath.getParameters().containsKey("index_name")) { |
|
256 |
indicatorPath.getParameters().put("index_name", stakeholder.getIndex_name()); |
|
257 |
} else if (indicatorPath.getParameters().containsKey("index_shortName")) { |
|
258 |
indicatorPath.getParameters().put("index_shortName", stakeholder.getIndex_name().toLowerCase()); |
|
259 |
} else if (indicatorPath.getParameters().containsKey("index_id")) { |
|
260 |
indicatorPath.getParameters().put("index_id", stakeholder.getIndex_id()); |
|
261 |
} |
|
252 | 262 |
} |
253 | 263 |
|
254 |
|
|
255 |
String url = indicatorPath.getUrl(); |
|
256 |
String encoded_index_id = urlEncode(URLEncoder.encode(stakeholder.getIndex_id(), "UTF-8")); |
|
257 |
url = url.replace("index_id", encoded_index_id); |
|
258 |
String encoded_index_name = urlEncode(URLEncoder.encode(stakeholder.getIndex_name(), "UTF-8")); |
|
259 |
url = url.replace("index_name", encoded_index_name); |
|
260 |
String encoded_index_shortName = urlEncode(URLEncoder.encode(stakeholder.getIndex_shortName(), "UTF-8")); |
|
261 |
url = url.replace("index_shortName", encoded_index_shortName); |
|
262 |
indicatorPath.setUrl(url); |
|
264 |
// // url encoding for number indicators |
|
265 |
// String url = indicatorPath.getUrl();
|
|
266 |
// String encoded_index_id = urlEncode(URLEncoder.encode(stakeholder.getIndex_id(), "UTF-8"));
|
|
267 |
// url = url.replace("index_id", encoded_index_id);
|
|
268 |
// String encoded_index_name = urlEncode(URLEncoder.encode(stakeholder.getIndex_name(), "UTF-8"));
|
|
269 |
// url = url.replace("index_name", encoded_index_name);
|
|
270 |
// String encoded_index_shortName = urlEncode(URLEncoder.encode(stakeholder.getIndex_shortName(), "UTF-8"));
|
|
271 |
// url = url.replace("index_shortName", encoded_index_shortName);
|
|
272 |
// indicatorPath.setUrl(url);
|
|
263 | 273 |
} |
264 | 274 |
|
265 | 275 |
public String urlEncode(String encodedIndicatorPathField) { |
Also available in: Unified diff
[Trunk | Monitor Service]:
1. trunk/src/test/java/eu/dnetlib/uoamonitorservice: New folders for tests.
2. ExceptionsHandler.java: Replace "log.debug" with "log.error".
3. Stakeholder.java: Field 'description' and getter/ setter methods added.
4. Topic.java: Field 'icon' and getter/ setter methods added | In method "copyFromDefault()", set "isActive" and "isPublic" fields of new Topic same as the values from default Topic.
5. TopicController.java: In method "onUpdateDefaultTopic()", add update for icon.
6. Category.java & SubCategory.java & Indicator.java:
In method "copyFromDefault()", set "isActive" and "isPublic" fields of new Category/ SubCategory/ Indicator same as the values from default Category/ SubCategory/ Indicator.
7. IndicatorController.java:
a. [Bug fix] Add some null checks when updating number indicators.
b. In method "parameterMapping()" comment replacement of "index_id", "index_name", "index_shortName" in indicatorPath.url (number indicators only).