/** * Returns the query string to execute an exists query for the given id attributes. * * @param entityName the name of the entity to create the query for, must not be {@literal null}. * @param countQueryPlaceHolder the placeholder for the count clause, must not be {@literal null}. * @param idAttributes the id attributes for the entity, must not be {@literal null}. */ public static String getExistsQueryString(String entityName, String countQueryPlaceHolder, Iterable<String> idAttributes) { String whereClause = Streamable.of(idAttributes).stream() // .map(idAttribute -> String.format(EQUALS_CONDITION_STRING, "x", idAttribute, idAttribute)) // .collect(Collectors.joining(" AND ", " WHERE ", "")); return String.format(COUNT_QUERY_STRING, countQueryPlaceHolder, entityName) + whereClause; }
@Override public <S extends T> List<S> insert(Iterable<S> entities) { Assert.notNull(entities, "The given Iterable of entities not be null!"); List<S> list = Streamable.of(entities).stream().collect(StreamUtils.toUnmodifiableList()); if (list.isEmpty()) { return list; } return new ArrayList<>(mongoOperations.insertAll(list)); }
@Override public <S extends T> List<S> saveAll(Iterable<S> entities) { Assert.notNull(entities, "The given Iterable of entities not be null!"); Streamable<S> source = Streamable.of(entities); boolean allNew = source.stream().allMatch(it -> entityInformation.isNew(it)); if (allNew) { List<S> result = source.stream().collect(Collectors.toList()); return new ArrayList<>(mongoOperations.insert(result, entityInformation.getCollectionName())); } return source.stream().map(this::save).collect(Collectors.toList()); }
@Override public <S extends T> Flux<S> insert(Iterable<S> entities) { Assert.notNull(entities, "The given Iterable of entities must not be null!"); List<S> source = Streamable.of(entities).stream().collect(StreamUtils.toUnmodifiableList()); return source.isEmpty() ? Flux.empty() : Flux.from(mongoOperations.insertAll(source)); }
@Override public <S extends T> Flux<S> saveAll(Iterable<S> entities) { Assert.notNull(entities, "The given Iterable of entities must not be null!"); Streamable<S> source = Streamable.of(entities); return source.stream().allMatch(entityInformation::isNew) ? // mongoOperations.insert(source.stream().collect(Collectors.toList()), entityInformation.getCollectionName()) : // Flux.fromIterable(entities).flatMap(this::save); }
@Override public Flux<T> findAllById(Iterable<ID> ids) { Assert.notNull(ids, "The given Iterable of Id's must not be null!"); return findAll(new Query(new Criteria(entityInformation.getIdAttribute()) .in(Streamable.of(ids).stream().collect(StreamUtils.toUnmodifiableList())))); }
@Override public Iterable<T> findAllById(Iterable<ID> ids) { return findAll(new Query(new Criteria(entityInformation.getIdAttribute()) .in(Streamable.of(ids).stream().collect(StreamUtils.toUnmodifiableList())))); }
@Override public <S extends T> List<S> insert(Iterable<S> entities) { Assert.notNull(entities, "The given Iterable of entities not be null!"); List<S> list = Streamable.of(entities).stream().collect(StreamUtils.toUnmodifiableList()); if (list.isEmpty()) { return list; } return new ArrayList<>(mongoOperations.insertAll(list)); }
@Override public <S extends T> List<S> saveAll(Iterable<S> entities) { Assert.notNull(entities, "The given Iterable of entities not be null!"); Streamable<S> source = Streamable.of(entities); boolean allNew = source.stream().allMatch(it -> entityInformation.isNew(it)); if (allNew) { List<S> result = source.stream().collect(Collectors.toList()); return new ArrayList<>(mongoOperations.insert(result, entityInformation.getCollectionName())); } return source.stream().map(this::save).collect(Collectors.toList()); }
@Override public <S extends T> Flux<S> saveAll(Iterable<S> entities) { Assert.notNull(entities, "The given Iterable of entities must not be null!"); Streamable<S> source = Streamable.of(entities); return source.stream().allMatch(entityInformation::isNew) ? // mongoOperations.insert(source.stream().collect(Collectors.toList()), entityInformation.getCollectionName()) : // Flux.fromIterable(entities).flatMap(this::save); }
@Override public <S extends T> Flux<S> insert(Iterable<S> entities) { Assert.notNull(entities, "The given Iterable of entities must not be null!"); List<S> source = Streamable.of(entities).stream().collect(StreamUtils.toUnmodifiableList()); return source.isEmpty() ? Flux.empty() : Flux.from(mongoOperations.insertAll(source)); }
@Override public Flux<T> findAllById(Iterable<ID> ids) { Assert.notNull(ids, "The given Iterable of Id's must not be null!"); return findAll(new Query(new Criteria(entityInformation.getIdAttribute()) .in(Streamable.of(ids).stream().collect(StreamUtils.toUnmodifiableList())))); }
@Override public Iterable<T> findAllById(Iterable<ID> ids) { return findAll(new Query(new Criteria(entityInformation.getIdAttribute()) .in(Streamable.of(ids).stream().collect(StreamUtils.toUnmodifiableList())))); }
@Override public <S extends T> Iterable<S> saveAll(Iterable<S> entities) { return Streamable.of(entities).stream() // .map(this::save) // .collect(Collectors.toList()); }
/** * Returns all {@link TypeInformation} exposed by the registered {@link MappingContext}s. * * @return */ public Streamable<TypeInformation<?>> getManagedTypes() { return Streamable.of(contexts.stream()// .flatMap(it -> it.getManagedTypes().stream())// .collect(Collectors.toSet())); }
@Override public Streamable<Method> getQueryMethods() { Set<Method> result = new HashSet<>(); for (Method method : getRepositoryInterface().getMethods()) { method = ClassUtils.getMostSpecificMethod(method, getRepositoryInterface()); if (isQueryMethodCandidate(method)) { result.add(method); } } return Streamable.of(Collections.unmodifiableSet(result)); }
@Override public Streamable<Method> getQueryMethods() { Set<Method> result = new HashSet<>(); for (Method method : getRepositoryInterface().getMethods()) { method = ClassUtils.getMostSpecificMethod(method, getRepositoryInterface()); if (isQueryMethodCandidate(method)) { result.add(method); } } return Streamable.of(Collections.unmodifiableSet(result)); }
@Override public Streamable<Method> getQueryMethods() { Set<Method> result = new HashSet<>(); for (Method method : getRepositoryInterface().getMethods()) { method = ClassUtils.getMostSpecificMethod(method, getRepositoryInterface()); if (isQueryMethodCandidate(method)) { result.add(method); } } return Streamable.of(Collections.unmodifiableSet(result)); }
@Override public Streamable<Method> getQueryMethods() { Set<Method> result = new HashSet<>(); for (Method method : getRepositoryInterface().getMethods()) { method = ClassUtils.getMostSpecificMethod(method, getRepositoryInterface()); if (isQueryMethodCandidate(method)) { result.add(method); } } return Streamable.of(Collections.unmodifiableSet(result)); }
@Override public Streamable<BeanDefinition> getCandidates(ResourceLoader loader) { RepositoryComponentProvider scanner = new RepositoryComponentProvider(getIncludeFilters(), registry); scanner.setConsiderNestedRepositoryInterfaces(shouldConsiderNestedRepositories()); scanner.setEnvironment(environment); scanner.setResourceLoader(loader); getExcludeFilters().forEach(it -> scanner.addExcludeFilter(it)); return Streamable.of(() -> getBasePackages().stream()// .flatMap(it -> scanner.findCandidateComponents(it).stream())); }