rest ressources tuning
This commit is contained in:
@@ -33,11 +33,11 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.16.18</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.16.18</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
@@ -49,6 +49,10 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-rest</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-rest-hal-browser</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package pl.com.bottega.factory.delivery.planning.definition;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@RepositoryRestResource(
|
||||
path = "delivery/planning/definitions",
|
||||
collectionResourceRel = "definitions for auto delivery planning")
|
||||
public interface DeliveryPlannerDefinitionDao extends JpaRepository<DeliveryPlannerDefinitionEntity, String> {
|
||||
}
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
package pl.com.bottega.factory.delivery.planning.projection;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
import org.springframework.data.rest.core.annotation.RestResource;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import pl.com.bottega.tools.ProjectionDao;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface DeliveryForecastDao extends JpaRepository<DeliveryForecastEntity, Long> {
|
||||
@RepositoryRestResource(
|
||||
path = "delivery/planning/forecasts",
|
||||
collectionResourceRel = "forecast of deliveries")
|
||||
public interface DeliveryForecastDao extends ProjectionDao<DeliveryForecastEntity, Long> {
|
||||
|
||||
List<DeliveryForecastEntity> findByRefNoAndDateGreaterThanEqual(String refNo, Instant instant);
|
||||
|
||||
@RestResource(exported = false)
|
||||
void deleteByRefNoAndDate(String refNo, LocalDate date);
|
||||
|
||||
@RestResource(exported = false)
|
||||
void deleteByRefNo(String refNo);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package pl.com.bottega.factory.demand.forecasting.persistence;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RestResource;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import pl.com.bottega.factory.demand.forecasting.DemandEntity;
|
||||
|
||||
@@ -8,6 +9,7 @@ import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
@RestResource(exported = false)
|
||||
public interface DemandDao extends JpaRepository<DemandEntity, Long> {
|
||||
|
||||
List<DemandEntity> findByProductRefNoAndDateGreaterThanEqual(String refNo, LocalDate now);
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package pl.com.bottega.factory.demand.forecasting.persistence;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RestResource;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import pl.com.bottega.factory.demand.forecasting.ProductDemandEntity;
|
||||
|
||||
@Repository
|
||||
@RestResource(exported = false)
|
||||
public interface ProductDemandDao extends JpaRepository<ProductDemandEntity, Long> {
|
||||
|
||||
ProductDemandEntity findById(Long id);
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
package pl.com.bottega.factory.demand.forecasting.projection;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
import org.springframework.data.rest.core.annotation.RestResource;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import pl.com.bottega.tools.ProjectionDao;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface CurrentDemandDao extends JpaRepository<CurrentDemandEntity, Long> {
|
||||
@RepositoryRestResource(
|
||||
path = "demand/forecasts",
|
||||
collectionResourceRel = "forecast of customers demands")
|
||||
public interface CurrentDemandDao extends ProjectionDao<CurrentDemandEntity, Long> {
|
||||
|
||||
List<CurrentDemandEntity> findByRefNoAndDateGreaterThanEqual(String refNo, LocalDate date);
|
||||
|
||||
@RestResource(exported = false)
|
||||
void deleteByRefNoAndDate(String refNo, LocalDate date);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package pl.com.bottega.factory.product.management;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
|
||||
@RepositoryRestResource(
|
||||
path = "product/management/descriptions",
|
||||
collectionResourceRel = "descriptions of products")
|
||||
public interface ProductDescriptionDao extends JpaRepository<ProductDescriptionEntity, Long> {
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package pl.com.bottega.factory.production.planning.projection;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import pl.com.bottega.tools.ProjectionDao;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface ProductionOutputDao extends JpaRepository<ProductionOutputEntity, Long> {
|
||||
@RepositoryRestResource(
|
||||
path = "production/planning/outputs",
|
||||
collectionResourceRel = "forecast of production outputs")
|
||||
public interface ProductionOutputDao extends ProjectionDao<ProductionOutputEntity, Long> {
|
||||
|
||||
List<ProductionOutputEntity> findByRefNoAndStartGreaterThanEqual(String refNo, Instant instant);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package pl.com.bottega.factory.shortages.prediction.monitoring;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import pl.com.bottega.tools.ProjectionDao;
|
||||
|
||||
@Repository
|
||||
public interface ShortagesDao extends JpaRepository<ShortagesEntity, String> {
|
||||
@RepositoryRestResource(
|
||||
path = "shortages/prediction/current",
|
||||
collectionResourceRel = "predicted shortages")
|
||||
public interface ShortagesDao extends ProjectionDao<ShortagesEntity, String> {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package pl.com.bottega.tools;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.rest.core.annotation.RestResource;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Repository
|
||||
public interface ProjectionDao<T, ID extends Serializable> extends CrudRepository<T, ID> {
|
||||
|
||||
@Override
|
||||
@RestResource(exported = false)
|
||||
<S extends T> S save(S entity);
|
||||
|
||||
@Override
|
||||
@RestResource(exported = false)
|
||||
<S extends T> Iterable<S> save(Iterable<S> entities);
|
||||
|
||||
@Override
|
||||
@RestResource(exported = false)
|
||||
void delete(ID id);
|
||||
|
||||
@Override
|
||||
@RestResource(exported = false)
|
||||
void delete(T entity);
|
||||
|
||||
@Override
|
||||
@RestResource(exported = false)
|
||||
void delete(Iterable<? extends T> entities);
|
||||
|
||||
@Override
|
||||
@RestResource(exported = false)
|
||||
void deleteAll();
|
||||
}
|
||||
Reference in New Issue
Block a user