Search in sources :

Example 1 with MAlertProcessorLog

use of org.compiere.model.MAlertProcessorLog in project adempiere by adempiere.

the class AlertProcessor method doWork.

/**
	 * 	Work
	 */
protected void doWork() {
    m_summary = new StringBuffer();
    m_errors = new StringBuffer();
    //
    int count = 0;
    int countError = 0;
    MAlert[] alerts = m_model.getAlerts(false);
    for (int i = 0; i < alerts.length; i++) {
        if (!processAlert(alerts[i]))
            countError++;
        count++;
    }
    //
    String summary = "Total=" + count;
    if (countError > 0)
        summary += ", Not processed=" + countError;
    summary += " - ";
    m_summary.insert(0, summary);
    //
    int no = m_model.deleteLog();
    m_summary.append("Logs deleted=").append(no);
    //
    MAlertProcessorLog pLog = new MAlertProcessorLog(m_model, m_summary.toString());
    pLog.setReference("#" + String.valueOf(p_runCount) + " - " + TimeUtil.formatElapsed(new Timestamp(p_startWork)));
    pLog.setTextMsg(m_errors.toString());
    pLog.saveEx();
}
Also used : MAlert(org.compiere.model.MAlert) MAlertProcessorLog(org.compiere.model.MAlertProcessorLog) Timestamp(java.sql.Timestamp)

Example 2 with MAlertProcessorLog

use of org.compiere.model.MAlertProcessorLog in project adempiere by adempiere.

the class AlertTest method testAlertProcessor.

public void testAlertProcessor() {
    MAlertProcessor alertpro = new MAlertProcessor(getCtx(), 100, null);
    alertpro.setAD_AlertProcessor_ID(100);
    MAlertProcessorLog[] test = (MAlertProcessorLog[]) alertpro.getLogs();
    assertTrue("Alert Processor has logs", test.length > 0);
    MAlert[] alerts = (MAlert[]) alertpro.getAlerts(true);
    assertTrue("There are alerts", alerts.length > 0);
    assertTrue("There are active recs", MAlertProcessor.getActive(getCtx()).length > 0);
}
Also used : MAlert(org.compiere.model.MAlert) MAlertProcessorLog(org.compiere.model.MAlertProcessorLog) MAlertProcessor(org.compiere.model.MAlertProcessor)

Aggregations

MAlert (org.compiere.model.MAlert)2 MAlertProcessorLog (org.compiere.model.MAlertProcessorLog)2 Timestamp (java.sql.Timestamp)1 MAlertProcessor (org.compiere.model.MAlertProcessor)1