use of org.compiere.model.MAlert 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();
}
use of org.compiere.model.MAlert 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);
}
use of org.compiere.model.MAlert in project adempiere by adempiere.
the class AlertTest method testAlertCreation.
/**
* Run
*/
public void testAlertCreation() throws Exception {
log.info("trx = " + getTrxName());
boolean resultSave = false;
//----- Old way:
MAlert alertOldWay = new MAlert(Env.getCtx(), 100, getTrxName());
log.info(alertOldWay.toString());
X_AD_AlertProcessor alertProcessorOldWay = new X_AD_AlertProcessor(Env.getCtx(), alertOldWay.getAD_AlertProcessor_ID(), getTrxName());
log.info("alertProcessorOldWay.getAD_AlertProcessor_ID = " + alertProcessorOldWay.getAD_AlertProcessor_ID());
alertOldWay.setDescription("Trifon test");
//--- Save;
resultSave = alertOldWay.save();
log.info("resultSave = " + resultSave);
System.out.println("New value of Description = " + alertOldWay.getDescription());
//----- New way:
/* I_AD_Alert alert = new MAlert(Env.getCtx(), 100, trx.getTrxName());
log.info(alert.toString());
I_AD_AlertProcessor alertProcessor = alert.getI_AD_AlertProcessor();
log.info("I_AD_AlertProcessor.getAD_AlertProcessor_ID = " + alertProcessor.getAD_AlertProcessor_ID());
log.info("alert.getAD_AlertProcessor_ID = " + alert.getAD_AlertProcessor_ID());
alert.setDescription("Trifon Description modified!");
//--- Save; PO.save(PO) must be static method!!! Two way of usage: PO.save(Object) or PO.save(PO)
//resultSave = PO.save((PO)alert);
resultSave = PO.save(alert); // Overloaded save method; For simple usage!
log.info("resultSave = " + resultSave);
System.out.println("New value of Description = " + alert.getDescription());
*/
commit();
}
Aggregations