IDEMPIERE-294 BroadCast Message
This commit is contained in:
parent
566df6608e
commit
8d1865571f
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -66,7 +66,7 @@ public class NoteDelete extends SvrProcess
|
|||
{
|
||||
log.info("doIt - AD_User_ID=" + p_AD_User_ID);
|
||||
|
||||
StringBuilder sql = new StringBuilder("DELETE FROM AD_Note WHERE AD_Client_ID=").append(getAD_Client_ID());
|
||||
StringBuilder sql = new StringBuilder("DELETE FROM AD_Note WHERE AD_BroadcastMessage_ID IS NULL AND AD_Client_ID=").append(getAD_Client_ID());
|
||||
if (p_AD_User_ID > 0)
|
||||
sql.append(" AND AD_User_ID=").append(p_AD_User_ID);
|
||||
if (p_KeepLogDays > 0)
|
||||
|
|
|
@ -184,6 +184,7 @@ Export-Package: bsh,
|
|||
org.compiere.util,
|
||||
org.compiere.wf,
|
||||
org.eevolution.model,
|
||||
org.idempiere.broadcast,
|
||||
org.idempiere.distributed,
|
||||
org.jfree,
|
||||
org.jfree.base,
|
||||
|
|
|
@ -90,5 +90,7 @@ public interface IEventTopics {
|
|||
public static final String IMPORT_AFTER_IMPORT = IMPORT_PREFIX+"afterImport";
|
||||
|
||||
public static final String PREF_AFTER_LOAD = "adempiere/pref/afterLoad";
|
||||
|
||||
public static final String BROADCAST_MESSAGE = "adempiere/broadcastMsg";
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.compiere.model.X_AD_BroadcastMessage;
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Vivek
|
||||
* @author Deepak Pansheriya
|
||||
*
|
||||
*/
|
||||
public class MBroadcastMessage extends X_AD_BroadcastMessage
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6390563897422379468L;
|
||||
static private CCache<Integer,MBroadcastMessage> s_cache = new CCache<Integer,MBroadcastMessage>("AD_BroadcastMessage", 30, 60);
|
||||
|
||||
public MBroadcastMessage(Properties ctx, int AD_BroadcastMessage_ID,
|
||||
String trxName)
|
||||
{
|
||||
super(ctx, AD_BroadcastMessage_ID, trxName);
|
||||
}
|
||||
|
||||
public MBroadcastMessage(Properties ctx, ResultSet rs,
|
||||
String trxName)
|
||||
{
|
||||
super(ctx, rs, trxName);
|
||||
}
|
||||
|
||||
public static MBroadcastMessage get (Properties ctx, int AD_BroadcastMessage_ID)
|
||||
{
|
||||
Integer key = new Integer(AD_BroadcastMessage_ID);
|
||||
MBroadcastMessage retValue = (MBroadcastMessage)s_cache.get(key);
|
||||
if (retValue == null)
|
||||
{
|
||||
retValue = new MBroadcastMessage (ctx, AD_BroadcastMessage_ID, null);
|
||||
|
||||
s_cache.put(key, retValue);
|
||||
}
|
||||
return retValue;
|
||||
} // get
|
||||
|
||||
|
||||
/**
|
||||
* Is broadcast message applicable to current login user
|
||||
* @return
|
||||
*/
|
||||
public boolean isValidUserforMessage()
|
||||
{
|
||||
Properties ctx = Env.getCtx();
|
||||
|
||||
if(getBroadcastType()!=null && getBroadcastType().equals("I") && getTarget()!=null){
|
||||
if (getTarget().equals("R") ) {
|
||||
String SQL = "select count(*) from ad_user_roles where ad_role_id = ? and ad_User_ID=?";
|
||||
int roleSubs = DB.getSQLValue(null, SQL, getAD_Role_ID(),Env.getAD_User_ID(ctx));
|
||||
if(roleSubs>0)
|
||||
return true;
|
||||
} else if (getTarget().equals("U") && getAD_User_ID() == Env.getAD_User_ID(ctx)) {
|
||||
return true;
|
||||
} else if (getTarget().equals("C") && getAD_Client_ID() == Env.getAD_Client_ID(ctx)) {
|
||||
return true;
|
||||
}else if (getTarget().equals("E")){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
int AD_User_ID = Env.getAD_User_ID(ctx);
|
||||
String sql = "SELECT AD_User_ID from AD_Note WHERE AD_BroadcastMessage_ID = ? AND AD_User_ID = ? ";
|
||||
int result = DB.getSQLValue(null, sql,getAD_Broadcastmessage_ID(),AD_User_ID);
|
||||
if (result <= 0) {
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,313 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software, you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program, if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
|
||||
/** Generated Interface for AD_BroadcastMessage
|
||||
* @author Adempiere (generated)
|
||||
* @version Release 3.6.0LTS
|
||||
*/
|
||||
public interface I_AD_BroadcastMessage
|
||||
{
|
||||
|
||||
/** TableName=AD_BroadcastMessage */
|
||||
public static final String Table_Name = "AD_BroadcastMessage";
|
||||
|
||||
/** AD_Table_ID=200024 */
|
||||
public static final int Table_ID = 200038;
|
||||
|
||||
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
|
||||
|
||||
/** AccessLevel = 6 - System - Client
|
||||
*/
|
||||
BigDecimal accessLevel = BigDecimal.valueOf(6);
|
||||
|
||||
/** Load Meta Data */
|
||||
|
||||
/** Column name AD_Broadcastmessage_ID */
|
||||
public static final String COLUMNNAME_AD_Broadcastmessage_ID = "AD_Broadcastmessage_ID";
|
||||
|
||||
/** Set Broadcast Message.
|
||||
* Broadcast Message
|
||||
*/
|
||||
public void setAD_Broadcastmessage_ID (int AD_Broadcastmessage_ID);
|
||||
|
||||
/** Get Broadcast Message.
|
||||
* Broadcast Message
|
||||
*/
|
||||
public int getAD_Broadcastmessage_ID();
|
||||
|
||||
/** Column name AD_Client_ID */
|
||||
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
|
||||
|
||||
/** Get Client.
|
||||
* Client/Tenant for this installation.
|
||||
*/
|
||||
public int getAD_Client_ID();
|
||||
|
||||
/** Column name AD_Org_ID */
|
||||
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
|
||||
|
||||
/** Set Organization.
|
||||
* Organizational entity within client
|
||||
*/
|
||||
public void setAD_Org_ID (int AD_Org_ID);
|
||||
|
||||
/** Get Organization.
|
||||
* Organizational entity within client
|
||||
*/
|
||||
public int getAD_Org_ID();
|
||||
|
||||
/** Column name AD_Role_ID */
|
||||
public static final String COLUMNNAME_AD_Role_ID = "AD_Role_ID";
|
||||
|
||||
/** Set Role.
|
||||
* Responsibility Role
|
||||
*/
|
||||
public void setAD_Role_ID (int AD_Role_ID);
|
||||
|
||||
/** Get Role.
|
||||
* Responsibility Role
|
||||
*/
|
||||
public int getAD_Role_ID();
|
||||
|
||||
public org.compiere.model.I_AD_Role getAD_Role() throws RuntimeException;
|
||||
|
||||
/** Column name AD_User_ID */
|
||||
public static final String COLUMNNAME_AD_User_ID = "AD_User_ID";
|
||||
|
||||
/** Set User/Contact.
|
||||
* User within the system - Internal or Business Partner Contact
|
||||
*/
|
||||
public void setAD_User_ID (int AD_User_ID);
|
||||
|
||||
/** Get User/Contact.
|
||||
* User within the system - Internal or Business Partner Contact
|
||||
*/
|
||||
public int getAD_User_ID();
|
||||
|
||||
public org.compiere.model.I_AD_User getAD_User() throws RuntimeException;
|
||||
|
||||
/** Column name BroadcastFrequency */
|
||||
public static final String COLUMNNAME_BroadcastFrequency = "BroadcastFrequency";
|
||||
|
||||
/** Set Broadcast Frequency.
|
||||
* How Many Times Message Should be Broadcasted
|
||||
*/
|
||||
public void setBroadcastFrequency (String BroadcastFrequency);
|
||||
|
||||
/** Get Broadcast Frequency.
|
||||
* How Many Times Message Should be Broadcasted
|
||||
*/
|
||||
public String getBroadcastFrequency();
|
||||
|
||||
/** Column name BroadcastMessage */
|
||||
public static final String COLUMNNAME_BroadcastMessage = "BroadcastMessage";
|
||||
|
||||
/** Set Broadcast Message.
|
||||
* Broadcast Message
|
||||
*/
|
||||
public void setBroadcastMessage (String BroadcastMessage);
|
||||
|
||||
/** Get Broadcast Message.
|
||||
* Broadcast Message
|
||||
*/
|
||||
public String getBroadcastMessage();
|
||||
|
||||
/** Column name BroadcastType */
|
||||
public static final String COLUMNNAME_BroadcastType = "BroadcastType";
|
||||
|
||||
/** Set Broadcast Type.
|
||||
* Type of Broadcast
|
||||
*/
|
||||
public void setBroadcastType (String BroadcastType);
|
||||
|
||||
/** Get Broadcast Type.
|
||||
* Type of Broadcast
|
||||
*/
|
||||
public String getBroadcastType();
|
||||
|
||||
/** Column name Created */
|
||||
public static final String COLUMNNAME_Created = "Created";
|
||||
|
||||
/** Get Created.
|
||||
* Date this record was created
|
||||
*/
|
||||
public Timestamp getCreated();
|
||||
|
||||
/** Column name CreatedBy */
|
||||
public static final String COLUMNNAME_CreatedBy = "CreatedBy";
|
||||
|
||||
/** Get Created By.
|
||||
* User who created this records
|
||||
*/
|
||||
public int getCreatedBy();
|
||||
|
||||
/** Column name Expiration */
|
||||
public static final String COLUMNNAME_Expiration = "Expiration";
|
||||
|
||||
/** Set Expiration.
|
||||
* Expiration
|
||||
*/
|
||||
public void setExpiration (Timestamp Expiration);
|
||||
|
||||
/** Get Expiration.
|
||||
* Expiration
|
||||
*/
|
||||
public Timestamp getExpiration();
|
||||
|
||||
/** Column name Expired */
|
||||
public static final String COLUMNNAME_Expired = "Expired";
|
||||
|
||||
/** Set Expired */
|
||||
public void setExpired (boolean Expired);
|
||||
|
||||
/** Get Expired */
|
||||
public boolean isExpired();
|
||||
|
||||
/** Column name ExpireNow */
|
||||
public static final String COLUMNNAME_ExpireNow = "ExpireNow";
|
||||
|
||||
/** Set Expire Now.
|
||||
* Expire the broadcast message
|
||||
*/
|
||||
public void setExpireNow (String ExpireNow);
|
||||
|
||||
/** Get Expire Now.
|
||||
* Expire the broadcast message
|
||||
*/
|
||||
public String getExpireNow();
|
||||
|
||||
/** Column name IsActive */
|
||||
public static final String COLUMNNAME_IsActive = "IsActive";
|
||||
|
||||
/** Set Active.
|
||||
* The record is active in the system
|
||||
*/
|
||||
public void setIsActive (boolean IsActive);
|
||||
|
||||
/** Get Active.
|
||||
* The record is active in the system
|
||||
*/
|
||||
public boolean isActive();
|
||||
|
||||
/** Column name IsPublished */
|
||||
public static final String COLUMNNAME_IsPublished = "IsPublished";
|
||||
|
||||
/** Set Published.
|
||||
* The Topic is published and can be viewed
|
||||
*/
|
||||
public void setIsPublished (boolean IsPublished);
|
||||
|
||||
/** Get Published.
|
||||
* The Topic is published and can be viewed
|
||||
*/
|
||||
public boolean isPublished();
|
||||
|
||||
/** Column name LogAcknowledge */
|
||||
public static final String COLUMNNAME_LogAcknowledge = "LogAcknowledge";
|
||||
|
||||
/** Set Log Acknowledge.
|
||||
* Want to Log the Acknowledgement of Message?
|
||||
*/
|
||||
public void setLogAcknowledge (boolean LogAcknowledge);
|
||||
|
||||
/** Get Log Acknowledge.
|
||||
* Want to Log the Acknowledgement of Message?
|
||||
*/
|
||||
public boolean isLogAcknowledge();
|
||||
|
||||
/** Column name Notification_Client */
|
||||
public static final String COLUMNNAME_Notification_Client = "Notification_Client";
|
||||
|
||||
/** Set Notification_Client */
|
||||
public void setNotification_Client (int Notification_Client);
|
||||
|
||||
/** Get Notification_Client */
|
||||
public int getNotification_Client();
|
||||
|
||||
/** Column name Processed */
|
||||
public static final String COLUMNNAME_Processed = "Processed";
|
||||
|
||||
/** Set Processed.
|
||||
* The document has been processed
|
||||
*/
|
||||
public void setProcessed (boolean Processed);
|
||||
|
||||
/** Get Processed.
|
||||
* The document has been processed
|
||||
*/
|
||||
public boolean isProcessed();
|
||||
|
||||
/** Column name Publish */
|
||||
public static final String COLUMNNAME_Publish = "Publish";
|
||||
|
||||
/** Set Publish.
|
||||
* Publish Broadcast Message
|
||||
*/
|
||||
public void setPublish (String Publish);
|
||||
|
||||
/** Get Publish.
|
||||
* Publish Broadcast Message
|
||||
*/
|
||||
public String getPublish();
|
||||
|
||||
/** Column name Target */
|
||||
public static final String COLUMNNAME_Target = "Target";
|
||||
|
||||
/** Set Target.
|
||||
* Target client
|
||||
*/
|
||||
public void setTarget (String Target);
|
||||
|
||||
/** Get Target.
|
||||
* Target client
|
||||
*/
|
||||
public String getTarget();
|
||||
|
||||
/** Column name TestMessage */
|
||||
public static final String COLUMNNAME_TestMessage = "TestMessage";
|
||||
|
||||
/** Set Test Message.
|
||||
* Test broadcast message
|
||||
*/
|
||||
public void setTestMessage (String TestMessage);
|
||||
|
||||
/** Get Test Message.
|
||||
* Test broadcast message
|
||||
*/
|
||||
public String getTestMessage();
|
||||
|
||||
/** Column name Updated */
|
||||
public static final String COLUMNNAME_Updated = "Updated";
|
||||
|
||||
/** Get Updated.
|
||||
* Date this record was updated
|
||||
*/
|
||||
public Timestamp getUpdated();
|
||||
|
||||
/** Column name UpdatedBy */
|
||||
public static final String COLUMNNAME_UpdatedBy = "UpdatedBy";
|
||||
|
||||
/** Get Updated By.
|
||||
* User who updated this records
|
||||
*/
|
||||
public int getUpdatedBy();
|
||||
}
|
|
@ -41,6 +41,34 @@ public interface I_AD_Note
|
|||
|
||||
/** Load Meta Data */
|
||||
|
||||
/** Column name AcknowledgeDateTime */
|
||||
public static final String COLUMNNAME_AcknowledgeDateTime = "AcknowledgeDateTime";
|
||||
|
||||
/** Set Acknowledgement Time.
|
||||
* Acknowledgement Time of message
|
||||
*/
|
||||
public void setAcknowledgeDateTime (Timestamp AcknowledgeDateTime);
|
||||
|
||||
/** Get Acknowledgement Time.
|
||||
* Acknowledgement Time of message
|
||||
*/
|
||||
public Timestamp getAcknowledgeDateTime();
|
||||
|
||||
/** Column name AD_Broadcastmessage_ID */
|
||||
public static final String COLUMNNAME_AD_Broadcastmessage_ID = "AD_Broadcastmessage_ID";
|
||||
|
||||
/** Set Broadcast Message.
|
||||
* Broadcast Message
|
||||
*/
|
||||
public void setAD_Broadcastmessage_ID (int AD_Broadcastmessage_ID);
|
||||
|
||||
/** Get Broadcast Message.
|
||||
* Broadcast Message
|
||||
*/
|
||||
public int getAD_Broadcastmessage_ID();
|
||||
|
||||
public I_AD_BroadcastMessage getAD_Broadcastmessage() throws RuntimeException;
|
||||
|
||||
/** Column name AD_Client_ID */
|
||||
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
|
||||
|
||||
|
|
|
@ -0,0 +1,423 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software, you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program, if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
/** Generated Model - DO NOT CHANGE */
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Properties;
|
||||
|
||||
/** Generated Model for AD_BroadcastMessage
|
||||
* @author Adempiere (generated)
|
||||
* @version Release 3.6.0LTS - $Id$ */
|
||||
public class X_AD_BroadcastMessage extends PO implements I_AD_BroadcastMessage, I_Persistent
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 20121107L;
|
||||
|
||||
/** Standard Constructor */
|
||||
public X_AD_BroadcastMessage (Properties ctx, int AD_BroadcastMessage_ID, String trxName)
|
||||
{
|
||||
super (ctx, AD_BroadcastMessage_ID, trxName);
|
||||
/** if (AD_BroadcastMessage_ID == 0)
|
||||
{
|
||||
} */
|
||||
}
|
||||
|
||||
/** Load Constructor */
|
||||
public X_AD_BroadcastMessage (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super (ctx, rs, trxName);
|
||||
}
|
||||
|
||||
/** AccessLevel
|
||||
* @return 6 - System - Client
|
||||
*/
|
||||
protected int get_AccessLevel()
|
||||
{
|
||||
return accessLevel.intValue();
|
||||
}
|
||||
|
||||
/** Load Meta Data */
|
||||
protected POInfo initPO (Properties ctx)
|
||||
{
|
||||
POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName());
|
||||
return poi;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer ("X_AD_BroadcastMessage[")
|
||||
.append(get_ID()).append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** Set Broadcast Message.
|
||||
@param AD_Broadcastmessage_ID
|
||||
Broadcast Message
|
||||
*/
|
||||
public void setAD_Broadcastmessage_ID (int AD_Broadcastmessage_ID)
|
||||
{
|
||||
if (AD_Broadcastmessage_ID < 1)
|
||||
set_ValueNoCheck (COLUMNNAME_AD_Broadcastmessage_ID, null);
|
||||
else
|
||||
set_ValueNoCheck (COLUMNNAME_AD_Broadcastmessage_ID, Integer.valueOf(AD_Broadcastmessage_ID));
|
||||
}
|
||||
|
||||
/** Get Broadcast Message.
|
||||
@return Broadcast Message
|
||||
*/
|
||||
public int getAD_Broadcastmessage_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_AD_Broadcastmessage_ID);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
public org.compiere.model.I_AD_Role getAD_Role() throws RuntimeException
|
||||
{
|
||||
return (org.compiere.model.I_AD_Role)MTable.get(getCtx(), org.compiere.model.I_AD_Role.Table_Name)
|
||||
.getPO(getAD_Role_ID(), get_TrxName()); }
|
||||
|
||||
/** Set Role.
|
||||
@param AD_Role_ID
|
||||
Responsibility Role
|
||||
*/
|
||||
public void setAD_Role_ID (int AD_Role_ID)
|
||||
{
|
||||
if (AD_Role_ID < 0)
|
||||
set_Value (COLUMNNAME_AD_Role_ID, null);
|
||||
else
|
||||
set_Value (COLUMNNAME_AD_Role_ID, Integer.valueOf(AD_Role_ID));
|
||||
}
|
||||
|
||||
/** Get Role.
|
||||
@return Responsibility Role
|
||||
*/
|
||||
public int getAD_Role_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_AD_Role_ID);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
public org.compiere.model.I_AD_User getAD_User() throws RuntimeException
|
||||
{
|
||||
return (org.compiere.model.I_AD_User)MTable.get(getCtx(), org.compiere.model.I_AD_User.Table_Name)
|
||||
.getPO(getAD_User_ID(), get_TrxName()); }
|
||||
|
||||
/** Set User/Contact.
|
||||
@param AD_User_ID
|
||||
User within the system - Internal or Business Partner Contact
|
||||
*/
|
||||
public void setAD_User_ID (int AD_User_ID)
|
||||
{
|
||||
if (AD_User_ID < 1)
|
||||
set_Value (COLUMNNAME_AD_User_ID, null);
|
||||
else
|
||||
set_Value (COLUMNNAME_AD_User_ID, Integer.valueOf(AD_User_ID));
|
||||
}
|
||||
|
||||
/** Get User/Contact.
|
||||
@return User within the system - Internal or Business Partner Contact
|
||||
*/
|
||||
public int getAD_User_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_AD_User_ID);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** BroadcastFrequency AD_Reference_ID=200010 */
|
||||
public static final int BROADCASTFREQUENCY_AD_Reference_ID=200010;
|
||||
/** Just Once = J */
|
||||
public static final String BROADCASTFREQUENCY_JustOnce = "J";
|
||||
/** Until Expiration = U */
|
||||
public static final String BROADCASTFREQUENCY_UntilExpiration = "U";
|
||||
/** Set Broadcast Frequency.
|
||||
@param BroadcastFrequency
|
||||
How Many Times Message Should be Broadcasted
|
||||
*/
|
||||
public void setBroadcastFrequency (String BroadcastFrequency)
|
||||
{
|
||||
|
||||
set_Value (COLUMNNAME_BroadcastFrequency, BroadcastFrequency);
|
||||
}
|
||||
|
||||
/** Get Broadcast Frequency.
|
||||
@return How Many Times Message Should be Broadcasted
|
||||
*/
|
||||
public String getBroadcastFrequency ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_BroadcastFrequency);
|
||||
}
|
||||
|
||||
/** Set Broadcast Message.
|
||||
@param BroadcastMessage
|
||||
Broadcast Message
|
||||
*/
|
||||
public void setBroadcastMessage (String BroadcastMessage)
|
||||
{
|
||||
set_Value (COLUMNNAME_BroadcastMessage, BroadcastMessage);
|
||||
}
|
||||
|
||||
/** Get Broadcast Message.
|
||||
@return Broadcast Message
|
||||
*/
|
||||
public String getBroadcastMessage ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_BroadcastMessage);
|
||||
}
|
||||
|
||||
/** BroadcastType AD_Reference_ID=200009 */
|
||||
public static final int BROADCASTTYPE_AD_Reference_ID=200009;
|
||||
/** Login = L */
|
||||
public static final String BROADCASTTYPE_Login = "L";
|
||||
/** Immediate = I */
|
||||
public static final String BROADCASTTYPE_Immediate = "I";
|
||||
/** Immediate + Login = IL */
|
||||
public static final String BROADCASTTYPE_ImmediatePlusLogin = "IL";
|
||||
/** Set Broadcast Type.
|
||||
@param BroadcastType
|
||||
Type of Broadcast
|
||||
*/
|
||||
public void setBroadcastType (String BroadcastType)
|
||||
{
|
||||
|
||||
set_Value (COLUMNNAME_BroadcastType, BroadcastType);
|
||||
}
|
||||
|
||||
/** Get Broadcast Type.
|
||||
@return Type of Broadcast
|
||||
*/
|
||||
public String getBroadcastType ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_BroadcastType);
|
||||
}
|
||||
|
||||
/** Set Expiration.
|
||||
@param Expiration
|
||||
Expiration
|
||||
*/
|
||||
public void setExpiration (Timestamp Expiration)
|
||||
{
|
||||
set_Value (COLUMNNAME_Expiration, Expiration);
|
||||
}
|
||||
|
||||
/** Get Expiration.
|
||||
@return Expiration
|
||||
*/
|
||||
public Timestamp getExpiration ()
|
||||
{
|
||||
return (Timestamp)get_Value(COLUMNNAME_Expiration);
|
||||
}
|
||||
|
||||
/** Set Expired.
|
||||
@param Expired Expired */
|
||||
public void setExpired (boolean Expired)
|
||||
{
|
||||
set_Value (COLUMNNAME_Expired, Boolean.valueOf(Expired));
|
||||
}
|
||||
|
||||
/** Get Expired.
|
||||
@return Expired */
|
||||
public boolean isExpired ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_Expired);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set Expire Now.
|
||||
@param ExpireNow
|
||||
Expire the broadcast message
|
||||
*/
|
||||
public void setExpireNow (String ExpireNow)
|
||||
{
|
||||
set_Value (COLUMNNAME_ExpireNow, ExpireNow);
|
||||
}
|
||||
|
||||
/** Get Expire Now.
|
||||
@return Expire the broadcast message
|
||||
*/
|
||||
public String getExpireNow ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_ExpireNow);
|
||||
}
|
||||
|
||||
/** Set Published.
|
||||
@param IsPublished
|
||||
The Topic is published and can be viewed
|
||||
*/
|
||||
public void setIsPublished (boolean IsPublished)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsPublished, Boolean.valueOf(IsPublished));
|
||||
}
|
||||
|
||||
/** Get Published.
|
||||
@return The Topic is published and can be viewed
|
||||
*/
|
||||
public boolean isPublished ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsPublished);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set Log Acknowledge.
|
||||
@param LogAcknowledge
|
||||
Want to Log the Acknowledgement of Message?
|
||||
*/
|
||||
public void setLogAcknowledge (boolean LogAcknowledge)
|
||||
{
|
||||
set_Value (COLUMNNAME_LogAcknowledge, Boolean.valueOf(LogAcknowledge));
|
||||
}
|
||||
|
||||
/** Get Log Acknowledge.
|
||||
@return Want to Log the Acknowledgement of Message?
|
||||
*/
|
||||
public boolean isLogAcknowledge ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_LogAcknowledge);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set Notification_Client.
|
||||
@param Notification_Client Notification_Client */
|
||||
public void setNotification_Client (int Notification_Client)
|
||||
{
|
||||
set_Value (COLUMNNAME_Notification_Client, Integer.valueOf(Notification_Client));
|
||||
}
|
||||
|
||||
/** Get Notification_Client.
|
||||
@return Notification_Client */
|
||||
public int getNotification_Client ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_Notification_Client);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** Set Processed.
|
||||
@param Processed
|
||||
The document has been processed
|
||||
*/
|
||||
public void setProcessed (boolean Processed)
|
||||
{
|
||||
set_Value (COLUMNNAME_Processed, Boolean.valueOf(Processed));
|
||||
}
|
||||
|
||||
/** Get Processed.
|
||||
@return The document has been processed
|
||||
*/
|
||||
public boolean isProcessed ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_Processed);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set Publish.
|
||||
@param Publish
|
||||
Publish Broadcast Message
|
||||
*/
|
||||
public void setPublish (String Publish)
|
||||
{
|
||||
set_Value (COLUMNNAME_Publish, Publish);
|
||||
}
|
||||
|
||||
/** Get Publish.
|
||||
@return Publish Broadcast Message
|
||||
*/
|
||||
public String getPublish ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_Publish);
|
||||
}
|
||||
|
||||
/** Target AD_Reference_ID=200011 */
|
||||
public static final int TARGET_AD_Reference_ID=200011;
|
||||
/** Everybody = E */
|
||||
public static final String TARGET_Everybody = "E";
|
||||
/** Client = C */
|
||||
public static final String TARGET_Client = "C";
|
||||
/** User = U */
|
||||
public static final String TARGET_User = "U";
|
||||
/** Role = R */
|
||||
public static final String TARGET_Role = "R";
|
||||
/** Set Target.
|
||||
@param Target
|
||||
Target client
|
||||
*/
|
||||
public void setTarget (String Target)
|
||||
{
|
||||
|
||||
set_Value (COLUMNNAME_Target, Target);
|
||||
}
|
||||
|
||||
/** Get Target.
|
||||
@return Target client
|
||||
*/
|
||||
public String getTarget ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_Target);
|
||||
}
|
||||
|
||||
/** Set Test Message.
|
||||
@param TestMessage
|
||||
Test broadcast message
|
||||
*/
|
||||
public void setTestMessage (String TestMessage)
|
||||
{
|
||||
set_Value (COLUMNNAME_TestMessage, TestMessage);
|
||||
}
|
||||
|
||||
/** Get Test Message.
|
||||
@return Test broadcast message
|
||||
*/
|
||||
public String getTestMessage ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_TestMessage);
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@
|
|||
package org.compiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Properties;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
|
||||
|
@ -30,7 +31,7 @@ public class X_AD_Note extends PO implements I_AD_Note, I_Persistent
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 20121031L;
|
||||
private static final long serialVersionUID = 20121024L;
|
||||
|
||||
/** Standard Constructor */
|
||||
public X_AD_Note (Properties ctx, int AD_Note_ID, String trxName)
|
||||
|
@ -71,6 +72,51 @@ public class X_AD_Note extends PO implements I_AD_Note, I_Persistent
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
/** Set Acknowledgement Time.
|
||||
@param AcknowledgeDateTime
|
||||
Acknowledgement Time of message
|
||||
*/
|
||||
public void setAcknowledgeDateTime (Timestamp AcknowledgeDateTime)
|
||||
{
|
||||
set_Value (COLUMNNAME_AcknowledgeDateTime, AcknowledgeDateTime);
|
||||
}
|
||||
|
||||
/** Get Acknowledgement Time.
|
||||
@return Acknowledgement Time of message
|
||||
*/
|
||||
public Timestamp getAcknowledgeDateTime ()
|
||||
{
|
||||
return (Timestamp)get_Value(COLUMNNAME_AcknowledgeDateTime);
|
||||
}
|
||||
|
||||
public org.compiere.model.I_AD_BroadcastMessage getAD_Broadcastmessage() throws RuntimeException
|
||||
{
|
||||
return (org.compiere.model.I_AD_BroadcastMessage)MTable.get(getCtx(), org.compiere.model.I_AD_BroadcastMessage.Table_Name)
|
||||
.getPO(getAD_Broadcastmessage_ID(), get_TrxName()); }
|
||||
|
||||
/** Set Broadcast Message.
|
||||
@param AD_Broadcastmessage_ID
|
||||
Broadcast Message
|
||||
*/
|
||||
public void setAD_Broadcastmessage_ID (int AD_Broadcastmessage_ID)
|
||||
{
|
||||
if (AD_Broadcastmessage_ID < 1)
|
||||
set_Value (COLUMNNAME_AD_Broadcastmessage_ID, null);
|
||||
else
|
||||
set_Value (COLUMNNAME_AD_Broadcastmessage_ID, Integer.valueOf(AD_Broadcastmessage_ID));
|
||||
}
|
||||
|
||||
/** Get Broadcast Message.
|
||||
@return Broadcast Message
|
||||
*/
|
||||
public int getAD_Broadcastmessage_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_AD_Broadcastmessage_ID);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
public org.compiere.model.I_AD_Message getAD_Message() throws RuntimeException
|
||||
{
|
||||
return (org.compiere.model.I_AD_Message)MTable.get(getCtx(), org.compiere.model.I_AD_Message.Table_Name)
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.idempiere.broadcast;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Deepak Pansheriya
|
||||
*
|
||||
*/
|
||||
public class BroadCastMsg implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7669279373526944539L;
|
||||
|
||||
private String src;
|
||||
private int messageId;
|
||||
private String targetNode;
|
||||
private int eventId;
|
||||
|
||||
private boolean fromCluster = false;
|
||||
|
||||
public boolean isFromCluster() {
|
||||
return fromCluster;
|
||||
}
|
||||
|
||||
public void setFromCluster(boolean fromCluster) {
|
||||
this.fromCluster = fromCluster;
|
||||
}
|
||||
|
||||
public int getEventId() {
|
||||
return eventId;
|
||||
}
|
||||
|
||||
public void setEventId(int eventId) {
|
||||
this.eventId = eventId;
|
||||
}
|
||||
|
||||
public String getTargetNode() {
|
||||
return targetNode;
|
||||
}
|
||||
|
||||
public void setTargetNode(String targetNode) {
|
||||
this.targetNode = targetNode;
|
||||
}
|
||||
|
||||
public String getSrc() {
|
||||
return src;
|
||||
}
|
||||
|
||||
public void setSrc(String src) {
|
||||
this.src = src;
|
||||
}
|
||||
|
||||
public int getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public void setMessageId(int messageId) {
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.idempiere.broadcast;
|
||||
|
||||
import org.adempiere.base.IServiceHolder;
|
||||
import org.adempiere.base.Service;
|
||||
import org.idempiere.distributed.IMessageService;
|
||||
import org.idempiere.distributed.ITopic;
|
||||
import org.idempiere.distributed.ITopicSubscriber;
|
||||
|
||||
/**
|
||||
* @author Deepak Pansheriya
|
||||
*/
|
||||
public class BroadCastUtil {
|
||||
public static final String TOPIC_BROADCAST_MESSAGE="BROADCAST_MESSAGE";
|
||||
public static final int EVENT_BROADCAST_MESSAGE =1;
|
||||
public static final int EVENT_TEST_BROADCAST_MESSAGE=2;
|
||||
public static final int EVENT_SESSION_TIMEOUT =3;
|
||||
|
||||
public static void subscribe(ITopicSubscriber<BroadCastMsg> subscriber){
|
||||
|
||||
IServiceHolder<IMessageService> holder = Service.locator().locate(IMessageService.class);
|
||||
IMessageService service = holder.getService();
|
||||
if (service != null) {
|
||||
ITopic<BroadCastMsg> topic= service.getTopic(TOPIC_BROADCAST_MESSAGE);
|
||||
topic.subscribe(subscriber);
|
||||
}
|
||||
}
|
||||
|
||||
public static void unSubscribe(ITopicSubscriber<BroadCastMsg> subscriber){
|
||||
|
||||
IServiceHolder<IMessageService> holder = Service.locator().locate(IMessageService.class);
|
||||
IMessageService service = holder.getService();
|
||||
if (service != null) {
|
||||
ITopic<BroadCastMsg> topic= service.getTopic(TOPIC_BROADCAST_MESSAGE);
|
||||
topic.unsubscribe(subscriber);
|
||||
}
|
||||
}
|
||||
|
||||
public static void publish(BroadCastMsg msg){
|
||||
|
||||
IServiceHolder<IMessageService> holder = Service.locator().locate(IMessageService.class);
|
||||
IMessageService service = holder.getService();
|
||||
if (service != null) {
|
||||
ITopic<BroadCastMsg> topic= service.getTopic(TOPIC_BROADCAST_MESSAGE);
|
||||
topic.publish(msg);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,183 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
|
||||
package org.idempiere.broadcast;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.base.event.EventManager;
|
||||
import org.adempiere.base.event.IEventTopics;
|
||||
import org.adempiere.model.MBroadcastMessage;
|
||||
import org.compiere.model.MNote;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Vivek
|
||||
* @author Deepak Pansheriya
|
||||
*
|
||||
*/
|
||||
public class BroadcastMsgUtil
|
||||
{
|
||||
|
||||
private static final CLogger logger = CLogger
|
||||
.getCLogger(BroadcastMsgUtil.class);
|
||||
// BROADCAST_MESSAGE_QUEUE
|
||||
|
||||
|
||||
/**
|
||||
* Publish Message
|
||||
* @param messageID
|
||||
* @param trxName
|
||||
*/
|
||||
public static void publishBroadcastMessage(final int messageID, String trxName) {
|
||||
MBroadcastMessage mbMessage = MBroadcastMessage.get(Env.getCtx(), messageID);
|
||||
String broadcastType = mbMessage.getBroadcastType();
|
||||
|
||||
if (MBroadcastMessage.BROADCASTTYPE_Login.equals(broadcastType)
|
||||
|| MBroadcastMessage.BROADCASTTYPE_ImmediatePlusLogin.equals(broadcastType)) {
|
||||
// get list of users based on rule
|
||||
ArrayList<Integer> userIDs = new ArrayList<Integer>();
|
||||
String SQL = "";
|
||||
|
||||
if (mbMessage.getTarget() != null) {
|
||||
// Role
|
||||
if (mbMessage.getTarget().equals("R")) {
|
||||
SQL = "select DISTINCT(ad_user_id) from ad_user_roles where ad_role_id = "
|
||||
+ mbMessage.getAD_Role_ID();
|
||||
} else if (mbMessage.getTarget().equals("U")) {
|
||||
SQL = "select DISTINCT(ad_user_id) from ad_user_roles where ad_user_id = "
|
||||
+ mbMessage.getAD_User_ID();
|
||||
} else if (mbMessage.getTarget().equals("C")) {
|
||||
SQL = "select DISTINCT(ad_user_id) from ad_user_roles where ad_client_id = "
|
||||
+ mbMessage.getNotification_Client();
|
||||
} else if (mbMessage.getTarget().equals("E")) {
|
||||
SQL = "select DISTINCT(ad_user_id) from ad_user_roles";
|
||||
}
|
||||
|
||||
Statement stmt = DB.createStatement();
|
||||
ResultSet rs =null;
|
||||
try {
|
||||
rs = stmt.executeQuery(SQL);
|
||||
while (rs.next()) {
|
||||
int AD_User_ID = rs.getInt("ad_user_id");
|
||||
userIDs.add(AD_User_ID);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
logger.log(Level.SEVERE, "Exception while retrieving user list",e);
|
||||
}finally{
|
||||
DB.close(rs, stmt);
|
||||
}
|
||||
|
||||
for (Integer userID : userIDs) {
|
||||
MNote note = new MNote(Env.getCtx(), 0, trxName);
|
||||
note.setAD_Broadcastmessage_ID(messageID);
|
||||
note.setAD_User_ID(userID);
|
||||
note.setAD_Message_ID(0);
|
||||
note.save();
|
||||
}
|
||||
mbMessage.setIsPublished(true);
|
||||
mbMessage.setProcessed(true);
|
||||
mbMessage.save(trxName);
|
||||
} // create entry for users in AD_Note
|
||||
}else if(MBroadcastMessage.BROADCASTTYPE_Immediate.equals(broadcastType)){
|
||||
mbMessage.setProcessed(true);
|
||||
mbMessage.setIsPublished(true);
|
||||
mbMessage.save(trxName);
|
||||
}
|
||||
|
||||
if (!MBroadcastMessage.BROADCASTTYPE_Login.equals(broadcastType)) {
|
||||
BroadCastMsg msg = new BroadCastMsg();
|
||||
msg.setMessageId(messageID);
|
||||
msg.setEventId(BroadCastUtil.EVENT_BROADCAST_MESSAGE);
|
||||
pushToQueue(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void pushToQueue(final BroadCastMsg msg){
|
||||
Runnable runnable = new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
org.osgi.service.event.Event event = EventManager.newEvent(IEventTopics.BROADCAST_MESSAGE, msg);
|
||||
EventManager.getInstance().postEvent(event);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Thread thread = new Thread(runnable);
|
||||
thread.setName("PublishMessage -" + Env.getContextAsInt(Env.getCtx(), "AD_Session_ID"));
|
||||
thread.start();
|
||||
}
|
||||
/**
|
||||
* Test message
|
||||
* @param messageID
|
||||
* @param AD_Session_ID
|
||||
*/
|
||||
public static void testBroadcastMessage(int messageID, int AD_Session_ID) {
|
||||
BroadCastMsg msg = new BroadCastMsg();
|
||||
msg.setMessageId(messageID);
|
||||
msg.setFromCluster(true);
|
||||
msg.setEventId(BroadCastUtil.EVENT_TEST_BROADCAST_MESSAGE);
|
||||
msg.setTargetNode(Integer.toString(AD_Session_ID));
|
||||
|
||||
pushToQueue(msg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show all pending to acknowledge messages
|
||||
* @param AD_User_ID
|
||||
* @param messageWindow
|
||||
*/
|
||||
public static void showPendingMeassage(int AD_User_ID, IBroadcastMsgPopup messageWindow) {
|
||||
StringBuilder sql = new StringBuilder("SELECT bm.AD_BroadcastMessage_ID ")
|
||||
.append(" FROM AD_Note n INNER JOIN AD_BroadcastMessage bm ON bm.AD_BroadcastMessage_ID=n.AD_BroadcastMessage_ID ")
|
||||
.append(" WHERE n.AD_User_ID = ?")
|
||||
.append(" AND (bm.BroadcastType='IL' OR bm.BroadcastType='L') ")
|
||||
.append(" AND bm.isPublished='Y' AND n.processed = 'N'")
|
||||
.append(" AND ((bm.BroadcastFrequency='U' AND bm.Expired='N' AND bm.expiration > current_timestamp) OR bm.BroadcastFrequency='J') ");
|
||||
|
||||
|
||||
ArrayList<MBroadcastMessage> mbMessages = new ArrayList<MBroadcastMessage>();
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
pstmt = DB.prepareStatement(sql.toString(),null);
|
||||
pstmt.setInt(1, AD_User_ID);
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
mbMessages.add(MBroadcastMessage.get(Env.getCtx(), rs.getInt(1)));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.SEVERE, "Broadcast messages could not be retrieved",e);
|
||||
}
|
||||
finally{
|
||||
DB.close(rs, pstmt);
|
||||
}
|
||||
if(mbMessages.size()>0){
|
||||
messageWindow.prepareMessage(mbMessages);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
|
||||
package org.idempiere.broadcast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.adempiere.model.MBroadcastMessage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Deepak Pansheriya
|
||||
*
|
||||
*/
|
||||
public interface IBroadcastMsgPopup {
|
||||
|
||||
public void prepareMessage(ArrayList<MBroadcastMessage> arrMessages);
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
|
||||
package org.idempiere.broadcast.process;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
import org.adempiere.model.MBroadcastMessage;
|
||||
import org.compiere.process.SvrProcess;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Vivek
|
||||
* @author Deepak Pansheriya
|
||||
*
|
||||
*/
|
||||
public class ExpireBrodcastMessage extends SvrProcess{
|
||||
|
||||
@Override
|
||||
protected void prepare() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doIt() throws Exception {
|
||||
MBroadcastMessage mbMessage = MBroadcastMessage.get(Env.getCtx(), getRecord_ID());
|
||||
if(mbMessage.getBroadcastFrequency().equals("U") && !mbMessage.isExpired() && mbMessage.isPublished()){
|
||||
String sql = "UPDATE AD_Note SET processed='Y' WHERE AD_BroadcastMessage_ID = ?";
|
||||
PreparedStatement pstmt = null;
|
||||
try {
|
||||
pstmt = DB.prepareStatement(sql,null);
|
||||
pstmt.setInt(1, getRecord_ID());
|
||||
pstmt.executeUpdate();
|
||||
mbMessage.setProcessed(true);
|
||||
mbMessage.setExpired(true);
|
||||
} catch (Exception e) {
|
||||
return "Message is not Expired";
|
||||
}finally{
|
||||
DB.close(pstmt);
|
||||
}
|
||||
mbMessage.save();
|
||||
}
|
||||
return "Expired";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.idempiere.broadcast.process;
|
||||
|
||||
import org.idempiere.broadcast.BroadcastMsgUtil;
|
||||
import org.compiere.process.SvrProcess;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Vivek
|
||||
* @author Deepak Pansheriya
|
||||
*
|
||||
*/
|
||||
public class PublishBrodcastMessage extends SvrProcess
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void prepare()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doIt() throws Exception{
|
||||
BroadcastMsgUtil.publishBroadcastMessage(getRecord_ID(), get_TrxName());
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.idempiere.broadcast.process;
|
||||
|
||||
import org.idempiere.broadcast.BroadcastMsgUtil;
|
||||
import org.compiere.process.SvrProcess;
|
||||
import org.compiere.util.Env;
|
||||
/**
|
||||
*
|
||||
* @author Vivek
|
||||
* @author Deepak Pansheriya
|
||||
*
|
||||
*/
|
||||
public class TestBrodcastMessage extends SvrProcess
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void prepare()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doIt() throws Exception
|
||||
{
|
||||
int AD_Session_ID = Env.getContextAsInt(getCtx(), "AD_Session_ID");
|
||||
BroadcastMsgUtil.testBroadcastMessage(getRecord_ID(), AD_Session_ID);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -12,6 +12,7 @@ Import-Package: javax.servlet,
|
|||
org.apache.ecs.xhtml,
|
||||
org.compiere.css,
|
||||
org.osgi.framework;version="1.5.0",
|
||||
org.osgi.service.event;version="1.3.0",
|
||||
org.slf4j;version="1.6.1",
|
||||
org.slf4j.helpers;version="1.6.1",
|
||||
org.slf4j.spi;version="1.6.1"
|
||||
|
|
|
@ -40,6 +40,10 @@ import org.zkoss.zul.Vbox;
|
|||
*
|
||||
* Contributors:
|
||||
* CarlosRuiz - globalqss - Add unprocessed button to iDempiere
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* Deepak Pansheriya - showing only notes message
|
||||
*/
|
||||
public class DPActivities extends DashboardPanel implements EventListener<Event> {
|
||||
/**
|
||||
|
@ -123,7 +127,7 @@ public class DPActivities extends DashboardPanel implements EventListener<Event>
|
|||
{
|
||||
String sql = "SELECT COUNT(1) FROM AD_Note "
|
||||
+ "WHERE AD_Client_ID=? AND AD_User_ID IN (0,?)"
|
||||
+ " AND Processed='N'";
|
||||
+ " AND Processed='N' AND AD_BroadcastMessage_ID IS NULL";
|
||||
|
||||
int retValue = DB.getSQLValue(null, sql, Env.getAD_Client_ID(Env.getCtx()), Env.getAD_User_ID(Env.getCtx()));
|
||||
return retValue;
|
||||
|
|
|
@ -20,6 +20,10 @@ package org.adempiere.webui.desktop;
|
|||
import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.adempiere.base.event.EventManager;
|
||||
import org.adempiere.base.event.IEventManager;
|
||||
import org.adempiere.base.event.IEventTopics;
|
||||
import org.adempiere.model.MBroadcastMessage;
|
||||
import org.adempiere.util.ServerContext;
|
||||
import org.adempiere.webui.LayoutUtils;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
|
@ -28,6 +32,8 @@ import org.adempiere.webui.component.Tabpanel;
|
|||
import org.adempiere.webui.component.ToolBarButton;
|
||||
import org.adempiere.webui.dashboard.DPActivities;
|
||||
import org.adempiere.webui.event.MenuListener;
|
||||
import org.adempiere.webui.event.ZKBroadCastManager;
|
||||
import org.adempiere.webui.panel.BroadcastMessageWindow;
|
||||
import org.adempiere.webui.panel.HeaderPanel;
|
||||
import org.adempiere.webui.session.SessionContextListener;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
|
@ -39,14 +45,21 @@ import org.compiere.util.CLogger;
|
|||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Util;
|
||||
import org.idempiere.broadcast.BroadCastMsg;
|
||||
import org.idempiere.broadcast.BroadCastUtil;
|
||||
import org.idempiere.broadcast.BroadcastMsgUtil;
|
||||
import org.osgi.service.event.EventHandler;
|
||||
import org.zkoss.zk.au.out.AuScript;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Desktop;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.Page;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zk.ui.event.OpenEvent;
|
||||
import org.zkoss.zk.ui.util.Clients;
|
||||
import org.zkoss.zk.ui.util.DesktopCleanup;
|
||||
import org.zkoss.zul.Borderlayout;
|
||||
import org.zkoss.zul.Center;
|
||||
import org.zkoss.zul.North;
|
||||
|
@ -59,8 +72,9 @@ import org.zkoss.zul.West;
|
|||
* @author <a href="mailto:hengsin@gmail.com">Low Heng Sin</a>
|
||||
* @date Mar 2, 2007
|
||||
* @version $Revision: 0.10 $
|
||||
* @author Deepak Pansheriya/Vivek - Adding support for message broadcasting
|
||||
*/
|
||||
public class DefaultDesktop extends TabbedDesktop implements MenuListener, Serializable, EventListener<Event>, IServerPushCallback
|
||||
public class DefaultDesktop extends TabbedDesktop implements MenuListener, Serializable, EventListener<Event>, IServerPushCallback,EventHandler,DesktopCleanup
|
||||
{
|
||||
/**
|
||||
* generated serial version ID
|
||||
|
@ -86,16 +100,27 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
|||
|
||||
private DashboardController dashboardController, sideController;
|
||||
|
||||
private BroadcastMessageWindow messageWindow;
|
||||
private BroadcastMessageWindow testMessageWindow;
|
||||
private HeaderPanel pnlHead;
|
||||
|
||||
private Desktop m_desktop = null;
|
||||
public DefaultDesktop()
|
||||
{
|
||||
super();
|
||||
dashboardController = new DashboardController();
|
||||
sideController = new DashboardController();
|
||||
|
||||
m_desktop = AEnv.getDesktop();
|
||||
m_desktop.addListener(this);
|
||||
//subscribing to broadcast event
|
||||
bindEventManager();
|
||||
ZKBroadCastManager.getBroadCastMgr();
|
||||
}
|
||||
|
||||
protected Component doCreatePart(Component parent)
|
||||
{
|
||||
HeaderPanel pnlHead = new HeaderPanel();
|
||||
pnlHead = new HeaderPanel();
|
||||
|
||||
layout = new Borderlayout();
|
||||
if (parent != null)
|
||||
|
@ -150,6 +175,9 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
|||
busyDialog.setShadow(false);
|
||||
homeTab.appendChild(busyDialog);
|
||||
|
||||
messageWindow = new BroadcastMessageWindow(pnlHead);
|
||||
BroadcastMsgUtil.showPendingMeassage(Env.getAD_User_ID(Env.getCtx()), messageWindow);
|
||||
|
||||
if (!layout.getDesktop().isServerPushEnabled())
|
||||
{
|
||||
layout.getDesktop().enableServerPush(true);
|
||||
|
@ -251,6 +279,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
|||
}
|
||||
|
||||
public void logout() {
|
||||
unbindEventManager();
|
||||
if (dashboardController != null) {
|
||||
dashboardController.onLogOut();
|
||||
}
|
||||
|
@ -287,4 +316,62 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
|||
{
|
||||
autoHideMenu();
|
||||
}
|
||||
|
||||
//Implementation for Broadcast message
|
||||
/**
|
||||
* @param eventManager
|
||||
*/
|
||||
public void bindEventManager() {
|
||||
EventManager.getInstance().register(IEventTopics.BROADCAST_MESSAGE, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param eventManager
|
||||
*/
|
||||
public void unbindEventManager() {
|
||||
EventManager.getInstance().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(final org.osgi.service.event.Event event) {
|
||||
String eventName = event.getTopic();
|
||||
if (eventName.equals(IEventTopics.BROADCAST_MESSAGE)) {
|
||||
EventListener<Event> listner = new EventListener<Event>(){
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
BroadCastMsg msg = (BroadCastMsg) event.getData();
|
||||
MBroadcastMessage mbMessage = MBroadcastMessage.get(
|
||||
Env.getCtx(), msg.getMessageId());
|
||||
if (msg.getEventId() == BroadCastUtil.EVENT_TEST_BROADCAST_MESSAGE) {
|
||||
|
||||
String currSession = Integer
|
||||
.toString(Env.getContextAsInt(Env.getCtx(),
|
||||
"AD_Session_ID"));
|
||||
if (currSession.equals(msg.getTargetNode())) {
|
||||
if (testMessageWindow == null)
|
||||
testMessageWindow = new BroadcastMessageWindow(
|
||||
pnlHead);
|
||||
testMessageWindow.appendMessage(mbMessage, true);
|
||||
testMessageWindow = null;
|
||||
|
||||
}
|
||||
} else if (mbMessage.isValidUserforMessage()) {
|
||||
if (messageWindow == null)
|
||||
messageWindow = new BroadcastMessageWindow(pnlHead);
|
||||
messageWindow.appendMessage(mbMessage, false);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
Executions.schedule(m_desktop, listner, new Event("OnBroadcast", null, event.getProperty(IEventManager.EVENT_DATA)));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup(Desktop desktop) throws Exception {
|
||||
unbindEventManager();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
|
||||
package org.adempiere.webui.event;
|
||||
|
||||
import org.adempiere.base.event.EventManager;
|
||||
import org.adempiere.base.event.IEventTopics;
|
||||
import org.compiere.util.WebUtil;
|
||||
import org.idempiere.broadcast.BroadCastMsg;
|
||||
import org.idempiere.broadcast.BroadCastUtil;
|
||||
import org.idempiere.broadcast.BroadcastMsgUtil;
|
||||
import org.idempiere.distributed.ITopicSubscriber;
|
||||
import org.osgi.service.event.EventHandler;
|
||||
/**
|
||||
* Class Manages Broadcast Messages across webui cluster
|
||||
* @author Deepak Pansheriya
|
||||
*
|
||||
*/
|
||||
public class ZKBroadCastManager implements ITopicSubscriber<BroadCastMsg>,EventHandler{
|
||||
|
||||
private static ZKBroadCastManager broadCastMgr = null;
|
||||
|
||||
public static ZKBroadCastManager getBroadCastMgr() {
|
||||
|
||||
synchronized (ZKBroadCastManager.class) {
|
||||
if(broadCastMgr==null)
|
||||
broadCastMgr= new ZKBroadCastManager();
|
||||
|
||||
}
|
||||
return broadCastMgr;
|
||||
}
|
||||
|
||||
private ZKBroadCastManager(){
|
||||
EventManager.getInstance().register(IEventTopics.BROADCAST_MESSAGE, this);
|
||||
BroadCastUtil.subscribe(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* MessageService event
|
||||
*/
|
||||
@Override
|
||||
public void onMessage(BroadCastMsg message) {
|
||||
|
||||
if(!WebUtil.getServerName().equalsIgnoreCase(message.getSrc())){
|
||||
switch(message.getEventId()){
|
||||
case BroadCastUtil.EVENT_BROADCAST_MESSAGE:
|
||||
message.setFromCluster(true);
|
||||
BroadcastMsgUtil.pushToQueue(message);
|
||||
break;
|
||||
case BroadCastUtil.EVENT_SESSION_TIMEOUT:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* OSGI Event Handler
|
||||
*/
|
||||
@Override
|
||||
public void handleEvent(org.osgi.service.event.Event event) {
|
||||
BroadCastMsg msg = (BroadCastMsg) event
|
||||
.getProperty(EventManager.EVENT_DATA);
|
||||
// Avoid loop
|
||||
if (msg.isFromCluster())
|
||||
return;
|
||||
if (msg.getEventId() == BroadCastUtil.EVENT_BROADCAST_MESSAGE) {
|
||||
msg.setSrc(WebUtil.getServerName());
|
||||
msg.setEventId(BroadCastUtil.EVENT_BROADCAST_MESSAGE);
|
||||
BroadCastUtil.publish(msg);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,364 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui.panel;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.model.MBroadcastMessage;
|
||||
import org.adempiere.webui.component.Button;
|
||||
import org.adempiere.webui.component.Checkbox;
|
||||
import org.adempiere.webui.component.Label;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.compiere.model.MNote;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.idempiere.broadcast.IBroadcastMsgPopup;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zul.Borderlayout;
|
||||
import org.zkoss.zul.Cell;
|
||||
import org.zkoss.zul.Center;
|
||||
import org.zkoss.zul.Div;
|
||||
import org.zkoss.zul.Hbox;
|
||||
import org.zkoss.zul.Html;
|
||||
import org.zkoss.zul.North;
|
||||
import org.zkoss.zul.Separator;
|
||||
import org.zkoss.zul.South;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Vivek
|
||||
* @author Deepak Pansheriya
|
||||
*
|
||||
*/
|
||||
public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup,EventListener<Event>{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 5990080817061314383L;
|
||||
private static CLogger log = CLogger.getCLogger(BroadcastMessageWindow.class);
|
||||
public static final int PRESSED_PREV = 1;
|
||||
public static final int PRESSED_NEXT = 2;
|
||||
public static final int UPDATE_CurrMsg = 0;
|
||||
|
||||
private int currMsg=0;
|
||||
private Label textMsgNo = null;
|
||||
private Html textMsgContent = null;
|
||||
private North north =null;
|
||||
private Div swDiv =null;
|
||||
private Div sDiv = null;
|
||||
private Button btnPrev = null;
|
||||
private Button btnNext = null;
|
||||
private Checkbox acknowledged = null;
|
||||
private ArrayList<MBroadcastMessage> mbMessages = null;
|
||||
private Hashtable<Integer, Boolean> hashMessages = new Hashtable<Integer, Boolean>();
|
||||
private HeaderPanel pnlHead = null;
|
||||
private boolean isTest = false;
|
||||
private boolean initialised = false;
|
||||
/*public BroadcastMessageWindow(){
|
||||
//init();
|
||||
}*/
|
||||
|
||||
public BroadcastMessageWindow(HeaderPanel pnlHead) {
|
||||
this.pnlHead = pnlHead;
|
||||
textMsgNo = new Label();
|
||||
textMsgContent = new Html();
|
||||
textMsgContent.setStyle("color:black;");
|
||||
btnPrev = new Button("<");
|
||||
btnNext = new Button(">");
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setTitle("Message");
|
||||
Borderlayout layout = new Borderlayout();
|
||||
this.appendChild(layout);
|
||||
addEventListener("onFocus", this);
|
||||
initialised = true;
|
||||
|
||||
setWidth("30%");
|
||||
setHeight("30%");
|
||||
setPosition("right,bottom");
|
||||
setBorder(true);
|
||||
setShadow(false);
|
||||
doOverlapped();
|
||||
setClosable(true);
|
||||
|
||||
north = new North();
|
||||
layout.appendChild(north);
|
||||
|
||||
Center center = new Center();
|
||||
layout.appendChild(center);
|
||||
Div htmlDiv = new Div();
|
||||
//textMsgContent = new Label();
|
||||
htmlDiv.appendChild(textMsgContent);
|
||||
textMsgContent.setContent(mbMessages.get(0).getBroadcastMessage());
|
||||
htmlDiv.setFocus(true);
|
||||
htmlDiv.setStyle("display: table-cell; vertical-align: middle; text-align: center;");
|
||||
Div divAlign = new Div();
|
||||
divAlign.setStyle("color:white; position: absolute; width: 370px; height: 120px; display: table;");
|
||||
htmlDiv.setParent(divAlign);
|
||||
center.appendChild(divAlign);
|
||||
center.setBorder("rounded");
|
||||
center.setStyle("-moz-border-radius: 3px; -webkit-border-radius: 3px; border: 1px solid #BBBBBB; border-radius: 3px; margin-bottom:10px;");
|
||||
|
||||
South south = new South();
|
||||
layout.appendChild(south);
|
||||
Hbox southHLayout = new Hbox();
|
||||
south.appendChild(southHLayout);
|
||||
southHLayout.setSpacing("30");
|
||||
southHLayout.setWidth("350px");
|
||||
|
||||
Cell leftCell = new Cell();
|
||||
southHLayout.appendChild(leftCell);
|
||||
leftCell.setHflex("1");
|
||||
//leftCell.setWidth("30%");
|
||||
leftCell.setAlign("left");
|
||||
swDiv = new Div();
|
||||
swDiv.setParent(leftCell);
|
||||
acknowledged = new Checkbox();
|
||||
|
||||
Cell rightCell = new Cell();
|
||||
southHLayout.appendChild(rightCell);
|
||||
rightCell.setAlign("right");
|
||||
rightCell.setHflex("2");
|
||||
sDiv = new Div();
|
||||
sDiv.setWidth("70px");
|
||||
rightCell.appendChild(sDiv);
|
||||
|
||||
|
||||
//createHashTable();
|
||||
currMsg = 0;
|
||||
//btnPrev = new Button("<");
|
||||
btnPrev.addEventListener("onClick", this);
|
||||
//textMsgNo = new Label();
|
||||
//textMsgNo.setValue((currMsg+1)+"/"+noOfMsgs);
|
||||
btnNext = new Button(">");
|
||||
btnNext.addEventListener("onClick", this);
|
||||
|
||||
swDiv.appendChild(btnPrev);
|
||||
swDiv.appendChild(new Separator("vertical"));
|
||||
swDiv.appendChild(textMsgNo);
|
||||
swDiv.appendChild(new Separator("vertical"));
|
||||
swDiv.appendChild(btnNext);
|
||||
textMsgNo.setStyle("font-weight:bold;");
|
||||
|
||||
renderMsg(UPDATE_CurrMsg);
|
||||
|
||||
if(mbMessages.size()<=0)
|
||||
swDiv.setVisible(false);
|
||||
|
||||
south.setHeight("22%");
|
||||
//south.setWidth("45%");
|
||||
acknowledged.setParent(rightCell);
|
||||
acknowledged.setVisible(false);
|
||||
//acknowledged.setHflex("6");
|
||||
acknowledged.setLabel("Acknowledge");
|
||||
acknowledged.addEventListener("onClick", this);
|
||||
|
||||
}
|
||||
|
||||
private void createHashTable() {
|
||||
hashMessages.clear();
|
||||
for(int i=0; i<mbMessages.size(); i++){
|
||||
if(!mbMessages.get(i).getBroadcastType().equals(MBroadcastMessage.BROADCASTTYPE_Immediate)){
|
||||
MNote note = getMNote(mbMessages.get(i));
|
||||
hashMessages.put(mbMessages.get(i).get_ID(), note.isProcessed());
|
||||
}else{
|
||||
hashMessages.put(mbMessages.get(i).get_ID(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void prepareMessage(ArrayList<MBroadcastMessage> arrMessages){
|
||||
mbMessages = arrMessages;
|
||||
createHashTable();
|
||||
if(!initialised)
|
||||
init();
|
||||
pnlHead.appendChild(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append message to existing message list
|
||||
* @param mbMessage
|
||||
* @param isTest
|
||||
*/
|
||||
public void appendMessage(MBroadcastMessage mbMessage, boolean isTest){
|
||||
this.isTest = isTest;
|
||||
currMsg = 0;
|
||||
if(mbMessages!=null && isTest){
|
||||
mbMessages.clear();
|
||||
}else if(mbMessages == null){
|
||||
mbMessages = new ArrayList<MBroadcastMessage>();
|
||||
}
|
||||
|
||||
mbMessages.add(0, mbMessage);
|
||||
if(!isTest)
|
||||
createHashTable();
|
||||
|
||||
if(!initialised)
|
||||
init();
|
||||
else if(!isTest){
|
||||
currMsg=0;
|
||||
renderMsg(UPDATE_CurrMsg);
|
||||
}
|
||||
|
||||
pnlHead.appendChild(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
Component comp = event.getTarget();
|
||||
int noOfMsgs = mbMessages.size();
|
||||
|
||||
if(event.getName().equals(Events.ON_CLICK)){
|
||||
if(comp == btnPrev){
|
||||
if(currMsg > 0){
|
||||
currMsg--;
|
||||
renderMsg(PRESSED_PREV);
|
||||
}
|
||||
}else if (comp == btnNext){
|
||||
if(currMsg < noOfMsgs-1){
|
||||
currMsg++;
|
||||
renderMsg(PRESSED_NEXT);
|
||||
}
|
||||
}else if(comp == acknowledged){
|
||||
hashMessages.put(mbMessages.get(currMsg).get_ID(), acknowledged.isChecked());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update message on window
|
||||
* @param status
|
||||
*/
|
||||
public void renderMsg(int status) {
|
||||
int msgToUpdate = currMsg-1;
|
||||
if(status == PRESSED_NEXT){
|
||||
msgToUpdate = currMsg-1;
|
||||
}else if(status == PRESSED_PREV){
|
||||
msgToUpdate = currMsg+1;
|
||||
}else if(status == UPDATE_CurrMsg){
|
||||
msgToUpdate = currMsg;
|
||||
}
|
||||
|
||||
int noOfMsgs = mbMessages.size();
|
||||
MBroadcastMessage mbMessage = mbMessages.get(currMsg);
|
||||
String broadcastFrequency = mbMessage.getBroadcastFrequency();
|
||||
|
||||
if(mbMessages.size()>1)
|
||||
swDiv.setVisible(true);
|
||||
else
|
||||
swDiv.setVisible(false);
|
||||
|
||||
if (noOfMsgs > 1) {
|
||||
btnNext.setEnabled(true);
|
||||
btnPrev.setEnabled(true);
|
||||
MBroadcastMessage prevMsg = mbMessages.get(msgToUpdate);
|
||||
if((prevMsg.getBroadcastFrequency().equals("J")
|
||||
|| prevMsg.getBroadcastType().equals(MBroadcastMessage.BROADCASTTYPE_Immediate))){
|
||||
hashMessages.put(prevMsg.get_ID(), true);
|
||||
}
|
||||
|
||||
if (currMsg == 0) {
|
||||
btnPrev.setEnabled(false);
|
||||
} else if (currMsg == noOfMsgs - 1) {
|
||||
if ((broadcastFrequency.equals("J"))
|
||||
|| (mbMessage.getBroadcastType().equals(MBroadcastMessage.BROADCASTTYPE_Immediate))) {
|
||||
hashMessages.put(mbMessage.get_ID(), true);
|
||||
}
|
||||
btnNext.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
textMsgNo.setValue((currMsg+1)+"/"+noOfMsgs);
|
||||
textMsgContent.setContent(mbMessage.getBroadcastMessage());
|
||||
|
||||
if(!isTest && mbMessage.isLogAcknowledge() && broadcastFrequency.equals(MBroadcastMessage.BROADCASTFREQUENCY_UntilExpiration)){
|
||||
boolean ack = hashMessages.get(mbMessage.get_ID());
|
||||
acknowledged.setChecked(ack);
|
||||
acknowledged.setVisible(true);
|
||||
}else if((broadcastFrequency.equals("J"))
|
||||
|| (mbMessage.getBroadcastType().equals(MBroadcastMessage.BROADCASTTYPE_Immediate))){
|
||||
acknowledged.setVisible(false);
|
||||
hashMessages.put(mbMessages.get(currMsg).get_ID(), true);
|
||||
}else{
|
||||
acknowledged.setVisible(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get AD Note entries for current login user for provided message
|
||||
* @param mbMessage
|
||||
* @return
|
||||
*/
|
||||
public MNote getMNote(MBroadcastMessage mbMessage) {
|
||||
String sql = "SELECT * FROM AD_Note WHERE AD_BroadcastMessage_ID = ? AND AD_User_ID = ?";
|
||||
MNote note =null;
|
||||
if(!mbMessage.getBroadcastType().equals(MBroadcastMessage.BROADCASTTYPE_Immediate)){
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs=null;
|
||||
try {
|
||||
pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, mbMessage.get_ID());
|
||||
pstmt.setInt(2, Env.getAD_User_ID(Env.getCtx()));
|
||||
rs = pstmt.executeQuery();
|
||||
if(rs.next())
|
||||
note = new MNote(Env.getCtx(), rs, null);
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Note for the Mesaage Could not be retrieved ",e);
|
||||
}finally{
|
||||
DB.close(rs, pstmt);
|
||||
}
|
||||
}
|
||||
return note;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose() {
|
||||
super.onClose();
|
||||
if (!isTest) {
|
||||
if(mbMessages.size()==1){
|
||||
if ((mbMessages.get(0).getBroadcastFrequency().equals("J"))
|
||||
|| (mbMessages.get(0).getBroadcastType().equals(MBroadcastMessage.BROADCASTTYPE_Immediate))) {
|
||||
hashMessages.put(mbMessages.get(0).get_ID(), true);
|
||||
}
|
||||
}
|
||||
ArrayList<MBroadcastMessage> acknowedgedMsgs = new ArrayList<MBroadcastMessage>();
|
||||
for (MBroadcastMessage mbMessage : mbMessages) {
|
||||
if(!mbMessage.getBroadcastType().equals(MBroadcastMessage.BROADCASTTYPE_Immediate)){
|
||||
MNote note = getMNote(mbMessage);
|
||||
note.setProcessed(hashMessages.get(mbMessage.get_ID()));
|
||||
if(hashMessages.get(mbMessage.get_ID())){
|
||||
acknowedgedMsgs.add(mbMessage);
|
||||
}
|
||||
note.save();
|
||||
}else{
|
||||
acknowedgedMsgs.add(mbMessage);
|
||||
}
|
||||
}
|
||||
for (MBroadcastMessage mBroadcastMessage : acknowedgedMsgs) {
|
||||
mbMessages.remove(mBroadcastMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue