|
@@ -13,6 +13,7 @@ import db.mapper.DatabaseMapper;
|
|
import microfolie.persistance.entity.Espace;
|
|
import microfolie.persistance.entity.Espace;
|
|
import microfolie.persistance.entity.Frequentation;
|
|
import microfolie.persistance.entity.Frequentation;
|
|
import microfolie.persistance.entity.Usager;
|
|
import microfolie.persistance.entity.Usager;
|
|
|
|
+import microfolie.utils.DateUtils;
|
|
|
|
|
|
@DbTable(name = "Frequentation", entity = Frequentation.class)
|
|
@DbTable(name = "Frequentation", entity = Frequentation.class)
|
|
public class FrequentationTable extends DatabaseTable<Frequentation>{
|
|
public class FrequentationTable extends DatabaseTable<Frequentation>{
|
|
@@ -23,7 +24,7 @@ public class FrequentationTable extends DatabaseTable<Frequentation>{
|
|
// Private constructor for singleton
|
|
// Private constructor for singleton
|
|
}
|
|
}
|
|
|
|
|
|
- public Frequentation getByUsagerAndEspace(long usagerId, long espaceId) {
|
|
|
|
|
|
+ public List<Frequentation> getByUsagerAndEspace(long usagerId, long espaceId) {
|
|
List<String> fields = new ArrayList<>();
|
|
List<String> fields = new ArrayList<>();
|
|
List<Object> values = new ArrayList<>();
|
|
List<Object> values = new ArrayList<>();
|
|
fields.add("USAGER");
|
|
fields.add("USAGER");
|
|
@@ -31,10 +32,36 @@ public class FrequentationTable extends DatabaseTable<Frequentation>{
|
|
fields.add("ESPACE");
|
|
fields.add("ESPACE");
|
|
values.add(espaceId);
|
|
values.add(espaceId);
|
|
List<Frequentation> frequentation = getWhere(fields, values);
|
|
List<Frequentation> frequentation = getWhere(fields, values);
|
|
|
|
+ return frequentation;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Frequentation getByUsagerAndEspaceToday(long usagerId, long espaceId) {
|
|
|
|
+ List<String> fields = new ArrayList<>();
|
|
|
|
+ List<Object> values = new ArrayList<>();
|
|
|
|
+ fields.add("USAGER");
|
|
|
|
+ values.add(usagerId);
|
|
|
|
+ fields.add("ESPACE");
|
|
|
|
+ values.add(espaceId);
|
|
|
|
+ fields.add("DATE");
|
|
|
|
+ values.add(DateUtils.removeTimeInformation(new Date()).getTime());
|
|
|
|
+ List<Frequentation> frequentation = getWhere(fields, values);
|
|
if (frequentation.size() <= 0) {
|
|
if (frequentation.size() <= 0) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
return frequentation.get(0);
|
|
return frequentation.get(0);
|
|
|
|
+
|
|
|
|
+ /*SQLQueryBuilder sqlBuilder = SQLQueryBuilder.selectQuery("Frequentation");
|
|
|
|
+ sqlBuilder.add("USAGER", usagerId);
|
|
|
|
+ sqlBuilder.add("ESPACE", espaceId);
|
|
|
|
+ sqlBuilder.add("DATE", );
|
|
|
|
+ List<Object> params = sqlBuilder.getParams();
|
|
|
|
+ params.add(from);
|
|
|
|
+ params.add(to);
|
|
|
|
+ Optional<List<Frequentation>> opt = Database.query(sql, params, DatabaseMapper.listMapper(getClass().getAnnotation(DbTable.class)));
|
|
|
|
+ if (opt.isPresent()) {
|
|
|
|
+ return cache(opt.get().get(0));
|
|
|
|
+ }
|
|
|
|
+ return null;*/
|
|
}
|
|
}
|
|
|
|
|
|
public List<Frequentation> getByDate(Date from, Date to) {
|
|
public List<Frequentation> getByDate(Date from, Date to) {
|