IDEMPIERE-294 BroadCast Message / Peer review
This commit is contained in:
parent
f992cef2d7
commit
2de5900c6c
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -70,17 +70,17 @@ public class MBroadcastMessage extends X_AD_BroadcastMessage
|
||||||
{
|
{
|
||||||
Properties ctx = Env.getCtx();
|
Properties ctx = Env.getCtx();
|
||||||
|
|
||||||
if(getBroadcastType()!=null && getBroadcastType().equals("I") && getTarget()!=null){
|
if(getBroadcastType()!=null && getBroadcastType().equals(BROADCASTTYPE_Immediate) && getTarget()!=null){
|
||||||
if (getTarget().equals("R") ) {
|
if (getTarget().equals(TARGET_Role) ) {
|
||||||
String SQL = "select count(*) from ad_user_roles where ad_role_id = ? and ad_User_ID=?";
|
String sql = "SELECT COUNT(*) FROM AD_User_Roles WHERE AD_Role_ID = ? AND AD_User_ID=? AND IsActive='Y'";
|
||||||
int roleSubs = DB.getSQLValue(null, SQL, getAD_Role_ID(),Env.getAD_User_ID(ctx));
|
int roleSubs = DB.getSQLValue(null, sql, getAD_Role_ID(),Env.getAD_User_ID(ctx));
|
||||||
if(roleSubs>0)
|
if(roleSubs>0)
|
||||||
return true;
|
return true;
|
||||||
} else if (getTarget().equals("U") && getAD_User_ID() == Env.getAD_User_ID(ctx)) {
|
} else if (getTarget().equals(TARGET_User) && getAD_User_ID() == Env.getAD_User_ID(ctx)) {
|
||||||
return true;
|
return true;
|
||||||
} else if (getTarget().equals("C") && getAD_Client_ID() == Env.getAD_Client_ID(ctx)) {
|
} else if (getTarget().equals(TARGET_Client) && getAD_Client_ID() == Env.getAD_Client_ID(ctx)) {
|
||||||
return true;
|
return true;
|
||||||
}else if (getTarget().equals("E")){
|
}else if (getTarget().equals(TARGET_Everybody)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ public class MBroadcastMessage extends X_AD_BroadcastMessage
|
||||||
|
|
||||||
int AD_User_ID = Env.getAD_User_ID(ctx);
|
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 = ? ";
|
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);
|
int result = DB.getSQLValue(null, sql,getAD_BroadcastMessage_ID(),AD_User_ID);
|
||||||
if (result <= 0) {
|
if (result <= 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||||
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
|
* Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved. *
|
||||||
* This program is free software, you can redistribute it and/or modify it *
|
* 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 *
|
* 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 *
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
@ -21,8 +21,8 @@ import java.sql.Timestamp;
|
||||||
import org.compiere.util.KeyNamePair;
|
import org.compiere.util.KeyNamePair;
|
||||||
|
|
||||||
/** Generated Interface for AD_BroadcastMessage
|
/** Generated Interface for AD_BroadcastMessage
|
||||||
* @author Adempiere (generated)
|
* @author iDempiere (generated)
|
||||||
* @version Release 3.6.0LTS
|
* @version Release 1.0a
|
||||||
*/
|
*/
|
||||||
public interface I_AD_BroadcastMessage
|
public interface I_AD_BroadcastMessage
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@ public interface I_AD_BroadcastMessage
|
||||||
/** TableName=AD_BroadcastMessage */
|
/** TableName=AD_BroadcastMessage */
|
||||||
public static final String Table_Name = "AD_BroadcastMessage";
|
public static final String Table_Name = "AD_BroadcastMessage";
|
||||||
|
|
||||||
/** AD_Table_ID=200024 */
|
/** AD_Table_ID=200038 */
|
||||||
public static final int Table_ID = 200038;
|
public static final int Table_ID = 200038;
|
||||||
|
|
||||||
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
|
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
|
||||||
|
@ -41,18 +41,27 @@ public interface I_AD_BroadcastMessage
|
||||||
|
|
||||||
/** Load Meta Data */
|
/** Load Meta Data */
|
||||||
|
|
||||||
/** Column name AD_Broadcastmessage_ID */
|
/** Column name AD_BroadcastMessage_ID */
|
||||||
public static final String COLUMNNAME_AD_Broadcastmessage_ID = "AD_Broadcastmessage_ID";
|
public static final String COLUMNNAME_AD_BroadcastMessage_ID = "AD_BroadcastMessage_ID";
|
||||||
|
|
||||||
/** Set Broadcast Message.
|
/** Set Broadcast Message.
|
||||||
* Broadcast Message
|
* Broadcast Message
|
||||||
*/
|
*/
|
||||||
public void setAD_Broadcastmessage_ID (int AD_Broadcastmessage_ID);
|
public void setAD_BroadcastMessage_ID (int AD_BroadcastMessage_ID);
|
||||||
|
|
||||||
/** Get Broadcast Message.
|
/** Get Broadcast Message.
|
||||||
* Broadcast Message
|
* Broadcast Message
|
||||||
*/
|
*/
|
||||||
public int getAD_Broadcastmessage_ID();
|
public int getAD_BroadcastMessage_ID();
|
||||||
|
|
||||||
|
/** Column name AD_BroadcastMessage_UU */
|
||||||
|
public static final String COLUMNNAME_AD_BroadcastMessage_UU = "AD_BroadcastMessage_UU";
|
||||||
|
|
||||||
|
/** Set AD_BroadcastMessage_UU */
|
||||||
|
public void setAD_BroadcastMessage_UU (String AD_BroadcastMessage_UU);
|
||||||
|
|
||||||
|
/** Get AD_BroadcastMessage_UU */
|
||||||
|
public String getAD_BroadcastMessage_UU();
|
||||||
|
|
||||||
/** Column name AD_Client_ID */
|
/** Column name AD_Client_ID */
|
||||||
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
|
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
|
||||||
|
@ -163,13 +172,13 @@ public interface I_AD_BroadcastMessage
|
||||||
/** Column name Expiration */
|
/** Column name Expiration */
|
||||||
public static final String COLUMNNAME_Expiration = "Expiration";
|
public static final String COLUMNNAME_Expiration = "Expiration";
|
||||||
|
|
||||||
/** Set Expiration.
|
/** Set Expire On.
|
||||||
* Expiration
|
* Expire On
|
||||||
*/
|
*/
|
||||||
public void setExpiration (Timestamp Expiration);
|
public void setExpiration (Timestamp Expiration);
|
||||||
|
|
||||||
/** Get Expiration.
|
/** Get Expire On.
|
||||||
* Expiration
|
* Expire On
|
||||||
*/
|
*/
|
||||||
public Timestamp getExpiration();
|
public Timestamp getExpiration();
|
||||||
|
|
||||||
|
@ -234,14 +243,18 @@ public interface I_AD_BroadcastMessage
|
||||||
*/
|
*/
|
||||||
public boolean isLogAcknowledge();
|
public boolean isLogAcknowledge();
|
||||||
|
|
||||||
/** Column name Notification_Client */
|
/** Column name Notification_Client_ID */
|
||||||
public static final String COLUMNNAME_Notification_Client = "Notification_Client";
|
public static final String COLUMNNAME_Notification_Client_ID = "Notification_Client_ID";
|
||||||
|
|
||||||
/** Set Notification_Client */
|
/** Set Notification Client.
|
||||||
public void setNotification_Client (int Notification_Client);
|
* Notification Client
|
||||||
|
*/
|
||||||
|
public void setNotification_Client_ID (int Notification_Client_ID);
|
||||||
|
|
||||||
/** Get Notification_Client */
|
/** Get Notification Client.
|
||||||
public int getNotification_Client();
|
* Notification Client
|
||||||
|
*/
|
||||||
|
public int getNotification_Client_ID();
|
||||||
|
|
||||||
/** Column name Processed */
|
/** Column name Processed */
|
||||||
public static final String COLUMNNAME_Processed = "Processed";
|
public static final String COLUMNNAME_Processed = "Processed";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||||
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
|
* Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved. *
|
||||||
* This program is free software, you can redistribute it and/or modify it *
|
* 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 *
|
* 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 *
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
@ -22,15 +22,15 @@ import java.sql.Timestamp;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
/** Generated Model for AD_BroadcastMessage
|
/** Generated Model for AD_BroadcastMessage
|
||||||
* @author Adempiere (generated)
|
* @author iDempiere (generated)
|
||||||
* @version Release 3.6.0LTS - $Id$ */
|
* @version Release 1.0a - $Id$ */
|
||||||
public class X_AD_BroadcastMessage extends PO implements I_AD_BroadcastMessage, I_Persistent
|
public class X_AD_BroadcastMessage extends PO implements I_AD_BroadcastMessage, I_Persistent
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 20121107L;
|
private static final long serialVersionUID = 20121202L;
|
||||||
|
|
||||||
/** Standard Constructor */
|
/** Standard Constructor */
|
||||||
public X_AD_BroadcastMessage (Properties ctx, int AD_BroadcastMessage_ID, String trxName)
|
public X_AD_BroadcastMessage (Properties ctx, int AD_BroadcastMessage_ID, String trxName)
|
||||||
|
@ -38,6 +38,11 @@ public class X_AD_BroadcastMessage extends PO implements I_AD_BroadcastMessage,
|
||||||
super (ctx, AD_BroadcastMessage_ID, trxName);
|
super (ctx, AD_BroadcastMessage_ID, trxName);
|
||||||
/** if (AD_BroadcastMessage_ID == 0)
|
/** if (AD_BroadcastMessage_ID == 0)
|
||||||
{
|
{
|
||||||
|
setAD_BroadcastMessage_ID (0);
|
||||||
|
setBroadcastFrequency (null);
|
||||||
|
setBroadcastMessage (null);
|
||||||
|
setBroadcastType (null);
|
||||||
|
setTarget (null);
|
||||||
} */
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,28 +75,42 @@ public class X_AD_BroadcastMessage extends PO implements I_AD_BroadcastMessage,
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set Broadcast Message.
|
/** Set Broadcast Message.
|
||||||
@param AD_Broadcastmessage_ID
|
@param AD_BroadcastMessage_ID
|
||||||
Broadcast Message
|
Broadcast Message
|
||||||
*/
|
*/
|
||||||
public void setAD_Broadcastmessage_ID (int AD_Broadcastmessage_ID)
|
public void setAD_BroadcastMessage_ID (int AD_BroadcastMessage_ID)
|
||||||
{
|
{
|
||||||
if (AD_Broadcastmessage_ID < 1)
|
if (AD_BroadcastMessage_ID < 1)
|
||||||
set_ValueNoCheck (COLUMNNAME_AD_Broadcastmessage_ID, null);
|
set_ValueNoCheck (COLUMNNAME_AD_BroadcastMessage_ID, null);
|
||||||
else
|
else
|
||||||
set_ValueNoCheck (COLUMNNAME_AD_Broadcastmessage_ID, Integer.valueOf(AD_Broadcastmessage_ID));
|
set_ValueNoCheck (COLUMNNAME_AD_BroadcastMessage_ID, Integer.valueOf(AD_BroadcastMessage_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get Broadcast Message.
|
/** Get Broadcast Message.
|
||||||
@return Broadcast Message
|
@return Broadcast Message
|
||||||
*/
|
*/
|
||||||
public int getAD_Broadcastmessage_ID ()
|
public int getAD_BroadcastMessage_ID ()
|
||||||
{
|
{
|
||||||
Integer ii = (Integer)get_Value(COLUMNNAME_AD_Broadcastmessage_ID);
|
Integer ii = (Integer)get_Value(COLUMNNAME_AD_BroadcastMessage_ID);
|
||||||
if (ii == null)
|
if (ii == null)
|
||||||
return 0;
|
return 0;
|
||||||
return ii.intValue();
|
return ii.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set AD_BroadcastMessage_UU.
|
||||||
|
@param AD_BroadcastMessage_UU AD_BroadcastMessage_UU */
|
||||||
|
public void setAD_BroadcastMessage_UU (String AD_BroadcastMessage_UU)
|
||||||
|
{
|
||||||
|
set_Value (COLUMNNAME_AD_BroadcastMessage_UU, AD_BroadcastMessage_UU);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get AD_BroadcastMessage_UU.
|
||||||
|
@return AD_BroadcastMessage_UU */
|
||||||
|
public String getAD_BroadcastMessage_UU ()
|
||||||
|
{
|
||||||
|
return (String)get_Value(COLUMNNAME_AD_BroadcastMessage_UU);
|
||||||
|
}
|
||||||
|
|
||||||
public org.compiere.model.I_AD_Role getAD_Role() throws RuntimeException
|
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)
|
return (org.compiere.model.I_AD_Role)MTable.get(getCtx(), org.compiere.model.I_AD_Role.Table_Name)
|
||||||
|
@ -148,8 +167,8 @@ public class X_AD_BroadcastMessage extends PO implements I_AD_BroadcastMessage,
|
||||||
return ii.intValue();
|
return ii.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** BroadcastFrequency AD_Reference_ID=200010 */
|
/** BroadcastFrequency AD_Reference_ID=200020 */
|
||||||
public static final int BROADCASTFREQUENCY_AD_Reference_ID=200010;
|
public static final int BROADCASTFREQUENCY_AD_Reference_ID=200020;
|
||||||
/** Just Once = J */
|
/** Just Once = J */
|
||||||
public static final String BROADCASTFREQUENCY_JustOnce = "J";
|
public static final String BROADCASTFREQUENCY_JustOnce = "J";
|
||||||
/** Until Expiration = U */
|
/** Until Expiration = U */
|
||||||
|
@ -189,14 +208,14 @@ public class X_AD_BroadcastMessage extends PO implements I_AD_BroadcastMessage,
|
||||||
return (String)get_Value(COLUMNNAME_BroadcastMessage);
|
return (String)get_Value(COLUMNNAME_BroadcastMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** BroadcastType AD_Reference_ID=200009 */
|
/** BroadcastType AD_Reference_ID=200021 */
|
||||||
public static final int BROADCASTTYPE_AD_Reference_ID=200009;
|
public static final int BROADCASTTYPE_AD_Reference_ID=200021;
|
||||||
/** Login = L */
|
|
||||||
public static final String BROADCASTTYPE_Login = "L";
|
|
||||||
/** Immediate = I */
|
/** Immediate = I */
|
||||||
public static final String BROADCASTTYPE_Immediate = "I";
|
public static final String BROADCASTTYPE_Immediate = "I";
|
||||||
/** Immediate + Login = IL */
|
/** Immediate + Login = IL */
|
||||||
public static final String BROADCASTTYPE_ImmediatePlusLogin = "IL";
|
public static final String BROADCASTTYPE_ImmediatePlusLogin = "IL";
|
||||||
|
/** Login = L */
|
||||||
|
public static final String BROADCASTTYPE_Login = "L";
|
||||||
/** Set Broadcast Type.
|
/** Set Broadcast Type.
|
||||||
@param BroadcastType
|
@param BroadcastType
|
||||||
Type of Broadcast
|
Type of Broadcast
|
||||||
|
@ -215,17 +234,17 @@ public class X_AD_BroadcastMessage extends PO implements I_AD_BroadcastMessage,
|
||||||
return (String)get_Value(COLUMNNAME_BroadcastType);
|
return (String)get_Value(COLUMNNAME_BroadcastType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set Expiration.
|
/** Set Expire On.
|
||||||
@param Expiration
|
@param Expiration
|
||||||
Expiration
|
Expire On
|
||||||
*/
|
*/
|
||||||
public void setExpiration (Timestamp Expiration)
|
public void setExpiration (Timestamp Expiration)
|
||||||
{
|
{
|
||||||
set_Value (COLUMNNAME_Expiration, Expiration);
|
set_Value (COLUMNNAME_Expiration, Expiration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get Expiration.
|
/** Get Expire On.
|
||||||
@return Expiration
|
@return Expire On
|
||||||
*/
|
*/
|
||||||
public Timestamp getExpiration ()
|
public Timestamp getExpiration ()
|
||||||
{
|
{
|
||||||
|
@ -318,18 +337,24 @@ public class X_AD_BroadcastMessage extends PO implements I_AD_BroadcastMessage,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set Notification_Client.
|
/** Set Notification Client.
|
||||||
@param Notification_Client Notification_Client */
|
@param Notification_Client_ID
|
||||||
public void setNotification_Client (int Notification_Client)
|
Notification Client
|
||||||
|
*/
|
||||||
|
public void setNotification_Client_ID (int Notification_Client_ID)
|
||||||
{
|
{
|
||||||
set_Value (COLUMNNAME_Notification_Client, Integer.valueOf(Notification_Client));
|
if (Notification_Client_ID < 1)
|
||||||
|
set_Value (COLUMNNAME_Notification_Client_ID, null);
|
||||||
|
else
|
||||||
|
set_Value (COLUMNNAME_Notification_Client_ID, Integer.valueOf(Notification_Client_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get Notification_Client.
|
/** Get Notification Client.
|
||||||
@return Notification_Client */
|
@return Notification Client
|
||||||
public int getNotification_Client ()
|
*/
|
||||||
|
public int getNotification_Client_ID ()
|
||||||
{
|
{
|
||||||
Integer ii = (Integer)get_Value(COLUMNNAME_Notification_Client);
|
Integer ii = (Integer)get_Value(COLUMNNAME_Notification_Client_ID);
|
||||||
if (ii == null)
|
if (ii == null)
|
||||||
return 0;
|
return 0;
|
||||||
return ii.intValue();
|
return ii.intValue();
|
||||||
|
@ -376,16 +401,16 @@ public class X_AD_BroadcastMessage extends PO implements I_AD_BroadcastMessage,
|
||||||
return (String)get_Value(COLUMNNAME_Publish);
|
return (String)get_Value(COLUMNNAME_Publish);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Target AD_Reference_ID=200011 */
|
/** Target AD_Reference_ID=200022 */
|
||||||
public static final int TARGET_AD_Reference_ID=200011;
|
public static final int TARGET_AD_Reference_ID=200022;
|
||||||
/** Everybody = E */
|
|
||||||
public static final String TARGET_Everybody = "E";
|
|
||||||
/** Client = C */
|
/** Client = C */
|
||||||
public static final String TARGET_Client = "C";
|
public static final String TARGET_Client = "C";
|
||||||
/** User = U */
|
/** Everybody = E */
|
||||||
public static final String TARGET_User = "U";
|
public static final String TARGET_Everybody = "E";
|
||||||
/** Role = R */
|
/** Role = R */
|
||||||
public static final String TARGET_Role = "R";
|
public static final String TARGET_Role = "R";
|
||||||
|
/** User = U */
|
||||||
|
public static final String TARGET_User = "U";
|
||||||
/** Set Target.
|
/** Set Target.
|
||||||
@param Target
|
@param Target
|
||||||
Target client
|
Target client
|
||||||
|
|
|
@ -16,13 +16,12 @@ package org.idempiere.broadcast;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.adempiere.base.event.EventManager;
|
import org.adempiere.base.event.EventManager;
|
||||||
import org.adempiere.base.event.IEventTopics;
|
import org.adempiere.base.event.IEventTopics;
|
||||||
|
import org.adempiere.exceptions.DBException;
|
||||||
import org.adempiere.model.MBroadcastMessage;
|
import org.adempiere.model.MBroadcastMessage;
|
||||||
import org.compiere.model.MNote;
|
import org.compiere.model.MNote;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
@ -55,53 +54,35 @@ public class BroadcastMsgUtil
|
||||||
if (MBroadcastMessage.BROADCASTTYPE_Login.equals(broadcastType)
|
if (MBroadcastMessage.BROADCASTTYPE_Login.equals(broadcastType)
|
||||||
|| MBroadcastMessage.BROADCASTTYPE_ImmediatePlusLogin.equals(broadcastType)) {
|
|| MBroadcastMessage.BROADCASTTYPE_ImmediatePlusLogin.equals(broadcastType)) {
|
||||||
// get list of users based on rule
|
// get list of users based on rule
|
||||||
ArrayList<Integer> userIDs = new ArrayList<Integer>();
|
|
||||||
String SQL = "";
|
|
||||||
|
|
||||||
if (mbMessage.getTarget() != null) {
|
if (mbMessage.getTarget() != null) {
|
||||||
|
String sql = "SELECT DISTINCT(AD_User_ID) FROM AD_User_Roles WHERE IsActive='Y'";
|
||||||
|
|
||||||
// Role
|
// Role
|
||||||
if (mbMessage.getTarget().equals("R")) {
|
if (mbMessage.getTarget().equals(MBroadcastMessage.TARGET_Role)) {
|
||||||
SQL = "select DISTINCT(ad_user_id) from ad_user_roles where ad_role_id = "
|
sql += " AND AD_Role_ID=" + mbMessage.getAD_Role_ID();
|
||||||
+ mbMessage.getAD_Role_ID();
|
} else if (mbMessage.getTarget().equals(MBroadcastMessage.TARGET_User)) {
|
||||||
} else if (mbMessage.getTarget().equals("U")) {
|
sql += " AND AD_User_ID=" + mbMessage.getAD_User_ID();
|
||||||
SQL = "select DISTINCT(ad_user_id) from ad_user_roles where ad_user_id = "
|
} else if (mbMessage.getTarget().equals(MBroadcastMessage.TARGET_Client)) {
|
||||||
+ mbMessage.getAD_User_ID();
|
sql += " AND ad_client_id = " + mbMessage.getNotification_Client_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();
|
int[] userIDs = DB.getIDsEx(null, sql);
|
||||||
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) {
|
for (int userID : userIDs) {
|
||||||
MNote note = new MNote(Env.getCtx(), 0, trxName);
|
MNote note = new MNote(Env.getCtx(), 0, trxName);
|
||||||
note.setAD_Broadcastmessage_ID(messageID);
|
note.setAD_Broadcastmessage_ID(messageID);
|
||||||
note.setAD_User_ID(userID);
|
note.setAD_User_ID(userID);
|
||||||
note.setAD_Message_ID(0);
|
note.setAD_Message_ID(0);
|
||||||
note.save();
|
note.saveEx();
|
||||||
}
|
}
|
||||||
mbMessage.setIsPublished(true);
|
mbMessage.setIsPublished(true);
|
||||||
mbMessage.setProcessed(true);
|
mbMessage.setProcessed(true);
|
||||||
mbMessage.save(trxName);
|
mbMessage.saveEx(trxName);
|
||||||
} // create entry for users in AD_Note
|
} // create entry for users in AD_Note
|
||||||
}else if(MBroadcastMessage.BROADCASTTYPE_Immediate.equals(broadcastType)){
|
}else if(MBroadcastMessage.BROADCASTTYPE_Immediate.equals(broadcastType)){
|
||||||
mbMessage.setProcessed(true);
|
mbMessage.setProcessed(true);
|
||||||
mbMessage.setIsPublished(true);
|
mbMessage.setIsPublished(true);
|
||||||
mbMessage.save(trxName);
|
mbMessage.saveEx(trxName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MBroadcastMessage.BROADCASTTYPE_Login.equals(broadcastType)) {
|
if (!MBroadcastMessage.BROADCASTTYPE_Login.equals(broadcastType)) {
|
||||||
|
@ -150,20 +131,19 @@ public class BroadcastMsgUtil
|
||||||
* @param AD_User_ID
|
* @param AD_User_ID
|
||||||
* @param messageWindow
|
* @param messageWindow
|
||||||
*/
|
*/
|
||||||
public static void showPendingMeassage(int AD_User_ID, IBroadcastMsgPopup messageWindow) {
|
public static void showPendingMessage(int AD_User_ID, IBroadcastMsgPopup messageWindow) {
|
||||||
StringBuilder sql = new StringBuilder("SELECT bm.AD_BroadcastMessage_ID ")
|
String sql = "SELECT bm.AD_BroadcastMessage_ID "
|
||||||
.append(" FROM AD_Note n INNER JOIN AD_BroadcastMessage bm ON bm.AD_BroadcastMessage_ID=n.AD_BroadcastMessage_ID ")
|
+ " FROM AD_Note n INNER JOIN AD_BroadcastMessage bm ON (bm.AD_BroadcastMessage_ID=n.AD_BroadcastMessage_ID) "
|
||||||
.append(" WHERE n.AD_User_ID = ?")
|
+ " WHERE n.AD_User_ID=?"
|
||||||
.append(" AND (bm.BroadcastType='IL' OR bm.BroadcastType='L') ")
|
+ " AND (bm.BroadcastType='IL' OR bm.BroadcastType='L') "
|
||||||
.append(" AND bm.isPublished='Y' AND n.processed = 'N'")
|
+ " 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') ");
|
+ " AND ((bm.BroadcastFrequency='U' AND bm.Expired='N' AND bm.expiration > SYSDATE) OR bm.BroadcastFrequency='J')";
|
||||||
|
|
||||||
|
|
||||||
ArrayList<MBroadcastMessage> mbMessages = new ArrayList<MBroadcastMessage>();
|
ArrayList<MBroadcastMessage> mbMessages = new ArrayList<MBroadcastMessage>();
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
pstmt = DB.prepareStatement(sql.toString(),null);
|
pstmt = DB.prepareStatement(sql, null);
|
||||||
pstmt.setInt(1, AD_User_ID);
|
pstmt.setInt(1, AD_User_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
@ -171,6 +151,7 @@ public class BroadcastMsgUtil
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.log(Level.SEVERE, "Broadcast messages could not be retrieved",e);
|
logger.log(Level.SEVERE, "Broadcast messages could not be retrieved",e);
|
||||||
|
throw new DBException(e);
|
||||||
}
|
}
|
||||||
finally{
|
finally{
|
||||||
DB.close(rs, pstmt);
|
DB.close(rs, pstmt);
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
|
|
||||||
package org.idempiere.broadcast.process;
|
package org.idempiere.broadcast.process;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
|
|
||||||
import org.adempiere.model.MBroadcastMessage;
|
import org.adempiere.model.MBroadcastMessage;
|
||||||
import org.compiere.process.SvrProcess;
|
import org.compiere.process.SvrProcess;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
|
@ -36,21 +34,13 @@ public class ExpireBrodcastMessage extends SvrProcess{
|
||||||
@Override
|
@Override
|
||||||
protected String doIt() throws Exception {
|
protected String doIt() throws Exception {
|
||||||
MBroadcastMessage mbMessage = MBroadcastMessage.get(Env.getCtx(), getRecord_ID());
|
MBroadcastMessage mbMessage = MBroadcastMessage.get(Env.getCtx(), getRecord_ID());
|
||||||
if(mbMessage.getBroadcastFrequency().equals("U") && !mbMessage.isExpired() && mbMessage.isPublished()){
|
if (MBroadcastMessage.BROADCASTFREQUENCY_UntilExpiration.equals(mbMessage.getBroadcastFrequency())
|
||||||
String sql = "UPDATE AD_Note SET processed='Y' WHERE AD_BroadcastMessage_ID = ?";
|
&& !mbMessage.isExpired() && mbMessage.isPublished()){
|
||||||
PreparedStatement pstmt = null;
|
String sql = "UPDATE AD_Note SET Processed='Y' WHERE AD_BroadcastMessage_ID = ?";
|
||||||
try {
|
DB.executeUpdateEx(sql, new Object[] {getRecord_ID()}, null);
|
||||||
pstmt = DB.prepareStatement(sql,null);
|
|
||||||
pstmt.setInt(1, getRecord_ID());
|
|
||||||
pstmt.executeUpdate();
|
|
||||||
mbMessage.setProcessed(true);
|
mbMessage.setProcessed(true);
|
||||||
mbMessage.setExpired(true);
|
mbMessage.setExpired(true);
|
||||||
} catch (Exception e) {
|
mbMessage.saveEx();
|
||||||
return "Message is not Expired";
|
|
||||||
}finally{
|
|
||||||
DB.close(pstmt);
|
|
||||||
}
|
|
||||||
mbMessage.save();
|
|
||||||
}
|
}
|
||||||
return "Expired";
|
return "Expired";
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -176,7 +176,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
||||||
homeTab.appendChild(busyDialog);
|
homeTab.appendChild(busyDialog);
|
||||||
|
|
||||||
messageWindow = new BroadcastMessageWindow(pnlHead);
|
messageWindow = new BroadcastMessageWindow(pnlHead);
|
||||||
BroadcastMsgUtil.showPendingMeassage(Env.getAD_User_ID(Env.getCtx()), messageWindow);
|
BroadcastMsgUtil.showPendingMessage(Env.getAD_User_ID(Env.getCtx()), messageWindow);
|
||||||
|
|
||||||
if (!layout.getDesktop().isServerPushEnabled())
|
if (!layout.getDesktop().isServerPushEnabled())
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,6 +19,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.adempiere.exceptions.DBException;
|
||||||
import org.adempiere.model.MBroadcastMessage;
|
import org.adempiere.model.MBroadcastMessage;
|
||||||
import org.adempiere.webui.component.Button;
|
import org.adempiere.webui.component.Button;
|
||||||
import org.adempiere.webui.component.Checkbox;
|
import org.adempiere.webui.component.Checkbox;
|
||||||
|
@ -296,7 +297,7 @@ public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup
|
||||||
boolean ack = hashMessages.get(mbMessage.get_ID());
|
boolean ack = hashMessages.get(mbMessage.get_ID());
|
||||||
acknowledged.setChecked(ack);
|
acknowledged.setChecked(ack);
|
||||||
acknowledged.setVisible(true);
|
acknowledged.setVisible(true);
|
||||||
}else if((broadcastFrequency.equals("J"))
|
}else if((broadcastFrequency.equals(MBroadcastMessage.BROADCASTFREQUENCY_JustOnce))
|
||||||
|| (mbMessage.getBroadcastType().equals(MBroadcastMessage.BROADCASTTYPE_Immediate))){
|
|| (mbMessage.getBroadcastType().equals(MBroadcastMessage.BROADCASTTYPE_Immediate))){
|
||||||
acknowledged.setVisible(false);
|
acknowledged.setVisible(false);
|
||||||
hashMessages.put(mbMessages.get(currMsg).get_ID(), true);
|
hashMessages.put(mbMessages.get(currMsg).get_ID(), true);
|
||||||
|
@ -312,9 +313,9 @@ public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public MNote getMNote(MBroadcastMessage mbMessage) {
|
public MNote getMNote(MBroadcastMessage mbMessage) {
|
||||||
String sql = "SELECT * FROM AD_Note WHERE AD_BroadcastMessage_ID = ? AND AD_User_ID = ?";
|
|
||||||
MNote note =null;
|
MNote note =null;
|
||||||
if(!mbMessage.getBroadcastType().equals(MBroadcastMessage.BROADCASTTYPE_Immediate)){
|
if(!mbMessage.getBroadcastType().equals(MBroadcastMessage.BROADCASTTYPE_Immediate)){
|
||||||
|
String sql = "SELECT * FROM AD_Note WHERE AD_BroadcastMessage_ID = ? AND AD_User_ID = ?";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs=null;
|
ResultSet rs=null;
|
||||||
try {
|
try {
|
||||||
|
@ -326,6 +327,7 @@ public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup
|
||||||
note = new MNote(Env.getCtx(), rs, null);
|
note = new MNote(Env.getCtx(), rs, null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.log(Level.SEVERE, "Note for the Mesaage Could not be retrieved ",e);
|
log.log(Level.SEVERE, "Note for the Mesaage Could not be retrieved ",e);
|
||||||
|
throw new DBException(e);
|
||||||
}finally{
|
}finally{
|
||||||
DB.close(rs, pstmt);
|
DB.close(rs, pstmt);
|
||||||
}
|
}
|
||||||
|
@ -351,7 +353,7 @@ public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup
|
||||||
if(hashMessages.get(mbMessage.get_ID())){
|
if(hashMessages.get(mbMessage.get_ID())){
|
||||||
acknowedgedMsgs.add(mbMessage);
|
acknowedgedMsgs.add(mbMessage);
|
||||||
}
|
}
|
||||||
note.save();
|
note.saveEx();
|
||||||
}else{
|
}else{
|
||||||
acknowedgedMsgs.add(mbMessage);
|
acknowedgedMsgs.add(mbMessage);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue