diff --git a/fitnesse/FitNesseRoot/IdempiereSuite/TestCashPosOrder/content.txt b/fitnesse/FitNesseRoot/IdempiereSuite/TestCashPosOrder/content.txt index cfc4f468b0..a46f1c1336 100644 --- a/fitnesse/FitNesseRoot/IdempiereSuite/TestCashPosOrder/content.txt +++ b/fitnesse/FitNesseRoot/IdempiereSuite/TestCashPosOrder/content.txt @@ -65,15 +65,15 @@ Check the inventory level after the document |@ExpectedInventoryLevelAfter@|@SQL=SELECT SUM(s.qtyonhand) FROM m_storage s, m_locator l, m_warehouse w WHERE s.m_product_id=133 AND s.m_locator_id = l.m_locator_id AND l.m_warehouse_id=w.m_warehouse_id AND w.m_warehouse_id=103| -Check the bp balance after the document +Check the bp balance after the document (with the new cash payment is applied immediately so there must not be variance on the bp balance) !|Assert Record| |*Table* |C_bpartner | |*Where* |c_bpartner_id=120 | |*Read* | | |actuallifetimevalue|@SQL=SELECT @C_bpartner.actuallifetimevalue@ + @c_order.grandtotal@ FROM DUAL| -|so_creditused |@SQL=SELECT @C_bpartner.so_creditused@ + @c_order.grandtotal@ FROM DUAL | -|totalopenbalance |@SQL=SELECT @C_bpartner.totalopenbalance@ + @c_order.grandtotal@ FROM DUAL | +|so_creditused |@SQL=SELECT @C_bpartner.so_creditused@ FROM DUAL | +|totalopenbalance |@SQL=SELECT @C_bpartner.totalopenbalance@ FROM DUAL | Check existance of shipment @@ -123,17 +123,14 @@ Check existance of invoice |qtyinvoiced | | |linenetamt | | -Check existance of cash journal line +Check existance of cash payment (now on payment table) !|Read Record| -|*Table* |C_CashLine | +|*Table* |C_Payment | |C_Invoice_id|@C_Invoice.C_Invoice_id@| |*Read* | | -|line | | -|c_cash_id | | -|line | | +|documentno | | |description | | |amount | | -|isgenerated | | |processed | | diff --git a/fitnesse/FitNesseRoot/IdempiereSuite/TestCreateReference/content.txt b/fitnesse/FitNesseRoot/IdempiereSuite/TestCreateReference/content.txt index 0de14861a5..1bdaa8b574 100644 --- a/fitnesse/FitNesseRoot/IdempiereSuite/TestCreateReference/content.txt +++ b/fitnesse/FitNesseRoot/IdempiereSuite/TestCreateReference/content.txt @@ -1,4 +1,4 @@ -This test tries to create a reference in the database, intentionally the !-ValidationType-! is left to a wrong value (Y) to make it fail. +This test tries to create a reference in the database, intentionally the !-ValidationType-! is set to a wrong value (Y) to make it fail. !include TestLoginSystem @@ -7,4 +7,4 @@ This test tries to create a reference in the database, intentionally the !-Valid |Name |Fitnesse Test| |ValidationType|Y | |invalidcolumn|Y | -|*Save* | | +|*Save*Error* |java.lang.Exception: Cannot set value of column| diff --git a/fitnesse/FitNesseRoot/IdempiereSuite/TestInitialClientSetup/content.txt b/fitnesse/FitNesseRoot/IdempiereSuite/TestInitialClientSetup/content.txt index 320b83ed9e..381f04285c 100644 --- a/fitnesse/FitNesseRoot/IdempiereSuite/TestInitialClientSetup/content.txt +++ b/fitnesse/FitNesseRoot/IdempiereSuite/TestInitialClientSetup/content.txt @@ -2,19 +2,23 @@ This test creates a new tenant in the database. !include TestLoginSystem -!|Run Process| -|*ProcessValue* |InitialClientSetup | -|ClientName |Prueba | -|OrgName |Prueba | -|AdminUserName |PruebaAdmin | -|NormalUserName |PruebaUser | -|C_Currency_ID |230 | -|C_Country_ID |156 | -|CityName |Bogotá | -|IsUseBPDimension |Y | -|IsUseProductDimension |Y | -|IsUseProjectDimension |Y | -|IsUseCampaignDimension |N | -|IsUseSalesRegionDimension|N | -|CoAFile |/home/carlos/hgAdempiere/adempiere361/data/import/AccountingUS.csv| -|*Run* | | +!|Set Variable | +|@random_string@|@random_string(,,6)| + + +!|Run Process | +|*ProcessValue* |InitialClientSetup | +|ClientName |TestClient @random_string@ | +|OrgName |TestOrg @random_string@ | +|AdminUserName |@random_string@Admin | +|NormalUserName |@random_string@User | +|C_Currency_ID |230 | +|C_Country_ID |156 | +|CityName |Bogotá | +|IsUseBPDimension |Y | +|IsUseProductDimension |Y | +|IsUseProjectDimension |Y | +|IsUseCampaignDimension |N | +|IsUseSalesRegionDimension|N | +|CoAFile |${fitnesse_home}/../org.adempiere.server-feature/data/import/AccountingUS.csv| +|*Run* | | diff --git a/fitnesse/FitNesseRoot/IdempiereSuite/TestPostInternalInventory/content.txt b/fitnesse/FitNesseRoot/IdempiereSuite/TestPostInternalInventory/content.txt index cc9d42f948..e1c24b150c 100644 --- a/fitnesse/FitNesseRoot/IdempiereSuite/TestPostInternalInventory/content.txt +++ b/fitnesse/FitNesseRoot/IdempiereSuite/TestPostInternalInventory/content.txt @@ -4,43 +4,49 @@ https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2713724&group_id=17 !include -c TestLoginGardenAdmin +!|Set Variable | +|@InventoryLevelBefore@ |@SQL=select sum(qtyonhand) from m_storage where m_product_id=141 and m_locator_id=101| +|@ExpectedInventoryLevelAfter@|@SQL=SELECT @InventoryLevelBefore@-2 FROM dual | + Create the internal use document -!|Create Record| -|*Table*|M_Inventory | +!|Create Record | +|*Table* |M_Inventory | |ad_org_id |11 | -|c_doctype_id |144 | +|c_doctype_id |200000 | |m_warehouse_id|103 | -|movementdate |2009-03-26 00:00:00.0| -|*Save*| | +|movementdate |2013-06-26 00:00:00.0| +|*Save* | | Create internal use line -!|Create Record| -|*Table*|M_InventoryLine | -|M_Inventory_ID|@M_Inventory.M_Inventory_ID@ | -|ad_org_id |@M_Inventory.AD_Org_ID@ | -|m_locator_id |101 | -|m_product_id |141 | -|c_charge_id |101 | -|qtyinternaluse|@SQL=select sum(qtyonhand) from m_storage where m_product_id=141 and m_locator_id=101 and m_attributesetinstance_id=0| -|qtybook|@SQL=select sum(qtyonhand) from m_storage where m_product_id=141 and m_locator_id=101 and m_attributesetinstance_id=0| -|*Save*| | +!|Create Record | +|*Table* |M_InventoryLine | +|M_Inventory_ID|@M_Inventory.M_Inventory_ID@| +|ad_org_id |@M_Inventory.AD_Org_ID@ | +|m_locator_id |101 | +|m_product_id |141 | +|c_charge_id |101 | +|qtyinternaluse|2 | +|*Save* | | Complete the internal use -!|Run Process| -|*ProcessValue*|M_Inventory Process | +!|Run Process | +|*ProcessValue*|M_Inventory Process | |*RecordID* |@M_Inventory.M_Inventory_ID@| -|*DocAction* |CO | -|*Run*| | +|*DocAction* |CO | +|*Run* | | + +!|Assert Variable | +|@ExpectedInventoryLevelAfter@|@SQL=select sum(qtyonhand) from m_storage where m_product_id=141 and m_locator_id=101| Post -!|Set DocAction| -|*Table* |M_Inventory| -|M_Inventory_ID|@M_Inventory.M_Inventory_ID@ | -|docAction |PO | -|*Save*| | +!|Set DocAction | +|*Table* |M_Inventory | +|M_Inventory_ID|@M_Inventory.M_Inventory_ID@| +|docAction |PO | +|*Save* | | Check the postings \ No newline at end of file diff --git a/fitnesse/FitNesseRoot/RecentChanges/content.txt b/fitnesse/FitNesseRoot/RecentChanges/content.txt index ea72a69fd5..60b5d36182 100644 --- a/fitnesse/FitNesseRoot/RecentChanges/content.txt +++ b/fitnesse/FitNesseRoot/RecentChanges/content.txt @@ -1,3 +1,9 @@ +|IdempiereSuite.TestInitialClientSetup||17:03:35 vie, jun 28, 2013| +|IdempiereSuite.TestPostInternalInventory||15:31:05 vie, jun 28, 2013| +|IdempiereSuite.TestCreateReference||14:44:52 vie, jun 28, 2013| +|IdempiereSuite.TestCashPosOrder||14:42:20 vie, jun 28, 2013| +|ZkSuite.ZkGardenAdminLogin||13:02:13 vie, jun 28, 2013| +|ZkSuite.ZkSystemAdminLogin||13:00:38 vie, jun 28, 2013| |||12:04:00 jue, dic 20, 2012| |FitLibraryWeb||01:41:13 Thu, Dec 13, 2012| |FitLibrary||01:40:51 Thu, Dec 13, 2012| @@ -9,13 +15,9 @@ |CommonTests.CreateProductPrice||01:29:57 mar, abr 03, 2012| |AvgCostSuite.BasicTest||01:18:34 mar, abr 03, 2012| |CommonTests.CreatePurchaseOrder||01:13:34 mar, abr 03, 2012| -|IdempiereSuite.TestPostInternalInventory||24:21:25 mar, abr 03, 2012| -|IdempiereSuite.TestInitialClientSetup||24:20:45 mar, abr 03, 2012| -|IdempiereSuite.TestCreateReference||24:20:15 mar, abr 03, 2012| |IdempiereSuite.TestLoginSystem||24:20:05 mar, abr 03, 2012| |IdempiereSuite.TestCreateBusinessPartner||24:19:40 mar, abr 03, 2012| |IdempiereSuite.TestCompletePayment||24:19:18 mar, abr 03, 2012| -|IdempiereSuite.TestCashPosOrder||24:18:46 mar, abr 03, 2012| |IdempiereSuite||24:17:17 mar, abr 03, 2012| |IdempiereSuite.TestLoginGardenAdmin||24:17:07 mar, abr 03, 2012| |IdempiereSuite.QuickTest||24:16:36 mar, abr 03, 2012| diff --git a/fitnesse/FitNesseRoot/ZkSuite/ProductionTest/content.txt b/fitnesse/FitNesseRoot/ZkSuite/ProductionTest/content.txt index 8acfa8a923..a844a280ef 100644 --- a/fitnesse/FitNesseRoot/ZkSuite/ProductionTest/content.txt +++ b/fitnesse/FitNesseRoot/ZkSuite/ProductionTest/content.txt @@ -15,12 +15,12 @@ |''window''|${windowId}|''click toolbar''|!-BtnSave-!| |''wait response''| |''window message''|${windowId}|is|!-Record saved-!| -|''window''|${windowId}|''click detail toolbar''|!-BtnNew-!| +|''window''|${windowId}|''click detail toolbar''|!-BtnEdit-!| |''wait response''| |''text of''|${windowId} $recordInfo|is|!-+*1/1-!| |''window''|${windowId}|''click toolbar''|!-BtnParentRecord-!| |''wait response''| -|''window''|${windowId}|''click process button''|!-CreateFrom-!| +|''click''|${windowId} $Production $CreateFrom| |''wait response''| |''click''|${windowId} @window[title="Create Production"] $Ok| |''wait response''| diff --git a/fitnesse/FitNesseRoot/ZkSuite/ZkGardenAdminLogin/content.txt b/fitnesse/FitNesseRoot/ZkSuite/ZkGardenAdminLogin/content.txt index c546b2b34c..0e1f985afe 100644 --- a/fitnesse/FitNesseRoot/ZkSuite/ZkGardenAdminLogin/content.txt +++ b/fitnesse/FitNesseRoot/ZkSuite/ZkGardenAdminLogin/content.txt @@ -4,7 +4,7 @@ '''start firefox,chrome or phantomjs''' |''start spider with''|firefox| |''shutdown browser automatically''|false| -|''get url''|http://localhost:8080/webui/index.zul| +|''get url''|http://localhost:${ADEMPIERE_WEB_PORT}/webui/index.zul| |''wait response''| diff --git a/fitnesse/FitNesseRoot/ZkSuite/ZkSystemAdminLogin/content.txt b/fitnesse/FitNesseRoot/ZkSuite/ZkSystemAdminLogin/content.txt index df13eeb65e..6b1cf7a3db 100644 --- a/fitnesse/FitNesseRoot/ZkSuite/ZkSystemAdminLogin/content.txt +++ b/fitnesse/FitNesseRoot/ZkSuite/ZkSystemAdminLogin/content.txt @@ -3,7 +3,7 @@ '''start firefox,chrome or phantomjs''' |''start spider with''|firefox| |''shutdown browser automatically''|false| -|''get url''|http://localhost:8080/webui/index.zul| +|''get url''|http://localhost:${ADEMPIERE_WEB_PORT}/webui/index.zul| |''wait response''| diff --git a/migration/i1.0c-release/oracle/20130603172740_IDEMPIERE-1123.sql b/migration/i1.0c-release/oracle/20130603172740_IDEMPIERE-1123.sql new file mode 100644 index 0000000000..7a780aacdd --- /dev/null +++ b/migration/i1.0c-release/oracle/20130603172740_IDEMPIERE-1123.sql @@ -0,0 +1,12 @@ +-- Jul 3, 2013 5:16:26 PM COT +-- IDEMPIERE-1123 Unnecessary showing user security fields +UPDATE AD_Field SET IsActive='N',Updated=TO_DATE('2013-07-03 17:16:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200473 +; + +-- Jul 3, 2013 5:16:32 PM COT +-- IDEMPIERE-1123 Unnecessary showing user security fields +UPDATE AD_Field SET IsActive='N',Updated=TO_DATE('2013-07-03 17:16:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200475 +; + +SELECT register_migration_script('20130603172740_IDEMPIERE-1123.sql') FROM dual +; diff --git a/migration/i1.0c-release/oracle/20130603182945_IDEMPIERE-1121.sql b/migration/i1.0c-release/oracle/20130603182945_IDEMPIERE-1121.sql new file mode 100644 index 0000000000..eb223da70a --- /dev/null +++ b/migration/i1.0c-release/oracle/20130603182945_IDEMPIERE-1121.sql @@ -0,0 +1,13 @@ +-- Jul 3, 2013 6:25:43 PM COT +-- IDEMPIERE-1121 Field Customization IsUpdateable mandatory on DB not in dict +ALTER TABLE AD_UserDef_Field MODIFY IsUpdateable CHAR(1) DEFAULT NULL +; + +-- Jul 3, 2013 6:25:44 PM COT +-- IDEMPIERE-1121 Field Customization IsUpdateable mandatory on DB not in dict +ALTER TABLE AD_UserDef_Field MODIFY IsUpdateable NULL +; + +SELECT register_migration_script('20130603182945_IDEMPIERE-1121.sql') FROM dual +; + diff --git a/migration/i1.0c-release/oracle/201307041818_IDEMPIERE-1133.sql b/migration/i1.0c-release/oracle/201307041818_IDEMPIERE-1133.sql new file mode 100644 index 0000000000..81a4a0594b --- /dev/null +++ b/migration/i1.0c-release/oracle/201307041818_IDEMPIERE-1133.sql @@ -0,0 +1,13 @@ +-- 4/07/2013 06:07:52 PM COT +-- IDEMPIERE-1133 Customize grid not translated +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,Created,AD_Org_ID,AD_Client_ID,EntityType) VALUES ('I','Save Column Width',200186,'e55bb769-5507-483c-bfd4-c938c5c5d93f','SaveColumnWidth','Y',TO_DATE('2013-07-04 18:07:52','YYYY-MM-DD HH24:MI:SS'),100,100,TO_DATE('2013-07-04 18:07:52','YYYY-MM-DD HH24:MI:SS'),0,0,'D') +; + +-- 4/07/2013 06:07:52 PM COT +-- IDEMPIERE-1133 Customize grid not translated +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200186 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + +SELECT register_migration_script('201307041818_IDEMPIERE-1133.sql') FROM dual +; + diff --git a/migration/i1.0c-release/postgresql/20130603172740_IDEMPIERE-1123.sql b/migration/i1.0c-release/postgresql/20130603172740_IDEMPIERE-1123.sql new file mode 100644 index 0000000000..942225d789 --- /dev/null +++ b/migration/i1.0c-release/postgresql/20130603172740_IDEMPIERE-1123.sql @@ -0,0 +1,13 @@ +-- Jul 3, 2013 5:16:26 PM COT +-- IDEMPIERE-1123 Unnecessary showing user security fields +UPDATE AD_Field SET IsActive='N',Updated=TO_TIMESTAMP('2013-07-03 17:16:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200473 +; + +-- Jul 3, 2013 5:16:32 PM COT +-- IDEMPIERE-1123 Unnecessary showing user security fields +UPDATE AD_Field SET IsActive='N',Updated=TO_TIMESTAMP('2013-07-03 17:16:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200475 +; + +SELECT register_migration_script('20130603172740_IDEMPIERE-1123.sql') FROM dual +; + diff --git a/migration/i1.0c-release/postgresql/20130603182945_IDEMPIERE-1121.sql b/migration/i1.0c-release/postgresql/20130603182945_IDEMPIERE-1121.sql new file mode 100644 index 0000000000..16ac69b98b --- /dev/null +++ b/migration/i1.0c-release/postgresql/20130603182945_IDEMPIERE-1121.sql @@ -0,0 +1,13 @@ +-- Jul 3, 2013 6:25:43 PM COT +-- IDEMPIERE-1121 Field Customization IsUpdateable mandatory on DB not in dict +INSERT INTO t_alter_column values('ad_userdef_field','IsUpdateable','CHAR(1)',null,'NULL') +; + +-- Jul 3, 2013 6:25:44 PM COT +-- IDEMPIERE-1121 Field Customization IsUpdateable mandatory on DB not in dict +INSERT INTO t_alter_column values('ad_userdef_field','IsUpdateable',null,'NULL',null) +; + +SELECT register_migration_script('20130603182945_IDEMPIERE-1121.sql') FROM dual +; + diff --git a/migration/i1.0c-release/postgresql/201307041818_IDEMPIERE-1133.sql b/migration/i1.0c-release/postgresql/201307041818_IDEMPIERE-1133.sql new file mode 100644 index 0000000000..1a62c356f7 --- /dev/null +++ b/migration/i1.0c-release/postgresql/201307041818_IDEMPIERE-1133.sql @@ -0,0 +1,13 @@ +-- 4/07/2013 06:07:52 PM COT +-- IDEMPIERE-1133 Customize grid not translated +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,Created,AD_Org_ID,AD_Client_ID,EntityType) VALUES ('I','Save Column Width',200186,'e55bb769-5507-483c-bfd4-c938c5c5d93f','SaveColumnWidth','Y',TO_TIMESTAMP('2013-07-04 18:07:52','YYYY-MM-DD HH24:MI:SS'),100,100,TO_TIMESTAMP('2013-07-04 18:07:52','YYYY-MM-DD HH24:MI:SS'),0,0,'D') +; + +-- 4/07/2013 06:07:52 PM COT +-- IDEMPIERE-1133 Customize grid not translated +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200186 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + +SELECT register_migration_script('201307041818_IDEMPIERE-1133.sql') FROM dual +; + diff --git a/org.adempiere.base/src/org/compiere/acct/DocLine.java b/org.adempiere.base/src/org/compiere/acct/DocLine.java index ac1cce333b..cc793ed1bd 100644 --- a/org.adempiere.base/src/org/compiere/acct/DocLine.java +++ b/org.adempiere.base/src/org/compiere/acct/DocLine.java @@ -1143,6 +1143,11 @@ public class DocLine } // getReversalLine_ID //end AZ Goodwill + public PO getPO() + { + return p_po; + } + /** * String representation * @return String diff --git a/org.adempiere.base/src/org/compiere/acct/Doc_InOut.java b/org.adempiere.base/src/org/compiere/acct/Doc_InOut.java index f74460caf1..fa79852c77 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc_InOut.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc_InOut.java @@ -21,6 +21,8 @@ import java.sql.ResultSet; import java.util.ArrayList; import java.util.logging.Level; +import org.compiere.model.I_M_InOutLine; +import org.compiere.model.I_M_RMALine; import org.compiere.model.MTax; import org.compiere.model.MCurrency; import org.compiere.model.MAccount; @@ -33,6 +35,7 @@ import org.compiere.model.MProduct; import org.compiere.model.ProductCost; import org.compiere.util.DB; import org.compiere.util.Env; +import org.compiere.util.Util; /** * Post Shipment/Receipt Documents. @@ -178,9 +181,19 @@ public class Doc_InOut extends Doc MProduct product = line.getProduct(); if (product.isStocked()) { - p_Error = "No Costs for " + line.getProduct().getName(); - log.log(Level.WARNING, p_Error); - return null; + //ok if we have purchased zero cost item from vendor before + int count = DB.getSQLValue(null, "SELECT Count(*) FROM M_CostDetail WHERE M_Product_ID=? AND Processed='Y' AND Amt=0.00 AND Qty > 0 AND (C_OrderLine_ID > 0 OR C_InvoiceLine_ID > 0)", + product.getM_Product_ID()); + if (count > 0) + { + costs = BigDecimal.ZERO; + } + else + { + p_Error = "No Costs for " + line.getProduct().getName(); + log.log(Level.WARNING, p_Error); + return null; + } } else // ignore service continue; @@ -381,6 +394,7 @@ public class Doc_InOut extends Doc DocLine line = p_lines[i]; BigDecimal costs = null; MProduct product = line.getProduct(); + MOrderLine orderLine = null; if (!isReversal(line)) { //get costing method for product @@ -393,7 +407,7 @@ public class Doc_InOut extends Doc // Low - check if c_orderline_id is valid if (C_OrderLine_ID > 0) { - MOrderLine orderLine = new MOrderLine (getCtx(), C_OrderLine_ID, getTrxName()); + orderLine = new MOrderLine (getCtx(), C_OrderLine_ID, getTrxName()); // Elaine 2008/06/26 C_Currency_ID = orderLine.getC_Currency_ID(); // @@ -418,8 +432,8 @@ public class Doc_InOut extends Doc costs = costs.multiply(line.getQty()); } else - { - p_Error = "Resubmit - No Costs for " + product.getName(); + { + p_Error = "Resubmit - No Costs for " + product.getName() + " (required order line)"; log.log(Level.WARNING, p_Error); return null; } @@ -432,9 +446,17 @@ public class Doc_InOut extends Doc if (costs == null || costs.signum() == 0) { - p_Error = "Resubmit - No Costs for " + product.getName(); - log.log(Level.WARNING, p_Error); - return null; + //ok if purchase price is actually zero + if (orderLine != null && orderLine.getPriceActual().signum() == 0) + { + costs = BigDecimal.ZERO; + } + else + { + p_Error = "Resubmit - No Costs for " + product.getName(); + log.log(Level.WARNING, p_Error); + return null; + } } } else @@ -525,7 +547,33 @@ public class Doc_InOut extends Doc MProduct product = line.getProduct(); if (!isReversal(line)) { - costs = line.getProductCosts(as, line.getAD_Org_ID(), false); // current costs + MInOutLine ioLine = (MInOutLine) line.getPO(); + I_M_RMALine rmaLine = ioLine.getM_RMALine(); + costs = rmaLine != null ? rmaLine.getAmt() : BigDecimal.ZERO; + I_M_InOutLine originalInOutLine = rmaLine != null ? rmaLine.getM_InOutLine() : null; + if (originalInOutLine != null && originalInOutLine.getC_OrderLine_ID() > 0) + { + MOrderLine originalOrderLine = (MOrderLine) originalInOutLine.getC_OrderLine(); + // Goodwill: Correct included Tax + int C_Tax_ID = originalOrderLine.getC_Tax_ID(); + if (originalOrderLine.isTaxIncluded() && C_Tax_ID != 0) + { + MTax tax = MTax.get(getCtx(), C_Tax_ID); + if (!tax.isZeroTax()) + { + int stdPrecision = MCurrency.getStdPrecision(getCtx(), originalOrderLine.getC_Currency_ID()); + BigDecimal costTax = tax.calculateTax(costs, true, stdPrecision); + if (log.isLoggable(Level.FINE)) log.fine("Costs=" + costs + " - Tax=" + costTax); + costs = costs.subtract(costTax); + } + } // correct included Tax + costs = costs.multiply(line.getQty()); + costs = costs.negate(); + } + else + { + costs = line.getProductCosts(as, line.getAD_Org_ID(), false); // current costs + } if (costs == null || costs.signum() == 0) { p_Error = "Resubmit - No Costs for " + product.getName(); @@ -535,7 +583,8 @@ public class Doc_InOut extends Doc } else { - costs = BigDecimal.ZERO; + //update below + costs = Env.ONE; } // NotInvoicedReceipt DR // Elaine 2008/06/26 @@ -596,7 +645,15 @@ public class Doc_InOut extends Doc return null; } } + + String costingError = createVendorRMACostDetail(as, line, costs); + if (!Util.isEmpty(costingError)) + { + p_Error = costingError; + return null; + } } + } // Purchasing Return else { @@ -613,4 +670,20 @@ public class Doc_InOut extends Doc return m_Reversal_ID !=0 && line.getReversalLine_ID() != 0; } + private String createVendorRMACostDetail(MAcctSchema as, DocLine line, BigDecimal costs) + { + BigDecimal tQty = line.getQty(); + BigDecimal tAmt = costs; + if (tAmt.signum() != tQty.signum()) + { + tAmt = tAmt.negate(); + } + if (!MCostDetail.createShipment(as, line.getAD_Org_ID(), line.getM_Product_ID(), + line.getM_AttributeSetInstance_ID(), line.get_ID(), 0, tAmt, tQty, + line.getDescription(), false, getTrxName())) + { + return "SaveError"; + } + return ""; + } } // Doc_InOut diff --git a/org.adempiere.base/src/org/compiere/acct/Doc_MatchInv.java b/org.adempiere.base/src/org/compiere/acct/Doc_MatchInv.java index cff6ff0c50..ef47927faa 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc_MatchInv.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc_MatchInv.java @@ -205,27 +205,9 @@ public class Doc_MatchInv extends Doc if (log.isLoggable(Level.FINE)) log.fine("Line Net Amt=0 - M_Product_ID=" + getM_Product_ID() + ",Qty=" + getQty() + ",InOutQty=" + m_receiptLine.getMovementQty()); - // Invoice Price Variance - BigDecimal ipv = dr.getSourceBalance().negate(); - if (ipv.signum() != 0) - { - MInvoice m_invoice = m_invoiceLine.getParent(); - int C_Currency_ID = m_invoice.getC_Currency_ID(); - FactLine pv = fact.createLine(null, - m_pc.getAccount(ProductCost.ACCTTYPE_P_IPV, as), - C_Currency_ID, ipv); - pv.setC_Activity_ID(m_invoiceLine.getC_Activity_ID()); - pv.setC_Campaign_ID(m_invoiceLine.getC_Campaign_ID()); - pv.setC_Project_ID(m_invoiceLine.getC_Project_ID()); - pv.setC_ProjectPhase_ID(m_invoiceLine.getC_ProjectPhase_ID()); - pv.setC_ProjectTask_ID(m_invoiceLine.getC_ProjectTask_ID()); - pv.setC_UOM_ID(m_invoiceLine.getC_UOM_ID()); - pv.setUser1_ID(m_invoiceLine.getUser1_ID()); - pv.setUser2_ID(m_invoiceLine.getUser2_ID()); - } - if (log.isLoggable(Level.FINE)) log.fine("IPV=" + ipv + "; Balance=" + fact.getSourceBalance()); - facts.add(fact); - return facts; + cr = fact.createLine (null, expense, as.getC_Currency_ID(), null, Env.ONE); + cr.setAmtAcctCr(BigDecimal.ZERO); + cr.setAmtSourceCr(BigDecimal.ZERO); } cr.setQty(getQty().negate()); temp = cr.getAcctBalance(); @@ -351,6 +333,8 @@ public class Doc_MatchInv extends Doc if (m_invoiceLine != null && m_invoiceLine.get_ID() > 0 && m_receiptLine != null && m_receiptLine.get_ID() > 0) { + MMatchInv matchInv = (MMatchInv)getPO(); + BigDecimal LineNetAmt = m_invoiceLine.getLineNetAmt(); BigDecimal multiplier = getQty() .divide(m_invoiceLine.getQtyInvoiced(), 12, BigDecimal.ROUND_HALF_UP) @@ -358,8 +342,6 @@ public class Doc_MatchInv extends Doc if (multiplier.compareTo(Env.ONE) != 0) LineNetAmt = LineNetAmt.multiply(multiplier); - // Source from Doc_MatchInv.createFacts(MAcctSchema) - // Cost Detail Record - data from Expense/IncClearing (CR) record // MZ Goodwill // Create Cost Detail Matched Invoice using Total Amount and Total Qty based on InvoiceLine MMatchInv[] mInv = MMatchInv.getInvoiceLine(getCtx(), m_invoiceLine.getC_InvoiceLine_ID(), getTrxName()); @@ -367,7 +349,7 @@ public class Doc_MatchInv extends Doc BigDecimal tAmt = Env.ZERO; for (int i = 0 ; i < mInv.length ; i++) { - if (mInv[i].isPosted() && mInv[i].getM_MatchInv_ID() != get_ID()) + if (mInv[i].isPosted() && mInv[i].getM_MatchInv_ID() != get_ID() && mInv[i].getM_AttributeSetInstance_ID() == matchInv.getM_AttributeSetInstance_ID()) { tQty = tQty.add(mInv[i].getQty()); multiplier = mInv[i].getQty() @@ -397,8 +379,7 @@ public class Doc_MatchInv extends Doc tQty = tQty.add(getQty().negate()); // Qty is set to negative value else tQty = tQty.add(getQty()); - - MMatchInv matchInv = (MMatchInv)getPO(); + // Set Total Amount and Total Quantity from Matched Invoice if (!MCostDetail.createInvoice(as, getAD_Org_ID(), getM_Product_ID(), matchInv.getM_AttributeSetInstance_ID(), diff --git a/org.adempiere.base/src/org/compiere/model/MColor.java b/org.adempiere.base/src/org/compiere/model/MColor.java index ae63a0900b..fb5958306b 100644 --- a/org.adempiere.base/src/org/compiere/model/MColor.java +++ b/org.adempiere.base/src/org/compiere/model/MColor.java @@ -34,7 +34,7 @@ public class MColor extends X_AD_Color /** * */ - private static final long serialVersionUID = 8672637038417465668L; + private static final long serialVersionUID = 3054697070898921956L; /** * Color Model @@ -48,6 +48,11 @@ public class MColor extends X_AD_Color if (AD_Color_ID == 0) setName("-/-"); } // MColor + + public MColor(Properties ctx, ResultSet rs, String trxName) + { + super (ctx, rs, trxName); + } /** * String Representation diff --git a/org.adempiere.base/src/org/compiere/model/MCost.java b/org.adempiere.base/src/org/compiere/model/MCost.java index 598d94e217..33a4633321 100644 --- a/org.adempiere.base/src/org/compiere/model/MCost.java +++ b/org.adempiere.base/src/org/compiere/model/MCost.java @@ -290,6 +290,8 @@ public class MCost extends X_M_Cost if (retValue == null || retValue.signum() == 0) retValue = getLastPOPrice(product, M_ASI_ID, Org_ID, as.getC_Currency_ID()); } + else if (MCostElement.COSTINGMETHOD_StandardCosting.equals(costingMethod)) + ; else if (MCostElement.COSTINGMETHOD_UserDefined.equals(costingMethod)) ; else @@ -1480,9 +1482,9 @@ public class MCost extends X_M_Cost public void setWeightedAverage (BigDecimal amt, BigDecimal qty) { //amount must follow the sign of qty - if (amt.signum() != 0 && amt.signum() != qty.signum()) + if (amt.signum() != 0 && qty.signum() != 0 && amt.signum() != qty.signum()) { - amt = amt.multiply(BigDecimal.valueOf(-1.00d)); + amt = amt.negate(); } if (getCurrentQty().add(qty).signum() < 0) diff --git a/org.adempiere.base/src/org/compiere/model/MCostDetail.java b/org.adempiere.base/src/org/compiere/model/MCostDetail.java index caa83f3bd8..735e4d46c4 100644 --- a/org.adempiere.base/src/org/compiere/model/MCostDetail.java +++ b/org.adempiere.base/src/org/compiere/model/MCostDetail.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Properties; import java.util.logging.Level; +import org.compiere.acct.Doc; import org.compiere.model.X_M_CostHistory; import org.compiere.util.CLogger; import org.compiere.util.DB; @@ -51,6 +52,12 @@ public class MCostDetail extends X_M_CostDetail */ private static final long serialVersionUID = -448632684360931078L; + private static final String INOUTLINE_DOCBASETYPE_SQL = + "SELECT c.DocBaseType From M_InOut io " + + "INNER JOIN M_InOutLine iol ON io.M_InOut_ID=iol.M_InOut_ID " + + "INNER JOIN C_DocType c ON io.C_DocType_ID=c.C_DocType_ID " + + "WHERE iol.M_InOutLine_ID=?"; + /** * Create New Order Cost Detail for Purchase Orders. * Called from Doc_MatchPO @@ -677,6 +684,20 @@ public class MCostDetail extends X_M_CostDetail return isSOTrx() && getM_InOutLine_ID() != 0; } // isShipment + /** + * @return true if return to vendor + */ + public boolean isVendorRMA() + { + if (!isSOTrx() && getM_InOutLine_ID() > 0) + { + String docBaseType = DB.getSQLValueString((String)null, + INOUTLINE_DOCBASETYPE_SQL, getM_InOutLine_ID()); + return Doc.DOCTYPE_MatShipment.equals(docBaseType); + } + return false; + } + /** * Is this a Delta Record (previously processed)? * @return true if delta is not null @@ -1036,22 +1057,26 @@ public class MCostDetail extends X_M_CostDetail || getPP_Cost_Collector_ID() != 0) { boolean addition = qty.signum() > 0; + boolean isVendorRMA = isVendorRMA(); // if (ce.isAverageInvoice()) { - if (addition) + if (!isVendorRMA) { - cost.setWeightedAverage(amt, qty); - //shouldn't accumulate reversal of customer shipment qty and amt - if (isShipment()) + if (addition) { - cost.setCumulatedQty(history.getOldCQty()); - cost.setCumulatedAmt(history.getOldCAmt()); + cost.setWeightedAverage(amt, qty); + //shouldn't accumulate reversal of customer shipment qty and amt + if (isShipment()) + { + cost.setCumulatedQty(history.getOldCQty()); + cost.setCumulatedAmt(history.getOldCAmt()); + } } + else + cost.setCurrentQty(cost.getCurrentQty().add(qty)); + if (log.isLoggable(Level.FINER)) log.finer("QtyAdjust - AverageInv - " + cost); } - else - cost.setCurrentQty(cost.getCurrentQty().add(qty)); - if (log.isLoggable(Level.FINER)) log.finer("QtyAdjust - AverageInv - " + cost); } else if (ce.isAveragePO()) { @@ -1059,51 +1084,63 @@ public class MCostDetail extends X_M_CostDetail { cost.setWeightedAverage(amt, qty); //shouldn't accumulate reversal of customer shipment qty and amt - if (isShipment()) + if (isShipment() && !isVendorRMA()) { cost.setCumulatedQty(history.getOldCQty()); cost.setCumulatedAmt(history.getOldCAmt()); } } else - cost.setCurrentQty(cost.getCurrentQty().add(qty)); + { + if (isVendorRMA) + { + cost.setWeightedAverage(amt, qty); + } + else + { + cost.setCurrentQty(cost.getCurrentQty().add(qty)); + } + } if (log.isLoggable(Level.FINER)) log.finer("QtyAdjust - AveragePO - " + cost); } else if (ce.isFifo() || ce.isLifo()) { - if (addition) + if (!isVendorRMA) { - // Real ASI - costing level Org - MCostQueue cq = MCostQueue.get(product, getM_AttributeSetInstance_ID(), - as, Org_ID, ce.getM_CostElement_ID(), get_TrxName()); - cq.setCosts(amt, qty, precision); - cq.saveEx(); + if (addition) + { + // Real ASI - costing level Org + MCostQueue cq = MCostQueue.get(product, getM_AttributeSetInstance_ID(), + as, Org_ID, ce.getM_CostElement_ID(), get_TrxName()); + cq.setCosts(amt, qty, precision); + cq.saveEx(); + } + else + { + // Adjust Queue - costing level Org/ASI + MCostQueue.adjustQty(product, M_ASI_ID, + as, Org_ID, ce, qty.negate(), get_TrxName()); + } + // Get Costs - costing level Org/ASI + MCostQueue[] cQueue = MCostQueue.getQueue(product, M_ASI_ID, + as, Org_ID, ce, get_TrxName()); + if (cQueue != null && cQueue.length > 0) + cost.setCurrentCostPrice(cQueue[0].getCurrentCostPrice()); + cost.setCurrentQty(cost.getCurrentQty().add(qty)); + if (log.isLoggable(Level.FINER)) log.finer("QtyAdjust - FiFo/Lifo - " + cost); } - else - { - // Adjust Queue - costing level Org/ASI - MCostQueue.adjustQty(product, M_ASI_ID, - as, Org_ID, ce, qty.negate(), get_TrxName()); - } - // Get Costs - costing level Org/ASI - MCostQueue[] cQueue = MCostQueue.getQueue(product, M_ASI_ID, - as, Org_ID, ce, get_TrxName()); - if (cQueue != null && cQueue.length > 0) - cost.setCurrentCostPrice(cQueue[0].getCurrentCostPrice()); - cost.setCurrentQty(cost.getCurrentQty().add(qty)); - if (log.isLoggable(Level.FINER)) log.finer("QtyAdjust - FiFo/Lifo - " + cost); } - else if (ce.isLastInvoice()) + else if (ce.isLastInvoice() && !isVendorRMA) { cost.setCurrentQty(cost.getCurrentQty().add(qty)); if (log.isLoggable(Level.FINER)) log.finer("QtyAdjust - LastInv - " + cost); } - else if (ce.isLastPOPrice()) + else if (ce.isLastPOPrice() && !isVendorRMA) { cost.setCurrentQty(cost.getCurrentQty().add(qty)); if (log.isLoggable(Level.FINER)) log.finer("QtyAdjust - LastPO - " + cost); } - else if (ce.isStandardCosting()) + else if (ce.isStandardCosting() && !isVendorRMA) { if (addition) { @@ -1123,7 +1160,7 @@ public class MCostDetail extends X_M_CostDetail } if (log.isLoggable(Level.FINER)) log.finer("QtyAdjust - Standard - " + cost); } - else if (ce.isUserDefined()) + else if (ce.isUserDefined() && !isVendorRMA) { // Interface if (addition) diff --git a/org.adempiere.base/src/org/compiere/model/MPaymentTransaction.java b/org.adempiere.base/src/org/compiere/model/MPaymentTransaction.java index 4b4960f566..8b83582648 100644 --- a/org.adempiere.base/src/org/compiere/model/MPaymentTransaction.java +++ b/org.adempiere.base/src/org/compiere/model/MPaymentTransaction.java @@ -39,7 +39,7 @@ public class MPaymentTransaction extends X_C_PaymentTransaction implements Proce /** * */ - private static final long serialVersionUID = 3136835982476528825L; + private static final long serialVersionUID = 8722189788479132158L; public MPaymentTransaction(Properties ctx, int C_PaymentTransaction_ID, String trxName) { super(ctx, C_PaymentTransaction_ID, trxName); @@ -656,4 +656,17 @@ public class MPaymentTransaction extends X_C_PaymentTransaction implements Proce return MPaymentTransaction.getAllIDs(Table_Name, whereClause.toString(), trxName); } + + /** + * String Representation + * @return info + */ + public String toString () + { + StringBuilder sb = new StringBuilder ("MPaymentTransaction["); + sb.append(get_ID()).append("-") + .append(",Receipt=").append(isReceipt()) + .append(",PayAmt=").append(getPayAmt()); + return sb.toString (); + } // toString } diff --git a/org.adempiere.base/src/org/compiere/model/MQualityTestResult.java b/org.adempiere.base/src/org/compiere/model/MQualityTestResult.java index 34364b0040..a4b3b73c47 100644 --- a/org.adempiere.base/src/org/compiere/model/MQualityTestResult.java +++ b/org.adempiere.base/src/org/compiere/model/MQualityTestResult.java @@ -1,5 +1,6 @@ package org.compiere.model; +import java.sql.ResultSet; import java.util.Properties; public class MQualityTestResult extends X_M_QualityTestResult { @@ -7,11 +8,16 @@ public class MQualityTestResult extends X_M_QualityTestResult { /** * */ - private static final long serialVersionUID = -4253026765149175778L; + private static final long serialVersionUID = -5529865718027582930L; public MQualityTestResult(Properties ctx, int M_QualityTestResult_ID, String trxName) { super(ctx, M_QualityTestResult_ID, trxName); } + public MQualityTestResult(Properties ctx, ResultSet rs, + String trxName) { + super (ctx, rs, trxName); + } + } diff --git a/org.adempiere.base/src/org/compiere/model/MReplication.java b/org.adempiere.base/src/org/compiere/model/MReplication.java index 5532d6af95..f2d2fca802 100644 --- a/org.adempiere.base/src/org/compiere/model/MReplication.java +++ b/org.adempiere.base/src/org/compiere/model/MReplication.java @@ -16,6 +16,7 @@ *****************************************************************************/ package org.compiere.model; +import java.sql.ResultSet; import java.sql.Timestamp; import java.util.Properties; @@ -30,7 +31,7 @@ public class MReplication extends X_AD_Replication /** * */ - private static final long serialVersionUID = -7363193371925559167L; + private static final long serialVersionUID = -562186299848949607L; /** * Load Constructor @@ -41,6 +42,11 @@ public class MReplication extends X_AD_Replication { super (ctx, AD_Replication_ID, trxName); } // MReplication + + public MReplication (Properties ctx, ResultSet rs, String trxName) + { + super (ctx, rs, trxName); + } /** * Public Access diff --git a/org.adempiere.base/src/org/compiere/model/MReplicationLog.java b/org.adempiere.base/src/org/compiere/model/MReplicationLog.java index fe760c3b7e..a8b6a00ad4 100644 --- a/org.adempiere.base/src/org/compiere/model/MReplicationLog.java +++ b/org.adempiere.base/src/org/compiere/model/MReplicationLog.java @@ -16,6 +16,7 @@ *****************************************************************************/ package org.compiere.model; +import java.sql.ResultSet; import java.util.Properties; /** @@ -30,7 +31,7 @@ public class MReplicationLog extends X_AD_Replication_Log /** * */ - private static final long serialVersionUID = -5188563816312329819L; + private static final long serialVersionUID = -8815834636981996509L; /** * Create new Log @@ -47,5 +48,10 @@ public class MReplicationLog extends X_AD_Replication_Log setIsReplicated(false); setP_Msg(P_Msg); } // MReplicationLog - + + public MReplicationLog(Properties ctx, ResultSet rs, String trxName) + { + super (ctx, rs, trxName); + } + } // MReplicationLog diff --git a/org.adempiere.base/src/org/compiere/model/MReplicationRun.java b/org.adempiere.base/src/org/compiere/model/MReplicationRun.java index 83636ff455..e07f203408 100644 --- a/org.adempiere.base/src/org/compiere/model/MReplicationRun.java +++ b/org.adempiere.base/src/org/compiere/model/MReplicationRun.java @@ -16,6 +16,7 @@ *****************************************************************************/ package org.compiere.model; +import java.sql.ResultSet; import java.sql.Timestamp; import java.util.Properties; @@ -30,7 +31,7 @@ public class MReplicationRun extends X_AD_Replication_Run /** * */ - private static final long serialVersionUID = 2619966943083677072L; + private static final long serialVersionUID = 7609847179225634980L; /** * Create new Run @@ -46,6 +47,11 @@ public class MReplicationRun extends X_AD_Replication_Run super.setIsReplicated (false); } // MReplicationRun + public MReplicationRun (Properties ctx, ResultSet rs, String trxName) + { + super (ctx, rs, trxName); + } + /** * Set Replication Flag * @param IsReplicated replicated diff --git a/org.adempiere.base/src/org/compiere/model/MReplicationStrategy.java b/org.adempiere.base/src/org/compiere/model/MReplicationStrategy.java index 94780d6e17..0be0afec5c 100644 --- a/org.adempiere.base/src/org/compiere/model/MReplicationStrategy.java +++ b/org.adempiere.base/src/org/compiere/model/MReplicationStrategy.java @@ -17,6 +17,7 @@ package org.compiere.model; +import java.sql.ResultSet; import java.util.List; import java.util.Properties; @@ -34,10 +35,10 @@ import org.compiere.util.CLogger; */ public class MReplicationStrategy extends X_AD_ReplicationStrategy { - /** - * - */ - private static final long serialVersionUID = -3017484140206284805L; + /** + * + */ + private static final long serialVersionUID = 7231926756021012730L; public static final int REPLICATION_TABLE =0; public static final int REPLICATION_DOCUMENT =1; @@ -56,7 +57,11 @@ public class MReplicationStrategy extends X_AD_ReplicationStrategy { public MReplicationStrategy(Properties ctx, int AD_ReplicationStrategy_ID, String trxName) { super(ctx, AD_ReplicationStrategy_ID, trxName); } - + + public MReplicationStrategy(Properties ctx, ResultSet rs, String trxName) { + super (ctx, rs, trxName); + } + /** * @return the list the X_AD_ReplicationTable */ diff --git a/org.adempiere.base/src/org/compiere/model/MSearchDefinition.java b/org.adempiere.base/src/org/compiere/model/MSearchDefinition.java index 11eb001765..45d0591068 100644 --- a/org.adempiere.base/src/org/compiere/model/MSearchDefinition.java +++ b/org.adempiere.base/src/org/compiere/model/MSearchDefinition.java @@ -47,7 +47,7 @@ public class MSearchDefinition extends X_AD_SearchDefinition { /** * */ - private static final long serialVersionUID = 2448668218372939766L; + private static final long serialVersionUID = -5366274782950561962L; /** Constant for the searchtype table */ public static final String SEARCHTYPE_TABLE = "T"; /** Constant for the searchtype query */ @@ -66,6 +66,10 @@ public class MSearchDefinition extends X_AD_SearchDefinition { public MSearchDefinition(Properties ctx, int AD_SearchDefinition_ID, String trxName) { super(ctx, AD_SearchDefinition_ID, trxName); } + + public MSearchDefinition(Properties ctx, ResultSet rs, String trxName) { + super (ctx, rs, trxName); + } /** * Returns all SearchDefinition objects with the given transaction code diff --git a/org.adempiere.base/src/org/compiere/print/MPrintColor.java b/org.adempiere.base/src/org/compiere/print/MPrintColor.java index e9b8df0e59..9d69c80124 100644 --- a/org.adempiere.base/src/org/compiere/print/MPrintColor.java +++ b/org.adempiere.base/src/org/compiere/print/MPrintColor.java @@ -18,6 +18,7 @@ package org.compiere.print; import java.awt.Color; import java.awt.SystemColor; +import java.sql.ResultSet; import java.util.Properties; import java.util.logging.Level; @@ -36,11 +37,10 @@ import org.compiere.util.Util; */ public class MPrintColor extends X_AD_PrintColor { - /** * */ - private static final long serialVersionUID = 8352503254165120016L; + private static final long serialVersionUID = -5611659311562283304L; /************************************************************************** * Create Color in Database and save @@ -138,6 +138,11 @@ public class MPrintColor extends X_AD_PrintColor if (AD_PrintColor_ID == 0) setIsDefault(false); } // MPrintColor + + public MPrintColor(Properties ctx, ResultSet rs, String trxName) + { + super (ctx, rs, trxName); + } /** Color cached */ private Color m_cacheColor = null; diff --git a/org.adempiere.base/src/org/compiere/print/MPrintFont.java b/org.adempiere.base/src/org/compiere/print/MPrintFont.java index 775b4f1daf..5b0d28dd54 100644 --- a/org.adempiere.base/src/org/compiere/print/MPrintFont.java +++ b/org.adempiere.base/src/org/compiere/print/MPrintFont.java @@ -18,6 +18,7 @@ package org.compiere.print; import java.awt.Font; import java.awt.GraphicsEnvironment; +import java.sql.ResultSet; import java.util.Iterator; import java.util.Map; import java.util.Properties; @@ -39,7 +40,7 @@ public class MPrintFont extends X_AD_PrintFont /** * */ - private static final long serialVersionUID = -4721840631004326810L; + private static final long serialVersionUID = -2986160498367260541L; /** * Constructor @@ -53,6 +54,11 @@ public class MPrintFont extends X_AD_PrintFont if (AD_PrintFont_ID == 0) setIsDefault(false); } // MPrintFont + + public MPrintFont(Properties ctx, ResultSet rs, String trxName) + { + super (ctx, rs, trxName); + } /** Font cached */ private Font m_cacheFont = null; diff --git a/org.adempiere.base/src/org/compiere/process/DocumentEngine.java b/org.adempiere.base/src/org/compiere/process/DocumentEngine.java index c85de31b8c..4a5fe8aeee 100644 --- a/org.adempiere.base/src/org/compiere/process/DocumentEngine.java +++ b/org.adempiere.base/src/org/compiere/process/DocumentEngine.java @@ -48,6 +48,7 @@ import org.compiere.model.PO; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; +import org.compiere.util.Util; import org.eevolution.model.I_DD_Order; import org.eevolution.model.I_HR_Process; import org.eevolution.model.I_PP_Cost_Collector; @@ -489,6 +490,12 @@ public class DocumentEngine implements DocAction return false; String error = DocumentEngine.postImmediate(Env.getCtx(), m_document.getAD_Client_ID(), m_document.get_Table_ID(), m_document.get_ID(), true, m_document.get_TrxName()); + if (ACTION_Post.equals(m_action)) { + // forced post via process - throw exception to inform the caller about the error + if (! Util.isEmpty(error)) { + throw new AdempiereException(error); + } + } return (error == null); } // postIt diff --git a/org.adempiere.base/src/org/compiere/report/MReportColumnSet.java b/org.adempiere.base/src/org/compiere/report/MReportColumnSet.java index 1e88219f45..9a148fdb8d 100644 --- a/org.adempiere.base/src/org/compiere/report/MReportColumnSet.java +++ b/org.adempiere.base/src/org/compiere/report/MReportColumnSet.java @@ -37,7 +37,7 @@ public class MReportColumnSet extends X_PA_ReportColumnSet /** * */ - private static final long serialVersionUID = 8636368829160472883L; + private static final long serialVersionUID = -3496781398287709753L; /** * Constructor @@ -54,6 +54,11 @@ public class MReportColumnSet extends X_PA_ReportColumnSet else loadColumns(); } // MReportColumnSet + + public MReportColumnSet (Properties ctx, ResultSet rs, String trxName) + { + super (ctx, rs, trxName); + } /** Contained Columns */ private MReportColumn[] m_columns = null; diff --git a/org.adempiere.base/src/org/compiere/report/MReportLineSet.java b/org.adempiere.base/src/org/compiere/report/MReportLineSet.java index b72160c9a5..5f85ffb10a 100644 --- a/org.adempiere.base/src/org/compiere/report/MReportLineSet.java +++ b/org.adempiere.base/src/org/compiere/report/MReportLineSet.java @@ -37,7 +37,7 @@ public class MReportLineSet extends X_PA_ReportLineSet /** * */ - private static final long serialVersionUID = -2540937629148624046L; + private static final long serialVersionUID = 6882950634644885097L; /** * Constructor @@ -54,6 +54,11 @@ public class MReportLineSet extends X_PA_ReportLineSet else loadLines(); } // MReportLineSet + + public MReportLineSet (Properties ctx, ResultSet rs, String trxName) + { + super (ctx, rs, trxName); + } /** Contained Lines */ private MReportLine[] m_lines = null; diff --git a/org.adempiere.base/src/org/compiere/util/Trx.java b/org.adempiere.base/src/org/compiere/util/Trx.java index 1d9e09b1fd..8c0a663739 100644 --- a/org.adempiere.base/src/org/compiere/util/Trx.java +++ b/org.adempiere.base/src/org/compiere/util/Trx.java @@ -22,10 +22,10 @@ import java.sql.Savepoint; import java.util.ArrayList; import java.util.Collection; import java.util.Date; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -63,16 +63,11 @@ public class Trx * @param createNew if false, null is returned if not found * @return Transaction or null */ - public static synchronized Trx get (String trxName, boolean createNew) + public static Trx get (String trxName, boolean createNew) { if (trxName == null || trxName.length() == 0) throw new IllegalArgumentException ("No Transaction Name"); - if (s_cache == null) - { - s_cache = new HashMap(10); - } - Trx retValue = (Trx)s_cache.get(trxName); if (retValue == null && createNew) { @@ -83,9 +78,9 @@ public class Trx } // get /** Transaction Cache */ - private static Map s_cache = null; // create change listener + private static final Map s_cache = new ConcurrentHashMap(); - private static Trx.TrxMonitor s_monitor = new Trx.TrxMonitor(); + private static final Trx.TrxMonitor s_monitor = new Trx.TrxMonitor(); private List listeners = new ArrayList(); @@ -171,7 +166,7 @@ public class Trx * @param createNew if true, create new connection if the trx does not have one created yet * @return connection */ - public Connection getConnection(boolean createNew) + public synchronized Connection getConnection(boolean createNew) { if (log.isLoggable(Level.ALL))log.log(Level.ALL, "Active=" + isActive() + ", Connection=" + m_connection); @@ -179,7 +174,7 @@ public class Trx { if (createNew) { - if (s_cache == null || !s_cache.containsKey(m_trxName)) + if (!s_cache.containsKey(m_trxName)) { new Exception("Illegal to getConnection for Trx that is not register.").printStackTrace(); return null; @@ -272,7 +267,7 @@ public class Trx * @param throwException if true, re-throws exception * @return true if success, false if failed or transaction already rollback */ - public boolean rollback(boolean throwException) throws SQLException + public synchronized boolean rollback(boolean throwException) throws SQLException { //local try @@ -351,7 +346,7 @@ public class Trx * @param throwException if true, re-throws exception * @return true if success **/ - public boolean commit(boolean throwException) throws SQLException + public synchronized boolean commit(boolean throwException) throws SQLException { //local try @@ -410,8 +405,7 @@ public class Trx */ public synchronized boolean close() { - if (s_cache != null) - s_cache.remove(getTrxName()); + s_cache.remove(getTrxName()); //local if (m_connection == null) @@ -459,7 +453,7 @@ public class Trx * @return Savepoint * @throws SQLException */ - public Savepoint setSavepoint(String name) throws SQLException { + public synchronized Savepoint setSavepoint(String name) throws SQLException { if (m_connection == null) getConnection(); @@ -479,7 +473,7 @@ public class Trx * @throws SQLException * @see {@link Connection#releaseSavepoint(Savepoint)} */ - public void releaseSavepoint(Savepoint savepoint) throws SQLException + public synchronized void releaseSavepoint(Savepoint savepoint) throws SQLException { if (DB.isOracle()) { @@ -519,9 +513,6 @@ public class Trx */ public static Trx[] getActiveTransactions() { - if (s_cache == null) - return new Trx[0]; - Collection collections = s_cache.values(); Trx[] trxs = new Trx[collections.size()]; collections.toArray(trxs); @@ -626,11 +617,15 @@ public class Trx * @param listener */ public void addTrxEventListener(TrxEventListener listener) { - listeners.add(listener); + synchronized (listeners) { + listeners.add(listener); + } } public boolean removeTrxEventListener(TrxEventListener listener) { - return listeners.remove(listener); + synchronized (listeners) { + return listeners.remove(listener); + } } static class TrxMonitor implements Runnable @@ -638,7 +633,7 @@ public class Trx public void run() { - if (Trx.s_cache != null && !Trx.s_cache.isEmpty()) + if (!Trx.s_cache.isEmpty()) { Trx[] trxs = Trx.s_cache.values().toArray(new Trx[0]); for(int i = 0; i < trxs.length; i++) diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/AdElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/AdElementHandler.java index 7d498452de..efed2fe277 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/AdElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/AdElementHandler.java @@ -56,7 +56,10 @@ public class AdElementHandler extends AbstractElementHandler { M_Element mElement = findPO(ctx, element); if (mElement == null) { - int id = findIdByColumn(ctx, X_AD_Element.Table_Name, X_AD_Element.COLUMNNAME_ColumnName, ColumnName, /*ignorecase=*/true); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + id = findIdByColumn(ctx, X_AD_Element.Table_Name, X_AD_Element.COLUMNNAME_ColumnName, ColumnName, /*ignorecase=*/true); + } mElement = new M_Element(ctx.ctx, id, getTrxName(ctx)); } List excludes = defaultExcludeList(X_AD_Element.Table_Name); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/AttachmentElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/AttachmentElementHandler.java index c9dd58bdd5..b0bddf7e79 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/AttachmentElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/AttachmentElementHandler.java @@ -64,7 +64,10 @@ public class AttachmentElementHandler extends AbstractElementHandler { return; } - int id = DB.getSQLValue(getTrxName(ctx), "SELECT AD_Attachment_ID FROM AD_Attachment WHERE Record_ID="+Record_ID+" AND AD_Table_ID="+AD_Table_ID); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + DB.getSQLValue(getTrxName(ctx), "SELECT AD_Attachment_ID FROM AD_Attachment WHERE Record_ID="+Record_ID+" AND AD_Table_ID="+AD_Table_ID); + } mAttachment = new MAttachment(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); if (mAttachment.is_new()) { mAttachment.setAD_Table_ID(AD_Table_ID); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ColumnElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ColumnElementHandler.java index 6e7227cd4a..80828f2952 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ColumnElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ColumnElementHandler.java @@ -73,7 +73,10 @@ public class ColumnElementHandler extends AbstractElementHandler { filler.setTableReference("AD_Table_ID"); tableid = mColumn.getAD_Table_ID(); } - int AD_Column_ID = findIdByColumnAndParentId(ctx, "AD_Column", "ColumnName", columnName, "AD_Table", tableid, /*ignorecase=*/true); + int AD_Column_ID = 0; + if (!hasUUIDKey(ctx, element)) { + AD_Column_ID = findIdByColumnAndParentId(ctx, "AD_Column", "ColumnName", columnName, "AD_Table", tableid, /*ignorecase=*/true); + } mColumn = new MColumn(ctx.ctx, AD_Column_ID > 0 ? AD_Column_ID : 0, getTrxName(ctx)); if (mColumn.getAD_Column_ID() == 0 && isOfficialId(element, "AD_Column_ID")) { mColumn.setAD_Column_ID(getIntValue(element, "AD_Column_ID")); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/DynValRuleElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/DynValRuleElementHandler.java index e87476484b..d18ee1bf5c 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/DynValRuleElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/DynValRuleElementHandler.java @@ -48,7 +48,10 @@ public class DynValRuleElementHandler extends AbstractElementHandler { X_AD_Val_Rule mValRule = findPO(ctx, element); if (mValRule == null) { - int id = findIdByColumn(ctx, "AD_Val_Rule", "Name", name); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + id = findIdByColumn(ctx, "AD_Val_Rule", "Name", name); + } mValRule = new X_AD_Val_Rule(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); } if (mValRule.getAD_Val_Rule_ID() == 0 && isOfficialId(element, "AD_Val_Rule_ID")) diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/EntityTypeElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/EntityTypeElementHandler.java index 693d10f4e0..0574b272c3 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/EntityTypeElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/EntityTypeElementHandler.java @@ -61,7 +61,10 @@ public class EntityTypeElementHandler extends AbstractElementHandler{ X_AD_EntityType m_EntityType = findPO(ctx, element); if (m_EntityType == null) { - int id = findIdByColumn(ctx, X_AD_EntityType.Table_Name, X_AD_EntityType.COLUMNNAME_Name, name, /*ignorecase=*/true); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + id = findIdByColumn(ctx, X_AD_EntityType.Table_Name, X_AD_EntityType.COLUMNNAME_Name, name, /*ignorecase=*/true); + } m_EntityType = new X_AD_EntityType(ctx.ctx, id, getTrxName(ctx)); } diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FieldElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FieldElementHandler.java index c4b29f82ba..32eb62667e 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FieldElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FieldElementHandler.java @@ -100,11 +100,14 @@ public class FieldElementHandler extends AbstractElementHandler { MField mField = findPO(ctx, element); if (mField == null) { - StringBuffer sqlB = new StringBuffer( - "select AD_Field_ID from AD_Field where AD_Column_ID = ") - .append(AD_Column_ID) - .append(" and AD_Tab_ID = ?"); - int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), tabid); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + StringBuffer sqlB = new StringBuffer( + "select AD_Field_ID from AD_Field where AD_Column_ID = ") + .append(AD_Column_ID) + .append(" and AD_Tab_ID = ?"); + id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), tabid); + } mField = new MField(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); if (mField.is_new()) { mField.setAD_Column_ID(AD_Column_ID); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FieldGroupElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FieldGroupElementHandler.java index 70d9b68879..4eb06680d0 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FieldGroupElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FieldGroupElementHandler.java @@ -58,7 +58,10 @@ public class FieldGroupElementHandler extends AbstractElementHandler { X_AD_FieldGroup fieldGroup = findPO(ctx, element); if (fieldGroup == null) { - int id = findIdByColumn(ctx, X_AD_FieldGroup.Table_Name, X_AD_FieldGroup.COLUMNNAME_Name, name); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + id = findIdByColumn(ctx, X_AD_FieldGroup.Table_Name, X_AD_FieldGroup.COLUMNNAME_Name, name); + } fieldGroup = new X_AD_FieldGroup(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); } PoFiller pf = new PoFiller(ctx, fieldGroup, element, this); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FormAccessElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FormAccessElementHandler.java index 25f2a78be3..d4f57ea683 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FormAccessElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FormAccessElementHandler.java @@ -66,10 +66,12 @@ public class FormAccessElementHandler extends AbstractElementHandler { return; } - Query query = new Query(ctx.ctx, "AD_Form_Access", "AD_Form_ID = ? AND AD_Role_ID = ?", getTrxName(ctx)); - po = query.setParameters(new Object[]{AD_Form_ID, AD_Role_ID}) - .setClient_ID() - .first(); + if (!hasUUIDKey(ctx, element)) { + Query query = new Query(ctx.ctx, "AD_Form_Access", "AD_Form_ID = ? AND AD_Role_ID = ?", getTrxName(ctx)); + po = query.setParameters(new Object[]{AD_Form_ID, AD_Role_ID}) + .setClient_ID() + .first(); + } if (po == null) { po = new MFormAccess(ctx.ctx, 0, getTrxName(ctx)); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FormElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FormElementHandler.java index a037691d60..0cf625922f 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FormElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FormElementHandler.java @@ -50,7 +50,10 @@ public class FormElementHandler extends AbstractElementHandler { MForm mForm = findPO(ctx, element); if (mForm == null) { String name = getStringValue(element, "Name"); - int id = findIdByName(ctx, "AD_Form", name); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + id = findIdByName(ctx, "AD_Form", name); + } mForm = new MForm(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); } PoFiller filler = new PoFiller(ctx, mForm, element, this); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ImpFormatElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ImpFormatElementHandler.java index dbc9538ea3..dda587d4d3 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ImpFormatElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ImpFormatElementHandler.java @@ -56,7 +56,10 @@ public class ImpFormatElementHandler extends AbstractElementHandler { X_AD_ImpFormat mImpFormat = findPO(ctx, element); if (mImpFormat == null) { - int id = findIdByName(ctx, "AD_ImpFormat", name); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + id = findIdByName(ctx, "AD_ImpFormat", name); + } mImpFormat = new X_AD_ImpFormat(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); } diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ImpFormatRowElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ImpFormatRowElementHandler.java index af9b51b9d3..653fed9b37 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ImpFormatRowElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ImpFormatRowElementHandler.java @@ -102,8 +102,11 @@ public class ImpFormatRowElementHandler extends AbstractElementHandler { } } - StringBuilder sqlB = new StringBuilder ("SELECT AD_ImpFormat_Row_ID FROM AD_ImpFormat_Row WHERE AD_Column_ID=? AND AD_ImpFormat_ID=?"); - int id = DB.getSQLValue(getTrxName(ctx),sqlB.toString(),columnId,impFormatId); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + StringBuilder sqlB = new StringBuilder ("SELECT AD_ImpFormat_Row_ID FROM AD_ImpFormat_Row WHERE AD_Column_ID=? AND AD_ImpFormat_ID=?"); + id = DB.getSQLValue(getTrxName(ctx),sqlB.toString(),columnId,impFormatId); + } mImpFormatRow = new X_AD_ImpFormat_Row(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); mImpFormatRow.setAD_Column_ID(columnId); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/MenuElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/MenuElementHandler.java index d5d93de1b1..b451809644 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/MenuElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/MenuElementHandler.java @@ -59,8 +59,11 @@ public class MenuElementHandler extends AbstractElementHandler { X_AD_Menu mMenu = findPO(ctx, element); if (mMenu == null) { - String menuName = getStringValue(element, "Name"); - int menuId = findIdByColumn(ctx, "AD_Menu", "Name", menuName); + int menuId = 0; + if (!hasUUIDKey(ctx, element)) { + String menuName = getStringValue(element, "Name"); + menuId = findIdByColumn(ctx, "AD_Menu", "Name", menuName); + } mMenu = new X_AD_Menu(ctx.ctx, menuId > 0 ? menuId : 0, getTrxName(ctx)); } PoFiller filler = new PoFiller(ctx, mMenu, element, this); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/MessageElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/MessageElementHandler.java index ffdf1b8c07..6250e729a2 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/MessageElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/MessageElementHandler.java @@ -46,9 +46,11 @@ public class MessageElementHandler extends AbstractElementHandler { if (isProcessElement(ctx.ctx, entitytype)) { MMessage mMessage = findPO(ctx, element); if (mMessage == null) { - String value = getStringValue(element, "Value"); - int id = findIdByColumn(ctx, "AD_Message", "value", value); - + int id = 0; + if (!hasUUIDKey(ctx, element)) { + String value = getStringValue(element, "Value"); + id = findIdByColumn(ctx, "AD_Message", "value", value); + } mMessage = new MMessage(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); } PoFiller filler = new PoFiller(ctx, mMessage, element, this); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ModelValidatorElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ModelValidatorElementHandler.java index e91ed49a96..b3c06d2cec 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ModelValidatorElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ModelValidatorElementHandler.java @@ -37,7 +37,10 @@ public class ModelValidatorElementHandler extends AbstractElementHandler{ X_AD_ModelValidator validator = findPO(ctx, element); if (validator == null) { - int id = findIdByColumn(ctx, X_AD_ModelValidator.Table_Name, X_AD_ModelValidator.COLUMNNAME_Name, name, /*ignorecase=*/true); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + id = findIdByColumn(ctx, X_AD_ModelValidator.Table_Name, X_AD_ModelValidator.COLUMNNAME_Name, name, /*ignorecase=*/true); + } validator = new X_AD_ModelValidator(ctx.ctx, id, getTrxName(ctx)); } List excludes = defaultExcludeList(X_AD_ModelValidator.Table_Name); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ModificationElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ModificationElementHandler.java index 2bc120c728..0a0e655921 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ModificationElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ModificationElementHandler.java @@ -52,7 +52,10 @@ public class ModificationElementHandler extends AbstractElementHandler{ X_AD_Modification modification = findPO(ctx, element); if (modification == null) { - int id = findIdByColumn(ctx, X_AD_Modification.Table_Name, X_AD_Modification.COLUMNNAME_Name, name, /*ignorecase=*/true); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + id = findIdByColumn(ctx, X_AD_Modification.Table_Name, X_AD_Modification.COLUMNNAME_Name, name, /*ignorecase=*/true); + } modification = new X_AD_Modification(ctx.ctx, id, getTrxName(ctx)); } List excludes = defaultExcludeList(X_AD_Modification.Table_Name); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/OrgRoleElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/OrgRoleElementHandler.java index bd60879237..4c35540c8e 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/OrgRoleElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/OrgRoleElementHandler.java @@ -60,10 +60,12 @@ public class OrgRoleElementHandler extends AbstractElementHandler { Element orgElement = element.properties.get("AD_Org_ID"); int orgId = ReferenceUtils.resolveReference(ctx.ctx, orgElement, getTrxName(ctx)); - Query query = new Query(ctx.ctx, "AD_Role_OrgAccess", "AD_Role_ID=? and AD_Org_ID=?", getTrxName(ctx)); - po = query.setParameters(new Object[]{roleId, orgId}) - .setClient_ID() - .first(); + if (!hasUUIDKey(ctx, element)) { + Query query = new Query(ctx.ctx, "AD_Role_OrgAccess", "AD_Role_ID=? and AD_Org_ID=?", getTrxName(ctx)); + po = query.setParameters(new Object[]{roleId, orgId}) + .setClient_ID() + .first(); + } if (po == null) { po = new X_AD_Role_OrgAccess(ctx.ctx, 0, getTrxName(ctx)); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/PrintFormatElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/PrintFormatElementHandler.java index d7c6ced3bc..529f48173d 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/PrintFormatElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/PrintFormatElementHandler.java @@ -55,8 +55,11 @@ public class PrintFormatElementHandler extends AbstractElementHandler { X_AD_PrintFormat mPrintFormat = findPO(ctx, element); if (mPrintFormat == null) { - String name = getStringValue(element, "Name"); - int id = findIdByColumn(ctx, "AD_PrintFormat", "Name", name); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + String name = getStringValue(element, "Name"); + id = findIdByColumn(ctx, "AD_PrintFormat", "Name", name); + } mPrintFormat = new X_AD_PrintFormat(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); } PoFiller filler = new PoFiller(ctx, mPrintFormat, element, this); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/PrintFormatItemElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/PrintFormatItemElementHandler.java index 8ab6dd648f..b0c14ca96d 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/PrintFormatItemElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/PrintFormatItemElementHandler.java @@ -64,8 +64,11 @@ public class PrintFormatItemElementHandler extends AbstractElementHandler { return; } - String name = getStringValue(element, "Name"); - int id = findIdByNameAndParentId(ctx, "AD_PrintFormatItem", name, "AD_PrintFormat", parentId); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + String name = getStringValue(element, "Name"); + id = findIdByNameAndParentId(ctx, "AD_PrintFormatItem", name, "AD_PrintFormat", parentId); + } mPrintFormatItem = new X_AD_PrintFormatItem(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); mPrintFormatItem.setAD_PrintFormat_ID(parentId); excludes.add(I_AD_PrintFormatItem.COLUMNNAME_AD_PrintFormat_ID); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/PrintPaperElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/PrintPaperElementHandler.java index f94b9b6ab2..c2a55c6049 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/PrintPaperElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/PrintPaperElementHandler.java @@ -46,9 +46,12 @@ public class PrintPaperElementHandler extends AbstractElementHandler { if (printPaper == null) { String printPaperName = getStringValue(element, "Name", excludes); - int id = findIdByName(ctx, "AD_PrintPaper", printPaperName); - + int id = 0; + if (!hasUUIDKey(ctx, element)) { + id = findIdByName(ctx, "AD_PrintPaper", printPaperName); + } printPaper = new X_AD_PrintPaper(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); + printPaper.setName(printPaperName); } PoFiller filler = new PoFiller(ctx, printPaper, element, this); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ProcessAccessElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ProcessAccessElementHandler.java index 08b0ce4db1..3cb567c9a4 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ProcessAccessElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ProcessAccessElementHandler.java @@ -66,9 +66,11 @@ public class ProcessAccessElementHandler extends AbstractElementHandler { element.unresolved = "AD_Process_ID " + (processElement.contents != null ? processElement.contents.toString() : ""); return; } - - Query query = new Query(ctx.ctx, "AD_Process_Access", "AD_Role_ID=? and AD_Process_ID=?", getTrxName(ctx)); - po = query.setParameters(new Object[]{roleid, processid}).first(); + + if (!hasUUIDKey(ctx, element)) { + Query query = new Query(ctx.ctx, "AD_Process_Access", "AD_Role_ID=? and AD_Process_ID=?", getTrxName(ctx)); + po = query.setParameters(new Object[]{roleid, processid}).first(); + } if (po == null) { po = new X_AD_Process_Access(ctx.ctx, 0, getTrxName(ctx)); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ProcessElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ProcessElementHandler.java index 25aa74dc57..a8c3aa38b4 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ProcessElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ProcessElementHandler.java @@ -62,7 +62,10 @@ public class ProcessElementHandler extends AbstractElementHandler { String value = getStringValue(element, "Value"); // Get New process. - int id = findIdByColumn(ctx, "AD_Process", "Value", value); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + id = findIdByColumn(ctx, "AD_Process", "Value", value); + } mProcess = new X_AD_Process(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); } diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ProcessParaElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ProcessParaElementHandler.java index 692c54b3d0..4975772e7b 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ProcessParaElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ProcessParaElementHandler.java @@ -69,7 +69,9 @@ public class ProcessParaElementHandler extends AbstractElementHandler { return; } - id = findIdByColumnAndParentId(ctx, "AD_Process_Para", "ColumnName", name, "AD_Process", masterId); + if (!hasUUIDKey(ctx, element)) { + id = findIdByColumnAndParentId(ctx, "AD_Process_Para", "ColumnName", name, "AD_Process", masterId); + } mProcessPara = new X_AD_Process_Para(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); mProcessPara.setAD_Process_ID(masterId); excludes.add(I_AD_Process_Para.COLUMNNAME_AD_Process_ID); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReferenceElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReferenceElementHandler.java index 0a7a19fe1a..e4f47aa047 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReferenceElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReferenceElementHandler.java @@ -60,7 +60,10 @@ public class ReferenceElementHandler extends AbstractElementHandler { X_AD_Reference mReference = findPO(ctx, element); if (mReference == null) { - int id = findIdByName(ctx, "AD_Reference", name); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + id = findIdByName(ctx, "AD_Reference", name); + } mReference = new X_AD_Reference(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); } List excludes = defaultExcludeList(X_AD_Reference.Table_Name); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReferenceListElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReferenceListElementHandler.java index 0fe4dffd66..96457752f2 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReferenceListElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReferenceListElementHandler.java @@ -59,7 +59,10 @@ public class ReferenceListElementHandler extends AbstractElementHandler { AD_Reference_ID = ReferenceUtils.resolveReference(ctx.ctx, referenceElement, getTrxName(ctx)); } - int AD_Ref_List_ID = findIdByColumnAndParentId(ctx, "AD_Ref_List", "Value", value, "AD_Reference", AD_Reference_ID); + int AD_Ref_List_ID = 0; + if (!hasUUIDKey(ctx, element)) { + AD_Ref_List_ID = findIdByColumnAndParentId(ctx, "AD_Ref_List", "Value", value, "AD_Reference", AD_Reference_ID); + } mRefList = new X_AD_Ref_List(ctx.ctx, AD_Ref_List_ID, getTrxName(ctx)); } diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReferenceTableElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReferenceTableElementHandler.java index 0563369cf8..4d14a92868 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReferenceTableElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReferenceTableElementHandler.java @@ -67,22 +67,26 @@ public class ReferenceTableElementHandler extends AbstractElementHandler { if (AD_Reference_ID <= 0 && isOfficialId(element, "AD_Reference_ID")) AD_Reference_ID = getIntValue(element, "AD_Reference_ID"); - String sql = "SELECT * FROM AD_Ref_Table WHERE AD_Reference_ID = ?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try { - pstmt = DB.prepareStatement(sql, getTrxName(ctx)); - pstmt.setInt(1, AD_Reference_ID); - rs = pstmt.executeQuery(); - if (rs.next()) { - refTable = new X_AD_Ref_Table(ctx.ctx, rs, getTrxName(ctx)); - } else { - refTable = new X_AD_Ref_Table(ctx.ctx, 0, getTrxName(ctx)); + if (!hasUUIDKey(ctx, element)) { + String sql = "SELECT * FROM AD_Ref_Table WHERE AD_Reference_ID = ?"; + PreparedStatement pstmt = null; + ResultSet rs = null; + try { + pstmt = DB.prepareStatement(sql, getTrxName(ctx)); + pstmt.setInt(1, AD_Reference_ID); + rs = pstmt.executeQuery(); + if (rs.next()) { + refTable = new X_AD_Ref_Table(ctx.ctx, rs, getTrxName(ctx)); + } else { + refTable = new X_AD_Ref_Table(ctx.ctx, 0, getTrxName(ctx)); + } + } catch (Exception e) { + throw new DatabaseAccessException(e.getLocalizedMessage(), e); + } finally { + DB.close(rs, pstmt); } - } catch (Exception e) { - throw new DatabaseAccessException(e.getLocalizedMessage(), e); - } finally { - DB.close(rs, pstmt); + } else { + refTable = new X_AD_Ref_Table(ctx.ctx, 0, getTrxName(ctx)); } } String action = refTable.is_new() ? "New" : "Update"; diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReportViewColElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReportViewColElementHandler.java index d48260fa19..fee37ccde9 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReportViewColElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReportViewColElementHandler.java @@ -90,7 +90,10 @@ public class ReportViewColElementHandler extends AbstractElementHandler { sql.append(" AND FunctionColumn = ?"); sql.append(" AND AD_ReportView_ID = ?"); - int id = DB.getSQLValue(getTrxName(ctx), sql.toString(), functionColumn, AD_ReportView_ID); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + id = DB.getSQLValue(getTrxName(ctx), sql.toString(), functionColumn, AD_ReportView_ID); + } mReportviewCol = new X_AD_ReportView_Col(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); mReportviewCol.setAD_ReportView_ID(AD_ReportView_ID); if (AD_Column_ID > 0) { diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReportViewElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReportViewElementHandler.java index 701a63edd4..d88fded70c 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReportViewElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ReportViewElementHandler.java @@ -57,8 +57,11 @@ public class ReportViewElementHandler extends AbstractElementHandler { X_AD_ReportView mReportview = findPO(ctx, element); if (mReportview == null) { - String name = getStringValue(element, "Name"); - int id = findIdByName(ctx, "AD_ReportView", name); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + String name = getStringValue(element, "Name"); + id = findIdByName(ctx, "AD_ReportView", name); + } mReportview = new X_AD_ReportView(ctx.ctx, id, getTrxName(ctx)); } PoFiller filler = new PoFiller(ctx, mReportview, element, this); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/RoleElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/RoleElementHandler.java index f9ddbecb66..535cb299ae 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/RoleElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/RoleElementHandler.java @@ -69,7 +69,10 @@ public class RoleElementHandler extends AbstractElementHandler { MRole mRole = findPO(ctx, element); if (mRole == null) { String name = getStringValue(element, "Name", excludes); - int id = findIdByName(ctx, "AD_Role", name); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + id = findIdByName(ctx, "AD_Role", name); + } mRole = new MRole(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); mRole.setName(name); } diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/TabElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/TabElementHandler.java index c4e8cffcae..516130bc66 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/TabElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/TabElementHandler.java @@ -85,11 +85,14 @@ public class TabElementHandler extends AbstractElementHandler { return; } - String sql = "SELECT AD_Tab_ID FROM AD_Tab where AD_Window_ID = ? " - + " AND Name = ?" - + " AND AD_Table_ID = ?"; - - int id = DB.getSQLValue(getTrxName(ctx), sql, windowId, name, tableId); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + String sql = "SELECT AD_Tab_ID FROM AD_Tab where AD_Window_ID = ? " + + " AND Name = ?" + + " AND AD_Table_ID = ?"; + + id = DB.getSQLValue(getTrxName(ctx), sql, windowId, name, tableId); + } mTab = new MTab(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); mTab.setAD_Table_ID(tableId); mTab.setName(name); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/TableElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/TableElementHandler.java index 7c1bc576ca..3627e22d7f 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/TableElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/TableElementHandler.java @@ -58,16 +58,18 @@ public class TableElementHandler extends AbstractElementHandler { MTable mTable = findPO(ctx, element); if (mTable == null) { + int id = 0; String tableName = getStringValue(element, "TableName", excludes); - - int id = packIn.getTableId(tableName); - if (id <= 0) { - id = findIdByColumn(ctx, "AD_Table", "TableName", tableName); - if (id > 0) - packIn.addTable(tableName, id); - } - if (id > 0 && isTableProcess(ctx, id)) { - return; + if (!hasUUIDKey(ctx, element)) { + id = packIn.getTableId(tableName); + if (id <= 0) { + id = findIdByColumn(ctx, "AD_Table", "TableName", tableName); + if (id > 0) + packIn.addTable(tableName, id); + } + if (id > 0 && isTableProcess(ctx, id)) { + return; + } } mTable = new MTable(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/TaskAccessElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/TaskAccessElementHandler.java index db069d9a6a..5b1a15cf93 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/TaskAccessElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/TaskAccessElementHandler.java @@ -67,8 +67,10 @@ public class TaskAccessElementHandler extends AbstractElementHandler { return; } - Query query = new Query(ctx.ctx, "AD_Task_Access", "AD_Role_ID=? and AD_Task_ID=?", getTrxName(ctx)); - po = query.setParameters(new Object[]{roleid, taskid}).first(); + if (!hasUUIDKey(ctx, element)) { + Query query = new Query(ctx.ctx, "AD_Task_Access", "AD_Role_ID=? and AD_Task_ID=?", getTrxName(ctx)); + po = query.setParameters(new Object[]{roleid, taskid}).first(); + } if (po == null){ po = new X_AD_Task_Access(ctx.ctx, 0, getTrxName(ctx)); po.setAD_Role_ID(roleid); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/TaskElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/TaskElementHandler.java index fdfdbd2325..5b20d96258 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/TaskElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/TaskElementHandler.java @@ -50,8 +50,11 @@ public class TaskElementHandler extends AbstractElementHandler { MTask mTask = findPO(ctx, element); if (mTask == null) { - String name = getStringValue(element, "Name"); - int id = findIdByName(ctx, "AD_Task", name); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + String name = getStringValue(element, "Name"); + id = findIdByName(ctx, "AD_Task", name); + } mTask = new MTask(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); } diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/UserRoleElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/UserRoleElementHandler.java index 9f6cabdc9b..5a1658f012 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/UserRoleElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/UserRoleElementHandler.java @@ -73,8 +73,10 @@ public class UserRoleElementHandler extends AbstractElementHandler { Element orgElement = element.properties.get(I_AD_User_Roles.COLUMNNAME_AD_Org_ID); orgid = ReferenceUtils.resolveReference(ctx.ctx, orgElement, getTrxName(ctx)); - Query query = new Query(ctx.ctx, "AD_User_Roles", "AD_User_ID = ? AND AD_Role_ID = ? AND AD_Org_ID = ?", getTrxName(ctx)); - po = query.setParameters(new Object[]{userid, roleid, orgid}).first(); + if (!hasUUIDKey(ctx, element)) { + Query query = new Query(ctx.ctx, "AD_User_Roles", "AD_User_ID = ? AND AD_Role_ID = ? AND AD_Org_ID = ?", getTrxName(ctx)); + po = query.setParameters(new Object[]{userid, roleid, orgid}).first(); + } if (po == null) { po = new X_AD_User_Roles(ctx.ctx, 0, getTrxName(ctx)); po.setAD_Org_ID(orgid); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WindowAccessElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WindowAccessElementHandler.java index f4820baeb4..502b87e836 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WindowAccessElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WindowAccessElementHandler.java @@ -66,8 +66,10 @@ public class WindowAccessElementHandler extends AbstractElementHandler { return; } - Query query = new Query(ctx.ctx, "AD_Window_Access", "AD_Role_ID=? and AD_Window_ID=?", getTrxName(ctx)); - po = query.setParameters(new Object[]{roleid, windowid}).first(); + if (!hasUUIDKey(ctx, element)) { + Query query = new Query(ctx.ctx, "AD_Window_Access", "AD_Role_ID=? and AD_Window_ID=?", getTrxName(ctx)); + po = query.setParameters(new Object[]{roleid, windowid}).first(); + } if (po == null) { po = new X_AD_Window_Access(ctx.ctx, 0, getTrxName(ctx)); po.setAD_Role_ID(roleid); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WindowElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WindowElementHandler.java index 196ec3becd..07310a3ff5 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WindowElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WindowElementHandler.java @@ -63,12 +63,14 @@ public class WindowElementHandler extends AbstractElementHandler { if (isProcessElement(ctx.ctx, entitytype)) { MWindow mWindow = findPO(ctx, element); if (mWindow == null) { + int id = 0; String name = getStringValue(element, "Name", excludes); - int id = findIdByName(ctx, "AD_Window", name); - if (id > 0 && windows.contains(id)) { - return; + if (!hasUUIDKey(ctx, element)) { + id = findIdByName(ctx, "AD_Window", name); + if (id > 0 && windows.contains(id)) { + return; + } } - mWindow = new MWindow(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); mWindow.setName(name); } else { diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WorkflowAccessElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WorkflowAccessElementHandler.java index 0a39808222..336912755d 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WorkflowAccessElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WorkflowAccessElementHandler.java @@ -67,8 +67,10 @@ public class WorkflowAccessElementHandler extends AbstractElementHandler { element.unresolved = "AD_Workflow_ID"; } - Query query = new Query(ctx.ctx, "AD_Workflow_Access", "AD_Role_ID=? and AD_Workflow_ID=?", getTrxName(ctx)); - po = query.setParameters(new Object[]{roleid, workflowid}).first(); + if (!hasUUIDKey(ctx, element)) { + Query query = new Query(ctx.ctx, "AD_Workflow_Access", "AD_Role_ID=? and AD_Workflow_ID=?", getTrxName(ctx)); + po = query.setParameters(new Object[]{roleid, workflowid}).first(); + } if (po == null) { po = new MWorkflowAccess(ctx.ctx, 0, getTrxName(ctx)); po.setAD_Role_ID(roleid); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WorkflowElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WorkflowElementHandler.java index 458f297c5a..c888a367ff 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WorkflowElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WorkflowElementHandler.java @@ -63,11 +63,14 @@ public class WorkflowElementHandler extends AbstractElementHandler { MWorkflow mWorkflow = findPO(ctx, element); if (mWorkflow == null) { + int id = 0; String workflowValue = getStringValue(element, "Value", excludes); - int id = findIdByColumn(ctx, "AD_Workflow", "Value", workflowValue); - if (id > 0 && workflows.contains(id)) { - element.skip = true; - return; + if (!hasUUIDKey(ctx, element)) { + id = findIdByColumn(ctx, "AD_Workflow", "Value", workflowValue); + if (id > 0 && workflows.contains(id)) { + element.skip = true; + return; + } } mWorkflow = new MWorkflow(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WorkflowNodeElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WorkflowNodeElementHandler.java index 6a409717e7..3618687714 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WorkflowNodeElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WorkflowNodeElementHandler.java @@ -74,10 +74,12 @@ public class WorkflowNodeElementHandler extends AbstractElementHandler { } String workflowNodeValue = getStringValue(element, "Value", excludes); - StringBuilder sqlB = new StringBuilder( + int id = 0; + if (!hasUUIDKey(ctx, element)) { + StringBuilder sqlB = new StringBuilder( "SELECT AD_WF_Node_ID FROM AD_WF_Node WHERE AD_Workflow_ID=? and Value =?"); - - int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), workflowId, workflowNodeValue); + id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), workflowId, workflowNodeValue); + } mWFNode = new MWFNode(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); mWFNode.setValue(workflowNodeValue); mWFNode.setAD_Workflow_ID(workflowId); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WorkflowNodeNextConditionElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WorkflowNodeNextConditionElementHandler.java index fd92a9494c..b7479f50a2 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WorkflowNodeNextConditionElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WorkflowNodeNextConditionElementHandler.java @@ -78,9 +78,12 @@ public class WorkflowNodeNextConditionElementHandler extends return; } - int seqNo = getIntValue(element, "SeqNo"); - String sql = "SELECT AD_WF_NextCondition_ID FROM AD_WF_NextCondition WHERE AD_WF_NodeNext_ID =? AND SeqNo=?"; - int id = DB.getSQLValue(getTrxName(ctx), sql, new Object[] {wfNodeNextId, seqNo}); + int id = 0; + if (!hasUUIDKey(ctx, element)) { + int seqNo = getIntValue(element, "SeqNo"); + String sql = "SELECT AD_WF_NextCondition_ID FROM AD_WF_NextCondition WHERE AD_WF_NodeNext_ID =? AND SeqNo=?"; + id = DB.getSQLValue(getTrxName(ctx), sql, new Object[] {wfNodeNextId, seqNo}); + } mWFNodeNextCondition = new MWFNextCondition(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx)); mWFNodeNextCondition.setAD_WF_NodeNext_ID(wfNodeNextId); diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WorkflowNodeNextElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WorkflowNodeNextElementHandler.java index 02e5a90ffa..bbe80bfda9 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WorkflowNodeNextElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/WorkflowNodeNextElementHandler.java @@ -94,7 +94,10 @@ public class WorkflowNodeNextElementHandler extends AbstractElementHandler { return; } - int AD_WF_NodeNext_ID = DB.getSQLValue(getTrxName(ctx), "SELECT AD_WF_NodeNext_ID FROM AD_WF_NodeNext WHERE AD_WF_Node_ID=? and AD_WF_NEXT_ID =?", wfNodeId, AD_WF_Next_ID); + int AD_WF_NodeNext_ID = 0; + if (!hasUUIDKey(ctx, element)) { + AD_WF_NodeNext_ID = DB.getSQLValue(getTrxName(ctx), "SELECT AD_WF_NodeNext_ID FROM AD_WF_NodeNext WHERE AD_WF_Node_ID=? and AD_WF_NEXT_ID =?", wfNodeId, AD_WF_Next_ID); + } mWFNodeNext = new MWFNodeNext(ctx.ctx, AD_WF_NodeNext_ID, getTrxName(ctx)); mWFNodeNext.setAD_WF_Node_ID(wfNodeId); diff --git a/org.adempiere.pipo/src/org/adempiere/pipo2/AbstractElementHandler.java b/org.adempiere.pipo/src/org/adempiere/pipo2/AbstractElementHandler.java index b6655eeff3..11862d0340 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo2/AbstractElementHandler.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo2/AbstractElementHandler.java @@ -574,7 +574,25 @@ public abstract class AbstractElementHandler implements ElementHandler { } return po; } + + protected boolean hasUUIDKey(PIPOContext ctx, Element element) { + String tableName = element.getElementValue(); + String uuidColumn = PO.getUUIDColumnName(tableName); + String uuid = element.properties.get(uuidColumn).contents.toString(); + return (uuid != null && uuid.trim().length() == 36); + } + protected String getUUIDKey(PIPOContext ctx, Element element) { + String tableName = element.getElementValue(); + String uuidColumn = PO.getUUIDColumnName(tableName); + if (element.properties.containsKey(uuidColumn)) { + String uuid = element.properties.get(uuidColumn).contents.toString(); + if (uuid != null && uuid.trim().length() == 36) + return uuid.trim(); + } + return null; + } + /** * * @param atts diff --git a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AdempiereActivator.java b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AdempiereActivator.java index c2bb3b7721..dee2f98b30 100644 --- a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AdempiereActivator.java +++ b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AdempiereActivator.java @@ -81,7 +81,7 @@ public class AdempiereActivator implements BundleActivator, ServiceTrackerCustom String where = "Name=? AND PK_Version LIKE ?"; Query q = new Query(Env.getCtx(), X_AD_Package_Imp.Table_Name, - where.toString(), trxName); + where.toString(), null); q.setParameters(new Object[] { getName(), version + "%" }); X_AD_Package_Imp pkg = q.first(); if (pkg == null) { diff --git a/org.adempiere.replication.server/src/org/adempiere/server/rpl/imp/ReplicationServerFactory.java b/org.adempiere.replication.server/src/org/adempiere/server/rpl/imp/ReplicationServerFactory.java index 9a29c4ee09..59ba473e00 100644 --- a/org.adempiere.replication.server/src/org/adempiere/server/rpl/imp/ReplicationServerFactory.java +++ b/org.adempiere.replication.server/src/org/adempiere/server/rpl/imp/ReplicationServerFactory.java @@ -9,14 +9,13 @@ import java.util.Properties; import org.adempiere.server.IServerFactory; import org.compiere.model.MIMPProcessor; -import org.compiere.server.AdempiereServer; import org.compiere.server.ReplicationProcessor; /** * @author hengsin * */ -public class ReplicationServerFactory implements IServerFactory { +public class ReplicationServerFactory implements IServerFactory { /** * default constructor @@ -28,17 +27,21 @@ public class ReplicationServerFactory implements IServerFactory { * @see org.adempiere.server.IServerFactory#create() */ @Override - public AdempiereServer[] create(Properties ctx) { - List list = new ArrayList(); + public ReplicationProcessor[] create(Properties ctx) { + List list = new ArrayList(); MIMPProcessor[] importModels = MIMPProcessor.getActive(ctx); - for (int i = 0; i < importModels.length; i++) + for (MIMPProcessor lp : importModels) { - MIMPProcessor lp = importModels[i]; - AdempiereServer server = new ReplicationProcessor(lp); + ReplicationProcessor server = new ReplicationProcessor(lp); list.add(server); } - AdempiereServer[] servers = list.toArray(new AdempiereServer[0]); + ReplicationProcessor[] servers = list.toArray(new ReplicationProcessor[0]); return servers; } + @Override + public Class getProcessorClass() { + return MIMPProcessor.class; + } + } diff --git a/org.adempiere.replication.server/src/org/compiere/server/ReplicationProcessor.java b/org.adempiere.replication.server/src/org/compiere/server/ReplicationProcessor.java index 39be155dd3..a86279ab57 100644 --- a/org.adempiere.replication.server/src/org/compiere/server/ReplicationProcessor.java +++ b/org.adempiere.replication.server/src/org/compiere/server/ReplicationProcessor.java @@ -48,18 +48,17 @@ import org.compiere.model.MIMPProcessorLog; public class ReplicationProcessor extends AdempiereServer { /** Last Summary */ - private StringBuffer m_summary = new StringBuffer(); + protected StringBuffer m_summary = new StringBuffer(); /** Client info */ - @SuppressWarnings("unused") - private MClient m_client = null; + protected MClient m_client = null; - private MIMPProcessor mImportProcessor = null; + protected MIMPProcessor mImportProcessor = null; /** * flag showing if process is working! */ - private boolean isProcessRunning = false; + protected boolean isProcessRunning = false; /*protected ReplicationProcessor(MIMPProcessor model, int initialNap) { @@ -75,10 +74,10 @@ public class ReplicationProcessor extends AdempiereServer { }*/ public ReplicationProcessor(AdempiereProcessor model, int initialNap) { - super (model, initialNap); - mImportProcessor = (MIMPProcessor)model; - m_client = MClient.get(mImportProcessor.getCtx(), mImportProcessor.getAD_Client_ID()); -} + super (model, initialNap); + mImportProcessor = (MIMPProcessor)model; + m_client = MClient.get(mImportProcessor.getCtx(), mImportProcessor.getAD_Client_ID()); + } public ReplicationProcessor(AdempiereProcessor model) { super (model, 30); mImportProcessor =(MIMPProcessor)model; diff --git a/org.adempiere.server/.project b/org.adempiere.server/.project index 2ea4fe630b..3b30177424 100644 --- a/org.adempiere.server/.project +++ b/org.adempiere.server/.project @@ -20,6 +20,11 @@ + + org.eclipse.pde.ds.core.builder + + + org.eclipse.jdt.core.javanature diff --git a/org.adempiere.server/META-INF/MANIFEST.MF b/org.adempiere.server/META-INF/MANIFEST.MF index 2a64795b6c..fb1bb1f0cc 100644 --- a/org.adempiere.server/META-INF/MANIFEST.MF +++ b/org.adempiere.server/META-INF/MANIFEST.MF @@ -32,4 +32,8 @@ Import-Package: javax.jms;version="1.1.0", org.restlet.service, org.restlet.util Export-Package: org.adempiere.server, - org.compiere.server + org.compiere.ldap, + org.compiere.server, + org.idempiere.server.factory +Bundle-ActivationPolicy: lazy +Service-Component: OSGI-INF/acctprocessorfactory.xml, OSGI-INF/alertprocessorfactory.xml, OSGI-INF/ldapprocessorfactory.xml, OSGI-INF/requestprocessorfactory.xml, OSGI-INF/schedulerfactory.xml, OSGI-INF/workflowprocessorfactory.xml diff --git a/org.adempiere.server/OSGI-INF/acctprocessorfactory.xml b/org.adempiere.server/OSGI-INF/acctprocessorfactory.xml new file mode 100644 index 0000000000..ab965f7a41 --- /dev/null +++ b/org.adempiere.server/OSGI-INF/acctprocessorfactory.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/org.adempiere.server/OSGI-INF/alertprocessorfactory.xml b/org.adempiere.server/OSGI-INF/alertprocessorfactory.xml new file mode 100644 index 0000000000..ef40ea2b28 --- /dev/null +++ b/org.adempiere.server/OSGI-INF/alertprocessorfactory.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/org.adempiere.server/OSGI-INF/ldapprocessorfactory.xml b/org.adempiere.server/OSGI-INF/ldapprocessorfactory.xml new file mode 100644 index 0000000000..7373533582 --- /dev/null +++ b/org.adempiere.server/OSGI-INF/ldapprocessorfactory.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/org.adempiere.server/OSGI-INF/requestprocessorfactory.xml b/org.adempiere.server/OSGI-INF/requestprocessorfactory.xml new file mode 100644 index 0000000000..edd62584bb --- /dev/null +++ b/org.adempiere.server/OSGI-INF/requestprocessorfactory.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/org.adempiere.server/OSGI-INF/schedulerfactory.xml b/org.adempiere.server/OSGI-INF/schedulerfactory.xml new file mode 100644 index 0000000000..4947ceef93 --- /dev/null +++ b/org.adempiere.server/OSGI-INF/schedulerfactory.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/org.adempiere.server/OSGI-INF/workflowprocessorfactory.xml b/org.adempiere.server/OSGI-INF/workflowprocessorfactory.xml new file mode 100644 index 0000000000..e1c53aa8f1 --- /dev/null +++ b/org.adempiere.server/OSGI-INF/workflowprocessorfactory.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/org.adempiere.server/build.properties b/org.adempiere.server/build.properties index 2510288944..2eee8015ad 100644 --- a/org.adempiere.server/build.properties +++ b/org.adempiere.server/build.properties @@ -20,12 +20,19 @@ bin.includes = META-INF/,\ standard.css,\ webstart.jpg,\ zip.gif,\ - plugin.xml -bin.excludes = src/**,\ - .settings/**,\ - .classpath,\ - .project,\ - build.properties + plugin.xml,\ + OSGI-INF/acctprocessorfactory.xml,\ + OSGI-INF/alertprocessorfactory.xml,\ + OSGI-INF/ldapprocessorfactory.xml,\ + OSGI-INF/requestprocessorfactory.xml,\ + OSGI-INF/schedulerfactory.xml,\ + OSGI-INF/workflowprocessorfactory.xml,\ + OSGI-INF/ +output.. = build/classes/ source.. = src/main/server/,\ src/main/servlet/ -output.. = build/classes/ +bin.excludes = src/**,\ + .settings/**,\ + .classpath,\ + .project,\ + build.properties diff --git a/org.adempiere.server/src/main/server/org/adempiere/server/IServerFactory.java b/org.adempiere.server/src/main/server/org/adempiere/server/IServerFactory.java index 0f3fb37610..3373273e5c 100644 --- a/org.adempiere.server/src/main/server/org/adempiere/server/IServerFactory.java +++ b/org.adempiere.server/src/main/server/org/adempiere/server/IServerFactory.java @@ -15,6 +15,7 @@ package org.adempiere.server; import java.util.Properties; +import org.compiere.model.AdempiereProcessor; import org.compiere.server.AdempiereServer; /** @@ -22,8 +23,18 @@ import org.compiere.server.AdempiereServer; * @author hengsin * */ -public interface IServerFactory { +public interface IServerFactory { - // Class implementing this method must take into account if the server can be ran on this IP - public AdempiereServer[] create (Properties ctx); + /** + * @param ctx + * @return list of AdempiereServer + */ + public S[] create (Properties ctx); + + /** + * The Adempiere Server Manager will used this to avoid running duplicate server for the same + * AdempiereProcessor model. + * @return Fully qualified AdempiereProcessor model class name + */ + public Class getProcessorClass(); } diff --git a/org.adempiere.server/src/main/server/org/compiere/ldap/LdapProcessor.java b/org.adempiere.server/src/main/server/org/compiere/ldap/LdapProcessor.java index 173a093e20..9f34cb1a33 100644 --- a/org.adempiere.server/src/main/server/org/compiere/ldap/LdapProcessor.java +++ b/org.adempiere.server/src/main/server/org/compiere/ldap/LdapProcessor.java @@ -46,13 +46,13 @@ public class LdapProcessor extends AdempiereServer } // LdapProcessor /** The Concrete Model */ - private MLdapProcessor m_model = null; + protected MLdapProcessor m_model = null; /** Last Summary */ - private StringBuffer m_summary = new StringBuffer(); + protected StringBuffer m_summary = new StringBuffer(); /** Server Socket */ - private ServerSocket m_serverSocket = null; + protected ServerSocket m_serverSocket = null; /** Counter */ - private int m_counter = 0; + protected int m_counter = 0; /** diff --git a/org.adempiere.server/src/main/server/org/compiere/server/AcctProcessor.java b/org.adempiere.server/src/main/server/org/compiere/server/AcctProcessor.java index d55381e212..7e51963cab 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/AcctProcessor.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/AcctProcessor.java @@ -56,13 +56,13 @@ public class AcctProcessor extends AdempiereServer } // AcctProcessor /** The Concrete Model */ - private MAcctProcessor m_model = null; + protected MAcctProcessor m_model = null; /** Last Summary */ - private StringBuffer m_summary = new StringBuffer(); + protected StringBuffer m_summary = new StringBuffer(); /** Client onfo */ - private MClient m_client = null; + protected MClient m_client = null; /** Accounting Schemata */ - private MAcctSchema[] m_ass = null; + protected MAcctSchema[] m_ass = null; /** * Work diff --git a/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServer.java b/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServer.java index bdd8e2c77c..4afb642e17 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServer.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServer.java @@ -20,22 +20,15 @@ import java.sql.Timestamp; import java.util.Properties; import java.util.logging.Level; -import org.compiere.ldap.LdapProcessor; import org.compiere.model.AdempiereProcessor; import org.compiere.model.AdempiereProcessor2; import org.compiere.model.AdempiereProcessorLog; -import org.compiere.model.MAcctProcessor; -import org.compiere.model.MAlertProcessor; import org.compiere.model.MClient; -import org.compiere.model.MLdapProcessor; -import org.compiere.model.MRequestProcessor; import org.compiere.model.MSchedule; -import org.compiere.model.MScheduler; import org.compiere.model.MSystem; import org.compiere.util.CLogger; import org.compiere.util.Env; import org.compiere.util.TimeUtil; -import org.compiere.wf.MWorkflowProcessor; /** * Adempiere Server Base @@ -45,31 +38,6 @@ import org.compiere.wf.MWorkflowProcessor; */ public abstract class AdempiereServer implements Runnable { - /** - * Create New Server Thead - * @param model model - * @return server tread or null - */ - public static AdempiereServer create (AdempiereProcessor model) - { - if (! isOKtoRunOnIP(model)) - return null; - if (model instanceof MRequestProcessor) - return new RequestProcessor ((MRequestProcessor)model); - if (model instanceof MWorkflowProcessor) - return new WorkflowProcessor ((MWorkflowProcessor)model); - if (model instanceof MAcctProcessor) - return new AcctProcessor ((MAcctProcessor)model); - if (model instanceof MAlertProcessor) - return new AlertProcessor ((MAlertProcessor)model); - if (model instanceof MScheduler) - return new Scheduler ((MScheduler)model); - if (model instanceof MLdapProcessor) - return new LdapProcessor((MLdapProcessor)model); - // - throw new IllegalArgumentException("Unknown Processor"); - } // create - /************************************************************************** * Server Base Class diff --git a/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServerMgr.java b/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServerMgr.java index 32f5ca73da..4b057eeaff 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServerMgr.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServerMgr.java @@ -27,15 +27,10 @@ import java.util.logging.Level; import org.adempiere.base.Service; import org.adempiere.server.IServerFactory; import org.compiere.Adempiere; -import org.compiere.model.MAcctProcessor; -import org.compiere.model.MAlertProcessor; -import org.compiere.model.MLdapProcessor; -import org.compiere.model.MRequestProcessor; -import org.compiere.model.MScheduler; +import org.compiere.model.AdempiereProcessor; import org.compiere.model.MSession; import org.compiere.util.CLogger; import org.compiere.util.Env; -import org.compiere.wf.MWorkflowProcessor; /** * Adempiere Server Manager @@ -105,100 +100,36 @@ public class AdempiereServerMgr * Start Environment * @return true if started */ + @SuppressWarnings("rawtypes") public boolean startServers() { log.info(""); int noServers = 0; m_servers=new ArrayList(); - // Accounting - MAcctProcessor[] acctModels = MAcctProcessor.getActive(m_ctx); - for (int i = 0; i < acctModels.length; i++) - { - MAcctProcessor pModel = acctModels[i]; - AdempiereServer server = AdempiereServer.create(pModel); - if (server != null) { -// server.start(); -// server.setPriority(Thread.NORM_PRIORITY-2); - m_servers.add(new ServerWrapper(server)); - } - } - // Request - MRequestProcessor[] requestModels = MRequestProcessor.getActive(m_ctx); - for (int i = 0; i < requestModels.length; i++) - { - MRequestProcessor pModel = requestModels[i]; - AdempiereServer server = AdempiereServer.create(pModel); - if (server != null) { -// server.start(); -// server.setPriority(Thread.NORM_PRIORITY-2); - m_servers.add(new ServerWrapper(server)); - } - } - // Workflow - MWorkflowProcessor[] workflowModels = MWorkflowProcessor.getActive(m_ctx); - for (int i = 0; i < workflowModels.length; i++) - { - MWorkflowProcessor pModel = workflowModels[i]; - AdempiereServer server = AdempiereServer.create(pModel); - if (server != null) { -// server.start(); -// server.setPriority(Thread.NORM_PRIORITY-2); - m_servers.add(new ServerWrapper(server)); - } - } - // Alert - MAlertProcessor[] alertModels = MAlertProcessor.getActive(m_ctx); - for (int i = 0; i < alertModels.length; i++) - { - MAlertProcessor pModel = alertModels[i]; - AdempiereServer server = AdempiereServer.create(pModel); - if (server != null) { -// server.start(); -// server.setPriority(Thread.NORM_PRIORITY-2); - m_servers.add(new ServerWrapper(server)); - } - } - // Scheduler - MScheduler[] schedulerModels = MScheduler.getActive(m_ctx); - for (int i = 0; i < schedulerModels.length; i++) - { - MScheduler pModel = schedulerModels[i]; - AdempiereServer server = AdempiereServer.create(pModel); - if (server != null) { -// server.start(); -// server.setPriority(Thread.NORM_PRIORITY-2); - m_servers.add(new ServerWrapper(server)); - } - } - // LDAP - MLdapProcessor[] ldapModels = MLdapProcessor.getActive(m_ctx); - for (int i = 0; i < ldapModels.length; i++) - { - MLdapProcessor lp = ldapModels[i]; - AdempiereServer server = AdempiereServer.create(lp); - if (server != null) { -// server.start(); -// server.setPriority(Thread.NORM_PRIORITY-1); - m_servers.add(new ServerWrapper(server)); - } - } //osgi server List serverFactoryList = Service.locator().list(IServerFactory.class).getServices(); if (serverFactoryList != null && !serverFactoryList.isEmpty()) { + List processed = new ArrayList(); for(IServerFactory factory : serverFactoryList ) { - AdempiereServer[] servers = factory.create(m_ctx); - if (servers != null && servers.length > 0) + String name = factory.getProcessorClass().getName(); + if (!processed.contains(name)) { - for (AdempiereServer server : servers) + processed.add(name); + AdempiereServer[] servers = factory.create(m_ctx); + if (servers != null && servers.length > 0) { -// server.start(); -// server.setPriority(Thread.NORM_PRIORITY-1); - m_servers.add(new ServerWrapper(server)); - } - } + for (AdempiereServer server : servers) + { + AdempiereProcessor model = server.getModel(); + if (AdempiereServer.isOKtoRunOnIP(model)) { + m_servers.add(new ServerWrapper(server)); + } + } + } + } } } diff --git a/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java b/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java index d0da2a0fa7..94b6277ec5 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java @@ -72,13 +72,13 @@ public class AlertProcessor extends AdempiereServer } // AlertProcessor /** The Concrete Model */ - private MAlertProcessor m_model = null; + protected MAlertProcessor m_model = null; /** Last Summary */ - private StringBuffer m_summary = new StringBuffer(); + protected StringBuffer m_summary = new StringBuffer(); /** Last Error Msg */ - private StringBuffer m_errors = new StringBuffer(); + protected StringBuffer m_errors = new StringBuffer(); /** Client info */ - private MClient m_client = null; + protected MClient m_client = null; /** * Work @@ -119,7 +119,7 @@ public class AlertProcessor extends AdempiereServer * @param alert alert * @return true if processed */ - private boolean processAlert (MAlert alert) + protected boolean processAlert (MAlert alert) { if (!alert.isValid()) return false; @@ -240,7 +240,7 @@ public class AlertProcessor extends AdempiereServer * @param attachments * @return how many email were sent */ - private int notifyUsers(Collection users, String subject, String message, Collection attachments) + protected int notifyUsers(Collection users, String subject, String message, Collection attachments) { int countMail = 0; for (int user_id : users) { @@ -289,7 +289,7 @@ public class AlertProcessor extends AdempiereServer * @return data * @throws Exception */ - private ArrayList> getData (String sql, String trxName) throws Exception + protected ArrayList> getData (String sql, String trxName) throws Exception { ArrayList> data = new ArrayList>(); PreparedStatement pstmt = null; @@ -351,7 +351,7 @@ public class AlertProcessor extends AdempiereServer * @return list of rows & values * @throws Exception */ - private String getPlainTextReport(MAlertRule rule, String sql, String trxName, Collection attachments) + protected String getPlainTextReport(MAlertRule rule, String sql, String trxName, Collection attachments) throws Exception { StringBuilder result = new StringBuilder(); @@ -407,7 +407,7 @@ public class AlertProcessor extends AdempiereServer * @return summary message to be added into mail content * @throws Exception */ - private String getExcelReport(MAlertRule rule, String sql, String trxName, Collection attachments) + protected String getExcelReport(MAlertRule rule, String sql, String trxName, Collection attachments) throws Exception { ArrayList> data = getData(sql, trxName); diff --git a/org.adempiere.server/src/main/server/org/compiere/server/EMailProcessor.java b/org.adempiere.server/src/main/server/org/compiere/server/EMailProcessor.java index 9dd5e44496..b8784359b9 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/EMailProcessor.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/EMailProcessor.java @@ -69,30 +69,30 @@ public class EMailProcessor } // EMail /** EMail Host Parameter */ - private String m_host = null; + protected String m_host = null; /** EMail User Parameter */ - private String m_user = null; + protected String m_user = null; /** Password Parameter */ - private String m_pass = null; + protected String m_pass = null; /** Session */ - private Session m_session = null; + protected Session m_session = null; /** Store */ - private Store m_store = null; + protected Store m_store = null; /** Logger */ protected CLogger log = CLogger.getCLogger(getClass()); /** Process Error */ - private static final int ERROR = 0; + protected static final int ERROR = 0; /** Process Request */ - private static final int REQUEST = 1; + protected static final int REQUEST = 1; /** Process Workflow */ - private static final int WORKFLOW = 2; + protected static final int WORKFLOW = 2; /** Process Delivery Confirm */ - private static final int DELIVERY = 9; + protected static final int DELIVERY = 9; /** * Process Messages in InBox @@ -130,7 +130,7 @@ public class EMailProcessor * @return Session * @throws Exception */ - private Session getSession() throws Exception + protected Session getSession() throws Exception { if (m_session != null) return m_session; @@ -155,7 +155,7 @@ public class EMailProcessor * @return Store * @throws Exception */ - private Store getStore() throws Exception + protected Store getStore() throws Exception { if (m_store != null) return m_store; @@ -177,7 +177,7 @@ public class EMailProcessor * @return number of processed * @throws Exception */ - private int processInBox() throws Exception + protected int processInBox() throws Exception { // Folder Folder folder; @@ -276,7 +276,7 @@ public class EMailProcessor * @return Type of Message * @throws Exception */ - private int processMessage (Message msg) throws Exception + protected int processMessage (Message msg) throws Exception { dumpEnvelope (msg); dumpBody (msg); @@ -301,7 +301,7 @@ public class EMailProcessor * @param msg message * @return subject or "" */ - private String getSubject (Message msg) + protected String getSubject (Message msg) { try { @@ -321,7 +321,7 @@ public class EMailProcessor * @param msg Message * @return message or "" */ - private String getMessage (Part msg) + protected String getMessage (Part msg) { StringBuilder sb = new StringBuilder(); try @@ -406,7 +406,7 @@ public class EMailProcessor * @param msg message * @return delivery info or null */ - private String getDeliveryReport (Part msg) + protected String getDeliveryReport (Part msg) { try { @@ -451,7 +451,7 @@ public class EMailProcessor * @return info or null * @throws Exception */ - private String getDeliveredReportDetail (Part part) throws Exception + protected String getDeliveredReportDetail (Part part) throws Exception { Object content = part.getContent(); if (content == null) @@ -504,7 +504,7 @@ public class EMailProcessor * @param m message * @throws Exception */ - private void dumpEnvelope(Message m) throws Exception + protected void dumpEnvelope(Message m) throws Exception { printOut("-----------------------------------------------------------------"); Address[] a; @@ -613,7 +613,7 @@ public class EMailProcessor * @param p * @throws Exception */ - private void dumpBody (Part p) throws Exception + protected void dumpBody (Part p) throws Exception { // http://www.iana.org/assignments/media-types/ printOut("================================================================="); @@ -688,7 +688,7 @@ public class EMailProcessor * Print * @param s string */ - private static void printOut(String s) + protected static void printOut(String s) { // System.out.print(indentStr.substring(0, level * 2)); System.out.println(s); diff --git a/org.adempiere.server/src/main/server/org/compiere/server/RequestProcessor.java b/org.adempiere.server/src/main/server/org/compiere/server/RequestProcessor.java index 18dff4c00c..290222801c 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/RequestProcessor.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/RequestProcessor.java @@ -57,11 +57,11 @@ public class RequestProcessor extends AdempiereServer } // RequestProcessor /** The Concrete Model */ - private MRequestProcessor m_model = null; + protected MRequestProcessor m_model = null; /** Last Summary */ - private StringBuffer m_summary = new StringBuffer(); + protected StringBuffer m_summary = new StringBuffer(); /** Client onfo */ - private MClient m_client = null; + protected MClient m_client = null; /************************************************************************** * Do the actual Work @@ -90,7 +90,7 @@ public class RequestProcessor extends AdempiereServer * Process requests. * Scheduled - are they due? */ - private void processRequests () + protected void processRequests () { /** * Due Requests @@ -368,7 +368,7 @@ public class RequestProcessor extends AdempiereServer * @param AD_Message message * @return true if sent */ - private boolean sendEmail (MRequest request, String AD_Message) + protected boolean sendEmail (MRequest request, String AD_Message) { // Alert: Request {0} overdue String subject = Msg.getMsg(m_client.getAD_Language(), AD_Message, @@ -382,7 +382,7 @@ public class RequestProcessor extends AdempiereServer * @param request request * @return true if saved */ - private boolean escalate (MRequest request) + protected boolean escalate (MRequest request) { // Get Supervisor MUser supervisor = request.getSalesRep(); // self @@ -424,7 +424,7 @@ public class RequestProcessor extends AdempiereServer /************************************************************************** * Process Request Status */ - private void processStatus() + protected void processStatus() { int count = 0; // Requests with status with after timeout @@ -482,7 +482,7 @@ public class RequestProcessor extends AdempiereServer /** * Create ECR */ - private void processECR() + protected void processECR() { // Get Requests with Request Type-AutoChangeRequest and Group with info String sql = "SELECT * FROM R_Request r " @@ -543,7 +543,7 @@ public class RequestProcessor extends AdempiereServer /************************************************************************** * Create Reauest / Updates from EMail */ - private void processEMail () + protected void processEMail () { // m_summary.append("Mail #").append(count) // .append(" - "); @@ -553,7 +553,7 @@ public class RequestProcessor extends AdempiereServer /************************************************************************** * Allocate Sales Rep */ - private void findSalesRep () + protected void findSalesRep () { int changed = 0; int notFound = 0; @@ -614,7 +614,7 @@ public class RequestProcessor extends AdempiereServer * @param request request * @return SalesRep_ID user */ - private int findSalesRep (MRequest request) + protected int findSalesRep (MRequest request) { String QText = request.getSummary(); if (QText == null) diff --git a/org.adempiere.server/src/main/server/org/compiere/server/Scheduler.java b/org.adempiere.server/src/main/server/org/compiere/server/Scheduler.java index 5d96657b73..ebfb545f66 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/Scheduler.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/Scheduler.java @@ -69,14 +69,14 @@ public class Scheduler extends AdempiereServer } // Scheduler /** The Concrete Model */ - private MScheduler m_model = null; + protected MScheduler m_model = null; /** Last Summary */ - private StringBuffer m_summary = new StringBuffer(); + protected StringBuffer m_summary = new StringBuffer(); /** Transaction */ - private Trx m_trx = null; + protected Trx m_trx = null; // ctx for the report/process - Properties m_schedulerctx = new Properties(); + protected Properties m_schedulerctx = new Properties(); /** * Work @@ -148,7 +148,7 @@ public class Scheduler extends AdempiereServer * @return summary * @throws Exception */ - private String runProcess(MProcess process) throws Exception + protected String runProcess(MProcess process) throws Exception { if (log.isLoggable(Level.INFO)) log.info(process.toString()); @@ -278,7 +278,7 @@ public class Scheduler extends AdempiereServer return pi.getSummary(); } // runProcess - private int getAD_User_ID() { + protected int getAD_User_ID() { int AD_User_ID; if (m_model.getSupervisor_ID() > 0) AD_User_ID = m_model.getSupervisor_ID(); @@ -295,7 +295,7 @@ public class Scheduler extends AdempiereServer * Fill Parameter * @param pInstance process instance */ - private void fillParameter(MPInstance pInstance) + protected void fillParameter(MPInstance pInstance) { MSchedulerPara[] sParams = m_model.getParameters (false); MPInstancePara[] iParams = pInstance.getParameters(); diff --git a/org.adempiere.server/src/main/server/org/compiere/server/WorkflowProcessor.java b/org.adempiere.server/src/main/server/org/compiere/server/WorkflowProcessor.java index 9939007cb1..bcab69ed55 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/WorkflowProcessor.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/WorkflowProcessor.java @@ -61,11 +61,11 @@ public class WorkflowProcessor extends AdempiereServer } // WorkflowProcessor /** The Concrete Model */ - private MWorkflowProcessor m_model = null; + protected MWorkflowProcessor m_model = null; /** Last Summary */ - private StringBuffer m_summary = new StringBuffer(); + protected StringBuffer m_summary = new StringBuffer(); /** Client onfo */ - private MClient m_client = null; + protected MClient m_client = null; /** * Work @@ -90,7 +90,7 @@ public class WorkflowProcessor extends AdempiereServer /** * Continue Workflow After Sleep */ - private void wakeup() + protected void wakeup() { String sql = "SELECT * " + "FROM AD_WF_Activity a " @@ -135,7 +135,7 @@ public class WorkflowProcessor extends AdempiereServer /** * Set/Increase Priority dynamically */ - private void dynamicPriority() + protected void dynamicPriority() { // suspened activities with dynamic priority node String sql = "SELECT * " @@ -184,7 +184,7 @@ public class WorkflowProcessor extends AdempiereServer /** * Send Alerts */ - private void sendAlerts() + protected void sendAlerts() { // Alert over Priority if (m_model.getAlertOverPriority() > 0) @@ -350,7 +350,7 @@ public class WorkflowProcessor extends AdempiereServer * @param toSupervisor true if to Supervisor * @return number of mails sent */ - private int sendEmail (MWFActivity activity, String AD_Message, + protected int sendEmail (MWFActivity activity, String AD_Message, boolean toProcess, boolean toSupervisor) { if (m_client == null || m_client.getAD_Client_ID() != activity.getAD_Client_ID()) @@ -429,7 +429,7 @@ public class WorkflowProcessor extends AdempiereServer * @param pdf optional pdf * @return number of mail sent */ - private int sendAlertToResponsible (MWFResponsible responsible, + protected int sendAlertToResponsible (MWFResponsible responsible, ArrayList list, MWFProcess process, String subject, String message, File pdf) { diff --git a/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultAcctProcessorFactory.java b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultAcctProcessorFactory.java new file mode 100644 index 0000000000..db63a121c5 --- /dev/null +++ b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultAcctProcessorFactory.java @@ -0,0 +1,56 @@ +/****************************************************************************** + * Copyright (C) 2013 Heng Sin Low * + * Copyright (C) 2013 Trek Global * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.idempiere.server.factory; + +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import org.adempiere.server.IServerFactory; +import org.compiere.model.MAcctProcessor; +import org.compiere.server.AcctProcessor; + +/** + * @author hengsin + * + */ +public class DefaultAcctProcessorFactory implements IServerFactory { + + /** + * default constructor + */ + public DefaultAcctProcessorFactory() { + } + + /* (non-Javadoc) + * @see org.adempiere.server.IServerFactory#create(java.util.Properties) + */ + @Override + public AcctProcessor[] create(Properties ctx) { + MAcctProcessor[] acctModels = MAcctProcessor.getActive(ctx); + List list = new ArrayList(); + for (MAcctProcessor pModel : acctModels) + { + AcctProcessor processor = new AcctProcessor(pModel); + list.add(processor); + } + return list.toArray(new AcctProcessor[0]); + } + + @Override + public Class getProcessorClass() { + return MAcctProcessor.class; + } + +} diff --git a/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultAlertProcessorFactory.java b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultAlertProcessorFactory.java new file mode 100644 index 0000000000..58d31341c6 --- /dev/null +++ b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultAlertProcessorFactory.java @@ -0,0 +1,53 @@ +/****************************************************************************** + * Copyright (C) 2013 Heng Sin Low * + * Copyright (C) 2013 Trek Global * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.idempiere.server.factory; + +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import org.adempiere.server.IServerFactory; +import org.compiere.model.MAlertProcessor; +import org.compiere.server.AlertProcessor; + +/** + * @author hengsin + * + */ +public class DefaultAlertProcessorFactory implements IServerFactory { + + /** + * + */ + public DefaultAlertProcessorFactory() { + } + + @Override + public AlertProcessor[] create(Properties ctx) { + MAlertProcessor[] alertModels = MAlertProcessor.getActive(ctx); + List list = new ArrayList(); + for (MAlertProcessor pModel : alertModels) + { + AlertProcessor server = new AlertProcessor(pModel); + list.add(server); + } + return list.toArray(new AlertProcessor[0]); + } + + @Override + public Class getProcessorClass() { + return MAlertProcessor.class; + } + +} diff --git a/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultLDAPProcessorFactory.java b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultLDAPProcessorFactory.java new file mode 100644 index 0000000000..11201a53d9 --- /dev/null +++ b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultLDAPProcessorFactory.java @@ -0,0 +1,52 @@ +/****************************************************************************** + * Copyright (C) 2013 Heng Sin Low * + * Copyright (C) 2013 Trek Global * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.idempiere.server.factory; + +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import org.adempiere.server.IServerFactory; +import org.compiere.ldap.LdapProcessor; +import org.compiere.model.MLdapProcessor; + +/** + * @author hengsin + * + */ +public class DefaultLDAPProcessorFactory implements IServerFactory { + + /** + * default constructor + */ + public DefaultLDAPProcessorFactory() { + } + + @Override + public LdapProcessor[] create(Properties ctx) { + MLdapProcessor[] ldapModels = MLdapProcessor.getActive(ctx); + List list = new ArrayList(); + for (MLdapProcessor lp : ldapModels) + { + LdapProcessor server = new LdapProcessor(lp); + list.add(server); + } + return list.toArray(new LdapProcessor[0]); + } + + @Override + public Class getProcessorClass() { + return MLdapProcessor.class; + } +} diff --git a/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultRequestProcessorFactory.java b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultRequestProcessorFactory.java new file mode 100644 index 0000000000..0801a62a19 --- /dev/null +++ b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultRequestProcessorFactory.java @@ -0,0 +1,55 @@ +/****************************************************************************** + * Copyright (C) 2013 Heng Sin Low * + * Copyright (C) 2013 Trek Global * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.idempiere.server.factory; + +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import org.adempiere.server.IServerFactory; +import org.compiere.model.MRequestProcessor; +import org.compiere.server.RequestProcessor; + +/** + * @author hengsin + * + */ +public class DefaultRequestProcessorFactory implements IServerFactory { + + /** + * + */ + public DefaultRequestProcessorFactory() { + } + + /* (non-Javadoc) + * @see org.adempiere.server.IServerFactory#create(java.util.Properties) + */ + @Override + public RequestProcessor[] create(Properties ctx) { + MRequestProcessor[] requestModels = MRequestProcessor.getActive(ctx); + List list = new ArrayList(); + for (MRequestProcessor pModel : requestModels) + { + RequestProcessor processor = new RequestProcessor(pModel); + list.add(processor); + } + return list.toArray(new RequestProcessor[0]); + } + + @Override + public Class getProcessorClass() { + return MRequestProcessor.class; + } +} diff --git a/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultSchedulerFactory.java b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultSchedulerFactory.java new file mode 100644 index 0000000000..052f28e5be --- /dev/null +++ b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultSchedulerFactory.java @@ -0,0 +1,53 @@ +/****************************************************************************** + * Copyright (C) 2013 Heng Sin Low * + * Copyright (C) 2013 Trek Global * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.idempiere.server.factory; + +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import org.adempiere.server.IServerFactory; +import org.compiere.model.MScheduler; +import org.compiere.server.Scheduler; + +/** + * @author hengsin + * + */ +public class DefaultSchedulerFactory implements IServerFactory { + + /** + * default constructor + */ + public DefaultSchedulerFactory() { + } + + @Override + public Scheduler[] create(Properties ctx) { + MScheduler[] schedulerModels = MScheduler.getActive(ctx); + List list = new ArrayList(); + for (MScheduler pModel : schedulerModels) + { + Scheduler server = new Scheduler(pModel); + list.add(server); + } + return list.toArray(new Scheduler[0]); + } + + @Override + public Class getProcessorClass() { + return MScheduler.class; + } + +} diff --git a/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultWorkflowProcessorFactory.java b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultWorkflowProcessorFactory.java new file mode 100644 index 0000000000..98dea95fc3 --- /dev/null +++ b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultWorkflowProcessorFactory.java @@ -0,0 +1,58 @@ +/****************************************************************************** + * Copyright (C) 2013 Heng Sin Low * + * Copyright (C) 2013 Trek Global * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.idempiere.server.factory; + +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import org.adempiere.server.IServerFactory; +import org.compiere.server.WorkflowProcessor; +import org.compiere.wf.MWorkflowProcessor; + +/** + * @author hengsin + * + */ +public class DefaultWorkflowProcessorFactory implements IServerFactory { + + /** + * + */ + public DefaultWorkflowProcessorFactory() { + } + + /* (non-Javadoc) + * @see org.adempiere.server.IServerFactory#create(java.util.Properties) + */ + @Override + public WorkflowProcessor[] create(Properties ctx) { + MWorkflowProcessor[] workflowModels = MWorkflowProcessor.getActive(ctx); + List list = new ArrayList(); + for (MWorkflowProcessor pModel : workflowModels) + { + WorkflowProcessor server = new WorkflowProcessor(pModel); + list.add(server); + } + return list.toArray(new WorkflowProcessor[0]); + } + + /* (non-Javadoc) + * @see org.adempiere.server.IServerFactory#getServerModelClass() + */ + @Override + public Class getProcessorClass() { + return MWorkflowProcessor.class; + } +} diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WPAPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WPAPanel.java index 3c634120d7..80cd9a458d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WPAPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WPAPanel.java @@ -67,7 +67,7 @@ public class WPAPanel extends Panel implements EventListener Grid grid = new Grid(); appendChild(grid); int gh = options != null && options.chartHeight > 0 ? options.chartHeight+60 : 180; - grid.setHeight(m_goals.length * gh / 2 + "px"); + grid.setHeight((m_goals.length + (m_goals.length % 2)) * gh / 2 + "px"); grid.makeNoStrip(); Rows rows = new Rows(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Paymentbox.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Paymentbox.java index 0ea3242833..0cd4b59c38 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Paymentbox.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Paymentbox.java @@ -21,7 +21,6 @@ import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; import org.zkoss.zul.Comboitem; import org.zkoss.zul.Div; -import org.zkoss.zul.Hlayout; /** * @@ -52,20 +51,17 @@ public class Paymentbox extends Div { } private void initComponents() { - Hlayout hlayout = new Hlayout(); - this.appendChild(hlayout); - hlayout.setHflex("1"); combo = new Combobox(); - hlayout.appendChild(combo); - combo.setHflex("1"); + appendChild(combo); + combo.setHflex("0"); btn = new Button(); btn.setTabindex(-1); btn.setSclass("editor-button"); btn.setHflex("0"); - hlayout.appendChild(btn); + appendChild(btn); - LayoutUtils.addSclass("editor-box", this); + LayoutUtils.addSclass("payment-rule-editor", this); } public Combobox getCombobox() { @@ -81,19 +77,31 @@ public class Paymentbox extends Div { } public void setEnabled(boolean isComboEnabled, boolean isBtnEnabled) { - combo.setReadonly(!isComboEnabled); + combo.setEnabled(isComboEnabled); + combo.setButtonVisible(isComboEnabled); btn.setEnabled(isBtnEnabled); btn.setVisible(isBtnEnabled); if (isBtnEnabled) { - btn.setSclass("editor-button"); - btn.setParent(this.getFirstChild()); + if (btn.getParent() != combo.getParent()) + btn.setParent(combo.getParent()); } else { - btn.detach(); + if (btn.getParent() != null) + btn.detach(); + } + if (isComboEnabled) { + LayoutUtils.removeSclass("editor-input-disd", combo); + } else { + LayoutUtils.addSclass("editor-input-disd", combo); + } + if (btn.getParent() == null) { + LayoutUtils.addSclass("no-button", combo); + } else { + LayoutUtils.removeSclass("no-button", combo); } } public boolean isEnabled() { - return !combo.isReadonly(); + return combo.isEnabled(); } public boolean addEventListener(String evtnm, EventListener listener) { @@ -110,5 +118,5 @@ public class Paymentbox extends Div { public Button getButton() { return btn; - } + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPRecentItems.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPRecentItems.java index 7d34098857..5060ddfa06 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPRecentItems.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPRecentItems.java @@ -91,6 +91,7 @@ public class DPRecentItems extends DashboardPanel implements EventListener= maxri) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DashboardController.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DashboardController.java index 5d5ba96013..feb947e2c2 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DashboardController.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DashboardController.java @@ -407,7 +407,7 @@ public class DashboardController implements EventListener { } dashboardLayout.appendChild(maximizedHolder); maximizedHolder.appendChild(panel); - panel.setSclass(""); + panel.setSclass("dashboard-widget dashboard-widget-max"); } else { maximizedHolder.detach(); panel.detach(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/BroadcastMessageWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/BroadcastMessageWindow.java index 4657dc5e8c..e076a7f9af 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/BroadcastMessageWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/BroadcastMessageWindow.java @@ -171,7 +171,6 @@ public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup south.setHeight("22%"); //south.setWidth("45%"); acknowledged.setParent(rightCell); - acknowledged.setVisible(false); //acknowledged.setHflex("6"); acknowledged.setLabel(Msg.getMsg(Env.getCtx(),"Acknowledge")); acknowledged.addEventListener("onClick", this); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/CustomizeGridViewPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/CustomizeGridViewPanel.java index a902e0e7cb..eaab2fb368 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/CustomizeGridViewPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/CustomizeGridViewPanel.java @@ -231,7 +231,7 @@ public class CustomizeGridViewPanel extends Panel Div div = new Div(); div.setStyle("margin-top:5px"); div.appendChild(chkSaveWidth); - chkSaveWidth.setLabel("Save Column Width"); + chkSaveWidth.setLabel(Msg.getMsg(Env.getCtx(), "SaveColumnWidth")); centerPanel.appendChild(div); center.appendChild(centerPanel); @@ -296,14 +296,21 @@ public class CustomizeGridViewPanel extends Panel { yesModel.removeAllElements(); noModel.removeAllElements(); - - String sql = "SELECT t.AD_Field_ID,t.Name,t.SeqNoGrid,AD_Client_ID, AD_Org_ID FROM AD_Field t WHERE t.AD_Tab_ID=? AND t.IsDisplayedGrid ='Y' ORDER BY 3,2"; + boolean baseLanguage = Env.isBaseLanguage(Env.getCtx(), "AD_Field"); + String sql; + if (baseLanguage) + sql = "SELECT t.AD_Field_ID,t.Name,t.SeqNoGrid,AD_Client_ID, AD_Org_ID FROM AD_Field t WHERE t.AD_Tab_ID=? AND t.IsDisplayedGrid ='Y' AND t.IsActive='Y' ORDER BY 3,2"; + else + sql = "SELECT t.AD_Field_ID,trl.Name,t.SeqNoGrid,t.AD_Client_ID, t.AD_Org_ID FROM AD_Field t JOIN AD_Field_Trl trl ON (t.AD_Field_ID = trl.AD_Field_ID)" + + " WHERE t.AD_Tab_ID=? AND t.IsDisplayedGrid ='Y' AND t.IsActive='Y' AND trl.AD_Language=? ORDER BY 3,2"; PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = DB.prepareStatement(sql, null); pstmt.setInt(1, m_AD_Tab_ID); + if (!baseLanguage) + pstmt.setString(2, Env.getAD_Language(Env.getCtx())); rs = pstmt.executeQuery(); HashMap curTabSel = new HashMap(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java index 4e6a735ac9..43ef6850e8 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java @@ -190,6 +190,7 @@ public class WLocationDialog extends Window implements EventListener initLocation(); // this.setWidth("350px"); + this.setHeight("360px"); // required fixed height for ZK to auto adjust the position based on available space this.setSclass("popup-dialog"); this.setClosable(true); this.setBorder("normal"); @@ -336,7 +337,7 @@ public class WLocationDialog extends Window implements EventListener Borderlayout borderlayout = new Borderlayout(); this.appendChild(borderlayout); borderlayout.setHflex("1"); - borderlayout.setVflex("min"); + borderlayout.setVflex("1"); Center centerPane = new Center(); centerPane.setSclass("dialog-content"); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java index 4537ed58cc..fa7645c51e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java @@ -232,7 +232,7 @@ public class WLocatorDialog extends Window implements EventListener Borderlayout borderlayout = new Borderlayout(); this.appendChild(borderlayout); borderlayout.setHflex("1"); - borderlayout.setVflex("min"); + borderlayout.setVflex("1"); Center centerPane = new Center(); centerPane.setSclass("dialog-content"); @@ -252,6 +252,7 @@ public class WLocatorDialog extends Window implements EventListener this.setClosable(true); this.setBorder("normal"); this.setWidth("260px"); + this.setHeight("300px"); // required fixed height for ZK to auto adjust the position based on available space this.setShadow(true); this.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED); this.setSizable(true); // Elaine 2009/02/02 - window set to resizable diff --git a/org.adempiere.ui.zk/theme/default/css/theme.css.dsp b/org.adempiere.ui.zk/theme/default/css/theme.css.dsp index 7df150eb1f..bda1e55aaa 100644 --- a/org.adempiere.ui.zk/theme/default/css/theme.css.dsp +++ b/org.adempiere.ui.zk/theme/default/css/theme.css.dsp @@ -594,6 +594,11 @@ div.wc-modal, div.wc-modal-none, div.wc-highlighted, div.wc-highlighted-none { width: 92%; } +.dashboard-widget-max { + margin: auto; + width: auto; +} + .dashboard-report-iframe { min-height:300px; border: 1px solid lightgray; @@ -625,7 +630,6 @@ div.wc-modal, div.wc-modal-none, div.wc-highlighted, div.wc-highlighted-none { .recentitems-box A { display: block; - width: 100%; padding: 2px 0px; } @@ -1802,4 +1806,54 @@ table.z-vbox > tbody > tr > td > table { .help-window-content-l tr:hover td { background-color: #eee; +} + +<%-- payment rule --%> +.payment-rule-editor { + display: inline-block; + border: none; + padding: 0px; + margin: 0px; + background-color: transparent; + position: relative; +} +.payment-rule-editor .z-combobox { + width: 100%; +} +.payment-rule-editor .z-combobox-inp { + box-sizing: border-box; + -moz-box-sizing: border-box; /* Firefox */ + display: inline-block; + padding-right: 44px; + width: 100%; + height: 21px; +} +.payment-rule-editor .z-combobox-inp:focus { + border: 1px solid #0000ff; +} +.payment-rule-editor .z-combobox-inp.editor-input-disd { + padding-right: 22px !important; +} +.payment-rule-editor .z-combobox-btn { + padding: 0px; + margin: 0px; + display: inline-block; + border: none; + position: absolute; + right: 22px; + top: 1px; +} +.payment-rule-editor .z-combobox.no-button .z-combobox-btn { + right: 1px; +} +.payment-rule-editor .z-combobox .z-combobox-btn-over { + background-color: #ddd; + background-position: 0px 0px; +} +.payment-rule-editor .editor-button { + border-radius: 0px; +} +.payment-rule-editor .editor-button :hover { + border-radius: 0px; + background-color: #ddd; } \ No newline at end of file diff --git a/org.idempiere.fitnesse.fixture/META-INF/MANIFEST.MF b/org.idempiere.fitnesse.fixture/META-INF/MANIFEST.MF index 371b96d92a..415c557310 100644 --- a/org.idempiere.fitnesse.fixture/META-INF/MANIFEST.MF +++ b/org.idempiere.fitnesse.fixture/META-INF/MANIFEST.MF @@ -52,6 +52,7 @@ Import-Package: fit, fitnesse.wikitext.widgets, fitnesseMain, fitnesseMain.ant, + org.adempiere.util, org.compiere, org.compiere.model, org.compiere.process, diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Login.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Login.java index 93a3887aad..86a7bcfb0a 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Login.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Login.java @@ -26,6 +26,8 @@ package org.idempiere.fitnesse.fixture; +import java.util.Properties; + import org.compiere.model.MSession; import org.compiere.model.MUser; import org.compiere.util.Env; @@ -54,6 +56,7 @@ public class Login extends TableFixture { if (adempiereInstance == null) { adempiereInstance = Static_iDempiereInstance.getInstance(); } + Properties ctx = adempiereInstance.getAdempiereService().getCtx(); boolean isErrorExpected = "*Login*Error*".equalsIgnoreCase(getText(rows-1, 0)); String msgerror = getText(rows-1, 1); for (int i = 0; i < rows; i++) { @@ -116,7 +119,7 @@ public class Login extends TableFixture { else { String msg = modelLogin(); if (msg == null || msg.length() == 0) { - MSession.get (Env.getCtx(), true);// Start Session + MSession.get (ctx, true);// Start Session if (isErrorExpected) { wrong(rows-1, 0); wrong(rows-1, 1); diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/RunProcess.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/RunProcess.java index 53da5cd38d..dc2f9b6e9f 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/RunProcess.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/RunProcess.java @@ -33,6 +33,7 @@ import java.util.HashMap; import java.util.Properties; import java.util.logging.Level; +import org.adempiere.util.ProcessUtil; import org.compiere.model.Lookup; import org.compiere.model.MPInstance; import org.compiere.model.MPInstanceLog; @@ -172,7 +173,14 @@ public class RunProcess extends TableFixture { if (recordID >0) pi.setRecord_ID(recordID); boolean processOK = false; - boolean jasperreport = (process != null && process.getClassname()!=null && process.getClassname().indexOf( "net.sf.compilo.report.ReportStarter" ) >=0 ); + boolean jasperreport = + (process != null + && (process.getJasperReport() != null + || (process.getClassname() != null + && process.getClassname().indexOf(ProcessUtil.JASPER_STARTER_CLASS) >= 0 + ) + ) + ); // Start if (process.isWorkflow()) { @@ -191,6 +199,7 @@ public class RunProcess extends TableFixture { if (table != null) { PO po = table.getPO(recordID, null); if (!docAction.equals(po.get_Value("DocStatus"))) { + getCell(i, 1).addToBody("
Expected " + docAction + "
Received " + po.get_Value("DocStatus")); boolean ok = Util.evaluateError(Msg.parseTranslation(ctx, pi.getSummary()), msgerror1, isErrorExpected); if (ok) { right(getCell(i, 1)); @@ -306,7 +315,7 @@ public class RunProcess extends TableFixture { if (pil.getP_Number() != null) getCell(i, 1).addToBody(pil.getP_Number() + " \t"); if (pil.getP_Msg() != null) - getCell(i, 1).addToBody(Msg.parseTranslation(Env.getCtx(), pil.getP_Msg()).replaceAll("\\n", "
")); + getCell(i, 1).addToBody(Msg.parseTranslation(adempiereInstance.getAdempiereService().getCtx(), pil.getP_Msg()).replaceAll("\\n", "
")); } } } diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Util.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Util.java index e20edecab2..eb6b46f419 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Util.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Util.java @@ -125,18 +125,6 @@ public class Util { parse.addToBody("
" + newval); if (log.isLoggable(Level.CONFIG)) log.config("Cell value " + cell_value + " evaluated to " + newval); return newval; - } else if (cell_value.startsWith("@") && cell_value.endsWith("@")) { - int posdot = cell_value.indexOf("."); - if (posdot >= 0) { - cell_value = cell_value.toLowerCase(); - } - String newval = Env.getContext(ctx, windowNo, cell_value.substring(1, cell_value.length()-1)); - if (newval == null) - return cell_value; - if (parse != null) - parse.addToBody("
" + newval); - if (log.isLoggable(Level.CONFIG)) log.config("Cell value " + cell_value + " evaluated to " + newval); - return newval; } else if ((cell_value.toLowerCase().startsWith("@random_number(") || cell_value.toLowerCase().startsWith("@random_string(")) && cell_value.endsWith(")")) { // allow @RANDOM_NUMBER(PREFIX,SUFFIX,LENGTH,DECIMALS)@ in column value @@ -198,6 +186,26 @@ public class Util { parse.addToBody("
" + newval); if (log.isLoggable(Level.CONFIG)) log.config("Cell value " + cell_value + " evaluated to " + newval); return newval; + } else if (cell_value.startsWith("@") && cell_value.endsWith("@")) { + int posdot = cell_value.indexOf("."); + if (posdot >= 0) { + cell_value = cell_value.toLowerCase(); + } + String newval = Env.getContext(ctx, windowNo, cell_value.substring(1, cell_value.length()-1)); + if (newval == null) + return cell_value; + if (parse != null) + parse.addToBody("
" + newval); + if (log.isLoggable(Level.CONFIG)) log.config("Cell value " + cell_value + " evaluated to " + newval); + return newval; + } else if (cell_value.matches(".*@.*@.*")) { + String newval = Env.parseContext(ctx, windowNo, cell_value, false, false); + if (newval == null || newval.length() == 0) + return cell_value; + if (parse != null) + parse.addToBody("
" + newval); + if (log.isLoggable(Level.CONFIG)) log.config("Cell value " + cell_value + " evaluated to " + newval); + return newval; } else if (cell_value.startsWith("\\@")) { cell_value = cell_value.substring(1); } diff --git a/org.idempiere.ui.zk.selenium/src/fitlibrary/zk/ZkFixture.java b/org.idempiere.ui.zk.selenium/src/fitlibrary/zk/ZkFixture.java index 13683ed91b..297447a66f 100644 --- a/org.idempiere.ui.zk.selenium/src/fitlibrary/zk/ZkFixture.java +++ b/org.idempiere.ui.zk.selenium/src/fitlibrary/zk/ZkFixture.java @@ -159,7 +159,7 @@ public class ZkFixture extends SpiderFixture { Widget widget = new Widget(locator + " @textbox"); WebElement element = widget.findElement(webDriver); element.click(); - widget.execute(webDriver, "setValue('"+value+"')"); + widget.execute(webDriver, "setValue(\""+value+"\")"); widget.execute(webDriver, "fireOnChange()"); } diff --git a/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/Process.java b/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/Process.java index e90ff8659d..619ee054ad 100644 --- a/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/Process.java +++ b/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/Process.java @@ -14,6 +14,7 @@ import javax.xml.namespace.QName; import net.sf.compilo.report.ReportProcessor; import net.sf.jasperreports.engine.JasperPrint; +import org.adempiere.util.ProcessUtil; import org.compiere.model.Lookup; import org.compiere.model.MLookup; import org.compiere.model.MLookupFactory; @@ -288,7 +289,14 @@ public class Process { } boolean processOK = false; - boolean jasperreport = (process != null && process.getClassname()!=null && process.getClassname().indexOf( "net.sf.compilo.report.ReportStarter" ) >=0 ); + boolean jasperreport = + (process != null + && (process.getJasperReport() != null + || (process.getClassname() != null + && process.getClassname().indexOf(ProcessUtil.JASPER_STARTER_CLASS) >= 0 + ) + ) + ); if (jasperreport) {