Revize ad885d86
Přidáno uživatelem Jakub Šmíd před asi 2 roky(ů)
backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImpl.java | ||
---|---|---|
137 | 137 |
|
138 | 138 |
Set<String> types = typeService.getAllTypesAsString(); |
139 | 139 |
|
140 |
List<CatalogItem> catalog = catalogItemRepository.findAll(); |
|
141 |
Map<String, List<CatalogItem>> nameToCatalogItemMap = new HashMap<>(); |
|
142 |
for (CatalogItem catalogItem : catalog) { |
|
143 |
for (CatalogItemName name : catalogItem.getAllNames()) { |
|
144 |
if (!nameToCatalogItemMap.containsKey(name.getName())) { |
|
145 |
nameToCatalogItemMap.put(name.getName(), new ArrayList<>()); |
|
146 |
} |
|
147 |
nameToCatalogItemMap.get(name.getName()).add(catalogItem); |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
140 | 151 |
String[] tokens = text.split("((?<=\\s)|(?=\\s+))"); |
141 | 152 |
for (String token : tokens) { |
142 | 153 |
if (StringUtils.isBlank(token) || token.matches(START_PUNCTUATION_REGEX)) { |
... | ... | |
169 | 180 |
if (types.contains(textToFind)) { |
170 | 181 |
textToFind = "<b>" + textToFind + "</b>"; |
171 | 182 |
} else { |
172 |
List<CatalogItem> foundItems = catalogItemRepository.getItemsByName(textToFind);
|
|
173 |
if (!foundItems.isEmpty()) {
|
|
183 |
if (nameToCatalogItemMap.containsKey(textToFind)) {
|
|
184 |
List<CatalogItem> foundItems = nameToCatalogItemMap.get(textToFind);
|
|
174 | 185 |
if (foundItems.stream().anyMatch(c -> c.getLatitude() != null && c.getLongitude() != null)) { |
175 | 186 |
textToFind = "<span style='color:green'>" + textToFind + "</span>"; |
176 | 187 |
} else { |
Také k dispozici: Unified diff
Loading of path speeded up
re #9753