2018-03-21 11:57:56 +01:00
|
|
|
package eu.eudat.data.dao.databaselayer.service;
|
2017-12-17 22:34:24 +01:00
|
|
|
|
|
|
|
|
2018-03-21 11:57:56 +01:00
|
|
|
import eu.eudat.data.dao.databaselayer.context.DatabaseContext;
|
2017-12-17 22:34:24 +01:00
|
|
|
import eu.eudat.queryable.QueryableList;
|
2018-03-21 11:16:32 +01:00
|
|
|
import eu.eudat.queryable.queryableentity.DataEntity;
|
2017-12-17 22:34:24 +01:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
2018-01-02 09:36:40 +01:00
|
|
|
import java.util.Set;
|
|
|
|
|
2018-02-01 10:08:06 +01:00
|
|
|
|
2017-12-17 22:34:24 +01:00
|
|
|
@Service("databaseService")
|
2018-02-20 08:50:17 +01:00
|
|
|
public class DatabaseService<T extends DataEntity> {
|
2018-01-25 16:24:21 +01:00
|
|
|
|
2017-12-17 22:34:24 +01:00
|
|
|
private DatabaseContext<T> databaseCtx;
|
|
|
|
|
2018-01-25 16:24:21 +01:00
|
|
|
@Autowired
|
|
|
|
public DatabaseService(DatabaseContext<T> databaseCtx) {
|
|
|
|
this.databaseCtx = databaseCtx;
|
|
|
|
}
|
|
|
|
|
2017-12-17 22:34:24 +01:00
|
|
|
public QueryableList<T> getQueryable(Class<T> tClass) {
|
|
|
|
return this.databaseCtx.getQueryable(tClass);
|
|
|
|
}
|
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
public QueryableList<T> getQueryable(Set<String> hints, Class<T> tClass) {
|
2018-05-28 11:50:42 +02:00
|
|
|
return this.databaseCtx.getQueryable(tClass);
|
2018-01-02 09:36:40 +01:00
|
|
|
}
|
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
public T createOrUpdate(T item, Class<T> tClass) {
|
2017-12-17 22:34:24 +01:00
|
|
|
return this.databaseCtx.createOrUpdate(item, tClass);
|
|
|
|
}
|
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
public void delete(T item) {
|
2018-01-25 16:24:21 +01:00
|
|
|
this.databaseCtx.delete(item);
|
|
|
|
}
|
|
|
|
|
2017-12-17 22:34:24 +01:00
|
|
|
}
|