Search in sources :

Example 21 with ProgramMessage

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;
}
Also used : SqlHelper(org.hisp.dhis.commons.util.SqlHelper) ProgramMessage(org.hisp.dhis.program.message.ProgramMessage)

Example 22 with ProgramMessage

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);
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) ProgramMessage(org.hisp.dhis.program.message.ProgramMessage)

Aggregations

ProgramMessage (org.hisp.dhis.program.message.ProgramMessage)22 Test (org.junit.jupiter.api.Test)16 BatchResponseStatus (org.hisp.dhis.outboundmessage.BatchResponseStatus)8 DhisConvenienceTest (org.hisp.dhis.DhisConvenienceTest)7 NotificationTemplate (org.hisp.dhis.notification.NotificationTemplate)7 DhisSpringTest (org.hisp.dhis.DhisSpringTest)6 ProgramInstance (org.hisp.dhis.program.ProgramInstance)5 ProgramMessageRecipients (org.hisp.dhis.program.message.ProgramMessageRecipients)4 ProgramStageInstance (org.hisp.dhis.program.ProgramStageInstance)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 SqlHelper (org.hisp.dhis.commons.util.SqlHelper)1 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)1 NotificationMessage (org.hisp.dhis.notification.NotificationMessage)1 ProgramMessageBatch (org.hisp.dhis.program.message.ProgramMessageBatch)1 ProgramMessageQueryParams (org.hisp.dhis.program.message.ProgramMessageQueryParams)1