From 760fd61bccbd5c2eb7634f75a79754c0f6fc6959 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 21 Mar 2019 11:58:56 -0300 Subject: [PATCH] IDEMPIERE-3925 Export button - zip doesn't work for tables without single primary key --- .../src/org/compiere/model/GridTable.java | 2 +- .../handler/FormAccessElementHandler.java | 23 ++++++++++++-- .../InfoWindowAccessElementHandler.java | 22 ++++++++++++-- .../pipo2/handler/OrgRoleElementHandler.java | 24 +++++++++++++-- .../handler/ProcessAccessElementHandler.java | 26 ++++++++++++++-- .../handler/TaskAccessElementHandler.java | 25 ++++++++++++++-- .../pipo2/handler/UserRoleElementHandler.java | 30 +++++++++++++++---- .../handler/WindowAccessElementHandler.java | 26 ++++++++++++++-- .../handler/WorkflowAccessElementHandler.java | 25 ++++++++++++++-- .../org/adempiere/pipo2/ElementHandler.java | 14 +++++++++ .../adempiere/pipo2/GridTab2PackExporter.java | 23 +++++++++++--- .../src/org/adempiere/pipo2/PackOut.java | 2 +- .../src/org/adempiere/pipo2/PackoutItem.java | 17 +++++++++++ 13 files changed, 228 insertions(+), 31 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/GridTable.java b/org.adempiere.base/src/org/compiere/model/GridTable.java index 46b1314b1f..1570fed909 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTable.java +++ b/org.adempiere.base/src/org/compiere/model/GridTable.java @@ -1026,7 +1026,7 @@ public class GridTable extends AbstractTableModel } } return null; - } // getKeyID + } // getUUID /** * Get Key ColumnName 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 ffddf51a17..2938bf0c95 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 @@ -20,11 +20,12 @@ import java.util.List; import javax.xml.transform.sax.TransformerHandler; +import org.adempiere.exceptions.AdempiereException; import org.adempiere.pipo2.AbstractElementHandler; +import org.adempiere.pipo2.Element; import org.adempiere.pipo2.PIPOContext; import org.adempiere.pipo2.PackOut; import org.adempiere.pipo2.PoExporter; -import org.adempiere.pipo2.Element; import org.adempiere.pipo2.PoFiller; import org.compiere.model.I_AD_Form_Access; import org.compiere.model.MFormAccess; @@ -90,10 +91,28 @@ public class FormAccessElementHandler extends AbstractElementHandler { filler.export(excludes); } + @Override + public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, int recordId) + throws Exception { + throw new AdempiereException("AD_Form_Access doesn't have ID, use method with UUID"); + } + @Override public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, - int recordId) throws Exception { + int recordId, String uuid) throws Exception { + MFormAccess po = new Query(packout.getCtx().ctx, MFormAccess.Table_Name, "AD_Form_Access_UU=?", getTrxName(packout.getCtx())) + .setParameters(uuid) + .first(); + if (po != null) { + Env.setContext(packout.getCtx().ctx, X_AD_Form.COLUMNNAME_AD_Form_ID, po.getAD_Form_ID()); + Env.setContext(packout.getCtx().ctx, X_AD_Role.COLUMNNAME_AD_Role_ID, po.getAD_Role_ID()); + this.create(packout.getCtx(), packoutHandler); + packout.getCtx().ctx.remove(X_AD_Form.COLUMNNAME_AD_Form_ID); + packout.getCtx().ctx.remove(X_AD_Role.COLUMNNAME_AD_Role_ID); + } else { + throw new AdempiereException("AD_Form_Access_UU not found = " + uuid); + } } } diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/InfoWindowAccessElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/InfoWindowAccessElementHandler.java index d03a4dc4c0..fbfe18881b 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/InfoWindowAccessElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/InfoWindowAccessElementHandler.java @@ -29,6 +29,7 @@ import java.util.List; import javax.xml.transform.sax.TransformerHandler; +import org.adempiere.exceptions.AdempiereException; import org.adempiere.pipo2.AbstractElementHandler; import org.adempiere.pipo2.Element; import org.adempiere.pipo2.PIPOContext; @@ -90,7 +91,24 @@ public class InfoWindowAccessElementHandler extends AbstractElementHandler { } @Override - public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, int recordId) throws Exception { - create(packout.getCtx(), packoutHandler); + public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, int recordId) + throws Exception { + throw new AdempiereException("AD_InfoWindow_Access doesn't have ID, use method with UUID"); + } + + @Override + public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, int recordId, String uuid) throws Exception { + X_AD_InfoWindow_Access po = new Query(packout.getCtx().ctx, X_AD_InfoWindow_Access.Table_Name, "AD_InfoWindow_Access_UU=?", getTrxName(packout.getCtx())) + .setParameters(uuid) + .first(); + if (po != null) { + Env.setContext(packout.getCtx().ctx, X_AD_InfoWindow.COLUMNNAME_AD_InfoWindow_ID, po.getAD_InfoWindow_ID()); + Env.setContext(packout.getCtx().ctx, X_AD_Role.COLUMNNAME_AD_Role_ID, po.getAD_Role_ID()); + this.create(packout.getCtx(), packoutHandler); + packout.getCtx().ctx.remove(X_AD_InfoWindow.COLUMNNAME_AD_InfoWindow_ID); + packout.getCtx().ctx.remove(X_AD_Role.COLUMNNAME_AD_Role_ID); + } else { + throw new AdempiereException("AD_InfoWindow_Access_UU not found = " + uuid); + } } } 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 81255b64c2..17c4b445cb 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 @@ -20,6 +20,7 @@ import java.util.List; import javax.xml.transform.sax.TransformerHandler; +import org.adempiere.exceptions.AdempiereException; import org.adempiere.pipo2.AbstractElementHandler; import org.adempiere.pipo2.Element; import org.adempiere.pipo2.PIPOContext; @@ -59,7 +60,7 @@ public class OrgRoleElementHandler extends AbstractElementHandler { public void create(PIPOContext ctx, TransformerHandler document) throws SAXException { - int AD_Org_ID = Env.getContextAsInt(ctx.ctx, "AD_Org_ID"); + int AD_Org_ID = Env.getContextAsInt(ctx.ctx, X_AD_Role.COLUMNNAME_AD_Org_ID); int AD_Role_ID = Env.getContextAsInt(ctx.ctx, X_AD_Role.COLUMNNAME_AD_Role_ID); Query query = new Query(ctx.ctx, "AD_Role_OrgAccess", "AD_Role_ID=? and AD_Org_ID=?", getTrxName(ctx)); @@ -86,10 +87,27 @@ public class OrgRoleElementHandler extends AbstractElementHandler { filler.export(excludes); } + @Override + public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, int recordId) + throws Exception { + throw new AdempiereException("AD_Role_OrgAccess doesn't have ID, use method with UUID"); + } + @Override public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, - int recordId) throws Exception { - create(packout.getCtx(), packoutHandler); + int recordId, String uuid) throws Exception { + X_AD_Role_OrgAccess po = new Query(packout.getCtx().ctx, X_AD_Role_OrgAccess.Table_Name, "AD_Role_OrgAccess_UU=?", getTrxName(packout.getCtx())) + .setParameters(uuid) + .first(); + if (po != null) { + Env.setContext(packout.getCtx().ctx, X_AD_Role.COLUMNNAME_AD_Org_ID, po.getAD_Org_ID()); + Env.setContext(packout.getCtx().ctx, X_AD_Role.COLUMNNAME_AD_Role_ID, po.getAD_Role_ID()); + this.create(packout.getCtx(), packoutHandler); + packout.getCtx().ctx.remove(X_AD_Role.COLUMNNAME_AD_Org_ID); + packout.getCtx().ctx.remove(X_AD_Role.COLUMNNAME_AD_Role_ID); + } else { + throw new AdempiereException("AD_Role_OrgAccess_UU not found = " + uuid); + } } } 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 6e62db75d9..07fc631790 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 @@ -20,13 +20,15 @@ import java.util.List; import javax.xml.transform.sax.TransformerHandler; +import org.adempiere.exceptions.AdempiereException; import org.adempiere.pipo2.AbstractElementHandler; +import org.adempiere.pipo2.Element; import org.adempiere.pipo2.PIPOContext; import org.adempiere.pipo2.PackOut; import org.adempiere.pipo2.PoExporter; -import org.adempiere.pipo2.Element; import org.adempiere.pipo2.PoFiller; import org.compiere.model.I_AD_Process_Access; +import org.compiere.model.MProcessAccess; import org.compiere.model.Query; import org.compiere.model.X_AD_Process; import org.compiere.model.X_AD_Process_Access; @@ -88,10 +90,28 @@ public class ProcessAccessElementHandler extends AbstractElementHandler { filler.export(excludes); } + @Override + public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, int recordId) + throws Exception { + throw new AdempiereException("AD_Process_Access doesn't have ID, use method with UUID"); + } + @Override public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, - int recordId) throws Exception { - create(packout.getCtx(), packoutHandler); + int recordId, String uuid) throws Exception { + MProcessAccess po = new Query(packout.getCtx().ctx, MProcessAccess.Table_Name, "AD_Process_Access_UU=?", getTrxName(packout.getCtx())) + .setParameters(uuid) + .first(); + if (po != null) { + Env.setContext(packout.getCtx().ctx, X_AD_Process.COLUMNNAME_AD_Process_ID, po.getAD_Process_ID()); + Env.setContext(packout.getCtx().ctx, X_AD_Role.COLUMNNAME_AD_Role_ID, po.getAD_Role_ID()); + this.create(packout.getCtx(), packoutHandler); + packout.getCtx().ctx.remove(X_AD_Process.COLUMNNAME_AD_Process_ID); + packout.getCtx().ctx.remove(X_AD_Role.COLUMNNAME_AD_Role_ID); + } else { + throw new AdempiereException("AD_Process_Access_UU not found = " + uuid); + } } + } 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 0f0c9d05fd..92b9120fd6 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 @@ -20,11 +20,12 @@ import java.util.List; import javax.xml.transform.sax.TransformerHandler; +import org.adempiere.exceptions.AdempiereException; import org.adempiere.pipo2.AbstractElementHandler; +import org.adempiere.pipo2.Element; import org.adempiere.pipo2.PIPOContext; import org.adempiere.pipo2.PackOut; import org.adempiere.pipo2.PoExporter; -import org.adempiere.pipo2.Element; import org.adempiere.pipo2.PoFiller; import org.compiere.model.I_AD_Task_Access; import org.compiere.model.Query; @@ -82,10 +83,28 @@ public class TaskAccessElementHandler extends AbstractElementHandler { filler.export(excludes); } + @Override + public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, int recordId) + throws Exception { + throw new AdempiereException("AD_Task_Access doesn't have ID, use method with UUID"); + } + @Override public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, - int recordId) throws Exception { - create(packout.getCtx(), packoutHandler); + int recordId, String uuid) throws Exception { + X_AD_Task_Access po = new Query(packout.getCtx().ctx, X_AD_Task_Access.Table_Name, "AD_Task_Access_UU=?", getTrxName(packout.getCtx())) + .setParameters(uuid) + .first(); + if (po != null) { + Env.setContext(packout.getCtx().ctx, X_AD_Task.COLUMNNAME_AD_Task_ID, po.getAD_Task_ID()); + Env.setContext(packout.getCtx().ctx, X_AD_Role.COLUMNNAME_AD_Role_ID, po.getAD_Role_ID()); + this.create(packout.getCtx(), packoutHandler); + packout.getCtx().ctx.remove(X_AD_Task.COLUMNNAME_AD_Task_ID); + packout.getCtx().ctx.remove(X_AD_Role.COLUMNNAME_AD_Role_ID); + } else { + throw new AdempiereException("AD_Task_Access_UU not found = " + uuid); + } } + } 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 2ed746c279..8ca68dc307 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 @@ -20,11 +20,12 @@ import java.util.List; import javax.xml.transform.sax.TransformerHandler; +import org.adempiere.exceptions.AdempiereException; import org.adempiere.pipo2.AbstractElementHandler; +import org.adempiere.pipo2.Element; import org.adempiere.pipo2.PIPOContext; import org.adempiere.pipo2.PackOut; import org.adempiere.pipo2.PoExporter; -import org.adempiere.pipo2.Element; import org.adempiere.pipo2.PoFiller; import org.compiere.model.I_AD_User_Roles; import org.compiere.model.Query; @@ -63,11 +64,10 @@ public class UserRoleElementHandler extends AbstractElementHandler { throws SAXException { int AD_User_ID = Env.getContextAsInt(ctx.ctx, X_AD_User.COLUMNNAME_AD_User_ID); int AD_Role_ID = Env.getContextAsInt(ctx.ctx, X_AD_Role.COLUMNNAME_AD_Role_ID); - int AD_Org_ID = Env.getContextAsInt(ctx.ctx, "AD_Org_ID"); Query query = new Query(ctx.ctx, "AD_User_Roles", - "AD_User_ID = ? AND AD_Role_ID = ? AND AD_Org_ID = ?", getTrxName(ctx)); + "AD_User_ID = ? AND AD_Role_ID = ?", getTrxName(ctx)); X_AD_User_Roles po = query.setParameters( - new Object[] { AD_User_ID, AD_Role_ID, AD_Org_ID }).first(); + new Object[] { AD_User_ID, AD_Role_ID}).first(); if (po != null) { if (!isPackOutElement(ctx, po)) return; @@ -90,10 +90,28 @@ public class UserRoleElementHandler extends AbstractElementHandler { filler.export(excludes, true); } + @Override + public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, int recordId) + throws Exception { + throw new AdempiereException("AD_User_Roles doesn't have ID, use method with UUID"); + } + @Override public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, - int recordId) throws Exception { - create(packout.getCtx(), packoutHandler); + int recordId, String uuid) throws Exception { + X_AD_User_Roles po = new Query(packout.getCtx().ctx, X_AD_User_Roles.Table_Name, "AD_User_Roles_UU=?", getTrxName(packout.getCtx())) + .setParameters(uuid) + .first(); + if (po != null) { + Env.setContext(packout.getCtx().ctx, X_AD_User.COLUMNNAME_AD_User_ID, po.getAD_User_ID()); + Env.setContext(packout.getCtx().ctx, X_AD_Role.COLUMNNAME_AD_Role_ID, po.getAD_Role_ID()); + this.create(packout.getCtx(), packoutHandler); + packout.getCtx().ctx.remove(X_AD_User.COLUMNNAME_AD_User_ID); + packout.getCtx().ctx.remove(X_AD_Role.COLUMNNAME_AD_Role_ID); + } else { + throw new AdempiereException("AD_User_Roles_UU not found = " + uuid); + } } + } 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 02ef45f276..3cc2be26b9 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 @@ -20,13 +20,15 @@ import java.util.List; import javax.xml.transform.sax.TransformerHandler; +import org.adempiere.exceptions.AdempiereException; import org.adempiere.pipo2.AbstractElementHandler; +import org.adempiere.pipo2.Element; import org.adempiere.pipo2.PIPOContext; import org.adempiere.pipo2.PackOut; import org.adempiere.pipo2.PoExporter; -import org.adempiere.pipo2.Element; import org.adempiere.pipo2.PoFiller; import org.compiere.model.I_AD_Window_Access; +import org.compiere.model.MWindowAccess; import org.compiere.model.Query; import org.compiere.model.X_AD_Role; import org.compiere.model.X_AD_Window; @@ -83,10 +85,28 @@ public class WindowAccessElementHandler extends AbstractElementHandler { filler.export(excludes); } + @Override + public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, int recordId) + throws Exception { + throw new AdempiereException("AD_Window_Access doesn't have ID, use method with UUID"); + } + @Override public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, - int recordId) throws Exception { - create(packout.getCtx(), packoutHandler); + int recordId, String uuid) throws Exception { + MWindowAccess po = new Query(packout.getCtx().ctx, MWindowAccess.Table_Name, "AD_Window_Access_UU=?", getTrxName(packout.getCtx())) + .setParameters(uuid) + .first(); + if (po != null) { + Env.setContext(packout.getCtx().ctx, X_AD_Window.COLUMNNAME_AD_Window_ID, po.getAD_Window_ID()); + Env.setContext(packout.getCtx().ctx, X_AD_Role.COLUMNNAME_AD_Role_ID, po.getAD_Role_ID()); + this.create(packout.getCtx(), packoutHandler); + packout.getCtx().ctx.remove(X_AD_Window.COLUMNNAME_AD_Window_ID); + packout.getCtx().ctx.remove(X_AD_Role.COLUMNNAME_AD_Role_ID); + } else { + throw new AdempiereException("AD_Window_Access_UU not found = " + uuid); + } } + } 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 3a5a9a2c69..f0a69ca34d 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 @@ -20,11 +20,12 @@ import java.util.List; import javax.xml.transform.sax.TransformerHandler; +import org.adempiere.exceptions.AdempiereException; import org.adempiere.pipo2.AbstractElementHandler; +import org.adempiere.pipo2.Element; import org.adempiere.pipo2.PIPOContext; import org.adempiere.pipo2.PackOut; import org.adempiere.pipo2.PoExporter; -import org.adempiere.pipo2.Element; import org.adempiere.pipo2.PoFiller; import org.compiere.model.I_AD_Workflow_Access; import org.compiere.model.Query; @@ -86,10 +87,28 @@ public class WorkflowAccessElementHandler extends AbstractElementHandler { filler.export(excludes); } + @Override + public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, int recordId) + throws Exception { + throw new AdempiereException("AD_Workflow_Access doesn't have ID, use method with UUID"); + } + @Override public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, - int recordId) throws Exception { - create(packout.getCtx(), packoutHandler); + int recordId, String uuid) throws Exception { + MWorkflowAccess po = new Query(packout.getCtx().ctx, MWorkflowAccess.Table_Name, "AD_Workflow_Access_UU=?", getTrxName(packout.getCtx())) + .setParameters(uuid) + .first(); + if (po != null) { + Env.setContext(packout.getCtx().ctx, X_AD_Workflow.COLUMNNAME_AD_Workflow_ID, po.getAD_Workflow_ID()); + Env.setContext(packout.getCtx().ctx, X_AD_Role.COLUMNNAME_AD_Role_ID, po.getAD_Role_ID()); + this.create(packout.getCtx(), packoutHandler); + packout.getCtx().ctx.remove(X_AD_Workflow.COLUMNNAME_AD_Workflow_ID); + packout.getCtx().ctx.remove(X_AD_Role.COLUMNNAME_AD_Role_ID); + } else { + throw new AdempiereException("AD_Workflow_Access_UU not found = " + uuid); + } } + } diff --git a/org.adempiere.pipo/src/org/adempiere/pipo2/ElementHandler.java b/org.adempiere.pipo/src/org/adempiere/pipo2/ElementHandler.java index fe9bab225a..46910e11dc 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo2/ElementHandler.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo2/ElementHandler.java @@ -52,4 +52,18 @@ public interface ElementHandler { * @throws Exception */ public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler,int recordId) throws Exception; + + /** + * @param packout + * @param packoutHandler + * @param docHandler + * @param recordId + * @param uuid + * @throws Exception + */ + default public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler,int recordId, String uuid) throws Exception { + // element handlers for tables without ID must implement this method + packOut(packout, packoutHandler, docHandler, recordId); // defaults to calling the method without uuid + } + } diff --git a/org.adempiere.pipo/src/org/adempiere/pipo2/GridTab2PackExporter.java b/org.adempiere.pipo/src/org/adempiere/pipo2/GridTab2PackExporter.java index 9a7cc2704e..2a0d83cb23 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo2/GridTab2PackExporter.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo2/GridTab2PackExporter.java @@ -20,6 +20,7 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.UUID; import org.adempiere.base.IGridTabExporter; import org.adempiere.exceptions.AdempiereException; @@ -87,13 +88,27 @@ public class GridTab2PackExporter implements IGridTabExporter { packoutItems.add(packoutItem); } else { if (currentRowOnly) { - PackoutItem packoutItem = new PackoutItem(tableName, gridTab.getRecord_ID(), - properties); + int recordID = gridTab.getRecord_ID(); + String uuid = null; + if (recordID == -1) { + UUID uuidObj = gridTab.getTableModel().getUUID(gridTab.getCurrentRow()); + if (uuidObj != null) { + uuid = uuidObj.toString(); + } + } + PackoutItem packoutItem = new PackoutItem(tableName, recordID, uuid, properties); packoutItems.add(packoutItem); } else { for(int i = 0; i < gridTab.getRowCount(); i++) { - PackoutItem packoutItem = new PackoutItem(tableName, gridTab.getKeyID(i), - properties); + int recordID = gridTab.getKeyID(i); + String uuid = null; + if (recordID == -1) { + UUID uuidObj = gridTab.getTableModel().getUUID(i); + if (uuidObj != null) { + uuid = uuidObj.toString(); + } + } + PackoutItem packoutItem = new PackoutItem(tableName, recordID, uuid, properties); packoutItems.add(packoutItem); } } diff --git a/org.adempiere.pipo/src/org/adempiere/pipo2/PackOut.java b/org.adempiere.pipo/src/org/adempiere/pipo2/PackOut.java index c6d3a59ca6..6f6a3b52b0 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo2/PackOut.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo2/PackOut.java @@ -141,7 +141,7 @@ public class PackOut ElementHandler handler = handlerRegistry.getHandler(type); if (handler != null) - handler.packOut(this,packoutHandler,docHandler,packoutItem.getRecordId()); + handler.packOut(this,packoutHandler,docHandler,packoutItem.getRecordId(),packoutItem.getUUID()); else throw new IllegalArgumentException("Packout handler not found for type " + type); diff --git a/org.adempiere.pipo/src/org/adempiere/pipo2/PackoutItem.java b/org.adempiere.pipo/src/org/adempiere/pipo2/PackoutItem.java index 4af45dab38..dcf3b2cdc5 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo2/PackoutItem.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo2/PackoutItem.java @@ -24,6 +24,7 @@ public class PackoutItem { private String type; private int recordId; + private String uuid; private Map properties; /** @@ -31,9 +32,18 @@ public class PackoutItem { * @param recordId */ public PackoutItem(String type, int recordId, Map properties) { + this(type, recordId, null, properties); + } + + /** + * @param type + * @param recordId + */ + public PackoutItem(String type, int recordId, String uuid, Map properties) { super(); this.type = type; this.recordId = recordId; + this.uuid = uuid; this.properties = properties; } @@ -51,6 +61,13 @@ public class PackoutItem { return recordId; } + /** + * @return the uuid + */ + public String getUUID() { + return uuid; + } + /** * * @param key