hg merge release-4.1 (merge release4.1 into development)

This commit is contained in:
Carlos Ruiz 2017-07-21 20:13:24 +02:00
commit 80d851ed8e
93 changed files with 5018 additions and 271 deletions

View File

@ -0,0 +1,17 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Jun 19, 2017 8:54:41 PM CEST
-- 2Pack Semaphore
INSERT INTO AD_SysConfig (AD_SysConfig_ID,EntityType,ConfigurationLevel,Updated,Value,AD_SysConfig_UU,IsActive,Name,Created,AD_Org_ID,CreatedBy,UpdatedBy,AD_Client_ID) VALUES (200098,'D','S',TO_DATE('2017-06-19 20:54:40','YYYY-MM-DD HH24:MI:SS'),'AUTOMATIC_PACKIN_PROCESSING','cba425fc-4e0e-4a45-bc14-281a98a52c81','Y','AUTOMATIC_PACKIN_PROCESSING',TO_DATE('2017-06-19 20:54:40','YYYY-MM-DD HH24:MI:SS'),0,100,100,0)
;
-- Jun 19, 2017 8:55:06 PM CEST
INSERT INTO AD_SysConfig (AD_SysConfig_ID,EntityType,ConfigurationLevel,Updated,Value,AD_SysConfig_UU,IsActive,Name,Created,AD_Org_ID,CreatedBy,UpdatedBy,AD_Client_ID) VALUES (200099,'D','S',TO_DATE('2017-06-19 20:55:05','YYYY-MM-DD HH24:MI:SS'),'120','2dd1b89a-936e-47aa-b7e6-3b66649ed224','Y','AUTOMATIC_PACKIN_TIMEOUT',TO_DATE('2017-06-19 20:55:05','YYYY-MM-DD HH24:MI:SS'),0,100,100,0)
;
INSERT INTO AD_SysConfig (AD_SysConfig_ID,EntityType,ConfigurationLevel,Updated,Value,AD_SysConfig_UU,IsActive,Name,Created,AD_Org_ID,CreatedBy,UpdatedBy,AD_Client_ID) VALUES (200100,'D','S',TO_DATE('2017-06-20 12:12:07','YYYY-MM-DD HH24:MI:SS'),'5','49244d58-3306-4a38-9458-7fa8616214c2','Y','AUTOMATIC_PACKIN_RETRIES',TO_DATE('2017-06-20 12:12:07','YYYY-MM-DD HH24:MI:SS'),0,100,100,0)
;
SELECT register_migration_script('201706192054_Ticket_1008086.sql') FROM dual
;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
-- IDEMPIERE-794 Ticket #1001025 - Expand the views to provide more information / fix a reference that was wrongly defined
-- Jun 21, 2017 7:07:04 PM COT
UPDATE AD_Ref_Table SET AD_Table_ID=560, AD_Key=8490, AD_Display=8489,Updated=TO_DATE('2017-06-21 19:07:04','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Reference_ID=200055
;
SELECT register_migration_script('201706220209_IDEMPIERE-794.sql') FROM dual
;

View File

@ -0,0 +1,11 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-3409
-- Jun 24, 2017 6:06:16 PM CEST
INSERT INTO AD_SysConfig (AD_SysConfig_ID,AD_Client_ID,AD_Org_ID,Created,Updated,CreatedBy,UpdatedBy,IsActive,Name,Value,Description,EntityType,ConfigurationLevel,AD_SysConfig_UU) VALUES (200103,0,0,TO_DATE('2017-06-24 18:06:16','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2017-06-24 18:06:16','YYYY-MM-DD HH24:MI:SS'),100,100,'Y','IDENTIFIER_SEPARATOR','_','Separator for the fields that compose an identifier on lookup boxes','D','C','3139dada-425f-42ea-8840-3080e88aa5e2')
;
SELECT register_migration_script('201706241808_IDEMPIERE-3409.sql') FROM dual
;

View File

@ -0,0 +1,15 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-3401 Orderline Discount Context issue
-- Jun 24, 2017 6:44:50 PM CEST
UPDATE AD_Column SET Callout='org.compiere.model.CalloutOrder.navigateOrderLine', IsUpdateable='N',Updated=TO_DATE('2017-06-24 18:44:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2205
;
-- Jun 24, 2017 6:45:45 PM CEST
UPDATE AD_Column SET Callout='org.compiere.model.CalloutInvoice.navigateInvoiceLine', IsUpdateable='N',Updated=TO_DATE('2017-06-24 18:45:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3828
;
SELECT register_migration_script('201706241900_IDEMPIERE-3401.sql') FROM dual
;

View File

@ -0,0 +1,43 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-3405
-- Jun 24, 2017 11:48:25 PM CEST
UPDATE AD_Val_Rule SET Name='C_DocTypeTarget PO or SO',Updated=TO_DATE('2017-06-24 23:48:25','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=133
;
-- Jun 24, 2017 11:48:48 PM CEST
UPDATE AD_Val_Rule SET Description='Document Type for orders',Updated=TO_DATE('2017-06-24 23:48:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=133
;
-- Jun 24, 2017 11:49:44 PM CEST
INSERT INTO AD_Val_Rule (AD_Val_Rule_ID,Name,Description,Type,Code,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Val_Rule_UU) VALUES (200096,'C_DocType PO or SO','Document Type for orders','S','(C_DocType.DocBaseType IN (''SOO'', ''POO'') AND C_DocType.IsSOTrx=''@IsSOTrx@'' AND COALESCE(C_DocType.DocSubTypeSO,'' '')<>''RM'' AND C_DocType.AD_Client_ID=@#AD_Client_ID@) OR C_DocType_ID=0',0,0,'Y',TO_DATE('2017-06-24 23:49:43','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2017-06-24 23:49:43','YYYY-MM-DD HH24:MI:SS'),100,'D','7f54de3d-a0cb-4649-aeff-6c8dfa5bd991')
;
-- Jun 24, 2017 11:50:01 PM CEST
UPDATE AD_Val_Rule SET Description='Target Document Type for orders',Updated=TO_DATE('2017-06-24 23:50:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=133
;
-- Jun 24, 2017 11:50:13 PM CEST
UPDATE AD_Val_Rule SET Name='C_DocTypeTarget AR/AP Invoices and Credit Memos', Description='Target Document Type AR/AP Invoice and Credit Memos',Updated=TO_DATE('2017-06-24 23:50:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=124
;
-- Jun 24, 2017 11:50:29 PM CEST
INSERT INTO AD_Val_Rule (AD_Val_Rule_ID,Name,Description,Type,Code,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Val_Rule_UU) VALUES (200097,'C_DocTypeTarget AR/AP Invoices and Credit Memos','Target Document Type AR/AP Invoice and Credit Memos','S','(C_DocType.DocBaseType IN (''ARI'', ''API'',''ARC'',''APC'') AND C_DocType.IsSOTrx=''@IsSOTrx@'' AND C_DocType.AD_Client_ID=@#AD_Client_ID@) OR C_DocType_ID=0',0,0,'Y',TO_DATE('2017-06-24 23:50:29','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2017-06-24 23:50:29','YYYY-MM-DD HH24:MI:SS'),100,'D','62aa64dd-3808-4871-954a-783b60943758')
;
-- Jun 24, 2017 11:50:59 PM CEST
UPDATE AD_Column SET AD_Val_Rule_ID=200096,Updated=TO_DATE('2017-06-24 23:50:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2172
;
-- Jun 24, 2017 11:52:31 PM CEST
UPDATE AD_Val_Rule SET Name='C_DocType AR/AP Invoices and Credit Memos', Description='Document Type AR/AP Invoice and Credit Memos',Updated=TO_DATE('2017-06-24 23:52:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=200097
;
-- Jun 24, 2017 11:52:43 PM CEST
UPDATE AD_Column SET AD_Val_Rule_ID=200097,Updated=TO_DATE('2017-06-24 23:52:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3493
;
SELECT register_migration_script('201706242353_IDEMPIERE-3405.sql') FROM dual
;

View File

@ -0,0 +1,15 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-3405
-- Jun 25, 2017 2:58:01 PM CEST
UPDATE AD_Val_Rule SET Code='(C_DocType.DocBaseType IN (''ARI'', ''API'',''ARC'',''APC'') AND C_DocType.IsSOTrx=''@IsSOTrx@'' AND C_DocType.AD_Client_ID=@#AD_Client_ID@) OR C_DocType.C_DocType_ID=0',Updated=TO_DATE('2017-06-25 14:58:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=200097
;
-- Jun 25, 2017 2:58:15 PM CEST
UPDATE AD_Val_Rule SET Code='(C_DocType.DocBaseType IN (''SOO'', ''POO'') AND C_DocType.IsSOTrx=''@IsSOTrx@'' AND COALESCE(C_DocType.DocSubTypeSO,'' '')<>''RM'' AND C_DocType.AD_Client_ID=@#AD_Client_ID@) OR C_DocType.C_DocType_ID=0',Updated=TO_DATE('2017-06-25 14:58:15','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=200096
;
SELECT register_migration_script('201706251458_IDEMPIERE-3405.sql') FROM dual
;

View File

@ -0,0 +1,14 @@
-- Jun 19, 2017 8:54:41 PM CEST
-- 2Pack Semaphore
INSERT INTO AD_SysConfig (AD_SysConfig_ID,EntityType,ConfigurationLevel,Updated,Value,AD_SysConfig_UU,IsActive,Name,Created,AD_Org_ID,CreatedBy,UpdatedBy,AD_Client_ID) VALUES (200098,'D','S',TO_TIMESTAMP('2017-06-19 20:54:40','YYYY-MM-DD HH24:MI:SS'),'AUTOMATIC_PACKIN_PROCESSING','cba425fc-4e0e-4a45-bc14-281a98a52c81','Y','AUTOMATIC_PACKIN_PROCESSING',TO_TIMESTAMP('2017-06-19 20:54:40','YYYY-MM-DD HH24:MI:SS'),0,100,100,0)
;
-- Jun 19, 2017 8:55:06 PM CEST
INSERT INTO AD_SysConfig (AD_SysConfig_ID,EntityType,ConfigurationLevel,Updated,Value,AD_SysConfig_UU,IsActive,Name,Created,AD_Org_ID,CreatedBy,UpdatedBy,AD_Client_ID) VALUES (200099,'D','S',TO_TIMESTAMP('2017-06-19 20:55:05','YYYY-MM-DD HH24:MI:SS'),'120','2dd1b89a-936e-47aa-b7e6-3b66649ed224','Y','AUTOMATIC_PACKIN_TIMEOUT',TO_TIMESTAMP('2017-06-19 20:55:05','YYYY-MM-DD HH24:MI:SS'),0,100,100,0)
;
INSERT INTO AD_SysConfig (AD_SysConfig_ID,EntityType,ConfigurationLevel,Updated,Value,AD_SysConfig_UU,IsActive,Name,Created,AD_Org_ID,CreatedBy,UpdatedBy,AD_Client_ID) VALUES (200100,'D','S',TO_TIMESTAMP('2017-06-20 12:12:07','YYYY-MM-DD HH24:MI:SS'),'5','49244d58-3306-4a38-9458-7fa8616214c2','Y','AUTOMATIC_PACKIN_RETRIES',TO_TIMESTAMP('2017-06-20 12:12:07','YYYY-MM-DD HH24:MI:SS'),0,100,100,0)
;
SELECT register_migration_script('201706192054_Ticket_1008086.sql') FROM dual
;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
-- IDEMPIERE-794 Ticket #1001025 - Expand the views to provide more information / fix a reference that was wrongly defined
-- Jun 21, 2017 7:07:04 PM COT
UPDATE AD_Ref_Table SET AD_Table_ID=560, AD_Key=8490, AD_Display=8489,Updated=TO_TIMESTAMP('2017-06-21 19:07:04','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Reference_ID=200055
;
SELECT register_migration_script('201706220209_IDEMPIERE-794.sql') FROM dual
;

View File

@ -0,0 +1,8 @@
-- IDEMPIERE-3409
-- Jun 24, 2017 6:06:16 PM CEST
INSERT INTO AD_SysConfig (AD_SysConfig_ID,AD_Client_ID,AD_Org_ID,Created,Updated,CreatedBy,UpdatedBy,IsActive,Name,Value,Description,EntityType,ConfigurationLevel,AD_SysConfig_UU) VALUES (200103,0,0,TO_TIMESTAMP('2017-06-24 18:06:16','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2017-06-24 18:06:16','YYYY-MM-DD HH24:MI:SS'),100,100,'Y','IDENTIFIER_SEPARATOR','_','Separator for the fields that compose an identifier on lookup boxes','D','C','3139dada-425f-42ea-8840-3080e88aa5e2')
;
SELECT register_migration_script('201706241808_IDEMPIERE-3409.sql') FROM dual
;

View File

@ -0,0 +1,12 @@
-- IDEMPIERE-3401 Orderline Discount Context issue
-- Jun 24, 2017 6:44:50 PM CEST
UPDATE AD_Column SET Callout='org.compiere.model.CalloutOrder.navigateOrderLine', IsUpdateable='N',Updated=TO_TIMESTAMP('2017-06-24 18:44:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2205
;
-- Jun 24, 2017 6:45:45 PM CEST
UPDATE AD_Column SET Callout='org.compiere.model.CalloutInvoice.navigateInvoiceLine', IsUpdateable='N',Updated=TO_TIMESTAMP('2017-06-24 18:45:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3828
;
SELECT register_migration_script('201706241900_IDEMPIERE-3401.sql') FROM dual
;

View File

@ -0,0 +1,40 @@
-- IDEMPIERE-3405
-- Jun 24, 2017 11:48:25 PM CEST
UPDATE AD_Val_Rule SET Name='C_DocTypeTarget PO or SO',Updated=TO_TIMESTAMP('2017-06-24 23:48:25','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=133
;
-- Jun 24, 2017 11:48:48 PM CEST
UPDATE AD_Val_Rule SET Description='Document Type for orders',Updated=TO_TIMESTAMP('2017-06-24 23:48:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=133
;
-- Jun 24, 2017 11:49:44 PM CEST
INSERT INTO AD_Val_Rule (AD_Val_Rule_ID,Name,Description,Type,Code,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Val_Rule_UU) VALUES (200096,'C_DocType PO or SO','Document Type for orders','S','(C_DocType.DocBaseType IN (''SOO'', ''POO'') AND C_DocType.IsSOTrx=''@IsSOTrx@'' AND COALESCE(C_DocType.DocSubTypeSO,'' '')<>''RM'' AND C_DocType.AD_Client_ID=@#AD_Client_ID@) OR C_DocType_ID=0',0,0,'Y',TO_TIMESTAMP('2017-06-24 23:49:43','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2017-06-24 23:49:43','YYYY-MM-DD HH24:MI:SS'),100,'D','7f54de3d-a0cb-4649-aeff-6c8dfa5bd991')
;
-- Jun 24, 2017 11:50:01 PM CEST
UPDATE AD_Val_Rule SET Description='Target Document Type for orders',Updated=TO_TIMESTAMP('2017-06-24 23:50:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=133
;
-- Jun 24, 2017 11:50:13 PM CEST
UPDATE AD_Val_Rule SET Name='C_DocTypeTarget AR/AP Invoices and Credit Memos', Description='Target Document Type AR/AP Invoice and Credit Memos',Updated=TO_TIMESTAMP('2017-06-24 23:50:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=124
;
-- Jun 24, 2017 11:50:29 PM CEST
INSERT INTO AD_Val_Rule (AD_Val_Rule_ID,Name,Description,Type,Code,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Val_Rule_UU) VALUES (200097,'C_DocTypeTarget AR/AP Invoices and Credit Memos','Target Document Type AR/AP Invoice and Credit Memos','S','(C_DocType.DocBaseType IN (''ARI'', ''API'',''ARC'',''APC'') AND C_DocType.IsSOTrx=''@IsSOTrx@'' AND C_DocType.AD_Client_ID=@#AD_Client_ID@) OR C_DocType_ID=0',0,0,'Y',TO_TIMESTAMP('2017-06-24 23:50:29','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2017-06-24 23:50:29','YYYY-MM-DD HH24:MI:SS'),100,'D','62aa64dd-3808-4871-954a-783b60943758')
;
-- Jun 24, 2017 11:50:59 PM CEST
UPDATE AD_Column SET AD_Val_Rule_ID=200096,Updated=TO_TIMESTAMP('2017-06-24 23:50:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2172
;
-- Jun 24, 2017 11:52:31 PM CEST
UPDATE AD_Val_Rule SET Name='C_DocType AR/AP Invoices and Credit Memos', Description='Document Type AR/AP Invoice and Credit Memos',Updated=TO_TIMESTAMP('2017-06-24 23:52:31','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=200097
;
-- Jun 24, 2017 11:52:43 PM CEST
UPDATE AD_Column SET AD_Val_Rule_ID=200097,Updated=TO_TIMESTAMP('2017-06-24 23:52:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3493
;
SELECT register_migration_script('201706242353_IDEMPIERE-3405.sql') FROM dual
;

View File

@ -0,0 +1,12 @@
-- IDEMPIERE-3405
-- Jun 25, 2017 2:58:01 PM CEST
UPDATE AD_Val_Rule SET Code='(C_DocType.DocBaseType IN (''ARI'', ''API'',''ARC'',''APC'') AND C_DocType.IsSOTrx=''@IsSOTrx@'' AND C_DocType.AD_Client_ID=@#AD_Client_ID@) OR C_DocType.C_DocType_ID=0',Updated=TO_TIMESTAMP('2017-06-25 14:58:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=200097
;
-- Jun 25, 2017 2:58:15 PM CEST
UPDATE AD_Val_Rule SET Code='(C_DocType.DocBaseType IN (''SOO'', ''POO'') AND C_DocType.IsSOTrx=''@IsSOTrx@'' AND COALESCE(C_DocType.DocSubTypeSO,'' '')<>''RM'' AND C_DocType.AD_Client_ID=@#AD_Client_ID@) OR C_DocType.C_DocType_ID=0',Updated=TO_TIMESTAMP('2017-06-25 14:58:15','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=200096
;
SELECT register_migration_script('201706251458_IDEMPIERE-3405.sql') FROM dual
;

View File

@ -832,6 +832,45 @@ public class CalloutInvoice extends CalloutEngine
//
return "";
} // qty
public String navigateInvoiceLine(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) {
Integer M_Product_ID = Env.getContextAsInt(ctx, WindowNo, mTab.getTabNo(), "M_Product_ID");
if (M_Product_ID == null || M_Product_ID.intValue() == 0) {
Env.setContext(ctx, WindowNo, "DiscountSchema", "N");
return "";
}
/***** Price Calculation see also qty ****/
int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID");
BigDecimal Qty = (BigDecimal)mTab.getValue("QtyOrdered");
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y");
MProductPricing pp = new MProductPricing (M_Product_ID.intValue(), C_BPartner_ID, Qty, IsSOTrx);
//
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID");
pp.setM_PriceList_ID(M_PriceList_ID);
Timestamp orderDate = (Timestamp)mTab.getValue("DateOrdered");
/** PLV is only accurate if PL selected in header */
int M_PriceList_Version_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_Version_ID");
if ( M_PriceList_Version_ID == 0 && M_PriceList_ID > 0)
{
String sql = "SELECT plv.M_PriceList_Version_ID "
+ "FROM M_PriceList_Version plv "
+ "WHERE plv.M_PriceList_ID=? " // 1
+ " AND plv.ValidFrom <= ? "
+ "ORDER BY plv.ValidFrom DESC";
// Use newest price list - may not be future
M_PriceList_Version_ID = DB.getSQLValueEx(null, sql, M_PriceList_ID, orderDate);
if ( M_PriceList_Version_ID > 0 )
Env.setContext(ctx, WindowNo, "M_PriceList_Version_ID", M_PriceList_Version_ID );
}
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
pp.setPriceDate(orderDate);
//
Env.setContext(ctx, WindowNo, "EnforcePriceLimit", pp.isEnforcePriceLimit() ? "Y" : "N");
Env.setContext(ctx, WindowNo, "DiscountSchema", pp.isDiscountSchema() ? "Y" : "N");
return "";
}
} // CalloutInvoice

View File

@ -1411,5 +1411,46 @@ public class CalloutOrder extends CalloutEngine
}
return "";
}
public String navigateOrderLine(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) {
Integer M_Product_ID = Env.getContextAsInt(ctx, WindowNo, mTab.getTabNo(), "M_Product_ID");
if (M_Product_ID == null || M_Product_ID.intValue() == 0) {
Env.setContext(ctx, WindowNo, "DiscountSchema", "N");
return "";
}
/***** Price Calculation see also qty ****/
int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID");
BigDecimal Qty = (BigDecimal)mTab.getValue("QtyOrdered");
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y");
MProductPricing pp = new MProductPricing (M_Product_ID.intValue(), C_BPartner_ID, Qty, IsSOTrx);
//
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID");
pp.setM_PriceList_ID(M_PriceList_ID);
Timestamp orderDate = (Timestamp)mTab.getValue("DateOrdered");
/** PLV is only accurate if PL selected in header */
int M_PriceList_Version_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_Version_ID");
if ( M_PriceList_Version_ID == 0 && M_PriceList_ID > 0)
{
String sql = "SELECT plv.M_PriceList_Version_ID "
+ "FROM M_PriceList_Version plv "
+ "WHERE plv.M_PriceList_ID=? " // 1
+ " AND plv.ValidFrom <= ? "
+ "ORDER BY plv.ValidFrom DESC";
// Use newest price list - may not be future
M_PriceList_Version_ID = DB.getSQLValueEx(null, sql, M_PriceList_ID, orderDate);
if ( M_PriceList_Version_ID > 0 )
Env.setContext(ctx, WindowNo, "M_PriceList_Version_ID", M_PriceList_Version_ID );
}
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
pp.setPriceDate(orderDate);
//
Env.setContext(ctx, WindowNo, "EnforcePriceLimit", pp.isEnforcePriceLimit() ? "Y" : "N");
Env.setContext(ctx, WindowNo, "DiscountSchema", pp.isDiscountSchema() ? "Y" : "N");
return "";
}
} // CalloutOrder

View File

@ -221,6 +221,7 @@ public class ClientAcctProcessor extends SvrProcess
// Run every posting document in own transaction
String innerTrxName = Trx.createTrxName("CAP");
Trx innerTrx = Trx.get(innerTrxName, true);
innerTrx.setDisplayName(getClass().getName()+"_postSession");
try
{

View File

@ -104,6 +104,7 @@ public class AllocationReset extends SvrProcess
throw new AdempiereUserError(Msg.parseTranslation(getCtx(), "@Mandatory@: @C_AllocationHdr_ID@"));
m_trx = Trx.get(Trx.createTrxName("AllocReset"), true);
m_trx.setDisplayName(getClass().getName()+"_doIt");
int count = 0;
if (p_C_AllocationHdr_ID != 0)

View File

@ -209,6 +209,7 @@ public class RequestEMailProcessor extends SvrProcess implements ProcessEmailHan
Trx trxRequest = null;
try {
trxRequest = Trx.get(Trx.createTrxName("SvrProcess-makerequest"), true);
trxRequest.setDisplayName(getClass().getName()+"_processEmailContent");
trxRequest.start();
createRequest(emailHeader, trxRequest.getTrxName());

View File

@ -208,6 +208,7 @@ public class UUIDGenerator extends SvrProcess {
Trx trx = trxName != null ? Trx.get(trxName, false) : null;
if (trx == null) {
trx = Trx.get(Trx.createTrxName(), true);
trx.setDisplayName(UUIDGenerator.class.getName()+"_updateUUID");
localTrx = true;
}
try {

View File

@ -225,8 +225,10 @@ public final class ProcessUtil {
MRule.setContext(engine, ctx, 0); // no window
// now add the method arguments to the engine
engine.put(MRule.ARGUMENTS_PREFIX + "Ctx", ctx);
if (trx == null)
if (trx == null) {
trx = Trx.get(Trx.createTrxName(pi.getTitle()+"_"+pi.getAD_PInstance_ID()), true);
trx.setDisplayName(ProcessUtil.class.getName()+"_startScriptProcess");
}
engine.put(MRule.ARGUMENTS_PREFIX + "Trx", trx);
engine.put(MRule.ARGUMENTS_PREFIX + "TrxName", trx.getTrxName());
engine.put(MRule.ARGUMENTS_PREFIX + "Record_ID", pi.getRecord_ID());

View File

@ -258,10 +258,28 @@ public abstract class Doc
String error = null;
MAcctSchema[] ass = MAcctSchema.getClientAcctSchema(Env.getCtx(), AD_Client_ID);
Trx trx = Trx.get(Trx.createTrxName("ManulPosting"), true);
trx.setDisplayName(Doc.class.getName()+"_manualPosting");
try
{
error = postImmediate(ass, AD_Table_ID, Record_ID, force, trx.getTrxName());
//Average Costing: Post MatchPO and MatchInv together with MR and Invoice
//Costing: Post MatchPO before MR
if (AD_Table_ID == MInOut.Table_ID)
{
MMatchPO[] matchPos = MMatchPO.getInOut(Env.getCtx(), Record_ID, trx.getTrxName());
for (MMatchPO matchPo : matchPos)
{
if (!matchPo.isPosted())
{
error = postImmediate(ass, matchPo.get_Table_ID(), matchPo.get_ID(), force, matchPo.get_TrxName());
if (!Util.isEmpty(error))
break;
}
}
}
if (Util.isEmpty(error))
{
error = postImmediate(ass, AD_Table_ID, Record_ID, force, trx.getTrxName());
}
//Costing: Post MatchInv after Invoice
if (Util.isEmpty(error))
{
if (AD_Table_ID == MInvoice.Table_ID)
@ -276,20 +294,6 @@ public abstract class Doc
break;
}
}
}
else if (AD_Table_ID == MInOut.Table_ID)
{
MMatchPO[] matchPos = MMatchPO.getInOut(Env.getCtx(), Record_ID, trx.getTrxName());
for (MMatchPO matchPo : matchPos)
{
if (!matchPo.isPosted())
{
error = postImmediate(ass, matchPo.get_Table_ID(), matchPo.get_ID(), force, matchPo.get_TrxName());
if (!Util.isEmpty(error))
break;
}
}
}
}
if (Util.isEmpty(error))

View File

@ -286,32 +286,45 @@ public class DocManager {
}
Trx trx = Trx.get(trxName, true);
if (localTrxName != null)
trx.setDisplayName(DocManager.class.getName()+"_postDocument");
String error = null;
Savepoint savepoint = null;
try
{
savepoint = localTrxName == null ? trx.setSavepoint(null) : null;
String status = "";
for(MAcctSchema as : ass)
{
Doc doc = Doc.get (as, AD_Table_ID, rs, trxName);
if (doc != null)
{
Savepoint savepoint = trx.setSavepoint(null);
error = doc.post (force, repost); // repost
status = doc.getPostStatus();
if (error != null && error.trim().length() > 0)
{
trx.rollback(savepoint);
if (savepoint != null)
{
trx.rollback(savepoint);
savepoint = null;
}
else
trx.rollback();
s_log.info("Error Posting " + doc + " to " + as + " Error: " + error);
break;
}
else
{
try {
trx.releaseSavepoint(savepoint);
} catch (Exception e) {}
}
}
else
{
if (savepoint != null)
{
trx.rollback(savepoint);
savepoint = null;
}
else
trx.rollback();
s_log.info("Error Posting " + doc + " to " + as + " Error: NoDoc");
return "NoDoc";
}
}
@ -326,15 +339,27 @@ public class DocManager {
if (localTrxName != null) {
if (trx != null)
trx.rollback();
} else if (trx != null && savepoint != null) {
trx.rollback(savepoint);
savepoint = null;
}
if (dbError != null)
error = dbError.getValue();
else
error = "SaveError";
}
if (localTrxName != null) {
if (trx != null)
if (savepoint != null)
{
try
{
trx.releaseSavepoint(savepoint);
} catch (SQLException e1) {}
savepoint = null;
}
if (localTrxName != null && error == null) {
if (trx != null) {
trx.commit();
}
}
}
catch (Exception e)
@ -342,6 +367,10 @@ public class DocManager {
if (localTrxName != null) {
if (trx != null)
trx.rollback();
} else if (trx != null && savepoint != null) {
try {
trx.rollback(savepoint);
} catch (SQLException e1) {}
}
if (e instanceof RuntimeException)
throw (RuntimeException) e;

View File

@ -187,9 +187,6 @@ public class Doc_MatchPO extends Doc
MInOut inOut = receiptLine.getParent();
boolean isReturnTrx = inOut.getMovementType().equals(X_M_InOut.MOVEMENTTYPE_VendorReturns);
// calculate po cost
BigDecimal deliveredCost = poCost.multiply(getQty()); // Delivered so far
Map<Integer, BigDecimal> landedCostMap = new LinkedHashMap<Integer, BigDecimal>();
BigDecimal landedCost = BigDecimal.ZERO;
int C_OrderLine_ID = m_oLine.getC_OrderLine_ID();
@ -230,8 +227,7 @@ public class Doc_MatchPO extends Doc
}
landedCostMap.put(elementId, elementAmt);
}
BigDecimal totalCost = deliveredCost.add(landedCost);
// Different currency
if (m_oLine.getC_Currency_ID() != as.getC_Currency_ID())
{
@ -258,6 +254,10 @@ public class Doc_MatchPO extends Doc
return null;
}
// calculate po cost
BigDecimal deliveredCost = poCost.multiply(getQty()); // Delivered so far
BigDecimal totalCost = deliveredCost.add(landedCost);
// Calculate PPV for standard costing
MProduct product = MProduct.get(getCtx(), getM_Product_ID());
String costingMethod = product.getCostingMethod(as);

View File

@ -80,11 +80,10 @@ import org.idempiere.util.ParseSeq;
public class GridField
implements Serializable, Evaluatee, Cloneable
{
/**
*
*/
private static final long serialVersionUID = -7739433012288022819L;
private static final long serialVersionUID = 2703129833179761682L;
/**
* Field Constructor.
@ -1069,6 +1068,7 @@ public class GridField
*/
public boolean validateValueNoDirect()
{
refreshLookup();
// null
if (m_value == null || m_value.toString().length() == 0)
{
@ -1118,12 +1118,13 @@ public class GridField
setValue(null, m_inserting);
m_error = true;
return false;
} // validateValue
} // validateValueNoDirect
/**
* Validate initial Field Value. Push direct value if it doesn't exist
* Called from GridTab.setCurrentRow when inserting
* @return true if valid
* @deprecated use validateValueNoDirect instead
*/
public boolean validateValue()
{
@ -1166,7 +1167,7 @@ public class GridField
setValue(null, m_inserting);
m_error = true;
return false;
} // validateValuePushDirect
} // validateValue
/**************************************************************************
* Is the Column Visible ?

View File

@ -1180,11 +1180,6 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
return retValue;
setCurrentRow(m_currentRow + 1, true);
// check validity of defaults
for (GridField field : getFields()) {
field.refreshLookup();
field.validateValueNoDirect();
}
// process all Callouts (no dependency check - assumed that settings are valid)
for (int i = 0; i < getFieldCount(); i++)
processCallout(getField(i));
@ -2585,8 +2580,6 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
{
Object value = m_mTable.getValueAt(m_currentRow, i);
mField.setValue(value, m_mTable.isInserting());
if (m_mTable.isInserting()) // set invalid values to null
mField.validateValue();
if (mField.isKey())
keyCalloutDelayed = mField;
}

View File

@ -2618,11 +2618,17 @@ public class GridTable extends AbstractTableModel
|| (hasDocTypeTargetField && field.getColumnName().equals("C_DocType_ID"))
|| ! field.isAllowCopy())
{
rowData[i] = field.getDefault();
field.setValue(rowData[i], m_inserting);
Object value = field.getDefault();
field.setValue(value, m_inserting);
field.validateValueNoDirect();
rowData[i] = field.getValue();
}
else {
Object value = origData[i];
field.setValue(value, m_inserting);
field.validateValueNoDirect();
rowData[i] = field.getValue();
}
else
rowData[i] = origData[i];
}
}
else // new
@ -2630,8 +2636,10 @@ public class GridTable extends AbstractTableModel
for (int i = 0; i < size; i++)
{
GridField field = (GridField)m_fields.get(i);
rowData[i] = field.getDefault();
field.setValue(rowData[i], m_inserting);
Object value = field.getDefault();
field.setValue(value, m_inserting);
field.validateValueNoDirect();
rowData[i] = field.getValue();
}
}
@ -3563,6 +3571,8 @@ public class GridTable extends AbstractTableModel
//https://jdbc.postgresql.org/documentation/head/query.html#query-with-cursor
String trxName = m_virtual ? Trx.createTrxName("Loader") : null;
trx = trxName != null ? Trx.get(trxName, true) : null;
if (trx != null)
trx.setDisplayName(getClass().getName()+"_openResultSet");
// open Statement (closed by Loader.close)
try
{

View File

@ -453,15 +453,17 @@ public class MBankStatement extends X_C_BankStatement implements DocAction
MPeriod.testPeriodOpen(getCtx(), getStatementDate(), MDocType.DOCBASETYPE_BankStatement, getAD_Org_ID());
MFactAcct.deleteEx(Table_ID, getC_BankStatement_ID(), get_TrxName());
}
//Added Lines by AZ Goodwill
//Restore Bank Account Balance
MBankAccount ba = getBankAccount();
ba.load(get_TrxName());
ba.setCurrentBalance(ba.getCurrentBalance().subtract(getStatementDifference()));
ba.saveEx();
//End of Added Lines
if (isProcessed()) {
//Added Lines by AZ Goodwill
//Restore Bank Account Balance
MBankAccount ba = getBankAccount();
ba.load(get_TrxName());
ba.setCurrentBalance(ba.getCurrentBalance().subtract(getStatementDifference()));
ba.saveEx();
//End of Added Lines
}
// Set lines to 0
MBankStatementLine[] lines = getLines(true);
for (int i = 0; i < lines.length; i++)

View File

@ -163,6 +163,7 @@ public class MConversionRate extends X_C_Conversion_Rate
String trxName = Trx.createTrxName();
Trx trx = Trx.get(trxName, true);
trx.setDisplayName(MConversionRate.class.getName()+"_setRate");
Properties ctx = Env.getCtx();
MCurrency curFrom = MCurrency.get(ctx, CurFrom_ISO);
if (curFrom==null) throw new Exception("Invalid currency " + CurFrom_ISO);

View File

@ -638,6 +638,7 @@ public class MCost extends X_M_Cost
{
trxNameUsed = Trx.createTrxName("Cost");
trx = Trx.get(trxNameUsed, true);
trx.setDisplayName(MCost.class.getName()+"_create");
}
boolean success = true;
// For all Products

View File

@ -1263,10 +1263,11 @@ public class MCostDetail extends X_M_CostDetail
}
else if (addition)
{
if (getM_ProductionLine().getM_Production().getReversal_ID() < 0)
cost.add(amt, qty);
MProductionLine productionLine = getM_ProductionLine_ID() > 0 ? new MProductionLine(getCtx(), getM_ProductionLine_ID(), get_TrxName()) : null;
if (productionLine != null && productionLine.getProductionReversalId() > 0)
cost.setCurrentQty(cost.getCurrentQty().add(qty));
else
cost.setCurrentQty(cost.getCurrentQty().add(qty));
cost.add(amt, qty);
// Initial
if (cost.getCurrentCostPrice().signum() == 0

View File

@ -1428,20 +1428,10 @@ public class MInOut extends X_M_InOut implements DocAction
if (mtrx == null)
{
Timestamp dateMPolicy= null;
MStorageOnHand[] storages = null;
if (sLine.getMovementQty().compareTo(Env.ZERO) > 0) {
// Find Date Material Policy bases on ASI
storages = MStorageOnHand.getWarehouse(getCtx(), 0,
sLine.getM_Product_ID(), sLine.getM_AttributeSetInstance_ID(), null,
MClient.MMPOLICY_FiFo.equals(product.getMMPolicy()), false,
sLine.getM_Locator_ID(), get_TrxName());
} else {
//Case of reversal
storages = MStorageOnHand.getWarehouse(getCtx(), 0,
sLine.getM_Product_ID(), sLine.getM_AttributeSetInstance_ID(), null,
MClient.MMPOLICY_FiFo.equals(product.getMMPolicy()), false,
sLine.getM_Locator_ID(), get_TrxName());
}
MStorageOnHand[] storages = MStorageOnHand.getWarehouse(getCtx(), 0,
sLine.getM_Product_ID(), sLine.getM_AttributeSetInstance_ID(), null,
MClient.MMPOLICY_FiFo.equals(product.getMMPolicy()), false,
sLine.getM_Locator_ID(), get_TrxName());
for (MStorageOnHand storage : storages) {
if (storage.getQtyOnHand().compareTo(sLine.getMovementQty()) >= 0) {
dateMPolicy = storage.getDateMaterialPolicy();

View File

@ -778,6 +778,7 @@ public class MLocation extends X_C_Location implements Comparator<Object>
setErrorMessage(null);
Trx trx = Trx.get(Trx.createTrxName("avt-"), true);
trx.setDisplayName(getClass().getName()+"_processOnline");
boolean ok = false;
try
{

View File

@ -854,7 +854,11 @@ public class MLookupFactory
for (int i = 0; i < size; i++)
{
if (i > 0)
displayColumn.append(" ||'_'|| " );
{
displayColumn.append(" ||'")
.append(MSysConfig.getValue(MSysConfig.IDENTIFIER_SEPARATOR, "_", Env.getAD_Client_ID(Env.getCtx())))
.append("'|| " );
}
LookupDisplayColumn ldc = (LookupDisplayColumn)list.get(i);
StringBuilder msg = new StringBuilder().append(TableName).append(".").append(ldc.ColumnName);
String columnSQL = ldc.IsVirtual ? ldc.ColumnSQL : msg.toString();

View File

@ -456,8 +456,11 @@ public class MMatchPO extends X_M_MatchPO
}
if (iLine != null)
mpo.setC_InvoiceLine_ID(iLine);
if (sLine != null)
if (sLine != null){
mpo.setM_InOutLine_ID(sLine.getM_InOutLine_ID());
if (!mpo.isPosted())
mpo.setDateAcct(sLine.getParent().getDateAcct());
}
if (!mpo.save())
{

View File

@ -283,6 +283,7 @@ public class MPackage extends X_M_Package
setErrorMessage(null);
Trx trx = Trx.get(Trx.createTrxName("spt-"), true);
trx.setDisplayName(getClass().getName()+"_processOnline");
boolean ok = false;
try
{

View File

@ -279,6 +279,7 @@ public class MPaySelectionCheck extends X_C_PaySelectionCheck
localTrx = true;
trxName = Trx.createTrxName("ConfirmPrintSingle");
trx = Trx.get(trxName, true);
trx.setDisplayName(MPaySelectionCheck.class.getName()+"_confirmPrint");
check.set_TrxName(trxName);
}
try {
@ -397,6 +398,7 @@ public class MPaySelectionCheck extends X_C_PaySelectionCheck
localTrx = true;
trxName = Trx.createTrxName("ConfirmPrintMulti");
trx = Trx.get(trxName, true);
trx.setDisplayName(MPaySelectionCheck.class.getName()+"_confirmPrints");
}
int lastDocumentNo = 0;
try {

View File

@ -565,6 +565,7 @@ public class MPayment extends X_C_Payment
setIsApproved(approved);
Trx trx = Trx.get(Trx.createTrxName("ppt-"), true);
trx.setDisplayName(getClass().getName()+"_processOnline");
try
{

View File

@ -296,7 +296,7 @@ public class MPeriod extends X_C_Period
idxdate = po.get_ColumnIndex("DateAcct");
}
if (idxdate < 0) {
s_log.warning("Could not find DateAcct for " + table.getTableName());
if (s_log.isLoggable(Level.INFO)) s_log.info("Could not find DateAcct for " + table.getTableName());
return true;
}
Timestamp dateAcct = null;

View File

@ -103,15 +103,14 @@ public class MProduction extends X_M_Production implements DocAction {
StringBuilder errors = new StringBuilder();
int processed = 0;
//IDEMPIERE-3107 Check if End Product in Production Lines exist
if(!isHaveEndProduct(getLines())) {
m_processMsg = "Production does not contain End Product";
return DocAction.STATUS_Invalid;
}
if (!isUseProductionPlan()) {
MProductionLine[] lines = getLines();
//IDEMPIERE-3107 Check if End Product in Production Lines exist
if(!isHaveEndProduct(lines)) {
m_processMsg = "Production does not contain End Product";
return DocAction.STATUS_Invalid;
}
errors.append(processLines(lines));
if (errors.length() > 0) {
m_processMsg = errors.toString();
@ -123,6 +122,13 @@ public class MProduction extends X_M_Production implements DocAction {
List<MProductionPlan> plans = planQuery.setParameters(getM_Production_ID()).list();
for(MProductionPlan plan : plans) {
MProductionLine[] lines = plan.getLines();
//IDEMPIERE-3107 Check if End Product in Production Lines exist
if(!isHaveEndProduct(lines)) {
m_processMsg = String.format("Production plan (line %1$d id %2$d) does not contain End Product", plan.getLine(), plan.get_ID());
return DocAction.STATUS_Invalid;
}
if (lines.length > 0) {
errors.append(processLines(lines));
if (errors.length() > 0) {

View File

@ -78,7 +78,8 @@ public class MProductionLine extends X_M_ProductionLine {
* @return "" for success, error string if failed
*/
public String createTransactions(Timestamp date, boolean mustBeStocked) {
if (getParent().getReversal_ID() <= 0 )
int reversalId = getProductionReversalId ();
if (reversalId <= 0 )
{
// delete existing ASI records
int deleted = deleteMA();
@ -106,7 +107,7 @@ public class MProductionLine extends X_M_ProductionLine {
if (log.isLoggable(Level.FINEST)) log.log(Level.FINEST, "asi Description is: " + asiString);
// create transactions for finished goods
if ( getM_Product_ID() == getEndProduct_ID()) {
if (getParent().getReversal_ID() <= 0 && isAutoGenerateLot && getM_AttributeSetInstance_ID() == 0)
if (reversalId <= 0 && isAutoGenerateLot && getM_AttributeSetInstance_ID() == 0)
{
asi = MAttributeSetInstance.generateLot(getCtx(), (MProduct)getM_Product(), get_TrxName());
setM_AttributeSetInstance_ID(asi.getM_AttributeSetInstance_ID());
@ -394,16 +395,16 @@ public class MProductionLine extends X_M_ProductionLine {
return true;
}
/**
* Get Parent
* @return parent
* Get Reversal_ID of parent production
* @return Reversal_ID
*/
public MProduction getParent() {
if (productionParent == null)
productionParent = new MProduction (getCtx(), getM_Production_ID(), get_TrxName());
return productionParent;
} // getParent
public int getProductionReversalId() {
if (getM_Production_ID() > 0)
return DB.getSQLValueEx(get_TrxName(), "SELECT Reversal_ID FROM M_Production WHERE M_Production_ID=?", getM_Production_ID());
else
return DB.getSQLValueEx(get_TrxName(), "SELECT p.Reversal_ID FROM M_ProductionPlan pp INNER JOIN M_Production p ON (pp.M_Production_ID = p.M_Production_ID) WHERE pp.M_ProductionPlan_ID=?", getM_ProductionPlan_ID());
}
/**
*

View File

@ -116,6 +116,7 @@ public final class MSetup
String adminEmail, String userEmail, boolean isSetInitialPassword)
{
log.info(clientName);
m_trx.setDisplayName(getClass().getName()+"_createClient");
m_trx.start();
// info header

View File

@ -42,7 +42,7 @@ public class MSysConfig extends X_AD_SysConfig
/**
*
*/
private static final long serialVersionUID = -3599797130058840418L;
private static final long serialVersionUID = -5006794875155447942L;
public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION";
public static final String ALERT_SEND_ATTACHMENT_AS_XLS = "ALERT_SEND_ATTACHMENT_AS_XLS";
@ -59,6 +59,9 @@ public class MSysConfig extends X_AD_SysConfig
public static final String APPLICATION_MAIN_VERSION = "APPLICATION_MAIN_VERSION";
public static final String APPLICATION_MAIN_VERSION_SHOWN = "APPLICATION_MAIN_VERSION_SHOWN";
public static final String APPLICATION_OS_INFO_SHOWN = "APPLICATION_OS_INFO_SHOWN";
public static final String AUTOMATIC_PACKIN_PROCESSING = "AUTOMATIC_PACKIN_PROCESSING";
public static final String AUTOMATIC_PACKIN_TIMEOUT = "AUTOMATIC_PACKIN_TIMEOUT";
public static final String AUTOMATIC_PACKIN_RETRIES = "AUTOMATIC_PACKIN_RETRIES";
public static final String ATTACH_EMBEDDED_2PACK = "ATTACH_EMBEDDED_2PACK";
public static final String BACKGROUND_JOB_ALLOWED = "BACKGROUND_JOB_ALLOWED";
public static final String BACKGROUND_JOB_BY_DEFAULT = "BACKGROUND_JOB_BY_DEFAULT";
@ -85,6 +88,7 @@ public class MSysConfig extends X_AD_SysConfig
public static final String GRIDTABLE_LOAD_TIMEOUT_IN_SECONDS = "GRIDTABLE_LOAD_TIMEOUT_IN_SECONDS";
public static final String HTML_REPORT_THEME = "HTML_REPORT_THEME";
public static final String IBAN_VALIDATION = "IBAN_VALIDATION" ;
public static final String IDENTIFIER_SEPARATOR = "IDENTIFIER_SEPARATOR" ;
public static final String Invoice_ReverseUseNewNumber = "Invoice_ReverseUseNewNumber";
public static final String JASPER_SWAP_MAX_PAGES = "JASPER_SWAP_MAX_PAGES";
public static final String LASTRUN_RECORD_COUNT = "LASTRUN_RECORD_COUNT";
@ -132,6 +136,7 @@ public class MSysConfig extends X_AD_SysConfig
public static final String SYSTEM_IN_MAINTENANCE_MODE = "SYSTEM_IN_MAINTENANCE_MODE";
public static final String SYSTEM_INSERT_CHANGELOG = "SYSTEM_INSERT_CHANGELOG";
public static final String SYSTEM_NATIVE_SEQUENCE = "SYSTEM_NATIVE_SEQUENCE";
public static final String TRACE_ALL_TRX_CONNECTION_GET = "TRACE_ALL_TRX_CONNECTION_GET";
public static final String TWOPACK_COMMIT_DDL = "2PACK_COMMIT_DDL";
public static final String TWOPACK_HANDLE_TRANSLATIONS = "2PACK_HANDLE_TRANSLATIONS";
public static final String USE_EMAIL_FOR_LOGIN = "USE_EMAIL_FOR_LOGIN";

View File

@ -89,6 +89,8 @@ public class Obscure extends Object
public static final String OBSCURETYPE_ObscureAlphaNumericButFirstLast4 = "A44";
/** Obscure AlphaNumeric but last 4 = A04 */
public static final String OBSCURETYPE_ObscureAlphaNumericButLast4 = "A04";
/** Obscure by max 10 asterisk characters, use for EncryptedField - internal, not in the list of obscure type field */
public static final String OBSCURETYPE_ObscureMaskMax10Asterisk = "AA";
/** Obscure Type */
private String m_type = OBSCURETYPE_ObscureDigitsButLast4;
@ -103,13 +105,18 @@ public class Obscure extends Object
*/
public void setType (String obscureType)
{
if (obscureType == null || obscureType.equals("904") || obscureType.equals("944") || obscureType.equals("A44") || obscureType.equals("A04"))
if ( obscureType == null
|| OBSCURETYPE_ObscureDigitsButLast4.equals(obscureType)
|| OBSCURETYPE_ObscureDigitsButFirstLast4.equals(obscureType)
|| OBSCURETYPE_ObscureAlphaNumericButFirstLast4.equals(obscureType)
|| OBSCURETYPE_ObscureAlphaNumericButLast4.equals(obscureType)
|| OBSCURETYPE_ObscureMaskMax10Asterisk.equals(obscureType))
{
m_type = obscureType;
m_obscuredValue = null;
return;
}
throw new IllegalArgumentException ("ObscureType Invalid value - Reference_ID=291 - 904 - 944 - A44 - A04");
throw new IllegalArgumentException ("ObscureType Invalid value - Reference_ID=291 - 904 - 944 - A44 - A04 - AA");
} // setType
/**
@ -140,6 +147,17 @@ public class Obscure extends Object
m_obscuredValue = null;
} // setClearValue
/**
* Get Obscured Value
* @param clearValue The clearValue to set.
* @param maxlength maximum length of the obscured value
* @return Returns the obscuredValue.
*/
public String getObscuredValue(String clearValue, int maxlength) {
setClearValue(clearValue);
return getObscuredValue(maxlength);
}
/**
* Get Obscured Value
* @param clearValue The clearValue to set.
@ -151,6 +169,19 @@ public class Obscure extends Object
return getObscuredValue();
} // getObscuredValue
/**
* Get Obscured Value with a max length
* @param maxlength maximum length of the obscured value
* @return Returns the obscuredValue.
*/
public String getObscuredValue(int maxlength) {
String obs = getObscuredValue();
if (maxlength > 0 && obs.length() > maxlength) {
obs = obs.substring(0, maxlength);
}
return obs;
}
/**
* Get Obscured Value
* @return Returns the obscuredValue.
@ -161,6 +192,11 @@ public class Obscure extends Object
return m_obscuredValue;
if (m_clearValue == null || m_clearValue.length() == 0)
return m_clearValue;
if (OBSCURETYPE_ObscureMaskMax10Asterisk.equals(m_type)){
return "**********";
}
//
boolean alpha = m_type.charAt(0) == 'A';
int clearStart = Integer.parseInt(m_type.substring(1,2));
@ -198,5 +234,4 @@ public class Obscure extends Object
System.out.println (Obscure.obscure("1a2b3c4d5e6f7g8h9"));
} // main
} // Obscrure
} // Obscure

View File

@ -2047,6 +2047,8 @@ public abstract class PO
l_trxname.setLength(23);
m_trxName = Trx.createTrxName(l_trxname.toString());
localTrx = Trx.get(m_trxName, true);
localTrx.setDisplayName(getClass().getName()+"_save");
localTrx.getConnection();
}
else
{
@ -3171,6 +3173,8 @@ public abstract class PO
{
localTrxName = Trx.createTrxName("POdel");
localTrx = Trx.get(localTrxName, true);
localTrx.setDisplayName(getClass().getName()+"_delete");
localTrx.getConnection();
m_trxName = localTrxName;
}
else

View File

@ -264,6 +264,7 @@ public class CreateForeignKey extends SvrProcess {
Trx trx = null;
try {
trx = Trx.get(Trx.createTrxName("CreateForeignKey"), true);
trx.setDisplayName(getClass().getName()+"_process_dropConstraint");
int rvalue = DB.executeUpdate(sql.toString(), (Object[]) null, true, trx.getTrxName());
addLog(0, null, new BigDecimal(rvalue), sql.toString());
} catch (Exception e) {
@ -302,6 +303,7 @@ public class CreateForeignKey extends SvrProcess {
Trx trx = null;
try {
trx = Trx.get(Trx.createTrxName("CreateForeignKey"), true);
trx.setDisplayName(getClass().getName()+"_process_addConstraint");
int rvalue = DB.executeUpdate(sql.toString(), (Object[]) null, true, trx.getTrxName());
addLog(0, null, new BigDecimal(rvalue), sql.toString());
if (rvalue == -1)

View File

@ -192,6 +192,7 @@ public class CreateTableIndex extends SvrProcess {
addLog(Msg.getMsg(getCtx(), "CreateTableIndexCreateTableIndex") + dbTableIndex.indexName);
Trx trx = Trx.get(Trx.createTrxName("CreateTableIndex"), true);
trx.setDisplayName(getClass().getName()+"_process_createMTableIndex");
try {
MTableIndex tableIndex = new MTableIndex(getCtx(), 0, get_TrxName());
tableIndex.setAD_Table_ID(table.getAD_Table_ID());
@ -244,6 +245,7 @@ public class CreateTableIndex extends SvrProcess {
addLog(Msg.getMsg(getCtx(), "CreateTableIndexValidateTableIndex") + tableIndex.getName());
addLog(tableIndex.getAD_TableIndex_ID(), null, null, tableIndex.toString(), tableIndex.get_Table_ID(), tableIndex.getAD_TableIndex_ID());
Trx trx = Trx.get(Trx.createTrxName("ValidateTableIndex"), true);
trx.setDisplayName(getClass().getName()+"_process_validateTableIndex");
try {
String result = TableIndexValidate.validateTableIndex(getCtx(), tableIndex, trx.getTrxName(), getProcessInfo());
addLog(result);

View File

@ -124,7 +124,10 @@ public abstract class SvrProcess implements ProcessCall
//*** Trx
boolean localTrx = m_trx == null;
if (localTrx)
{
m_trx = Trx.get(Trx.createTrxName("SvrProcess"), true);
m_trx.setDisplayName(getClass().getName()+"_startProcess");
}
//
ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
ClassLoader processLoader = getClass().getClassLoader();

View File

@ -1444,7 +1444,7 @@ public class Login
user.setFailedLoginCount(0);
user.setDateLastLogin(new Timestamp(now));
if (!user.save())
log.severe("Failed to update user record with date last login");
log.severe("Failed to update user record with date last login (" + user.getName() + " / clientID = " + user.getAD_Client_ID() + ")");
}
}
else if (validButLocked)

View File

@ -16,6 +16,8 @@
*****************************************************************************/
package org.compiere.util;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Savepoint;
@ -32,6 +34,7 @@ import java.util.logging.Level;
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.exceptions.DBException;
import org.compiere.Adempiere;
import org.compiere.model.MSysConfig;
import org.compiere.model.PO;
/**
@ -84,6 +87,10 @@ public class Trx
private static final Trx.TrxMonitor s_monitor = new Trx.TrxMonitor();
private List<TrxEventListener> listeners = new ArrayList<TrxEventListener>();
protected Exception trace;
private String m_displayName;
public static void startTrxMonitor()
{
@ -187,6 +194,8 @@ public class Trx
}
if (!isActive())
start();
if (MSysConfig.getBooleanValue(MSysConfig.TRACE_ALL_TRX_CONNECTION_GET, false))
trace = new Exception();
return m_connection;
} // getConnection
@ -208,6 +217,7 @@ public class Trx
{
log.log(Level.SEVERE, "connection", e);
}
trace = new Exception();
} // setConnection
/**
@ -470,6 +480,7 @@ public class Trx
}
}
m_connection = null;
trace = null;
m_active = false;
fireAfterCloseEvent();
log.config(m_trxName);
@ -538,7 +549,7 @@ public class Trx
public String toString()
{
StringBuilder sb = new StringBuilder("Trx[");
sb.append(getTrxName())
sb.append(getDisplayName())
.append(",Active=").append(isActive())
.append("]");
return sb.toString();
@ -664,6 +675,31 @@ public class Trx
}
}
public String getStrackTrace()
{
if (trace != null)
{
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
trace.printStackTrace(printWriter);
return stringWriter.getBuffer().toString();
}
else
{
return "";
}
}
public String getDisplayName()
{
return m_displayName != null ? m_displayName : m_trxName;
}
public void setDisplayName(String displayName)
{
m_displayName = displayName;
}
static class TrxMonitor implements Runnable
{
@ -681,6 +717,10 @@ public class Trx
if (since > trxs[i].getTimeout() * 1000)
{
trxs[i].log.log(Level.WARNING, "Transaction timeout. Name="+trxs[i].getTrxName() + ", timeout(sec)="+(since / 1000));
if (trxs[i].trace != null)
{
trxs[i].log.log(Level.WARNING, "Transaction timeout. Trace:\n" + trxs[i].getStrackTrace());
}
trxs[i].rollbackAndCloseOnTimeout();
}
}
@ -695,4 +735,21 @@ public class Trx
;
}
@Override
protected void finalize() throws Throwable {
if (m_connection != null && trace != null) {
final Trx me = this;
Adempiere.getThreadPoolExecutor().schedule(new Runnable() {
@Override
public void run() {
if (me.m_connection != null && me.trace != null) {
log.log(Level.WARNING, "Trx Not Close: " + me.getStrackTrace());
me.trace = null;
me.close();
}
}
}, 2, TimeUnit.SECONDS);
}
super.finalize();
}
} // Trx

View File

@ -844,6 +844,8 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
}
trx = Trx.get(get_TrxName(), true);
if (localTrx)
trx.setDisplayName(getClass().getName()+"_run");
Savepoint savepoint = null;

View File

@ -678,7 +678,10 @@ public class MWorkflow extends X_AD_Workflow
MWFProcess retValue = null;
Trx localTrx = null;
if (trxName == null)
{
localTrx = Trx.get(Trx.createTrxName("WFP"), true);
localTrx.setDisplayName(getClass().getName()+"_start");
}
try
{
retValue = new MWFProcess (this, pi, trxName != null ? trxName : localTrx.getTrxName());

View File

@ -77,6 +77,7 @@ public class OrderTest implements Runnable
for (int i = 0; i < m_numberOrders; i++)
{
Trx trx = Trx.get(Trx.createTrxName("Test" + m_no + "_" + i),true);
trx.setDisplayName(getClass().getName()+"_run");
trx.start();
//
MOrder order = new MOrder(Env.getCtx(),0,trx.getTrxName());

View File

@ -13,8 +13,6 @@ package org.adempiere.pipo.srv;
import java.io.File;
import java.sql.Timestamp;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import org.adempiere.base.IDictionaryService;
@ -32,11 +30,8 @@ public class PipoDictionaryService implements IDictionaryService {
CLogger logger = CLogger.getCLogger(PipoDictionaryService.class.getName());
private final Semaphore semaphore;
public PipoDictionaryService() {
super();
semaphore = new Semaphore(1, true);
}
@Override
@ -49,13 +44,8 @@ public class PipoDictionaryService implements IDictionaryService {
X_AD_Package_Imp_Proc adPackageImp = null;
PackIn packIn = null;
try {
try {
semaphore.tryAcquire(120, TimeUnit.SECONDS);
} catch (InterruptedException e) {
semaphore.release();
semaphore.acquire();
}
trxName = Trx.createTrxName("PipoDS");
Trx.get(trxName, true).setDisplayName(getClass().getName()+"_merge");
packIn = new PackIn();
packIn.setPackageName(context.getBundle().getSymbolicName());
@ -65,11 +55,11 @@ public class PipoDictionaryService implements IDictionaryService {
//get package version from file name suffix or bundle header
String packageVersion = null;
String fileName = packageFile.getName();
int versionSeparatorPos = fileName.lastIndexOf("_");
int versionSeparatorPos = fileName.lastIndexOf("2Pack_");
if (versionSeparatorPos > 0) {
int dotPos = fileName.lastIndexOf(".");
if (dotPos > 0 && dotPos > versionSeparatorPos) {
String version = fileName.substring(versionSeparatorPos+1, dotPos);
String version = fileName.substring(versionSeparatorPos+"2Pack_".length(), dotPos);
if (version.split("[.]").length == 3) {
packageVersion = version;
}
@ -105,7 +95,7 @@ public class PipoDictionaryService implements IDictionaryService {
adPackageImp.setDateProcessed(new Timestamp(System.currentTimeMillis()));
adPackageImp.setP_Msg(msg);
Trx.get(trxName, false).commit();
Trx.get(trxName, false).commit(true);
if (logger.isLoggable(Level.INFO)) logger.info("commit " + trxName);
} catch (Exception e) {
adPackageImp.setP_Msg(e.getLocalizedMessage());
@ -116,7 +106,6 @@ public class PipoDictionaryService implements IDictionaryService {
try {
Trx.get(trxName, false).close();
} catch (Exception e) {}
semaphore.release();
adPackageImp.save(); // ignoring exceptions
if (adPackageImp != null && packIn != null) {

View File

@ -312,8 +312,8 @@ public class PackInHandler extends DefaultHandler {
}
packIn.getNotifier().addStatusLine(packageStatus);
updPackageImpNoTrx();
updPackageImpInstNoTrx();
updPackageImp(m_ctx.trx.getTrxName()); // do not set success until commit on PackInProcess, still can fail
updPackageImpInst(m_ctx.trx.getTrxName());
//reset
setupHandlers();
@ -326,31 +326,31 @@ public class PackInHandler extends DefaultHandler {
} catch (RuntimeException re) {
packageStatus = "Import Failed";
packIn.getNotifier().addStatusLine(packageStatus);
updPackageImpNoTrx();
updPackageImp(null);
throw re;
} catch (SAXException se) {
packageStatus = "Import Failed";
packIn.getNotifier().addStatusLine(packageStatus);
updPackageImpNoTrx();
updPackageImp(null);
throw se;
}
}
}
} // endElement
private void updPackageImpNoTrx() {
private void updPackageImp(String trxName) {
// NOTE: Updating out of model to avoid change log insert that can cause locks
//Update package history log with package status
DB.executeUpdateEx("UPDATE AD_Package_Imp SET Processed=?, PK_Status=?, UpdatedBy=?, Updated=SYSDATE WHERE AD_Package_Imp_ID=?",
new Object[] {"Y", packageStatus, Env.getAD_User_ID(m_ctx.ctx), AD_Package_Imp_ID},
null);
trxName);
}
private void updPackageImpInstNoTrx() {
private void updPackageImpInst(String trxName) {
// NOTE: Updating out of model to avoid change log insert that can cause locks
DB.executeUpdateEx("UPDATE AD_Package_Imp_Inst SET PK_Status=?, UpdatedBy=?, Updated=SYSDATE WHERE AD_Package_Imp_Inst_ID=?",
new Object[] {packageStatus, Env.getAD_User_ID(m_ctx.ctx), AD_Package_Imp_Inst_ID},
null);
trxName);
}
private void processDeferElements() throws SAXException {

View File

@ -41,6 +41,7 @@ Import-Package: org.adempiere.base,
org.apache.xerces.xs.datatypes;version="2.9.0",
org.apache.xml.serialize;version="2.9.0",
org.compiere,
org.compiere.db,
org.compiere.model,
org.compiere.util,
org.osgi.framework;version="1.5.0",

View File

@ -0,0 +1,108 @@
/******************************************************************************
* Copyright (C) 2017 Diego Ruiz *
* Copyright (C) 2017 Trek Global *
* 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.plugin.utils;
import java.io.File;
import java.util.logging.Level;
import org.adempiere.base.IDictionaryService;
import org.compiere.model.MSysConfig;
import org.compiere.model.PO;
import org.compiere.model.Query;
import org.compiere.model.X_AD_Package_Imp;
import org.compiere.util.AdempiereSystemError;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Trx;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;
public abstract class AbstractActivator implements BundleActivator, ServiceTrackerCustomizer<IDictionaryService, IDictionaryService> {
protected final static CLogger logger = CLogger.getCLogger(AbstractActivator.class.getName());
protected BundleContext context;
protected ServiceTracker<IDictionaryService, IDictionaryService> serviceTracker;
protected IDictionaryService service;
private String trxName = "";
protected boolean merge(File zipfile, String version) throws Exception {
boolean success = false;
if (!installedPackage(version)) {
service.merge(context, zipfile);
success = true;
} else {
logger.log(Level.SEVERE, "The file was already installed: " + zipfile.getName());
}
return success;
}
protected boolean installedPackage(String version) {
StringBuilder where = new StringBuilder("Name=? AND PK_Status = 'Completed successfully'");
Object[] params;
if (version != null) {
where.append(" AND PK_Version LIKE ?");
params = new Object[] { getName(), version + "%" };
} else {
params = new Object[] {getName()};
}
Query q = new Query(Env.getCtx(), X_AD_Package_Imp.Table_Name,
where.toString(), null);
q.setParameters(params);
return q.first() != null;
}
public abstract String getName();
public boolean getDBLock() throws AdempiereSystemError {
int timeout = MSysConfig.getIntValue(MSysConfig.AUTOMATIC_PACKIN_TIMEOUT, 120);
int maxAttempts = MSysConfig.getIntValue(MSysConfig.AUTOMATIC_PACKIN_RETRIES, 5);
boolean lockAcquired = false;
while(maxAttempts > 0 && !lockAcquired) {
maxAttempts --;
if (getDBLock(timeout))
lockAcquired = true;
}
return lockAcquired;
}
public void releaseLock() {
Trx.get(trxName, false).close();
}
private boolean getDBLock(int timeout) throws AdempiereSystemError {
return DB.getDatabase().forUpdate(getLockPO(), timeout);
}
private PO getLockPO() throws AdempiereSystemError {
MSysConfig sysconfig = new Query(Env.getCtx(), MSysConfig.Table_Name,
"Name=? AND AD_Client_ID=0", null)
.setParameters(MSysConfig.AUTOMATIC_PACKIN_PROCESSING)
.firstOnly();
if (sysconfig == null) {
throw new AdempiereSystemError(MSysConfig.AUTOMATIC_PACKIN_PROCESSING + " SysConfig does not exist");
}
trxName = Trx.createTrxName("ActSysTrx");
Trx.get(trxName, true).setDisplayName(getClass().getName()+"_getLockPO");
sysconfig.set_TrxName(trxName);
return sysconfig;
}
}

View File

@ -14,20 +14,16 @@ import org.compiere.model.Query;
import org.compiere.model.ServerStateChangeEvent;
import org.compiere.model.ServerStateChangeListener;
import org.compiere.model.X_AD_Package_Imp;
import org.compiere.util.AdempiereSystemError;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;
public class AdempiereActivator implements BundleActivator, ServiceTrackerCustomizer<IDictionaryService, IDictionaryService> {
public class AdempiereActivator extends AbstractActivator {
protected final static CLogger logger = CLogger.getCLogger(AdempiereActivator.class.getName());
private BundleContext context;
private ServiceTracker<IDictionaryService, IDictionaryService> serviceTracker;
private IDictionaryService service;
@Override
public void start(BundleContext context) throws Exception {
@ -53,27 +49,7 @@ public class AdempiereActivator implements BundleActivator, ServiceTrackerCustom
private void installPackage() {
// e.g. 1.0.0.qualifier, check only the "1.0.0" part
String version = getVersion();
if (version != null)
{
int count = 0;
int index = -1;
for(int i = 0; i < version.length(); i++)
{
if(version.charAt(i) == '.')
count++;
if (count == 3)
{
index = i;
break;
}
}
if (index == -1)
index = version.length();
version = version.substring(0, index);
}
String version = getPKVersion();
String where = "Name=? AND PK_Version LIKE ?";
Query q = new Query(Env.getCtx(), X_AD_Package_Imp.Table_Name,
@ -81,15 +57,49 @@ public class AdempiereActivator implements BundleActivator, ServiceTrackerCustom
q.setParameters(new Object[] { getName(), version + "%" });
X_AD_Package_Imp pkg = q.first();
if (pkg == null) {
System.out.println("Installing " + getName() + " " + version + " ...");
packIn();
install();
System.out.println(getName() + " " + version + " installed.");
try {
if (getDBLock()) {
System.out.println("Installing " + getName() + " " + version + " ...");
packIn();
install();
releaseLock();
System.out.println(getName() + " " + version + " installed.");
} else {
logger.log(Level.SEVERE, "Could not acquire the DB lock to install:" + getName());
}
} catch (AdempiereSystemError e) {
e.printStackTrace();
}
} else {
if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + version + " was installed: "
+ pkg.getCreated());
}
}
private String getPKVersion() {
String version = getVersion();
if (version != null)
{
int count = 0;
int index = -1;
for(int i = 0; i < version.length(); i++)
{
if(version.charAt(i) == '.')
count++;
if (count == 3)
{
index = i;
break;
}
}
if (index == -1)
index = version.length();
version = version.substring(0, index);
}
return version;
}
protected void packIn() {
URL packout = context.getBundle().getEntry("/META-INF/2Pack.zip");
@ -106,7 +116,7 @@ public class AdempiereActivator implements BundleActivator, ServiceTrackerCustom
zipstream.write(buffer, 0, read);
}
// call 2pack
service.merge(context, zipfile);
merge(zipfile, getPKVersion());
} catch (Throwable e) {
logger.log(Level.SEVERE, "Pack in failed.", e);
}

View File

@ -32,26 +32,22 @@ import org.compiere.model.Query;
import org.compiere.model.ServerStateChangeEvent;
import org.compiere.model.ServerStateChangeListener;
import org.compiere.model.X_AD_Package_Imp;
import org.compiere.util.AdempiereSystemError;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.compiere.util.Util;
import org.osgi.framework.BundleActivator;
import org.compiere.util.Trx;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;
/**
*
* @author hengsin
*
*/
public class Incremental2PackActivator implements BundleActivator, ServiceTrackerCustomizer<IDictionaryService, IDictionaryService> {
public class Incremental2PackActivator extends AbstractActivator {
protected final static CLogger logger = CLogger.getCLogger(Incremental2PackActivator.class.getName());
private BundleContext context;
private ServiceTracker<IDictionaryService, IDictionaryService> serviceTracker;
private IDictionaryService service;
@Override
public void start(BundleContext context) throws Exception {
@ -87,38 +83,24 @@ public class Incremental2PackActivator implements BundleActivator, ServiceTracke
}
private void installPackage() {
// e.g. 1.0.0.qualifier, check only the "1.0.0" part
String bundleVersionPart = getVersion();
String installedVersionPart = null;
String where = "Name=? AND PK_Status = 'Completed successfully'";
Query q = new Query(Env.getCtx(), X_AD_Package_Imp.Table_Name,
where.toString(), null);
q.setParameters(new Object[] { getName() });
List<X_AD_Package_Imp> pkgs = q.list();
if (pkgs != null && !pkgs.isEmpty()) {
for(X_AD_Package_Imp pkg : pkgs) {
String packageVersionPart = pkg.getPK_Version();
String[] part = packageVersionPart.split("[.]");
if (installedVersionPart == null) {
if (part.length > 3) {
installedVersionPart = part[0]+"."+part[1]+"."+part[2];
} else {
installedVersionPart = packageVersionPart;
}
} else {
Version installedVersion = new Version(installedVersionPart);
if (part.length > 3) {
packageVersionPart = part[0]+"."+part[1]+"."+part[2];
}
Version packageVersion = new Version(packageVersionPart);
if (packageVersion.compareTo(installedVersion) > 0) {
installedVersionPart = packageVersionPart;
}
}
String where = "Name=? AND PK_Status = 'Completed successfully'";
Query q = new Query(Env.getCtx(), X_AD_Package_Imp.Table_Name,
where.toString(), null);
q.setParameters(new Object[] { getName() });
List<X_AD_Package_Imp> pkgs = q.list();
List<String> installedVersions = new ArrayList<String>();
if (pkgs != null && !pkgs.isEmpty()) {
for(X_AD_Package_Imp pkg : pkgs) {
String packageVersionPart = pkg.getPK_Version();
String[] part = packageVersionPart.split("[.]");
if (part.length > 3 && (packageVersionPart.indexOf(".v") > 0 || packageVersionPart.indexOf(".qualifier") > 0)) {
packageVersionPart = part[0]+"."+part[1]+"."+part[2];
}
installedVersions.add(packageVersionPart);
}
packIn(installedVersionPart, bundleVersionPart);
afterPackIn();
}
packIn(installedVersions);
afterPackIn();
}
private static class TwoPackEntry {
@ -130,31 +112,73 @@ public class Incremental2PackActivator implements BundleActivator, ServiceTracke
}
}
protected void packIn(String installedVersionPart, String bundleVersionPart) {
protected void packIn(List<String> installedVersions) {
List<TwoPackEntry> list = new ArrayList<TwoPackEntry>();
//2Pack_1.0.0.zip, 2Pack_1.0.1.zip, etc
Enumeration<URL> urls = context.getBundle().findEntries("/META-INF", "2Pack_*.zip", false);
Version bundleVersion = new Version(bundleVersionPart);
if (!Util.isEmpty(installedVersionPart)) {
Version installedVersion = new Version(installedVersionPart);
while(urls.hasMoreElements()) {
URL u = urls.nextElement();
String version = extractVersionString(u);
Version packageVersion = new Version(version);
if (packageVersion.compareTo(bundleVersion) <= 0 && packageVersion.compareTo(installedVersion) > 0)
list.add(new TwoPackEntry(u, version));
}
} else {
while(urls.hasMoreElements()) {
URL u = urls.nextElement();
String version = extractVersionString(u);
Version packageVersion = new Version(version);
if (packageVersion.compareTo(bundleVersion) <= 0)
list.add(new TwoPackEntry(u, version));
}
while(urls.hasMoreElements()) {
URL u = urls.nextElement();
String version = extractVersionString(u);
list.add(new TwoPackEntry(u, version));
}
X_AD_Package_Imp firstImp = new Query(Env.getCtx(), X_AD_Package_Imp.Table_Name, "Name=? AND PK_Version=? AND PK_Status=?", null)
.setParameters(getName(), "0.0.0", "Completed successfully")
.setClient_ID()
.first();
if (firstImp == null) {
Trx trx = Trx.get(Trx.createTrxName(), true);
trx.setDisplayName(getClass().getName()+"_packIn");
try {
Env.getCtx().put("#AD_Client_ID", 0);
firstImp = new X_AD_Package_Imp(Env.getCtx(), 0, trx.getTrxName());
firstImp.setName(getName());
firstImp.setPK_Version("0.0.0");
firstImp.setPK_Status("Completed successfully");
firstImp.setProcessed(true);
firstImp.saveEx();
if (list.size() > 0 && installedVersions.size() > 0) {
List<TwoPackEntry> newList = new ArrayList<TwoPackEntry>();
for(TwoPackEntry entry : list) {
boolean patch = false;
for(String v : installedVersions) {
Version v1 = new Version(entry.version);
Version v2 = new Version(v);
int c = v2.compareTo(v1);
if (c == 0) {
patch = false;
break;
} else if (c > 0) {
patch = true;
}
}
if (patch) {
System.out.println("Patch Meta Data for " + getName() + " " + entry.version + " ...");
X_AD_Package_Imp pi = new X_AD_Package_Imp(Env.getCtx(), 0, trx.getTrxName());
pi.setName(getName());
pi.setPK_Version(entry.version);
pi.setPK_Status("Completed successfully");
pi.setProcessed(true);
pi.saveEx();
} else {
newList.add(entry);
}
}
list = newList;
}
trx.commit(true);
} catch (Exception e) {
trx.rollback();
logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
} finally {
trx.close();
}
}
Collections.sort(list, new Comparator<TwoPackEntry>() {
@Override
public int compare(TwoPackEntry o1, TwoPackEntry o2) {
@ -162,32 +186,43 @@ public class Incremental2PackActivator implements BundleActivator, ServiceTracke
}
});
for(TwoPackEntry entry : list) {
if (!packIn(entry.url)) {
// stop processing further packages if one fail
break;
try {
if (getDBLock()) {
for(TwoPackEntry entry : list) {
if (!installedVersions.contains(entry.version)) {
if (!packIn(entry.url)) {
// stop processing further packages if one fail
break;
}
}
}
releaseLock();
} else {
logger.log(Level.SEVERE, "Could not acquire the DB lock to install:" + getName());
}
} catch (AdempiereSystemError e) {
e.printStackTrace();
}
}
private String extractVersionString(URL u) {
String p = u.getPath();
int upos=p.lastIndexOf("_");
int upos=p.lastIndexOf("2Pack_");
int dpos=p.lastIndexOf(".");
String v = p.substring(upos+1, dpos);
String v = p.substring(upos+"2Pack_".length(), dpos);
return v;
}
protected boolean packIn(URL packout) {
if (packout != null && service != null) {
String path = packout.getPath();
String suffix = path.substring(path.lastIndexOf("_"));
String suffix = "_"+path.substring(path.lastIndexOf("2Pack_"));
System.out.println("Installing " + getName() + " " + path + " ...");
FileOutputStream zipstream = null;
try {
// copy the resource to a temporary file to process it with 2pack
InputStream stream = packout.openStream();
File zipfile = File.createTempFile(getName(), suffix);
File zipfile = File.createTempFile(getName()+"_", suffix);
zipstream = new FileOutputStream(zipfile);
byte[] buffer = new byte[1024];
int read;
@ -195,7 +230,8 @@ public class Incremental2PackActivator implements BundleActivator, ServiceTracke
zipstream.write(buffer, 0, read);
}
// call 2pack
service.merge(context, zipfile);
if (!merge(zipfile, extractVersionString(packout)))
return false;
} catch (Throwable e) {
logger.log(Level.SEVERE, "Pack in failed.", e);
return false;

View File

@ -0,0 +1,309 @@
/******************************************************************************
* Copyright (C) 2013 Heng Sin Low *
* Copyright (C) 2013 Trek Global *
* 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.plugin.utils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
import org.adempiere.base.IDictionaryService;
import org.adempiere.util.ServerContext;
import org.compiere.Adempiere;
import org.compiere.model.Query;
import org.compiere.model.ServerStateChangeEvent;
import org.compiere.model.ServerStateChangeListener;
import org.compiere.model.X_AD_Package_Imp;
import org.compiere.util.AdempiereSystemError;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.compiere.util.Util;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
/**
*
* @author hengsin
*
*/
public class Version2PackActivator extends AbstractActivator {
protected final static CLogger logger = CLogger.getCLogger(Version2PackActivator.class.getName());
@Override
public void start(BundleContext context) throws Exception {
this.context = context;
if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " starting...");
serviceTracker = new ServiceTracker<IDictionaryService, IDictionaryService>(context, IDictionaryService.class.getName(), this);
serviceTracker.open();
start();
if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " ready.");
}
public String getName() {
return context.getBundle().getSymbolicName();
}
public String getVersion() {
String version = (String) context.getBundle().getHeaders().get("Bundle-Version");
// e.g. 1.0.0.qualifier, check only the "1.0.0" part
String[] components = version.split("[.]");
StringBuilder versionBuilder = new StringBuilder(components[0]);
if (components.length >= 3) {
versionBuilder.append(".").append(components[1]).append(".").append(components[2]);
} else if (components.length == 2) {
versionBuilder.append(".").append(components[1]).append(".0");
} else {
versionBuilder.append(".0.0");
}
return versionBuilder.toString();
}
public String getDescription() {
return getName();
}
private void installPackage() {
// e.g. 1.0.0.qualifier, check only the "1.0.0" part
String bundleVersionPart = getVersion();
String installedVersionPart = null;
String where = "Name=? AND PK_Status = 'Completed successfully'";
Query q = new Query(Env.getCtx(), X_AD_Package_Imp.Table_Name,
where.toString(), null);
q.setParameters(new Object[] { getName() });
List<X_AD_Package_Imp> pkgs = q.list();
if (pkgs != null && !pkgs.isEmpty()) {
for(X_AD_Package_Imp pkg : pkgs) {
String packageVersionPart = pkg.getPK_Version();
String[] part = packageVersionPart.split("[.]");
if (installedVersionPart == null) {
if (part.length > 3) {
installedVersionPart = part[0]+"."+part[1]+"."+part[2];
} else {
installedVersionPart = packageVersionPart;
}
} else {
Version installedVersion = new Version(installedVersionPart);
if (part.length > 3) {
packageVersionPart = part[0]+"."+part[1]+"."+part[2];
}
Version packageVersion = new Version(packageVersionPart);
if (packageVersion.compareTo(installedVersion) > 0) {
installedVersionPart = packageVersionPart;
}
}
}
}
packIn(installedVersionPart, bundleVersionPart);
afterPackIn();
}
private static class TwoPackEntry {
private URL url;
private String version;
private TwoPackEntry(URL url, String version) {
this.url=url;
this.version = version;
}
}
protected void packIn(String installedVersionPart, String bundleVersionPart) {
List<TwoPackEntry> list = new ArrayList<TwoPackEntry>();
//2Pack_1.0.0.zip, 2Pack_1.0.1.zip, etc
Enumeration<URL> urls = context.getBundle().findEntries("/META-INF", "2Pack_*.zip", false);
Version bundleVersion = new Version(bundleVersionPart);
if (!Util.isEmpty(installedVersionPart)) {
Version installedVersion = new Version(installedVersionPart);
while(urls.hasMoreElements()) {
URL u = urls.nextElement();
String version = extractVersionString(u);
Version packageVersion = new Version(version);
if (packageVersion.compareTo(bundleVersion) <= 0 && packageVersion.compareTo(installedVersion) > 0)
list.add(new TwoPackEntry(u, version));
}
} else {
while(urls.hasMoreElements()) {
URL u = urls.nextElement();
String version = extractVersionString(u);
Version packageVersion = new Version(version);
if (packageVersion.compareTo(bundleVersion) <= 0)
list.add(new TwoPackEntry(u, version));
}
}
Collections.sort(list, new Comparator<TwoPackEntry>() {
@Override
public int compare(TwoPackEntry o1, TwoPackEntry o2) {
return new Version(o1.version).compareTo(new Version(o2.version));
}
});
try {
if (getDBLock()) {
for(TwoPackEntry entry : list) {
if (!packIn(entry.url)) {
// stop processing further packages if one fail
break;
}
}
releaseLock();
} else {
logger.log(Level.SEVERE, "Could not acquire the DB lock to install:" + getName());
}
} catch (AdempiereSystemError e) {
e.printStackTrace();
}
}
private String extractVersionString(URL u) {
String p = u.getPath();
int upos=p.lastIndexOf("_");
int dpos=p.lastIndexOf(".");
String v = p.substring(upos+1, dpos);
return v;
}
protected boolean packIn(URL packout) {
if (packout != null && service != null) {
String path = packout.getPath();
String suffix = "_"+path.substring(path.lastIndexOf("2Pack_"));
System.out.println("Installing " + getName() + " " + path + " ...");
FileOutputStream zipstream = null;
try {
// copy the resource to a temporary file to process it with 2pack
InputStream stream = packout.openStream();
File zipfile = File.createTempFile(getName()+"_", suffix);
zipstream = new FileOutputStream(zipfile);
byte[] buffer = new byte[1024];
int read;
while((read = stream.read(buffer)) != -1){
zipstream.write(buffer, 0, read);
}
// call 2pack
if (!merge(zipfile, extractVersionString(packout)))
return false;
} catch (Throwable e) {
logger.log(Level.SEVERE, "Pack in failed.", e);
return false;
} finally{
if (zipstream != null) {
try {
zipstream.close();
} catch (Exception e2) {}
}
}
System.out.println(getName() + " " + packout.getPath() + " installed");
}
return true;
}
protected BundleContext getContext() {
return context;
}
protected void setContext(BundleContext context) {
this.context = context;
}
@Override
public void stop(BundleContext context) throws Exception {
stop();
serviceTracker.close();
this.context = null;
if (logger.isLoggable(Level.INFO)) logger.info(context.getBundle().getSymbolicName() + " "
+ context.getBundle().getHeaders().get("Bundle-Version")
+ " stopped.");
}
protected void afterPackIn() {
};
/**
* call when bundle have been started ( after this.context have been set )
*/
protected void start() {
};
/**
* call when bundle is stop ( before this.context is set to null )
*/
protected void stop() {
}
@Override
public IDictionaryService addingService(
ServiceReference<IDictionaryService> reference) {
service = context.getService(reference);
if (Adempiere.getThreadPoolExecutor() != null) {
Adempiere.getThreadPoolExecutor().execute(new Runnable() {
@Override
public void run() {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(Version2PackActivator.class.getClassLoader());
setupPackInContext();
installPackage();
} finally {
ServerContext.dispose();
service = null;
Thread.currentThread().setContextClassLoader(cl);
}
}
});
} else {
Adempiere.addServerStateChangeListener(new ServerStateChangeListener() {
@Override
public void stateChange(ServerStateChangeEvent event) {
if (event.getEventType() == ServerStateChangeEvent.SERVER_START && service != null) {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(Version2PackActivator.class.getClassLoader());
setupPackInContext();
installPackage();
} finally {
ServerContext.dispose();
service = null;
Thread.currentThread().setContextClassLoader(cl);
}
}
}
});
}
return null;
}
@Override
public void modifiedService(ServiceReference<IDictionaryService> reference,
IDictionaryService service) {
}
@Override
public void removedService(ServiceReference<IDictionaryService> reference,
IDictionaryService service) {
}
protected void setupPackInContext() {
Properties serverContext = new Properties();
ServerContext.setCurrentInstance(serverContext);
};
}

View File

@ -155,4 +155,8 @@
<Arg>java.naming.factory.url.pkgs</Arg>
<Arg><Property name="java.naming.factory.url.pkgs" default="org.eclipse.jetty.jndi"/></Arg>
</Call>
</Configure>
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.Request.maxFormContentSize</Arg>
<Arg>1048576</Arg>
</Call>
</Configure>

View File

@ -138,8 +138,10 @@ public final class Prop implements Serializable {
}
catch (FileNotFoundException e)
{
log.warning(filename + " not found");
log.warning("!!WARNING:Please locate yout custom home.properties on iDEMPIERE_HOME.");
if (log.isLoggable(Level.INFO)) {
log.info(filename + " not found");
log.info("!!WARNING:Please locate your custom home.properties on IDEMPIERE_HOME.");
}
loadOK = false;
try {
fis = Prop.class.getResourceAsStream(HOME_PROPERTY_FILE);

View File

@ -270,6 +270,7 @@ public class AlertProcessor extends AdempiereServer
Trx trx = null;
try {
trx = Trx.get(Trx.createTrxName("AP_NU"), true);
trx.setDisplayName(getClass().getName()+"_"+m_model.getName()+"_notifyUsers");
// Notice
int AD_Message_ID = 52244; /* TODO - Hardcoded message=notes */
MNote note = new MNote(getCtx(), AD_Message_ID, user_id, trx.getTrxName());

View File

@ -115,6 +115,7 @@ public class Scheduler extends AdempiereServer
try
{
m_trx = Trx.get(Trx.createTrxName("Scheduler"), true);
m_trx.setDisplayName(getClass().getName()+"_"+getModel().getName()+"_doWork");
m_summary.append(runProcess(process));
m_trx.commit(true);
}

View File

@ -957,8 +957,13 @@ public class AdempiereMonitor extends HttpServlet
{
line = new tr();
line.addElement(new th().addElement("Active Transaction "));
line.addElement(new td().addElement("Name="+trx.getTrxName()
+ ", StartTime=" + trx.getStartTime()));
td td = new td();
td.setOnClick("var newwindow=window.open('','Popup', 'width=800,height=600');newwindow.document.write('<title>" + escapeEcmaScript(trx.getDisplayName()) +"</title>"
+ "<pre>" + escapeEcmaScript(trx.getStrackTrace()) + "</pre>')");
td.addElement("Name="+trx.getDisplayName() + ", StartTime=" + trx.getStartTime());
td.setTitle("Click to see stack trace");
td.setStyle("text-decoration: underline; color: blue");
line.addElement(td);
table.addElement(line);
}
}
@ -1247,4 +1252,14 @@ public class AdempiereMonitor extends HttpServlet
return dirAccessList;
}
private static final String escapeEcmaScript(String input) {
input = input.replace("'", "\\'");
input = input.replace("\"", "\\\"");
input = input.replace("\\", "\\\\");
input = input.replace("/", "\\/");
input = input.replace("\n", "\\n");
input = input.replace("\t", "\\t");
return input;
}
} // AdempiereMonitor

View File

@ -93,6 +93,13 @@ public class ADSortTab extends Panel implements IADTabpanel
m_AD_Table_ID = gridTab.getAD_Table_ID();
ZKUpdateUtil.setVflex(this, "true");
addEventListener(ON_ACTIVATE_EVENT, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
removeAttribute(ATTR_ON_ACTIVATE_POSTED);
}
});
} // ADSortTab
/** Logger */
@ -357,13 +364,6 @@ public class ADSortTab extends Panel implements IADTabpanel
ZKUpdateUtil.setVflex(yesList, true);
ZKUpdateUtil.setHflex(yesList, "1");
hlayout.appendChild(yesList);
addEventListener(ON_ACTIVATE_EVENT, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
removeAttribute(ATTR_ON_ACTIVATE_POSTED);
}
});
} // Init
/* (non-Javadoc)

View File

@ -744,10 +744,12 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
}
else
{
comp.dynamicDisplay();
boolean rw = mField.isEditable(true); // r/w - check Context
if (rw && !comp.isReadWrite()) // IDEMPIERE-3421 - if it was read-only the list can contain direct values
mField.refreshLookup();
comp.setReadWrite(rw);
comp.setMandatory(mField.isMandatory(true)); // check context
comp.dynamicDisplay();
}
}
else if (comp.isVisible())

View File

@ -1344,15 +1344,15 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
toolbar.enablePrint(adTabbox.getSelectedGridTab().isPrinted() && !adTabbox.getSelectedGridTab().isNew());
boolean isNewRow = adTabbox.getSelectedGridTab().getRowCount() == 0 || adTabbox.getSelectedGridTab().isNew();
//Deepak-Enabling customize button IDEMPIERE-364
if(!(adTabbox.getSelectedTabpanel() instanceof ADSortTab))
{
toolbar.enableCustomize(((ADTabpanel)adTabbox.getSelectedTabpanel()).isGridView());
}
else
{
if(adTabbox.getSelectedTabpanel() instanceof ADSortTab){//consistent with dataStatusChanged
toolbar.enableProcessButton (false);
toolbar.enableCustomize(false);
toolbar.enableProcessButton(false);
}else{
ADTabpanel adtab = (ADTabpanel) adTabbox.getSelectedTabpanel();
toolbar.enableProcessButton(!isNewRow && adtab != null && adtab.getToolbarButtons().size() > 0);
toolbar.enableCustomize(adtab.isGridView());
}
}
@ -1715,8 +1715,6 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
}
boolean isNewRow = adTabbox.getSelectedGridTab().getRowCount() == 0 || adTabbox.getSelectedGridTab().isNew();
ADTabpanel adtab = (ADTabpanel) adTabbox.getSelectedTabpanel();
toolbar.enableProcessButton(!isNewRow && adtab != null && adtab.getToolbarButtons().size() > 0);
toolbar.enableArchive(!isNewRow);
toolbar.enableZoomAcross(!isNewRow);
toolbar.enableActiveWorkflows(!isNewRow);
@ -1731,8 +1729,14 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
toolbar.enableTabNavigation(breadCrumb.hasParentLink(), adTabbox.getSelectedDetailADTabpanel() != null);
//Deepak-Enabling customize button IDEMPIERE-364
if(!(adTabbox.getSelectedTabpanel() instanceof ADSortTab))
toolbar.enableCustomize(adtab.isGridView());
if(adTabbox.getSelectedTabpanel() instanceof ADSortTab){//consistent with updateToolbar
toolbar.enableProcessButton (false);
toolbar.enableCustomize(false);
}else{
ADTabpanel adtab = (ADTabpanel) adTabbox.getSelectedTabpanel();
toolbar.enableProcessButton(!isNewRow && adtab != null && adtab.getToolbarButtons().size() > 0);
toolbar.enableCustomize(adtab.isGridView());
}
}
/**
@ -1811,6 +1815,10 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
{
sortColumn.setSortDirection("natural");
}
if (gridTab.isSortTab()) { // refresh is not refreshing sort tabs
IADTabpanel tabPanel = adTabbox.getSelectedTabpanel();
tabPanel.query(false, 0, 0);
}
}
private Column findCurrentSortColumn() {

View File

@ -996,9 +996,12 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
}
else
{
comp.dynamicDisplay();
boolean rw = mField.isEditableGrid(true); // r/w - check Context
boolean rw = mField.isEditable(true); // r/w - check Context
if (rw && !comp.isReadWrite()) // IDEMPIERE-3421 - if it was read-only the list can contain direct values
mField.refreshLookup();
comp.setReadWrite(rw);
comp.setMandatory(mField.isMandatory(true)); // check context
comp.dynamicDisplay();
}
Properties ctx = isDetailPane() ? new GridRowCtx(Env.getCtx(), gridTab, gridTab.getCurrentRow())

View File

@ -260,6 +260,7 @@ public class FeedbackRequestWindow extends Window implements EventListener<Event
protected void saveRequest() throws IOException {
Trx trx = Trx.get(Trx.createTrxName("SaveNewRequest"), true);
trx.setDisplayName(getClass().getName()+"_saveRequest");
try {
trx.start();
MRequest request = createMRequest(trx);

View File

@ -846,6 +846,7 @@ public class WBOMDrop extends ADForm implements EventListener<Event>
{
String trxName = Trx.createTrxName("BDP");
Trx localTrx = Trx.get(trxName, true); //trx needs to be committed too
localTrx.setDisplayName(getClass().getName()+"_onSave");
try
{
if (cmd_save(localTrx))

View File

@ -634,6 +634,7 @@ public class WWFActivity extends ADForm implements EventListener<Event>
Trx trx = null;
try {
trx = Trx.get(Trx.createTrxName("FWFA"), true);
trx.setDisplayName(getClass().getName()+"_onOK");
m_activity.set_TrxName(trx.getTrxName());
if (forward != null)

View File

@ -160,6 +160,7 @@ public class ADTreeOnDropListener implements EventListener<Event> {
// *** Save changes to disk
Trx trx = Trx.get (Trx.createTrxName("ADTree"), true);
trx.setDisplayName(getClass().getName()+"_moveNode");
try
{
@SuppressWarnings("unused")

View File

@ -23,6 +23,7 @@ import org.adempiere.util.Callback;
import org.adempiere.webui.AdempiereIdGenerator;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.factory.ButtonFactory;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.util.Env;
@ -338,7 +339,12 @@ public class Messagebox extends Window implements EventListener<Event>
returnValue = IGNORE;
}
this.detach();
try {
this.detach();
} catch (NullPointerException npe) {
if (! (SessionManager.getSessionApplication() == null)) // IDEMPIERE-1937 - ignore when session was closed
throw npe;
}
}
@SuppressWarnings("unchecked")

View File

@ -34,7 +34,7 @@ public class Textbox extends org.zkoss.zul.Textbox implements EventListener<Even
/**
*
*/
private static final long serialVersionUID = 2201466028538929955L;
private static final long serialVersionUID = -3919623360765045602L;
private Obscure m_obscure = null;
@ -86,7 +86,7 @@ public class Textbox extends org.zkoss.zul.Textbox implements EventListener<Even
String value = super.getValue();
if (m_obscure != null && value != null && value.length() > 0)
{
if (!isReadonly() && value.equals(m_obscure.getObscuredValue()))
if (!isReadonly() && value.equals(m_obscure.getObscuredValue(getMaxlength())))
value = m_obscure.getClearValue();
}
return value;
@ -94,9 +94,9 @@ public class Textbox extends org.zkoss.zul.Textbox implements EventListener<Even
@Override
public void setValue(String value) throws WrongValueException {
if (m_obscure != null && !m_infocus)
if (m_obscure != null && ("password".equals(getType()) || !m_infocus))
{
super.setValue(m_obscure.getObscuredValue(value));
super.setValue(m_obscure.getObscuredValue(value, getMaxlength()));
}
else
{
@ -118,4 +118,12 @@ public class Textbox extends org.zkoss.zul.Textbox implements EventListener<Even
setValue(getValue());
}
}
@Override
public void setType(String type) throws WrongValueException {
if ("password".equals(type))
setObscureType(Obscure.OBSCURETYPE_ObscureMaskMax10Asterisk);
super.setType(type);
}
}

View File

@ -93,8 +93,6 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
private boolean readOnly;
private boolean updateable;
private String columnName;
protected WEditorPopupMenu popupMenu;
@ -177,7 +175,6 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
this.setMandatory(gridField.isMandatory(true));
this.readOnly = gridField.isReadOnly();
this.description = gridField.getDescription();
this.updateable = gridField.isUpdateable();
this.columnName = gridField.getColumnName();
this.strLabel = gridField.getHeader();
init();
@ -227,7 +224,6 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
this.setMandatory(mandatory);
this.readOnly = readonly;
this.description = description;
this.updateable = updateable;
this.strLabel = label;
init();
}
@ -253,7 +249,6 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
this.setMandatory(mandatory);
this.readOnly = readonly;
this.description = description;
this.updateable = updateable;
this.strLabel = label;
this.columnName = columnName;
init();
@ -277,15 +272,7 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
label.setMandatory(mandatory);
this.setMandatory (mandatory);
if (readOnly || !updateable)
{
this.setReadWrite(false);
}
else
{
this.setReadWrite(true);
}
this.setReadWrite(!readOnly);
((HtmlBasedComponent)component).setTooltiptext(description);
label.setTooltiptext(description);

View File

@ -68,6 +68,7 @@ import org.compiere.model.MLookupFactory;
import org.compiere.model.MLookupInfo;
import org.compiere.model.MProcess;
import org.compiere.model.MRole;
import org.compiere.model.MSysConfig;
import org.compiere.model.MTable;
import org.compiere.model.X_AD_InfoColumn;
import org.compiere.util.DB;
@ -464,12 +465,13 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
boolean splitValue = false;
if (m_count <= 0) {
String[] values = queryValue.split("[_]");
String separator = MSysConfig.getValue(MSysConfig.IDENTIFIER_SEPARATOR, "_", Env.getAD_Client_ID(Env.getCtx()));
String[] values = queryValue.split("[" + separator.trim()+"]");
if (values.length == 2) {
splitValue = true;
for(int i = 0; i < values.length && i < identifiers.size(); i++) {
WEditor editor = identifiers.get(i);
editor.setValue(values[i]);
editor.setValue(values[i].trim());
}
testCount(false);
}

View File

@ -316,6 +316,7 @@ public class ChangePasswordPanel extends Window implements EventListener<Event>
{
String trxName = Trx.createTrxName("ChangePasswordTrx");
trx = Trx.get(trxName, true);
trx.setDisplayName(getClass().getName()+"_validateChangePassword");
for (KeyNamePair clientKNPair : m_clientKNPairs)
{

View File

@ -847,6 +847,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
//https://jdbc.postgresql.org/documentation/head/query.html#query-with-cursor
String trxName = Trx.createTrxName("InfoPanelLoad:");
trx = Trx.get(trxName, true);
trx.setDisplayName(getClass().getName()+"_readLine");
m_pstmt = DB.prepareStatement(dataSql, trxName);
setParameters (m_pstmt, false); // no count
if (log.isLoggable(Level.FINE))
@ -1778,6 +1779,11 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
{
updateListSelected();
int pgNo = paging.getActivePage();
if (pgNo == paging.getPageCount()-1 && !isLoadPageNumber()) {
testCount();
paging.setTotalSize(m_count);
pgNo = paging.getActivePage();
}
if (pageNo != pgNo)
{

View File

@ -258,6 +258,7 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
txtSecurityQuestion.setVisible(false);
txtAnswer = new Textbox();
txtAnswer.setType("password");
txtAnswer.setId("txtAnswer");
// txtAnswer.setType("password");
txtAnswer.setCols(25);
@ -449,6 +450,7 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
{
String trxName = Trx.createTrxName("ResetPasswordTrx");
trx = Trx.get(trxName, true);
trx.setDisplayName(getClass().getName()+"_validateResetPassword");
for (MUser user : users)
{

View File

@ -149,6 +149,7 @@ public class GridTabDataBinder implements ValueChangeListener {
int recordId = gridTab.getKeyID(gridTab.getCurrentRow());
Trx trx = Trx.get(Trx.createTrxName(), true);
trx.setDisplayName(getClass().getName()+"_valueChange");
trx.start();
try
{

View File

@ -101,6 +101,7 @@ public class WGadgets extends Window implements EventListener<Event>{
if (panel.getButton("Ok").equals(event.getTarget()))
{
Trx trx = Trx.get(Trx.createTrxName("ManagedGadgets"), true);
trx.setDisplayName(getClass().getName()+"_onEvent_onOk");
try {
trx.start();
for(MDashboardPreference pre : dirtyList.values()) {

View File

@ -915,6 +915,7 @@ public class WLocationDialog extends Window implements EventListener<Event>
private boolean action_OK()
{
Trx trx = Trx.get(Trx.createTrxName("WLocationDialog"), true);
trx.setDisplayName(getClass().getName()+"_action_Ok");
m_location.set_TrxName(trx.getTrxName());
m_location.setAddress1(txtAddress1.getValue());
m_location.setAddress2(txtAddress2.getValue());

View File

@ -247,6 +247,7 @@ public class InOutGen extends GenForm
if (log.isLoggable(Level.INFO)) log.info("M_Warehouse_ID=" + m_M_Warehouse_ID);
String trxName = Trx.createTrxName("IOG");
Trx trx = Trx.get(trxName, true); //trx needs to be committed too
trx.setDisplayName(getClass().getName()+"_generate");
setSelectionActive(false); // prevents from being called twice
statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "InOutGenerateGen"));

View File

@ -247,6 +247,7 @@ public class InvoiceGen extends GenForm
String info = "";
String trxName = Trx.createTrxName("IVG");
Trx trx = Trx.get(trxName, true); //trx needs to be committed too
trx.setDisplayName(getClass().getName()+"_generate");
setSelectionActive(false); // prevents from being called twice
statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "InvGenerateGen"));

View File

@ -206,6 +206,7 @@ public class Match
// Create it
String innerTrxName = Trx.createTrxName("Match");
Trx innerTrx = Trx.get(innerTrxName, true);
innerTrx.setDisplayName(getClass().getName()+"_cmd_process");
try{
if (createMatchRecord(invoice, M_InOutLine_ID, Line_ID, BigDecimal.valueOf(qty), innerTrxName))

View File

@ -114,8 +114,9 @@ public class Merge
try
{
m_trx = Trx.get(Trx.createTrxName("merge"), true);
m_trx.setDisplayName(getClass().getName()+"_merge");
//
pstmt = DB.prepareStatement(sql, Trx.createTrxName());
pstmt = DB.prepareStatement(sql, m_trx.getTrxName());
pstmt.setString(1, ColumnName);
pstmt.setString(2, ColumnName);
rs = pstmt.executeQuery();

View File

@ -422,6 +422,7 @@ public class PaySelect
try {
trxName = Trx.createTrxName("PaySelect");
trx = Trx.get(trxName, true);
trx.setDisplayName(getClass().getName()+"_generatePaySelect");
String PaymentRule = paymentRule.getValue();

View File

@ -239,6 +239,7 @@ public class RunProcess extends TableFixture {
if (process.isJavaProcess() && !jasperreport)
{
Trx trx = Trx.get(Trx.createTrxName("FixturePrc"), true);
trx.setDisplayName(getClass().getName()+"_doStaticTable");
try
{
processOK = process.processIt(pi, trx);

View File

@ -97,6 +97,7 @@ public class SetDocAction extends TableFixture {
}
Trx trx = Trx.get(Trx.createTrxName("FixtureSetDocAction"), true);
trx.setDisplayName(getClass().getName()+"_doStaticTable");
gpo = table.getPO(recordID, trx.getTrxName());
if (gpo == null) {

View File

@ -93,6 +93,7 @@ public class CompositeServiceImpl extends AbstractService implements CompositeSe
String trxName = Trx.createTrxName(webServiceName);
Trx trx = Trx.get(trxName, true);
trx.setDisplayName(getClass().getName()+"_"+webServiceName+"_compositeOperation");
try {
modelADService.setLocalTrxName(trxName);

View File

@ -214,6 +214,8 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
}
trx = Trx.get(trxName, true);
if (manageTrx)
trx.setDisplayName(getClass().getName()+"_"+webServiceName+"_setDocAction");
Map<String, Object> requestCtx = getRequestCtx();
@ -698,6 +700,8 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
}
trx = Trx.get(trxName, true);
if (manageTrx)
trx.setDisplayName(getClass().getName()+"_"+webServiceName+"_deleteData");
// get the PO for the tablename and record ID
MTable table = MTable.get(ctx, tableName);
@ -780,6 +784,8 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
}
trx = Trx.get(trxName, true);
if (manageTrx)
trx.setDisplayName(getClass().getName()+"_"+webServiceName+"_createData");
// get the PO for the tablename and record ID
@ -892,6 +898,8 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
manageTrx = true;
}
trx = Trx.get(trxName, true);
if (manageTrx)
trx.setDisplayName(getClass().getName()+"_"+webServiceName+"_createUpdateData");
// get the PO for the tablename and record ID
MTable table = MTable.get(ctx, tableName);
@ -1272,6 +1280,8 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
}
trx = Trx.get(trxName, true);
if (manageTrx)
trx.setDisplayName(getClass().getName()+"_"+webServiceName+"_updateData");
@ -1464,6 +1474,8 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
manageTrx = true;
}
trx = Trx.get(trxName, true);
if (manageTrx)
trx.setDisplayName(getClass().getName()+"_"+webServiceName+"_queryData");
StringBuilder sqlBuilder = new StringBuilder(role.addAccessSQL("SELECT * FROM " + tableName, tableName, true, true));

View File

@ -340,6 +340,8 @@ public class Process {
if (process.isJavaProcess() && !jasperreport)
{
Trx trx = trxName == null ? Trx.get(Trx.createTrxName("WebPrc"), true) : Trx.get(trxName, true);
if (trxName == null)
trx.setDisplayName(Process.class.getName()+"_runProcess");
try
{
processOK = process.processIt(pi, trx, false);