2018-03-21 11:57:56 +01:00
|
|
|
package eu.eudat.data.dao.entities;
|
2017-09-14 12:37:36 +02:00
|
|
|
|
2018-03-21 11:57:56 +01:00
|
|
|
import eu.eudat.data.dao.DatabaseAccess;
|
|
|
|
import eu.eudat.data.dao.criteria.ServiceCriteria;
|
|
|
|
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
|
|
|
import eu.eudat.data.entities.Service;
|
2018-01-25 16:24:21 +01:00
|
|
|
import eu.eudat.queryable.QueryableList;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2018-10-02 16:33:58 +02:00
|
|
|
import org.springframework.scheduling.annotation.Async;
|
2017-12-15 00:01:26 +01:00
|
|
|
import org.springframework.stereotype.Component;
|
2017-09-14 12:37:36 +02:00
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
import java.util.UUID;
|
2018-02-21 11:07:31 +01:00
|
|
|
import java.util.concurrent.CompletableFuture;
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2017-12-15 00:01:26 +01:00
|
|
|
@Component("serviceDao")
|
2018-01-25 16:24:21 +01:00
|
|
|
public class ServiceDaoImpl extends DatabaseAccess<Service> implements ServiceDao {
|
2017-09-14 12:37:36 +02:00
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
@Autowired
|
|
|
|
public ServiceDaoImpl(DatabaseService<Service> databaseService) {
|
2018-05-28 11:50:42 +02:00
|
|
|
super(databaseService);
|
2018-02-16 11:34:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public QueryableList<Service> getWithCriteria(ServiceCriteria criteria) {
|
|
|
|
QueryableList<Service> query = this.getDatabaseService().getQueryable(Service.class);
|
|
|
|
if (criteria.getLike() != null)
|
|
|
|
query.where((builder, root) -> builder.equal(root.get("reference"), criteria.getLike()));
|
|
|
|
return query;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Service createOrUpdate(Service item) {
|
|
|
|
return this.getDatabaseService().createOrUpdate(item, Service.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Service find(UUID id) {
|
|
|
|
return this.getDatabaseService().getQueryable(Service.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void delete(Service item) {
|
|
|
|
this.getDatabaseService().delete(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public QueryableList<Service> asQueryable() {
|
|
|
|
return this.getDatabaseService().getQueryable(Service.class);
|
|
|
|
}
|
2018-02-21 11:07:31 +01:00
|
|
|
|
2018-10-02 16:33:58 +02:00
|
|
|
@Async
|
2018-02-21 11:07:31 +01:00
|
|
|
@Override
|
|
|
|
public CompletableFuture<Service> createOrUpdateAsync(Service item) {
|
|
|
|
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Service find(UUID id, String hint) {
|
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
2017-09-14 12:37:36 +02:00
|
|
|
}
|