From 8425078adf6ea4bc1a3e416aa08ac2fb58272368 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Sun, 25 Feb 2007 22:25:35 +0000 Subject: [PATCH] Work in progress - integrate bug fixing from Compiere 260b --- .../org/compiere/process/ImportGLJournal.java | 24 +- .../compiere/process/ImportInOutConfirm.java | 2 +- .../org/compiere/process/ImportInventory.java | 24 +- .../org/compiere/process/ImportInvoice.java | 64 +-- .../src/org/compiere/process/ImportOrder.java | 72 +-- .../org/compiere/process/ImportPayment.java | 12 +- .../org/compiere/process/ImportProduct.java | 74 ++- .../compiere/process/ImportReportLine.java | 47 +- .../org/compiere/process/InOutGenerate.java | 24 +- .../process/InventoryCountCreate.java | 1 + .../org/compiere/process/InvoiceGenerate.java | 2 +- .../org/compiere/process/InvoicePrint.java | 5 + .../org/compiere/process/PaymentOnline.java | 2 - .../org/compiere/process/TreeMaintenance.java | 6 +- base/src/org/compiere/tools/FileUtil.java | 13 +- base/src/org/compiere/util/WebLogin.java | 441 ++++++++++-------- base/src/org/compiere/wf/MWFNodeNext.java | 2 +- client/src/org/compiere/apps/AChat.java | 1 - client/src/org/compiere/apps/AEnv.java | 12 +- client/src/org/compiere/apps/ALogin.java | 19 +- client/src/org/compiere/apps/AMenu.java | 3 +- .../src/org/compiere/apps/AMenuStartItem.java | 10 +- client/src/org/compiere/apps/APanel.java | 5 +- client/src/org/compiere/apps/AppsAction.java | 9 +- client/src/org/compiere/apps/ProcessCtl.java | 46 +- client/src/org/compiere/apps/RecordInfo.java | 4 +- .../org/compiere/apps/form/VAllocation.java | 4 +- .../org/compiere/apps/wf/WFContentPanel.java | 3 +- client/src/org/compiere/grid/ed/Calendar.java | 2 +- .../src/org/compiere/grid/ed/MDocNumber.java | 9 +- client/src/org/compiere/grid/ed/VAccount.java | 14 +- .../org/compiere/grid/ed/VAccountDialog.java | 3 +- client/src/org/compiere/grid/ed/VBinary.java | 1 - .../src/org/compiere/grid/ed/VCellEditor.java | 2 +- .../org/compiere/grid/ed/VCellRenderer.java | 6 +- .../src/org/compiere/grid/ed/VComboBox.java | 2 +- .../org/compiere/grid/ed/VHeaderRenderer.java | 2 +- client/src/org/compiere/grid/ed/VNumber.java | 51 +- .../org/compiere/grid/ed/ValuePreference.java | 2 - .../org/compiere/grid/tree/VTreePanel.java | 11 +- client/src/org/compiere/print/Viewer.java | 4 +- dbPort/src/org/compiere/Adempiere.java | 8 +- dbPort/src/org/compiere/db/CConnection.java | 18 + dbPort/src/org/compiere/db/DB_Oracle.java | 39 +- .../src/org/compiere/model/MClientShare.java | 2 +- dbPort/src/org/compiere/model/MColumn.java | 52 ++- dbPort/src/org/compiere/model/MField.java | 22 + dbPort/src/org/compiere/model/MIssue.java | 1 + dbPort/src/org/compiere/model/MLanguage.java | 19 +- dbPort/src/org/compiere/model/MLookup.java | 2 +- .../src/org/compiere/model/MLookupInfo.java | 172 +++---- dbPort/src/org/compiere/model/MQuery.java | 17 +- dbPort/src/org/compiere/model/MSystem.java | 27 +- dbPort/src/org/compiere/model/MTable.java | 50 ++ dbPort/src/org/compiere/model/M_Element.java | 67 ++- .../compiere/model/ModelValidationEngine.java | 15 +- .../org/compiere/model/ModelValidator.java | 15 +- dbPort/src/org/compiere/model/PO.java | 77 +-- dbPort/src/org/compiere/util/Env.java | 2 +- .../src/org/compiere/util/GenerateModel.java | 4 +- dbPort/src/org/compiere/util/Login.java | 6 +- .../src/org/compiere/install/KeyStoreMgt.java | 4 +- .../src/org/compiere/install/SilentSetup.java | 2 +- .../src/org/compiere/plaf/CompiereColor.java | 2 - looks/src/org/compiere/util/Ini.java | 48 +- looks/src/org/compiere/util/Util.java | 31 +- .../src/org/compiere/print/MPrintFormat.java | 2 +- 67 files changed, 1137 insertions(+), 607 deletions(-) diff --git a/base/src/org/compiere/process/ImportGLJournal.java b/base/src/org/compiere/process/ImportGLJournal.java index 9de651102a..4469473e3e 100644 --- a/base/src/org/compiere/process/ImportGLJournal.java +++ b/base/src/org/compiere/process/ImportGLJournal.java @@ -274,24 +274,24 @@ public class ImportGLJournal extends SvrProcess log.fine("Set Home CurrencyRate=" + no); // Set Currency Rate sql = new StringBuffer ("UPDATE I_GLJournal i " - + "SET CurrencyRate=(SELECT r.MultiplyRate FROM C_Conversion_Rate r, C_AcctSchema s" + + "SET CurrencyRate=(SELECT MAX(r.MultiplyRate) FROM C_Conversion_Rate r, C_AcctSchema s" + " WHERE s.C_AcctSchema_ID=i.C_AcctSchema_ID AND s.AD_Client_ID=i.AD_Client_ID" + " AND r.C_Currency_ID=i.C_Currency_ID AND r.C_Currency_ID_TO=s.C_Currency_ID" + " AND r.AD_Client_ID=i.AD_Client_ID AND r.AD_Org_ID=i.AD_OrgDoc_ID" + " AND r.C_ConversionType_ID=i.C_ConversionType_ID" - + " AND i.DateAcct BETWEEN r.ValidFrom AND r.ValidTo AND ROWNUM=1" + + " AND i.DateAcct BETWEEN r.ValidFrom AND r.ValidTo " // ORDER BY ValidFrom DESC + ") WHERE CurrencyRate IS NULL OR CurrencyRate=0 AND C_Currency_ID>0" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set Org Rate=" + no); sql = new StringBuffer ("UPDATE I_GLJournal i " - + "SET CurrencyRate=(SELECT r.MultiplyRate FROM C_Conversion_Rate r, C_AcctSchema s" + + "SET CurrencyRate=(SELECT MAX(r.MultiplyRate) FROM C_Conversion_Rate r, C_AcctSchema s" + " WHERE s.C_AcctSchema_ID=i.C_AcctSchema_ID AND s.AD_Client_ID=i.AD_Client_ID" + " AND r.C_Currency_ID=i.C_Currency_ID AND r.C_Currency_ID_TO=s.C_Currency_ID" + " AND r.AD_Client_ID=i.AD_Client_ID" + " AND r.C_ConversionType_ID=i.C_ConversionType_ID" - + " AND i.DateAcct BETWEEN r.ValidFrom AND r.ValidTo AND ROWNUM=1" + + " AND i.DateAcct BETWEEN r.ValidFrom AND r.ValidTo " // ORDER BY ValidFrom DESC + ") WHERE CurrencyRate IS NULL OR CurrencyRate=0 AND C_Currency_ID>0" + " AND I_IsImported<>'Y'").append (clientCheck); @@ -307,25 +307,25 @@ public class ImportGLJournal extends SvrProcess // Set Period sql = new StringBuffer ("UPDATE I_GLJournal i " - + "SET C_Period_ID=(SELECT p.C_Period_ID FROM C_Period p" + + "SET C_Period_ID=(SELECT MAX(p.C_Period_ID) FROM C_Period p" + " INNER JOIN C_Year y ON (y.C_Year_ID=p.C_Year_ID)" + " INNER JOIN AD_ClientInfo c ON (c.C_Calendar_ID=y.C_Calendar_ID)" + " WHERE c.AD_Client_ID=i.AD_Client_ID" // globalqss - cruiz - Bug [ 1577712 ] Financial Period Bug - + " AND i.DateAcct BETWEEN p.StartDate AND p.EndDate AND p.IsActive='Y' AND p.PeriodType='S' AND ROWNUM=1) " + + " AND i.DateAcct BETWEEN p.StartDate AND p.EndDate AND p.IsActive='Y' AND p.PeriodType='S') " + "WHERE C_Period_ID IS NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set Period=" + no); sql = new StringBuffer ("UPDATE I_GLJournal i " + "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Period, '" - + "WHERE C_Period_ID IS NULL OR C_Period_ID<>" + + "WHERE C_Period_ID IS NULL OR C_Period_ID NOT IN" + "(SELECT C_Period_ID FROM C_Period p" + " INNER JOIN C_Year y ON (y.C_Year_ID=p.C_Year_ID)" + " INNER JOIN AD_ClientInfo c ON (c.C_Calendar_ID=y.C_Calendar_ID) " + " WHERE c.AD_Client_ID=i.AD_Client_ID" // globalqss - cruiz - Bug [ 1577712 ] Financial Period Bug - + " AND i.DateAcct BETWEEN p.StartDate AND p.EndDate AND p.IsActive='Y' AND p.PeriodType='S' AND ROWNUM=1)" + + " AND i.DateAcct BETWEEN p.StartDate AND p.EndDate AND p.IsActive='Y' AND p.PeriodType='S')" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); if (no != 0) @@ -384,11 +384,11 @@ public class ImportGLJournal extends SvrProcess // Set Account sql = new StringBuffer ("UPDATE I_GLJournal i " - + "SET Account_ID=(SELECT ev.C_ElementValue_ID FROM C_ElementValue ev" + + "SET Account_ID=(SELECT MAX(ev.C_ElementValue_ID) FROM C_ElementValue ev" + " INNER JOIN C_Element e ON (e.C_Element_ID=ev.C_Element_ID)" + " INNER JOIN C_AcctSchema_Element ase ON (e.C_Element_ID=ase.C_Element_ID AND ase.ElementType='AC')" + " WHERE ev.Value=i.AccountValue AND ev.IsSummary='N'" - + " AND i.C_AcctSchema_ID=ase.C_AcctSchema_ID AND i.AD_Client_ID=ev.AD_Client_ID AND ROWNUM=1) " + + " AND i.C_AcctSchema_ID=ase.C_AcctSchema_ID AND i.AD_Client_ID=ev.AD_Client_ID) " + "WHERE Account_ID IS NULL AND AccountValue IS NOT NULL" + " AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); @@ -419,9 +419,9 @@ public class ImportGLJournal extends SvrProcess // Set Product sql = new StringBuffer ("UPDATE I_GLJournal i " - + "SET M_Product_ID=(SELECT p.M_Product_ID FROM M_Product p" + + "SET M_Product_ID=(SELECT MAX(p.M_Product_ID) FROM M_Product p" + " WHERE (p.Value=i.ProductValue OR p.UPC=i.UPC OR p.SKU=i.SKU)" - + " AND p.IsSummary='N' AND i.AD_Client_ID=p.AD_Client_ID AND ROWNUM=1) " + + " AND p.IsSummary='N' AND i.AD_Client_ID=p.AD_Client_ID) " + "WHERE M_Product_ID IS NULL AND (ProductValue IS NOT NULL OR UPC IS NOT NULL OR SKU IS NOT NULL)" + " AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); diff --git a/base/src/org/compiere/process/ImportInOutConfirm.java b/base/src/org/compiere/process/ImportInOutConfirm.java index 61916983d6..3807c3d072 100644 --- a/base/src/org/compiere/process/ImportInOutConfirm.java +++ b/base/src/org/compiere/process/ImportInOutConfirm.java @@ -66,7 +66,7 @@ public class ImportInOutConfirm extends SvrProcess */ protected String doIt () throws Exception { - log.info(""); + log.info("I_InOutLineConfirm_ID=" + p_I_InOutLineConfirm_ID); StringBuffer sql = null; int no = 0; String clientCheck = " AND AD_Client_ID=" + p_AD_Client_ID; diff --git a/base/src/org/compiere/process/ImportInventory.java b/base/src/org/compiere/process/ImportInventory.java index 4621715915..6b029b3100 100644 --- a/base/src/org/compiere/process/ImportInventory.java +++ b/base/src/org/compiere/process/ImportInventory.java @@ -122,15 +122,15 @@ public class ImportInventory extends SvrProcess // Location sql = new StringBuffer ("UPDATE I_Inventory i " - + "SET M_Locator_ID=(SELECT M_Locator_ID FROM M_Locator l" - + " WHERE i.LocatorValue=l.Value AND i.AD_Client_ID=l.AD_Client_ID AND ROWNUM=1) " + + "SET M_Locator_ID=(SELECT MAX(M_Locator_ID) FROM M_Locator l" + + " WHERE i.LocatorValue=l.Value AND i.AD_Client_ID=l.AD_Client_ID) " + "WHERE M_Locator_ID IS NULL AND LocatorValue IS NOT NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate (sql.toString (), get_TrxName()); log.fine("Set Locator from Value =" + no); sql = new StringBuffer ("UPDATE I_Inventory i " - + "SET M_Locator_ID=(SELECT M_Locator_ID FROM M_Locator l" - + " WHERE i.X=l.X AND i.Y=l.Y AND i.Z=l.Z AND i.AD_Client_ID=l.AD_Client_ID AND ROWNUM=1) " + + "SET M_Locator_ID=(SELECT MAX(M_Locator_ID) FROM M_Locator l" + + " WHERE i.X=l.X AND i.Y=l.Y AND i.Z=l.Z AND i.AD_Client_ID=l.AD_Client_ID) " + "WHERE M_Locator_ID IS NULL AND X IS NOT NULL AND Y IS NOT NULL AND Z IS NOT NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate (sql.toString (), get_TrxName()); @@ -171,19 +171,19 @@ public class ImportInventory extends SvrProcess // Product sql = new StringBuffer ("UPDATE I_Inventory i " - + "SET M_Product_ID=(SELECT M_Product_ID FROM M_Product p" - + " WHERE i.Value=p.Value AND i.AD_Client_ID=p.AD_Client_ID AND ROWNUM=1) " + + "SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p" + + " WHERE i.Value=p.Value AND i.AD_Client_ID=p.AD_Client_ID) " + "WHERE M_Product_ID IS NULL AND Value IS NOT NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate (sql.toString (), get_TrxName()); log.fine("Set Product from Value=" + no); sql = new StringBuffer ("UPDATE I_Inventory i " - + "SET M_Product_ID=(SELECT M_Product_ID FROM M_Product p" - + " WHERE i.UPC=p.UPC AND i.AD_Client_ID=p.AD_Client_ID AND ROWNUM=1) " - + "WHERE M_Product_ID IS NULL AND UPC IS NOT NULL" - + " AND I_IsImported<>'Y'").append (clientCheck); - no = DB.executeUpdate (sql.toString (), get_TrxName()); - log.fine("Set Product from UPC=" + no); + + "SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p" + + " WHERE i.UPC=p.UPC AND i.AD_Client_ID=p.AD_Client_ID) " + + "WHERE M_Product_ID IS NULL AND UPC IS NOT NULL" + + " AND I_IsImported<>'Y'").append (clientCheck); + no = DB.executeUpdate (sql.toString (), get_TrxName()); + log.fine("Set Product from UPC=" + no); sql = new StringBuffer ("UPDATE I_Inventory " + "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Product, ' " + "WHERE M_Product_ID IS NULL" diff --git a/base/src/org/compiere/process/ImportInvoice.java b/base/src/org/compiere/process/ImportInvoice.java index cd4b3402fa..4ebf81009c 100644 --- a/base/src/org/compiere/process/ImportInvoice.java +++ b/base/src/org/compiere/process/ImportInvoice.java @@ -146,22 +146,22 @@ public class ImportInvoice extends SvrProcess log.warning ("Invalid DocTypeName=" + no); // DocType Default sql = new StringBuffer ("UPDATE I_Invoice o " - + "SET C_DocType_ID=(SELECT C_DocType_ID FROM C_DocType d WHERE d.IsDefault='Y'" - + " AND d.DocBaseType='API' AND ROWNUM=1 AND o.AD_Client_ID=d.AD_Client_ID) " + + "SET C_DocType_ID=(SELECT MAX(C_DocType_ID) FROM C_DocType d WHERE d.IsDefault='Y'" + + " AND d.DocBaseType='API' AND o.AD_Client_ID=d.AD_Client_ID) " + "WHERE C_DocType_ID IS NULL AND IsSOTrx='N' AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); if (no != 0) log.fine("Set PO Default DocType=" + no); sql = new StringBuffer ("UPDATE I_Invoice o " - + "SET C_DocType_ID=(SELECT C_DocType_ID FROM C_DocType d WHERE d.IsDefault='Y'" - + " AND d.DocBaseType='ARI' AND ROWNUM=1 AND o.AD_Client_ID=d.AD_Client_ID) " + + "SET C_DocType_ID=(SELECT MAX(C_DocType_ID) FROM C_DocType d WHERE d.IsDefault='Y'" + + " AND d.DocBaseType='ARI' AND o.AD_Client_ID=d.AD_Client_ID) " + "WHERE C_DocType_ID IS NULL AND IsSOTrx='Y' AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); if (no != 0) log.fine("Set SO Default DocType=" + no); sql = new StringBuffer ("UPDATE I_Invoice o " - + "SET C_DocType_ID=(SELECT C_DocType_ID FROM C_DocType d WHERE d.IsDefault='Y'" - + " AND d.DocBaseType IN('ARI','API') AND ROWNUM=1 AND o.AD_Client_ID=d.AD_Client_ID) " + + "SET C_DocType_ID=(SELECT MAX(C_DocType_ID) FROM C_DocType d WHERE d.IsDefault='Y'" + + " AND d.DocBaseType IN('ARI','API') AND o.AD_Client_ID=d.AD_Client_ID) " + "WHERE C_DocType_ID IS NULL AND IsSOTrx IS NULL AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); if (no != 0) @@ -190,26 +190,26 @@ public class ImportInvoice extends SvrProcess // Price List sql = new StringBuffer ("UPDATE I_Invoice o " - + "SET M_PriceList_ID=(SELECT M_PriceList_ID FROM M_PriceList p WHERE p.IsDefault='Y'" - + " AND p.C_Currency_ID=o.C_Currency_ID AND p.IsSOPriceList=o.IsSOTrx AND ROWNUM=1 AND o.AD_Client_ID=p.AD_Client_ID) " + + "SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p WHERE p.IsDefault='Y'" + + " AND p.C_Currency_ID=o.C_Currency_ID AND p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) " + "WHERE M_PriceList_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set Default Currency PriceList=" + no); sql = new StringBuffer ("UPDATE I_Invoice o " - + "SET M_PriceList_ID=(SELECT M_PriceList_ID FROM M_PriceList p WHERE p.IsDefault='Y'" - + " AND p.IsSOPriceList=o.IsSOTrx AND ROWNUM=1 AND o.AD_Client_ID=p.AD_Client_ID) " + + "SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p WHERE p.IsDefault='Y'" + + " AND p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) " + "WHERE M_PriceList_ID IS NULL AND C_Currency_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set Default PriceList=" + no); sql = new StringBuffer ("UPDATE I_Invoice o " - + "SET M_PriceList_ID=(SELECT M_PriceList_ID FROM M_PriceList p " - + " WHERE p.C_Currency_ID=o.C_Currency_ID AND p.IsSOPriceList=o.IsSOTrx AND ROWNUM=1 AND o.AD_Client_ID=p.AD_Client_ID) " + + "SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p " + + " WHERE p.C_Currency_ID=o.C_Currency_ID AND p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) " + "WHERE M_PriceList_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set Currency PriceList=" + no); sql = new StringBuffer ("UPDATE I_Invoice o " - + "SET M_PriceList_ID=(SELECT M_PriceList_ID FROM M_PriceList p " - + " WHERE p.IsSOPriceList=o.IsSOTrx AND ROWNUM=1 AND o.AD_Client_ID=p.AD_Client_ID) " + + "SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p " + + " WHERE p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) " + "WHERE M_PriceList_ID IS NULL AND C_Currency_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set PriceList=" + no); @@ -230,8 +230,8 @@ public class ImportInvoice extends SvrProcess no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set PaymentTerm=" + no); sql = new StringBuffer ("UPDATE I_Invoice o " - + "SET C_PaymentTerm_ID=(SELECT C_PaymentTerm_ID FROM C_PaymentTerm p" - + " WHERE p.IsDefault='Y' AND ROWNUM=1 AND o.AD_Client_ID=p.AD_Client_ID) " + + "SET C_PaymentTerm_ID=(SELECT MAX(C_PaymentTerm_ID) FROM C_PaymentTerm p" + + " WHERE p.IsDefault='Y' AND o.AD_Client_ID=p.AD_Client_ID) " + "WHERE C_PaymentTerm_ID IS NULL AND o.PaymentTermValue IS NULL AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set Default PaymentTerm=" + no); @@ -263,8 +263,8 @@ public class ImportInvoice extends SvrProcess log.fine("Set BP from ContactName=" + no); // BP from Value sql = new StringBuffer ("UPDATE I_Invoice o " - + "SET C_BPartner_ID=(SELECT C_BPartner_ID FROM C_BPartner bp" - + " WHERE o.BPartnerValue=bp.Value AND o.AD_Client_ID=bp.AD_Client_ID AND ROWNUM=1) " + + "SET C_BPartner_ID=(SELECT MAX(C_BPartner_ID) FROM C_BPartner bp" + + " WHERE o.BPartnerValue=bp.Value AND o.AD_Client_ID=bp.AD_Client_ID) " + "WHERE C_BPartner_ID IS NULL AND BPartnerValue IS NOT NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); @@ -292,10 +292,10 @@ public class ImportInvoice extends SvrProcess log.fine("Found Location=" + no); // Set Location from BPartner sql = new StringBuffer ("UPDATE I_Invoice o " - + "SET C_BPartner_Location_ID=(SELECT C_BPartner_Location_ID FROM C_BPartner_Location l" + + "SET C_BPartner_Location_ID=(SELECT MAX(C_BPartner_Location_ID) FROM C_BPartner_Location l" + " WHERE l.C_BPartner_ID=o.C_BPartner_ID AND o.AD_Client_ID=l.AD_Client_ID" + " AND ((l.IsBillTo='Y' AND o.IsSOTrx='Y') OR o.IsSOTrx='N')" - + " AND ROWNUM=1) " + + ") " + "WHERE C_BPartner_ID IS NOT NULL AND C_BPartner_Location_ID IS NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); @@ -312,8 +312,8 @@ public class ImportInvoice extends SvrProcess // Set Country /** sql = new StringBuffer ("UPDATE I_Invoice o " - + "SET CountryCode=(SELECT CountryCode FROM C_Country c WHERE c.IsDefault='Y'" - + " AND c.AD_Client_ID IN (0, o.AD_Client_ID) AND ROWNUM=1) " + + "SET CountryCode=(SELECT MAX(CountryCode) FROM C_Country c WHERE c.IsDefault='Y'" + + " AND c.AD_Client_ID IN (0, o.AD_Client_ID)) " + "WHERE C_BPartner_ID IS NULL AND CountryCode IS NULL AND C_Country_ID IS NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); @@ -337,9 +337,9 @@ public class ImportInvoice extends SvrProcess // Set Region sql = new StringBuffer ("UPDATE I_Invoice o " - + "Set RegionName=(SELECT Name FROM C_Region r" + + "Set RegionName=(SELECT MAX(Name) FROM C_Region r" + " WHERE r.IsDefault='Y' AND r.C_Country_ID=o.C_Country_ID" - + " AND r.AD_Client_ID IN (0, o.AD_Client_ID) AND ROWNUM=1) " + + " AND r.AD_Client_ID IN (0, o.AD_Client_ID)) " + "WHERE C_BPartner_ID IS NULL AND C_Region_ID IS NULL AND RegionName IS NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); @@ -366,22 +366,22 @@ public class ImportInvoice extends SvrProcess // Product sql = new StringBuffer ("UPDATE I_Invoice o " - + "SET M_Product_ID=(SELECT M_Product_ID FROM M_Product p" - + " WHERE o.ProductValue=p.Value AND o.AD_Client_ID=p.AD_Client_ID AND ROWNUM=1) " + + "SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p" + + " WHERE o.ProductValue=p.Value AND o.AD_Client_ID=p.AD_Client_ID) " + "WHERE M_Product_ID IS NULL AND ProductValue IS NOT NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set Product from Value=" + no); sql = new StringBuffer ("UPDATE I_Invoice o " - + "SET M_Product_ID=(SELECT M_Product_ID FROM M_Product p" - + " WHERE o.UPC=p.UPC AND o.AD_Client_ID=p.AD_Client_ID AND ROWNUM=1) " + + "SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p" + + " WHERE o.UPC=p.UPC AND o.AD_Client_ID=p.AD_Client_ID) " + "WHERE M_Product_ID IS NULL AND UPC IS NOT NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set Product from UPC=" + no); sql = new StringBuffer ("UPDATE I_Invoice o " - + "SET M_Product_ID=(SELECT M_Product_ID FROM M_Product p" - + " WHERE o.SKU=p.SKU AND o.AD_Client_ID=p.AD_Client_ID AND ROWNUM=1) " + + "SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p" + + " WHERE o.SKU=p.SKU AND o.AD_Client_ID=p.AD_Client_ID) " + "WHERE M_Product_ID IS NULL AND SKU IS NOT NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); @@ -396,8 +396,8 @@ public class ImportInvoice extends SvrProcess // Tax sql = new StringBuffer ("UPDATE I_Invoice o " - + "SET C_Tax_ID=(SELECT C_Tax_ID FROM C_Tax t" - + " WHERE o.TaxIndicator=t.TaxIndicator AND o.AD_Client_ID=t.AD_Client_ID AND ROWNUM=1) " + + "SET C_Tax_ID=(SELECT MAX(C_Tax_ID) FROM C_Tax t" + + " WHERE o.TaxIndicator=t.TaxIndicator AND o.AD_Client_ID=t.AD_Client_ID) " + "WHERE C_Tax_ID IS NULL AND TaxIndicator IS NOT NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); diff --git a/base/src/org/compiere/process/ImportOrder.java b/base/src/org/compiere/process/ImportOrder.java index d340dfcb8d..b069907b58 100644 --- a/base/src/org/compiere/process/ImportOrder.java +++ b/base/src/org/compiere/process/ImportOrder.java @@ -143,20 +143,20 @@ public class ImportOrder extends SvrProcess log.warning ("Invalid DocTypeName=" + no); // DocType Default sql = new StringBuffer ("UPDATE I_Order o " // Default PO - + "SET C_DocType_ID=(SELECT C_DocType_ID FROM C_DocType d WHERE d.IsDefault='Y'" - + " AND d.DocBaseType='POO' AND ROWNUM=1 AND o.AD_Client_ID=d.AD_Client_ID) " + + "SET C_DocType_ID=(SELECT MAX(C_DocType_ID) FROM C_DocType d WHERE d.IsDefault='Y'" + + " AND d.DocBaseType='POO' AND o.AD_Client_ID=d.AD_Client_ID) " + "WHERE C_DocType_ID IS NULL AND IsSOTrx='N' AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set PO Default DocType=" + no); sql = new StringBuffer ("UPDATE I_Order o " // Default SO - + "SET C_DocType_ID=(SELECT C_DocType_ID FROM C_DocType d WHERE d.IsDefault='Y'" - + " AND d.DocBaseType='SOO' AND ROWNUM=1 AND o.AD_Client_ID=d.AD_Client_ID) " + + "SET C_DocType_ID=(SELECT MAX(C_DocType_ID) FROM C_DocType d WHERE d.IsDefault='Y'" + + " AND d.DocBaseType='SOO' AND o.AD_Client_ID=d.AD_Client_ID) " + "WHERE C_DocType_ID IS NULL AND IsSOTrx='Y' AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set SO Default DocType=" + no); sql = new StringBuffer ("UPDATE I_Order o " - + "SET C_DocType_ID=(SELECT C_DocType_ID FROM C_DocType d WHERE d.IsDefault='Y'" - + " AND d.DocBaseType IN('SOO','POO') AND ROWNUM=1 AND o.AD_Client_ID=d.AD_Client_ID) " + + "SET C_DocType_ID=(SELECT MAX(C_DocType_ID) FROM C_DocType d WHERE d.IsDefault='Y'" + + " AND d.DocBaseType IN('SOO','POO') AND o.AD_Client_ID=d.AD_Client_ID) " + "WHERE C_DocType_ID IS NULL AND IsSOTrx IS NULL AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set Default DocType=" + no); @@ -184,26 +184,26 @@ public class ImportOrder extends SvrProcess // Price List sql = new StringBuffer ("UPDATE I_Order o " - + "SET M_PriceList_ID=(SELECT M_PriceList_ID FROM M_PriceList p WHERE p.IsDefault='Y'" - + " AND p.C_Currency_ID=o.C_Currency_ID AND p.IsSOPriceList=o.IsSOTrx AND ROWNUM=1 AND o.AD_Client_ID=p.AD_Client_ID) " + + "SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p WHERE p.IsDefault='Y'" + + " AND p.C_Currency_ID=o.C_Currency_ID AND p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) " + "WHERE M_PriceList_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set Default Currency PriceList=" + no); sql = new StringBuffer ("UPDATE I_Order o " - + "SET M_PriceList_ID=(SELECT M_PriceList_ID FROM M_PriceList p WHERE p.IsDefault='Y'" - + " AND p.IsSOPriceList=o.IsSOTrx AND ROWNUM=1 AND o.AD_Client_ID=p.AD_Client_ID) " + + "SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p WHERE p.IsDefault='Y'" + + " AND p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) " + "WHERE M_PriceList_ID IS NULL AND C_Currency_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set Default PriceList=" + no); sql = new StringBuffer ("UPDATE I_Order o " - + "SET M_PriceList_ID=(SELECT M_PriceList_ID FROM M_PriceList p " - + " WHERE p.C_Currency_ID=o.C_Currency_ID AND p.IsSOPriceList=o.IsSOTrx AND ROWNUM=1 AND o.AD_Client_ID=p.AD_Client_ID) " + + "SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p " + + " WHERE p.C_Currency_ID=o.C_Currency_ID AND p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) " + "WHERE M_PriceList_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set Currency PriceList=" + no); sql = new StringBuffer ("UPDATE I_Order o " - + "SET M_PriceList_ID=(SELECT M_PriceList_ID FROM M_PriceList p " - + " WHERE p.IsSOPriceList=o.IsSOTrx AND ROWNUM=1 AND o.AD_Client_ID=p.AD_Client_ID) " + + "SET M_PriceList_ID=(SELECT MAX(M_PriceList_ID) FROM M_PriceList p " + + " WHERE p.IsSOPriceList=o.IsSOTrx AND o.AD_Client_ID=p.AD_Client_ID) " + "WHERE M_PriceList_ID IS NULL AND C_Currency_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set PriceList=" + no); @@ -224,8 +224,8 @@ public class ImportOrder extends SvrProcess no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set PaymentTerm=" + no); sql = new StringBuffer ("UPDATE I_Order o " - + "SET C_PaymentTerm_ID=(SELECT C_PaymentTerm_ID FROM C_PaymentTerm p" - + " WHERE p.IsDefault='Y' AND ROWNUM=1 AND o.AD_Client_ID=p.AD_Client_ID) " + + "SET C_PaymentTerm_ID=(SELECT MAX(C_PaymentTerm_ID) FROM C_PaymentTerm p" + + " WHERE p.IsDefault='Y' AND o.AD_Client_ID=p.AD_Client_ID) " + "WHERE C_PaymentTerm_ID IS NULL AND o.PaymentTermValue IS NULL AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set Default PaymentTerm=" + no); @@ -240,8 +240,8 @@ public class ImportOrder extends SvrProcess // Warehouse sql = new StringBuffer ("UPDATE I_Order o " - + "SET M_Warehouse_ID=(SELECT M_Warehouse_ID FROM M_Warehouse w" - + " WHERE ROWNUM=1 AND o.AD_Client_ID=w.AD_Client_ID AND o.AD_Org_ID=w.AD_Org_ID) " + + "SET M_Warehouse_ID=(SELECT MAX(M_Warehouse_ID) FROM M_Warehouse w" + + " WHERE o.AD_Client_ID=w.AD_Client_ID AND o.AD_Org_ID=w.AD_Org_ID) " + "WHERE M_Warehouse_ID IS NULL AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); // Warehouse for Org if (no != 0) @@ -283,8 +283,8 @@ public class ImportOrder extends SvrProcess log.fine("Set BP from ContactName=" + no); // BP from Value sql = new StringBuffer ("UPDATE I_Order o " - + "SET C_BPartner_ID=(SELECT C_BPartner_ID FROM C_BPartner bp" - + " WHERE o.BPartnerValue=bp.Value AND o.AD_Client_ID=bp.AD_Client_ID AND ROWNUM=1) " + + "SET C_BPartner_ID=(SELECT MAX(C_BPartner_ID) FROM C_BPartner bp" + + " WHERE o.BPartnerValue=bp.Value AND o.AD_Client_ID=bp.AD_Client_ID) " + "WHERE C_BPartner_ID IS NULL AND BPartnerValue IS NOT NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); @@ -312,20 +312,20 @@ public class ImportOrder extends SvrProcess log.fine("Found Location=" + no); // Set Bill Location from BPartner sql = new StringBuffer ("UPDATE I_Order o " - + "SET BillTo_ID=(SELECT C_BPartner_Location_ID FROM C_BPartner_Location l" + + "SET BillTo_ID=(SELECT MAX(C_BPartner_Location_ID) FROM C_BPartner_Location l" + " WHERE l.C_BPartner_ID=o.C_BPartner_ID AND o.AD_Client_ID=l.AD_Client_ID" + " AND ((l.IsBillTo='Y' AND o.IsSOTrx='Y') OR (l.IsPayFrom='Y' AND o.IsSOTrx='N'))" - + " AND ROWNUM=1) " + + ") " + "WHERE C_BPartner_ID IS NOT NULL AND BillTo_ID IS NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set BP BillTo from BP=" + no); // Set Location from BPartner sql = new StringBuffer ("UPDATE I_Order o " - + "SET C_BPartner_Location_ID=(SELECT C_BPartner_Location_ID FROM C_BPartner_Location l" + + "SET C_BPartner_Location_ID=(SELECT MAX(C_BPartner_Location_ID) FROM C_BPartner_Location l" + " WHERE l.C_BPartner_ID=o.C_BPartner_ID AND o.AD_Client_ID=l.AD_Client_ID" + " AND ((l.IsShipTo='Y' AND o.IsSOTrx='Y') OR o.IsSOTrx='N')" - + " AND ROWNUM=1) " + + ") " + "WHERE C_BPartner_ID IS NOT NULL AND C_BPartner_Location_ID IS NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); @@ -342,8 +342,8 @@ public class ImportOrder extends SvrProcess // Set Country /** sql = new StringBuffer ("UPDATE I_Order o " - + "SET CountryCode=(SELECT CountryCode FROM C_Country c WHERE c.IsDefault='Y'" - + " AND c.AD_Client_ID IN (0, o.AD_Client_ID) AND ROWNUM=1) " + + "SET CountryCode=(SELECT MAX(CountryCode) FROM C_Country c WHERE c.IsDefault='Y'" + + " AND c.AD_Client_ID IN (0, o.AD_Client_ID)) " + "WHERE C_BPartner_ID IS NULL AND CountryCode IS NULL AND C_Country_ID IS NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); @@ -367,9 +367,9 @@ public class ImportOrder extends SvrProcess // Set Region sql = new StringBuffer ("UPDATE I_Order o " - + "Set RegionName=(SELECT Name FROM C_Region r" + + "Set RegionName=(SELECT MAX(Name) FROM C_Region r" + " WHERE r.IsDefault='Y' AND r.C_Country_ID=o.C_Country_ID" - + " AND r.AD_Client_ID IN (0, o.AD_Client_ID) AND ROWNUM=1) " + + " AND r.AD_Client_ID IN (0, o.AD_Client_ID)) " + "WHERE C_BPartner_ID IS NULL AND C_Region_ID IS NULL AND RegionName IS NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); @@ -396,22 +396,22 @@ public class ImportOrder extends SvrProcess // Product sql = new StringBuffer ("UPDATE I_Order o " - + "SET M_Product_ID=(SELECT M_Product_ID FROM M_Product p" - + " WHERE o.ProductValue=p.Value AND o.AD_Client_ID=p.AD_Client_ID AND ROWNUM=1) " + + "SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p" + + " WHERE o.ProductValue=p.Value AND o.AD_Client_ID=p.AD_Client_ID) " + "WHERE M_Product_ID IS NULL AND ProductValue IS NOT NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set Product from Value=" + no); sql = new StringBuffer ("UPDATE I_Order o " - + "SET M_Product_ID=(SELECT M_Product_ID FROM M_Product p" - + " WHERE o.UPC=p.UPC AND o.AD_Client_ID=p.AD_Client_ID AND ROWNUM=1) " + + "SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p" + + " WHERE o.UPC=p.UPC AND o.AD_Client_ID=p.AD_Client_ID) " + "WHERE M_Product_ID IS NULL AND UPC IS NOT NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set Product from UPC=" + no); sql = new StringBuffer ("UPDATE I_Order o " - + "SET M_Product_ID=(SELECT M_Product_ID FROM M_Product p" - + " WHERE o.SKU=p.SKU AND o.AD_Client_ID=p.AD_Client_ID AND ROWNUM=1) " + + "SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p" + + " WHERE o.SKU=p.SKU AND o.AD_Client_ID=p.AD_Client_ID) " + "WHERE M_Product_ID IS NULL AND SKU IS NOT NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); @@ -426,8 +426,8 @@ public class ImportOrder extends SvrProcess // Tax sql = new StringBuffer ("UPDATE I_Order o " - + "SET C_Tax_ID=(SELECT C_Tax_ID FROM C_Tax t" - + " WHERE o.TaxIndicator=t.TaxIndicator AND o.AD_Client_ID=t.AD_Client_ID AND ROWNUM=1) " + + "SET C_Tax_ID=(SELECT MAX(C_Tax_ID) FROM C_Tax t" + + " WHERE o.TaxIndicator=t.TaxIndicator AND o.AD_Client_ID=t.AD_Client_ID) " + "WHERE C_Tax_ID IS NULL AND TaxIndicator IS NOT NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); diff --git a/base/src/org/compiere/process/ImportPayment.java b/base/src/org/compiere/process/ImportPayment.java index 37a449d3eb..0d377c800c 100644 --- a/base/src/org/compiere/process/ImportPayment.java +++ b/base/src/org/compiere/process/ImportPayment.java @@ -255,8 +255,8 @@ public class ImportPayment extends SvrProcess // Invoice sql = new StringBuffer ("UPDATE I_Payment i " - + "SET C_Invoice_ID=(SELECT C_Invoice_ID FROM C_Invoice ii" - + " WHERE i.InvoiceDocumentNo=ii.DocumentNo AND i.AD_Client_ID=ii.AD_Client_ID AND ROWNUM=1) " + + "SET C_Invoice_ID=(SELECT MAX(C_Invoice_ID) FROM C_Invoice ii" + + " WHERE i.InvoiceDocumentNo=ii.DocumentNo AND i.AD_Client_ID=ii.AD_Client_ID) " + "WHERE C_Invoice_ID IS NULL AND InvoiceDocumentNo IS NOT NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); @@ -265,8 +265,8 @@ public class ImportPayment extends SvrProcess // BPartner sql = new StringBuffer ("UPDATE I_Payment i " - + "SET C_BPartner_ID=(SELECT C_BPartner_ID FROM C_BPartner bp" - + " WHERE i.BPartnerValue=bp.Value AND i.AD_Client_ID=bp.AD_Client_ID AND ROWNUM=1) " + + "SET C_BPartner_ID=(SELECT MAX(C_BPartner_ID) FROM C_BPartner bp" + + " WHERE i.BPartnerValue=bp.Value AND i.AD_Client_ID=bp.AD_Client_ID) " + "WHERE C_BPartner_ID IS NULL AND BPartnerValue IS NOT NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); @@ -274,8 +274,8 @@ public class ImportPayment extends SvrProcess log.fine("Set BP from Value=" + no); sql = new StringBuffer ("UPDATE I_Payment i " - + "SET C_BPartner_ID=(SELECT C_BPartner_ID FROM C_Invoice ii" - + " WHERE i.C_Invoice_ID=ii.C_Invoice_ID AND i.AD_Client_ID=ii.AD_Client_ID AND ROWNUM=1) " + + "SET C_BPartner_ID=(SELECT MAX(C_BPartner_ID) FROM C_Invoice ii" + + " WHERE i.C_Invoice_ID=ii.C_Invoice_ID AND i.AD_Client_ID=ii.AD_Client_ID) " + "WHERE C_BPartner_ID IS NULL AND C_Invoice_ID IS NOT NULL" + " AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); diff --git a/base/src/org/compiere/process/ImportProduct.java b/base/src/org/compiere/process/ImportProduct.java index b27672fe11..408ed4be87 100644 --- a/base/src/org/compiere/process/ImportProduct.java +++ b/base/src/org/compiere/process/ImportProduct.java @@ -35,8 +35,6 @@ public class ImportProduct extends SvrProcess /** Delete old Imported */ private boolean m_deleteOldImported = false; - /** Organization to be imported to */ - private int m_AD_Org_ID = 0; /** Effective */ private Timestamp m_DateValue = null; /** Pricelist to Update */ @@ -152,8 +150,8 @@ public class ImportProduct extends SvrProcess // Set Product Category sql = new StringBuffer ("UPDATE I_Product " - + "SET ProductCategory_Value=(SELECT Value FROM M_Product_Category" - + " WHERE IsDefault='Y' AND AD_Client_ID=").append(m_AD_Client_ID).append(" AND ROWNUM=1) " + + "SET ProductCategory_Value=(SELECT MAX(Value) FROM M_Product_Category" + + " WHERE IsDefault='Y' AND AD_Client_ID=").append(m_AD_Client_ID).append(") " + "WHERE ProductCategory_Value IS NULL AND M_Product_Category_ID IS NULL" + " AND M_Product_ID IS NULL" // set category only if product not found + " AND I_IsImported<>'Y'").append(clientCheck); @@ -247,7 +245,7 @@ public class ImportProduct extends SvrProcess // Set UOM (System/own) sql = new StringBuffer ("UPDATE I_Product i " + "SET X12DE355 = " - + "(SELECT X12DE355 FROM C_UOM u WHERE u.IsDefault='Y' AND u.AD_Client_ID IN (0,i.AD_Client_ID) AND ROWNUM=1) " + + "(SELECT MAX(X12DE355) FROM C_UOM u WHERE u.IsDefault='Y' AND u.AD_Client_ID IN (0,i.AD_Client_ID)) " + "WHERE X12DE355 IS NULL AND C_UOM_ID IS NULL" + " AND I_IsImported<>'Y'").append(clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); @@ -404,8 +402,9 @@ public class ImportProduct extends SvrProcess + "WHERE I_Product_ID=?"); */ // Update Product from Import - PreparedStatement pstmt_updateProduct = DB.prepareStatement - ("UPDATE M_PRODUCT " + //jz moved + /* + String sqlt = "UPDATE M_PRODUCT " + "SET (Value,Name,Description,DocumentNote,Help," + "UPC,SKU,C_UOM_ID,M_Product_Category_ID,Classification,ProductType," + "Volume,Weight,ShelfWidth,ShelfHeight,ShelfDepth,UnitsPerPallet," @@ -415,11 +414,12 @@ public class ImportProduct extends SvrProcess + "Volume,Weight,ShelfWidth,ShelfHeight,ShelfDepth,UnitsPerPallet," + "Discontinued,DiscontinuedBy,SysDate,UpdatedBy" + " FROM I_Product WHERE I_Product_ID=?) " - + "WHERE M_Product_ID=?", get_TrxName()); + + "WHERE M_Product_ID=?"; + PreparedStatement pstmt_updateProduct = DB.prepareStatement + (sqlt, get_TrxName()); // Update Product_PO from Import - PreparedStatement pstmt_updateProductPO = DB.prepareStatement - ("UPDATE M_Product_PO " + sqlt = "UPDATE M_Product_PO " + "SET (IsCurrentVendor,C_UOM_ID,C_Currency_ID,UPC," + "PriceList,PricePO,RoyaltyAmt,PriceEffective," + "VendorProductNo,VendorCategory,Manufacturer," @@ -432,8 +432,10 @@ public class ImportProduct extends SvrProcess + "CostPerOrder,DeliveryTime_Promised,SysDate,UpdatedBy" + " FROM I_Product" + " WHERE I_Product_ID=?) " - + "WHERE M_Product_ID=? AND C_BPartner_ID=?", get_TrxName()); - + + "WHERE M_Product_ID=? AND C_BPartner_ID=?"; + PreparedStatement pstmt_updateProductPO = DB.prepareStatement + (sqlt, get_TrxName()); +*/ // Insert Product from Import PreparedStatement pstmt_insertProductPO = DB.prepareStatement ("INSERT INTO M_Product_PO (M_Product_ID,C_BPartner_ID, " @@ -493,8 +495,22 @@ public class ImportProduct extends SvrProcess } else // Update Product { - pstmt_updateProduct.setInt(1, I_Product_ID); - pstmt_updateProduct.setInt(2, M_Product_ID); + String sqlt = "UPDATE M_PRODUCT " + + "SET (Value,Name,Description,DocumentNote,Help," + + "UPC,SKU,C_UOM_ID,M_Product_Category_ID,Classification,ProductType," + + "Volume,Weight,ShelfWidth,ShelfHeight,ShelfDepth,UnitsPerPallet," + + "Discontinued,DiscontinuedBy,Updated,UpdatedBy)= " + + "(SELECT Value,Name,Description,DocumentNote,Help," + + "UPC,SKU,C_UOM_ID,M_Product_Category_ID,Classification,ProductType," + + "Volume,Weight,ShelfWidth,ShelfHeight,ShelfDepth,UnitsPerPallet," + + "Discontinued,DiscontinuedBy,SysDate,UpdatedBy" + + " FROM I_Product WHERE I_Product_ID="+I_Product_ID+") " + + "WHERE M_Product_ID="+M_Product_ID; + PreparedStatement pstmt_updateProduct = DB.prepareStatement + (sqlt, get_TrxName()); + + //jz pstmt_updateProduct.setInt(1, I_Product_ID); + // pstmt_updateProduct.setInt(2, M_Product_ID); try { no = pstmt_updateProduct.executeUpdate(); @@ -510,6 +526,7 @@ public class ImportProduct extends SvrProcess DB.executeUpdate(sql0.toString(), get_TrxName()); continue; } + pstmt_updateProduct.close(); } // Do we have PO Info @@ -519,9 +536,25 @@ public class ImportProduct extends SvrProcess // If Product existed, Try to Update first if (!newProduct) { - pstmt_updateProductPO.setInt(1, I_Product_ID); - pstmt_updateProductPO.setInt(2, M_Product_ID); - pstmt_updateProductPO.setInt(3, C_BPartner_ID); + String sqlt = "UPDATE M_Product_PO " + + "SET (IsCurrentVendor,C_UOM_ID,C_Currency_ID,UPC," + + "PriceList,PricePO,RoyaltyAmt,PriceEffective," + + "VendorProductNo,VendorCategory,Manufacturer," + + "Discontinued,DiscontinuedBy,Order_Min,Order_Pack," + + "CostPerOrder,DeliveryTime_Promised,Updated,UpdatedBy)= " + + "(SELECT CAST('Y' AS CHAR),C_UOM_ID,C_Currency_ID,UPC," //jz fix EDB unknown datatype error + + "PriceList,PricePO,RoyaltyAmt,PriceEffective," + + "VendorProductNo,VendorCategory,Manufacturer," + + "Discontinued,DiscontinuedBy,Order_Min,Order_Pack," + + "CostPerOrder,DeliveryTime_Promised,SysDate,UpdatedBy" + + " FROM I_Product" + + " WHERE I_Product_ID="+I_Product_ID+") " + + "WHERE M_Product_ID="+M_Product_ID+" AND C_BPartner_ID="+C_BPartner_ID; + PreparedStatement pstmt_updateProductPO = DB.prepareStatement + (sqlt, get_TrxName()); + //jz pstmt_updateProductPO.setInt(1, I_Product_ID); + // pstmt_updateProductPO.setInt(2, M_Product_ID); + // pstmt_updateProductPO.setInt(3, C_BPartner_ID); try { no = pstmt_updateProductPO.executeUpdate(); @@ -539,6 +572,7 @@ public class ImportProduct extends SvrProcess DB.executeUpdate(sql0.toString(), get_TrxName()); continue; } + pstmt_updateProductPO.close(); } if (no == 0) // Insert PO { @@ -594,10 +628,10 @@ public class ImportProduct extends SvrProcess pstmt.close(); // - // pstmt_insertProduct.close(); - pstmt_updateProduct.close(); + // pstmt_insertProduct.close(); + // pstmt_updateProduct.close(); pstmt_insertProductPO.close(); - pstmt_updateProductPO.close(); + // pstmt_updateProductPO.close(); pstmt_setImported.close(); // } diff --git a/base/src/org/compiere/process/ImportReportLine.java b/base/src/org/compiere/process/ImportReportLine.java index df8299264e..d00a1cceba 100644 --- a/base/src/org/compiere/process/ImportReportLine.java +++ b/base/src/org/compiere/process/ImportReportLine.java @@ -36,8 +36,6 @@ public class ImportReportLine extends SvrProcess /** Delete old Imported */ private boolean m_deleteOldImported = false; - /** Organization to be imported to */ - private int m_AD_Org_ID = 0; /** Effective */ private Timestamp m_DateValue = null; @@ -228,8 +226,8 @@ public class ImportReportLine extends SvrProcess // Set PA_ReportLine_ID sql = new StringBuffer ("UPDATE I_ReportLine i " - + "SET PA_ReportLine_ID=(SELECT PA_ReportLine_ID FROM PA_ReportLine r" - + " WHERE i.Name=r.Name AND i.PA_ReportLineSet_ID=r.PA_ReportLineSet_ID AND ROWNUM=1) " + + "SET PA_ReportLine_ID=(SELECT MAX(PA_ReportLine_ID) FROM PA_ReportLine r" + + " WHERE i.Name=r.Name AND i.PA_ReportLineSet_ID=r.PA_ReportLineSet_ID) " + "WHERE PA_ReportLine_ID IS NULL AND PA_ReportLineSet_ID IS NOT NULL" + " AND I_IsImported='N'").append(clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); @@ -257,9 +255,14 @@ public class ImportReportLine extends SvrProcess + "SELECT ?,PA_ReportLineSet_ID," + "AD_Client_ID,AD_Org_ID,'Y',SysDate,CreatedBy,SysDate,UpdatedBy," + "Name,SeqNo,IsPrinted,IsSummary,LineType " + //jz + "FROM I_ReportLine " + // + "WHERE PA_ReportLineSet_ID=? AND Name=? AND ROWNUM=1" // #2..3 + "FROM I_ReportLine " - + "WHERE PA_ReportLineSet_ID=? AND Name=? AND ROWNUM=1" // #2..3 - + clientCheck, get_TrxName()); + + "WHERE I_ReportLine_ID=(SELECT MAX(I_ReportLine_ID) " + + "FROM I_ReportLine " + + "WHERE PA_ReportLineSet_ID=? AND Name=? " // #2..3 + //jz + clientCheck, get_TrxName()); + + clientCheck + ")", get_TrxName()); PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); ResultSet rs = pstmt.executeQuery(); @@ -299,8 +302,8 @@ public class ImportReportLine extends SvrProcess // Set PA_ReportLine_ID (for newly created) sql = new StringBuffer ("UPDATE I_ReportLine i " - + "SET PA_ReportLine_ID=(SELECT PA_ReportLine_ID FROM PA_ReportLine r" - + " WHERE i.Name=r.Name AND i.PA_ReportLineSet_ID=r.PA_ReportLineSet_ID AND ROWNUM=1) " + + "SET PA_ReportLine_ID=(SELECT MAX(PA_ReportLine_ID) FROM PA_ReportLine r" + + " WHERE i.Name=r.Name AND i.PA_ReportLineSet_ID=r.PA_ReportLineSet_ID) " + "WHERE PA_ReportLine_ID IS NULL AND PA_ReportLineSet_ID IS NOT NULL" + " AND I_IsImported='N'").append(clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); @@ -348,14 +351,18 @@ public class ImportReportLine extends SvrProcess + clientCheck, get_TrxName()); // Update ReportSource - PreparedStatement pstmt_updateSource = DB.prepareStatement - ("UPDATE PA_ReportSource " + //jz + /* + String sqlt="UPDATE PA_ReportSource " + "SET (ElementType,C_ElementValue_ID,Updated,UpdatedBy)=" + " (SELECT 'AC',C_ElementValue_ID,SysDate,UpdatedBy" + " FROM I_ReportLine" + " WHERE I_ReportLine_ID=?) " + "WHERE PA_ReportSource_ID=?" - + clientCheck, get_TrxName()); + + clientCheck; + PreparedStatement pstmt_updateSource = DB.prepareStatement + (sqlt, get_TrxName()); + */ // Set Imported = Y PreparedStatement pstmt_setImported = DB.prepareStatement @@ -396,11 +403,22 @@ public class ImportReportLine extends SvrProcess } else // update Report Source { - pstmt_updateSource.setInt(1, I_ReportLine_ID); - pstmt_updateSource.setInt(2, PA_ReportSource_ID); + //jz + String sqlt="UPDATE PA_ReportSource " + + "SET (ElementType,C_ElementValue_ID,Updated,UpdatedBy)=" + + " (SELECT CAST('AC' AS CHAR(2)),C_ElementValue_ID,SysDate,UpdatedBy" //jz + + " FROM I_ReportLine" + + " WHERE I_ReportLine_ID=" + I_ReportLine_ID + ") " + + "WHERE PA_ReportSource_ID="+PA_ReportSource_ID+" " + + clientCheck; + PreparedStatement pstmt_updateSource = DB.prepareStatement + (sqlt, get_TrxName()); + //pstmt_updateSource.setInt(1, I_ReportLine_ID); + //pstmt_updateSource.setInt(2, PA_ReportSource_ID); try { no = pstmt_updateSource.executeUpdate(); + //no = DB.executeUpdate(sqlt, get_TrxName()); log.finest("Update ReportSource = " + no + ", I_ReportLine_ID=" + I_ReportLine_ID + ", PA_ReportSource_ID=" + PA_ReportSource_ID); noUpdateSource++; } @@ -413,6 +431,7 @@ public class ImportReportLine extends SvrProcess DB.executeUpdate(sql.toString(), get_TrxName()); continue; } + pstmt_updateSource.close(); } // update source // Set Imported to Y @@ -428,7 +447,7 @@ public class ImportReportLine extends SvrProcess pstmt.close(); // pstmt_insertSource.close(); - pstmt_updateSource.close(); + //jz pstmt_updateSource.close(); pstmt_setImported.close(); // } diff --git a/base/src/org/compiere/process/InOutGenerate.java b/base/src/org/compiere/process/InOutGenerate.java index a64870b55d..2eb7499303 100644 --- a/base/src/org/compiere/process/InOutGenerate.java +++ b/base/src/org/compiere/process/InOutGenerate.java @@ -143,12 +143,13 @@ public class InOutGenerate extends SvrProcess + " AND o.DeliveryRule<>'M'" // Open Order Lines with Warehouse + " AND EXISTS (SELECT * FROM C_OrderLine ol " - + "WHERE ol.M_Warehouse_ID=?" - + " AND o.C_Order_ID=ol.C_Order_ID AND ol.QtyOrdered<>ol.QtyDelivered)"; - if (p_C_BPartner_ID != 0) - m_sql += " AND C_BPartner_ID=?"; + + "WHERE ol.M_Warehouse_ID=?"; // #1 if (p_DatePromised != null) - m_sql += " AND TRUNC(DatePromised)<=?"; + m_sql += " AND TRUNC(ol.DatePromised)<=?"; // #2 + m_sql += " AND o.C_Order_ID=ol.C_Order_ID AND ol.QtyOrdered<>ol.QtyDelivered)"; + // + if (p_C_BPartner_ID != 0) + m_sql += " AND o.C_BPartner_ID=?"; // #3 } m_sql += " ORDER BY M_Warehouse_ID, PriorityRule, M_Shipper_ID, C_BPartner_ID, C_BPartner_Location_ID, C_Order_ID"; // m_sql += " FOR UPDATE"; @@ -163,10 +164,10 @@ public class InOutGenerate extends SvrProcess else { pstmt.setInt(index++, p_M_Warehouse_ID); - if (p_C_BPartner_ID != 0) - pstmt.setInt(index++, p_C_BPartner_ID); if (p_DatePromised != null) pstmt.setTimestamp(index++, p_DatePromised); + if (p_C_BPartner_ID != 0) + pstmt.setInt(index++, p_C_BPartner_ID); } } catch (Exception e) @@ -200,8 +201,11 @@ public class InOutGenerate extends SvrProcess // Timestamp minGuaranteeDate = m_movementDate; boolean completeOrder = MOrder.DELIVERYRULE_CompleteOrder.equals(order.getDeliveryRule()); - // + // OrderLine WHERE String where = " AND M_Warehouse_ID=" + p_M_Warehouse_ID; + if (p_DatePromised != null) + where += " AND (TRUNC(DatePromised)<=" + DB.TO_DATE(p_DatePromised, true) + + " OR DatePromised IS NULL)"; // Exclude Auto Delivery if not Force if (!MOrder.DELIVERYRULE_Force.equals(order.getDeliveryRule())) where += " AND (C_OrderLine.M_Product_ID IS NULL" @@ -229,10 +233,6 @@ public class InOutGenerate extends SvrProcess if (product != null && toDeliver.signum() == 0) continue; - // or it's a charge - Bug#: 1603966 - if (line.getC_Charge_ID()!=0 && toDeliver.signum() == 0) - continue; - // Check / adjust for confirmations BigDecimal unconfirmedShippedQty = Env.ZERO; if (p_IsUnconfirmedInOut && product != null && toDeliver.signum() != 0) diff --git a/base/src/org/compiere/process/InventoryCountCreate.java b/base/src/org/compiere/process/InventoryCountCreate.java index 147df6df7c..de0637331e 100644 --- a/base/src/org/compiere/process/InventoryCountCreate.java +++ b/base/src/org/compiere/process/InventoryCountCreate.java @@ -181,6 +181,7 @@ public class InventoryCountCreate extends SvrProcess + " AND il.M_Product_ID=s.M_Product_ID" + " AND il.M_Locator_ID=s.M_Locator_ID" + " AND COALESCE(il.M_AttributeSetInstance_ID,0)=COALESCE(s.M_AttributeSetInstance_ID,0))"); + // + " AND il.M_AttributeSetInstance_ID=s.M_AttributeSetInstance_ID)"); // sql.append(" ORDER BY l.Value, p.Value, s.QtyOnHand DESC"); // Locator/Product // diff --git a/base/src/org/compiere/process/InvoiceGenerate.java b/base/src/org/compiere/process/InvoiceGenerate.java index 93283cb9f8..073f71fe77 100644 --- a/base/src/org/compiere/process/InvoiceGenerate.java +++ b/base/src/org/compiere/process/InvoiceGenerate.java @@ -354,7 +354,7 @@ public class InvoiceGenerate extends SvrProcess m_bp = new MBPartner (getCtx(), ship.getC_BPartner_ID(), get_TrxName()); // Reference: Delivery: 12345 - 12.12.12 - MClient client = MClient.get(getCtx()); + MClient client = MClient.get(getCtx(), order.getAD_Client_ID ()); String AD_Language = client.getAD_Language(); if (client.isMultiLingualDocument() && m_bp.getAD_Language() != null) AD_Language = m_bp.getAD_Language(); diff --git a/base/src/org/compiere/process/InvoicePrint.java b/base/src/org/compiere/process/InvoicePrint.java index b848fb8821..3d917a0d80 100644 --- a/base/src/org/compiere/process/InvoicePrint.java +++ b/base/src/org/compiere/process/InvoicePrint.java @@ -91,6 +91,11 @@ public class InvoicePrint extends SvrProcess // Need to have Template if (p_EMailPDF && p_R_MailText_ID == 0) throw new AdempiereUserError ("@NotFound@: @R_MailText_ID@"); + log.info ("C_BPartner_ID=" + m_C_BPartner_ID + + ", C_Invoice_ID=" + m_C_Invoice_ID + + ", EmailPDF=" + p_EMailPDF + ",R_MailText_ID=" + p_R_MailText_ID + + ", DateInvoiced=" + m_dateInvoiced_From + "-" + m_dateInvoiced_To + + ", DocumentNo=" + m_DocumentNo_From + "-" + m_DocumentNo_To); MMailText mText = null; if (p_R_MailText_ID != 0) diff --git a/base/src/org/compiere/process/PaymentOnline.java b/base/src/org/compiere/process/PaymentOnline.java index 344465b6b1..4fb5378f3f 100644 --- a/base/src/org/compiere/process/PaymentOnline.java +++ b/base/src/org/compiere/process/PaymentOnline.java @@ -30,8 +30,6 @@ import org.compiere.util.*; */ public class PaymentOnline extends SvrProcess { - private int m_C_Payment_ID = -1; - /** * Prepare - e.g., get Parameters. */ diff --git a/base/src/org/compiere/process/TreeMaintenance.java b/base/src/org/compiere/process/TreeMaintenance.java index 64d95aad1f..cf9b1192b0 100644 --- a/base/src/org/compiere/process/TreeMaintenance.java +++ b/base/src/org/compiere/process/TreeMaintenance.java @@ -57,7 +57,7 @@ public class TreeMaintenance extends SvrProcess */ protected String doIt() throws Exception { - log.info("doIt - AD_Tree_ID=" + m_AD_Tree_ID); + log.info("AD_Tree_ID=" + m_AD_Tree_ID); if (m_AD_Tree_ID == 0) throw new IllegalArgumentException("Tree_ID = 0"); MTree tree = new MTree (getCtx(), m_AD_Tree_ID, get_TrxName()); @@ -139,13 +139,13 @@ public class TreeMaintenance extends SvrProcess // node = new MTree_NodeMM(tree, Node_ID); // if (node == null) - log.log(Level.SEVERE, "verifyTree - no Model for " + nodeTableName); + log.log(Level.SEVERE, "No Model for " + nodeTableName); else { if (node.save()) inserts++; else - log.log(Level.SEVERE, "verifyTree - Could not add to " + tree + " Node_ID=" + Node_ID); + log.log(Level.SEVERE, "Could not add to " + tree + " Node_ID=" + Node_ID); } } rs.close(); diff --git a/base/src/org/compiere/tools/FileUtil.java b/base/src/org/compiere/tools/FileUtil.java index e762f7a70a..034cbbe5c6 100644 --- a/base/src/org/compiere/tools/FileUtil.java +++ b/base/src/org/compiere/tools/FileUtil.java @@ -327,6 +327,14 @@ public class FileUtil } } // license + /** + * Get Filter String + * @return flter String + */ + String getFilterString() + { + return m_filterString; + } // getFilterString /************************************************************************** * File Filter. @@ -347,7 +355,8 @@ public class FileUtil File file = new File (dir, name); if (file.isDirectory()) return true; - if (m_filterString == null || m_filterString.length() == 0) + String filterString = getFilterString(); + if (filterString == null || filterString.length() == 0) return true; if (name == null) return false; @@ -355,7 +364,7 @@ public class FileUtil if (name.indexOf("~") != -1 || name.equals("FileUtil.java")) return false; // - return name.indexOf(m_filterString) != -1; + return name.indexOf(filterString) != -1; } // accept } // FileUtilFilter diff --git a/base/src/org/compiere/util/WebLogin.java b/base/src/org/compiere/util/WebLogin.java index ab834c34d4..eb241a3849 100644 --- a/base/src/org/compiere/util/WebLogin.java +++ b/base/src/org/compiere/util/WebLogin.java @@ -24,7 +24,8 @@ import java.util.logging.*; /** - * WebLogin provides a standard interface to login from Webapps like WStore or M + * WebLogin provides a standard interface to login + * from Webapps like WStore or CM * * @author Yves Sandfort * @version $Id$ @@ -33,7 +34,8 @@ public class WebLogin { /** Logging */ private CLogger log = CLogger.getCLogger(getClass()); - private final static String COOKIE_NAME = "adempiereWebUser"; + private final static String COOKIE_NAME = "CompiereWebUser"; + /** Forward Parameter */ private String P_ForwardTo = "ForwardTo"; /** SalesRep Parameter */ @@ -44,32 +46,36 @@ public class WebLogin private String P_Password = "Password"; /** Mode/Action Parameter */ private String P_Action = "Mode"; + /** Login Page */ - private String LOGIN_RelURL = "/login.jsp"; + private String m_login_page = "/login.jsp"; /** Update Page */ - private String update_page = "/update.jsp"; + private String m_update_page = "/update.jsp"; + /** Message */ - private String message = null; + private String m_message = null; /** Context */ - private Properties ctx; + private Properties m_ctx; /** HttpServletRequest */ - private HttpServletRequest request; + private HttpServletRequest m_request; /** HttpServletResponse */ - private HttpServletResponse response; + private HttpServletResponse m_response; /** HttpSession */ - private HttpSession session; + private HttpSession m_session; /** adressConfirm */ - private boolean addressConfirm; + private boolean m_addressConfirm; /** forward */ - private String forward; + private String m_forward; /** SalesRep */ - private String salesRep; + private String m_salesRep; /** EMail */ - private String email; + private String m_email; /** Password */ - private String password; + private String m_password; /** WebUser */ - private WebUser wu; + private WebUser m_wu; + /** Mode */ + private String m_mode; /** * WebLogin @@ -79,24 +85,24 @@ public class WebLogin */ public WebLogin (HttpServletRequest t_request, HttpServletResponse t_response, Properties t_ctx) { - request = t_request; - response = t_response; - ctx = t_ctx; + m_request = t_request; + m_response = t_response; + m_ctx = t_ctx; // We will check the Request to see whether Parameters are overwritten - if (request.getParameter ("P_ForwardTo")!=null) - setP_ForwardTo (request.getParameter("P_ForwardTo")); - if (request.getParameter ("SalesRep_ID")!=null) - setP_SalesRep_ID (request.getParameter ("SalesRep_ID")); - if (request.getParameter ("P_EMail")!=null) - setP_EMail (request.getParameter ("P_EMail")); - if (request.getParameter ("P_Password")!=null) - setP_Password (request.getParameter ("P_Password")); - if (request.getParameter ("P_Action")!=null) - setP_Action (request.getParameter ("P_Action")); - if (request.getParameter ("LOGIN_RelURL")!=null) - setLogin_RelURL (request.getParameter ("LOGIN_RelURL")); - if (request.getParameter ("update_page")!=null) - setLogin_RelURL (request.getParameter ("update_page")); + if (m_request.getParameter ("P_ForwardTo")!=null) + setP_ForwardTo (m_request.getParameter("P_ForwardTo")); + if (m_request.getParameter ("SalesRep_ID")!=null) + setP_SalesRep_ID (m_request.getParameter ("SalesRep_ID")); + if (m_request.getParameter ("P_EMail")!=null) + setP_EMail (m_request.getParameter ("P_EMail")); + if (m_request.getParameter ("P_Password")!=null) + setP_Password (m_request.getParameter ("P_Password")); + if (m_request.getParameter ("P_Action")!=null) + setP_Action (m_request.getParameter ("P_Action")); + if (m_request.getParameter ("LOGIN_RelURL")!=null) + setLogin_RelURL (m_request.getParameter ("LOGIN_RelURL")); + if (m_request.getParameter ("update_page")!=null) + setLogin_RelURL (m_request.getParameter ("update_page")); } /** @@ -105,35 +111,37 @@ public class WebLogin */ public boolean init() { - session = request.getSession(true); // create new - forward = WebUtil.getParameter (request, P_ForwardTo); // get forward from request - if (forward != null) - session.setAttribute(P_ForwardTo, forward); - salesRep = WebUtil.getParameter (request, P_SalesRep_ID); // get SalesRep from request - if (salesRep != null) - session.setAttribute(P_SalesRep_ID, salesRep); + m_session = m_request.getSession(true); // create new + m_forward = WebUtil.getParameter (m_request, P_ForwardTo); // get forward from request + if (m_forward != null) + m_session.setAttribute(P_ForwardTo, m_forward); + else + m_forward = ""; + m_salesRep = WebUtil.getParameter (m_request, P_SalesRep_ID); // get SalesRep from request + if (m_salesRep != null) + m_session.setAttribute(P_SalesRep_ID, m_salesRep); // Get Base Info - email = WebUtil.getParameter (request, P_EMail); - if (email == null) - email = ""; - email = email.trim(); - if (email != null) - session.setAttribute (P_EMail, email); - password = WebUtil.getParameter (request, P_Password); - if (password == null) - password = ""; // null loads w/o check - password = password.trim(); - if (session.getAttribute (WebInfo.NAME)!=null) + m_email = WebUtil.getParameter (m_request, P_EMail); + if (m_email == null) + m_email = ""; + m_email = m_email.trim(); + if (m_email != null) + m_session.setAttribute (P_EMail, m_email); + m_password = WebUtil.getParameter (m_request, P_Password); + if (m_password == null) + m_password = ""; // null loads w/o check + m_password = m_password.trim(); + if (m_session.getAttribute (WebInfo.NAME)!=null) { - WebInfo wi = (WebInfo)session.getAttribute(WebInfo.NAME); - wu = wi.getWebUser (); + WebInfo wi = (WebInfo)m_session.getAttribute(WebInfo.NAME); + m_wu = wi.getWebUser (); } return true; } /** - * action run functions against the Login process + * Action run functions against the Login process. * @return true if successfull * @throws IOException * @throws ServletException @@ -141,184 +149,190 @@ public class WebLogin public boolean action() throws IOException, ServletException { // Mode - String mode = WebUtil.getParameter (request, P_Action); - boolean deleteCookie = "deleteCookie".equals(mode); + if (getMode() == null) + { + String s = WebUtil.getParameter (m_request, P_Action); + setMode(s); + } + boolean deleteCookie = "deleteCookie".equals(m_mode); if (deleteCookie) { log.fine("** deleteCookie"); - WebUtil.deleteCookieWebUser (request, response, COOKIE_NAME); + WebUtil.deleteCookieWebUser (m_request, m_response, COOKIE_NAME); } - boolean logout = "logout".equals(mode); + // + boolean logout = "logout".equals(m_mode); if (logout || deleteCookie) { log.fine("** logout"); - if (session != null) + if (m_session != null) { - MSession cSession = MSession.get (ctx, false); + MSession cSession = MSession.get (m_ctx, false); if (cSession != null) cSession.logout(); // - wu = (WebUser)session.getAttribute(WebUser.NAME); - if (wu != null) - wu.logout(); + m_wu = (WebUser)m_session.getAttribute(WebUser.NAME); + if (m_wu != null) + m_wu.logout(); - session.removeAttribute(WebUser.NAME); - session.setMaxInactiveInterval(1); - session.invalidate (); + m_session.removeAttribute(WebUser.NAME); + m_session.setMaxInactiveInterval(1); + m_session.invalidate (); } // Forward to unsecure / - WebUtil.createForwardPage(response, "Logout", "http://" + request.getServerName() + "/", 2); + WebUtil.createForwardPage(m_response, "Logout", "http://" + m_request.getServerName() + "/", 2); } // Send EMail *** Send Password EMail Request - else if ("SendEMail".equals(mode)) + else if ("SendEMail".equals(m_mode)) { log.info("** send mail"); - wu = WebUser.get (ctx, email); // find it - if (!wu.isEMailValid()) - wu.setPasswordMessage("EMail not found in system"); + m_wu = WebUser.get (m_ctx, m_email); // find it + if (!m_wu.isEMailValid()) + m_wu.setPasswordMessage("EMail not found in system"); else { - wu.setPassword(); // set password to current + m_wu.setPassword(); // set password to current // - String msg = WebUtil.sendEMail (request, wu, + String msg = WebUtil.sendEMail (m_request, m_wu, MMailMsg.MAILMSGTYPE_UserPassword, new Object[]{ - request.getServerName(), - wu.getName(), - WebUtil.getFrom(request), - wu.getPassword()}); + m_request.getServerName(), + m_wu.getName(), + WebUtil.getFrom(m_request), + m_wu.getPassword()}); if (EMail.SENT_OK.equals(msg)) - wu.setPasswordMessage ("EMail sent"); + m_wu.setPasswordMessage ("EMail sent"); else - wu.setPasswordMessage ("Problem sending EMail: " + msg); + m_wu.setPasswordMessage ("Problem sending EMail: " + msg); } - forward = getLogin_RelURL (); + m_forward = getLogin_RelURL (); } // SendEMail // Login - else if ("Login".equals(mode)) + else if ("Login".equals(m_mode)) { - log.info("** login " + email + "/" + password); + log.info("** login " + m_email + "/" + m_password); // add Cookie - WebUtil.addCookieWebUser(request, response, email, COOKIE_NAME); + WebUtil.addCookieWebUser(m_request, m_response, m_email, COOKIE_NAME); // Always re-query - wu = WebUser.get (ctx, email, password, false); - wu.login(password); + m_wu = WebUser.get (m_ctx, m_email, m_password, false); + m_wu.login(m_password); // Password valid - if (wu.isLoggedIn()) + if (m_wu.isLoggedIn()) { - if (forward==null || forward.equals(getLogin_RelURL ())) - forward = "/index.jsp"; + if (m_forward==null || m_forward.equals(getLogin_RelURL ())) + m_forward = "/index.jsp"; // Create Session with User ID - MSession cSession = MSession.get (ctx, request.getRemoteAddr(), - request.getRemoteHost(), session.getId()); + MSession cSession = MSession.get (m_ctx, m_request.getRemoteAddr(), + m_request.getRemoteHost(), m_session.getId()); if (cSession != null) cSession.setWebStoreSession(true); } else { - forward = getLogin_RelURL (); - log.fine("- PasswordMessage=" + wu.getPasswordMessage()); + m_forward = getLogin_RelURL (); + log.fine("- PasswordMessage=" + m_wu.getPasswordMessage()); } // If no session exists or is not loaded, load or create it - if (session==null) - session = request.getSession (true); + if (m_session==null) + m_session = m_request.getSession (true); - session.setAttribute (WebInfo.NAME, new WebInfo (ctx, wu)); + m_session.setAttribute (WebInfo.NAME, new WebInfo (m_ctx, m_wu)); } // Login // Login New - else if ("LoginNew".equals(mode)) + else if ("LoginNew".equals(m_mode)) { log.info("** loginNew"); - WebUtil.addCookieWebUser(request, response, "", COOKIE_NAME); - wu = WebUser.get (ctx, ""); - forward = getLogin_RelURL (); + WebUtil.addCookieWebUser(m_request, m_response, "", COOKIE_NAME); + m_wu = WebUser.get (m_ctx, ""); + m_forward = getLogin_RelURL (); } // Submit - update/new Contact - else if ("Submit".equals(mode)) + else if ("Submit".equals(m_mode)) { - log.info("** submit " + email + "/" + password + " - AddrConf=" + addressConfirm); + log.info("** submit " + m_email + "/" + m_password + " - AddrConf=" + m_addressConfirm); // we have a record for address update - if (wu != null && wu.isLoggedIn() && addressConfirm) // address update + if (m_wu != null && m_wu.isLoggedIn() && m_addressConfirm) // address update ; else // Submit - always re-load user record - wu = WebUser.get (ctx, email, null, false); // load w/o password check direct + m_wu = WebUser.get (m_ctx, m_email, null, false); // load w/o password check direct // - if (wu.getAD_User_ID() != 0) // existing BPC + if (m_wu.getAD_User_ID() != 0) // existing BPC { - String passwordNew = WebUtil.getParameter (request, "PasswordNew"); + String passwordNew = WebUtil.getParameter (m_request, "PasswordNew"); if (passwordNew == null) passwordNew = ""; - boolean passwordChange = passwordNew.length() > 0 && !passwordNew.equals(password); - if (addressConfirm || wu.login (password)) + boolean passwordChange = passwordNew.length() > 0 && !passwordNew.equals(m_password); + if (m_addressConfirm || m_wu.login (m_password)) { // Create / set session - if (wu.isLoggedIn()) + if (m_wu.isLoggedIn()) { - MSession cSession = MSession.get (ctx, request.getRemoteAddr(), - request.getRemoteHost(), session.getId()); + MSession cSession = MSession.get (m_ctx, m_request.getRemoteAddr(), + m_request.getRemoteHost(), m_session.getId()); if (cSession != null) cSession.setWebStoreSession(true); } // if (passwordChange) - log.fine("- update Pwd " + email + ", Old=" + password + ", DB=" + wu.getPassword() + ", New=" + passwordNew); - if (WebUtil.updateFields(request, wu, passwordChange)) + log.fine("- update Pwd " + m_email + ", Old=" + m_password + ", DB=" + m_wu.getPassword() + ", New=" + passwordNew); + if (WebUtil.updateFields(m_request, m_wu, passwordChange)) { if (passwordChange) - session.setAttribute(WebSessionCtx.HDR_MESSAGE, "Password changed"); + m_session.setAttribute(WebSessionCtx.HDR_MESSAGE, "Password changed"); } else { - forward = getLogin_RelURL (); + m_forward = getLogin_RelURL (); log.warning(" - update not done"); } } else { - forward = getLogin_RelURL (); - session.setAttribute(WebSessionCtx.HDR_MESSAGE, "Email/Password not correct"); + m_forward = getLogin_RelURL (); + m_session.setAttribute(WebSessionCtx.HDR_MESSAGE, "Email/Password not correct"); log.warning(" - update not confirmed"); } } else // new { - log.fine("** new " + email + "/" + password); - wu.setEmail (email); - wu.setPassword (password); - if (WebUtil.updateFields (request, wu, true)) + log.fine("** new " + m_email + "/" + m_password); + m_wu.setEmail (m_email); + m_wu.setPassword (m_password); + if (WebUtil.updateFields (m_request, m_wu, true)) { - if (wu.login(password)) + if (m_wu.login(m_password)) { - session.setAttribute (WebInfo.NAME, new WebInfo (ctx, wu)); + m_session.setAttribute (WebInfo.NAME, new WebInfo (m_ctx, m_wu)); // Create / set session - MSession cSession = MSession.get (ctx, request.getRemoteAddr(), - request.getRemoteHost(), session.getId()); + MSession cSession = MSession.get (m_ctx, m_request.getRemoteAddr(), + m_request.getRemoteHost(), m_session.getId()); if (cSession != null) cSession.setWebStoreSession(true); + WebUtil.resendCode(m_request, m_wu); } else - forward = getLogin_RelURL (); + m_forward = getLogin_RelURL (); } else { - log.fine("- failed - " + wu.getSaveErrorMessage() + " - " + wu.getPasswordMessage()); - forward = getLogin_RelURL (); + log.fine("- failed - " + m_wu.getSaveErrorMessage() + " - " + m_wu.getPasswordMessage()); + m_forward = getLogin_RelURL (); } } // new - if (wu!=null) - session.setAttribute (WebInfo.NAME, new WebInfo (ctx, wu)); + if (m_wu!=null) + m_session.setAttribute (WebInfo.NAME, new WebInfo (m_ctx, m_wu)); } // Submit - else if("email".equals(mode)) + else if("email".equals(m_mode)) { - String email = WebUtil.getParameter (request, "EMail"); + String email = WebUtil.getParameter (m_request, "EMail"); if (email == null) email = ""; email = email.trim(); - String emailNew = WebUtil.getParameter (request, "EMailNew"); + String emailNew = WebUtil.getParameter (m_request, "EMailNew"); if (emailNew == null) emailNew = ""; @@ -335,36 +349,36 @@ public class WebLogin return false; } - wu.setEmail(emailNew); - wu.save(); - session.setAttribute(WebSessionCtx.HDR_MESSAGE, "EMail Address Changed"); - session.setAttribute(WebInfo.NAME, new WebInfo(ctx, wu)); + m_wu.setEmail(emailNew); + m_wu.save(); + m_session.setAttribute(WebSessionCtx.HDR_MESSAGE, "EMail Address Changed"); + m_session.setAttribute(WebInfo.NAME, new WebInfo(m_ctx, m_wu)); } - else if("password".equals(mode)) + else if("password".equals(m_mode)) { - if (wu == null) + if (m_wu == null) { log.warning("No web user"); return false; } - String password = WebUtil.getParameter (request, "Password"); + String password = WebUtil.getParameter (m_request, "Password"); if (password == null) password = ""; // null loads w/o check password = password.trim(); - if(!wu.login(password)) + if(!m_wu.login(password)) { setMessage("Email/Password not correct"); return false; } - MSession cSession = MSession.get (ctx, request.getRemoteAddr(), request.getRemoteHost(), session.getId()); + MSession cSession = MSession.get (m_ctx, m_request.getRemoteAddr(), m_request.getRemoteHost(), m_session.getId()); if (cSession != null) cSession.setWebStoreSession(true); - String passwordNew = WebUtil.getParameter (request, "PasswordNew"); + String passwordNew = WebUtil.getParameter (m_request, "PasswordNew"); if (passwordNew == null) passwordNew = ""; @@ -375,79 +389,81 @@ public class WebLogin return false; } - wu.setPasswordMessage(null); - wu.setPassword(passwordNew); - if(wu.getPasswordMessage() != null) + m_wu.setPasswordMessage(null); + m_wu.setPassword(passwordNew); + if(m_wu.getPasswordMessage() != null) { setMessage("New Password invalid."); return false; } - wu.save(); - session.setAttribute(WebSessionCtx.HDR_MESSAGE, "Password Changed"); - session.setAttribute(WebInfo.NAME, new WebInfo(ctx, wu)); + m_wu.save(); + if (m_forward==null || m_forward.equals(getLogin_RelURL ())) + m_forward = "/index.jsp"; + m_session.setAttribute(WebSessionCtx.HDR_MESSAGE, "Password Changed"); + m_session.setAttribute(WebInfo.NAME, new WebInfo(m_ctx, m_wu)); } - else if("address".equals(mode)) + else if("address".equals(m_mode)) { - wu.setC_Country_ID(WebUtil.getParamOrNull(request, "C_Country_ID")); - wu.setC_Region_ID(WebUtil.getParamOrNull(request, "C_Region_ID")); - wu.setRegionName(WebUtil.getParamOrNull(request, "RegionName")); - wu.setName(WebUtil.getParamOrNull(request, "Name")); - wu.setCompany(WebUtil.getParamOrNull(request, "Company")); - wu.setTitle(WebUtil.getParamOrNull(request, "Title")); - wu.setAddress(WebUtil.getParamOrNull(request, "Address")); - wu.setAddress2(WebUtil.getParamOrNull(request, "Address2")); - wu.setCity(WebUtil.getParamOrNull(request, "City")); - wu.setPostal(WebUtil.getParamOrNull(request, "Postal")); - wu.setPhone(WebUtil.getParamOrNull(request, "Phone")); - wu.setFax(WebUtil.getParamOrNull(request, "Fax")); - wu.save(); - session.setAttribute(WebSessionCtx.HDR_MESSAGE, "Contact Information Changed"); - session.setAttribute(WebInfo.NAME, new WebInfo(ctx, wu)); + m_wu.setC_Country_ID(WebUtil.getParamOrNull(m_request, "C_Country_ID")); + m_wu.setC_Region_ID(WebUtil.getParamOrNull(m_request, "C_Region_ID")); + m_wu.setRegionName(WebUtil.getParamOrNull(m_request, "RegionName")); + m_wu.setName(WebUtil.getParamOrNull(m_request, "Name")); + m_wu.setCompany(WebUtil.getParamOrNull(m_request, "Company")); + m_wu.setTitle(WebUtil.getParamOrNull(m_request, "Title")); + m_wu.setAddress(WebUtil.getParamOrNull(m_request, "Address")); + m_wu.setAddress2(WebUtil.getParamOrNull(m_request, "Address2")); + m_wu.setCity(WebUtil.getParamOrNull(m_request, "City")); + m_wu.setPostal(WebUtil.getParamOrNull(m_request, "Postal")); + m_wu.setPhone(WebUtil.getParamOrNull(m_request, "Phone")); + m_wu.setFax(WebUtil.getParamOrNull(m_request, "Fax")); + m_wu.save(); + m_session.setAttribute(WebSessionCtx.HDR_MESSAGE, "Contact Information Changed"); + m_session.setAttribute(WebInfo.NAME, new WebInfo(m_ctx, m_wu)); } - else if ("EMailVerify".equals(mode)) + else if ("EMailVerify".equals(m_mode)) { - if (wu == null) + if (m_wu == null) { log.warning("No web user"); return false; } - log.info(forward + " - " + wu.toString()); + log.info(m_forward + " - " + m_wu.toString()); - String cmd = WebUtil.getParameter(request, "ReSend"); + String cmd = WebUtil.getParameter(m_request, "ReSend"); if (cmd != null && cmd.length() > 1) - WebUtil.resendCode(request, wu); + WebUtil.resendCode(m_request, m_wu); else - wu.setEMailVerifyCode(WebUtil.getParameter(request, "VerifyCode"), request.getRemoteAddr()); + m_wu.setEMailVerifyCode(WebUtil.getParameter(m_request, "VerifyCode"), m_request.getRemoteAddr()); } - else if ("bankaccountach".equals(mode)) + else if ("bankaccountach".equals(m_mode)) { - if (wu == null) + if (m_wu == null) { log.warning("No web user"); return false; } - log.info(forward + " - " + wu.toString()); + log.info(m_forward + " - " + m_wu.toString()); - MBPBankAccount thisBPBankAccount = wu.getBankAccount (true); + MBPBankAccount thisBPBankAccount = m_wu.getBankAccount (true); // As this sets bankaccountach thisBPBankAccount.setIsACH (true); - thisBPBankAccount.setA_City (WebUtil.getParamOrNull (request, "A_City")); - thisBPBankAccount.setA_Name (WebUtil.getParamOrNull (request, "A_Name")); - thisBPBankAccount.setAccountNo (WebUtil.getParamOrNull (request, "AccountNo")); - thisBPBankAccount.setRoutingNo (WebUtil.getParamOrNull (request, "RoutingNo")); + thisBPBankAccount.setA_City (WebUtil.getParamOrNull (m_request, "A_City")); + thisBPBankAccount.setA_Name (WebUtil.getParamOrNull (m_request, "A_Name")); + thisBPBankAccount.setAccountNo (WebUtil.getParamOrNull (m_request, "AccountNo")); + thisBPBankAccount.setRoutingNo (WebUtil.getParamOrNull (m_request, "RoutingNo")); thisBPBankAccount.save (); } else - log.log(Level.WARNING, "Unknown request='" + mode + "'"); + log.log(Level.WARNING, "Unknown request='" + m_mode + "'"); return true; - } + } // action /** * setMessage to set a Message @@ -456,7 +472,7 @@ public class WebLogin public void setMessage(String newVal) { if (newVal!=null) - message = newVal; + m_message = newVal; } /** @@ -465,7 +481,7 @@ public class WebLogin */ public String getMessage() { - return message; + return m_message; } /** @@ -482,7 +498,8 @@ public class WebLogin * getP_ForwardTo * @return ForwardTo request parameter */ - public String getP_ForwardTo() { + public String getP_ForwardTo() + { return P_ForwardTo; } @@ -500,7 +517,8 @@ public class WebLogin * getP_EMail * @return EMail request parameter */ - public String getP_EMail() { + public String getP_EMail() + { return P_EMail; } @@ -518,7 +536,8 @@ public class WebLogin * getP_Password * @return Password request parameter */ - public String getP_Password() { + public String getP_Password() + { return P_Password; } @@ -536,7 +555,8 @@ public class WebLogin * getP_SalesRep_ID * @return SalesRep_ID request parameter */ - public String getP_SalesRep_ID() { + public String getP_SalesRep_ID() + { return P_SalesRep_ID; } @@ -554,7 +574,8 @@ public class WebLogin * getP_SalesRep_ID * @return SalesRep_ID request parameter */ - public String getP_Action() { + public String getP_Action() + { return P_Action; } @@ -565,15 +586,16 @@ public class WebLogin public void setLogin_RelURL(String newVal) { if (newVal!=null) - LOGIN_RelURL = newVal; + m_login_page = newVal; } /** * getLogin_RelURL * @return Login_RelURL request parameter */ - public String getLogin_RelURL() { - return LOGIN_RelURL; + public String getLogin_RelURL() + { + return m_login_page; } /** @@ -583,15 +605,16 @@ public class WebLogin public void setUpdate_page(String newVal) { if (newVal!=null) - update_page = newVal; + m_update_page = newVal; } /** * getLogin_RelURL * @return Login_RelURL request parameter */ - public String getUpdate_page() { - return update_page; + public String getUpdate_page() + { + return m_update_page; } /** @@ -601,23 +624,25 @@ public class WebLogin public void setForward(String newVal) { if (newVal!=null) - forward = newVal; + m_forward = newVal; } /** * getForward * @return URL to forward request on to */ - public String getForward() { - return forward; + public String getForward() + { + return m_forward; } /** * getSalesRep_ID * @return SalesRep_ID of the SalesRep_ID in the Request */ - public String getSalesRep_ID() { - return salesRep; + public String getSalesRep_ID() + { + return m_salesRep; } /** @@ -626,18 +651,30 @@ public class WebLogin */ public void setAddressConfirm(boolean newVal) { - addressConfirm = newVal; + m_addressConfirm = newVal; } /** * getAdressConfirm * @return boolean addressConfirm */ - public boolean getAddressConfirm() { - return addressConfirm; + public boolean getAddressConfirm() + { + return m_addressConfirm; } - public WebUser getWebUser() { - return wu; + public WebUser getWebUser() + { + return m_wu; + } + + public void setMode(String t_mode) + { + m_mode = t_mode; + } + + public String getMode() + { + return m_mode; } } \ No newline at end of file diff --git a/base/src/org/compiere/wf/MWFNodeNext.java b/base/src/org/compiere/wf/MWFNodeNext.java index cee1fda354..b0c74e8bc7 100644 --- a/base/src/org/compiere/wf/MWFNodeNext.java +++ b/base/src/org/compiere/wf/MWFNodeNext.java @@ -200,7 +200,7 @@ public class MWFNodeNext extends X_AD_WF_NodeNext // No Conditions if (getConditions(false).length == 0) { - log.fine("isValidFor #0 " + toString()); + log.fine("#0 " + toString()); return true; } // First condition always AND diff --git a/client/src/org/compiere/apps/AChat.java b/client/src/org/compiere/apps/AChat.java index c581db8590..f367909721 100644 --- a/client/src/org/compiere/apps/AChat.java +++ b/client/src/org/compiere/apps/AChat.java @@ -18,7 +18,6 @@ package org.compiere.apps; import java.awt.*; import java.awt.event.*; -import java.net.*; import java.util.logging.*; import javax.swing.*; import org.compiere.model.*; diff --git a/client/src/org/compiere/apps/AEnv.java b/client/src/org/compiere/apps/AEnv.java index 28d10ce188..7fb76eb071 100644 --- a/client/src/org/compiere/apps/AEnv.java +++ b/client/src/org/compiere/apps/AEnv.java @@ -229,7 +229,7 @@ public final class AEnv { JMenu menu = new JMenu(); String text = Msg.getMsg(Env.getCtx(), AD_Message); - int pos = text.indexOf("&"); + int pos = text.indexOf('&'); if (pos != -1 && text.length() > pos) // We have a nemonic { char ch = text.toUpperCase().charAt(pos+1); @@ -268,7 +268,7 @@ public final class AEnv if (al != null) mi.addActionListener(al); return mi; - } // addMeniItem + } // addMenuItem /** * Perform action command for common menu items. @@ -408,7 +408,7 @@ public final class AEnv /** * Set Text and Mnemonic for Button. - * Create Mnemonics of text containing "&". + * Create Mnemonics of text containing '&'. * Based on MS notation of &Help => H is Mnemonics * @param b The button * @param text The text with optional Mnemonics @@ -417,7 +417,7 @@ public final class AEnv { if (text == null || b == null) return; - int pos = text.indexOf("&"); + int pos = text.indexOf('&'); if (pos != -1) // We have a nemonic { char ch = text.charAt(pos+1); @@ -429,12 +429,12 @@ public final class AEnv /** * Get Mnemonic character from text. - * @param text text with "&" + * @param text text with '&' * @return Mnemonic or 0 */ public static char getMnemonic (String text) { - int pos = text.indexOf("&"); + int pos = text.indexOf('&'); if (pos != -1) // We have a nemonic return text.charAt(pos+1); return 0; diff --git a/client/src/org/compiere/apps/ALogin.java b/client/src/org/compiere/apps/ALogin.java index bcaa88a420..9c46f9e5c8 100644 --- a/client/src/org/compiere/apps/ALogin.java +++ b/client/src/org/compiere/apps/ALogin.java @@ -190,12 +190,14 @@ public final class ALogin extends CDialog versionLabel.setToolTipText(Adempiere.getImplementationVersion()); hostLabel.setHorizontalAlignment(SwingConstants.RIGHT); hostLabel.setText("Host"); + hostLabel.setLabelFor(hostField); connectionPanel.add(hostLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); connectionPanel.add(hostField, new GridBagConstraints(1, 2, 3, 1, 1.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0)); userLabel.setHorizontalAlignment(SwingConstants.RIGHT); userLabel.setText("User"); + userLabel.setLabelFor(userTextField); connectionPanel.add(userLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); userTextField.setText("System"); // default @@ -203,6 +205,7 @@ public final class ALogin extends CDialog ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0)); passwordLabel.setHorizontalAlignment(SwingConstants.RIGHT); passwordLabel.setText("Password"); + passwordLabel.setLabelFor(passwordField); connectionPanel.add(passwordLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); passwordField.setText("System"); // default @@ -210,6 +213,7 @@ public final class ALogin extends CDialog ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0)); languageLabel.setHorizontalAlignment(SwingConstants.RIGHT); languageLabel.setText("Language"); + languageLabel.setLabelFor(languageCombo); connectionPanel.add(languageLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); languageCombo.addActionListener(this); @@ -218,7 +222,7 @@ public final class ALogin extends CDialog copy0Label.setHorizontalAlignment(SwingConstants.RIGHT); connectionPanel.add(copy0Label, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - /** Removing/modifying the Adempiere copyright notice is a violation of the license */ + copy1Label.setText(Adempiere.COPYRIGHT); connectionPanel.add(copy1Label, new GridBagConstraints(1, 6, 2, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 12, 12), 0, 0)); @@ -236,6 +240,7 @@ public final class ALogin extends CDialog // roleLabel.setText("Role"); roleLabel.setHorizontalAlignment(SwingConstants.RIGHT); + roleLabel.setLabelFor(roleCombo); roleCombo.addActionListener(this); defaultPanel.add(roleLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); @@ -243,6 +248,7 @@ public final class ALogin extends CDialog ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0)); clientLabel.setText("Client"); clientLabel.setHorizontalAlignment(SwingConstants.RIGHT); + clientLabel.setLabelFor(clientCombo); defaultPanel.add(clientLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); clientCombo.addActionListener(this); @@ -250,6 +256,7 @@ public final class ALogin extends CDialog ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0)); orgLabel.setText("Organization"); orgLabel.setHorizontalAlignment(SwingConstants.RIGHT); + orgLabel.setLabelFor(orgCombo); defaultPanel.add(orgLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); orgCombo.addActionListener(this); @@ -257,6 +264,7 @@ public final class ALogin extends CDialog ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0)); dateLabel.setText("Date"); dateLabel.setHorizontalAlignment(SwingConstants.RIGHT); + dateLabel.setLabelFor(dateField); defaultPanel.add(dateLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); defaultPanel.add(dateField, new GridBagConstraints(1, 4, 1, 1, 1.0, 0.0 @@ -264,8 +272,10 @@ public final class ALogin extends CDialog // warehouseLabel.setText("Warehouse"); warehouseLabel.setHorizontalAlignment(SwingConstants.RIGHT); + warehouseLabel.setLabelFor(warehouseCombo); printerLabel.setText("Printer"); printerLabel.setHorizontalAlignment(SwingConstants.RIGHT); + printerLabel.setLabelFor(printerField); defaultPanel.add(printerLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 12, 5), 0, 0)); defaultPanel.add(printerField, new GridBagConstraints(1, 5, 1, 1, 1.0, 0.0 @@ -623,6 +633,7 @@ public final class ALogin extends CDialog userTextField.setBackground(AdempierePLAF.getFieldBackground_Normal()); passwordField.setBackground(AdempierePLAF.getFieldBackground_Normal()); // + this.setTitle(hostField.getDisplay()); statusBar.setStatusLine(txt_LoggedIn); m_comboActive = false; roleComboChanged(); @@ -859,9 +870,15 @@ public final class ALogin extends CDialog dateField.setValue(new Timestamp(System.currentTimeMillis())); // if (m_connectionOK) + { + this.setTitle(hostField.getDisplay()); statusBar.setStatusLine(txt_LoggedIn); + } else + { + this.setTitle(res.getString("Login")); statusBar.setStatusLine(txt_NotConnected, true); + } } // languageCombo_actionPerformed } // ALogin diff --git a/client/src/org/compiere/apps/AMenu.java b/client/src/org/compiere/apps/AMenu.java index 8fd1e16cc4..f05085d3ed 100644 --- a/client/src/org/compiere/apps/AMenu.java +++ b/client/src/org/compiere/apps/AMenu.java @@ -61,7 +61,8 @@ public final class AMenu extends CFrame splash.paint(splash.getGraphics()); // - Adempiere.startupEnvironment(true); // Load Environment + if (!Adempiere.startupEnvironment(true)) // Load Environment + System.exit(1); MSession.get (Env.getCtx(), true); // Start Session // Preparation diff --git a/client/src/org/compiere/apps/AMenuStartItem.java b/client/src/org/compiere/apps/AMenuStartItem.java index 2ffa0582f1..7963d63d87 100644 --- a/client/src/org/compiere/apps/AMenuStartItem.java +++ b/client/src/org/compiere/apps/AMenuStartItem.java @@ -96,10 +96,12 @@ public class AMenuStartItem extends Thread implements ActionListener m_menu.progressBar.setValue(m_value); } }; - private int m_value = 0; - private int m_increment = 20; - private javax.swing.Timer m_timer = new javax.swing.Timer(500, this); // every 1/2 second - + /** Value */ + int m_value = 0; + /** Increment */ + int m_increment = 20; + /** Timer */ + private Timer m_timer = new Timer(500, this); // every 1/2 second /** * Start Menu Item diff --git a/client/src/org/compiere/apps/APanel.java b/client/src/org/compiere/apps/APanel.java index 9df18bddfd..2d897f9606 100644 --- a/client/src/org/compiere/apps/APanel.java +++ b/client/src/org/compiere/apps/APanel.java @@ -715,6 +715,7 @@ public final class APanel extends CPanel mTab.getAD_Table_ID(), mTab.getTableName(), where.toString(), findFields, 10); // no query below 10 query = find.getQuery(); + find.dispose(); find = null; } return query; @@ -1767,6 +1768,7 @@ public final class APanel extends CPanel m_curTab.getAD_Table_ID(), m_curTab.getTableName(), m_curTab.getWhereExtended(), findFields, 1); MQuery query = find.getQuery(); + find.dispose(); find = null; // Confirmed query @@ -2077,8 +2079,9 @@ public final class APanel extends CPanel { if (ADialog.ask(m_curWindowNo, this, "PostImmediate?")) { + boolean force = ps != null && !ps.equals ("N"); // force when problems String error = AEnv.postImmediate (m_curWindowNo, Env.getAD_Client_ID(m_ctx), - m_curTab.getAD_Table_ID(), m_curTab.getRecord_ID(), false); + m_curTab.getAD_Table_ID(), m_curTab.getRecord_ID(), force); m_curTab.dataRefresh(); if (error != null) ADialog.error(m_curWindowNo, this, "PostingError-N", error); diff --git a/client/src/org/compiere/apps/AppsAction.java b/client/src/org/compiere/apps/AppsAction.java index a808a97078..df3eb2398d 100644 --- a/client/src/org/compiere/apps/AppsAction.java +++ b/client/src/org/compiere/apps/AppsAction.java @@ -74,7 +74,7 @@ public final class AppsAction extends AbstractAction // Data if (toolTipText == null) toolTipText = Msg.getMsg(Env.getCtx(), action); - int pos = toolTipText.indexOf("&"); + int pos = toolTipText.indexOf('&'); if (pos != -1 && toolTipText.length() > pos) // We have a nemonic - creates ALT-_ { Character ch = new Character(toolTipText.toUpperCase().charAt(pos+1)); @@ -222,9 +222,12 @@ public final class AppsAction extends AbstractAction m_pressed = pressed; // Set Button - m_button.setSelected(pressed); + if (m_button != null) + m_button.setSelected(pressed); + // Set Menu - m_menu.setSelected(pressed); + if (m_menu != null) + m_menu.setSelected(pressed); } // setPressed /** diff --git a/client/src/org/compiere/apps/ProcessCtl.java b/client/src/org/compiere/apps/ProcessCtl.java index 664ea1fefd..4d60a6c332 100644 --- a/client/src/org/compiere/apps/ProcessCtl.java +++ b/client/src/org/compiere/apps/ProcessCtl.java @@ -66,7 +66,25 @@ public class ProcessCtl extends Thread { log.fine("WindowNo=" + WindowNo + " - " + pi); - MPInstance instance = new MPInstance(Env.getCtx(), pi.getAD_Process_ID(), pi.getRecord_ID()); + MPInstance instance = null; + try + { + instance = new MPInstance(Env.getCtx(), pi.getAD_Process_ID(), pi.getRecord_ID()); + } + catch (Exception e) + { + pi.setSummary (e.getLocalizedMessage()); + pi.setError (true); + log.warning(pi.toString()); + return null; + } + catch (Error e) + { + pi.setSummary (e.getLocalizedMessage()); + pi.setError (true); + log.warning(pi.toString()); + return null; + } if (!instance.save()) { pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessNoInstance")); @@ -117,7 +135,25 @@ public class ProcessCtl extends Thread { log.fine("WindowNo=" + WindowNo + " - " + pi); - MPInstance instance = new MPInstance(Env.getCtx(), pi.getAD_Process_ID(), pi.getRecord_ID()); + MPInstance instance = null; + try + { + instance = new MPInstance(Env.getCtx(), pi.getAD_Process_ID(), pi.getRecord_ID()); + } + catch (Exception e) + { + pi.setSummary (e.getLocalizedMessage()); + pi.setError (true); + log.warning(pi.toString()); + return null; + } + catch (Error e) + { + pi.setSummary (e.getLocalizedMessage()); + pi.setError (true); + log.warning(pi.toString()); + return null; + } if (!instance.save()) { pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessNoInstance")); @@ -156,8 +192,10 @@ public class ProcessCtl extends Thread m_trx = trx; // handeled correctly } // ProcessCtl - private ASyncProcess m_parent; - private ProcessInfo m_pi; + /** Parenr */ + ASyncProcess m_parent; + /** Process Info */ + ProcessInfo m_pi; private Trx m_trx; private Waiting m_waiting; private boolean m_IsServerProcess = false; diff --git a/client/src/org/compiere/apps/RecordInfo.java b/client/src/org/compiere/apps/RecordInfo.java index cfe1802024..0eea1b4c2d 100644 --- a/client/src/org/compiere/apps/RecordInfo.java +++ b/client/src/org/compiere/apps/RecordInfo.java @@ -153,8 +153,8 @@ public class RecordInfo extends CDialog // Title if (dse.AD_Table_ID != 0) { - MTable table = MTable.get (Env.getCtx(), dse.AD_Table_ID); - setTitle(title + " - " + table.getName()); + MTable table1 = MTable.get (Env.getCtx(), dse.AD_Table_ID); + setTitle(title + " - " + table1.getName()); } // Only Client Preference can view Change Log diff --git a/client/src/org/compiere/apps/form/VAllocation.java b/client/src/org/compiere/apps/form/VAllocation.java index 579d99c717..c5ef22cae4 100644 --- a/client/src/org/compiere/apps/form/VAllocation.java +++ b/client/src/org/compiere/apps/form/VAllocation.java @@ -350,7 +350,7 @@ public class VAllocation extends CPanel Vector columnNames = new Vector(); columnNames.add(Msg.getMsg(Env.getCtx(), "Select")); columnNames.add(Msg.translate(Env.getCtx(), "Date")); - columnNames.add(Msg.translate(Env.getCtx(), "DocumentNo")); + columnNames.add(Util.cleanAmp(Msg.translate(Env.getCtx(), "DocumentNo"))); if (multiCurrency.isSelected()) { columnNames.add(Msg.getMsg(Env.getCtx(), "TrxCurrency")); @@ -472,7 +472,7 @@ public class VAllocation extends CPanel columnNames = new Vector(); columnNames.add(Msg.getMsg(Env.getCtx(), "Select")); columnNames.add(Msg.translate(Env.getCtx(), "Date")); - columnNames.add(Msg.translate(Env.getCtx(), "DocumentNo")); + columnNames.add(Util.cleanAmp(Msg.translate(Env.getCtx(), "DocumentNo"))); if (multiCurrency.isSelected()) { columnNames.add(Msg.getMsg(Env.getCtx(), "TrxCurrency")); diff --git a/client/src/org/compiere/apps/wf/WFContentPanel.java b/client/src/org/compiere/apps/wf/WFContentPanel.java index 970131a1cf..2a658b7597 100644 --- a/client/src/org/compiere/apps/wf/WFContentPanel.java +++ b/client/src/org/compiere/apps/wf/WFContentPanel.java @@ -467,8 +467,9 @@ public class WFContentPanel extends CPanel if (e.getSource()== m_NewMenuNode) { log.info("Create New Node"); + String nameLabel = Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Name")); String name = JOptionPane.showInputDialog(this, - Msg.getMsg(Env.getCtx(), "Name"), // message + nameLabel, // message Msg.getMsg(Env.getCtx(), "CreateNewNode"), // title JOptionPane.QUESTION_MESSAGE); if (name != null && name.length() > 0) diff --git a/client/src/org/compiere/grid/ed/Calendar.java b/client/src/org/compiere/grid/ed/Calendar.java index 94bf0f15a2..860df89f01 100644 --- a/client/src/org/compiere/grid/ed/Calendar.java +++ b/client/src/org/compiere/grid/ed/Calendar.java @@ -425,7 +425,7 @@ public class Calendar extends CDialog } // Set Hour - boolean pm = m_current24Hour > 12; + boolean pm = m_current24Hour > 11; int index = m_current24Hour; if (pm && m_hasAM_PM) index -= 12; diff --git a/client/src/org/compiere/grid/ed/MDocNumber.java b/client/src/org/compiere/grid/ed/MDocNumber.java index bcffdb8557..4a41b0a7b8 100644 --- a/client/src/org/compiere/grid/ed/MDocNumber.java +++ b/client/src/org/compiere/grid/ed/MDocNumber.java @@ -201,17 +201,16 @@ public final class MDocNumber extends PlainDocument } // decimal or thousand // something else - else + else if (VNumber.AUTO_POPUP) { log.fine("Input=" + c + " (" + (int)c + ")"); - //hengsin, [ 1648436 ] Remove auto popup of calculator - /* String result = VNumber.startCalculator(m_tc, getText(), m_format, m_displayType, m_title); super.remove(0, content.length()); - super.insertString(0, result, attr);*/ - ADialog.beep(); + super.insertString(0, result, attr); } + else + ADialog.beep(); } // insertString diff --git a/client/src/org/compiere/grid/ed/VAccount.java b/client/src/org/compiere/grid/ed/VAccount.java index 666fdf8a24..99b3e47116 100644 --- a/client/src/org/compiere/grid/ed/VAccount.java +++ b/client/src/org/compiere/grid/ed/VAccount.java @@ -360,5 +360,15 @@ public final class VAccount extends JComponent m_WindowNo = mField.getWindowNo(); } // setField -} // VAccount - + /** + * String Representation + * @return info + */ + public String toString() + { + StringBuffer sb = new StringBuffer ("VAccount["); + sb.append (m_value).append ("]"); + return sb.toString (); + } // toString + +} // VAccount \ No newline at end of file diff --git a/client/src/org/compiere/grid/ed/VAccountDialog.java b/client/src/org/compiere/grid/ed/VAccountDialog.java index fb6314db16..5a320a1231 100644 --- a/client/src/org/compiere/grid/ed/VAccountDialog.java +++ b/client/src/org/compiere/grid/ed/VAccountDialog.java @@ -992,7 +992,8 @@ public final class VAccountDialog extends CDialog f_AD_Org_ID.setValue(null); // Account (mandatory) f_Account_ID.setValue(null); - f_SubAcct_ID.setValue(null); + if (f_SubAcct_ID != null) + f_SubAcct_ID.setValue(null); // Product if (f_M_Product_ID != null) diff --git a/client/src/org/compiere/grid/ed/VBinary.java b/client/src/org/compiere/grid/ed/VBinary.java index 6d8f2c5bf4..94bcb45222 100644 --- a/client/src/org/compiere/grid/ed/VBinary.java +++ b/client/src/org/compiere/grid/ed/VBinary.java @@ -22,7 +22,6 @@ import java.beans.*; import java.io.*; import java.util.logging.*; import javax.swing.*; -import org.compiere.model.*; import org.compiere.util.*; /** diff --git a/client/src/org/compiere/grid/ed/VCellEditor.java b/client/src/org/compiere/grid/ed/VCellEditor.java index 28f01f03fc..806b8cee71 100644 --- a/client/src/org/compiere/grid/ed/VCellEditor.java +++ b/client/src/org/compiere/grid/ed/VCellEditor.java @@ -62,7 +62,7 @@ public final class VCellEditor extends AbstractCellEditor /** Table */ private JTable m_table = null; /** ClickCount */ - private static int CLICK_TO_START = 2; + private static int CLICK_TO_START = 1; /** Logger */ private static CLogger log = CLogger.getCLogger(VCellEditor.class); diff --git a/client/src/org/compiere/grid/ed/VCellRenderer.java b/client/src/org/compiere/grid/ed/VCellRenderer.java index 4f8b09e176..75c0989c28 100644 --- a/client/src/org/compiere/grid/ed/VCellRenderer.java +++ b/client/src/org/compiere/grid/ed/VCellRenderer.java @@ -28,8 +28,6 @@ import org.compiere.plaf.*; import java.util.logging.*; import org.compiere.util.*; -import sun.security.krb5.internal.*; - /** * Table Cell Renderer based on DisplayType * @@ -122,7 +120,11 @@ public final class VCellRenderer extends DefaultTableCellRenderer // Inactive Background boolean ro = !table.isCellEditable(row, col); if (ro) + { bg = AdempierePLAF.getFieldBackground_Inactive(); + if (isSelected && !hasFocus) + bg = bg.darker(); + } // Foreground int cCode = 0; diff --git a/client/src/org/compiere/grid/ed/VComboBox.java b/client/src/org/compiere/grid/ed/VComboBox.java index 135ff6bbb3..263aa8d458 100644 --- a/client/src/org/compiere/grid/ed/VComboBox.java +++ b/client/src/org/compiere/grid/ed/VComboBox.java @@ -155,5 +155,5 @@ public class VComboBox extends CComboBox return ""; return p.getName(); } // getDisplay - + } // VComboBox diff --git a/client/src/org/compiere/grid/ed/VHeaderRenderer.java b/client/src/org/compiere/grid/ed/VHeaderRenderer.java index 9ef1b06065..b34a8debc0 100644 --- a/client/src/org/compiere/grid/ed/VHeaderRenderer.java +++ b/client/src/org/compiere/grid/ed/VHeaderRenderer.java @@ -73,7 +73,7 @@ public final class VHeaderRenderer implements TableCellRenderer { // Log.trace(this,10, "VHeaderRenderer.getTableCellRendererComponent", value==null ? "null" : value.toString()); // indicator for invisible column - + m_button.setFont(table.getFont()); Icon icon = null; if (table instanceof CTable) { diff --git a/client/src/org/compiere/grid/ed/VNumber.java b/client/src/org/compiere/grid/ed/VNumber.java index d3c01b9158..101f4908e8 100644 --- a/client/src/org/compiere/grid/ed/VNumber.java +++ b/client/src/org/compiere/grid/ed/VNumber.java @@ -40,7 +40,8 @@ public final class VNumber extends JComponent { /** Number of Columns (12) */ public final static int SIZE = 12; - + /** Automatically pop up calculator */ + public final static boolean AUTO_POPUP = false; /** * IDE Bean Constructor */ @@ -143,6 +144,14 @@ public final class VNumber extends JComponent /** Logger */ private static CLogger log = CLogger.getCLogger(VNumber.class); + /** + * Select all the number text. + */ + public void selectAll() + { + m_text.selectAll(); + } + /** * Set no of Columns * @param columns columns @@ -531,12 +540,48 @@ public final class VNumber extends JComponent m_text.setText(m_initialText); return; } + Object oo = getValue(); + if (m_rangeSet) + { + String error = ""; + if (oo instanceof Integer) + { + Integer ii = (Integer)oo; + if (ii < m_minValue) + { + error = oo + " < " + m_minValue; + oo = new Integer(m_minValue.intValue()); + } + else if (ii > m_maxValue) + { + error = oo + " > " + m_maxValue; + oo = new Integer(m_maxValue.intValue()); + } + } + else if (oo instanceof BigDecimal) + { + BigDecimal bd = (BigDecimal)oo; + if (bd.doubleValue() < m_minValue) + { + error = oo + " < " + m_minValue; + oo = new BigDecimal(m_minValue); + } + else if (bd.doubleValue() > m_maxValue) + { + error = oo + " > " + m_maxValue; + oo = new BigDecimal(m_maxValue); + } + } + if (error != null) + log.warning(error); + } try { - fireVetoableChange (m_columnName, m_initialText, getValue()); + fireVetoableChange (m_columnName, m_initialText, oo); fireActionPerformed(); } - catch (PropertyVetoException pve) {} + catch (PropertyVetoException pve) + {} } // focusLost /** diff --git a/client/src/org/compiere/grid/ed/ValuePreference.java b/client/src/org/compiere/grid/ed/ValuePreference.java index 938737b115..01fb8e0f50 100644 --- a/client/src/org/compiere/grid/ed/ValuePreference.java +++ b/client/src/org/compiere/grid/ed/ValuePreference.java @@ -171,7 +171,6 @@ public class ValuePreference extends CDialog m_Value = Value; m_DisplayValue = DisplayValue; m_DisplayType = displayType; - m_AD_Reference_ID = AD_Reference_ID; // m_role = MRole.getDefault(); try @@ -197,7 +196,6 @@ public class ValuePreference extends CDialog private String m_Value; private String m_DisplayValue; private int m_DisplayType; - private int m_AD_Reference_ID; private MRole m_role; // Display diff --git a/client/src/org/compiere/grid/tree/VTreePanel.java b/client/src/org/compiere/grid/tree/VTreePanel.java index f758f7beba..81bbea88f8 100644 --- a/client/src/org/compiere/grid/tree/VTreePanel.java +++ b/client/src/org/compiere/grid/tree/VTreePanel.java @@ -477,6 +477,7 @@ public final class VTreePanel extends CPanel //Statement stmt = trx.getConnection().createStatement(); //end vpj-cd e-evolution 07/12/2005 PostgreSQL // START TRANSACTION ************** + int no = 0; for (int i = 0; i < oldParent.getChildCount(); i++) { MTreeNode nd = (MTreeNode)oldParent.getChildAt(i); @@ -488,10 +489,10 @@ public final class VTreePanel extends CPanel .append(" WHERE AD_Tree_ID=").append(m_AD_Tree_ID) .append(" AND Node_ID=").append(nd.getNode_ID()); log.fine(sql.toString()); - //begin vpj-cd e-evolution 07/12/2005 PostgreSQL + //begin vpj-cd e-evolution 07/12/2005 PostgreSQL //stmt.executeUpdate(sql.toString()); - DB.executeUpdate(sql.toString(),trx.getTrxName()); - //end vpj-cd e-evolution 07/12/2005 PostgreSQL + no = DB.executeUpdate(sql.toString(),trx.getTrxName()); + //end vpj-cd e-evolution 07/12/2005 PostgreSQL } if (oldParent != newParent) for (int i = 0; i < newParent.getChildCount(); i++) @@ -507,8 +508,8 @@ public final class VTreePanel extends CPanel log.fine(sql.toString()); //begin vpj-cd e-evolution 07/12/2005 PostgreSQL //stmt.executeUpdate(sql.toString()); - DB.executeUpdate(sql.toString(),trx.getTrxName()); - //end vpj-cd e-evolution 07/12/2005 PostgreSQL + no = DB.executeUpdate(sql.toString(),trx.getTrxName()); + //end vpj-cd e-evolution 07/12/2005 PostgreSQL } // COMMIT ********************* trx.commit(true); diff --git a/client/src/org/compiere/print/Viewer.java b/client/src/org/compiere/print/Viewer.java index 2b4db5fa04..d8dfea9f2b 100644 --- a/client/src/org/compiere/print/Viewer.java +++ b/client/src/org/compiere/print/Viewer.java @@ -905,7 +905,7 @@ public class Viewer extends CFrame + "FROM AD_Tab t" + " INNER JOIN AD_Window w ON (t.AD_Window_ID=w.AD_Window_ID)" + " INNER JOIN AD_Table tt ON (t.AD_Table_ID=tt.AD_Table_ID) " - + "WHERE t.AD_Table_ID=? " + + "WHERE tt.AD_Table_ID=? " + "ORDER BY w.IsDefault DESC, t.SeqNo, ABS (tt.AD_Window_ID-t.AD_Window_ID)"; int AD_Tab_ID = DB.getSQLValue(null, sql, AD_Table_ID); // @@ -944,6 +944,8 @@ public class Viewer extends CFrame Find find = new Find (this, m_WindowNo, title, AD_Table_ID, tableName, "", findFields, 1); m_reportEngine.setQuery(find.getQuery()); + find.dispose(); + find = null; revalidate(); } cmd_drill(); // setCursor diff --git a/dbPort/src/org/compiere/Adempiere.java b/dbPort/src/org/compiere/Adempiere.java index 6377301df3..569c071c8a 100644 --- a/dbPort/src/org/compiere/Adempiere.java +++ b/dbPort/src/org/compiere/Adempiere.java @@ -22,6 +22,7 @@ import java.net.*; import java.util.logging.*; import javax.jnlp.*; import javax.swing.*; + import org.adempiere.plaf.AdempierePLAF; import org.compiere.db.*; import org.compiere.model.*; @@ -483,13 +484,16 @@ public final class Adempiere if (!DB.isConnected()) { log.severe ("No Database"); - System.exit(1); + return false; } + MSystem system = MSystem.get(Env.getCtx()); // Initializes Base Context too + if (system == null) + return false; + // Initialize main cached Singletons ModelValidationEngine.get(); try { - MSystem system = MSystem.get(Env.getCtx()); // Initializes Base Context too String className = system.getEncryptionKey(); if (className == null || className.length() == 0) { diff --git a/dbPort/src/org/compiere/db/CConnection.java b/dbPort/src/org/compiere/db/CConnection.java index 53b04898fc..0b256bddfe 100644 --- a/dbPort/src/org/compiere/db/CConnection.java +++ b/dbPort/src/org/compiere/db/CConnection.java @@ -22,6 +22,8 @@ import java.util.*; import java.util.logging.*; import javax.naming.*; import javax.sql.*; +import javax.swing.JOptionPane; + import org.compiere.*; import org.compiere.interfaces.*; import org.compiere.util.*; @@ -1241,6 +1243,22 @@ public class CConnection implements Serializable break; } } + if (m_db != null) // test class loader ability + m_db.getDataSource(this); + } + catch (NoClassDefFoundError ee) + { + System.err.println("Environment Error - Check Adempiere.properties - " + ee); + if (Ini.isClient()) + { + if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog + (null, "There is a configuration error:\n" + ee + + "\nDo you want to reset the saved configuration?", + "Adempiere Configuration Error", + JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE)) + Ini.deletePropertyFile(); + } + System.exit (1); } catch (Exception e) { diff --git a/dbPort/src/org/compiere/db/DB_Oracle.java b/dbPort/src/org/compiere/db/DB_Oracle.java index 8136316c41..03f8f264f0 100644 --- a/dbPort/src/org/compiere/db/DB_Oracle.java +++ b/dbPort/src/org/compiere/db/DB_Oracle.java @@ -95,6 +95,30 @@ public class DB_Oracle implements AdempiereDatabase, OracleConnectionCacheCallba /** Logger */ private static CLogger log = CLogger.getCLogger (DB_Oracle.class); + + /** + * Check if a connect is valid + * conn Connection + * @return true if connection is valid + */ + public boolean isConnectionValid(Connection conn) + { + try + { + if (((OracleConnection)conn).pingDatabase(1) < 0) + { + return false; + } + else + return true; + } + catch (SQLException e) + { + return false; + } + } + + /** * Get Database Name * @return database short name @@ -466,7 +490,20 @@ public class DB_Oracle implements AdempiereDatabase, OracleConnectionCacheCallba { if (number == null) return "NULL"; - return number.toString(); + BigDecimal result = number; + int scale = DisplayType.getDefaultPrecision(displayType); + if (scale > number.scale()) + { + try + { + result = number.setScale(scale, BigDecimal.ROUND_HALF_UP); + } + catch (Exception e) + { + // log.severe("Number=" + number + ", Scale=" + " - " + e.getMessage()); + } + } + return result.toString(); } // TO_NUMBER diff --git a/dbPort/src/org/compiere/model/MClientShare.java b/dbPort/src/org/compiere/model/MClientShare.java index 02fb39ddfb..88ac05f4cf 100644 --- a/dbPort/src/org/compiere/model/MClientShare.java +++ b/dbPort/src/org/compiere/model/MClientShare.java @@ -234,7 +234,7 @@ public class MClientShare extends X_AD_ClientShare StringBuffer info = new StringBuffer(); String sql = "SELECT AD_Table_ID, TableName " + "FROM AD_Table t " - + "WHERE AccessLevel=3 AND IsView='N'" + + "WHERE AccessLevel='3' AND IsView='N'" + " AND EXISTS (SELECT * FROM AD_Column c " + "WHERE t.AD_Table_ID=c.AD_Table_ID" + " AND c.IsParent='Y'" diff --git a/dbPort/src/org/compiere/model/MColumn.java b/dbPort/src/org/compiere/model/MColumn.java index d942f68376..b14242d3a9 100644 --- a/dbPort/src/org/compiere/model/MColumn.java +++ b/dbPort/src/org/compiere/model/MColumn.java @@ -29,10 +29,10 @@ import org.compiere.util.*; public class MColumn extends X_AD_Column { /** - * Get M_Column from Cache + * Get MColumn from Cache * @param ctx context * @param AD_Column_ID id - * @return M_Column + * @return MColumn */ public static MColumn get (Properties ctx, int AD_Column_ID) { @@ -91,7 +91,7 @@ public class MColumn extends X_AD_Column setIsUpdateable (true); // Y setVersion (Env.ZERO); } - } // M_Column + } // MColumn /** * Load Constructor @@ -102,7 +102,7 @@ public class MColumn extends X_AD_Column public MColumn (Properties ctx, ResultSet rs, String trxName) { super(ctx, rs, trxName); - } // M_Column + } // MColumn /** * Parent Constructor @@ -114,7 +114,7 @@ public class MColumn extends X_AD_Column setClientOrg(parent); setAD_Table_ID (parent.getAD_Table_ID()); setEntityType(parent.getEntityType()); - } // M_Column + } // MColumn /** @@ -170,12 +170,26 @@ public class MColumn extends X_AD_Column */ protected boolean beforeSave (boolean newRecord) { - if (getFieldLength() == 0 // LOB can be 0 - && !DisplayType.isLOB(getAD_Reference_ID())) + int displayType = getAD_Reference_ID(); + if (DisplayType.isLOB(displayType)) // LOBs are 0 + { + if (getFieldLength() != 0) + setFieldLength(0); + } + else if (getFieldLength() == 0) + { + if (DisplayType.isID(displayType)) + setFieldLength(10); + else if (DisplayType.isNumeric (displayType)) + setFieldLength(14); + else if (DisplayType.isDate (displayType)) + setFieldLength(7); + else { log.saveError("FillMandatory", Msg.getElement(getCtx(), "FieldLength")); return false; } + } /** Views are not updateable UPDATE AD_Column c @@ -211,6 +225,17 @@ public class MColumn extends X_AD_Column setIsEncrypted(false); } } + + // Sync Terminology + if ((newRecord || is_ValueChanged ("AD_Element_ID")) + && getAD_Element_ID() != 0) + { + M_Element element = new M_Element (getCtx(), getAD_Element_ID (), get_TrxName()); + setColumnName (element.getColumnName()); + setName (element.getName()); + setDescription (element.getDescription()); + setHelp (element.getHelp()); + } return true; } // beforeSave @@ -407,4 +432,15 @@ public class MColumn extends X_AD_Column return ""; } // getConstraint -} // M_Column + /** + * String Representation + * @return info + */ + public String toString() + { + StringBuffer sb = new StringBuffer ("MColumn["); + sb.append (get_ID()).append ("-").append (getColumnName()).append ("]"); + return sb.toString (); + } // toString + +} // MColumn diff --git a/dbPort/src/org/compiere/model/MField.java b/dbPort/src/org/compiere/model/MField.java index 43d05d1db4..7050beed0d 100644 --- a/dbPort/src/org/compiere/model/MField.java +++ b/dbPort/src/org/compiere/model/MField.java @@ -105,4 +105,26 @@ public class MField extends X_AD_Field setEntityType(column.getEntityType()); } // setColumn + /** + * beforeSave + * @see org.compiere.model.PO#beforeSave(boolean) + * @param newRecord + * @return + */ + @Override + protected boolean beforeSave(boolean newRecord) + { + // Sync Terminology + if ((newRecord || is_ValueChanged("AD_Column_ID")) + && isCentrallyMaintained()) + { + M_Element element = M_Element.getOfColumn(getCtx(), getAD_Column_ID()); + setName (element.getName ()); + setDescription (element.getDescription ()); + setHelp (element.getHelp()); + } + + return true; + } // beforeSave + } // MField diff --git a/dbPort/src/org/compiere/model/MIssue.java b/dbPort/src/org/compiere/model/MIssue.java index 60019220bc..0b288f42bb 100644 --- a/dbPort/src/org/compiere/model/MIssue.java +++ b/dbPort/src/org/compiere/model/MIssue.java @@ -43,6 +43,7 @@ public class MIssue extends X_AD_Issue s_log.config(record.getMessage()); MSystem system = MSystem.get(Env.getCtx()); if (!DB.isConnected() + || system == null || !system.isAutoErrorReport()) return null; // diff --git a/dbPort/src/org/compiere/model/MLanguage.java b/dbPort/src/org/compiere/model/MLanguage.java index 917f22b6aa..90fd4a43a9 100644 --- a/dbPort/src/org/compiere/model/MLanguage.java +++ b/dbPort/src/org/compiere/model/MLanguage.java @@ -309,6 +309,19 @@ public class MLanguage extends X_AD_Language return m_dateFormat; } // getDateFormat + /** + * Set AD_Language_ID + */ + private void setAD_Language_ID() + { + int AD_Language_ID = getAD_Language_ID(); + if (AD_Language_ID == 0) + { + String sql = "SELECT NVL(MAX(AD_Language_ID), 999999) FROM AD_Language WHERE AD_Language_ID > 1000"; + AD_Language_ID = DB.getSQLValue (get_TrxName(), sql); + setAD_Language_ID(AD_Language_ID+1); + } + } // setAD_Language_ID /** * Before Save @@ -317,9 +330,9 @@ public class MLanguage extends X_AD_Language */ protected boolean beforeSave (boolean newRecord) { - if (is_ValueChanged("DatePattern") && getDatePattern() != null) + String dp = getDatePattern(); + if (is_ValueChanged("DatePattern") && dp != null && dp.length() > 0) { - String dp = getDatePattern(); if (dp.indexOf("MM") == -1) { log.saveError("Error", Msg.parseTranslation(getCtx(), "@Error@ @DatePattern@ - No Month (MM)")); @@ -349,6 +362,8 @@ public class MLanguage extends X_AD_Language return false; } } + if (newRecord) + setAD_Language_ID(); return true; } // beforeSae diff --git a/dbPort/src/org/compiere/model/MLookup.java b/dbPort/src/org/compiere/model/MLookup.java index de6778816e..0e23f45876 100644 --- a/dbPort/src/org/compiere/model/MLookup.java +++ b/dbPort/src/org/compiere/model/MLookup.java @@ -77,7 +77,7 @@ public final class MLookup extends Lookup implements Serializable /** Inactive Marker End */ public static final String INACTIVE_E = "~"; /** Number of max rows to load */ - private static final int MAX_ROWS = 1000; // i.e. Drop Down has max 500 items + private static final int MAX_ROWS = 10000; /** Indicator for Null */ private static Integer MINUS_ONE = new Integer(-1); diff --git a/dbPort/src/org/compiere/model/MLookupInfo.java b/dbPort/src/org/compiere/model/MLookupInfo.java index dd8331934c..291d25606d 100644 --- a/dbPort/src/org/compiere/model/MLookupInfo.java +++ b/dbPort/src/org/compiere/model/MLookupInfo.java @@ -31,6 +31,92 @@ import org.compiere.util.*; public class MLookupInfo implements Serializable, Cloneable { /** + * Get first AD_Reference_ID of a matching Reference Name. + * Can have SQL LIKE placeholders. + * (This is more a development tool than used for production) + * @param referenceName reference name + * @return AD_Reference_ID + */ + public static int getAD_Reference_ID (String referenceName) + { + int retValue = 0; + String sql = "SELECT AD_Reference_ID,Name,ValidationType,IsActive " + + "FROM AD_Reference WHERE Name LIKE ?"; + try + { + PreparedStatement pstmt = DB.prepareStatement(sql, null); + pstmt.setString(1, referenceName); + ResultSet rs = pstmt.executeQuery(); + // + int i = 0; + int id = 0; + String refName = ""; + String validationType = ""; + boolean isActive = false; + while (rs.next()) + { + id = rs.getInt(1); + if (i == 0) + retValue = id; + refName = rs.getString(2); + validationType = rs.getString(3); + isActive = rs.getString(4).equals("Y"); + CLogger.get().config("AD_Reference Name=" + refName + ", ID=" + id + ", Type=" + validationType + ", Active=" + isActive); + } + rs.close(); + pstmt.close(); + } + catch (SQLException e) + { + CLogger.get().log(Level.SEVERE, sql, e); + } + return retValue; + } // getAD_Reference_ID + + /** + * Get first AD_Column_ID of matching ColumnName. + * Can have SQL LIKE placeholders. + * (This is more a development tool than used for production) + * @param columnName column name + * @return AD_Column_ID + */ + public static int getAD_Column_ID (String columnName) + { + int retValue = 0; + String sql = "SELECT c.AD_Column_ID,c.ColumnName,t.TableName " + + "FROM AD_Column c, AD_Table t " + + "WHERE c.ColumnName LIKE ? AND c.AD_Table_ID=t.AD_Table_ID"; + try + { + PreparedStatement pstmt = DB.prepareStatement(sql, null); + pstmt.setString(1, columnName); + ResultSet rs = pstmt.executeQuery(); + // + int i = 0; + int id = 0; + String colName = ""; + String tabName = ""; + while (rs.next()) + { + id = rs.getInt(1); + if (i == 0) + retValue = id; + colName = rs.getString(2); + tabName = rs.getString(3); + CLogger.get().config("Name=" + colName + ", ID=" + id + ", Table=" + tabName); + } + rs.close(); + pstmt.close(); + } + catch (SQLException e) + { + CLogger.get().log(Level.SEVERE, sql, e); + } + return retValue; + } // getAD_Column_ID + + + /************************************************************************** * Constructor. * (called from MLookupFactory) * @param sqlQuery SQL query @@ -128,90 +214,4 @@ public class MLookupInfo implements Serializable, Cloneable return null; } // clone - - /************************************************************************** - * Get first AD_Reference_ID of a matching Reference Name. - * Can have SQL LIKE placeholders. - * (This is more a development tool than used for production) - * @param referenceName reference name - * @return AD_Reference_ID - */ - public static int getAD_Reference_ID (String referenceName) - { - int retValue = 0; - String sql = "SELECT AD_Reference_ID,Name,ValidationType,IsActive " - + "FROM AD_Reference WHERE Name LIKE ?"; - try - { - PreparedStatement pstmt = DB.prepareStatement(sql, null); - pstmt.setString(1, referenceName); - ResultSet rs = pstmt.executeQuery(); - // - int i = 0; - int id = 0; - String refName = ""; - String validationType = ""; - boolean isActive = false; - while (rs.next()) - { - id = rs.getInt(1); - if (i == 0) - retValue = id; - refName = rs.getString(2); - validationType = rs.getString(3); - isActive = rs.getString(4).equals("Y"); - CLogger.get().config("AD_Reference Name=" + refName + ", ID=" + id + ", Type=" + validationType + ", Active=" + isActive); - } - rs.close(); - pstmt.close(); - } - catch (SQLException e) - { - CLogger.get().log(Level.SEVERE, sql, e); - } - return retValue; - } // getAD_Reference_ID - - /** - * Get first AD_Column_ID of matching ColumnName. - * Can have SQL LIKE placeholders. - * (This is more a development tool than used for production) - * @param columnName column name - * @return AD_Column_ID - */ - public static int getAD_Column_ID (String columnName) - { - int retValue = 0; - String sql = "SELECT c.AD_Column_ID,c.ColumnName,t.TableName " - + "FROM AD_Column c, AD_Table t " - + "WHERE c.ColumnName LIKE ? AND c.AD_Table_ID=t.AD_Table_ID"; - try - { - PreparedStatement pstmt = DB.prepareStatement(sql, null); - pstmt.setString(1, columnName); - ResultSet rs = pstmt.executeQuery(); - // - int i = 0; - int id = 0; - String colName = ""; - String tabName = ""; - while (rs.next()) - { - id = rs.getInt(1); - if (i == 0) - retValue = id; - colName = rs.getString(2); - tabName = rs.getString(3); - CLogger.get().config("Name=" + colName + ", ID=" + id + ", Table=" + tabName); - } - rs.close(); - pstmt.close(); - } - catch (SQLException e) - { - CLogger.get().log(Level.SEVERE, sql, e); - } - return retValue; - } // getAD_Column_ID - } // MLookupInfo diff --git a/dbPort/src/org/compiere/model/MQuery.java b/dbPort/src/org/compiere/model/MQuery.java index c6084c43a8..b4686fe122 100644 --- a/dbPort/src/org/compiere/model/MQuery.java +++ b/dbPort/src/org/compiere/model/MQuery.java @@ -912,14 +912,28 @@ class Restriction implements Serializable } else sb.append(ColumnName); - // + + // NULL Operator + if ((Operator.equals("=") || Operator.equals("!=")) + && (Code == null + || "NULL".equals (Code.toString().toUpperCase()))) + { + if (Operator.equals("=")) + sb.append(" IS NULL "); + else + sb.append(" IS NOT NULL "); + } + else + { sb.append(Operator); + if (Code instanceof String) sb.append(DB.TO_STRING(Code.toString())); else if (Code instanceof Timestamp) sb.append(DB.TO_DATE((Timestamp)Code)); else sb.append(Code); + // Between // if (Code_to != null && InfoDisplay_to != null) if (MQuery.BETWEEN.equals(Operator)) @@ -932,6 +946,7 @@ class Restriction implements Serializable else sb.append(Code_to); } + } return sb.toString(); } // getSQL diff --git a/dbPort/src/org/compiere/model/MSystem.java b/dbPort/src/org/compiere/model/MSystem.java index eab62f356a..5082775c40 100644 --- a/dbPort/src/org/compiere/model/MSystem.java +++ b/dbPort/src/org/compiere/model/MSystem.java @@ -160,28 +160,15 @@ public class MSystem extends X_AD_System public String getStatisticsInfo (boolean recalc) { String s = super.getStatisticsInfo (); - /* - if (DB.isDerby()) - {//jz Derby time out, fix it later - s = "NO Statistics for Derby."; - recalc = false; - } - */ - if (DB.isDerby()) - {//jz Derby time out, fix it later - s = "NO Compiere statistics for Derby."; - recalc = false; - } - if (s == null || recalc) { - //jz to avoid data conversion String sql = "SELECT 'C'||(SELECT COUNT(*) FROM AD_Client)" - String sql = "SELECT 'C'||(SELECT COUNT(*) FROM AD_Client)" - + "||'U'||(SELECT COUNT(*) FROM AD_User)" - + "||'B'||(SELECT COUNT(*) FROM C_BPartner)" - + "||'P'||(SELECT COUNT(*) FROM M_Product)" - + "||'I'||(SELECT COUNT(*) FROM C_Invoice)" - + "||'M'||(SELECT COUNT(*) FROM M_Transaction)" + String sql = "SELECT 'C'||(SELECT " + DB.TO_CHAR("COUNT(*)", DisplayType.Number, Env.getAD_Language(Env.getCtx())) + " FROM AD_Client)" + + "||'U'|| (SELECT " + DB.TO_CHAR("COUNT(*)", DisplayType.Number, Env.getAD_Language(Env.getCtx())) + " FROM AD_User)" + + "||'B'|| (SELECT " + DB.TO_CHAR("COUNT(*)", DisplayType.Number, Env.getAD_Language(Env.getCtx())) + " FROM C_BPartner)" + + "||'P'|| (SELECT " + DB.TO_CHAR("COUNT(*)", DisplayType.Number, Env.getAD_Language(Env.getCtx())) + " FROM M_Product)" + + "||'I'|| (SELECT " + DB.TO_CHAR("COUNT(*)", DisplayType.Number, Env.getAD_Language(Env.getCtx())) + " FROM C_Invoice)" + + "||'L'|| (SELECT " + DB.TO_CHAR("COUNT(*)", DisplayType.Number, Env.getAD_Language(Env.getCtx())) + " FROM C_InvoiceLine)" + + "||'M'|| (SELECT " + DB.TO_CHAR("COUNT(*)", DisplayType.Number, Env.getAD_Language(Env.getCtx())) + " FROM M_Transaction)" + " FROM AD_System"; PreparedStatement pstmt = null; try diff --git a/dbPort/src/org/compiere/model/MTable.java b/dbPort/src/org/compiere/model/MTable.java index 8b72a095ab..53c4a04a1b 100644 --- a/dbPort/src/org/compiere/model/MTable.java +++ b/dbPort/src/org/compiere/model/MTable.java @@ -359,6 +359,38 @@ public class MTable extends X_AD_Table return null; } // getColumn + /** + * Table has a single Key + * @return true if table has single key column + */ + public boolean isSingleKey() + { + String[] keys = getKeyColumns(); + return keys.length == 1; + } // isSingleKey + + /** + * Get Key Columns of Table + * @return key columns + */ + public String[] getKeyColumns() + { + getColumns(false); + ArrayList list = new ArrayList(); + // + for (int i = 0; i < m_columns.length; i++) + { + MColumn column = m_columns[i]; + if (column.isKey()) + return new String[]{column.getColumnName()}; + if (column.isParent()) + list.add(column.getColumnName()); + } + String[] retValue = new String[list.size()]; + retValue = list.toArray(retValue); + return retValue; + } // getKeyColumns + /************************************************************************** * Get PO Class Instance * @param Record_ID record @@ -368,6 +400,11 @@ public class MTable extends X_AD_Table public PO getPO (int Record_ID, String trxName) { String tableName = getTableName(); + if (Record_ID != 0 && !isSingleKey()) + { + log.log(Level.WARNING, "(id) - Multi-Key " + tableName); + return null; + } Class clazz = getClass(tableName); if (clazz == null) { @@ -492,6 +529,8 @@ public class MTable extends X_AD_Table { pstmt = null; } + if (po == null) + return getPO(0, trxName); return po; } // getPO @@ -614,4 +653,15 @@ public class MTable extends X_AD_Table return retValue; } + /** + * String Representation + * @return info + */ + public String toString() + { + StringBuffer sb = new StringBuffer ("MTable["); + sb.append (get_ID()).append ("-").append (getTableName()).append ("]"); + return sb.toString (); + } // toString + } // MTable \ No newline at end of file diff --git a/dbPort/src/org/compiere/model/M_Element.java b/dbPort/src/org/compiere/model/M_Element.java index 00f3bacdba..c4562cb225 100644 --- a/dbPort/src/org/compiere/model/M_Element.java +++ b/dbPort/src/org/compiere/model/M_Element.java @@ -123,6 +123,48 @@ public class M_Element extends X_AD_Element return retValue; } // get + /** + * Get Element + * @param ctx context + * @param columnName case insentitive column name + * @return case sensitive column name + */ + public static M_Element getOfColumn (Properties ctx, int AD_Column_ID) + { + if (AD_Column_ID ==0) + return null; + M_Element retValue = null; + String sql = "SELECT * FROM AD_Element e " + + "WHERE EXISTS (SELECT * FROM AD_Column c " + + "WHERE c.AD_Element_ID=e.AD_Element_ID AND c.AD_Column_ID=?)"; + PreparedStatement pstmt = null; + try + { + pstmt = DB.prepareStatement (sql, null); + pstmt.setInt (1, AD_Column_ID); + ResultSet rs = pstmt.executeQuery (); + if (rs.next ()) + retValue = new M_Element (ctx, rs, null); + rs.close (); + pstmt.close (); + pstmt = null; + } + catch (Exception e) + { + s_log.log (Level.SEVERE, sql, e); + } + try + { + if (pstmt != null) + pstmt.close (); + pstmt = null; + } + catch (Exception e) + { + pstmt = null; + } + return retValue; + } // get /** Logger */ private static CLogger s_log = CLogger.getCLogger (M_Element.class); @@ -232,14 +274,35 @@ public class M_Element extends X_AD_Element sql = new StringBuffer("UPDATE AD_PrintFormatItem pi SET PrintName=") .append(DB.TO_STRING(getPrintName())) .append(", Name=").append(DB.TO_STRING(getName())) - .append(" WHERE AD_Client_ID=0") + .append(" WHERE IsCentrallyMaintained='Y'") .append(" AND EXISTS (SELECT * FROM AD_Column c ") .append("WHERE c.AD_Column_ID=pi.AD_Column_ID AND c.AD_Element_ID=") - .append(get_ID()).append(") AND IsCentrallyMaintained='Y'"); + .append(get_ID()).append(")"); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("PrintFormatItem updated #" + no); + + // Info Column + sql = new StringBuffer ("UPDATE AD_InfoColumn SET Name=") + .append(DB.TO_STRING(getName())) + .append(", Description=").append(DB.TO_STRING(getDescription())) + .append(", Help=").append(DB.TO_STRING(getHelp())) + .append(" WHERE AD_Element_ID=").append(get_ID()) + .append(" AND IsCentrallyMaintained='Y'"); + no = DB.executeUpdate(sql.toString(), get_TrxName()); + log.fine("InfoWindow updated #" + no); } return success; } // afterSave + /** + * String Representation + * @return info + */ + public String toString() + { + StringBuffer sb = new StringBuffer ("M_Element["); + sb.append (get_ID()).append ("-").append (getColumnName()).append ("]"); + return sb.toString (); + } // toString + } // M_Element diff --git a/dbPort/src/org/compiere/model/ModelValidationEngine.java b/dbPort/src/org/compiere/model/ModelValidationEngine.java index 23d42bd559..a7ca830a3d 100644 --- a/dbPort/src/org/compiere/model/ModelValidationEngine.java +++ b/dbPort/src/org/compiere/model/ModelValidationEngine.java @@ -178,7 +178,7 @@ public class ModelValidationEngine * @param type ModelValidator.TYPE_* * @return error message or NULL for no veto */ - public String fireModelChange (PO po, int type) + public String fireModelChange (PO po, int changeType) { if (po == null || m_modelChangeListeners.size() == 0) return null; @@ -194,10 +194,13 @@ public class ModelValidationEngine try { ModelValidator validator = (ModelValidator)list.get(i); - String error = validator.modelChange(po, type); + if (validator.getAD_Client_ID() == po.getAD_Client_ID()) + { + String error = validator.modelChange(po, changeType); if (error != null && error.length() > 0) return error; } + } catch (Exception e) { String error = e.getMessage(); @@ -257,7 +260,7 @@ public class ModelValidationEngine * @param timing see ModelValidator.TIMING_ constants * @return error message or null */ - public String fireDocValidate (PO po, int timing) + public String fireDocValidate (PO po, int docTiming) { if (po == null || m_docValidateListeners.size() == 0) return null; @@ -274,10 +277,13 @@ public class ModelValidationEngine try { validator = (ModelValidator)list.get(i); - String error = validator.docValidate(po, timing); + if (validator.getAD_Client_ID() == po.getAD_Client_ID()) + { + String error = validator.docValidate(po, docTiming); if (error != null && error.length() > 0) return error; } + } catch (Exception e) { log.log(Level.SEVERE, validator.toString(), e); @@ -299,4 +305,5 @@ public class ModelValidationEngine .append("]"); return sb.toString(); } // toString + } // ModelValidatorEngine diff --git a/dbPort/src/org/compiere/model/ModelValidator.java b/dbPort/src/org/compiere/model/ModelValidator.java index 9c42419047..5e6b8d6f5b 100644 --- a/dbPort/src/org/compiere/model/ModelValidator.java +++ b/dbPort/src/org/compiere/model/ModelValidator.java @@ -26,11 +26,20 @@ public interface ModelValidator { /** Model Change Type New */ public static final int TYPE_NEW = 1; + public static final int CHANGETYPE_NEW = 1; /** Model Change Type Change */ public static final int TYPE_CHANGE = 2; + public static final int CHANGETYPE_CHANGE = 2; /** Model Change Type Delete */ public static final int TYPE_DELETE = 3; + public static final int CHANGETYPE_DELETE = 3; + /** Called before document is prepared */ + public static final int TIMING_BEFORE_PREPARE = 1; + public static final int DOCTIMING_BEFORE_PREPARE = 1; + /** Called after document is processed */ + public static final int TIMING_AFTER_COMPLETE = 9; + public static final int DOCTIMING_AFTER_COMPLETE = 9; /** * Initialize Validation @@ -81,10 +90,4 @@ public interface ModelValidator */ public String docValidate (PO po, int timing); - - /** Called before document is prepared */ - public static final int TIMING_BEFORE_PREPARE = 1; - /** Called after document is processed */ - public static final int TIMING_AFTER_COMPLETE = 9; - } // ModelValidator diff --git a/dbPort/src/org/compiere/model/PO.java b/dbPort/src/org/compiere/model/PO.java index bf0dbab626..70511967cb 100644 --- a/dbPort/src/org/compiere/model/PO.java +++ b/dbPort/src/org/compiere/model/PO.java @@ -349,7 +349,7 @@ public abstract class PO { if (index < 0 || index >= get_ColumnCount()) { - log.log(Level.SEVERE, "Index invalid - " + index); + log.log(Level.WARNING, "Index invalid - " + index); return null; } if (m_newValues[index] != null) @@ -394,7 +394,7 @@ public abstract class PO int index = get_ColumnIndex(columnName); if (index < 0) { - log.log(Level.SEVERE, "Column not found - " + columnName); + log.log(Level.WARNING, "Column not found - " + columnName); Trace.printStack(); return null; } @@ -434,7 +434,7 @@ public abstract class PO int index = p_info.getColumnIndex(AD_Column_ID); if (index < 0) { - log.log(Level.SEVERE, "Not found - AD_Column_ID=" + AD_Column_ID); + log.log(Level.WARNING, "Not found - AD_Column_ID=" + AD_Column_ID); return null; } return get_Value (index); @@ -449,7 +449,7 @@ public abstract class PO { if (index < 0 || index >= get_ColumnCount()) { - log.log(Level.SEVERE, "Index invalid - " + index); + log.log(Level.WARNING, "Index invalid - " + index); return null; } return m_oldValues[index]; @@ -465,7 +465,7 @@ public abstract class PO int index = get_ColumnIndex(columnName); if (index < 0) { - log.log(Level.SEVERE, "Column not found - " + columnName); + log.log(Level.WARNING, "Column not found - " + columnName); return null; } return get_ValueOld (index); @@ -503,7 +503,7 @@ public abstract class PO { if (index < 0 || index >= get_ColumnCount()) { - log.log(Level.SEVERE, "Index invalid - " + index); + log.log(Level.WARNING, "Index invalid - " + index); return false; } if (m_newValues[index] == null) @@ -521,7 +521,7 @@ public abstract class PO int index = get_ColumnIndex(columnName); if (index < 0) { - log.log(Level.SEVERE, "Column not found - " + columnName); + log.log(Level.WARNING, "Column not found - " + columnName); return false; } return is_ValueChanged (index); @@ -539,7 +539,7 @@ public abstract class PO { if (index < 0 || index >= get_ColumnCount()) { - log.log(Level.SEVERE, "Index invalid - " + index); + log.log(Level.WARNING, "Index invalid - " + index); return null; } Object nValue = m_newValues[index]; @@ -579,7 +579,7 @@ public abstract class PO int index = get_ColumnIndex(columnName); if (index < 0) { - log.log(Level.SEVERE, "Column not found - " + columnName); + log.log(Level.WARNING, "Column not found - " + columnName); return null; } return get_ValueDifference (index); @@ -594,14 +594,9 @@ public abstract class PO */ protected final boolean set_Value (String ColumnName, Object value) { - if (ColumnName.equals("WhereClause") && value instanceof String && value != null) - { - //jz check if there is '=null' and replace them - value = ((String)value).replaceAll("=null", " IS NULL "); - value = ((String)value).replaceAll("=NULL", " IS NULL "); - value = ((String)value).replaceAll("!=null", " IS NOT NULL "); - value = ((String)value).replaceAll("!=NULL", " IS NOT NULL "); - } + if (value instanceof String && ColumnName.equals("WhereClause") + && value.toString().toUpperCase().indexOf("=NULL") != -1) + log.warning("Invalid Null Value - " + ColumnName + "=" + value); int index = get_ColumnIndex(ColumnName); if (index < 0) @@ -609,9 +604,11 @@ public abstract class PO log.log(Level.SEVERE, "Column not found - " + ColumnName); return false; } - //jz if (ColumnName.endsWith("_ID") && value instanceof String ) + { + log.severe("Invalid Data Type for " + ColumnName + "=" + value); value = Integer.parseInt((String)value); + } return set_Value (index, value); } // setValue @@ -638,7 +635,7 @@ public abstract class PO { if (index < 0 || index >= get_ColumnCount()) { - log.log(Level.SEVERE, "Index invalid - " + index); + log.log(Level.WARNING, "Index invalid - " + index); return false; } String ColumnName = p_info.getColumnName(index); @@ -646,7 +643,7 @@ public abstract class PO // if (p_info.isVirtualColumn(index)) { - log.log(Level.SEVERE, "Virtual Column" + colInfo); + log.log(Level.WARNING, "Virtual Column" + colInfo); return false; } // @@ -655,7 +652,7 @@ public abstract class PO if ( ( ! p_info.isColumnUpdateable(index) ) && ( ! is_new() ) ) { colInfo += " - NewValue=" + value + " - OldValue=" + get_Value(index); - log.log(Level.SEVERE, "Column not updateable" + colInfo); + log.log(Level.WARNING, "Column not updateable" + colInfo); return false; } // @@ -663,7 +660,7 @@ public abstract class PO { if (p_info.isColumnMandatory(index)) { - log.log(Level.SEVERE, "Cannot set mandatory column to null " + colInfo); + log.log(Level.WARNING, "Cannot set mandatory column to null " + colInfo); // Trace.printStack(); return false; } @@ -807,6 +804,10 @@ public abstract class PO int index = p_info.getColumnIndex(AD_Column_ID); if (index < 0) log.log(Level.SEVERE, "Not found - AD_Column_ID=" + AD_Column_ID); + String ColumnName = p_info.getColumnName(index); + if (ColumnName.equals("IsApproved")) + set_ValueNoCheck(ColumnName, value); + else set_Value (index, value); } // setValueOfColumn @@ -1438,16 +1439,28 @@ public abstract class PO // Search for Primary Key for (int i = 0; i < p_info.getColumnCount(); i++) { - if (p_info.isKey(i) && p_info.getColumnName(i).endsWith("_ID")) + if (p_info.isKey(i)) { String ColumnName = p_info.getColumnName(i); m_KeyColumns = new String[] {ColumnName}; + if (p_info.getColumnName(i).endsWith("_ID")) + { Integer ii = (Integer)get_Value(i); if (ii == null) m_IDs = new Object[] {I_ZERO}; else m_IDs = new Object[] {ii}; log.finest("(PK) " + ColumnName + "=" + ii); + } + else + { + Object oo = get_Value(i); + if (oo == null) + m_IDs = new Object[] {null}; + else + m_IDs = new Object[] {oo}; + log.finest("(PK) " + ColumnName + "=" + oo); + } return; } } // primary key search @@ -1772,7 +1785,7 @@ public abstract class PO } catch (Exception e) { - log.log(Level.SEVERE, "beforeSave - " + toString(), e); + log.log(Level.WARNING, "beforeSave - " + toString(), e); log.saveError("Error", e.toString(), false); // throw new DBException(e); return false; @@ -1816,7 +1829,7 @@ public abstract class PO } catch (Exception e) { - log.log(Level.SEVERE, "afterSave", e); + log.log(Level.WARNING, "afterSave", e); log.saveError("Error", e.toString(), false); success = false; // throw new DBException(e); @@ -2088,9 +2101,11 @@ public abstract class PO else { if (m_trxName == null) - log.log(Level.WARNING, p_info.getTableName() + "." + where); + log.log(Level.WARNING, "#" + no + + " - " + p_info.getTableName() + "." + where); else - log.log(Level.WARNING, "[" + m_trxName + "] - " + p_info.getTableName() + "." + where); + log.log(Level.WARNING, "#" + no + + " - [" + m_trxName + "] - " + p_info.getTableName() + "." + where); } return saveFinish (false, ok); } @@ -2416,7 +2431,7 @@ public abstract class PO } catch (Exception e) { - log.log(Level.SEVERE, "beforeDelete", e); + log.log(Level.WARNING, "beforeDelete", e); log.saveError("Error", e.toString(), false); // throw new DBException(e); return false; @@ -2522,7 +2537,7 @@ public abstract class PO } catch (Exception e) { - log.log(Level.SEVERE, "afterDelete", e); + log.log(Level.WARNING, "afterDelete", e); log.saveError("Error", e.toString(), false); success = false; // throw new DBException(e); @@ -2898,7 +2913,7 @@ public abstract class PO if (success) log.fine("success"); else - log.log(Level.SEVERE, "failed"); + log.log(Level.WARNING, "failed"); return success; } return false; @@ -2931,7 +2946,7 @@ public abstract class PO if (success) log.fine("success" + (trxName == null ? "" : "[" + trxName + "]")); else - log.log(Level.SEVERE, "failed" + (trxName == null ? "" : "[" + trxName + "]")); + log.log(Level.WARNING, "failed" + (trxName == null ? "" : " [" + trxName + "]")); return success; } return true; diff --git a/dbPort/src/org/compiere/util/Env.java b/dbPort/src/org/compiere/util/Env.java index 22f525ed72..93eee8cd15 100644 --- a/dbPort/src/org/compiere/util/Env.java +++ b/dbPort/src/org/compiere/util/Env.java @@ -1298,7 +1298,7 @@ public final class Env URL url = Adempiere.class.getResource("images/" + fileNameInImageDir); if (url == null) { - s_log.log(Level.WARNING, "Not found: " + fileNameInImageDir); + s_log.log(Level.SEVERE, "Not found: " + fileNameInImageDir); return null; } return new ImageIcon(url); diff --git a/dbPort/src/org/compiere/util/GenerateModel.java b/dbPort/src/org/compiere/util/GenerateModel.java index cc14b1d889..969a85213e 100644 --- a/dbPort/src/org/compiere/util/GenerateModel.java +++ b/dbPort/src/org/compiere/util/GenerateModel.java @@ -60,8 +60,8 @@ public class GenerateModel /** File Header */ public static final String COPY = "/******************************************************************************\n" - +" * Product: Adempiere ERP & CRM Smart Business Solution *\n" - +" * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *\n" + +" * Product: Adempiere ERP & CRM Smart Business Solution *\n" + +" * Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *\n" +" * This program is free software; you can redistribute it and/or modify it *\n" +" * under the terms version 2 of the GNU General Public License as published *\n" +" * by the Free Software Foundation. This program is distributed in the hope *\n" diff --git a/dbPort/src/org/compiere/util/Login.java b/dbPort/src/org/compiere/util/Login.java index 8eb9a28e5e..b812d80fd7 100644 --- a/dbPort/src/org/compiere/util/Login.java +++ b/dbPort/src/org/compiere/util/Login.java @@ -43,7 +43,8 @@ public class Login public static Properties initTest (boolean isClient) { // logger.entering("Env", "initTest"); - Adempiere.startupEnvironment(true); + if (!Adempiere.startupEnvironment(true)) + System.exit (1); // Test Context Properties ctx = Env.getCtx(); Login login = new Login(ctx); @@ -217,6 +218,9 @@ public class Login // Authentification boolean authenticated = false; MSystem system = MSystem.get(m_ctx); + if (system == null) + throw new IllegalStateException("No System Info"); + if (system.isLDAP()) { authenticated = system.isLDAP(app_user, app_pwd); diff --git a/install/src/org/compiere/install/KeyStoreMgt.java b/install/src/org/compiere/install/KeyStoreMgt.java index 2c08f34c5f..d0ffe7fc66 100644 --- a/install/src/org/compiere/install/KeyStoreMgt.java +++ b/install/src/org/compiere/install/KeyStoreMgt.java @@ -379,7 +379,7 @@ public class KeyStoreMgt StringBuffer cmd = new StringBuffer ("-genkey -keyalg rsa"); cmd.append(" -alias ").append(alias); cmd.append(" -dname \"").append(dname).append("\""); - cmd.append(" -keypass ").append(password).append(" -validity 365"); + cmd.append(" -keypass ").append(password).append(" -validity 999"); if (fileName.indexOf(' ') != -1) cmd.append(" -keystore \"").append(fileName).append("\" -storepass ").append(password); else @@ -399,7 +399,7 @@ public class KeyStoreMgt StringBuffer cmd = new StringBuffer ("-selfcert"); cmd.append(" -alias ").append(alias); cmd.append(" -dname \"").append(dname).append("\""); - cmd.append(" -keypass ").append(password).append(" -validity 180"); + cmd.append(" -keypass ").append(password).append(" -validity 999"); if (fileName.indexOf(' ') != -1) cmd.append(" -keystore \"").append(fileName).append("\" -storepass ").append(password); else diff --git a/install/src/org/compiere/install/SilentSetup.java b/install/src/org/compiere/install/SilentSetup.java index 30fec7412c..2a2d7604ac 100644 --- a/install/src/org/compiere/install/SilentSetup.java +++ b/install/src/org/compiere/install/SilentSetup.java @@ -28,7 +28,7 @@ public class SilentSetup { return; } - Ini.setShowLicenseDialog(false); + // Ini.setShowLicenseDialog(false); ConfigurationData data = new ConfigurationData(null); if (!data.load()) return; if (!data.test()) diff --git a/looks/src/org/compiere/plaf/CompiereColor.java b/looks/src/org/compiere/plaf/CompiereColor.java index ff35fe6117..8fbef8963d 100644 --- a/looks/src/org/compiere/plaf/CompiereColor.java +++ b/looks/src/org/compiere/plaf/CompiereColor.java @@ -369,8 +369,6 @@ public class CompiereColor implements Serializable /** Background */ private ColorBackground m_back = null; - /** 3D Look */ - private boolean m_3d = true; /** Diry marker for repaining Background */ private boolean m_dirty = true; diff --git a/looks/src/org/compiere/util/Ini.java b/looks/src/org/compiere/util/Ini.java index 9ea2bd23ca..0ce971c2fd 100644 --- a/looks/src/org/compiere/util/Ini.java +++ b/looks/src/org/compiere/util/Ini.java @@ -46,10 +46,10 @@ public final class Ini implements Serializable /** Apps User ID */ public static final String P_UID = "ApplicationUserID"; - private static final String DEFAULT_UID = "System"; + private static final String DEFAULT_UID = "GardenAdmin"; /** Apps Password */ public static final String P_PWD = "ApplicationPassword"; - private static final String DEFAULT_PWD = "System"; + private static final String DEFAULT_PWD = "GardenAdmin"; /** Store Password */ public static final String P_STORE_PWD = "StorePassword"; private static final boolean DEFAULT_STORE_PWD = true; @@ -280,7 +280,6 @@ public final class Ini implements Serializable { log.config(filename); firstTime = true; - if (isShowLicenseDialog()) if (!IniDialog.accept()) System.exit(-1); } @@ -308,6 +307,29 @@ public final class Ini implements Serializable return firstTime; } // loadProperties + /** + * Delete Property file + */ + public static void deletePropertyFile() + { + String fileName = getFileName(s_client); + File file = new File(fileName); + if (file.exists()) + { + try + { + if (!file.delete()) + file.deleteOnExit(); + s_prop = new Properties(); + log.config (fileName); + } + catch (Exception e) + { + log.log (Level.WARNING, "Cannot delete Property file", e); + } + } + } // deleteProperties + /** * Load property and set to default, if not existing * @@ -493,8 +515,6 @@ public final class Ini implements Serializable private static boolean s_client = true; /** IsClient Internal marker */ private static boolean s_loaded = false; - /** Show license dialog for first time **/ - private static boolean s_license_dialog = true; /** * Are we in Client Mode ? @@ -514,24 +534,6 @@ public final class Ini implements Serializable s_client = client; } // setClient - /** - * Set show license dialog for new setup - * @param b - */ - public static void setShowLicenseDialog(boolean b) - { - s_license_dialog = b; - } - - /** - * Is show license dialog for new setup - * @return boolean - */ - public static boolean isShowLicenseDialog() - { - return s_license_dialog; - } - /** * Are the properties loaded? * @return true if properties loaded. diff --git a/looks/src/org/compiere/util/Util.java b/looks/src/org/compiere/util/Util.java index d58c51f6c8..5b3b06d7b1 100644 --- a/looks/src/org/compiere/util/Util.java +++ b/looks/src/org/compiere/util/Util.java @@ -87,6 +87,35 @@ public class Util } // removeCRLF + /** + * Clean - Remove all white spaces + * @param in in + * @return cleaned string + */ + public static String cleanWhitespace (String in) + { + char[] inArray = in.toCharArray(); + StringBuffer out = new StringBuffer(inArray.length); + boolean lastWasSpace = false; + for (int i = 0; i < inArray.length; i++) + { + char c = inArray[i]; + if (Character.isWhitespace(c)) + { + if (!lastWasSpace) + out.append (' '); + lastWasSpace = true; + } + else + { + out.append (c); + lastWasSpace = false; + } + } + return out.toString(); + } // cleanWhitespace + + /** * Mask HTML content. * i.e. replace characters with &values; @@ -498,7 +527,7 @@ public class Util */ public static String cleanAmp (String in) { - if (in == null) + if (in == null || in.length() == 0) return in; int pos = in.indexOf('&'); if (pos == -1) diff --git a/print/src/org/compiere/print/MPrintFormat.java b/print/src/org/compiere/print/MPrintFormat.java index 02af8a8c0c..f89c743893 100644 --- a/print/src/org/compiere/print/MPrintFormat.java +++ b/print/src/org/compiere/print/MPrintFormat.java @@ -559,7 +559,7 @@ public class MPrintFormat extends X_AD_PrintFormat // Get Column List from Tab String sql = "SELECT AD_Column_ID " //, Name, IsDisplayed, SeqNo + "FROM AD_Field " - + "WHERE AD_Tab_ID=(SELECT AD_Tab_ID FROM AD_Tab WHERE AD_Table_ID=? AND ROWNUM=1)" + + "WHERE AD_Tab_ID=(SELECT MIN(AD_Tab_ID) FROM AD_Tab WHERE AD_Table_ID=?)" + " AND IsEncrypted='N' AND ObscureType IS NULL " + "ORDER BY COALESCE(IsDisplayed,'N') DESC, SortNo, SeqNo, Name"; try