Revision 58410
Added by Michele Artini about 4 years ago
OrganizationController.java | ||
---|---|---|
9 | 9 |
import java.util.Set; |
10 | 10 |
import java.util.TreeMap; |
11 | 11 |
import java.util.TreeSet; |
12 |
import java.util.stream.Collectors; |
|
12 | 13 |
import java.util.stream.Stream; |
13 | 14 |
|
14 | 15 |
import org.apache.commons.lang3.StringUtils; |
... | ... | |
24 | 25 |
import org.springframework.web.bind.annotation.RestController; |
25 | 26 |
|
26 | 27 |
import eu.dnetlib.organizations.model.OpenaireDuplicate; |
28 |
import eu.dnetlib.organizations.model.Relationship; |
|
27 | 29 |
import eu.dnetlib.organizations.model.utils.BrowseEntry; |
28 | 30 |
import eu.dnetlib.organizations.model.utils.OrganizationConflict; |
29 | 31 |
import eu.dnetlib.organizations.model.utils.OrganizationConflictImpl; |
... | ... | |
42 | 44 |
import eu.dnetlib.organizations.repository.readonly.OrganizationViewRepository; |
43 | 45 |
import eu.dnetlib.organizations.repository.readonly.SuggestionInfoViewByCountryRepository; |
44 | 46 |
import eu.dnetlib.organizations.utils.DatabaseUtils; |
47 |
import eu.dnetlib.organizations.utils.RelationType; |
|
45 | 48 |
|
46 | 49 |
@RestController |
47 | 50 |
@RequestMapping("/api/organizations") |
... | ... | |
248 | 251 |
: organizationSimpleViewRepository.browseTypesForUser(authentication.getName()); |
249 | 252 |
} |
250 | 253 |
|
254 |
@RequestMapping(value = "/conflicts/fix/{masterId}", method = RequestMethod.POST) |
|
255 |
public List<Relationship> fixConflicts(final Authentication authentication, @PathVariable final String masterId, @RequestBody final List<String> otherIds) { |
|
256 |
if (UserInfo.isSuperAdmin(authentication) || userCountryRepository.verifyAuthorizationForId(masterId, authentication.getName())) { |
|
257 |
|
|
258 |
return otherIds.stream() |
|
259 |
.filter(id -> UserInfo.isSuperAdmin(authentication) || userCountryRepository.verifyAuthorizationForId(id, authentication.getName())) |
|
260 |
.map(id -> databaseUtils.makeRelation(masterId, id, RelationType.Merges)) |
|
261 |
.flatMap(List::stream) |
|
262 |
.collect(Collectors.toList()); |
|
263 |
|
|
264 |
} else { |
|
265 |
return new ArrayList<>(); |
|
266 |
} |
|
267 |
|
|
268 |
} |
|
269 |
|
|
251 | 270 |
} |
Also available in: Unified diff
save relations