com.zuunr.restbed.repository.sqlserver.ReactiveSqlServerRepository Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of restbed-repository-sqlserver Show documentation
Show all versions of restbed-repository-sqlserver Show documentation
SQL Server implementation of the reactive repository interface in core project
/*
* Copyright 2018 Zuunr AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.zuunr.restbed.repository.sqlserver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.zuunr.json.JsonObjectSupport;
import com.zuunr.restbed.core.exchange.Collection;
import com.zuunr.restbed.core.exchange.Exchange;
import com.zuunr.restbed.repository.ReactiveRepository;
import com.zuunr.restbed.repository.sqlserver.impl.DeleteItem;
import com.zuunr.restbed.repository.sqlserver.impl.GetCollection;
import com.zuunr.restbed.repository.sqlserver.impl.GetItem;
import com.zuunr.restbed.repository.sqlserver.impl.SaveItem;
import com.zuunr.restbed.repository.sqlserver.impl.UpdateItem;
import reactor.core.publisher.Mono;
/**
* SQLServer implementation of {@link ReactiveRepository}.
*
* @see ReactiveRepository
*/
public abstract class ReactiveSqlServerRepository implements ReactiveRepository {
private final Logger logger = LoggerFactory.getLogger(ReactiveSqlServerRepository.class);
private @Autowired SaveItem saveItem;
private @Autowired GetItem getItem;
private @Autowired UpdateItem updateItem;
private @Autowired DeleteItem deleteItem;
private @Autowired GetCollection getCollection;
@Override
public Mono> saveItem(Mono> exchange, Class resourceClass) {
if (logger.isDebugEnabled()) {
logger.debug("Calling save item with exchange for resource: {}", resourceClass.getName());
}
return exchange.flatMap(o -> saveItem.saveItem(o, resourceClass));
}
@Override
public Mono> getItem(Mono> exchange, Class resourceClass) {
if (logger.isDebugEnabled()) {
logger.debug("Calling get item with exchange for resource: {}", resourceClass.getName());
}
return exchange.flatMap(o -> getItem.getItem(o, resourceClass));
}
@Override
public Mono> updateItem(Mono> exchange, Class resourceClass) {
if (logger.isDebugEnabled()) {
logger.debug("Calling update item with exchange for resource: {}", resourceClass.getName());
}
return exchange.flatMap(o -> updateItem.updateItem(o, resourceClass));
}
@Override
public Mono> deleteItem(Mono> exchange) {
if (logger.isDebugEnabled()) {
logger.debug("Calling delete item with exchange");
}
return exchange.flatMap(deleteItem::deleteItem);
}
@Override
public Mono>> getCollection(Mono>> exchange, Class resourceClass) {
if (logger.isDebugEnabled()) {
logger.debug("Calling get collection with exchange for resource: {}", resourceClass.getName());
}
return exchange.flatMap(o -> getCollection.getCollection(o, resourceClass));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy