@SuppressWarnings("unchecked") @Override protected Object transformFromDatasource(Class<? extends BaseMapper<?, ?, ?>> mapperType, Value object) { if (mapperType != Mango.class) { throw new UnsupportedOperationException( "MultiPointLocationProperty currently only supports Mango as mapper!"); } List<Tuple<Double, Double>> locations = new ArrayList<>(); if (!object.isNull()) { Object coordinates = ((Document) object.get()).get("coordinates"); if (coordinates instanceof List<?>) { ((List<List<Double>>) coordinates).stream() .map(entry -> Tuple.create(entry.get(0), entry.get(1))) .collect(Lambdas.into(locations)); } } return locations; }
/** * Returns a list of two-letter codes enumerating all supported languages. Provided via the config in * {@code nls.languages} * * @return a list of supported language codes */ public static Set<String> getSupportedLanguages() { if (supportedLanguages == null && Sirius.getSettings() != null) { try { supportedLanguages = Sirius.getSettings() .getStringList("nls.languages") .stream() .map(String::toLowerCase) .collect(Lambdas.into(Sets.newLinkedHashSet())); } catch (Exception e) { Exceptions.handle(e); } } // Returns the default language or (for very early access we default to en) return supportedLanguages == null ? Collections.singleton("en") : Collections.unmodifiableSet(supportedLanguages); }
private boolean processBlock(Function<? super E, Boolean> consumer, Limit lim, TaskContext ctx, RateLimit rateLimit, Set<String> entityDeDuplicator) throws Exception { SearchRequestBuilder srb = buildSearch(); if (IndexAccess.LOG.isFINE()) { IndexAccess.LOG.FINE("PAGED-SEARCH: %s.%s: %s", indexAccess.getIndex(clazz), indexAccess.getDescriptor(clazz).getType(), buildQuery()); } ResultList<E> resultList = transform(srb); for (E entity : resultList) { try { if (!processEntity(consumer, lim, ctx, rateLimit, entityDeDuplicator, entity)) { return false; } } catch (Exception e) { Exceptions.handle().to(IndexAccess.LOG).error(e).handle(); } } // Re-create entity the duplicator entityDeDuplicator.clear(); resultList.getResults().stream().map(Entity::getId).collect(Lambdas.into(entityDeDuplicator)); start += resultList.size(); return resultList.size() >= limit; }