Skip to content

Commit

Permalink
Resolves #360
Browse files Browse the repository at this point in the history
  • Loading branch information
nmandrescu committed May 31, 2021
1 parent 799e03e commit f92e3d7
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ public interface BaseJpaService<T extends GenericPersistable & Serializable> {

<S extends T> S saveAndFlush(S entity);

<S extends T> List<S> saveAllAndFlush(Iterable<S> iterable);

void delete(T entity);

void deleteAllInBatch(Iterable<T> iterable);

void deleteAllByIdInBatch(Iterable<Long> iterable);

T newInstance();
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,30 @@ public <S extends T> S saveAndFlush(final S entity) {
return repository().saveAndFlush(entity);
}

@Override
@Transactional
public <S extends T> List<S> saveAllAndFlush(final Iterable<S> iterable) {
return repository().saveAllAndFlush(iterable);
}

@Override
@Transactional
public void delete(final T entity) {
repository().delete(entity);
}

@Override
@Transactional
public void deleteAllInBatch(final Iterable<T> iterable) {
repository().deleteAllInBatch(iterable);
}

@Override
@Transactional
public void deleteAllByIdInBatch(final Iterable<Long> iterable) {
repository().deleteAllByIdInBatch(iterable);
}

protected abstract BaseJpaRepository<T, Long> repository();

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public void delete(TestAddress entity) {

}

@Override
public void deleteAllById(final Iterable<? extends Long> iterable) {

}

@Override
public void deleteAll(Iterable entities) {

Expand All @@ -84,6 +89,7 @@ public void flush() {
}

@Override
@Deprecated
public void deleteInBatch(Iterable entities) {

}
Expand All @@ -94,10 +100,16 @@ public void deleteAllInBatch() {
}

@Override
@Deprecated
public TestAddress getOne(Long aLong) {
return null;
}

@Override
public TestAddress getById(final Long aLong) {
return null;
}

@Override
public List findAll(Example example, Sort sort) {
return null;
Expand All @@ -113,6 +125,21 @@ public <S extends TestAddress> S saveAndFlush(S entity) {
return null;
}

@Override
public <S extends TestAddress> List<S> saveAllAndFlush(final Iterable<S> iterable) {
return null;
}

@Override
public void deleteAllInBatch(final Iterable<TestAddress> iterable) {

}

@Override
public void deleteAllByIdInBatch(final Iterable<Long> iterable) {

}

@Override
public List saveAll(Iterable entities) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>16</java.version>
<liquibase.version>4.3.5</liquibase.version>
<spring.boot.version>2.4.5</spring.boot.version>
<spring.boot.version>2.5.0</spring.boot.version>
<derby.version>10.14.2.0</derby.version>
<poi.version>4.0.1</poi.version>
<docker.image.prefix>devgateway/toolkit</docker.image.prefix>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
*/
@RestController
public class HTTPErrorController implements ErrorController {
@Override
public String getErrorPath() {
return null;
}

@RequestMapping("/error")
public void handleError(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.data.rest.core.mapping.RepositoryDetectionStrategy.RepositoryDetectionStrategies;
import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer;
import org.springframework.web.servlet.config.annotation.CorsRegistry;

/**
* We only allow to expose repositories that are annotated
Expand All @@ -20,9 +21,10 @@ public RepositoryRestConfigurer repositoryRestConfigurer() {
return new RepositoryRestConfigurer() {

@Override
public void configureRepositoryRestConfiguration(final RepositoryRestConfiguration config) {
public void configureRepositoryRestConfiguration(final RepositoryRestConfiguration config,
CorsRegistry cors) {
config.setRepositoryDetectionStrategy(RepositoryDetectionStrategies.ANNOTATED);
}
};
}
}
}

0 comments on commit f92e3d7

Please sign in to comment.