IDEMPIERE-1138 Broadcast Message Problems / Based on patch from Richard Morales

This commit is contained in:
Carlos Ruiz 2013-08-05 00:12:23 -05:00
parent 7badfa1db9
commit 73bbb90470
6 changed files with 251 additions and 25 deletions

View File

@ -0,0 +1,98 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Jul 16, 2013 5:50:07 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_Ref_List SET Value='E',Updated=TO_DATE('2013-07-16 17:50:07','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Ref_List_ID=200046
;
-- Jul 16, 2013 5:56:21 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_BroadcastMessage SET BroadcastFrequency='E' WHERE BroadcastFrequency='U'
;
-- Jul 16, 2013 5:54:09 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
INSERT INTO AD_Ref_List (AD_Ref_List_ID,AD_Reference_ID,Description,Name,AD_Ref_List_UU,Value,Created,CreatedBy,Updated,UpdatedBy,IsActive,AD_Org_ID,AD_Client_ID,EntityType) VALUES (200156,200020,'Repeat it until the message has been acknowledged','Until Acknowledge','d6b87260-502d-4984-b9e3-8daafde1acd9','A',TO_DATE('2013-07-16 17:54:08','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2013-07-16 17:54:08','YYYY-MM-DD HH24:MI:SS'),100,'Y',0,0,'D')
;
-- Jul 16, 2013 5:54:09 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Ref_List_Trl_UU ) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=200156 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID)
;
-- Jul 16, 2013 5:56:21 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
INSERT INTO AD_Ref_List (AD_Ref_List_ID,AD_Reference_ID,Description,Name,AD_Ref_List_UU,Value,Created,CreatedBy,Updated,UpdatedBy,IsActive,AD_Org_ID,AD_Client_ID,EntityType) VALUES (200157,200020,'Repeat it until the message expires or until it has been acknowledged, whatever happens first','Until Expiration or Acknowledge','aa345f63-dfbe-4d18-aae4-e5ed06cd4407','O',TO_DATE('2013-07-16 17:56:21','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2013-07-16 17:56:21','YYYY-MM-DD HH24:MI:SS'),100,'Y',0,0,'U')
;
-- Jul 16, 2013 5:56:21 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Ref_List_Trl_UU ) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=200157 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID)
;
-- Jul 17, 2013 8:50:32 AM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_Field SET IsActive='N',Updated=TO_DATE('2013-07-17 08:50:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200882
;
-- Jul 17, 2013 8:50:51 AM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_Field SET DisplayLogic=NULL,Updated=TO_DATE('2013-07-17 08:50:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200881
;
-- Jul 17, 2013 8:50:59 AM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_Field SET IsDisplayed='N',Updated=TO_DATE('2013-07-17 08:50:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200881
;
-- Jul 17, 2013 8:54:47 AM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_Field SET DisplayLogic='@BroadcastType@!''I''',Updated=TO_DATE('2013-07-17 08:54:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200873
;
-- Jul 17, 2013 9:14:17 AM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_Field SET DisplayLogic='@BroadcastFrequency@=''E'' | @BroadcastFrequency@=''O''',Updated=TO_DATE('2013-07-17 09:14:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200879
;
-- Jul 17, 2013 3:18:50 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
INSERT INTO AD_Val_Rule (AD_Val_Rule_ID,EntityType,Name,Code,Type,AD_Val_Rule_UU,CreatedBy,UpdatedBy,Updated,Created,AD_Org_ID,IsActive,AD_Client_ID) VALUES (200051,'D','AD_BroadcastMessage - Combination','AD_Ref_List.Value NOT IN(SELECT CASE WHEN AD_Client_ID<>0 THEN ''E'' ELSE ''1'' END FROM AD_Client WHERE AD_Client_ID=@#AD_Client_ID@)','S','9c09aaee-c787-4f30-900e-25412968812a',100,100,TO_DATE('2013-07-17 15:18:49','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2013-07-17 15:18:49','YYYY-MM-DD HH24:MI:SS'),0,'Y',0)
;
-- Jul 17, 2013 3:19:09 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_Column SET AD_Val_Rule_ID=200051, IsToolbarButton='N',Updated=TO_DATE('2013-07-17 15:19:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=200989
;
-- Jul 17, 2013 4:29:38 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_Field SET Help='<p>1. Just Once : Message will be broadcasted one time.&nbsp;</p>
<p><span style="line-height: 1.6em;">2. Until Acknowledge : Repeat it until the message has been acknowledged.&nbsp;</span></p>
<p><span style="line-height: 1.6em;">3.&nbsp;</span><span style="line-height: 1.6em;">Until Expiration or Acknowledge : Repeat it until&nbsp;the message expires or until it has been acknowledged, whatever happens first.</span></p>
<p><span style="line-height: 1.6em;">4.&nbsp;</span><span style="line-height: 1.6em;">Until Expiration : Repeat it until message expiration value.</span></p>
',Updated=TO_DATE('2013-07-17 16:29:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200873
;
-- Jul 17, 2013 4:29:49 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_Column SET Help='<p>1. Just Once : Message will be broadcasted one time.&nbsp;</p>
<p><span style="line-height: 1.6em;">2. Until Acknowledge : Repeat it until the message has been acknowledged.&nbsp;</span></p>
<p><span style="line-height: 1.6em;">3.&nbsp;</span><span style="line-height: 1.6em;">Until Expiration or Acknowledge : Repeat it until&nbsp;the message expires or until it has been acknowledged, whatever happens first.</span></p>
<p><span style="line-height: 1.6em;">4.&nbsp;</span><span style="line-height: 1.6em;">Until Expiration : Repeat it until message expiration value.</span></p>
',Updated=TO_DATE('2013-07-17 16:29:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=200984
;
-- Jul 17, 2013 4:29:49 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_Field SET Name='Broadcast Frequency', Description='How Many Times Message Should be Broadcasted', Help='<p>1. Just Once : Message will be broadcasted one time.&nbsp;</p>
<p><span style="line-height: 1.6em;">2. Until Acknowledge : Repeat it until the message has been acknowledged.&nbsp;</span></p>
<p><span style="line-height: 1.6em;">3.&nbsp;</span><span style="line-height: 1.6em;">Until Expiration or Acknowledge : Repeat it until&nbsp;the message expires or until it has been acknowledged, whatever happens first.</span></p>
<p><span style="line-height: 1.6em;">4.&nbsp;</span><span style="line-height: 1.6em;">Until Expiration : Repeat it until message expiration value.</span></p>
' WHERE AD_Column_ID=200984 AND IsCentrallyMaintained='Y'
;
SELECT register_migration_script('20131707164800_IDEMPIERE-1138.sql') FROM dual
;

View File

@ -0,0 +1,95 @@
-- Jul 16, 2013 5:50:07 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_Ref_List SET Value='E',Updated=TO_TIMESTAMP('2013-07-16 17:50:07','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Ref_List_ID=200046
;
-- Jul 16, 2013 5:56:21 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_BroadcastMessage SET BroadcastFrequency='E' WHERE BroadcastFrequency='U'
;
-- Jul 16, 2013 5:54:09 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
INSERT INTO AD_Ref_List (AD_Ref_List_ID,AD_Reference_ID,Description,Name,AD_Ref_List_UU,Value,Created,CreatedBy,Updated,UpdatedBy,IsActive,AD_Org_ID,AD_Client_ID,EntityType) VALUES (200156,200020,'Repeat it until the message has been acknowledged','Until Acknowledge','d6b87260-502d-4984-b9e3-8daafde1acd9','A',TO_TIMESTAMP('2013-07-16 17:54:08','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2013-07-16 17:54:08','YYYY-MM-DD HH24:MI:SS'),100,'Y',0,0,'D')
;
-- Jul 16, 2013 5:54:09 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Ref_List_Trl_UU ) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=200156 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID)
;
-- Jul 16, 2013 5:56:21 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
INSERT INTO AD_Ref_List (AD_Ref_List_ID,AD_Reference_ID,Description,Name,AD_Ref_List_UU,Value,Created,CreatedBy,Updated,UpdatedBy,IsActive,AD_Org_ID,AD_Client_ID,EntityType) VALUES (200157,200020,'Repeat it until the message expires or until it has been acknowledged, whatever happens first','Until Expiration or Acknowledge','aa345f63-dfbe-4d18-aae4-e5ed06cd4407','O',TO_TIMESTAMP('2013-07-16 17:56:21','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2013-07-16 17:56:21','YYYY-MM-DD HH24:MI:SS'),100,'Y',0,0,'U')
;
-- Jul 16, 2013 5:56:21 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Ref_List_Trl_UU ) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=200157 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID)
;
-- Jul 17, 2013 8:50:32 AM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_Field SET IsActive='N',Updated=TO_TIMESTAMP('2013-07-17 08:50:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200882
;
-- Jul 17, 2013 8:50:51 AM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_Field SET DisplayLogic=NULL,Updated=TO_TIMESTAMP('2013-07-17 08:50:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200881
;
-- Jul 17, 2013 8:50:59 AM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_Field SET IsDisplayed='N',Updated=TO_TIMESTAMP('2013-07-17 08:50:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200881
;
-- Jul 17, 2013 8:54:47 AM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_Field SET DisplayLogic='@BroadcastType@!''I''',Updated=TO_TIMESTAMP('2013-07-17 08:54:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200873
;
-- Jul 17, 2013 9:14:17 AM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_Field SET DisplayLogic='@BroadcastFrequency@=''E'' | @BroadcastFrequency@=''O''',Updated=TO_TIMESTAMP('2013-07-17 09:14:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200879
;
-- Jul 17, 2013 3:18:50 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
INSERT INTO AD_Val_Rule (AD_Val_Rule_ID,EntityType,Name,Code,Type,AD_Val_Rule_UU,CreatedBy,UpdatedBy,Updated,Created,AD_Org_ID,IsActive,AD_Client_ID) VALUES (200051,'D','AD_BroadcastMessage - Combination','AD_Ref_List.Value NOT IN(SELECT CASE WHEN AD_Client_ID<>0 THEN ''E'' ELSE ''1'' END FROM AD_Client WHERE AD_Client_ID=@#AD_Client_ID@)','S','9c09aaee-c787-4f30-900e-25412968812a',100,100,TO_TIMESTAMP('2013-07-17 15:18:49','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2013-07-17 15:18:49','YYYY-MM-DD HH24:MI:SS'),0,'Y',0)
;
-- Jul 17, 2013 3:19:09 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_Column SET AD_Val_Rule_ID=200051, IsToolbarButton='N',Updated=TO_TIMESTAMP('2013-07-17 15:19:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=200989
;
-- Jul 17, 2013 4:29:38 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_Field SET Help='<p>1. Just Once : Message will be broadcasted one time.&nbsp;</p>
<p><span style="line-height: 1.6em;">2. Until Acknowledge : Repeat it until the message has been acknowledged.&nbsp;</span></p>
<p><span style="line-height: 1.6em;">3.&nbsp;</span><span style="line-height: 1.6em;">Until Expiration or Acknowledge : Repeat it until&nbsp;the message expires or until it has been acknowledged, whatever happens first.</span></p>
<p><span style="line-height: 1.6em;">4.&nbsp;</span><span style="line-height: 1.6em;">Until Expiration : Repeat it until message expiration value.</span></p>
',Updated=TO_TIMESTAMP('2013-07-17 16:29:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200873
;
-- Jul 17, 2013 4:29:49 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_Column SET Help='<p>1. Just Once : Message will be broadcasted one time.&nbsp;</p>
<p><span style="line-height: 1.6em;">2. Until Acknowledge : Repeat it until the message has been acknowledged.&nbsp;</span></p>
<p><span style="line-height: 1.6em;">3.&nbsp;</span><span style="line-height: 1.6em;">Until Expiration or Acknowledge : Repeat it until&nbsp;the message expires or until it has been acknowledged, whatever happens first.</span></p>
<p><span style="line-height: 1.6em;">4.&nbsp;</span><span style="line-height: 1.6em;">Until Expiration : Repeat it until message expiration value.</span></p>
',Updated=TO_TIMESTAMP('2013-07-17 16:29:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=200984
;
-- Jul 17, 2013 4:29:49 PM COT
-- IDEMPIERE-1138 Broadcast Message Problems
UPDATE AD_Field SET Name='Broadcast Frequency', Description='How Many Times Message Should be Broadcasted', Help='<p>1. Just Once : Message will be broadcasted one time.&nbsp;</p>
<p><span style="line-height: 1.6em;">2. Until Acknowledge : Repeat it until the message has been acknowledged.&nbsp;</span></p>
<p><span style="line-height: 1.6em;">3.&nbsp;</span><span style="line-height: 1.6em;">Until Expiration or Acknowledge : Repeat it until&nbsp;the message expires or until it has been acknowledged, whatever happens first.</span></p>
<p><span style="line-height: 1.6em;">4.&nbsp;</span><span style="line-height: 1.6em;">Until Expiration : Repeat it until message expiration value.</span></p>
' WHERE AD_Column_ID=200984 AND IsCentrallyMaintained='Y'
;
SELECT register_migration_script('20131707164800_IDEMPIERE-1138.sql') FROM dual
;

View File

@ -29,11 +29,11 @@ import org.compiere.util.Env;
*/
public class MBroadcastMessage extends X_AD_BroadcastMessage
{
/**
*
*/
private static final long serialVersionUID = -6390563897422379468L;
*
*/
private static final long serialVersionUID = 1908264699133879072L;
static private CCache<Integer,MBroadcastMessage> s_cache = new CCache<Integer,MBroadcastMessage>("AD_BroadcastMessage", 30, 60);
public MBroadcastMessage(Properties ctx, int AD_BroadcastMessage_ID,
@ -99,4 +99,21 @@ public class MBroadcastMessage extends X_AD_BroadcastMessage
return false;
}
/**************************************************************************
* Before Save
* @param newRecord new
* @return save
*/
protected boolean beforeSave (boolean newRecord)
{
if (BROADCASTTYPE_Immediate.equals(getBroadcastType())) {
setBroadcastFrequency(BROADCASTFREQUENCY_JustOnce);
}
boolean logack =
( BROADCASTFREQUENCY_UntilAcknowledge.equals(getBroadcastFrequency())
|| BROADCASTFREQUENCY_UntilExpirationOrAcknowledge.equals(getBroadcastFrequency()));
setLogAcknowledge(logack);
return true;
}
}

View File

@ -30,7 +30,7 @@ public class X_AD_BroadcastMessage extends PO implements I_AD_BroadcastMessage,
/**
*
*/
private static final long serialVersionUID = 20130626L;
private static final long serialVersionUID = 20130716L;
/** Standard Constructor */
public X_AD_BroadcastMessage (Properties ctx, int AD_BroadcastMessage_ID, String trxName)
@ -171,8 +171,12 @@ public class X_AD_BroadcastMessage extends PO implements I_AD_BroadcastMessage,
public static final int BROADCASTFREQUENCY_AD_Reference_ID=200020;
/** Just Once = J */
public static final String BROADCASTFREQUENCY_JustOnce = "J";
/** Until Expiration = U */
public static final String BROADCASTFREQUENCY_UntilExpiration = "U";
/** Until Expiration = E */
public static final String BROADCASTFREQUENCY_UntilExpiration = "E";
/** Until Acknowledge = A */
public static final String BROADCASTFREQUENCY_UntilAcknowledge = "A";
/** Until Expiration or Acknowledge = O */
public static final String BROADCASTFREQUENCY_UntilExpirationOrAcknowledge = "O";
/** Set Broadcast Frequency.
@param BroadcastFrequency
How Many Times Message Should be Broadcasted

View File

@ -27,6 +27,7 @@ import org.adempiere.exceptions.DBException;
import org.adempiere.model.MBroadcastMessage;
import org.compiere.Adempiere;
import org.compiere.model.MNote;
import org.compiere.model.MUser;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
@ -61,20 +62,20 @@ public class BroadcastMsgUtil
// get list of users based on rule
if (mbMessage.getTarget() != null) {
String sql = "SELECT DISTINCT(AD_User_ID) FROM AD_User_Roles WHERE IsActive='Y'";
// Role
if (mbMessage.getTarget().equals(MBroadcastMessage.TARGET_Role)) {
sql += " AND AD_Role_ID=" + mbMessage.getAD_Role_ID();
} else if (mbMessage.getTarget().equals(MBroadcastMessage.TARGET_User)) {
sql += " AND AD_User_ID=" + mbMessage.getAD_User_ID();
} else if (mbMessage.getTarget().equals(MBroadcastMessage.TARGET_Client)) {
sql += " AND ad_client_id = " + mbMessage.getNotification_Client_ID();
}
sql += " AND AD_Client_ID = " + Env.getAD_Client_ID(Env.getCtx());
} // else Everybody doesn't need additional filtering
int[] userIDs = DB.getIDsEx(null, sql);
for (int userID : userIDs) {
MNote note = new MNote(Env.getCtx(), 0, trxName);
note.setClientOrg(MUser.get(Env.getCtx(), userID).getAD_Client_ID(), 0);
note.setAD_BroadcastMessage_ID(messageID);
note.setAD_User_ID(userID);
note.setAD_Message_ID(0);
@ -147,13 +148,17 @@ public class BroadcastMsgUtil
* @param messageWindow
*/
public static void showPendingMessage(int AD_User_ID, IBroadcastMsgPopup messageWindow) {
String sql = "SELECT bm.AD_BroadcastMessage_ID "
+ " FROM AD_Note n INNER JOIN AD_BroadcastMessage bm ON (bm.AD_BroadcastMessage_ID=n.AD_BroadcastMessage_ID) "
+ " WHERE n.AD_User_ID=?"
+ " AND n.AD_Client_ID=?"
+ " AND (bm.BroadcastType='IL' OR bm.BroadcastType='L') "
+ " AND bm.isPublished='Y' AND n.processed = 'N'"
+ " AND ((bm.BroadcastFrequency='U' AND bm.Expired='N' AND (bm.expiration IS NULL OR bm.expiration > SYSDATE)) OR bm.BroadcastFrequency='J')";
String sql = ""
+ "SELECT bm.AD_BroadcastMessage_ID "
+ "FROM AD_Note n "
+ " INNER JOIN AD_BroadcastMessage bm "
+ " ON ( bm.AD_BroadcastMessage_ID = n.AD_BroadcastMessage_ID ) "
+ "WHERE n.AD_User_ID = ? "
+ " AND n.AD_Client_ID = ? "
+ " AND ( bm.BroadcastType = 'IL' OR bm.BroadcastType = 'L' ) "
+ " AND bm.isPublished = 'Y' "
+ " AND ( n.Processed = 'N' OR ( n.Processed = 'Y' AND bm.BroadcastFrequency = 'E' ) ) "
+ " AND ( bm.Expired = 'N' AND ( bm.Expiration IS NULL OR bm.Expiration > SYSDATE ) ) ";
ArrayList<MBroadcastMessage> mbMessages = new ArrayList<MBroadcastMessage>();
PreparedStatement pstmt = null;

View File

@ -293,15 +293,17 @@ public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup
textMsgNo.setValue((currMsg+1)+"/"+noOfMsgs);
textMsgContent.setContent(mbMessage.getBroadcastMessage());
if(!isTest && mbMessage.isLogAcknowledge() && broadcastFrequency.equals(MBroadcastMessage.BROADCASTFREQUENCY_UntilExpiration)){
if (!isTest && mbMessage.isLogAcknowledge()) {
boolean ack = hashMessages.get(mbMessage.get_ID());
acknowledged.setChecked(ack);
acknowledged.setVisible(true);
} else if(mbMessage.isLogAcknowledge()) {
acknowledged.setVisible(true);
}else if((broadcastFrequency.equals(MBroadcastMessage.BROADCASTFREQUENCY_JustOnce))
|| (mbMessage.getBroadcastType().equals(MBroadcastMessage.BROADCASTTYPE_Immediate))){
} else if ( broadcastFrequency.equals(MBroadcastMessage.BROADCASTFREQUENCY_JustOnce)
|| mbMessage.getBroadcastType().equals(MBroadcastMessage.BROADCASTTYPE_Immediate)) {
acknowledged.setVisible(false);
hashMessages.put(mbMessages.get(currMsg).get_ID(), true);
}else{
} else {
acknowledged.setVisible(false);
}
@ -315,18 +317,19 @@ public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup
public MNote getMNote(MBroadcastMessage mbMessage) {
MNote note =null;
if(!mbMessage.getBroadcastType().equals(MBroadcastMessage.BROADCASTTYPE_Immediate)){
String sql = "SELECT * FROM AD_Note WHERE AD_BroadcastMessage_ID = ? AND AD_User_ID = ?";
String sql = "SELECT * FROM AD_Note WHERE AD_BroadcastMessage_ID = ? AND AD_User_ID = ? AND AD_Client_ID = ?";
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()));
pstmt.setInt(3, Env.getAD_Client_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);
log.log(Level.SEVERE, "Note for the Message Could not be retrieved ",e);
throw new DBException(e);
}finally{
DB.close(rs, pstmt);
@ -340,7 +343,8 @@ public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup
super.onClose();
if (!isTest) {
if(mbMessages.size()==1){
if ((mbMessages.get(0).getBroadcastFrequency().equals("J"))
if ((mbMessages.get(0).getBroadcastFrequency().equals(MBroadcastMessage.BROADCASTFREQUENCY_JustOnce))
|| (mbMessages.get(0).getBroadcastFrequency().equals(MBroadcastMessage.BROADCASTFREQUENCY_UntilExpiration))
|| (mbMessages.get(0).getBroadcastType().equals(MBroadcastMessage.BROADCASTTYPE_Immediate))) {
hashMessages.put(mbMessages.get(0).get_ID(), true);
}
@ -349,7 +353,10 @@ public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup
for (MBroadcastMessage mbMessage : mbMessages) {
if(!mbMessage.getBroadcastType().equals(MBroadcastMessage.BROADCASTTYPE_Immediate)){
MNote note = getMNote(mbMessage);
note.setProcessed(hashMessages.get(mbMessage.get_ID()));
if (mbMessage.getBroadcastFrequency().equals(MBroadcastMessage.BROADCASTFREQUENCY_UntilExpiration))
note.setProcessed(true);
else
note.setProcessed(hashMessages.get(mbMessage.get_ID()));
if(hashMessages.get(mbMessage.get_ID())){
acknowedgedMsgs.add(mbMessage);
}