From 6c03341bc4b333ab85011ed1082e113d9230f504 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 8 Aug 2013 01:02:41 -0500 Subject: [PATCH] IDEMPIERE-1256 2Pack exporting repeated elements --- .../pipo2/handler/ColumnElementHandler.java | 13 +++++++++++-- .../pipo2/handler/FieldElementHandler.java | 9 +++++++++ .../pipo2/handler/ImpFormatRowElementHandler.java | 6 ++++++ .../pipo2/handler/PreferenceElementHandler.java | 8 ++++++++ .../handler/PrintFormatItemElementHandler.java | 6 ++++++ .../pipo2/handler/PrintPaperElementHandler.java | 6 ++++++ .../pipo2/handler/ProcessParaElementHandler.java | 6 ++++++ .../pipo2/handler/ReportViewColElementHandler.java | 7 +++++++ .../adempiere/pipo2/handler/TabElementHandler.java | 6 ++++++ .../pipo2/handler/WorkflowNodeElementHandler.java | 6 ++++++ .../WorkflowNodeNextConditionElementHandler.java | 6 ++++++ .../handler/WorkflowNodeNextElementHandler.java | 6 ++++++ 12 files changed, 83 insertions(+), 2 deletions(-) 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 80828f2952..912e920828 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 @@ -20,16 +20,17 @@ import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; import java.util.List; import java.util.logging.Level; import javax.xml.transform.sax.TransformerHandler; import org.adempiere.pipo2.AbstractElementHandler; -import org.adempiere.pipo2.PIPOContext; -import org.adempiere.pipo2.PoExporter; import org.adempiere.pipo2.Element; +import org.adempiere.pipo2.PIPOContext; import org.adempiere.pipo2.PackOut; +import org.adempiere.pipo2.PoExporter; import org.adempiere.pipo2.PoFiller; import org.adempiere.pipo2.exception.DatabaseAccessException; import org.adempiere.pipo2.exception.POSaveFailedException; @@ -49,6 +50,8 @@ import org.xml.sax.helpers.AttributesImpl; public class ColumnElementHandler extends AbstractElementHandler { + private List processedColumns = new ArrayList(); + public void startElement(PIPOContext ctx, Element element) throws SAXException { int success = 0; @@ -297,6 +300,12 @@ public class ColumnElementHandler extends AbstractElementHandler { throws SAXException { int AD_Column_ID = Env.getContextAsInt(ctx.ctx, X_AD_Column.COLUMNNAME_AD_Column_ID); + + if (processedColumns.contains(AD_Column_ID)) + return; + + processedColumns.add(AD_Column_ID); + AttributesImpl atts = new AttributesImpl(); X_AD_Column m_Column = new X_AD_Column(ctx.ctx, AD_Column_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 efd5451551..6924c31e4c 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 @@ -16,6 +16,7 @@ *****************************************************************************/ package org.adempiere.pipo2.handler; +import java.util.ArrayList; import java.util.List; import java.util.logging.Level; @@ -44,6 +45,8 @@ import org.xml.sax.helpers.AttributesImpl; public class FieldElementHandler extends AbstractElementHandler { + private List processedFields = new ArrayList(); + public void startElement(PIPOContext ctx, Element element) throws SAXException { String entitytype = getStringValue(element, "EntityType"); @@ -169,6 +172,12 @@ public class FieldElementHandler extends AbstractElementHandler { throws SAXException { int AD_Field_ID = Env.getContextAsInt(ctx.ctx, X_AD_Field.COLUMNNAME_AD_Field_ID); + + if (processedFields.contains(AD_Field_ID)) + return; + + processedFields.add(AD_Field_ID); + X_AD_Field m_Field = new X_AD_Field(ctx.ctx, AD_Field_ID, null); PackOut packOut = ctx.packOut; 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 653fed9b37..1383363de0 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 @@ -16,6 +16,7 @@ *****************************************************************************/ package org.adempiere.pipo2.handler; +import java.util.ArrayList; import java.util.List; import javax.xml.transform.sax.TransformerHandler; @@ -39,6 +40,8 @@ import org.xml.sax.helpers.AttributesImpl; public class ImpFormatRowElementHandler extends AbstractElementHandler { + private List formatrows = new ArrayList(); + public void startElement(PIPOContext ctx, Element element) throws SAXException { String action = null; @@ -151,6 +154,9 @@ public class ImpFormatRowElementHandler extends AbstractElementHandler { public void create(PIPOContext ctx, TransformerHandler document) throws SAXException { int AD_ImpFormat_Row_ID = Env.getContextAsInt(ctx.ctx, X_AD_ImpFormat_Row.COLUMNNAME_AD_ImpFormat_Row_ID); + if (formatrows.contains(AD_ImpFormat_Row_ID)) + return; + formatrows.add(AD_ImpFormat_Row_ID); X_AD_ImpFormat_Row m_ImpFormat_Row = new X_AD_ImpFormat_Row (ctx.ctx, AD_ImpFormat_Row_ID, getTrxName(ctx)); if (ctx.packOut.getFromDate() != null) { diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/PreferenceElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/PreferenceElementHandler.java index 296935d75f..c7af828a10 100644 --- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/PreferenceElementHandler.java +++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/PreferenceElementHandler.java @@ -16,6 +16,7 @@ *****************************************************************************/ package org.adempiere.pipo2.handler; +import java.util.ArrayList; import java.util.List; import javax.xml.transform.sax.TransformerHandler; @@ -38,6 +39,8 @@ import org.xml.sax.helpers.AttributesImpl; public class PreferenceElementHandler extends AbstractElementHandler { + private ListprocessedPreferences = new ArrayList(); + public void startElement(PIPOContext ctx, Element element) throws SAXException { @@ -109,6 +112,11 @@ public class PreferenceElementHandler extends AbstractElementHandler { throws SAXException { int AD_Preference_ID = Env.getContextAsInt(ctx.ctx, X_AD_Preference.COLUMNNAME_AD_Preference_ID); + if (processedPreferences.contains(AD_Preference_ID)) + return; + + processedPreferences.add(AD_Preference_ID); + X_AD_Preference m_Preference = new X_AD_Preference(ctx.ctx, AD_Preference_ID, getTrxName(ctx)); 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 d6991cd820..26c8573972 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 @@ -17,6 +17,7 @@ *****************************************************************************/ package org.adempiere.pipo2.handler; +import java.util.ArrayList; import java.util.List; import java.util.logging.Level; @@ -40,6 +41,8 @@ import org.xml.sax.helpers.AttributesImpl; public class PrintFormatItemElementHandler extends AbstractElementHandler { + private List formatitems = new ArrayList(); + public void startElement(PIPOContext ctx, Element element) throws SAXException { @@ -143,6 +146,9 @@ public class PrintFormatItemElementHandler extends AbstractElementHandler { throws SAXException { int AD_PrintFormatItem_ID = Env.getContextAsInt(ctx.ctx, X_AD_PrintFormatItem.COLUMNNAME_AD_PrintFormatItem_ID); + if (formatitems.contains(AD_PrintFormatItem_ID)) + return; + formatitems.add(AD_PrintFormatItem_ID); X_AD_PrintFormatItem m_PrintFormatItem = new X_AD_PrintFormatItem(ctx.ctx, AD_PrintFormatItem_ID, null); 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 c2a55c6049..2d0d44a648 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 @@ -17,6 +17,7 @@ *****************************************************************************/ package org.adempiere.pipo2.handler; +import java.util.ArrayList; import java.util.List; import javax.xml.transform.sax.TransformerHandler; @@ -37,6 +38,8 @@ import org.xml.sax.helpers.AttributesImpl; public class PrintPaperElementHandler extends AbstractElementHandler { + private List papers = new ArrayList(); + public void startElement(PIPOContext ctx, Element element) throws SAXException { @@ -92,6 +95,9 @@ public class PrintPaperElementHandler extends AbstractElementHandler { throws SAXException { int AD_PrintPaper_ID = Env.getContextAsInt(ctx.ctx, X_AD_PrintPaper.COLUMNNAME_AD_PrintPaper_ID); + if (papers.contains(AD_PrintPaper_ID)) + return; + papers.add(AD_PrintPaper_ID); X_AD_PrintPaper printPaper = new X_AD_PrintPaper(ctx.ctx, AD_PrintPaper_ID, null); 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 95ad9d8595..d78f769c26 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 @@ -16,6 +16,7 @@ *****************************************************************************/ package org.adempiere.pipo2.handler; +import java.util.ArrayList; import java.util.List; import java.util.logging.Level; @@ -41,6 +42,8 @@ import org.xml.sax.helpers.AttributesImpl; public class ProcessParaElementHandler extends AbstractElementHandler { + private List processparas = new ArrayList(); + public void startElement(PIPOContext ctx, Element element) throws SAXException { List excludes = defaultExcludeList(X_AD_Process_Para.Table_Name); @@ -123,6 +126,9 @@ public class ProcessParaElementHandler extends AbstractElementHandler { throws SAXException { int AD_Process_Para_ID = Env.getContextAsInt(ctx.ctx, X_AD_Process_Para.COLUMNNAME_AD_Process_Para_ID); + if (processparas.contains(AD_Process_Para_ID)) + return; + processparas.add(AD_Process_Para_ID); X_AD_Process_Para m_Processpara = new X_AD_Process_Para(ctx.ctx, AD_Process_Para_ID, getTrxName(ctx)); 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 fee37ccde9..a33cdf932e 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 @@ -16,6 +16,7 @@ *****************************************************************************/ package org.adempiere.pipo2.handler; +import java.util.ArrayList; import java.util.List; import javax.xml.transform.sax.TransformerHandler; @@ -40,6 +41,8 @@ import org.xml.sax.helpers.AttributesImpl; public class ReportViewColElementHandler extends AbstractElementHandler { + private List viewcols = new ArrayList(); + public void startElement(PIPOContext ctx, Element element) throws SAXException { List excludes = defaultExcludeList(X_AD_ReportView_Col.Table_Name); @@ -148,6 +151,10 @@ public class ReportViewColElementHandler extends AbstractElementHandler { throws SAXException { int AD_ReportView_Col_ID = Env.getContextAsInt(ctx.ctx, X_AD_ReportView_Col.COLUMNNAME_AD_ReportView_Col_ID); + if (viewcols.contains(AD_ReportView_Col_ID)) + return; + + viewcols.add(AD_ReportView_Col_ID); X_AD_ReportView_Col m_Reportview_Col = new X_AD_ReportView_Col(ctx.ctx, AD_ReportView_Col_ID, getTrxName(ctx)); 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 42b4c4f39b..ba48d51a47 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 @@ -18,6 +18,7 @@ package org.adempiere.pipo2.handler; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.util.ArrayList; import java.util.List; import java.util.logging.Level; @@ -50,6 +51,8 @@ public class TabElementHandler extends AbstractElementHandler { private FieldElementHandler fieldHandler = new FieldElementHandler(); + private List tabs = new ArrayList(); + public void startElement(PIPOContext ctx, Element element) throws SAXException { List excludes = defaultExcludeList(X_AD_Tab.Table_Name); @@ -173,6 +176,9 @@ public class TabElementHandler extends AbstractElementHandler { throws SAXException { PackOut packOut = ctx.packOut; int AD_Tab_ID = Env.getContextAsInt(ctx.ctx, "AD_Tab_ID"); + if (tabs.contains(AD_Tab_ID)) + return; + tabs.add(AD_Tab_ID); boolean createElement = true; X_AD_Tab m_Tab = new X_AD_Tab (ctx.ctx, AD_Tab_ID, 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 05e15d9396..3fe14247cd 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 @@ -17,6 +17,7 @@ *****************************************************************************/ package org.adempiere.pipo2.handler; +import java.util.ArrayList; import java.util.List; import java.util.logging.Level; @@ -43,6 +44,8 @@ import org.xml.sax.helpers.AttributesImpl; public class WorkflowNodeElementHandler extends AbstractElementHandler { + private List nodes = new ArrayList(); + public void startElement(PIPOContext ctx, Element element) throws SAXException { List excludes = defaultExcludeList(X_AD_WF_Node.Table_Name); @@ -131,6 +134,9 @@ public class WorkflowNodeElementHandler extends AbstractElementHandler { throws SAXException { int AD_WF_Node_ID = Env.getContextAsInt(ctx.ctx, X_AD_WF_Node.COLUMNNAME_AD_WF_Node_ID); + if (nodes.contains(AD_WF_Node_ID)) + return; + nodes.add(AD_WF_Node_ID); AttributesImpl atts = new AttributesImpl(); MWFNode m_WF_Node = new MWFNode(ctx.ctx, AD_WF_Node_ID, getTrxName(ctx)); 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 b7479f50a2..957b26ddc5 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 @@ -16,6 +16,7 @@ *****************************************************************************/ package org.adempiere.pipo2.handler; +import java.util.ArrayList; import java.util.List; import javax.xml.transform.sax.TransformerHandler; @@ -44,6 +45,8 @@ import org.xml.sax.helpers.AttributesImpl; public class WorkflowNodeNextConditionElementHandler extends AbstractElementHandler { + private List nextconds = new ArrayList(); + public void startElement(PIPOContext ctx, Element element) throws SAXException { List excludes = defaultExcludeList(X_AD_WF_NextCondition.Table_Name); @@ -154,6 +157,9 @@ public class WorkflowNodeNextConditionElementHandler extends public void create(PIPOContext ctx, TransformerHandler document) throws SAXException { int ad_wf_nodenextcondition_id = Env.getContextAsInt(ctx.ctx, "AD_WF_NextCondition_ID"); + if (nextconds.contains(ad_wf_nodenextcondition_id)) + return; + nextconds.add(ad_wf_nodenextcondition_id); MWFNextCondition m_WF_NodeNextCondition = new MWFNextCondition( ctx.ctx, ad_wf_nodenextcondition_id, null); if (ctx.packOut.getFromDate() != null) { 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 bbe80bfda9..170f75bfd9 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 @@ -16,6 +16,7 @@ *****************************************************************************/ package org.adempiere.pipo2.handler; +import java.util.ArrayList; import java.util.List; import javax.xml.transform.sax.TransformerHandler; @@ -41,6 +42,8 @@ import org.xml.sax.helpers.AttributesImpl; public class WorkflowNodeNextElementHandler extends AbstractElementHandler { + private List nexts = new ArrayList(); + public void startElement(PIPOContext ctx, Element element) throws SAXException { List excludes = defaultExcludeList(MWFNodeNext.Table_Name); @@ -145,6 +148,9 @@ public class WorkflowNodeNextElementHandler extends AbstractElementHandler { public void create(PIPOContext ctx, TransformerHandler document) throws SAXException { int ad_wf_nodenext_id = Env.getContextAsInt(ctx.ctx, "AD_WF_NodeNext_ID"); + if (nexts.contains(ad_wf_nodenext_id)) + return; + nexts.add(ad_wf_nodenext_id); MWFNodeNext m_WF_NodeNext = new MWFNodeNext( ctx.ctx, ad_wf_nodenext_id, null); if (ctx.packOut.getFromDate() != null) {