use of org.hisp.dhis.program.message.ProgramMessage in project dhis2-core by dhis2.
the class HibernateProgramMessageStore method getHqlQuery.
// -------------------------------------------------------------------------
// Supportive Methods
// -------------------------------------------------------------------------
private Query<ProgramMessage> getHqlQuery(ProgramMessageQueryParams params) {
SqlHelper helper = new SqlHelper(true);
String hql = " select distinct pm from ProgramMessage pm ";
if (params.hasProgramInstance()) {
hql += helper.whereAnd() + "pm.programInstance = :programInstance";
}
if (params.hasProgramStageInstance()) {
hql += helper.whereAnd() + "pm.programStageInstance = :programStageInstance";
}
hql += params.getMessageStatus() != null ? helper.whereAnd() + "pm.messageStatus = :messageStatus" : "";
hql += params.getAfterDate() != null ? helper.whereAnd() + "pm.processeddate > :processeddate" : "";
hql += params.getBeforeDate() != null ? helper.whereAnd() + "pm.processeddate < :processeddate" : "";
Query<ProgramMessage> query = getQuery(hql);
if (params.hasProgramInstance()) {
query.setParameter("programInstance", params.getProgramInstance());
}
if (params.hasProgramStageInstance()) {
query.setParameter("programStageInstance", params.getProgramStageInstance());
}
if (params.getMessageStatus() != null) {
query.setParameter("messageStatus", params.getMessageStatus());
}
if (params.getAfterDate() != null) {
query.setParameter("processeddate", params.getAfterDate());
}
if (params.getBeforeDate() != null) {
query.setParameter("processeddate", params.getBeforeDate());
}
return query;
}
use of org.hisp.dhis.program.message.ProgramMessage in project dhis2-core by dhis2.
the class HibernateProgramMessageStore method getAllOutboundMessages.
@Override
public List<ProgramMessage> getAllOutboundMessages() {
CriteriaBuilder builder = getCriteriaBuilder();
JpaQueryParameters<ProgramMessage> parameters = newJpaParameters().addPredicate(root -> builder.and(builder.equal(root.get("messageStatus"), "OUTBOUND"), builder.equal(root.get("messageCatagory"), "OUTGOING")));
return getList(builder, parameters);
}
Aggregations