* {@inheritDoc }
*/
@Override
public List<SimpleAction> getLogs(LogSearchCriteria searchCriteria) {
final Session session = (Session) entityManager.getDelegate();
final Conjunction criteria = conjunction();
if (searchCriteria.isUserNameSet()) {
criteria.add(eq("userNickname", searchCriteria.getUserName()));
}
if (searchCriteria.isDateSet()) {
switch (searchCriteria.getDateType()) {
case SINGLE: {
criteria.add(eq("actionDate", searchCriteria.getDateSingle()));
break;
}
case PERIOD: {
criteria.add(between("actionDate", searchCriteria.getDateFrom(), searchCriteria.getDateTo()));
break;
}
}
}
if (searchCriteria.isOperationsSet()) {
Disjunction operations = disjunction();
for (PosibleOperations operation : searchCriteria.getOperations()) {
operations.add(eq("actionName", operation));
}
criteria.add(operations);
}
return session.createCriteria(SimpleAction.class).add(criteria).
addOrder(Order.desc("actionDate")).addOrder(Order.desc("actionTime")).list();
}