From 73bbb904703259d2fd584dd7b1da50a9537276d5 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 5 Aug 2013 00:12:23 -0500 Subject: [PATCH] IDEMPIERE-1138 Broadcast Message Problems / Based on patch from Richard Morales --- .../oracle/20131707164800_IDEMPIERE-1138.sql | 98 +++++++++++++++++++ .../20131707164800_IDEMPIERE-1138.sql | 95 ++++++++++++++++++ .../adempiere/model/MBroadcastMessage.java | 25 ++++- .../compiere/model/X_AD_BroadcastMessage.java | 10 +- .../idempiere/broadcast/BroadcastMsgUtil.java | 25 +++-- .../webui/panel/BroadcastMessageWindow.java | 23 +++-- 6 files changed, 251 insertions(+), 25 deletions(-) create mode 100644 migration/i1.0c-release/oracle/20131707164800_IDEMPIERE-1138.sql create mode 100644 migration/i1.0c-release/postgresql/20131707164800_IDEMPIERE-1138.sql diff --git a/migration/i1.0c-release/oracle/20131707164800_IDEMPIERE-1138.sql b/migration/i1.0c-release/oracle/20131707164800_IDEMPIERE-1138.sql new file mode 100644 index 0000000000..a5e1979a03 --- /dev/null +++ b/migration/i1.0c-release/oracle/20131707164800_IDEMPIERE-1138.sql @@ -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='

1. Just Once : Message will be broadcasted one time. 

+

2. Until Acknowledge : Repeat it until the message has been acknowledged. 

+

3. Until Expiration or Acknowledge : Repeat it until the message expires or until it has been acknowledged, whatever happens first.

+

4. Until Expiration : Repeat it until message expiration value.

+',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='

1. Just Once : Message will be broadcasted one time. 

+

2. Until Acknowledge : Repeat it until the message has been acknowledged. 

+

3. Until Expiration or Acknowledge : Repeat it until the message expires or until it has been acknowledged, whatever happens first.

+

4. Until Expiration : Repeat it until message expiration value.

+',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='

1. Just Once : Message will be broadcasted one time. 

+

2. Until Acknowledge : Repeat it until the message has been acknowledged. 

+

3. Until Expiration or Acknowledge : Repeat it until the message expires or until it has been acknowledged, whatever happens first.

+

4. Until Expiration : Repeat it until message expiration value.

+' WHERE AD_Column_ID=200984 AND IsCentrallyMaintained='Y' +; + +SELECT register_migration_script('20131707164800_IDEMPIERE-1138.sql') FROM dual +; + diff --git a/migration/i1.0c-release/postgresql/20131707164800_IDEMPIERE-1138.sql b/migration/i1.0c-release/postgresql/20131707164800_IDEMPIERE-1138.sql new file mode 100644 index 0000000000..4aefe2812f --- /dev/null +++ b/migration/i1.0c-release/postgresql/20131707164800_IDEMPIERE-1138.sql @@ -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='

1. Just Once : Message will be broadcasted one time. 

+

2. Until Acknowledge : Repeat it until the message has been acknowledged. 

+

3. Until Expiration or Acknowledge : Repeat it until the message expires or until it has been acknowledged, whatever happens first.

+

4. Until Expiration : Repeat it until message expiration value.

+',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='

1. Just Once : Message will be broadcasted one time. 

+

2. Until Acknowledge : Repeat it until the message has been acknowledged. 

+

3. Until Expiration or Acknowledge : Repeat it until the message expires or until it has been acknowledged, whatever happens first.

+

4. Until Expiration : Repeat it until message expiration value.

+',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='

1. Just Once : Message will be broadcasted one time. 

+

2. Until Acknowledge : Repeat it until the message has been acknowledged. 

+

3. Until Expiration or Acknowledge : Repeat it until the message expires or until it has been acknowledged, whatever happens first.

+

4. Until Expiration : Repeat it until message expiration value.

+' WHERE AD_Column_ID=200984 AND IsCentrallyMaintained='Y' +; + +SELECT register_migration_script('20131707164800_IDEMPIERE-1138.sql') FROM dual +; + diff --git a/org.adempiere.base/src/org/adempiere/model/MBroadcastMessage.java b/org.adempiere.base/src/org/adempiere/model/MBroadcastMessage.java index 7ec6eabda7..240c61e860 100644 --- a/org.adempiere.base/src/org/adempiere/model/MBroadcastMessage.java +++ b/org.adempiere.base/src/org/adempiere/model/MBroadcastMessage.java @@ -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 s_cache = new CCache("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; + } + } diff --git a/org.adempiere.base/src/org/compiere/model/X_AD_BroadcastMessage.java b/org.adempiere.base/src/org/compiere/model/X_AD_BroadcastMessage.java index ed809a6039..5fb9060c2a 100644 --- a/org.adempiere.base/src/org/compiere/model/X_AD_BroadcastMessage.java +++ b/org.adempiere.base/src/org/compiere/model/X_AD_BroadcastMessage.java @@ -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 diff --git a/org.adempiere.base/src/org/idempiere/broadcast/BroadcastMsgUtil.java b/org.adempiere.base/src/org/idempiere/broadcast/BroadcastMsgUtil.java index b9b9e86d0b..e4a3391a2a 100644 --- a/org.adempiere.base/src/org/idempiere/broadcast/BroadcastMsgUtil.java +++ b/org.adempiere.base/src/org/idempiere/broadcast/BroadcastMsgUtil.java @@ -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 mbMessages = new ArrayList(); PreparedStatement pstmt = null; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/BroadcastMessageWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/BroadcastMessageWindow.java index e076a7f9af..4967f392ec 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/BroadcastMessageWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/BroadcastMessageWindow.java @@ -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); }