Search in sources :

Example 1 with MWFResponsible

use of org.compiere.wf.MWFResponsible in project adempiere by adempiere.

the class WorkflowProcessor method sendEmail.

//	sendAlerts
/**
	 *  Send Alert EMail
	 *  @param activity activity
	 *  @param AD_Message message
	 *  @param toProcess true if to process owner
	 *  @param toSupervisor true if to Supervisor
	 * 	@return number of mails sent
	 */
private int sendEmail(MWFActivity activity, String AD_Message, boolean toProcess, boolean toSupervisor) {
    if (m_client == null || m_client.getAD_Client_ID() != activity.getAD_Client_ID())
        m_client = MClient.get(getCtx(), activity.getAD_Client_ID());
    MWFProcess process = new MWFProcess(getCtx(), activity.getAD_WF_Process_ID(), null);
    String subjectVar = activity.getNode().getName();
    String message = activity.getTextMsg();
    if (message == null || message.length() == 0)
        message = process.getTextMsg();
    File pdf = null;
    PO po = activity.getPO();
    if (po instanceof DocAction) {
        message = ((DocAction) po).getDocumentInfo() + "\n" + message;
        pdf = ((DocAction) po).createPDF();
    }
    //  Inactivity Alert: Workflow Activity {0}
    String subject = Msg.getMsg(m_client.getAD_Language(), AD_Message, new Object[] { subjectVar });
    //	Prevent duplicates
    ArrayList<Integer> list = new ArrayList<Integer>();
    int counter = 0;
    //	To Activity Owner
    if (m_client.sendEMail(activity.getAD_User_ID(), subject, message, pdf))
        counter++;
    list.add(new Integer(activity.getAD_User_ID()));
    //	To Process Owner
    if (toProcess && process.getAD_User_ID() != activity.getAD_User_ID()) {
        if (m_client.sendEMail(process.getAD_User_ID(), subject, message, pdf))
            counter++;
        list.add(new Integer(process.getAD_User_ID()));
    }
    //	To Activity Responsible
    MWFResponsible responsible = MWFResponsible.get(getCtx(), activity.getAD_WF_Responsible_ID());
    counter += sendAlertToResponsible(responsible, list, process, subject, message, pdf);
    //	To Process Responsible
    if (toProcess && process.getAD_WF_Responsible_ID() != activity.getAD_WF_Responsible_ID()) {
        responsible = MWFResponsible.get(getCtx(), process.getAD_WF_Responsible_ID());
        counter += sendAlertToResponsible(responsible, list, process, subject, message, pdf);
    }
    //	Processor SuperVisor
    if (toSupervisor && m_model.getSupervisor_ID() != 0 && !list.contains(new Integer(m_model.getSupervisor_ID()))) {
        if (m_client.sendEMail(m_model.getSupervisor_ID(), subject, message, pdf))
            counter++;
        list.add(new Integer(m_model.getSupervisor_ID()));
    }
    return counter;
}
Also used : MWFResponsible(org.compiere.wf.MWFResponsible) MWFProcess(org.compiere.wf.MWFProcess) DocAction(org.compiere.process.DocAction) ArrayList(java.util.ArrayList) File(java.io.File) PO(org.compiere.model.PO)

Aggregations

File (java.io.File)1 ArrayList (java.util.ArrayList)1 PO (org.compiere.model.PO)1 DocAction (org.compiere.process.DocAction)1 MWFProcess (org.compiere.wf.MWFProcess)1 MWFResponsible (org.compiere.wf.MWFResponsible)1