IDEMPIERE-1256 2Pack exporting repeated elements

This commit is contained in:
Carlos Ruiz 2013-08-08 01:02:41 -05:00
parent bc2f43b356
commit 6c03341bc4
12 changed files with 83 additions and 2 deletions

View File

@ -20,16 +20,17 @@ import java.sql.Connection;
import java.sql.DatabaseMetaData; import java.sql.DatabaseMetaData;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.sax.TransformerHandler;
import org.adempiere.pipo2.AbstractElementHandler; import org.adempiere.pipo2.AbstractElementHandler;
import org.adempiere.pipo2.PIPOContext;
import org.adempiere.pipo2.PoExporter;
import org.adempiere.pipo2.Element; import org.adempiere.pipo2.Element;
import org.adempiere.pipo2.PIPOContext;
import org.adempiere.pipo2.PackOut; import org.adempiere.pipo2.PackOut;
import org.adempiere.pipo2.PoExporter;
import org.adempiere.pipo2.PoFiller; import org.adempiere.pipo2.PoFiller;
import org.adempiere.pipo2.exception.DatabaseAccessException; import org.adempiere.pipo2.exception.DatabaseAccessException;
import org.adempiere.pipo2.exception.POSaveFailedException; import org.adempiere.pipo2.exception.POSaveFailedException;
@ -49,6 +50,8 @@ import org.xml.sax.helpers.AttributesImpl;
public class ColumnElementHandler extends AbstractElementHandler { public class ColumnElementHandler extends AbstractElementHandler {
private List<Integer> processedColumns = new ArrayList<Integer>();
public void startElement(PIPOContext ctx, Element element) public void startElement(PIPOContext ctx, Element element)
throws SAXException { throws SAXException {
int success = 0; int success = 0;
@ -297,6 +300,12 @@ public class ColumnElementHandler extends AbstractElementHandler {
throws SAXException { throws SAXException {
int AD_Column_ID = Env.getContextAsInt(ctx.ctx, int AD_Column_ID = Env.getContextAsInt(ctx.ctx,
X_AD_Column.COLUMNNAME_AD_Column_ID); X_AD_Column.COLUMNNAME_AD_Column_ID);
if (processedColumns.contains(AD_Column_ID))
return;
processedColumns.add(AD_Column_ID);
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
X_AD_Column m_Column = new X_AD_Column(ctx.ctx, AD_Column_ID, X_AD_Column m_Column = new X_AD_Column(ctx.ctx, AD_Column_ID,
getTrxName(ctx)); getTrxName(ctx));

View File

@ -16,6 +16,7 @@
*****************************************************************************/ *****************************************************************************/
package org.adempiere.pipo2.handler; package org.adempiere.pipo2.handler;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@ -44,6 +45,8 @@ import org.xml.sax.helpers.AttributesImpl;
public class FieldElementHandler extends AbstractElementHandler { public class FieldElementHandler extends AbstractElementHandler {
private List<Integer> processedFields = new ArrayList<Integer>();
public void startElement(PIPOContext ctx, Element element) public void startElement(PIPOContext ctx, Element element)
throws SAXException { throws SAXException {
String entitytype = getStringValue(element, "EntityType"); String entitytype = getStringValue(element, "EntityType");
@ -169,6 +172,12 @@ public class FieldElementHandler extends AbstractElementHandler {
throws SAXException { throws SAXException {
int AD_Field_ID = Env.getContextAsInt(ctx.ctx, int AD_Field_ID = Env.getContextAsInt(ctx.ctx,
X_AD_Field.COLUMNNAME_AD_Field_ID); 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); X_AD_Field m_Field = new X_AD_Field(ctx.ctx, AD_Field_ID, null);
PackOut packOut = ctx.packOut; PackOut packOut = ctx.packOut;

View File

@ -16,6 +16,7 @@
*****************************************************************************/ *****************************************************************************/
package org.adempiere.pipo2.handler; package org.adempiere.pipo2.handler;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.sax.TransformerHandler;
@ -39,6 +40,8 @@ import org.xml.sax.helpers.AttributesImpl;
public class ImpFormatRowElementHandler extends AbstractElementHandler { public class ImpFormatRowElementHandler extends AbstractElementHandler {
private List<Integer> formatrows = new ArrayList<Integer>();
public void startElement(PIPOContext ctx, Element element) throws SAXException { public void startElement(PIPOContext ctx, Element element) throws SAXException {
String action = null; String action = null;
@ -151,6 +154,9 @@ public class ImpFormatRowElementHandler extends AbstractElementHandler {
public void create(PIPOContext ctx, TransformerHandler document) public void create(PIPOContext ctx, TransformerHandler document)
throws SAXException { throws SAXException {
int AD_ImpFormat_Row_ID = Env.getContextAsInt(ctx.ctx, X_AD_ImpFormat_Row.COLUMNNAME_AD_ImpFormat_Row_ID); 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)); 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) { if (ctx.packOut.getFromDate() != null) {

View File

@ -16,6 +16,7 @@
*****************************************************************************/ *****************************************************************************/
package org.adempiere.pipo2.handler; package org.adempiere.pipo2.handler;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.sax.TransformerHandler;
@ -38,6 +39,8 @@ import org.xml.sax.helpers.AttributesImpl;
public class PreferenceElementHandler extends AbstractElementHandler { public class PreferenceElementHandler extends AbstractElementHandler {
private List<Integer>processedPreferences = new ArrayList<Integer>();
public void startElement(PIPOContext ctx, Element element) public void startElement(PIPOContext ctx, Element element)
throws SAXException { throws SAXException {
@ -109,6 +112,11 @@ public class PreferenceElementHandler extends AbstractElementHandler {
throws SAXException { throws SAXException {
int AD_Preference_ID = Env.getContextAsInt(ctx.ctx, int AD_Preference_ID = Env.getContextAsInt(ctx.ctx,
X_AD_Preference.COLUMNNAME_AD_Preference_ID); 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, X_AD_Preference m_Preference = new X_AD_Preference(ctx.ctx,
AD_Preference_ID, getTrxName(ctx)); AD_Preference_ID, getTrxName(ctx));

View File

@ -17,6 +17,7 @@
*****************************************************************************/ *****************************************************************************/
package org.adempiere.pipo2.handler; package org.adempiere.pipo2.handler;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@ -40,6 +41,8 @@ import org.xml.sax.helpers.AttributesImpl;
public class PrintFormatItemElementHandler extends AbstractElementHandler { public class PrintFormatItemElementHandler extends AbstractElementHandler {
private List<Integer> formatitems = new ArrayList<Integer>();
public void startElement(PIPOContext ctx, Element element) public void startElement(PIPOContext ctx, Element element)
throws SAXException { throws SAXException {
@ -143,6 +146,9 @@ public class PrintFormatItemElementHandler extends AbstractElementHandler {
throws SAXException { throws SAXException {
int AD_PrintFormatItem_ID = Env.getContextAsInt(ctx.ctx, int AD_PrintFormatItem_ID = Env.getContextAsInt(ctx.ctx,
X_AD_PrintFormatItem.COLUMNNAME_AD_PrintFormatItem_ID); 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, X_AD_PrintFormatItem m_PrintFormatItem = new X_AD_PrintFormatItem(ctx.ctx,
AD_PrintFormatItem_ID, null); AD_PrintFormatItem_ID, null);

View File

@ -17,6 +17,7 @@
*****************************************************************************/ *****************************************************************************/
package org.adempiere.pipo2.handler; package org.adempiere.pipo2.handler;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.sax.TransformerHandler;
@ -37,6 +38,8 @@ import org.xml.sax.helpers.AttributesImpl;
public class PrintPaperElementHandler extends AbstractElementHandler { public class PrintPaperElementHandler extends AbstractElementHandler {
private List<Integer> papers = new ArrayList<Integer>();
public void startElement(PIPOContext ctx, Element element) public void startElement(PIPOContext ctx, Element element)
throws SAXException { throws SAXException {
@ -92,6 +95,9 @@ public class PrintPaperElementHandler extends AbstractElementHandler {
throws SAXException { throws SAXException {
int AD_PrintPaper_ID = Env.getContextAsInt(ctx.ctx, int AD_PrintPaper_ID = Env.getContextAsInt(ctx.ctx,
X_AD_PrintPaper.COLUMNNAME_AD_PrintPaper_ID); 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, X_AD_PrintPaper printPaper = new X_AD_PrintPaper(ctx.ctx,
AD_PrintPaper_ID, null); AD_PrintPaper_ID, null);

View File

@ -16,6 +16,7 @@
*****************************************************************************/ *****************************************************************************/
package org.adempiere.pipo2.handler; package org.adempiere.pipo2.handler;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@ -41,6 +42,8 @@ import org.xml.sax.helpers.AttributesImpl;
public class ProcessParaElementHandler extends AbstractElementHandler { public class ProcessParaElementHandler extends AbstractElementHandler {
private List<Integer> processparas = new ArrayList<Integer>();
public void startElement(PIPOContext ctx, Element element) public void startElement(PIPOContext ctx, Element element)
throws SAXException { throws SAXException {
List<String> excludes = defaultExcludeList(X_AD_Process_Para.Table_Name); List<String> excludes = defaultExcludeList(X_AD_Process_Para.Table_Name);
@ -123,6 +126,9 @@ public class ProcessParaElementHandler extends AbstractElementHandler {
throws SAXException { throws SAXException {
int AD_Process_Para_ID = Env.getContextAsInt(ctx.ctx, int AD_Process_Para_ID = Env.getContextAsInt(ctx.ctx,
X_AD_Process_Para.COLUMNNAME_AD_Process_Para_ID); 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, X_AD_Process_Para m_Processpara = new X_AD_Process_Para(ctx.ctx,
AD_Process_Para_ID, getTrxName(ctx)); AD_Process_Para_ID, getTrxName(ctx));

View File

@ -16,6 +16,7 @@
*****************************************************************************/ *****************************************************************************/
package org.adempiere.pipo2.handler; package org.adempiere.pipo2.handler;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.sax.TransformerHandler;
@ -40,6 +41,8 @@ import org.xml.sax.helpers.AttributesImpl;
public class ReportViewColElementHandler extends AbstractElementHandler { public class ReportViewColElementHandler extends AbstractElementHandler {
private List<Integer> viewcols = new ArrayList<Integer>();
public void startElement(PIPOContext ctx, Element element) public void startElement(PIPOContext ctx, Element element)
throws SAXException { throws SAXException {
List<String> excludes = defaultExcludeList(X_AD_ReportView_Col.Table_Name); List<String> excludes = defaultExcludeList(X_AD_ReportView_Col.Table_Name);
@ -148,6 +151,10 @@ public class ReportViewColElementHandler extends AbstractElementHandler {
throws SAXException { throws SAXException {
int AD_ReportView_Col_ID = Env.getContextAsInt(ctx.ctx, int AD_ReportView_Col_ID = Env.getContextAsInt(ctx.ctx,
X_AD_ReportView_Col.COLUMNNAME_AD_ReportView_Col_ID); 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, X_AD_ReportView_Col m_Reportview_Col = new X_AD_ReportView_Col(ctx.ctx,
AD_ReportView_Col_ID, getTrxName(ctx)); AD_ReportView_Col_ID, getTrxName(ctx));

View File

@ -18,6 +18,7 @@ package org.adempiere.pipo2.handler;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@ -50,6 +51,8 @@ public class TabElementHandler extends AbstractElementHandler {
private FieldElementHandler fieldHandler = new FieldElementHandler(); private FieldElementHandler fieldHandler = new FieldElementHandler();
private List<Integer> tabs = new ArrayList<Integer>();
public void startElement(PIPOContext ctx, Element element) throws SAXException { public void startElement(PIPOContext ctx, Element element) throws SAXException {
List<String> excludes = defaultExcludeList(X_AD_Tab.Table_Name); List<String> excludes = defaultExcludeList(X_AD_Tab.Table_Name);
@ -173,6 +176,9 @@ public class TabElementHandler extends AbstractElementHandler {
throws SAXException { throws SAXException {
PackOut packOut = ctx.packOut; PackOut packOut = ctx.packOut;
int AD_Tab_ID = Env.getContextAsInt(ctx.ctx, "AD_Tab_ID"); 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; boolean createElement = true;
X_AD_Tab m_Tab = new X_AD_Tab (ctx.ctx, AD_Tab_ID, getTrxName(ctx)); X_AD_Tab m_Tab = new X_AD_Tab (ctx.ctx, AD_Tab_ID, getTrxName(ctx));

View File

@ -17,6 +17,7 @@
*****************************************************************************/ *****************************************************************************/
package org.adempiere.pipo2.handler; package org.adempiere.pipo2.handler;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@ -43,6 +44,8 @@ import org.xml.sax.helpers.AttributesImpl;
public class WorkflowNodeElementHandler extends AbstractElementHandler { public class WorkflowNodeElementHandler extends AbstractElementHandler {
private List<Integer> nodes = new ArrayList<Integer>();
public void startElement(PIPOContext ctx, Element element) public void startElement(PIPOContext ctx, Element element)
throws SAXException { throws SAXException {
List<String> excludes = defaultExcludeList(X_AD_WF_Node.Table_Name); List<String> excludes = defaultExcludeList(X_AD_WF_Node.Table_Name);
@ -131,6 +134,9 @@ public class WorkflowNodeElementHandler extends AbstractElementHandler {
throws SAXException { throws SAXException {
int AD_WF_Node_ID = Env.getContextAsInt(ctx.ctx, int AD_WF_Node_ID = Env.getContextAsInt(ctx.ctx,
X_AD_WF_Node.COLUMNNAME_AD_WF_Node_ID); 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(); AttributesImpl atts = new AttributesImpl();
MWFNode m_WF_Node = new MWFNode(ctx.ctx, AD_WF_Node_ID, MWFNode m_WF_Node = new MWFNode(ctx.ctx, AD_WF_Node_ID,
getTrxName(ctx)); getTrxName(ctx));

View File

@ -16,6 +16,7 @@
*****************************************************************************/ *****************************************************************************/
package org.adempiere.pipo2.handler; package org.adempiere.pipo2.handler;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.sax.TransformerHandler;
@ -44,6 +45,8 @@ import org.xml.sax.helpers.AttributesImpl;
public class WorkflowNodeNextConditionElementHandler extends public class WorkflowNodeNextConditionElementHandler extends
AbstractElementHandler { AbstractElementHandler {
private List<Integer> nextconds = new ArrayList<Integer>();
public void startElement(PIPOContext ctx, Element element) public void startElement(PIPOContext ctx, Element element)
throws SAXException { throws SAXException {
List<String> excludes = defaultExcludeList(X_AD_WF_NextCondition.Table_Name); List<String> excludes = defaultExcludeList(X_AD_WF_NextCondition.Table_Name);
@ -154,6 +157,9 @@ public class WorkflowNodeNextConditionElementHandler extends
public void create(PIPOContext ctx, TransformerHandler document) public void create(PIPOContext ctx, TransformerHandler document)
throws SAXException { throws SAXException {
int ad_wf_nodenextcondition_id = Env.getContextAsInt(ctx.ctx, "AD_WF_NextCondition_ID"); 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( MWFNextCondition m_WF_NodeNextCondition = new MWFNextCondition(
ctx.ctx, ad_wf_nodenextcondition_id, null); ctx.ctx, ad_wf_nodenextcondition_id, null);
if (ctx.packOut.getFromDate() != null) { if (ctx.packOut.getFromDate() != null) {

View File

@ -16,6 +16,7 @@
*****************************************************************************/ *****************************************************************************/
package org.adempiere.pipo2.handler; package org.adempiere.pipo2.handler;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.sax.TransformerHandler;
@ -41,6 +42,8 @@ import org.xml.sax.helpers.AttributesImpl;
public class WorkflowNodeNextElementHandler extends AbstractElementHandler { public class WorkflowNodeNextElementHandler extends AbstractElementHandler {
private List<Integer> nexts = new ArrayList<Integer>();
public void startElement(PIPOContext ctx, Element element) throws SAXException { public void startElement(PIPOContext ctx, Element element) throws SAXException {
List<String> excludes = defaultExcludeList(MWFNodeNext.Table_Name); List<String> excludes = defaultExcludeList(MWFNodeNext.Table_Name);
@ -145,6 +148,9 @@ public class WorkflowNodeNextElementHandler extends AbstractElementHandler {
public void create(PIPOContext ctx, TransformerHandler document) public void create(PIPOContext ctx, TransformerHandler document)
throws SAXException { throws SAXException {
int ad_wf_nodenext_id = Env.getContextAsInt(ctx.ctx, "AD_WF_NodeNext_ID"); 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( MWFNodeNext m_WF_NodeNext = new MWFNodeNext(
ctx.ctx, ad_wf_nodenext_id, null); ctx.ctx, ad_wf_nodenext_id, null);
if (ctx.packOut.getFromDate() != null) { if (ctx.packOut.getFromDate() != null) {