From d96199a2b658d033fc1840d80f04f45971f73966 Mon Sep 17 00:00:00 2001 From: hengsin Date: Tue, 12 Jan 2021 21:29:50 +0800 Subject: [PATCH] IDEMPIERE-4251 Constant definition for all Env Context (#519) * IDEMPIERE-4251 Constant definition for all Env Context replace "#Date" with Env.DATE * IDEMPIERE-4251 Constant definition for all Env Context replace "#.." with constant at Env * IDEMPIERE-4251 Constant definition for all Env Context Merge patch from Carlos --- .../org/compiere/model/CalloutInvoice.java | 4 +- .../compiere/model/CalloutInvoiceBatch.java | 2 +- .../src/org/compiere/model/CalloutOrder.java | 4 +- .../org/compiere/model/CalloutPayment.java | 4 +- .../compiere/model/CalloutTimeExpense.java | 2 +- .../process/ImmediateBankTransfer.java | 2 +- .../adempiere/process/InOutGenerateRMA.java | 2 +- .../adempiere/process/InvoiceGenerateRMA.java | 2 +- .../src/org/compiere/process/ConvertLead.java | 4 +- .../org/compiere/process/InOutGenerate.java | 2 +- .../org/compiere/process/InvoiceGenerate.java | 2 +- .../process/OrderLineCreateProduction.java | 2 +- .../process/OrderLineCreateShipment.java | 2 +- .../process/ReplenishReportProduction.java | 2 +- .../adempiere/apps/graph/ChartBuilder.java | 2 +- .../base/event/RequestEventHandler.java | 2 +- .../adempiere/process/MatchInvReverse.java | 2 +- .../org/adempiere/process/MatchPOReverse.java | 2 +- .../src/org/compiere/MigrateData.java | 4 +- .../src/org/compiere/acct/Doc.java | 2 +- .../src/org/compiere/model/GridTab.java | 4 +- .../src/org/compiere/model/GridTabVO.java | 6 +- .../src/org/compiere/model/GridTable.java | 2 +- .../org/compiere/model/MAllocationHdr.java | 4 +- .../src/org/compiere/model/MAsset.java | 2 +- .../src/org/compiere/model/MIFixedAsset.java | 2 +- .../src/org/compiere/model/MInOut.java | 4 +- .../src/org/compiere/model/MInOutLine.java | 2 +- .../src/org/compiere/model/MInventory.java | 2 +- .../src/org/compiere/model/MInvoice.java | 12 +-- .../src/org/compiere/model/MInvoiceLine.java | 2 +- .../src/org/compiere/model/MJournal.java | 2 +- .../src/org/compiere/model/MJournalBatch.java | 2 +- .../src/org/compiere/model/MMovement.java | 2 +- .../src/org/compiere/model/MOrder.java | 8 +- .../src/org/compiere/model/MPayment.java | 4 +- .../src/org/compiere/model/MProduction.java | 4 +- .../src/org/compiere/model/MRequest.java | 4 +- .../src/org/compiere/model/MRole.java | 4 +- .../src/org/compiere/model/MSession.java | 16 ++-- .../src/org/compiere/model/MSetup.java | 4 +- .../src/org/compiere/model/PO.java | 12 +-- .../src/org/compiere/model/ScheduleUtil.java | 2 +- .../src/org/compiere/process/SvrProcess.java | 6 +- .../src/org/compiere/tools/FileUtil.java | 2 +- .../src/org/compiere/util/CLogMgt.java | 10 +-- .../src/org/compiere/util/EMail.java | 2 +- .../src/org/compiere/util/Env.java | 83 +++++++++++++------ .../src/org/compiere/util/Login.java | 76 ++++++++--------- .../src/org/compiere/util/WebUser.java | 2 +- .../src/org/compiere/wf/MWFActivity.java | 4 +- .../src/org/compiere/wf/MWorkflow.java | 6 +- .../src/org/eevolution/model/MDDOrder.java | 4 +- .../org/eevolution/process/BankTransfer.java | 2 +- .../pipo/srv/PipoDictionaryService.java | 4 +- .../org/adempiere/pipo2/PackInProcess.java | 6 +- .../org/adempiere/pipo2/PackOutProcess.java | 2 +- .../plugin/utils/AdempiereActivator.java | 2 +- .../utils/Incremental2PackActivator.java | 4 +- .../utils/PackInApplicationActivator.java | 8 +- .../plugin/utils/Version2PackActivator.java | 2 +- .../compiere/server/ReplicationProcessor.java | 8 +- .../process/rpl/imp/ImportHelper.java | 2 +- .../report/jasper/ReportStarter.java | 10 +-- .../org/compiere/server/AcctProcessor.java | 16 ++-- .../org/compiere/server/AdempiereServer.java | 22 ++--- .../server/org/compiere/server/Scheduler.java | 22 ++--- .../org/adempiere/webui/AdempiereWebUI.java | 12 +-- .../src/org/adempiere/webui/apps/AEnv.java | 6 +- .../webui/apps/AbstractProcessDialog.java | 18 ++-- .../webui/apps/form/WAllocation.java | 2 +- .../adempiere/webui/apps/form/WInOutGen.java | 2 +- .../webui/desktop/FavouriteController.java | 2 +- .../webui/editor/WAccountEditor.java | 2 +- .../webui/editor/WRadioGroupEditor.java | 2 +- .../webui/editor/WTableDirEditor.java | 2 +- .../webui/info/InfoProductWindow.java | 2 +- .../webui/panel/ChangePasswordPanel.java | 2 +- .../webui/panel/InfoProductPanel.java | 2 +- .../webui/panel/ResetPasswordPanel.java | 2 +- .../org/adempiere/webui/panel/RolePanel.java | 12 +-- .../webui/session/SessionContextListener.java | 2 +- .../webui/session/SessionManager.java | 8 +- .../session/ValidateReadonlyComponent.java | 2 +- .../org/compiere/apps/form/Allocation.java | 4 +- .../src/org/compiere/apps/form/Charge.java | 2 +- .../org/compiere/apps/form/FactReconcile.java | 2 +- .../org/idempiere/test/AbstractTestCase.java | 8 +- .../org/idempiere/test/base/MatchInvTest.java | 2 +- .../idempiere/test/model/AllocationTest.java | 2 +- .../adinterface/CompiereService.java | 10 +-- .../org/idempiere/adinterface/Process.java | 12 +-- .../webservices/AbstractService.java | 10 +-- 93 files changed, 313 insertions(+), 280 deletions(-) diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java index 12543e7644..1c3e0fc1ed 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java @@ -168,7 +168,7 @@ public class CalloutInvoice extends CalloutEngine mTab.setValue("M_PriceList_ID", ii); else { // get default PriceList - int i = Env.getContextAsInt(ctx, "#M_PriceList_ID"); + int i = Env.getContextAsInt(ctx, Env.M_PRICELIST_ID); if (i != 0) { MPriceList pl = new MPriceList(ctx, i, null); @@ -484,7 +484,7 @@ public class CalloutInvoice extends CalloutEngine int AD_Org_ID = Env.getContextAsInt(ctx, WindowNo, "AD_Org_ID"); if (log.isLoggable(Level.FINE)) log.fine("Org=" + AD_Org_ID); - int M_Warehouse_ID = Env.getContextAsInt(ctx, "#M_Warehouse_ID"); + int M_Warehouse_ID = Env.getContextAsInt(ctx, Env.M_WAREHOUSE_ID); if (log.isLoggable(Level.FINE)) log.fine("Warehouse=" + M_Warehouse_ID); // diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoiceBatch.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoiceBatch.java index b346c68442..fa9da07da2 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoiceBatch.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoiceBatch.java @@ -313,7 +313,7 @@ public class CalloutInvoiceBatch extends CalloutEngine int AD_Org_ID = Env.getContextAsInt(ctx, WindowNo, "AD_Org_ID"); if (log.isLoggable(Level.FINE)) log.fine("Org=" + AD_Org_ID); - int M_Warehouse_ID = Env.getContextAsInt(ctx, "#M_Warehouse_ID"); + int M_Warehouse_ID = Env.getContextAsInt(ctx, Env.M_WAREHOUSE_ID); if (log.isLoggable(Level.FINE)) log.fine("Warehouse=" + M_Warehouse_ID); // diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java index a27bc1465c..4fcab174b2 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java @@ -286,7 +286,7 @@ public class CalloutOrder extends CalloutEngine mTab.setValue("M_PriceList_ID", ii); else { // get default PriceList - int i = Env.getContextAsInt(ctx, "#M_PriceList_ID"); + int i = Env.getContextAsInt(ctx, Env.M_PRICELIST_ID); if (i != 0) { MPriceList pl = new MPriceList(ctx, i, null); @@ -493,7 +493,7 @@ public class CalloutOrder extends CalloutEngine mTab.setValue("M_PriceList_ID", ii); else { // get default PriceList - int i = Env.getContextAsInt(ctx, "#M_PriceList_ID"); + int i = Env.getContextAsInt(ctx, Env.M_PRICELIST_ID); if (i != 0) { MPriceList pl = new MPriceList(ctx, i, null); diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutPayment.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutPayment.java index 7fd0e57598..80a6fbb0cd 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutPayment.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutPayment.java @@ -346,7 +346,7 @@ public class CalloutPayment extends CalloutEngine } else if (baseCurrencyRate.signum() == 0) { - int baseCurrencyId = Env.getContextAsInt(ctx, "$C_Currency_ID"); + int baseCurrencyId = Env.getContextAsInt(ctx, Env.C_CURRENCY_ID); Timestamp dateAcct = (Timestamp) mTab.getValue(I_C_Payment.COLUMNNAME_DateAcct); baseCurrencyRate = MConversionRate.getRate(C_Currency_ID, baseCurrencyId, dateAcct, C_ConversionType_ID, AD_Client_ID, AD_Org_ID); if (baseCurrencyRate == null) @@ -592,7 +592,7 @@ public class CalloutPayment extends CalloutEngine Boolean override = (Boolean)(colName.equals(I_C_Payment.COLUMNNAME_IsOverrideCurrencyRate) ? value : mTab.getValue(I_C_Payment.COLUMNNAME_IsOverrideCurrencyRate)); if (override == null) override = Boolean.FALSE; - int baseCurrencyId = Env.getContextAsInt(ctx, "$C_Currency_ID"); + int baseCurrencyId = Env.getContextAsInt(ctx, Env.C_CURRENCY_ID); if (baseCurrencyId == C_Currency_ID) { mTab.setValue(I_C_Payment.COLUMNNAME_IsOverrideCurrencyRate, false); mTab.setValue(I_C_Payment.COLUMNNAME_CurrencyRate, null); diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutTimeExpense.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutTimeExpense.java index 83f0341425..f3342ee916 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutTimeExpense.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutTimeExpense.java @@ -186,7 +186,7 @@ public class CalloutTimeExpense extends CalloutEngine // get values BigDecimal ExpenseAmt = (BigDecimal)mTab.getValue("ExpenseAmt"); Integer C_Currency_From_ID = (Integer)mTab.getValue("C_Currency_ID"); - int C_Currency_To_ID = Env.getContextAsInt(ctx, "$C_Currency_ID"); + int C_Currency_To_ID = Env.getContextAsInt(ctx, Env.C_CURRENCY_ID); Timestamp DateExpense = Env.getContextAsDate(ctx, WindowNo, "DateExpense"); // if (log.isLoggable(Level.FINE)) log.fine("Amt=" + ExpenseAmt + ", C_Currency_ID=" + C_Currency_From_ID); diff --git a/org.adempiere.base.process/src/org/adempiere/process/ImmediateBankTransfer.java b/org.adempiere.base.process/src/org/adempiere/process/ImmediateBankTransfer.java index 00c2c88ef5..cb9e6b1d0f 100644 --- a/org.adempiere.base.process/src/org/adempiere/process/ImmediateBankTransfer.java +++ b/org.adempiere.base.process/src/org/adempiere/process/ImmediateBankTransfer.java @@ -139,7 +139,7 @@ public class ImmediateBankTransfer extends SvrProcess // Login Date if (p_StatementDate == null) - p_StatementDate = Env.getContextAsDate(getCtx(), "#Date"); + p_StatementDate = Env.getContextAsDate(getCtx(), Env.DATE); if (p_StatementDate == null) p_StatementDate = new Timestamp(System.currentTimeMillis()); diff --git a/org.adempiere.base.process/src/org/adempiere/process/InOutGenerateRMA.java b/org.adempiere.base.process/src/org/adempiere/process/InOutGenerateRMA.java index fc366f707d..2103f89e03 100644 --- a/org.adempiere.base.process/src/org/adempiere/process/InOutGenerateRMA.java +++ b/org.adempiere.base.process/src/org/adempiere/process/InOutGenerateRMA.java @@ -78,7 +78,7 @@ public class InOutGenerateRMA extends SvrProcess log.log(Level.SEVERE, "Unknown Parameter: " + name); } - m_movementDate = Env.getContextAsDate(getCtx(), "#Date"); + m_movementDate = Env.getContextAsDate(getCtx(), Env.DATE); if (m_movementDate == null) { m_movementDate = new Timestamp(System.currentTimeMillis()); diff --git a/org.adempiere.base.process/src/org/adempiere/process/InvoiceGenerateRMA.java b/org.adempiere.base.process/src/org/adempiere/process/InvoiceGenerateRMA.java index 3d31ad9641..faab152334 100644 --- a/org.adempiere.base.process/src/org/adempiere/process/InvoiceGenerateRMA.java +++ b/org.adempiere.base.process/src/org/adempiere/process/InvoiceGenerateRMA.java @@ -73,7 +73,7 @@ public class InvoiceGenerateRMA extends SvrProcess log.log(Level.SEVERE, "Unknown Parameter: " + name); } - m_dateinvoiced = Env.getContextAsDate(getCtx(), "#Date"); + m_dateinvoiced = Env.getContextAsDate(getCtx(), Env.DATE); if (m_dateinvoiced == null) { m_dateinvoiced = new Timestamp(System.currentTimeMillis()); diff --git a/org.adempiere.base.process/src/org/compiere/process/ConvertLead.java b/org.adempiere.base.process/src/org/compiere/process/ConvertLead.java index 8a4dee96c3..f38439bc91 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ConvertLead.java +++ b/org.adempiere.base.process/src/org/compiere/process/ConvertLead.java @@ -132,14 +132,14 @@ public class ConvertLead extends SvrProcess { if ( p_C_Currency_ID > 0 ) op.setC_Currency_ID(p_C_Currency_ID); else - op.setC_Currency_ID(Env.getContextAsInt(getCtx(), "$C_Currency_ID")); + op.setC_Currency_ID(Env.getContextAsInt(getCtx(), Env.C_CURRENCY_ID)); if (p_SalesRep_ID > 0 ) op.setSalesRep_ID(p_SalesRep_ID); else if ( lead.getSalesRep_ID() > 0 ) op.setSalesRep_ID(lead.getSalesRep_ID()); else - op.setSalesRep_ID(Env.getContextAsInt(getCtx(), "#SalesRep_ID")); + op.setSalesRep_ID(Env.getContextAsInt(getCtx(), Env.SALESREP_ID)); op.setC_Campaign_ID(lead.getC_Campaign_ID()); diff --git a/org.adempiere.base.process/src/org/compiere/process/InOutGenerate.java b/org.adempiere.base.process/src/org/compiere/process/InOutGenerate.java index 557f06c911..94310eedfb 100644 --- a/org.adempiere.base.process/src/org/compiere/process/InOutGenerate.java +++ b/org.adempiere.base.process/src/org/compiere/process/InOutGenerate.java @@ -122,7 +122,7 @@ public class InOutGenerate extends SvrProcess // juddm - added ability to specify a shipment date from Generate Shipments if (p_DateShipped == null) { - m_movementDate = Env.getContextAsDate(getCtx(), "#Date"); + m_movementDate = Env.getContextAsDate(getCtx(), Env.DATE); if (m_movementDate == null) m_movementDate = new Timestamp(System.currentTimeMillis()); } else diff --git a/org.adempiere.base.process/src/org/compiere/process/InvoiceGenerate.java b/org.adempiere.base.process/src/org/compiere/process/InvoiceGenerate.java index ecdc9b1838..9a32828f29 100644 --- a/org.adempiere.base.process/src/org/compiere/process/InvoiceGenerate.java +++ b/org.adempiere.base.process/src/org/compiere/process/InvoiceGenerate.java @@ -126,7 +126,7 @@ public class InvoiceGenerate extends SvrProcess // Login Date if (p_DateInvoiced == null) - p_DateInvoiced = Env.getContextAsDate(getCtx(), "#Date"); + p_DateInvoiced = Env.getContextAsDate(getCtx(), Env.DATE); if (p_DateInvoiced == null) p_DateInvoiced = new Timestamp(System.currentTimeMillis()); diff --git a/org.adempiere.base.process/src/org/compiere/process/OrderLineCreateProduction.java b/org.adempiere.base.process/src/org/compiere/process/OrderLineCreateProduction.java index a03e660521..69dcb21345 100644 --- a/org.adempiere.base.process/src/org/compiere/process/OrderLineCreateProduction.java +++ b/org.adempiere.base.process/src/org/compiere/process/OrderLineCreateProduction.java @@ -62,7 +62,7 @@ public class OrderLineCreateProduction extends SvrProcess } if (p_MovementDate == null) - p_MovementDate = Env.getContextAsDate(getCtx(), "#Date"); + p_MovementDate = Env.getContextAsDate(getCtx(), Env.DATE); if ( p_MovementDate==null) p_MovementDate = new Timestamp(System.currentTimeMillis()); diff --git a/org.adempiere.base.process/src/org/compiere/process/OrderLineCreateShipment.java b/org.adempiere.base.process/src/org/compiere/process/OrderLineCreateShipment.java index cb8100cf93..d8b1d0e3a4 100644 --- a/org.adempiere.base.process/src/org/compiere/process/OrderLineCreateShipment.java +++ b/org.adempiere.base.process/src/org/compiere/process/OrderLineCreateShipment.java @@ -57,7 +57,7 @@ public class OrderLineCreateShipment extends SvrProcess } if (p_MovementDate == null) - p_MovementDate = Env.getContextAsDate(getCtx(), "#Date"); + p_MovementDate = Env.getContextAsDate(getCtx(), Env.DATE); if ( p_MovementDate==null) p_MovementDate = new Timestamp(System.currentTimeMillis()); diff --git a/org.adempiere.base.process/src/org/compiere/process/ReplenishReportProduction.java b/org.adempiere.base.process/src/org/compiere/process/ReplenishReportProduction.java index 65990a7e55..eca3e45d94 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ReplenishReportProduction.java +++ b/org.adempiere.base.process/src/org/compiere/process/ReplenishReportProduction.java @@ -835,7 +835,7 @@ public class ReplenishReportProduction extends SvrProcess production.setM_Locator_ID(wh.getDefaultLocator().get_ID()); production.setM_Product_ID(replenish.getM_Product_ID()); production.setProductionQty(qty); - production.setMovementDate(Env.getContextAsDate(getCtx(), "#Date")); + production.setMovementDate(Env.getContextAsDate(getCtx(), Env.DATE)); production.saveEx(); production.createLines(false); diff --git a/org.adempiere.base/src/org/adempiere/apps/graph/ChartBuilder.java b/org.adempiere.base/src/org/adempiere/apps/graph/ChartBuilder.java index 08b92f5e70..3e56a1c390 100644 --- a/org.adempiere.base/src/org/adempiere/apps/graph/ChartBuilder.java +++ b/org.adempiere.base/src/org/adempiere/apps/graph/ChartBuilder.java @@ -209,7 +209,7 @@ public class ChartBuilder { hasWhere = true; } - Date currentDate = Env.getContextAsDate(Env.getCtx(), "#Date"); + Date currentDate = Env.getContextAsDate(Env.getCtx(), Env.DATE); Date startDate = null; Date endDate = null; diff --git a/org.adempiere.base/src/org/adempiere/base/event/RequestEventHandler.java b/org.adempiere.base/src/org/adempiere/base/event/RequestEventHandler.java index b34b1bf293..b5cf8edec3 100644 --- a/org.adempiere.base/src/org/adempiere/base/event/RequestEventHandler.java +++ b/org.adempiere.base/src/org/adempiere/base/event/RequestEventHandler.java @@ -125,7 +125,7 @@ public class RequestEventHandler extends AbstractEventHandler implements Managed if (checkChange(r, ra, "SalesRep_ID")) { // Sender - int AD_User_ID = Env.getContextAsInt(r.getCtx(), "#AD_User_ID"); + int AD_User_ID = Env.getContextAsInt(r.getCtx(), Env.AD_USER_ID); if (AD_User_ID == 0) AD_User_ID = r.getUpdatedBy(); // Old diff --git a/org.adempiere.base/src/org/adempiere/process/MatchInvReverse.java b/org.adempiere.base/src/org/adempiere/process/MatchInvReverse.java index 6f25c9cf7d..94123d68a2 100644 --- a/org.adempiere.base/src/org/adempiere/process/MatchInvReverse.java +++ b/org.adempiere.base/src/org/adempiere/process/MatchInvReverse.java @@ -50,7 +50,7 @@ public class MatchInvReverse extends SvrProcess { if (inv.isProcessed()) { - Timestamp reversalDate = Env.getContextAsDate(getCtx(), "#Date"); + Timestamp reversalDate = Env.getContextAsDate(getCtx(), Env.DATE); if (reversalDate == null) { reversalDate = new Timestamp(System.currentTimeMillis()); } diff --git a/org.adempiere.base/src/org/adempiere/process/MatchPOReverse.java b/org.adempiere.base/src/org/adempiere/process/MatchPOReverse.java index e46b4c028f..bfec158656 100644 --- a/org.adempiere.base/src/org/adempiere/process/MatchPOReverse.java +++ b/org.adempiere.base/src/org/adempiere/process/MatchPOReverse.java @@ -48,7 +48,7 @@ public class MatchPOReverse extends SvrProcess { throw new AdempiereException("@NotFound@ @M_MatchPO_ID@ " + p_M_MatchPO_ID); if (po.isProcessed()) { - Timestamp reversalDate = Env.getContextAsDate(getCtx(), "#Date"); + Timestamp reversalDate = Env.getContextAsDate(getCtx(), Env.DATE); if (reversalDate == null) { reversalDate = new Timestamp(System.currentTimeMillis()); } diff --git a/org.adempiere.base/src/org/compiere/MigrateData.java b/org.adempiere.base/src/org/compiere/MigrateData.java index a41ca2b393..8d0db1ecb8 100644 --- a/org.adempiere.base/src/org/compiere/MigrateData.java +++ b/org.adempiere.base/src/org/compiere/MigrateData.java @@ -82,9 +82,9 @@ public class MigrateData String DownloadURL = rs.getString(5); // Properties ctx = new Properties (Env.getCtx()); - Env.setContext(ctx, "#AD_Client_ID", AD_Client_ID); + Env.setContext(ctx, Env.AD_CLIENT_ID, AD_Client_ID); Env.setContext(ctx, "AD_Client_ID", AD_Client_ID); - Env.setContext(ctx, "#AD_Org_ID", AD_Org_ID); + Env.setContext(ctx, Env.AD_ORG_ID, AD_Org_ID); Env.setContext(ctx, "AD_Org_ID", AD_Org_ID); MProductDownload pdl = new MProductDownload(ctx, 0, null); pdl.setM_Product_ID(M_Product_ID); diff --git a/org.adempiere.base/src/org/compiere/acct/Doc.java b/org.adempiere.base/src/org/compiere/acct/Doc.java index 80963d8673..27105a82c4 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc.java @@ -346,7 +346,7 @@ public abstract class Doc p_Status = STATUS_Error; m_as = as; m_ctx = new Properties(m_as.getCtx()); - m_ctx.setProperty("#AD_Client_ID", String.valueOf(m_as.getAD_Client_ID())); + m_ctx.setProperty(Env.AD_CLIENT_ID, String.valueOf(m_as.getAD_Client_ID())); String className = clazz.getName(); className = className.substring(className.lastIndexOf('.')+1); diff --git a/org.adempiere.base/src/org/compiere/model/GridTab.java b/org.adempiere.base/src/org/compiere/model/GridTab.java index e95e9171fc..eed0971397 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTab.java +++ b/org.adempiere.base/src/org/compiere/model/GridTab.java @@ -2236,7 +2236,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable */ public void loadLocks() { - int AD_User_ID = Env.getContextAsInt(Env.getCtx(), "#AD_User_ID"); + int AD_User_ID = Env.getContextAsInt(Env.getCtx(), Env.AD_USER_ID); if (log.isLoggable(Level.FINE)) log.fine("#" + m_vo.TabNo + " - AD_User_ID=" + AD_User_ID); if (!canHaveAttachment()) return; @@ -2301,7 +2301,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable */ public void lock (Properties ctx, int Record_ID, boolean lock) { - int AD_User_ID = Env.getContextAsInt(ctx, "#AD_User_ID"); + int AD_User_ID = Env.getContextAsInt(ctx, Env.AD_USER_ID); if (log.isLoggable(Level.FINE)) log.fine("Lock=" + lock + ", AD_User_ID=" + AD_User_ID + ", AD_Table_ID=" + m_vo.AD_Table_ID + ", Record_ID=" + Record_ID); MPrivateAccess access = MPrivateAccess.get (ctx, AD_User_ID, m_vo.AD_Table_ID, Record_ID); diff --git a/org.adempiere.base/src/org/compiere/model/GridTabVO.java b/org.adempiere.base/src/org/compiere/model/GridTabVO.java index b9ff102946..05235ec419 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTabVO.java +++ b/org.adempiere.base/src/org/compiere/model/GridTabVO.java @@ -101,9 +101,9 @@ public class GridTabVO implements Evaluatee, Serializable private static boolean loadTabDetails (GridTabVO vo, ResultSet rs) { MRole role = MRole.getDefault(vo.ctx, false); - boolean showTrl = "Y".equals(Env.getContext(vo.ctx, "#ShowTrl")); - boolean showAcct = "Y".equals(Env.getContext(vo.ctx, "#ShowAcct")); - boolean showAdvanced = "Y".equals(Env.getContext(vo.ctx, "#ShowAdvanced")); + boolean showTrl = "Y".equals(Env.getContext(vo.ctx, Env.SHOW_TRANSLATION)); + boolean showAcct = "Y".equals(Env.getContext(vo.ctx, Env.SHOW_ACCOUNTING)); + boolean showAdvanced = "Y".equals(Env.getContext(vo.ctx, Env.SHOW_ADVANCED)); // CLogger.get().warning("ShowTrl=" + showTrl + ", showAcct=" + showAcct); try { diff --git a/org.adempiere.base/src/org/compiere/model/GridTable.java b/org.adempiere.base/src/org/compiere/model/GridTable.java index 05c343ad22..f6766ddd73 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTable.java +++ b/org.adempiere.base/src/org/compiere/model/GridTable.java @@ -1671,7 +1671,7 @@ public class GridTable extends AbstractTableModel // Constants for Created/Updated(By) Timestamp now = new Timestamp(System.currentTimeMillis()); - int user = Env.getContextAsInt(m_ctx, "#AD_User_ID"); + int user = Env.getContextAsInt(m_ctx, Env.AD_USER_ID); /** * for every column diff --git a/org.adempiere.base/src/org/compiere/model/MAllocationHdr.java b/org.adempiere.base/src/org/compiere/model/MAllocationHdr.java index 6729e7925c..2855aeb280 100644 --- a/org.adempiere.base/src/org/compiere/model/MAllocationHdr.java +++ b/org.adempiere.base/src/org/compiere/model/MAllocationHdr.java @@ -841,7 +841,7 @@ public class MAllocationHdr extends X_C_AllocationHdr implements DocAction } - Timestamp reversalDate = accrual ? Env.getContextAsDate(getCtx(), "#Date") : getDateAcct(); + Timestamp reversalDate = accrual ? Env.getContextAsDate(getCtx(), Env.DATE) : getDateAcct(); if (reversalDate == null) { reversalDate = new Timestamp(System.currentTimeMillis()); } @@ -1067,7 +1067,7 @@ public class MAllocationHdr extends X_C_AllocationHdr implements DocAction description = Env.parseVariable(description, this, trxName, true); description = Msg.parseTranslation(getCtx(), description); } else - description = Env.getContext(getCtx(), "#AD_User_Name"); // just to be sure + description = Env.getContext(getCtx(), Env.AD_USER_NAME); // just to be sure return description; } diff --git a/org.adempiere.base/src/org/compiere/model/MAsset.java b/org.adempiere.base/src/org/compiere/model/MAsset.java index fc2dc004fc..66e0bd3d08 100644 --- a/org.adempiere.base/src/org/compiere/model/MAsset.java +++ b/org.adempiere.base/src/org/compiere/model/MAsset.java @@ -551,7 +551,7 @@ public class MAsset extends X_A_Asset // // If date is null, use context #Date if(date == null) { - date = Env.getContextAsDate(getCtx(), "#Date"); + date = Env.getContextAsDate(getCtx(), Env.DATE); } // diff --git a/org.adempiere.base/src/org/compiere/model/MIFixedAsset.java b/org.adempiere.base/src/org/compiere/model/MIFixedAsset.java index 2959b03407..c2eda35c2c 100644 --- a/org.adempiere.base/src/org/compiere/model/MIFixedAsset.java +++ b/org.adempiere.base/src/org/compiere/model/MIFixedAsset.java @@ -209,7 +209,7 @@ public class MIFixedAsset extends X_I_FixedAsset Timestamp dateAcct = getDateAcct(); if (dateAcct == null) { - dateAcct = Env.getContextAsDate(getCtx(), "#Date"); + dateAcct = Env.getContextAsDate(getCtx(), Env.DATE); setDateAcct(dateAcct); } } diff --git a/org.adempiere.base/src/org/compiere/model/MInOut.java b/org.adempiere.base/src/org/compiere/model/MInOut.java index 0f2a7cc4fd..f21802295d 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOut.java +++ b/org.adempiere.base/src/org/compiere/model/MInOut.java @@ -2226,7 +2226,7 @@ public class MInOut extends X_M_InOut implements DocAction protected MInOut reverse(boolean accrual) { MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); - Timestamp reversalDate = accrual ? Env.getContextAsDate(getCtx(), "#Date") : getDateAcct(); + Timestamp reversalDate = accrual ? Env.getContextAsDate(getCtx(), Env.DATE) : getDateAcct(); if (reversalDate == null) { reversalDate = new Timestamp(System.currentTimeMillis()); } @@ -2496,7 +2496,7 @@ public class MInOut extends X_M_InOut implements DocAction */ public int getC_Currency_ID () { - return Env.getContextAsInt(getCtx(),"$C_Currency_ID"); + return Env.getContextAsInt(getCtx(),Env.C_CURRENCY_ID); } // getC_Currency_ID /** diff --git a/org.adempiere.base/src/org/compiere/model/MInOutLine.java b/org.adempiere.base/src/org/compiere/model/MInOutLine.java index 808c5f21d1..391beb6346 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOutLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInOutLine.java @@ -557,7 +557,7 @@ public class MInOutLine extends X_M_InOutLine } // UOM if (getC_UOM_ID() == 0) - setC_UOM_ID (Env.getContextAsInt(getCtx(), "#C_UOM_ID")); + setC_UOM_ID (Env.getContextAsInt(getCtx(), Env.C_UOM_ID)); if (getC_UOM_ID() == 0) { int C_UOM_ID = MUOM.getDefault_UOM_ID(getCtx()); diff --git a/org.adempiere.base/src/org/compiere/model/MInventory.java b/org.adempiere.base/src/org/compiere/model/MInventory.java index f246bfa912..61dac0c240 100644 --- a/org.adempiere.base/src/org/compiere/model/MInventory.java +++ b/org.adempiere.base/src/org/compiere/model/MInventory.java @@ -988,7 +988,7 @@ public class MInventory extends X_M_Inventory implements DocAction } // reverseCorrectIt protected MInventory reverse(boolean accrual) { - Timestamp reversalDate = accrual ? Env.getContextAsDate(getCtx(), "#Date") : getMovementDate(); + Timestamp reversalDate = accrual ? Env.getContextAsDate(getCtx(), Env.DATE) : getMovementDate(); if (reversalDate == null) { reversalDate = new Timestamp(System.currentTimeMillis()); } diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index 8b1378ed9c..3db84597cd 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -996,7 +996,7 @@ public class MInvoice extends X_C_Invoice implements DocAction // Price List if (getM_PriceList_ID() == 0) { - int ii = Env.getContextAsInt(getCtx(), "#M_PriceList_ID"); + int ii = Env.getContextAsInt(getCtx(), Env.M_PRICELIST_ID); if (ii != 0) { MPriceList pl = new MPriceList(getCtx(), ii, null); @@ -1021,13 +1021,13 @@ public class MInvoice extends X_C_Invoice implements DocAction if (ii != 0) setC_Currency_ID (ii); else - setC_Currency_ID(Env.getContextAsInt(getCtx(), "#C_Currency_ID")); + setC_Currency_ID(Env.getContextAsInt(getCtx(), Env.C_CURRENCY_ID)); } // Sales Rep if (getSalesRep_ID() == 0) { - int ii = Env.getContextAsInt(getCtx(), "#SalesRep_ID"); + int ii = Env.getContextAsInt(getCtx(), Env.SALESREP_ID); if (ii != 0) setSalesRep_ID (ii); } @@ -1041,7 +1041,7 @@ public class MInvoice extends X_C_Invoice implements DocAction // Payment Term if (getC_PaymentTerm_ID() == 0) { - int ii = Env.getContextAsInt(getCtx(), "#C_PaymentTerm_ID"); + int ii = Env.getContextAsInt(getCtx(), Env.C_PAYMENTTERM_ID); if (ii != 0) setC_PaymentTerm_ID (ii); else @@ -2023,7 +2023,7 @@ public class MInvoice extends X_C_Invoice implements DocAction DB.getDatabase().forUpdate(bp, 0); // Update total revenue and balance / credit limit (reversed on AllocationLine.processIt) BigDecimal invAmt = null; - int baseCurrencyId = Env.getContextAsInt(getCtx(), "$C_Currency_ID"); + int baseCurrencyId = Env.getContextAsInt(getCtx(), Env.C_CURRENCY_ID); if (getC_Currency_ID() != baseCurrencyId && isOverrideCurrencyRate()) { invAmt = getGrandTotal(true).multiply(getCurrencyRate()); @@ -2513,7 +2513,7 @@ public class MInvoice extends X_C_Invoice implements DocAction } // reverseCorrectIt private MInvoice reverse(boolean accrual) { - Timestamp reversalDate = accrual ? Env.getContextAsDate(getCtx(), "#Date") : getDateAcct(); + Timestamp reversalDate = accrual ? Env.getContextAsDate(getCtx(), Env.DATE) : getDateAcct(); if (reversalDate == null) { reversalDate = new Timestamp(System.currentTimeMillis()); } diff --git a/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java b/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java index 7459ff6f5a..e09a10e08a 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java @@ -474,7 +474,7 @@ public class MInvoiceLine extends X_C_InvoiceLine if (isDescription()) return true; // - int M_Warehouse_ID = Env.getContextAsInt(getCtx(), "#M_Warehouse_ID"); + int M_Warehouse_ID = Env.getContextAsInt(getCtx(), Env.M_WAREHOUSE_ID); // int C_Tax_ID = Tax.get(getCtx(), getM_Product_ID(), getC_Charge_ID() , m_DateInvoiced, m_DateInvoiced, getAD_Org_ID(), M_Warehouse_ID, diff --git a/org.adempiere.base/src/org/compiere/model/MJournal.java b/org.adempiere.base/src/org/compiere/model/MJournal.java index 541c691238..636d8f1531 100644 --- a/org.adempiere.base/src/org/compiere/model/MJournal.java +++ b/org.adempiere.base/src/org/compiere/model/MJournal.java @@ -875,7 +875,7 @@ public class MJournal extends X_GL_Journal implements DocAction // Journal MJournal reverse = new MJournal (this); reverse.setGL_JournalBatch_ID(GL_JournalBatch_ID); - Timestamp reversalDate = Env.getContextAsDate(getCtx(), "#Date"); + Timestamp reversalDate = Env.getContextAsDate(getCtx(), Env.DATE); if (reversalDate == null) { reversalDate = new Timestamp(System.currentTimeMillis()); } diff --git a/org.adempiere.base/src/org/compiere/model/MJournalBatch.java b/org.adempiere.base/src/org/compiere/model/MJournalBatch.java index 1b1d049bd5..8284227a01 100644 --- a/org.adempiere.base/src/org/compiere/model/MJournalBatch.java +++ b/org.adempiere.base/src/org/compiere/model/MJournalBatch.java @@ -714,7 +714,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction // Reverse it MJournalBatch reverse = new MJournalBatch (this); reverse.setC_Period_ID(0); - Timestamp reversalDate = Env.getContextAsDate(getCtx(), "#Date"); + Timestamp reversalDate = Env.getContextAsDate(getCtx(), Env.DATE); if (reversalDate == null) { reversalDate = new Timestamp(System.currentTimeMillis()); } diff --git a/org.adempiere.base/src/org/compiere/model/MMovement.java b/org.adempiere.base/src/org/compiere/model/MMovement.java index 25c5b73782..c21bf987ff 100644 --- a/org.adempiere.base/src/org/compiere/model/MMovement.java +++ b/org.adempiere.base/src/org/compiere/model/MMovement.java @@ -833,7 +833,7 @@ public class MMovement extends X_M_Movement implements DocAction protected MMovement reverse(boolean accrual) { - Timestamp reversalDate = accrual ? Env.getContextAsDate(getCtx(), "#Date") : getMovementDate(); + Timestamp reversalDate = accrual ? Env.getContextAsDate(getCtx(), Env.DATE) : getMovementDate(); if (reversalDate == null) { reversalDate = new Timestamp(System.currentTimeMillis()); } diff --git a/org.adempiere.base/src/org/compiere/model/MOrder.java b/org.adempiere.base/src/org/compiere/model/MOrder.java index 2392413d49..54f3a79082 100644 --- a/org.adempiere.base/src/org/compiere/model/MOrder.java +++ b/org.adempiere.base/src/org/compiere/model/MOrder.java @@ -959,7 +959,7 @@ public class MOrder extends X_C_Order implements DocAction // Default Warehouse if (getM_Warehouse_ID() == 0) { - int ii = Env.getContextAsInt(getCtx(), "#M_Warehouse_ID"); + int ii = Env.getContextAsInt(getCtx(), Env.M_WAREHOUSE_ID); if (ii != 0) setM_Warehouse_ID(ii); else @@ -1025,13 +1025,13 @@ public class MOrder extends X_C_Order implements DocAction if (ii != 0) setC_Currency_ID (ii); else - setC_Currency_ID(Env.getContextAsInt(getCtx(), "#C_Currency_ID")); + setC_Currency_ID(Env.getContextAsInt(getCtx(), Env.C_CURRENCY_ID)); } // Default Sales Rep if (getSalesRep_ID() == 0) { - int ii = Env.getContextAsInt(getCtx(), "#SalesRep_ID"); + int ii = Env.getContextAsInt(getCtx(), Env.SALESREP_ID); if (ii != 0) setSalesRep_ID (ii); } @@ -1043,7 +1043,7 @@ public class MOrder extends X_C_Order implements DocAction // Default Payment Term if (getC_PaymentTerm_ID() == 0) { - int ii = Env.getContextAsInt(getCtx(), "#C_PaymentTerm_ID"); + int ii = Env.getContextAsInt(getCtx(), Env.C_PAYMENTTERM_ID); if (ii != 0) setC_PaymentTerm_ID(ii); else diff --git a/org.adempiere.base/src/org/compiere/model/MPayment.java b/org.adempiere.base/src/org/compiere/model/MPayment.java index 9bef309f0d..a6e4bf1214 100644 --- a/org.adempiere.base/src/org/compiere/model/MPayment.java +++ b/org.adempiere.base/src/org/compiere/model/MPayment.java @@ -2048,7 +2048,7 @@ public class MPayment extends X_C_Payment DB.getDatabase().forUpdate(bp, 0); // Update total balance to include this payment BigDecimal payAmt = null; - int baseCurrencyId = Env.getContextAsInt(getCtx(), "$C_Currency_ID"); + int baseCurrencyId = Env.getContextAsInt(getCtx(), Env.C_CURRENCY_ID); if (getC_Currency_ID() != baseCurrencyId && isOverrideCurrencyRate()) { payAmt = getConvertedAmt(); @@ -2700,7 +2700,7 @@ public class MPayment extends X_C_Payment return null; // Std Period open? - Timestamp dateAcct = accrual ? Env.getContextAsDate(getCtx(), "#Date") : getDateAcct(); + Timestamp dateAcct = accrual ? Env.getContextAsDate(getCtx(), Env.DATE) : getDateAcct(); if (dateAcct == null) { dateAcct = new Timestamp(System.currentTimeMillis()); } diff --git a/org.adempiere.base/src/org/compiere/model/MProduction.java b/org.adempiere.base/src/org/compiere/model/MProduction.java index f3b6898ad0..1d2831f0e5 100644 --- a/org.adempiere.base/src/org/compiere/model/MProduction.java +++ b/org.adempiere.base/src/org/compiere/model/MProduction.java @@ -82,7 +82,7 @@ public class MProduction extends X_M_Production implements DocAction { setC_Activity_ID(project.getC_Activity_ID()); setC_ProjectPhase_ID(line.getC_ProjectPhase_ID()); setC_ProjectTask_ID(line.getC_ProjectTask_ID()); - setMovementDate( Env.getContextAsDate(p_ctx, "#Date")); + setMovementDate( Env.getContextAsDate(p_ctx, Env.DATE)); } @Override @@ -704,7 +704,7 @@ public class MProduction extends X_M_Production implements DocAction { } protected MProduction reverse(boolean accrual) { - Timestamp reversalDate = accrual ? Env.getContextAsDate(getCtx(), "#Date") : getMovementDate(); + Timestamp reversalDate = accrual ? Env.getContextAsDate(getCtx(), Env.DATE) : getMovementDate(); if (reversalDate == null) { reversalDate = new Timestamp(System.currentTimeMillis()); } diff --git a/org.adempiere.base/src/org/compiere/model/MRequest.java b/org.adempiere.base/src/org/compiere/model/MRequest.java index cef7ac0eca..0124c8bc9c 100644 --- a/org.adempiere.base/src/org/compiere/model/MRequest.java +++ b/org.adempiere.base/src/org/compiere/model/MRequest.java @@ -817,7 +817,7 @@ public class MRequest extends X_R_Request return "RequestActionEMailNoFrom"; // Check that UI user is Request User -// int realSalesRep_ID = Env.getContextAsInt (getCtx(), "#AD_User_ID"); +// int realSalesRep_ID = Env.getContextAsInt (getCtx(), Env.AD_USER_ID); // if (realSalesRep_ID != getSalesRep_ID()) // setSalesRep_ID(realSalesRep_ID); @@ -898,7 +898,7 @@ public class MRequest extends X_R_Request * private void sendTransferMessage () { // Sender - int AD_User_ID = Env.getContextAsInt(p_ctx, "#AD_User_ID"); + int AD_User_ID = Env.getContextAsInt(p_ctx, Env.AD_USER_ID); if (AD_User_ID == 0) AD_User_ID = getUpdatedBy(); // Old diff --git a/org.adempiere.base/src/org/compiere/model/MRole.java b/org.adempiere.base/src/org/compiere/model/MRole.java index 4f3a8370d4..7a48b93855 100644 --- a/org.adempiere.base/src/org/compiere/model/MRole.java +++ b/org.adempiere.base/src/org/compiere/model/MRole.java @@ -86,8 +86,8 @@ public final class MRole extends X_AD_Role implements ImmutablePOSupport */ public static MRole getDefault (Properties ctx, boolean reload) { - int AD_Role_ID = Env.getContextAsInt(ctx, "#AD_Role_ID"); - int AD_User_ID = Env.getContextAsInt(ctx, "#AD_User_ID"); + int AD_Role_ID = Env.getContextAsInt(ctx, Env.AD_ROLE_ID); + int AD_User_ID = Env.getContextAsInt(ctx, Env.AD_USER_ID); // if (!Ini.isClient()) // none for Server // AD_User_ID = 0; MRole defaultRole = getDefaultRole(); diff --git a/org.adempiere.base/src/org/compiere/model/MSession.java b/org.adempiere.base/src/org/compiere/model/MSession.java index 302af270b1..8913327a2a 100644 --- a/org.adempiere.base/src/org/compiere/model/MSession.java +++ b/org.adempiere.base/src/org/compiere/model/MSession.java @@ -55,7 +55,7 @@ public class MSession extends X_AD_Session */ public static MSession get (Properties ctx, boolean createNew) { - int AD_Session_ID = Env.getContextAsInt(ctx, "#AD_Session_ID"); + int AD_Session_ID = Env.getContextAsInt(ctx, Env.AD_SESSION_ID); MSession session = null; // Try to load if (AD_Session_ID > 0 && s_sessions.contains(AD_Session_ID)) @@ -73,7 +73,7 @@ public class MSession extends X_AD_Session session = new MSession (ctx, null); // local session session.saveEx(); AD_Session_ID = session.getAD_Session_ID(); - Env.setContext (ctx, "#AD_Session_ID", AD_Session_ID); + Env.setContext (ctx, Env.AD_SESSION_ID, AD_Session_ID); s_sessions.add (Integer.valueOf(AD_Session_ID)); } return session; @@ -89,7 +89,7 @@ public class MSession extends X_AD_Session */ public static MSession get (Properties ctx, String Remote_Addr, String Remote_Host, String WebSession) { - int AD_Session_ID = Env.getContextAsInt(ctx, "#AD_Session_ID"); + int AD_Session_ID = Env.getContextAsInt(ctx, Env.AD_SESSION_ID); MSession session = null; // Try to load if (AD_Session_ID > 0 && s_sessions.contains(AD_Session_ID)) @@ -106,7 +106,7 @@ public class MSession extends X_AD_Session session = new MSession (ctx, Remote_Addr, Remote_Host, WebSession, null); // remote session session.saveEx(); AD_Session_ID = session.getAD_Session_ID(); - Env.setContext(ctx, "#AD_Session_ID", AD_Session_ID); + Env.setContext(ctx, Env.AD_SESSION_ID, AD_Session_ID); s_sessions.add(Integer.valueOf(AD_Session_ID)); } return session; @@ -164,8 +164,8 @@ public class MSession extends X_AD_Session setDescription(Adempiere.MAIN_VERSION + "_" + Adempiere.DATE_VERSION + " " + Adempiere.getImplementationVersion()); - setAD_Role_ID(Env.getContextAsInt(ctx, "#AD_Role_ID")); - setLoginDate(Env.getContextAsDate(ctx, "#Date")); + setAD_Role_ID(Env.getContextAsInt(ctx, Env.AD_ROLE_ID)); + setLoginDate(Env.getContextAsDate(ctx, Env.DATE)); } // MSession /** @@ -185,8 +185,8 @@ public class MSession extends X_AD_Session setDescription(Adempiere.MAIN_VERSION + "_" + Adempiere.DATE_VERSION + " " + Adempiere.getImplementationVersion()); - setAD_Role_ID(Env.getContextAsInt(ctx, "#AD_Role_ID")); - setLoginDate(Env.getContextAsDate(ctx, "#Date")); + setAD_Role_ID(Env.getContextAsInt(ctx, Env.AD_ROLE_ID)); + setLoginDate(Env.getContextAsDate(ctx, Env.DATE)); } catch (UnknownHostException e) { diff --git a/org.adempiere.base/src/org/compiere/model/MSetup.java b/org.adempiere.base/src/org/compiere/model/MSetup.java index 8b46ace562..f470c19410 100644 --- a/org.adempiere.base/src/org/compiere/model/MSetup.java +++ b/org.adempiere.base/src/org/compiere/model/MSetup.java @@ -159,7 +159,7 @@ public final class MSetup } int AD_Client_ID = m_client.getAD_Client_ID(); Env.setContext(m_ctx, m_WindowNo, "AD_Client_ID", AD_Client_ID); - Env.setContext(m_ctx, "#AD_Client_ID", AD_Client_ID); + Env.setContext(m_ctx, Env.AD_CLIENT_ID, AD_Client_ID); // Standard Values m_stdValues = String.valueOf(AD_Client_ID) + ",0,'Y',getDate(),0,getDate(),0"; @@ -208,7 +208,7 @@ public final class MSetup return false; } Env.setContext(m_ctx, m_WindowNo, "AD_Org_ID", getAD_Org_ID()); - Env.setContext(m_ctx, "#AD_Org_ID", getAD_Org_ID()); + Env.setContext(m_ctx, Env.AD_ORG_ID, getAD_Org_ID()); m_stdValuesOrg = AD_Client_ID + "," + getAD_Org_ID() + ",'Y',getDate(),0,getDate(),0"; // Info m_info.append(Msg.translate(m_lang, "AD_Org_ID")).append("=").append(name).append("\n"); diff --git a/org.adempiere.base/src/org/compiere/model/PO.java b/org.adempiere.base/src/org/compiere/model/PO.java index 665e8c06b1..2f9a8baa57 100644 --- a/org.adempiere.base/src/org/compiere/model/PO.java +++ b/org.adempiere.base/src/org/compiere/model/PO.java @@ -1689,7 +1689,7 @@ public abstract class PO String colName = p_info.getColumnName(i); // Set Standard Values if (colName.endsWith("tedBy")) - m_newValues[i] = Integer.valueOf(Env.getContextAsInt(p_ctx, "#AD_User_ID")); + m_newValues[i] = Integer.valueOf(Env.getContextAsInt(p_ctx, Env.AD_USER_ID)); else if (colName.equals("Created") || colName.equals("Updated")) m_newValues[i] = new Timestamp (System.currentTimeMillis()); else if (colName.equals(p_info.getTableName() + "_ID")) // KeyColumn @@ -2574,7 +2574,7 @@ public abstract class PO // If no changes set UpdatedBy explicitly to ensure commit of lob if (!changes && !updatedBy) { - int AD_User_ID = Env.getContextAsInt(p_ctx, "#AD_User_ID"); + int AD_User_ID = Env.getContextAsInt(p_ctx, Env.AD_USER_ID); set_ValueNoCheck("UpdatedBy", Integer.valueOf(AD_User_ID)); sql.append("UpdatedBy=").append(AD_User_ID); changes = true; @@ -2753,7 +2753,7 @@ public abstract class PO } if (!updatedBy) // UpdatedBy not explicitly set { - int AD_User_ID = Env.getContextAsInt(p_ctx, "#AD_User_ID"); + int AD_User_ID = Env.getContextAsInt(p_ctx, Env.AD_USER_ID); set_ValueNoCheck("UpdatedBy", Integer.valueOf(AD_User_ID)); if (withValues) { @@ -4977,7 +4977,7 @@ public abstract class PO } private void checkValidContext() { - if (getCtx().isEmpty() && getCtx().getProperty("#AD_Client_ID") == null) + if (getCtx().isEmpty() && getCtx().getProperty(Env.AD_CLIENT_ID) == null) throw new AdempiereException("Context lost"); } @@ -5016,9 +5016,9 @@ public abstract class PO +" Env.AD_Client_ID="+envClientID +" PO.AD_Client_ID="+poClientID +" writing="+writing - +" Session="+Env.getContext(getCtx(), "#AD_Session_ID")); + +" Session="+Env.getContext(getCtx(), Env.AD_SESSION_ID)); String message = "Cross tenant PO " + (writing ? "writing" : "reading") + " request detected from session " - + Env.getContext(getCtx(), "#AD_Session_ID") + " for table " + get_TableName() + + Env.getContext(getCtx(), Env.AD_SESSION_ID) + " for table " + get_TableName() + " Record_ID=" + get_ID(); throw new AdempiereException(message); } diff --git a/org.adempiere.base/src/org/compiere/model/ScheduleUtil.java b/org.adempiere.base/src/org/compiere/model/ScheduleUtil.java index 28b6c957b4..805bb3de87 100644 --- a/org.adempiere.base/src/org/compiere/model/ScheduleUtil.java +++ b/org.adempiere.base/src/org/compiere/model/ScheduleUtil.java @@ -190,7 +190,7 @@ public class ScheduleUtil pstmt = DB.prepareStatement(sql, trxName); pstmt.setTimestamp(1, startDay); pstmt.setTimestamp(2, endDay); - pstmt.setInt(3, Env.getContextAsInt(m_ctx, "#C_Country_ID")); + pstmt.setInt(3, Env.getContextAsInt(m_ctx, Env.C_COUNTRY_ID)); rs = pstmt.executeQuery(); while (rs.next()) { diff --git a/org.adempiere.base/src/org/compiere/process/SvrProcess.java b/org.adempiere.base/src/org/compiere/process/SvrProcess.java index 944665e38f..5278092233 100644 --- a/org.adempiere.base/src/org/compiere/process/SvrProcess.java +++ b/org.adempiere.base/src/org/compiere/process/SvrProcess.java @@ -614,12 +614,12 @@ public abstract class SvrProcess implements ProcessCall */ private void unlock () { - boolean noContext = Env.getCtx().isEmpty() && Env.getCtx().getProperty("#AD_Client_ID") == null; + boolean noContext = Env.getCtx().isEmpty() && Env.getCtx().getProperty(Env.AD_CLIENT_ID) == null; try { //save logging info even if context is lost if (noContext) - Env.getCtx().put("#AD_Client_ID", m_pi.getAD_Client_ID()); + Env.getCtx().put(Env.AD_CLIENT_ID, m_pi.getAD_Client_ID()); //clear interrupt signal so that we can unlock the ad_pinstance record if (Thread.currentThread().isInterrupted()) @@ -646,7 +646,7 @@ public abstract class SvrProcess implements ProcessCall finally { if (noContext) - Env.getCtx().remove("#AD_Client_ID"); + Env.getCtx().remove(Env.AD_CLIENT_ID); } } // unlock diff --git a/org.adempiere.base/src/org/compiere/tools/FileUtil.java b/org.adempiere.base/src/org/compiere/tools/FileUtil.java index d3d0100927..90f006d378 100644 --- a/org.adempiere.base/src/org/compiere/tools/FileUtil.java +++ b/org.adempiere.base/src/org/compiere/tools/FileUtil.java @@ -432,7 +432,7 @@ public class FileUtil String dt = sdf.format(cal.getTime()); String cleanName = subject.replaceAll("[ &/]", ""); String localFile = System.getProperty("java.io.tmpdir") - + System.getProperty("file.separator") + cleanName + "_" + dt + "_" + Env.getContext(Env.getCtx(), "#AD_Session_ID") + + System.getProperty("file.separator") + cleanName + "_" + dt + "_" + Env.getContext(Env.getCtx(), Env.AD_SESSION_ID) + extension; return localFile; } diff --git a/org.adempiere.base/src/org/compiere/util/CLogMgt.java b/org.adempiere.base/src/org/compiere/util/CLogMgt.java index 51eaff6100..90295dc5ae 100644 --- a/org.adempiere.base/src/org/compiere/util/CLogMgt.java +++ b/org.adempiere.base/src/org/compiere/util/CLogMgt.java @@ -522,13 +522,13 @@ public class CLogMgt sb.append(getMsg("Database")).append(eq) .append(getDatabaseInfo()).append(NL); sb.append(getMsg("Schema")).append(eq) .append(CConnection.get().getDbUid()).append(NL); // - sb.append(getMsg("AD_User_ID")).append(eq) .append(Env.getContext(Env.getCtx(), "#AD_User_Name")).append(NL); - sb.append(getMsg("AD_Role_ID")).append(eq) .append(Env.getContext(Env.getCtx(), "#AD_Role_Name")).append(NL); + sb.append(getMsg("AD_User_ID")).append(eq) .append(Env.getContext(Env.getCtx(), Env.AD_USER_NAME)).append(NL); + sb.append(getMsg("AD_Role_ID")).append(eq) .append(Env.getContext(Env.getCtx(), Env.AD_ROLE_NAME)).append(NL); // - sb.append(getMsg("AD_Client_ID")).append(eq).append(Env.getContext(Env.getCtx(), "#AD_Client_Name")).append(NL); - sb.append(getMsg("AD_Org_ID")).append(eq) .append(Env.getContext(Env.getCtx(), "#AD_Org_Name")).append(NL); + sb.append(getMsg("AD_Client_ID")).append(eq).append(Env.getContext(Env.getCtx(), Env.AD_CLIENT_NAME)).append(NL); + sb.append(getMsg("AD_Org_ID")).append(eq) .append(Env.getContext(Env.getCtx(), Env.AD_ORG_NAME)).append(NL); // - sb.append(getMsg("Date")).append(eq) .append(Env.getContext(Env.getCtx(), "#Date")).append(NL); + sb.append(getMsg("Date")).append(eq) .append(Env.getContext(Env.getCtx(), Env.DATE)).append(NL); sb.append(getMsg("Printer")).append(eq) .append(Env.getContext(Env.getCtx(), "#Printer")).append(NL); // Show Implementation Vendor / Version - teo_sarca, [ 1622855 ] sb.append(getMsg("ImplementationVendor")).append(eq).append(org.compiere.Adempiere.getImplementationVendor()).append(NL); diff --git a/org.adempiere.base/src/org/compiere/util/EMail.java b/org.adempiere.base/src/org/compiere/util/EMail.java index 5a3a76e7d9..cb6983f4d8 100644 --- a/org.adempiere.base/src/org/compiere/util/EMail.java +++ b/org.adempiere.base/src/org/compiere/util/EMail.java @@ -444,7 +444,7 @@ public final class EMail implements Serializable msg = msg.substring(0, index); String cc = "??"; if (m_ctx != null) - cc = m_ctx.getProperty("#AD_Client_ID"); + cc = m_ctx.getProperty(Env.AD_CLIENT_ID); msg += " - AD_Client_ID=" + cc; } String className = ex.getClass().getName(); diff --git a/org.adempiere.base/src/org/compiere/util/Env.java b/org.adempiere.base/src/org/compiere/util/Env.java index 779044d0d2..c91f60bcd4 100644 --- a/org.adempiere.base/src/org/compiere/util/Env.java +++ b/org.adempiere.base/src/org/compiere/util/Env.java @@ -75,24 +75,64 @@ import org.compiere.process.SvrProcess; */ public final class Env { - public static final String STANDARD_REPORT_FOOTER_TRADEMARK_TEXT = "#STANDARD_REPORT_FOOTER_TRADEMARK_TEXT"; - - public static final String AD_ROLE_ID = "#AD_Role_ID"; - - public static final String AD_USER_ID = "#AD_User_ID"; - - public static final String AD_ORG_ID = "#AD_Org_ID"; - + //Environments Constants public static final String AD_CLIENT_ID = "#AD_Client_ID"; - - public static final String AD_ORG_NAME = "#AD_Org_Name"; - - public static final String M_WAREHOUSE_ID = "#M_Warehouse_ID"; - + public static final String AD_CLIENT_NAME = "#AD_Client_Name"; + public static final String AD_ORG_ID = "#AD_Org_ID"; + public static final String AD_ORG_NAME = "#AD_Org_Name"; + public static final String AD_PRINTCOLOR_ID = "#AD_PrintColor_ID"; + public static final String AD_PRINTFONT_ID = "#AD_PrintFont_ID"; + public static final String AD_PRINTPAPER_ID = "#AD_PrintPaper_ID"; + public static final String AD_PRINTTABLEFORMAT_ID = "#AD_PrintTableFormat_ID"; + public static final String AD_ROLE_ID = "#AD_Role_ID"; + public static final String AD_ROLE_NAME = "#AD_Role_Name"; + public static final String AD_SESSION_ID = "#AD_Session_ID"; + public static final String AD_USER_ID = "#AD_User_ID"; + public static final String AD_USER_NAME = "#AD_User_Name"; + public static final String C_ACCTSCHEMA_ID = "$C_AcctSchema_ID"; + public static final String C_BANKACCOUNT_ID = "#C_BankAccount_ID"; + public static final String C_BP_GROUP_ID = "#C_BP_Group_ID"; + public static final String C_CASHBOOK_ID = "#C_CashBook_ID"; + public static final String C_CONVERSIONTYPE_ID = "#C_ConversionType_ID"; + public static final String C_COUNTRY_ID = "#C_Country_ID"; + public static final String C_CURRENCY_ID = "$C_Currency_ID"; + public static final String C_DOCTYPETARGET_ID = "#C_DocTypeTarget_ID"; + public static final String C_DUNNING_ID = "#C_Dunning_ID"; + public static final String C_PAYMENTTERM_ID = "#C_PaymentTerm_ID"; + public static final String C_REGION_ID = "#C_Region_ID"; + public static final String C_TAXCATEGORY_ID = "#C_TaxCategory_ID"; + public static final String C_TAX_ID = "#C_Tax_ID"; + public static final String C_UOM_ID = "#C_UOM_ID"; + public static final String DATE = "#Date"; + public static final String DB_TYPE = "#DBType"; + public static final String GL_CATEGORY_ID = "#GL_Category_ID"; + public static final String HAS_ALIAS = "$HasAlias"; + /** Context Language identifier */ + public static final String LANGUAGE = "#AD_Language"; + public static final String LANGUAGE_NAME = "#LanguageName"; + public static final String LOCAL_HTTP_ADDRESS = "#LocalHttpAddr"; + public static final String LOCALE = "#Locale"; + public static final String M_PRICELIST_ID = "#M_PriceList_ID"; + public static final String M_PRODUCT_CATEGORY_ID = "#M_Product_Category_ID"; + public static final String M_WAREHOUSE_ID = "#M_Warehouse_ID"; + /** Context for POS ID */ + public static final String POS_ID = "#POS_ID"; + public static final String R_STATUSCATEGORY_ID = "#R_StatusCategory_ID"; + public static final String R_STATUS_ID = "#R_Status_ID"; public static final String RUNNING_UNIT_TESTING_TEST_CASE = "#RUNNING_UNIT_TESTING_TEST_CASE"; - + public static final String SALESREP_ID = "#SalesRep_ID"; + public static final String SHOW_ACCOUNTING = "#ShowAcct"; + public static final String SHOW_ADVANCED = "#ShowAdvanced"; + public static final String SHOW_TRANSLATION = "#ShowTrl"; + public static final String STANDARD_PRECISION = "#StdPrecision"; + public static final String STANDARD_REPORT_FOOTER_TRADEMARK_TEXT = "#STANDARD_REPORT_FOOTER_TRADEMARK_TEXT"; + public static final String SYSTEM_NAME = "#System_Name"; + public static final String UI_CLIENT = "#UIClient"; + public static final String USER_LEVEL = "#User_Level"; + private final static ContextProvider clientContextProvider = new DefaultContextProvider(); + private static List eventListeners = new ArrayList(); public static int adWindowDummyID =200054; @@ -1013,12 +1053,6 @@ public final class Env * Language issues */ - /** Context Language identifier */ - static public final String LANGUAGE = "#AD_Language"; - - /** Context for POS ID */ - static public final String POS_ID = "#POS_ID"; - /** * Check Base Language * @param ctx context @@ -1154,8 +1188,7 @@ public final class Env } return language; } - - public static final String LOCALE = "#Locale"; + /** * @param ctx * @return Locale @@ -1356,9 +1389,9 @@ public final class Env sb.append(name).append(" "); } } - sb.append(getContext(ctx, "#AD_User_Name")).append("@") - .append(getContext(ctx, "#AD_Client_Name")).append(".") - .append(getContext(ctx, "#AD_Org_Name")) + sb.append(getContext(ctx, Env.AD_USER_NAME)).append("@") + .append(getContext(ctx, Env.AD_CLIENT_NAME)).append(".") + .append(getContext(ctx, Env.AD_ORG_NAME)) .append(" [").append(CConnection.get().toString()).append("]"); return sb.toString(); } // getHeader diff --git a/org.adempiere.base/src/org/compiere/util/Login.java b/org.adempiere.base/src/org/compiere/util/Login.java index b0c06fbb4b..48a904e9de 100644 --- a/org.adempiere.base/src/org/compiere/util/Login.java +++ b/org.adempiere.base/src/org/compiere/util/Login.java @@ -107,7 +107,7 @@ public class Login } } // - Env.setContext(ctx, "#Date", "2000-01-01"); + Env.setContext(ctx, Env.DATE, "2000-01-01"); // logger.exiting("Env", "initTest"); return ctx; } // testInit @@ -369,10 +369,10 @@ public class Login if (!rs.next()) // no record found if (force) { - Env.setContext(m_ctx, "#AD_User_Name", "System"); - Env.setContext(m_ctx, "#AD_User_ID", "0"); + Env.setContext(m_ctx, Env.AD_USER_NAME, "System"); + Env.setContext(m_ctx, Env.AD_USER_ID, "0"); Env.setContext(m_ctx, "#AD_User_Description", "System Forced Login"); - Env.setContext(m_ctx, "#User_Level", "S "); // Format 'SCO' + Env.setContext(m_ctx, Env.USER_LEVEL, "S "); // Format 'SCO' Env.setContext(m_ctx, "#User_Client", "0"); // Format c1, c2, ... Env.setContext(m_ctx, "#User_Org", "0"); // Format o1, o2, ... retValue = new KeyNamePair[] {new KeyNamePair(0, "System Administrator")}; @@ -384,9 +384,9 @@ public class Login return null; } - Env.setContext(m_ctx, "#AD_User_Name", app_user); - Env.setContext(m_ctx, "#AD_User_ID", rs.getInt(1)); - Env.setContext(m_ctx, "#SalesRep_ID", rs.getInt(1)); + Env.setContext(m_ctx, Env.AD_USER_NAME, app_user); + Env.setContext(m_ctx, Env.AD_USER_ID, rs.getInt(1)); + Env.setContext(m_ctx, Env.SALESREP_ID, rs.getInt(1)); if (Ini.isClient()) { @@ -485,11 +485,11 @@ public class Login } // Role Info - Env.setContext(m_ctx, "#AD_Role_ID", role.getKey()); - Env.setContext(m_ctx, "#AD_Role_Name", role.getName()); + Env.setContext(m_ctx, Env.AD_ROLE_ID, role.getKey()); + Env.setContext(m_ctx, Env.AD_ROLE_NAME, role.getName()); Ini.setProperty(Ini.P_ROLE, role.getName()); // User Level - Env.setContext(m_ctx, "#User_Level", rs.getString(1)); // Format 'SCO' + Env.setContext(m_ctx, Env.USER_LEVEL, rs.getString(1)); // Format 'SCO' // load Clients do @@ -529,11 +529,11 @@ public class Login { if (rol == null) throw new IllegalArgumentException("Rol missing"); - if (Env.getContext(m_ctx,"#AD_Client_ID").length() == 0) // could be number 0 + if (Env.getContext(m_ctx,Env.AD_CLIENT_ID).length() == 0) // could be number 0 throw new UnsupportedOperationException("Missing Context #AD_Client_ID"); - int AD_Client_ID = Env.getContextAsInt(m_ctx,"#AD_Client_ID"); - int AD_User_ID = Env.getContextAsInt(m_ctx, "#AD_User_ID"); + int AD_Client_ID = Env.getContextAsInt(m_ctx,Env.AD_CLIENT_ID); + int AD_User_ID = Env.getContextAsInt(m_ctx, Env.AD_USER_ID); // s_log.fine("Client: " + client.toStringX() + ", AD_Role_ID=" + AD_Role_ID); // get Client details for role @@ -571,11 +571,11 @@ public class Login return null; } // Role Info - Env.setContext(m_ctx, "#AD_Role_ID", rol.getKey()); - Env.setContext(m_ctx, "#AD_Role_Name", rol.getName()); + Env.setContext(m_ctx, Env.AD_ROLE_ID, rol.getKey()); + Env.setContext(m_ctx, Env.AD_ROLE_NAME, rol.getName()); Ini.setProperty(Ini.P_ROLE, rol.getName()); // User Level - Env.setContext(m_ctx, "#User_Level", rs.getString(1)); // Format 'SCO' + Env.setContext(m_ctx, Env.USER_LEVEL, rs.getString(1)); // Format 'SCO' // load Orgs do{ @@ -830,7 +830,7 @@ public class Login long today = System.currentTimeMillis(); if (timestamp != null) today = timestamp.getTime(); - Env.setContext(m_ctx, "#Date", new java.sql.Timestamp(today)); + Env.setContext(m_ctx, Env.DATE, new java.sql.Timestamp(today)); // Optional Printer if (printerName == null) @@ -845,19 +845,19 @@ public class Login loadUserPreferences(); if (MRole.getDefault(m_ctx, false).isShowAcct()) - Env.setContext(m_ctx, "#ShowAcct", Ini.getProperty(Ini.P_SHOW_ACCT)); + Env.setContext(m_ctx, Env.SHOW_ACCOUNTING, Ini.getProperty(Ini.P_SHOW_ACCT)); else - Env.setContext(m_ctx, "#ShowAcct", "N"); - Env.setContext(m_ctx, "#ShowTrl", Ini.getProperty(Ini.P_SHOW_TRL)); - Env.setContext(m_ctx, "#ShowAdvanced", MRole.getDefault().isAccessAdvanced()); + Env.setContext(m_ctx, Env.SHOW_ACCOUNTING, "N"); + Env.setContext(m_ctx, Env.SHOW_TRANSLATION, Ini.getProperty(Ini.P_SHOW_TRL)); + Env.setContext(m_ctx, Env.SHOW_ADVANCED, MRole.getDefault().isAccessAdvanced()); String retValue = ""; - int AD_Client_ID = Env.getContextAsInt(m_ctx, "#AD_Client_ID"); + int AD_Client_ID = Env.getContextAsInt(m_ctx, Env.AD_CLIENT_ID); int AD_Org_ID = org.getKey(); // Other Settings Env.setContext(m_ctx, "#YYYY", "Y"); - Env.setContext(m_ctx, "#StdPrecision", 2); + Env.setContext(m_ctx, Env.STANDARD_PRECISION, 2); // AccountSchema Info (first) String sql = "SELECT * " @@ -885,9 +885,9 @@ public class Login { // Accounting Info C_AcctSchema_ID = rs.getInt("C_AcctSchema_ID"); - Env.setContext(m_ctx, "$C_AcctSchema_ID", C_AcctSchema_ID); - Env.setContext(m_ctx, "$C_Currency_ID", rs.getInt("C_Currency_ID")); - Env.setContext(m_ctx, "$HasAlias", rs.getString("HasAlias")); + Env.setContext(m_ctx, Env.C_ACCTSCHEMA_ID, C_AcctSchema_ID); + Env.setContext(m_ctx, Env.C_CURRENCY_ID, rs.getInt("C_Currency_ID")); + Env.setContext(m_ctx, Env.HAS_ALIAS, rs.getString("HasAlias")); } DB.close(rs, pstmt); rs = null; pstmt = null; @@ -908,9 +908,9 @@ public class Login else { C_AcctSchema_ID = as.getC_AcctSchema_ID(); - Env.setContext(m_ctx, "$C_AcctSchema_ID", C_AcctSchema_ID); - Env.setContext(m_ctx, "$C_Currency_ID", as.getC_Currency_ID()); - Env.setContext(m_ctx, "$HasAlias", as.isHasAlias()); + Env.setContext(m_ctx, Env.C_ACCTSCHEMA_ID, C_AcctSchema_ID); + Env.setContext(m_ctx, Env.C_CURRENCY_ID, as.getC_Currency_ID()); + Env.setContext(m_ctx, Env.HAS_ALIAS, as.isHasAlias()); break; } } @@ -999,7 +999,7 @@ public class Login rs = null; pstmt = null; } // Country - Env.setContext(m_ctx, "#C_Country_ID", MCountry.getDefault().getC_Country_ID()); + Env.setContext(m_ctx, Env.C_COUNTRY_ID, MCountry.getDefault().getC_Country_ID()); // Call ModelValidators afterLoadPreferences - teo_sarca FR [ 1670025 ] ModelValidationEngine.get().afterLoadPreferences(m_ctx); return retValue; @@ -1343,7 +1343,7 @@ public class Login user.setIsLocked(false); user.setDateAccountLocked(null); user.setFailedLoginCount(0); - Env.setContext(Env.getCtx(), "#AD_Client_ID", user.getAD_Client_ID()); + Env.setContext(Env.getCtx(), Env.AD_CLIENT_ID, user.getAD_Client_ID()); if (!user.save()) log.severe("Failed to unlock user account"); } @@ -1357,7 +1357,7 @@ public class Login { user.setIsLocked(true); user.setDateAccountLocked(new Timestamp(now)); - Env.setContext(Env.getCtx(), "#AD_Client_ID", user.getAD_Client_ID()); + Env.setContext(Env.getCtx(), Env.AD_CLIENT_ID, user.getAD_Client_ID()); if (!user.save()) log.severe("Failed to lock user account"); } @@ -1466,7 +1466,7 @@ public class Login { user.setFailedLoginCount(0); user.setDateLastLogin(new Timestamp(now)); - Env.setContext(Env.getCtx(), "#AD_Client_ID", user.getAD_Client_ID()); + Env.setContext(Env.getCtx(), Env.AD_CLIENT_ID, user.getAD_Client_ID()); if (!user.save()) log.severe("Failed to update user record with date last login (" + user.getName() + " / clientID = " + user.getAD_Client_ID() + ")"); } @@ -1516,7 +1516,7 @@ public class Login user.setFailedLoginCount(count); user.setIsLocked(reachMaxAttempt); user.setDateAccountLocked(user.isLocked() ? new Timestamp(now) : null); - Env.setContext(Env.getCtx(), "#AD_Client_ID", user.getAD_Client_ID()); + Env.setContext(Env.getCtx(), Env.AD_CLIENT_ID, user.getAD_Client_ID()); if (!user.save()) log.severe("Failed to update user record with increase failed login count"); } @@ -1614,22 +1614,22 @@ public class Login rs = null; pstmt = null; } //Client Info - Env.setContext(m_ctx, "#AD_Client_ID", client.getKey()); - Env.setContext(m_ctx, "#AD_Client_Name", client.getName()); + Env.setContext(m_ctx, Env.AD_CLIENT_ID, client.getKey()); + Env.setContext(m_ctx, Env.AD_CLIENT_NAME, client.getName()); Ini.setProperty(Ini.P_CLIENT, client.getName()); return retValue; } // getRoles public KeyNamePair[] getClients() { - if (Env.getContext(m_ctx,"#AD_User_ID").length() == 0){ + if (Env.getContext(m_ctx,Env.AD_USER_ID).length() == 0){ throw new UnsupportedOperationException("Missing Context #AD_User_ID"); } loginErrMsg = null; isPasswordExpired = false; - int AD_User_ID = Env.getContextAsInt(m_ctx, "#AD_User_ID"); + int AD_User_ID = Env.getContextAsInt(m_ctx, Env.AD_USER_ID); KeyNamePair[] retValue = null; ArrayList clientList = new ArrayList(); StringBuilder sql= new StringBuilder("SELECT DISTINCT cli.AD_Client_ID, cli.Name, u.AD_User_ID, u.Name"); diff --git a/org.adempiere.base/src/org/compiere/util/WebUser.java b/org.adempiere.base/src/org/compiere/util/WebUser.java index b5c7f41a04..393a1c72b3 100644 --- a/org.adempiere.base/src/org/compiere/util/WebUser.java +++ b/org.adempiere.base/src/org/compiere/util/WebUser.java @@ -754,7 +754,7 @@ public class WebUser setPasswordOK (m_loggedIn, password); if (log.isLoggable(Level.FINE)) log.fine("success=" + m_loggedIn); if (m_loggedIn) - Env.setContext(m_ctx, "#AD_User_ID", getAD_User_ID()); + Env.setContext(m_ctx, Env.AD_USER_ID, getAD_User_ID()); return m_loggedIn; } // isLoggedIn diff --git a/org.adempiere.base/src/org/compiere/wf/MWFActivity.java b/org.adempiere.base/src/org/compiere/wf/MWFActivity.java index a03e5e267a..d2cd2a305a 100644 --- a/org.adempiere.base/src/org/compiere/wf/MWFActivity.java +++ b/org.adempiere.base/src/org/compiere/wf/MWFActivity.java @@ -967,7 +967,7 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable try { if (contextLost) { - Env.getCtx().setProperty("#AD_Client_ID", (m_po != null ? Integer.toString(m_po.getAD_Client_ID()) : "0") ); + Env.getCtx().setProperty(Env.AD_CLIENT_ID, (m_po != null ? Integer.toString(m_po.getAD_Client_ID()) : "0") ); m_state = new StateEngine(WFSTATE_Running); setProcessed(true); setWFState (StateEngine.STATE_Aborted); @@ -992,7 +992,7 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable } } finally { if (contextLost) - Env.getCtx().remove("#AD_Client_ID"); + Env.getCtx().remove(Env.AD_CLIENT_ID); } } finally diff --git a/org.adempiere.base/src/org/compiere/wf/MWorkflow.java b/org.adempiere.base/src/org/compiere/wf/MWorkflow.java index 7351fe3b5a..aae36a62e0 100644 --- a/org.adempiere.base/src/org/compiere/wf/MWorkflow.java +++ b/org.adempiere.base/src/org/compiere/wf/MWorkflow.java @@ -995,9 +995,9 @@ public class MWorkflow extends X_AD_Workflow implements ImmutablePOSupport /** - Env.setContext(Env.getCtx(), "#AD_Client_ID ", "11"); - Env.setContext(Env.getCtx(), "#AD_Org_ID ", "11"); - Env.setContext(Env.getCtx(), "#AD_User_ID ", "100"); + Env.setContext(Env.getCtx(), Env.AD_CLIENT_ID, "11"); + Env.setContext(Env.getCtx(), Env.AD_ORG_ID, "11"); + Env.setContext(Env.getCtx(), Env.AD_USER_ID, "100"); // int AD_Workflow_ID = 115; // Requisition WF int M_Requsition_ID = 100; diff --git a/org.adempiere.base/src/org/eevolution/model/MDDOrder.java b/org.adempiere.base/src/org/eevolution/model/MDDOrder.java index 14fc6585c0..3f894242a4 100644 --- a/org.adempiere.base/src/org/eevolution/model/MDDOrder.java +++ b/org.adempiere.base/src/org/eevolution/model/MDDOrder.java @@ -607,7 +607,7 @@ public class MDDOrder extends X_DD_Order implements DocAction // Default Warehouse if (getM_Warehouse_ID() == 0) { - int ii = Env.getContextAsInt(getCtx(), "#M_Warehouse_ID"); + int ii = Env.getContextAsInt(getCtx(), Env.M_WAREHOUSE_ID); if (ii != 0) setM_Warehouse_ID(ii); else @@ -637,7 +637,7 @@ public class MDDOrder extends X_DD_Order implements DocAction // Default Sales Rep if (getSalesRep_ID() == 0) { - int ii = Env.getContextAsInt(getCtx(), "#AD_User_ID"); + int ii = Env.getContextAsInt(getCtx(), Env.AD_USER_ID); if (ii != 0) setSalesRep_ID (ii); } diff --git a/org.adempiere.base/src/org/eevolution/process/BankTransfer.java b/org.adempiere.base/src/org/eevolution/process/BankTransfer.java index 83374c1f7f..9bc96432c4 100644 --- a/org.adempiere.base/src/org/eevolution/process/BankTransfer.java +++ b/org.adempiere.base/src/org/eevolution/process/BankTransfer.java @@ -127,7 +127,7 @@ public class BankTransfer extends SvrProcess // Login Date if (p_StatementDate == null) - p_StatementDate = Env.getContextAsDate(getCtx(), "#Date"); + p_StatementDate = Env.getContextAsDate(getCtx(), Env.DATE); if (p_StatementDate == null) p_StatementDate = new Timestamp(System.currentTimeMillis()); diff --git a/org.adempiere.pipo/src/org/adempiere/pipo/srv/PipoDictionaryService.java b/org.adempiere.pipo/src/org/adempiere/pipo/srv/PipoDictionaryService.java index 74f34bf8f2..50e0f70780 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo/srv/PipoDictionaryService.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo/srv/PipoDictionaryService.java @@ -61,8 +61,8 @@ public class PipoDictionaryService implements IDictionaryService { else packIn.setPackageName(symbolicName); - if (Env.getCtx().getProperty("#AD_Client_ID") == null) { - Env.getCtx().put("#AD_Client_ID", 0); + if (Env.getCtx().getProperty(Env.AD_CLIENT_ID) == null) { + Env.getCtx().put(Env.AD_CLIENT_ID, 0); } //get package version from file name suffix or bundle header String packageVersion = null; diff --git a/org.adempiere.pipo/src/org/adempiere/pipo2/PackInProcess.java b/org.adempiere.pipo/src/org/adempiere/pipo2/PackInProcess.java index d3d746979e..25b5efe361 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo2/PackInProcess.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo2/PackInProcess.java @@ -84,7 +84,7 @@ public class PackInProcess extends SvrProcess { packageDirectory = System.getProperty("java.io.tmpdir"); } - String targetDirName = packageDirectory + File.separator + "packin" + Env.getContext(getCtx(), "#AD_User_ID"); + String targetDirName = packageDirectory + File.separator + "packin" + Env.getContext(getCtx(), Env.AD_USER_ID); File targetDir = new File(targetDirName); if (targetDir.exists()) { @@ -116,7 +116,7 @@ public class PackInProcess extends SvrProcess { Zipper.unpackFile(zipFilepath, targetDir); String dict_file = packageDirectory + File.separator - + "packin" + Env.getContext(getCtx(), "#AD_User_ID") + File.separator + parentDir + File.separator + + "packin" + Env.getContext(getCtx(), Env.AD_USER_ID) + File.separator + parentDir + File.separator + "dict" + File.separator + "PackOut.xml"; if (log.isLoggable(Level.INFO)) log.info("dict file->" + dict_file); @@ -127,7 +127,7 @@ public class PackInProcess extends SvrProcess { m_UpdateDictionary = false; m_packageDirectory = packageDirectory + File.separator - + "packin" + Env.getContext(getCtx(), "#AD_User_ID") + File.separator + parentDir + File.separator; + + "packin" + Env.getContext(getCtx(), Env.AD_USER_ID) + File.separator + parentDir + File.separator; PackIn packIn = new PackIn(); packIn.setPackageDirectory(m_packageDirectory); diff --git a/org.adempiere.pipo/src/org/adempiere/pipo2/PackOutProcess.java b/org.adempiere.pipo/src/org/adempiere/pipo2/PackOutProcess.java index 362d4a346d..e145e466ac 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo2/PackOutProcess.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo2/PackOutProcess.java @@ -103,7 +103,7 @@ public class PackOutProcess extends SvrProcess packoutDirectory = System.getProperty("java.io.tmpdir"); if (!packoutDirectory.endsWith("/") && !packoutDirectory.endsWith("\\")) packoutDirectory+= File.separator; - packoutDirectory = packoutDirectory + "packout" + Env.getContext(getCtx(), "#AD_User_ID") + File.separator; + packoutDirectory = packoutDirectory + "packout" + Env.getContext(getCtx(), Env.AD_USER_ID) + File.separator; //create packout folder if needed File packoutDirectoryFile = new File(packoutDirectory); diff --git a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AdempiereActivator.java b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AdempiereActivator.java index 1943e4506b..2f3a639f55 100644 --- a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AdempiereActivator.java +++ b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AdempiereActivator.java @@ -136,7 +136,7 @@ public class AdempiereActivator extends AbstractActivator { protected void setupPackInContext() { Properties serverContext = new Properties(); - serverContext.setProperty("#AD_Client_ID", "0"); + serverContext.setProperty(Env.AD_CLIENT_ID, "0"); ServerContext.setCurrentInstance(serverContext); }; diff --git a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/Incremental2PackActivator.java b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/Incremental2PackActivator.java index 558073d2b0..b42f15c606 100644 --- a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/Incremental2PackActivator.java +++ b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/Incremental2PackActivator.java @@ -122,7 +122,7 @@ public class Incremental2PackActivator extends AbstractActivator { Trx trx = Trx.get(Trx.createTrxName(), true); trx.setDisplayName(getClass().getName()+"_packIn"); try { - Env.getCtx().put("#AD_Client_ID", 0); + Env.getCtx().put(Env.AD_CLIENT_ID, 0); firstImp = new X_AD_Package_Imp(Env.getCtx(), 0, trx.getTrxName()); firstImp.setName(getName()); @@ -256,7 +256,7 @@ public class Incremental2PackActivator extends AbstractActivator { protected void setupPackInContext() { Properties serverContext = new Properties(); - serverContext.setProperty("#AD_Client_ID", "0"); + serverContext.setProperty(Env.AD_CLIENT_ID, "0"); ServerContext.setCurrentInstance(serverContext); }; diff --git a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/PackInApplicationActivator.java b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/PackInApplicationActivator.java index 5666eafabd..1baa1189d7 100644 --- a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/PackInApplicationActivator.java +++ b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/PackInApplicationActivator.java @@ -99,7 +99,7 @@ public class PackInApplicationActivator extends AbstractActivator{ try { if (getDBLock()) { //Create Session to be able to create records in AD_ChangeLog - if (Env.getContextAsInt(Env.getCtx(), "#AD_Session_ID") <= 0) + if (Env.getContextAsInt(Env.getCtx(), Env.AD_SESSION_ID) <= 0) MSession.get(Env.getCtx(), true); for(File zipFile : fileArray) { currentFile = zipFile; @@ -188,7 +188,7 @@ public class PackInApplicationActivator extends AbstractActivator{ String message = "Installing " + fileName + " in client " + client.getValue() + "/" + client.getName(); statusUpdate(message); } - Env.setContext(Env.getCtx(), "#AD_Client_ID", client.getAD_Client_ID()); + Env.setContext(Env.getCtx(), Env.AD_CLIENT_ID, client.getAD_Client_ID()); try { // call 2pack if (service != null) { @@ -204,7 +204,7 @@ public class PackInApplicationActivator extends AbstractActivator{ logger.log(Level.WARNING, "Pack in failed.", e); return false; } finally { - Env.setContext(Env.getCtx(), "#AD_Client_ID", 0); + Env.setContext(Env.getCtx(), Env.AD_CLIENT_ID, 0); } logger.warning(packinFile.getPath() + " installed"); } @@ -335,7 +335,7 @@ public class PackInApplicationActivator extends AbstractActivator{ protected void setupPackInContext() { Properties serverContext = new Properties(); - serverContext.setProperty("#AD_Client_ID", "0"); + serverContext.setProperty(Env.AD_CLIENT_ID, "0"); ServerContext.setCurrentInstance(serverContext); } diff --git a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/Version2PackActivator.java b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/Version2PackActivator.java index 18271dadc3..f0f3290e54 100644 --- a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/Version2PackActivator.java +++ b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/Version2PackActivator.java @@ -223,7 +223,7 @@ public class Version2PackActivator extends AbstractActivator{ protected void setupPackInContext() { Properties serverContext = new Properties(); - serverContext.setProperty("#AD_Client_ID", "0"); + serverContext.setProperty(Env.AD_CLIENT_ID, "0"); ServerContext.setCurrentInstance(serverContext); }; diff --git a/org.adempiere.replication.server/src/org/compiere/server/ReplicationProcessor.java b/org.adempiere.replication.server/src/org/compiere/server/ReplicationProcessor.java index 2e7e714dea..0f06cec540 100644 --- a/org.adempiere.replication.server/src/org/compiere/server/ReplicationProcessor.java +++ b/org.adempiere.replication.server/src/org/compiere/server/ReplicationProcessor.java @@ -98,14 +98,14 @@ public class ReplicationProcessor extends AdempiereServer { // process is not started! // Prepare a ctx - Env.setContext(mImportProcessor.getCtx(), "#AD_Client_ID", mImportProcessor.getAD_Client_ID()); - Env.setContext(mImportProcessor.getCtx(), "#AD_Org_ID", mImportProcessor.getAD_Org_ID()); + Env.setContext(mImportProcessor.getCtx(), Env.AD_CLIENT_ID, mImportProcessor.getAD_Client_ID()); + Env.setContext(mImportProcessor.getCtx(), Env.AD_ORG_ID, mImportProcessor.getAD_Org_ID()); if (mImportProcessor.getAD_Org_ID() != 0) { MOrgInfo schedorg = MOrgInfo.get(getCtx(), mImportProcessor.getAD_Org_ID(), null); if (schedorg.getM_Warehouse_ID() > 0) - Env.setContext(mImportProcessor.getCtx(), "#M_Warehouse_ID", schedorg.getM_Warehouse_ID()); + Env.setContext(mImportProcessor.getCtx(), Env.M_WAREHOUSE_ID, schedorg.getM_Warehouse_ID()); } - Env.setContext(mImportProcessor.getCtx(), "#AD_User_ID", getAD_User_ID()); + Env.setContext(mImportProcessor.getCtx(), Env.AD_USER_ID, getAD_User_ID()); m_summary = new StringBuffer(); String trxName = mImportProcessor.get_TrxName(); diff --git a/org.adempiere.replication/src/org/adempiere/process/rpl/imp/ImportHelper.java b/org.adempiere.replication/src/org/adempiere/process/rpl/imp/ImportHelper.java index ed50251051..f858e24a57 100755 --- a/org.adempiere.replication/src/org/adempiere/process/rpl/imp/ImportHelper.java +++ b/org.adempiere.replication/src/org/adempiere/process/rpl/imp/ImportHelper.java @@ -172,7 +172,7 @@ public class ImportHelper { if(po != null) { - Env.setContext(po.getCtx(), "#AD_Client_ID", po.getAD_Client_ID()); + Env.setContext(po.getCtx(), Env.AD_CLIENT_ID, po.getAD_Client_ID()); if(MReplicationStrategy.REPLICATION_TABLE==ReplicationMode) { diff --git a/org.adempiere.report.jasper/src/org/adempiere/report/jasper/ReportStarter.java b/org.adempiere.report.jasper/src/org/adempiere/report/jasper/ReportStarter.java index 4c235c30f4..a4b145b5c8 100644 --- a/org.adempiere.report.jasper/src/org/adempiere/report/jasper/ReportStarter.java +++ b/org.adempiere.report.jasper/src/org/adempiere/report/jasper/ReportStarter.java @@ -422,7 +422,7 @@ public class ReportStarter implements ProcessCall, ClientProcess return false; } if (reportPath.startsWith("@#LocalHttpAddr@")) { - String localaddr = Env.getContext(Env.getCtx(), "#LocalHttpAddr"); + String localaddr = Env.getContext(Env.getCtx(), Env.LOCAL_HTTP_ADDRESS); if (!Util.isEmpty(localaddr)) { reportPath = reportPath.replace("@#LocalHttpAddr@", localaddr); } @@ -593,10 +593,10 @@ public class ReportStarter implements ProcessCall, ClientProcess params.put("AD_ROLE_ID", Integer.valueOf( Env.getAD_Role_ID(Env.getCtx()))); params.put("AD_USER_ID", Integer.valueOf( Env.getAD_User_ID(Env.getCtx()))); - params.put("AD_CLIENT_NAME", Env.getContext(Env.getCtx(), "#AD_Client_Name")); - params.put("AD_ROLE_NAME", Env.getContext(Env.getCtx(), "#AD_Role_Name")); - params.put("AD_USER_NAME", Env.getContext(Env.getCtx(), "#AD_User_Name")); - params.put("AD_ORG_NAME", Env.getContext(Env.getCtx(), "#AD_Org_Name")); + params.put("AD_CLIENT_NAME", Env.getContext(Env.getCtx(), Env.AD_CLIENT_NAME)); + params.put("AD_ROLE_NAME", Env.getContext(Env.getCtx(), Env.AD_ROLE_NAME)); + params.put("AD_USER_NAME", Env.getContext(Env.getCtx(), Env.AD_USER_NAME)); + params.put("AD_ORG_NAME", Env.getContext(Env.getCtx(), Env.AD_ORG_NAME)); params.put("BASE_DIR", REPORT_HOME.getAbsolutePath()); //params.put("HeaderLogo", reportPath); //params.put("LoginLogo", reportPath); diff --git a/org.adempiere.server/src/main/server/org/compiere/server/AcctProcessor.java b/org.adempiere.server/src/main/server/org/compiere/server/AcctProcessor.java index bc301da1bd..361aa8cfb4 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/AcctProcessor.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/AcctProcessor.java @@ -77,23 +77,23 @@ public class AcctProcessor extends AdempiereServer m_summary = new StringBuffer(); // Prepar ctx - Env.setContext(getCtx(), "#AD_Client_ID", m_client.getAD_Client_ID()); - Env.setContext(getCtx(), "#AD_Language", m_client.getAD_Language()); - Env.setContext(getCtx(), "#AD_Org_ID", m_model.getAD_Org_ID()); + Env.setContext(getCtx(), Env.AD_CLIENT_ID, m_client.getAD_Client_ID()); + Env.setContext(getCtx(), Env.LANGUAGE, m_client.getAD_Language()); + Env.setContext(getCtx(), Env.AD_ORG_ID, m_model.getAD_Org_ID()); if (m_model.getAD_Org_ID() != 0) { MOrgInfo schedorg = MOrgInfo.get(getCtx(), m_model.getAD_Org_ID(), null); if (schedorg.getM_Warehouse_ID() > 0) - Env.setContext(getCtx(), "#M_Warehouse_ID", schedorg.getM_Warehouse_ID()); + Env.setContext(getCtx(), Env.M_WAREHOUSE_ID, schedorg.getM_Warehouse_ID()); } - Env.setContext(getCtx(), "#AD_User_ID", getAD_User_ID()); - Env.setContext(getCtx(), "#SalesRep_ID", getAD_User_ID()); + Env.setContext(getCtx(), Env.AD_USER_ID, getAD_User_ID()); + Env.setContext(getCtx(), Env.SALESREP_ID, getAD_User_ID()); MUser scheduser = MUser.get(getCtx(), getAD_User_ID()); MRole[] schedroles = scheduser.getRoles(m_model.getAD_Org_ID()); if (schedroles != null && schedroles.length > 0) - Env.setContext(getCtx(), "#AD_Role_ID", schedroles[0].getAD_Role_ID()); // first role, ordered by AD_Role_ID + Env.setContext(getCtx(), Env.AD_ROLE_ID, schedroles[0].getAD_Role_ID()); // first role, ordered by AD_Role_ID Timestamp ts = new Timestamp(System.currentTimeMillis()); SimpleDateFormat dateFormat4Timestamp = new SimpleDateFormat("yyyy-MM-dd"); - Env.setContext(getCtx(), "#Date", dateFormat4Timestamp.format(ts)+" 00:00:00" ); // JDBC format + Env.setContext(getCtx(), Env.DATE, dateFormat4Timestamp.format(ts)+" 00:00:00" ); // JDBC format // Get Schemata if (m_model.getC_AcctSchema_ID() == 0) diff --git a/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServer.java b/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServer.java index f91a1d5e31..71a115fc05 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServer.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServer.java @@ -155,30 +155,30 @@ public abstract class AdempiereServer implements Runnable { Properties context = new Properties(); MClient schedclient = MClient.get(getCtx(), p_model.getAD_Client_ID()); - Env.setContext(context, "#AD_Client_ID", schedclient.getAD_Client_ID()); - Env.setContext(context, "#AD_Language", schedclient.getAD_Language()); + Env.setContext(context, Env.AD_CLIENT_ID, schedclient.getAD_Client_ID()); + Env.setContext(context, Env.LANGUAGE, schedclient.getAD_Language()); if (p_model instanceof PO) { PO po = (PO) p_model; if (po.get_ColumnIndex("AD_Org_ID") >= 0) { - Env.setContext(context, "#AD_Org_ID", po.get_ValueAsInt("AD_Org_ID")); + Env.setContext(context, Env.AD_ORG_ID, po.get_ValueAsInt("AD_Org_ID")); MOrgInfo schedorg = new Query(context, MOrgInfo.Table_Name, "AD_Org_ID=?", null) .setParameters(po.get_ValueAsInt("AD_Org_ID")).first(); if (schedorg != null && schedorg.getM_Warehouse_ID() > 0) - Env.setContext(context, "#M_Warehouse_ID", schedorg.getM_Warehouse_ID()); + Env.setContext(context, Env.M_WAREHOUSE_ID, schedorg.getM_Warehouse_ID()); } int AD_User_ID = getAD_User_ID(po); if (AD_User_ID > 0) { - Env.setContext(context, "#AD_User_ID", AD_User_ID); - Env.setContext(context, "#SalesRep_ID", AD_User_ID); + Env.setContext(context, Env.AD_USER_ID, AD_User_ID); + Env.setContext(context, Env.SALESREP_ID, AD_User_ID); MUser scheduser = new MUser(context, AD_User_ID, null); MRole[] schedroles = scheduser.getRoles(po.get_ValueAsInt("AD_Org_ID")); if (schedroles != null && schedroles.length > 0) - Env.setContext(context, "#AD_Role_ID", schedroles[0].getAD_Role_ID()); // first role, ordered by AD_Role_ID + Env.setContext(context, Env.AD_ROLE_ID, schedroles[0].getAD_Role_ID()); // first role, ordered by AD_Role_ID } } Timestamp ts = new Timestamp(System.currentTimeMillis()); SimpleDateFormat dateFormat4Timestamp = new SimpleDateFormat("yyyy-MM-dd"); - Env.setContext(context, "#Date", dateFormat4Timestamp.format(ts)+" 00:00:00" ); // JDBC format + Env.setContext(context, Env.DATE, dateFormat4Timestamp.format(ts)+" 00:00:00" ); // JDBC format Properties prevContext = ServerContext.getCurrentInstance(); try { @@ -240,13 +240,13 @@ public abstract class AdempiereServer implements Runnable } Properties context = new Properties(); - Env.setContext(context, "#AD_Client_ID", p_model.getAD_Client_ID()); + Env.setContext(context, Env.AD_CLIENT_ID, p_model.getAD_Client_ID()); if (p_model instanceof PO) { PO po = (PO) p_model; if (po.get_ColumnIndex("AD_Org_ID") >= 0) - Env.setContext(context, "#AD_Org_ID", po.get_ValueAsInt("AD_Org_ID")); + Env.setContext(context, Env.AD_ORG_ID, po.get_ValueAsInt("AD_Org_ID")); if (po.get_ColumnIndex("AD_User_ID") >= 0) - Env.setContext(context, "#AD_User_ID", po.get_ValueAsInt("AD_User_ID")); + Env.setContext(context, Env.AD_USER_ID, po.get_ValueAsInt("AD_User_ID")); } try { diff --git a/org.adempiere.server/src/main/server/org/compiere/server/Scheduler.java b/org.adempiere.server/src/main/server/org/compiere/server/Scheduler.java index 6c6a8355f9..0d91a4584f 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/Scheduler.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/Scheduler.java @@ -98,24 +98,24 @@ public class Scheduler extends AdempiereServer // Prepare a ctx for the report/process - BF [1966880] MClient schedclient = MClient.get(getCtx(), scheduler.getAD_Client_ID()); - Env.setContext(getCtx(), "#AD_Client_ID", schedclient.getAD_Client_ID()); - Env.setContext(getCtx(), "#AD_Language", schedclient.getAD_Language()); - Env.setContext(getCtx(), "#AD_Org_ID", scheduler.getAD_Org_ID()); + Env.setContext(getCtx(), Env.AD_CLIENT_ID, schedclient.getAD_Client_ID()); + Env.setContext(getCtx(), Env.LANGUAGE, schedclient.getAD_Language()); + Env.setContext(getCtx(), Env.AD_ORG_ID, scheduler.getAD_Org_ID()); if (scheduler.getAD_Org_ID() != 0) { MOrgInfo schedorg = MOrgInfo.get(getCtx(), scheduler.getAD_Org_ID(), null); if (schedorg.getM_Warehouse_ID() > 0) - Env.setContext(getCtx(), "#M_Warehouse_ID", schedorg.getM_Warehouse_ID()); + Env.setContext(getCtx(), Env.M_WAREHOUSE_ID, schedorg.getM_Warehouse_ID()); } - Env.setContext(getCtx(), "#AD_User_ID", getAD_User_ID()); - Env.setContext(getCtx(), "#SalesRep_ID", getAD_User_ID()); + Env.setContext(getCtx(), Env.AD_USER_ID, getAD_User_ID()); + Env.setContext(getCtx(), Env.SALESREP_ID, getAD_User_ID()); // TODO: It can be convenient to add AD_Scheduler.AD_Role_ID MUser scheduser = MUser.get(getCtx(), getAD_User_ID()); MRole[] schedroles = scheduser.getRoles(scheduler.getAD_Org_ID()); if (schedroles != null && schedroles.length > 0) - Env.setContext(getCtx(), "#AD_Role_ID", schedroles[0].getAD_Role_ID()); // first role, ordered by AD_Role_ID + Env.setContext(getCtx(), Env.AD_ROLE_ID, schedroles[0].getAD_Role_ID()); // first role, ordered by AD_Role_ID Timestamp ts = new Timestamp(System.currentTimeMillis()); SimpleDateFormat dateFormat4Timestamp = new SimpleDateFormat("yyyy-MM-dd"); - Env.setContext(getCtx(), "#Date", dateFormat4Timestamp.format(ts)+" 00:00:00" ); // JDBC format + Env.setContext(getCtx(), Env.DATE, dateFormat4Timestamp.format(ts)+" 00:00:00" ); // JDBC format //Create new Session and set #AD_Session_ID to context MSession session = MSession.get(getCtx(), true); @@ -140,7 +140,7 @@ public class Scheduler extends AdempiereServer m_trx.close(); session.logout(); - getCtx().remove("#AD_Session_ID"); + getCtx().remove(Env.AD_SESSION_ID); } // @@ -312,7 +312,7 @@ public class Scheduler extends AdempiereServer mailContent = scheduler.getDescription(); }else{ mailTemplate.setUser(user); - mailTemplate.setLanguage(Env.getContext(getCtx(), "#AD_Language")); + mailTemplate.setLanguage(Env.getContext(getCtx(), Env.LANGUAGE)); // if user has bpartner link. maybe use language depend user mailContent = mailTemplate.getMailText(true); schedulerName = mailTemplate.getMailHeader(); @@ -555,7 +555,7 @@ public class Scheduler extends AdempiereServer else value = env; - if (tail != null && columnName.equals("#Date")) + if (tail != null && columnName.equals(Env.DATE)) { tail = tail.trim(); if (tail.startsWith("-") || tail.startsWith("+")) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java index 14bff61444..1036de0782 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java @@ -195,7 +195,7 @@ public class AdempiereWebUI extends Window implements EventListener, IWeb } MSystem system = MSystem.get(Env.getCtx()); - Env.setContext(ctx, "#System_Name", system.getName()); + Env.setContext(ctx, Env.SYSTEM_NAME, system.getName()); // Validate language Language language = Language.getLanguage(langLogin); @@ -241,8 +241,8 @@ public class AdempiereWebUI extends Window implements EventListener, IWeb currSess.setAttribute("Check_AD_User_ID", Env.getAD_User_ID(ctx)); //enable full interface, relook into this when doing preference - Env.setContext(ctx, "#ShowTrl", true); - Env.setContext(ctx, "#ShowAcct", MRole.getDefault().isShowAcct()); + Env.setContext(ctx, Env.SHOW_TRANSLATION, true); + Env.setContext(ctx, Env.SHOW_ACCOUNTING, MRole.getDefault().isShowAcct()); // to reload preferences when the user refresh the browser userPreference = loadUserPreference(Env.getAD_User_ID(ctx)); @@ -276,15 +276,15 @@ public class AdempiereWebUI extends Window implements EventListener, IWeb MUser user = MUser.get(ctx); BrowserToken.save(mSession, user); - Env.setContext(ctx, "#UIClient", "zk"); - Env.setContext(ctx, "#DBType", DB.getDatabase().getName()); + Env.setContext(ctx, Env.UI_CLIENT, "zk"); + Env.setContext(ctx, Env.DB_TYPE, DB.getDatabase().getName()); StringBuilder localHttpAddr = new StringBuilder(Executions.getCurrent().getScheme()); localHttpAddr.append("://").append(Executions.getCurrent().getLocalAddr()); int port = Executions.getCurrent().getLocalPort(); if (port > 0 && port != 80) { localHttpAddr.append(":").append(port); } - Env.setContext(ctx, "#LocalHttpAddr", localHttpAddr.toString()); + Env.setContext(ctx, Env.LOCAL_HTTP_ADDRESS, localHttpAddr.toString()); Clients.response(new AuScript("zAu.cmd0.clearBusy()")); //init favorite diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java index 65ec4213ea..5c069cfd39 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java @@ -206,7 +206,7 @@ public final class AEnv */ public static void logout() { - String sessionID = Env.getContext(Env.getCtx(), "#AD_Session_ID"); + String sessionID = Env.getContext(Env.getCtx(), Env.AD_SESSION_ID); synchronized (windowCache) { CCache cache = windowCache.get(sessionID); @@ -222,7 +222,7 @@ public final class AEnv if (session != null) session.logout(); - Env.setContext(Env.getCtx(), "#AD_Session_ID", (String)null); + Env.setContext(Env.getCtx(), Env.AD_SESSION_ID, (String)null); // } @@ -272,7 +272,7 @@ public final class AEnv if (log.isLoggable(Level.CONFIG)) log.config("Window=" + WindowNo + ", AD_Window_ID=" + AD_Window_ID); GridWindowVO mWindowVO = null; - String sessionID = Env.getContext(Env.getCtx(), "#AD_Session_ID"); + String sessionID = Env.getContext(Env.getCtx(), Env.AD_SESSION_ID); if (AD_Window_ID != 0 && Ini.isCacheWindow()) // try cache { synchronized (windowCache) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AbstractProcessDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AbstractProcessDialog.java index 87e991f947..f824844808 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AbstractProcessDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AbstractProcessDialog.java @@ -501,7 +501,7 @@ public abstract class AbstractProcessDialog extends Window implements IProcessUI protected void querySaved() { //user query - savedParams = MPInstance.get(Env.getCtx(), getAD_Process_ID(), Env.getContextAsInt(Env.getCtx(), "#AD_User_ID")); + savedParams = MPInstance.get(Env.getCtx(), getAD_Process_ID(), Env.getContextAsInt(Env.getCtx(), Env.AD_USER_ID)); fSavedName.removeAllItems(); for (MPInstance instance : savedParams) { @@ -597,7 +597,7 @@ public abstract class AbstractProcessDialog extends Window implements IProcessUI final String where = "AD_Process_ID = ? AND AD_User_ID = ? AND Name IS NULL "; return new Query(Env.getCtx(), MPInstance.Table_Name, where, null) .setOnlyActiveRecords(true).setClient_ID() - .setParameters(m_AD_Process_ID, Env.getContextAsInt(Env.getCtx(), "#AD_User_ID")) + .setParameters(m_AD_Process_ID, Env.getContextAsInt(Env.getCtx(), Env.AD_USER_ID)) .setOrderBy("Created DESC") .first(); } @@ -1167,13 +1167,13 @@ public abstract class AbstractProcessDialog extends Window implements IProcessUI super(); m_ctx = new Properties(); - Env.setContext(m_ctx, "#AD_Client_ID", ctx.getProperty("#AD_Client_ID")); - Env.setContext(m_ctx, "#AD_Org_ID", ctx.getProperty("#AD_Org_ID")); - Env.setContext(m_ctx, "#AD_Role_ID", ctx.getProperty("#AD_Role_ID")); - Env.setContext(m_ctx, "#M_Warehouse_ID", ctx.getProperty("#M_Warehouse_ID")); - Env.setContext(m_ctx, "#AD_Language", ctx.getProperty("#AD_Language")); - Env.setContext(m_ctx, "#AD_User_ID", ctx.getProperty("#AD_User_ID")); - Env.setContext(m_ctx, "#Date", ctx.getProperty("#Date")); + Env.setContext(m_ctx, Env.AD_CLIENT_ID, ctx.getProperty(Env.AD_CLIENT_ID)); + Env.setContext(m_ctx, Env.AD_ORG_ID, ctx.getProperty(Env.AD_ORG_ID)); + Env.setContext(m_ctx, Env.AD_ROLE_ID, ctx.getProperty(Env.AD_ROLE_ID)); + Env.setContext(m_ctx, Env.M_WAREHOUSE_ID, ctx.getProperty(Env.M_WAREHOUSE_ID)); + Env.setContext(m_ctx, Env.LANGUAGE, ctx.getProperty(Env.LANGUAGE)); + Env.setContext(m_ctx, Env.AD_USER_ID, ctx.getProperty(Env.AD_USER_ID)); + Env.setContext(m_ctx, Env.DATE, ctx.getProperty(Env.DATE)); } @Override diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WAllocation.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WAllocation.java index c7ee486272..9aa46117ab 100755 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WAllocation.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WAllocation.java @@ -459,7 +459,7 @@ public class WAllocation extends Allocation // Date set to Login Date Calendar cal = Calendar.getInstance(); - cal.setTime(Env.getContextAsDate(Env.getCtx(), "#Date")); + cal.setTime(Env.getContextAsDate(Env.getCtx(), Env.DATE)); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WInOutGen.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WInOutGen.java index 4b56811905..7d75a27bf1 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WInOutGen.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WInOutGen.java @@ -166,7 +166,7 @@ public class WInOutGen extends InOutGen implements IFormController, EventListene fWarehouse = new WTableDirEditor ("M_Warehouse_ID", true, false, true, orgL); lWarehouse.setText(Msg.translate(Env.getCtx(), "M_Warehouse_ID")); fWarehouse.addValueChangeListener(this); - fWarehouse.setValue(Env.getContextAsInt(Env.getCtx(), "#M_Warehouse_ID")); + fWarehouse.setValue(Env.getContextAsInt(Env.getCtx(), Env.M_WAREHOUSE_ID)); setM_Warehouse_ID(fWarehouse.getValue()); // Document Action Prepared/ Completed lDocAction.setText(Msg.translate(Env.getCtx(), "DocAction")); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/FavouriteController.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/FavouriteController.java index 198de6b34e..2267178a63 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/FavouriteController.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/FavouriteController.java @@ -86,7 +86,7 @@ public class FavouriteController { { int AD_Client_ID = MUser.get(Env.getCtx()).getAD_Client_ID(); int AD_Org_ID = 0; - int AD_User_ID = Env.getContextAsInt(Env.getCtx(), "#AD_User_ID"); + int AD_User_ID = Env.getContextAsInt(Env.getCtx(), Env.AD_USER_ID); StringBuilder sql = new StringBuilder(); if (add) sql.append("INSERT INTO AD_TreeBar " diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WAccountEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WAccountEditor.java index 432b0ce90b..c339bf3b26 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WAccountEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WAccountEditor.java @@ -124,7 +124,7 @@ public class WAccountEditor extends WEditor implements ContextMenuListener // Try to get C_AcctSchema_ID from global context - teo_sarca BF [ 1830531 ] if (C_AcctSchema_ID <= 0) { - C_AcctSchema_ID = Env.getContextAsInt(Env.getCtx(), "$C_AcctSchema_ID"); + C_AcctSchema_ID = Env.getContextAsInt(Env.getCtx(), Env.C_ACCTSCHEMA_ID); } new WAccountDialog (gridField.getHeader(), m_mAccount, C_AcctSchema_ID, new Callback() { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WRadioGroupEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WRadioGroupEditor.java index 680f2100ca..fb733298f7 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WRadioGroupEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WRadioGroupEditor.java @@ -153,7 +153,7 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L lookup.setMandatory(true); lookup.setMandatory(isMandatory()); - if ((lookup.getDisplayType() == DisplayType.List && Env.getContextAsInt(Env.getCtx(), "#AD_Role_ID") == 0) + if ((lookup.getDisplayType() == DisplayType.List && Env.getContextAsInt(Env.getCtx(), Env.AD_ROLE_ID) == 0) || lookup.getDisplayType() != DisplayType.List) { zoom= true; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java index 92f563ac2d..86d17b769c 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java @@ -209,7 +209,7 @@ ContextMenuListener, IZoomableEditor lookup.addListDataListener(this); lookup.setMandatory(isMandatory()); - if ((lookup.getDisplayType() == DisplayType.List && Env.getContextAsInt(Env.getCtx(), "#AD_Role_ID") == 0) + if ((lookup.getDisplayType() == DisplayType.List && Env.getContextAsInt(Env.getCtx(), Env.AD_ROLE_ID) == 0) || lookup.getDisplayType() != DisplayType.List) { zoom= true; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoProductWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoProductWindow.java index 2398e5593b..b2ff1ffd94 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoProductWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoProductWindow.java @@ -448,7 +448,7 @@ public class InfoProductWindow extends InfoWindow { int M_PriceList_Version_ID = findPLV (M_PriceList_ID); // Set Warehouse if (M_Warehouse_ID == 0) - M_Warehouse_ID = Env.getContextAsInt(Env.getCtx(), "#M_Warehouse_ID"); + M_Warehouse_ID = Env.getContextAsInt(Env.getCtx(), Env.M_WAREHOUSE_ID); if (M_Warehouse_ID != 0) setWarehouse (M_Warehouse_ID); // Set PriceList Version diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ChangePasswordPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ChangePasswordPanel.java index 82d50d96ac..bbdf4e6d3e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ChangePasswordPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ChangePasswordPanel.java @@ -344,7 +344,7 @@ public class ChangePasswordPanel extends Window implements EventListener for (KeyNamePair clientKNPair : m_clientKNPairs) { int clientId = clientKNPair.getKey(); - Env.setContext(m_ctx, "#AD_Client_ID", clientId); + Env.setContext(m_ctx, Env.AD_CLIENT_ID, clientId); MUser user = MUser.get(m_ctx, m_userName); if (user == null) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoProductPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoProductPanel.java index 3423be95f5..5075acc887 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoProductPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoProductPanel.java @@ -757,7 +757,7 @@ public class InfoProductPanel extends InfoPanel implements EventListener int M_PriceList_Version_ID = findPLV (M_PriceList_ID); // Set Warehouse if (M_Warehouse_ID == 0) - M_Warehouse_ID = Env.getContextAsInt(Env.getCtx(), "#M_Warehouse_ID"); + M_Warehouse_ID = Env.getContextAsInt(Env.getCtx(), Env.M_WAREHOUSE_ID); if (M_Warehouse_ID != 0) setWarehouse (M_Warehouse_ID); // Set PriceList Version diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ResetPasswordPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ResetPasswordPanel.java index fae32a7987..755da2f340 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ResetPasswordPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ResetPasswordPanel.java @@ -516,7 +516,7 @@ public class ResetPasswordPanel extends Window implements EventListener return false; MMailText mailText = new MMailText(m_ctx, R_MailText_ID, null); - mailText.setLanguage(Env.getContext(m_ctx, "#AD_Language")); + mailText.setLanguage(Env.getContext(m_ctx, Env.LANGUAGE)); to.set_ValueOfColumn("Password", newPassword); // will be hashed and validate on saveEx mailText.setUser(to); String message = mailText.getMailText(true); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java index 6a69acbebc..a405669eab 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java @@ -131,7 +131,7 @@ public class RolePanel extends Window implements EventListener, Deferrabl m_clientKNPairs = clientsKNPairs; if( m_clientKNPairs.length == 1 && !m_show ){ - Env.setContext(m_ctx, "#AD_Client_ID", (String) m_clientKNPairs[0].getID()); + Env.setContext(m_ctx, Env.AD_CLIENT_ID, (String) m_clientKNPairs[0].getID()); MUser user = MUser.get (m_ctx, m_userName); m_userpreference=new UserPreference(); m_userpreference.loadPreference(user.get_ID()); @@ -569,15 +569,15 @@ public class RolePanel extends Window implements EventListener, Deferrabl private void setUserID() { if (lstClient.getSelectedItem() != null) { - Env.setContext(m_ctx, "#AD_Client_ID", (String) lstClient.getSelectedItem().getValue()); + Env.setContext(m_ctx, Env.AD_CLIENT_ID, (String) lstClient.getSelectedItem().getValue()); } else { - Env.setContext(m_ctx, "#AD_Client_ID", (String) null); + Env.setContext(m_ctx, Env.AD_CLIENT_ID, (String) null); } MUser user = MUser.get (m_ctx, m_userName); if (user != null) { - Env.setContext(m_ctx, "#AD_User_ID", user.getAD_User_ID() ); - Env.setContext(m_ctx, "#AD_User_Name", user.getName() ); - Env.setContext(m_ctx, "#SalesRep_ID", user.getAD_User_ID() ); + Env.setContext(m_ctx, Env.AD_USER_ID, user.getAD_User_ID() ); + Env.setContext(m_ctx, Env.AD_USER_NAME, user.getName() ); + Env.setContext(m_ctx, Env.SALESREP_ID, user.getAD_User_ID() ); } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/session/SessionContextListener.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/session/SessionContextListener.java index a602339559..881f2ddb43 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/session/SessionContextListener.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/session/SessionContextListener.java @@ -248,7 +248,7 @@ public class SessionContextListener implements ExecutionInit, if (Env.getCtx().getProperty(SERVLET_SESSION_ID) == null) return; } - int AD_Session_ID = Env.getContextAsInt(Env.getCtx(), "#AD_Session_ID"); + int AD_Session_ID = Env.getContextAsInt(Env.getCtx(), Env.AD_SESSION_ID); if (AD_Session_ID > 0) { String key = getSessionDesktopListKey(AD_Session_ID); @SuppressWarnings("unchecked") diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/session/SessionManager.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/session/SessionManager.java index 948abfb65b..971c85661c 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/session/SessionManager.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/session/SessionManager.java @@ -39,10 +39,10 @@ public class SessionManager public static boolean isUserLoggedIn(Properties ctx) { - String adUserId = Env.getContext(ctx, "#AD_User_ID"); - String adRoleId = Env.getContext(ctx, "#AD_Role_ID"); - String adClientId = Env.getContext(ctx, "#AD_Client_ID"); - String adOrgId = Env.getContext(ctx, "#AD_Org_ID"); + String adUserId = Env.getContext(ctx, Env.AD_USER_ID); + String adRoleId = Env.getContext(ctx, Env.AD_ROLE_ID); + String adClientId = Env.getContext(ctx, Env.AD_CLIENT_ID); + String adOrgId = Env.getContext(ctx, Env.AD_ORG_ID); return (!"".equals(adUserId) && !"".equals(adRoleId) && !"".equals(adClientId) && !"".equals(adOrgId)); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/session/ValidateReadonlyComponent.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/session/ValidateReadonlyComponent.java index 1a86085ced..65968e8489 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/session/ValidateReadonlyComponent.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/session/ValidateReadonlyComponent.java @@ -105,7 +105,7 @@ public class ValidateReadonlyComponent implements AuService { // for combobox each change have both event onchange and onselect if (editing){ comp.invalidate(); - String user = Env.getContext(Env.getCtx(), "#AD_User_Name") + "[" + Env.getContext(Env.getCtx(), "#AD_User_ID") + "]"; + String user = Env.getContext(Env.getCtx(), Env.AD_USER_NAME) + "[" + Env.getContext(Env.getCtx(), Env.AD_USER_ID) + "]"; log.log(Level.WARNING, String.format("Detected UI interaction with a read-only element: %1$s on event %2$s from user %3$s", comp.getClass(), cmd, user)); return true; diff --git a/org.adempiere.ui/src/org/compiere/apps/form/Allocation.java b/org.adempiere.ui/src/org/compiere/apps/form/Allocation.java index a4026baa71..0100fb7650 100644 --- a/org.adempiere.ui/src/org/compiere/apps/form/Allocation.java +++ b/org.adempiere.ui/src/org/compiere/apps/form/Allocation.java @@ -78,7 +78,7 @@ public class Allocation public void dynInit() throws Exception { - m_C_Currency_ID = Env.getContextAsInt(Env.getCtx(), "$C_Currency_ID"); // default + m_C_Currency_ID = Env.getContextAsInt(Env.getCtx(), Env.C_CURRENCY_ID); // default // if (log.isLoggable(Level.INFO)) log.info("Currency=" + m_C_Currency_ID); @@ -656,7 +656,7 @@ public class Allocation // Create Allocation MAllocationHdr alloc = new MAllocationHdr (Env.getCtx(), true, // manual - DateTrx, C_Currency_ID, Env.getContext(Env.getCtx(), "#AD_User_Name"), trxName); + DateTrx, C_Currency_ID, Env.getContext(Env.getCtx(), Env.AD_USER_NAME), trxName); alloc.setAD_Org_ID(AD_Org_ID); alloc.setC_DocType_ID(m_C_DocType_ID); alloc.setDescription(alloc.getDescriptionForManualAllocation(m_C_BPartner_ID, trxName)); diff --git a/org.adempiere.ui/src/org/compiere/apps/form/Charge.java b/org.adempiere.ui/src/org/compiere/apps/form/Charge.java index cb4829a4a2..3263394d22 100644 --- a/org.adempiere.ui/src/org/compiere/apps/form/Charge.java +++ b/org.adempiere.ui/src/org/compiere/apps/form/Charge.java @@ -110,7 +110,7 @@ public class Charge */ public void findChargeElementID() { - m_C_AcctSchema_ID = Env.getContextAsInt(Env.getCtx(), "$C_AcctSchema_ID"); + m_C_AcctSchema_ID = Env.getContextAsInt(Env.getCtx(), Env.C_ACCTSCHEMA_ID); // get Element String sql = "SELECT C_Element_ID " + "FROM C_AcctSchema_Element " diff --git a/org.adempiere.ui/src/org/compiere/apps/form/FactReconcile.java b/org.adempiere.ui/src/org/compiere/apps/form/FactReconcile.java index 16d96f3dd2..8a1bcc8703 100644 --- a/org.adempiere.ui/src/org/compiere/apps/form/FactReconcile.java +++ b/org.adempiere.ui/src/org/compiere/apps/form/FactReconcile.java @@ -219,7 +219,7 @@ public class FactReconcile { { log.info(""); - String matchcode = "Manual: " + Env.getContext(Env.getCtx(), "#AD_User_Name") + " " + time; + String matchcode = "Manual: " + Env.getContext(Env.getCtx(), Env.AD_USER_NAME) + " " + time; MFactReconciliation rec = new Query(Env.getCtx(), MFactReconciliation.Table_Name, "Fact_Acct_ID = ?", null) .setParameters(new Object[] {factId}).first(); diff --git a/org.idempiere.test/src/org/idempiere/test/AbstractTestCase.java b/org.idempiere.test/src/org/idempiere/test/AbstractTestCase.java index 4d9fcb2651..f45ecfd436 100644 --- a/org.idempiere.test/src/org/idempiere/test/AbstractTestCase.java +++ b/org.idempiere.test/src/org/idempiere/test/AbstractTestCase.java @@ -100,8 +100,8 @@ public abstract class AbstractTestCase { Env.setContext(Env.getCtx(), Env.AD_USER_ID, loginDetails.getUserId()); Env.setContext(Env.getCtx(), Env.AD_ROLE_ID, loginDetails.getRoleId()); Env.setContext(Env.getCtx(), Env.M_WAREHOUSE_ID, loginDetails.getWarehouseId()); - Env.setContext(Env.getCtx(), "#LanguageName", loginDetails.getLoginLanguage().getName()); - Env.setContext(Env.getCtx(), "#Date", loginDetails.getLoginDate()); + Env.setContext(Env.getCtx(), Env.LANGUAGE_NAME, loginDetails.getLoginLanguage().getName()); + Env.setContext(Env.getCtx(), Env.DATE, loginDetails.getLoginDate()); Env.verifyLanguage(Env.getCtx(), getLanguage()); Env.setContext(Env.getCtx(), Env.LANGUAGE, getLanguage().getAD_Language()); @@ -110,9 +110,9 @@ public abstract class AbstractTestCase { if (loginDetails.getRoleId() > 0) { if (MRole.getDefault(Env.getCtx(), false).isShowAcct()) - Env.setContext(Env.getCtx(), "#ShowAcct", "Y"); + Env.setContext(Env.getCtx(), Env.SHOW_ACCOUNTING, "Y"); else - Env.setContext(Env.getCtx(), "#ShowAcct", "N"); + Env.setContext(Env.getCtx(), Env.SHOW_ACCOUNTING, "N"); } /** Define AcctSchema , Currency, HasAlias **/ diff --git a/org.idempiere.test/src/org/idempiere/test/base/MatchInvTest.java b/org.idempiere.test/src/org/idempiere/test/base/MatchInvTest.java index 47c7f89073..e88a237d49 100644 --- a/org.idempiere.test/src/org/idempiere/test/base/MatchInvTest.java +++ b/org.idempiere.test/src/org/idempiere/test/base/MatchInvTest.java @@ -536,7 +536,7 @@ public class MatchInvTest extends AbstractTestCase { public void testMatReceiptPostingWithDiffCurrencyPrecision() { MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc. MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree - Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date"); + Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), Env.DATE); MPriceList priceList = new MPriceList(Env.getCtx(), 0, null); priceList.setName("Purchase JPY " + System.currentTimeMillis()); diff --git a/org.idempiere.test/src/org/idempiere/test/model/AllocationTest.java b/org.idempiere.test/src/org/idempiere/test/model/AllocationTest.java index 90d0d6de1b..d4395aebb0 100644 --- a/org.idempiere.test/src/org/idempiere/test/model/AllocationTest.java +++ b/org.idempiere.test/src/org/idempiere/test/model/AllocationTest.java @@ -112,7 +112,7 @@ public class AllocationTest extends AbstractTestCase { // Create allocation to allocate payment to charge MAllocationHdr alloc = new MAllocationHdr (Env.getCtx(), true, // manual - payment1.getDateTrx(), CURRENCY_USD, Env.getContext(Env.getCtx(), "#AD_User_Name"), trxName); + payment1.getDateTrx(), CURRENCY_USD, Env.getContext(Env.getCtx(), Env.AD_USER_NAME), trxName); alloc.setAD_Org_ID(payment1.getAD_Org_ID()); int doctypeAlloc = MDocType.getDocType("CMA"); alloc.setC_DocType_ID(doctypeAlloc); diff --git a/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/CompiereService.java b/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/CompiereService.java index 9a5f808983..dcf10ee4d9 100644 --- a/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/CompiereService.java +++ b/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/CompiereService.java @@ -123,7 +123,7 @@ public class CompiereService { CompiereUtil.initWeb(); ServerContext.setCurrentInstance(new Properties()); - Env.setContext(getCtx(), "#AD_Language", "en_US" ); + Env.setContext(getCtx(), Env.LANGUAGE, "en_US" ); m_language = Language.getLanguage("en_US"); dateFormat = DisplayType.getDateFormat(DisplayType.Date, m_language); @@ -266,7 +266,7 @@ public class CompiereService { else m_userName = Util.isEmpty(user.getLDAPUser()) ? user.getName() : user.getLDAPUser(); - Env.setContext( getCtx(), "#AD_Language", Lang); + Env.setContext( getCtx(), Env.LANGUAGE, Lang); m_language = Language.getLanguage(Lang); Env.verifyLanguage( getCtx(), m_language ); @@ -281,10 +281,10 @@ public class CompiereService { Timestamp ts = new Timestamp(System.currentTimeMillis()); SimpleDateFormat dateFormat4Timestamp = new SimpleDateFormat( dateFormatOnlyForCtx ); - Env.setContext( getCtx(), "#Date", dateFormat4Timestamp.format(ts)+" 00:00:00" ); // JDBC format - if (log.isLoggable(Level.INFO)) log.info(" #Date = "+ Env.getContextAsDate( getCtx(), "#Date")); + Env.setContext( getCtx(), Env.DATE, dateFormat4Timestamp.format(ts)+" 00:00:00" ); // JDBC format + if (log.isLoggable(Level.INFO)) log.info(" #Date = "+ Env.getContextAsDate( getCtx(), Env.DATE)); - Env.setContext( getCtx(), "#M_Warehouse_ID", M_Warehouse_ID ); + Env.setContext( getCtx(), Env.M_WAREHOUSE_ID, M_Warehouse_ID ); Env.setContext(getCtx(), Env.LANGUAGE, m_language.getAD_Language()); // Create session diff --git a/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/Process.java b/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/Process.java index d0e7ab4f6c..9132382717 100644 --- a/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/Process.java +++ b/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/Process.java @@ -124,9 +124,9 @@ public class Process { if (DisplayType.isDate(para.getAD_Reference_ID())) { if (para.getDefaultValue().indexOf( "@#Date@")>=0) { - //Object t = Env.getContextAsDate( cs.getM_ctx(), "#Date" ); - //String t = Env.getContext( cs.getM_ctx(), "#Date" ); - String t= cs.dateFormat.format( Env.getContextAsDate( cs.getCtx(), "#Date") ); + //Object t = Env.getContextAsDate( cs.getM_ctx(), Env.DATE ); + //String t = Env.getContext( cs.getM_ctx(), Env.DATE ); + String t= cs.dateFormat.format( Env.getContextAsDate( cs.getCtx(), Env.DATE) ); p.setDefaultValue( t ); //cs.dateFormat.format( t )); } @@ -148,9 +148,9 @@ public class Process { if (DisplayType.isDate(para.getAD_Reference_ID())) { if (para.getDefaultValue2().indexOf( "@#Date@")>=0) { - //Object t = Env.getContextAsDate( cs.getM_ctx(), "#Date" ); - //String t = Env.getContext( cs.getM_ctx(), "#Date" ); - String t= cs.dateFormat.format( Env.getContextAsDate( cs.getCtx(), "#Date") ); + //Object t = Env.getContextAsDate( cs.getM_ctx(), Env.DATE ); + //String t = Env.getContext( cs.getM_ctx(), Env.DATE ); + String t= cs.dateFormat.format( Env.getContextAsDate( cs.getCtx(), Env.DATE) ); p.setDefaultValue2( t ); //cs.dateFormat.format( t ) ); } } diff --git a/org.idempiere.webservices/WEB-INF/src/org/idempiere/webservices/AbstractService.java b/org.idempiere.webservices/WEB-INF/src/org/idempiere/webservices/AbstractService.java index 6248b2f6c4..eaf398a411 100644 --- a/org.idempiere.webservices/WEB-INF/src/org/idempiere/webservices/AbstractService.java +++ b/org.idempiere.webservices/WEB-INF/src/org/idempiere/webservices/AbstractService.java @@ -131,13 +131,13 @@ public class AbstractService { if (!okclient) return "Error logging in - client not allowed for this user"; - m_cs.getCtx().setProperty("#AD_Client_ID", "" + loginRequest.getClientID()); - Env.setContext(m_cs.getCtx(), "#AD_Client_ID", (String) selectedClient.getID()); + m_cs.getCtx().setProperty(Env.AD_CLIENT_ID, "" + loginRequest.getClientID()); + Env.setContext(m_cs.getCtx(), Env.AD_CLIENT_ID, (String) selectedClient.getID()); MUser user = MUser.get (m_cs.getCtx(), loginRequest.getUser()); if (user != null) { - Env.setContext(m_cs.getCtx(), "#AD_User_ID", user.getAD_User_ID() ); - Env.setContext(m_cs.getCtx(), "#AD_User_Name", user.getName() ); - Env.setContext(m_cs.getCtx(), "#SalesRep_ID", user.getAD_User_ID() ); + Env.setContext(m_cs.getCtx(), Env.AD_USER_ID, user.getAD_User_ID() ); + Env.setContext(m_cs.getCtx(), Env.AD_USER_NAME, user.getName() ); + Env.setContext(m_cs.getCtx(), Env.SALESREP_ID, user.getAD_User_ID() ); String userAgent = getHttpServletRequest().getHeader("User-Agent"); Env.setContext(m_cs.getCtx(), "#UserAgent", userAgent == null ? "Unknown" : userAgent); }