Revision 60175
Added by Konstantina Galouni about 2 years ago
modules/uoa-monitor-service/trunk/src/main/java/eu/dnetlib/uoamonitorservice/controllers/IndicatorController.java | ||
---|---|---|
135 | 135 |
for(Indicator indicatorBasedOnDefault : indicators) { |
136 | 136 |
changed = false; |
137 | 137 |
|
138 |
if(indicator.getName() != null && !indicator.getName().equals(indicatorBasedOnDefault.getName()) |
|
139 |
&& (oldIndicator.getName() == null || oldIndicator.getName().equals(indicatorBasedOnDefault.getName()))) { |
|
140 |
|
|
138 |
// if(indicator.getName() != null && !indicator.getName().equals(indicatorBasedOnDefault.getName()) |
|
139 |
// && (oldIndicator.getName() == null || oldIndicator.getName().equals(indicatorBasedOnDefault.getName()))) { |
|
140 |
if(( |
|
141 |
(indicator.getName() == null && oldIndicator.getName() != null) |
|
142 |
|| |
|
143 |
(indicator.getName() != null && !indicator.getName().equals(indicatorBasedOnDefault.getName())) |
|
144 |
) && ( |
|
145 |
(oldIndicator.getName() == null && indicatorBasedOnDefault.getName() == null) |
|
146 |
|| |
|
147 |
(oldIndicator.getName() != null && oldIndicator.getName().equals(indicatorBasedOnDefault.getName())) |
|
148 |
)) { |
|
141 | 149 |
indicatorBasedOnDefault.setName(indicator.getName()); |
142 | 150 |
changed = true; |
143 | 151 |
} |
144 | 152 |
|
145 |
if(indicator.getDescription() != null && !indicator.getDescription().equals(indicatorBasedOnDefault.getDescription())) { |
|
153 |
if(indicator.getDescription() != null && !indicator.getDescription().equals(indicatorBasedOnDefault.getDescription()) |
|
154 |
|| indicator.getDescription() == null && indicatorBasedOnDefault.getDescription() != null) { |
|
146 | 155 |
|
147 | 156 |
indicatorBasedOnDefault.setDescription(indicator.getDescription()); |
148 | 157 |
changed = true; |
149 | 158 |
} |
150 | 159 |
|
151 |
if(indicator.getAdditionalDescription() != null && !indicator.getAdditionalDescription().equals(indicatorBasedOnDefault.getAdditionalDescription()) |
|
152 |
&& (oldIndicator.getAdditionalDescription() == null || oldIndicator.getAdditionalDescription().equals(indicatorBasedOnDefault.getAdditionalDescription()))) { |
|
153 |
|
|
160 |
// if(indicator.getAdditionalDescription() != null && !indicator.getAdditionalDescription().equals(indicatorBasedOnDefault.getAdditionalDescription()) |
|
161 |
// && (oldIndicator.getAdditionalDescription() == null || oldIndicator.getAdditionalDescription().equals(indicatorBasedOnDefault.getAdditionalDescription()))) { |
|
162 |
if(( |
|
163 |
(indicator.getAdditionalDescription() == null && oldIndicator.getAdditionalDescription() != null) |
|
164 |
|| |
|
165 |
(indicator.getAdditionalDescription() != null && !indicator.getAdditionalDescription().equals(indicatorBasedOnDefault.getAdditionalDescription())) |
|
166 |
) && ( |
|
167 |
(oldIndicator.getAdditionalDescription() == null && indicatorBasedOnDefault.getAdditionalDescription() == null) |
|
168 |
|| |
|
169 |
(oldIndicator.getAdditionalDescription() != null && oldIndicator.getAdditionalDescription().equals(indicatorBasedOnDefault.getAdditionalDescription())) |
|
170 |
)) { |
|
154 | 171 |
indicatorBasedOnDefault.setAdditionalDescription(indicator.getAdditionalDescription()); |
155 | 172 |
changed = true; |
156 | 173 |
} |
... | ... | |
179 | 196 |
// Check if there are changes in indicator path and update existing indicators if needed |
180 | 197 |
log.debug("update indicator path: "+i + " (indicator id: "+indicatorBasedOnDefault.getId()+")"); |
181 | 198 |
|
182 |
if(indicatorPath.getType() != null |
|
183 |
&& !indicatorPath.getType().equals(indicatorPathBasedOnDefault.getType()) |
|
184 |
&& (oldIndicatorPath.getType().equals(indicatorPathBasedOnDefault.getType()))) { |
|
185 |
|
|
199 |
// if(indicatorPath.getType() != null |
|
200 |
// && !indicatorPath.getType().equals(indicatorPathBasedOnDefault.getType()) |
|
201 |
// && (oldIndicatorPath.getType().equals(indicatorPathBasedOnDefault.getType()))) { |
|
202 |
if(( |
|
203 |
(indicatorPath.getType() == null && oldIndicatorPath.getType() != null) |
|
204 |
|| |
|
205 |
(indicatorPath.getType() != null && !indicatorPath.getType().equals(indicatorPathBasedOnDefault.getType())) |
|
206 |
) && ( |
|
207 |
(oldIndicatorPath.getType() == null && indicatorPathBasedOnDefault.getType() == null) |
|
208 |
|| |
|
209 |
(oldIndicatorPath.getType() != null && oldIndicatorPath.getType().equals(indicatorPathBasedOnDefault.getType())) |
|
210 |
)) { |
|
186 | 211 |
indicatorPathBasedOnDefault.setType(indicatorPath.getType()); |
187 | 212 |
changed = true; // parameter "type" needs to be changed as well |
188 | 213 |
} |
189 | 214 |
log.debug("After type check: "+changed); |
190 | 215 |
|
191 |
if(indicatorPath.getSource() != null |
|
192 |
&& !indicatorPath.getSource().equals(indicatorPathBasedOnDefault.getSource()) |
|
193 |
&& (oldIndicatorPath.getSource().equals(indicatorPathBasedOnDefault.getSource()))) { |
|
194 |
|
|
216 |
// if(indicatorPath.getSource() != null |
|
217 |
// && !indicatorPath.getSource().equals(indicatorPathBasedOnDefault.getSource()) |
|
218 |
// && (oldIndicatorPath.getSource().equals(indicatorPathBasedOnDefault.getSource()))) { |
|
219 |
if(( |
|
220 |
(indicatorPath.getSource() == null && oldIndicatorPath.getSource() != null) |
|
221 |
|| |
|
222 |
(indicatorPath.getSource() != null && !indicatorPath.getSource().equals(indicatorPathBasedOnDefault.getSource())) |
|
223 |
) && ( |
|
224 |
(oldIndicatorPath.getSource() == null && indicatorPathBasedOnDefault.getSource() == null) |
|
225 |
|| |
|
226 |
(oldIndicatorPath.getSource() != null && oldIndicatorPath.getSource().equals(indicatorPathBasedOnDefault.getSource())) |
|
227 |
)) { |
|
195 | 228 |
indicatorPathBasedOnDefault.setSource(indicatorPath.getSource()); |
196 | 229 |
changed = true; |
197 | 230 |
} |
198 | 231 |
log.debug("After source check: "+changed); |
199 | 232 |
|
200 |
if(indicatorPath.getUrl() != null |
|
201 |
&& !indicatorPath.getUrl().equals(indicatorPathBasedOnDefault.getUrl()) |
|
202 |
&& (oldIndicatorPath.getUrl().equals(indicatorPathBasedOnDefault.getUrl()))) { |
|
203 |
|
|
233 |
// if(indicatorPath.getUrl() != null |
|
234 |
// && !indicatorPath.getUrl().equals(indicatorPathBasedOnDefault.getUrl()) |
|
235 |
// && (oldIndicatorPath.getUrl().equals(indicatorPathBasedOnDefault.getUrl()))) { |
|
236 |
if(( |
|
237 |
(indicatorPath.getUrl() == null && oldIndicatorPath.getUrl() != null) |
|
238 |
|| |
|
239 |
(indicatorPath.getUrl() != null && !indicatorPath.getUrl().equals(indicatorPathBasedOnDefault.getUrl())) |
|
240 |
) && ( |
|
241 |
(oldIndicatorPath.getUrl() == null && indicatorPathBasedOnDefault.getUrl() == null) |
|
242 |
|| |
|
243 |
(oldIndicatorPath.getUrl() != null && oldIndicatorPath.getUrl().equals(indicatorPathBasedOnDefault.getUrl())) |
|
244 |
)) { |
|
204 | 245 |
indicatorPathBasedOnDefault.setUrl(indicatorPath.getUrl()); |
205 | 246 |
changed = true; |
206 | 247 |
} |
207 | 248 |
log.debug("After url check: "+changed); |
208 | 249 |
|
209 |
if(indicatorPath.getChartObject() != null |
|
210 |
&& !indicatorPath.getChartObject().equals(indicatorPathBasedOnDefault.getChartObject()) |
|
211 |
&& (oldIndicatorPath.getChartObject().equals(indicatorPathBasedOnDefault.getChartObject()))) { |
|
250 |
if(( |
|
251 |
(indicatorPath.getChartObject() == null && oldIndicatorPath.getChartObject() != null) |
|
252 |
|| |
|
253 |
(indicatorPath.getChartObject() != null && !indicatorPath.getChartObject().equals(indicatorPathBasedOnDefault.getChartObject())) |
|
254 |
) && ( |
|
255 |
(oldIndicatorPath.getChartObject() == null && indicatorPathBasedOnDefault.getChartObject() == null) |
|
256 |
|| |
|
257 |
(oldIndicatorPath.getChartObject() != null && oldIndicatorPath.getChartObject().equals(indicatorPathBasedOnDefault.getChartObject())) |
|
258 |
)) { |
|
212 | 259 |
|
213 | 260 |
indicatorPathBasedOnDefault.setChartObject(indicatorPath.getChartObject()); |
214 | 261 |
changed = true; |
modules/uoa-monitor-service/trunk/src/main/java/eu/dnetlib/uoamonitorservice/controllers/StakeholderController.java | ||
---|---|---|
409 | 409 |
|
410 | 410 |
// if (roles.contains(authorizationService.PORTAL_ADMIN)) { |
411 | 411 |
if (rolesUtils.isPortalAdmin(roles)) { |
412 |
for(Stakeholder stakeholder : stakeholders) { |
|
413 |
stakeholdersFull.add(this.setFullEntities(stakeholder, roles)); |
|
414 |
} |
|
415 |
return stakeholdersFull; |
|
412 |
// for(Stakeholder stakeholder : stakeholders) { |
|
413 |
// stakeholdersFull.add(this.setFullEntities(stakeholder, roles)); |
|
414 |
// } |
|
415 |
// return stakeholdersFull; |
|
416 |
return stakeholders; |
|
416 | 417 |
} |
417 | 418 |
|
418 | 419 |
Iterator<Stakeholder> stakeholderIterator = stakeholders.iterator(); |
... | ... | |
423 | 424 |
// || roles.contains(authorizationService.manager(stakeholder.getType(), stakeholder.getAlias()))) { |
424 | 425 |
if(rolesUtils.isCurator(roles, stakeholder.getType()) |
425 | 426 |
|| rolesUtils.isManager(roles, stakeholder.getType(), stakeholder.getAlias())) { |
426 |
stakeholdersFull.add(this.setFullEntities(stakeholder, roles)); |
|
427 |
//stakeholdersFull.add(this.setFullEntities(stakeholder, roles));
|
|
427 | 428 |
continue; |
429 |
} else { |
|
430 |
stakeholderIterator.remove(); |
|
428 | 431 |
} |
429 |
stakeholderIterator.remove(); |
|
430 | 432 |
} |
431 | 433 |
} |
432 | 434 |
|
433 | 435 |
// log.debug(new Date()); |
434 | 436 |
|
435 |
return stakeholdersFull;
|
|
437 |
return stakeholders; |
|
436 | 438 |
} |
437 | 439 |
|
438 | 440 |
@RequestMapping(value = "/stakeholder/{alias}", method = RequestMethod.GET) |
... | ... | |
474 | 476 |
// @PreAuthorize("isAuthenticated()") |
475 | 477 |
@PreAuthorize("hasAnyAuthority(" |
476 | 478 |
+ "@AuthorizationService.PORTAL_ADMIN, " |
477 |
+ "@AuthorizationService.curator(#stakeholderFull.getType()), "
|
|
478 |
+ "@AuthorizationService.manager(#stakeholderFull.getType(), #stakeholderFull.getAlias()) "
|
|
479 |
+ "@AuthorizationService.curator(#_stakeholder.getType()), "
|
|
480 |
+ "@AuthorizationService.manager(#_stakeholder.getType(), #_stakeholder.getAlias()) "
|
|
479 | 481 |
+ ")") |
480 | 482 |
@RequestMapping(value = "/save", method = RequestMethod.POST) |
481 |
public Stakeholder<Topic> saveStakeholder(@RequestBody Stakeholder<Topic> stakeholderFull) {
|
|
483 |
public Stakeholder saveStakeholder(@RequestBody Stakeholder _stakeholder) {
|
|
482 | 484 |
log.debug("save stakeholder"); |
483 |
log.debug("Alias: "+stakeholderFull.getAlias() + " - Id: "+stakeholderFull.getId());
|
|
485 |
log.debug("Alias: "+_stakeholder.getAlias() + " - Id: "+_stakeholder.getId());
|
|
484 | 486 |
|
485 |
// if(stakeholderFull == null) {
|
|
487 |
// if(_stakeholder == null) {
|
|
486 | 488 |
// log.debug("stakeholder null"); |
487 | 489 |
// // EXCEPTION - Parameter for Stakeholder is not accepted |
488 | 490 |
// } |
489 | 491 |
|
490 |
Stakeholder<String> stakeholder = new Stakeholder<>(stakeholderFull);
|
|
492 |
Stakeholder<String> stakeholder = new Stakeholder<>(_stakeholder);
|
|
491 | 493 |
|
492 | 494 |
Date date = new Date(); |
493 | 495 |
stakeholder.setUpdateDate(date); |
... | ... | |
495 | 497 |
List<String> topics = new ArrayList<>(); |
496 | 498 |
|
497 | 499 |
// stakeholder does not exist in DB |
498 |
if(stakeholderFull.getId() == null) {
|
|
500 |
if(_stakeholder.getId() == null) {
|
|
499 | 501 |
stakeholder.setCreationDate(date); |
500 | 502 |
|
501 |
for(Topic topic : stakeholderFull.getTopics()) {
|
|
502 |
topics.add(topic.getId()); |
|
503 |
} |
|
503 |
// for(Topic topic : _stakeholder.getTopics()) {
|
|
504 |
// topics.add(topic.getId());
|
|
505 |
// }
|
|
504 | 506 |
} else { |
505 |
Stakeholder<String> oldStakeholder = stakeholderDAO.findById(stakeholderFull.getId());
|
|
507 |
Stakeholder<String> oldStakeholder = stakeholderDAO.findById(_stakeholder.getId());
|
|
506 | 508 |
if(oldStakeholder == null) { |
507 | 509 |
// EXCEPTION - Stakeholder not found |
508 |
throw new EntityNotFoundException("save stakeholder: Stakeholder with id: "+stakeholderFull.getId()+" not found");
|
|
510 |
throw new EntityNotFoundException("save stakeholder: Stakeholder with id: "+_stakeholder.getId()+" not found");
|
|
509 | 511 |
} |
510 | 512 |
for(String topicId : oldStakeholder.getTopics()) { |
511 | 513 |
Topic topic = topicDAO.findById(topicId); |
... | ... | |
516 | 518 |
topics.add(topic.getId()); |
517 | 519 |
} |
518 | 520 |
// stakeholder.setTopics(topics); |
519 |
// stakeholderFull = this.setFullEntities(stakeholder, rolesUtils.getRoles());
|
|
521 |
// _stakeholder = this.setFullEntities(stakeholder, rolesUtils.getRoles());
|
|
520 | 522 |
} |
521 | 523 |
|
522 | 524 |
stakeholder.setTopics(topics); |
523 | 525 |
|
524 | 526 |
Stakeholder<String> stakeholderSaved = stakeholderDAO.save(stakeholder); |
525 |
stakeholderFull.setId(stakeholderSaved.getId());
|
|
526 |
stakeholderFull.setCreationDate(stakeholderSaved.getCreationDate());
|
|
527 |
stakeholderFull.setUpdateDate(stakeholderSaved.getUpdateDate());
|
|
527 |
_stakeholder.setId(stakeholderSaved.getId());
|
|
528 |
_stakeholder.setCreationDate(stakeholderSaved.getCreationDate());
|
|
529 |
_stakeholder.setUpdateDate(stakeholderSaved.getUpdateDate());
|
|
528 | 530 |
|
529 | 531 |
topics = null; |
530 | 532 |
stakeholder = null; |
531 | 533 |
stakeholderSaved = null; |
532 | 534 |
|
533 |
return stakeholderFull;
|
|
535 |
return _stakeholder;
|
|
534 | 536 |
} |
535 | 537 |
|
536 | 538 |
@PreAuthorize("isAuthenticated()") |
Also available in: Unified diff
[Trunk | Monitor Service]:
1. StakeholderController.java:
a. Method "getMyRealStakeholders()" (/my-stakeholder) returns basic Stakeholder info (Topics are not full object anymore).
b. Method "saveStakeholder()" (/save) gets basic or full object for Stakeholder and returns whatever format it received.
2. IndicatorController.java: [Bug fix] In method "onUpdateDefaultIndicator()" improve checks (there were missing cases, e.g. chartObject of previous-saved indicatorPath was null).