Search in sources :

Example 1 with PackOut

use of org.adempiere.pipo2.PackOut in project idempiere by idempiere.

the class ReportViewElementHandler method create.

public void create(PIPOContext ctx, TransformerHandler document) throws SAXException {
    PackOut packOut = ctx.packOut;
    int AD_ReportView_ID = Env.getContextAsInt(ctx.ctx, "AD_ReportView_ID");
    if (ctx.packOut.isExported("AD_ReportView_ID" + "|" + AD_ReportView_ID))
        return;
    AttributesImpl atts = new AttributesImpl();
    MReportView m_Reportview = new MReportView(ctx.ctx, AD_ReportView_ID, getTrxName(ctx));
    // Export Table if neccessary
    ElementHandler tableHandler = packOut.getHandler(I_AD_Table.Table_Name);
    try {
        tableHandler.packOut(packOut, document, null, m_Reportview.getAD_Table_ID());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    boolean createElement = isPackOutElement(ctx, m_Reportview);
    if (createElement) {
        verifyPackOutRequirement(m_Reportview);
        addTypeName(atts, "table");
        document.startElement("", "", I_AD_ReportView.Table_Name, atts);
        createReportViewBinding(ctx, document, m_Reportview);
    }
    String sql = "SELECT AD_ReportView_Col_ID FROM AD_ReportView_Col WHERE AD_Reportview_ID= " + AD_ReportView_ID;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
        pstmt = DB.prepareStatement(sql, getTrxName(ctx));
        rs = pstmt.executeQuery();
        while (rs.next()) {
            createReportViewCol(ctx, document, rs.getInt("AD_ReportView_Col_ID"));
        }
    } catch (SQLException e) {
        throw new DBException(e);
    } finally {
        DB.close(rs, pstmt);
    }
    sql = "SELECT AD_Column_ID FROM AD_ReportView_Column WHERE AD_Reportview_ID= " + AD_ReportView_ID;
    pstmt = null;
    rs = null;
    try {
        pstmt = DB.prepareStatement(sql, getTrxName(ctx));
        rs = pstmt.executeQuery();
        while (rs.next()) {
            createReportViewColumn(ctx, document, AD_ReportView_ID, rs.getInt("AD_Column_ID"));
        }
    } catch (SQLException e) {
        throw new DBException(e);
    } finally {
        DB.close(rs, pstmt);
    }
    if (createElement) {
        document.endElement("", "", MReportView.Table_Name);
    }
    sql = "SELECT AD_PrintFormat_ID FROM AD_PrintFormat WHERE AD_ReportView_ID=" + AD_ReportView_ID + " AND AD_Client_ID=" + Env.getAD_Client_ID(ctx.ctx);
    pstmt = null;
    rs = null;
    try {
        pstmt = DB.prepareStatement(sql, getTrxName(ctx));
        rs = pstmt.executeQuery();
        while (rs.next()) {
            ElementHandler pftHandler = packOut.getHandler(I_AD_PrintFormat.Table_Name);
            pftHandler.packOut(packOut, document, null, rs.getInt(1));
        }
    } catch (Exception e) {
        throw new AdempiereException(e);
    } finally {
        DB.close(rs, pstmt);
    }
}
Also used : DBException(org.adempiere.exceptions.DBException) SQLException(java.sql.SQLException) PackOut(org.adempiere.pipo2.PackOut) PreparedStatement(java.sql.PreparedStatement) SQLException(java.sql.SQLException) POSaveFailedException(org.adempiere.pipo2.exception.POSaveFailedException) DBException(org.adempiere.exceptions.DBException) AdempiereException(org.adempiere.exceptions.AdempiereException) SAXException(org.xml.sax.SAXException) AttributesImpl(org.xml.sax.helpers.AttributesImpl) AdempiereException(org.adempiere.exceptions.AdempiereException) ResultSet(java.sql.ResultSet) MReportView(org.compiere.model.MReportView) AbstractElementHandler(org.adempiere.pipo2.AbstractElementHandler) ElementHandler(org.adempiere.pipo2.ElementHandler)

Example 2 with PackOut

use of org.adempiere.pipo2.PackOut in project idempiere by idempiere.

the class SQLStatementElementHandler method packOut.

public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, int field) throws Exception {
    PackoutItem detail = packout.getCurrentPackoutItem();
    Env.setContext(packout.getCtx().ctx, SQLElementParameters.SQL_STATEMENT, (String) detail.getProperty(SQLElementParameters.SQL_STATEMENT));
    Env.setContext(packout.getCtx().ctx, SQLElementParameters.DB_TYPE, (String) detail.getProperty(SQLElementParameters.DB_TYPE));
    this.create(packout.getCtx(), packoutHandler);
    packout.getCtx().ctx.remove(SQLElementParameters.SQL_STATEMENT);
    packout.getCtx().ctx.remove(SQLElementParameters.DB_TYPE);
}
Also used : PackoutItem(org.adempiere.pipo2.PackoutItem)

Example 3 with PackOut

use of org.adempiere.pipo2.PackOut in project idempiere by idempiere.

the class ShellScriptElementHandler method packOut.

@Override
public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, int recordId) throws Exception {
    PackoutItem detail = packout.getCurrentPackoutItem();
    Env.setContext(packout.getCtx().ctx, MPackageExpDetail.COLUMNNAME_ExecCode, (String) detail.getProperty(MPackageExpDetail.COLUMNNAME_ExecCode));
    this.create(packout.getCtx(), packoutHandler);
    packout.getCtx().ctx.remove(MPackageExpDetail.COLUMNNAME_ExecCode);
}
Also used : PackoutItem(org.adempiere.pipo2.PackoutItem)

Example 4 with PackOut

use of org.adempiere.pipo2.PackOut in project idempiere by idempiere.

the class TabElementHandler method create.

public void create(PIPOContext ctx, TransformerHandler document) throws SAXException {
    PackOut packOut = ctx.packOut;
    int AD_Tab_ID = Env.getContextAsInt(ctx.ctx, "AD_Tab_ID");
    if (ctx.packOut.isExported("AD_Tab_ID" + "|" + AD_Tab_ID))
        return;
    X_AD_Tab m_Tab = new X_AD_Tab(ctx.ctx, AD_Tab_ID, getTrxName(ctx));
    boolean createElement = isPackOutElement(ctx, m_Tab);
    if (createElement) {
        verifyPackOutRequirement(m_Tab);
        AttributesImpl atts = new AttributesImpl();
        addTypeName(atts, "table");
        document.startElement("", "", I_AD_Tab.Table_Name, atts);
        createTabBinding(ctx, document, m_Tab);
        packOut.getCtx().ctx.put("Table_Name", X_AD_Tab.Table_Name);
        try {
            new CommonTranslationHandler().packOut(packOut, document, null, m_Tab.get_ID());
        } catch (Exception e) {
            if (log.isLoggable(Level.INFO))
                log.info(e.toString());
        }
    }
    // Fields tags.
    String sql = "SELECT AD_Field_ID FROM AD_FIELD WHERE AD_TAB_ID = " + AD_Tab_ID + "ORDER BY SEQNO asc";
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
        pstmt = DB.prepareStatement(sql, getTrxName(ctx));
        rs = pstmt.executeQuery();
        while (rs.next()) {
            createField(ctx, document, rs.getInt("AD_Field_ID"));
        }
    } catch (SQLException e) {
        log.log(Level.SEVERE, e.getLocalizedMessage(), e);
        throw new DatabaseAccessException("Failed to export window tab", e);
    } finally {
        DB.close(rs, pstmt);
    }
    if (createElement) {
        document.endElement("", "", X_AD_Tab.Table_Name);
    }
    if (m_Tab.getAD_Process_ID() > 0) {
        try {
            ElementHandler handler = packOut.getHandler(I_AD_Process.Table_Name);
            handler.packOut(packOut, document, null, m_Tab.getAD_Process_ID());
        } catch (Exception e) {
            throw new AdempiereException(e);
        }
    }
}
Also used : SQLException(java.sql.SQLException) PackOut(org.adempiere.pipo2.PackOut) PreparedStatement(java.sql.PreparedStatement) X_AD_Tab(org.compiere.model.X_AD_Tab) SQLException(java.sql.SQLException) POSaveFailedException(org.adempiere.pipo2.exception.POSaveFailedException) AdempiereException(org.adempiere.exceptions.AdempiereException) DatabaseAccessException(org.adempiere.pipo2.exception.DatabaseAccessException) SAXException(org.xml.sax.SAXException) AttributesImpl(org.xml.sax.helpers.AttributesImpl) AdempiereException(org.adempiere.exceptions.AdempiereException) ResultSet(java.sql.ResultSet) AbstractElementHandler(org.adempiere.pipo2.AbstractElementHandler) ElementHandler(org.adempiere.pipo2.ElementHandler) DatabaseAccessException(org.adempiere.pipo2.exception.DatabaseAccessException)

Example 5 with PackOut

use of org.adempiere.pipo2.PackOut in project idempiere by idempiere.

the class TableElementHandler method create.

public void create(PIPOContext ctx, TransformerHandler document) throws SAXException {
    int AD_Table_ID = Env.getContextAsInt(ctx.ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Table_ID);
    if (ctx.packOut.isExported(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Table_ID + "|" + AD_Table_ID))
        return;
    PackOut packOut = ctx.packOut;
    AttributesImpl atts = new AttributesImpl();
    X_AD_Table m_Table = new X_AD_Table(ctx.ctx, AD_Table_ID, null);
    boolean createElement = isPackOutElement(ctx, m_Table);
    if (createElement) {
        verifyPackOutRequirement(m_Table);
        addTypeName(atts, "table");
        document.startElement("", "", I_AD_Table.Table_Name, atts);
        createTableBinding(ctx, document, m_Table);
    }
    try {
        List<MColumn> cols = new Query(ctx.ctx, MColumn.Table_Name, "AD_Table_ID=?", getTrxName(ctx)).setParameters(AD_Table_ID).setOrderBy(// Export key column as the first one
        "IsKey DESC, AD_Column_ID").list();
        for (MColumn col : cols) {
            ElementHandler handler = packOut.getHandler("AD_Element");
            handler.packOut(packOut, document, null, col.getAD_Element_ID());
            if (col.getAD_Reference_ID() > 0) {
                handler = packOut.getHandler("AD_Reference");
                handler.packOut(packOut, document, null, col.getAD_Reference_ID());
            }
            if (col.getAD_Reference_Value_ID() > 0) {
                handler = packOut.getHandler("AD_Reference");
                handler.packOut(packOut, document, null, col.getAD_Reference_Value_ID());
            }
            if (col.getAD_Process_ID() > 0) {
                handler = packOut.getHandler("AD_Process");
                handler.packOut(packOut, document, null, col.getAD_Process_ID());
            }
            if (col.getAD_Val_Rule_ID() > 0) {
                handler = packOut.getHandler("AD_Val_Rule");
                handler.packOut(packOut, document, null, col.getAD_Val_Rule_ID());
            }
            createColumn(ctx, document, col.getAD_Column_ID());
        }
    } catch (Exception e) {
        throw new AdempiereException(e);
    }
    try {
        List<MTableIndex> tis = new Query(ctx.ctx, MTableIndex.Table_Name, "AD_Table_ID=?", getTrxName(ctx)).setParameters(AD_Table_ID).setOrderBy("AD_TableIndex_ID").list();
        for (MTableIndex ti : tis) {
            createTableIndex(ctx, document, ti.getAD_TableIndex_ID());
        }
    } catch (Exception e) {
        throw new AdempiereException(e);
    }
    try {
        List<MViewComponent> vcs = new Query(ctx.ctx, MViewComponent.Table_Name, "AD_Table_ID=?", getTrxName(ctx)).setParameters(AD_Table_ID).setOrderBy("SeqNo, AD_ViewComponent_ID").list();
        for (MViewComponent vc : vcs) {
            createViewComponent(ctx, document, vc.getAD_ViewComponent_ID());
        }
    } catch (Exception e) {
        throw new AdempiereException(e);
    }
    if (createElement) {
        document.endElement("", "", X_AD_Table.Table_Name);
    }
}
Also used : MColumn(org.compiere.model.MColumn) Query(org.compiere.model.Query) MTableIndex(org.compiere.model.MTableIndex) PackOut(org.adempiere.pipo2.PackOut) POSaveFailedException(org.adempiere.pipo2.exception.POSaveFailedException) AdempiereException(org.adempiere.exceptions.AdempiereException) DatabaseAccessException(org.adempiere.pipo2.exception.DatabaseAccessException) SAXException(org.xml.sax.SAXException) AttributesImpl(org.xml.sax.helpers.AttributesImpl) AdempiereException(org.adempiere.exceptions.AdempiereException) X_AD_Table(org.compiere.model.X_AD_Table) AbstractElementHandler(org.adempiere.pipo2.AbstractElementHandler) ElementHandler(org.adempiere.pipo2.ElementHandler) MViewComponent(org.compiere.model.MViewComponent)

Aggregations

SAXException (org.xml.sax.SAXException)30 AttributesImpl (org.xml.sax.helpers.AttributesImpl)30 PackOut (org.adempiere.pipo2.PackOut)27 POSaveFailedException (org.adempiere.pipo2.exception.POSaveFailedException)25 AbstractElementHandler (org.adempiere.pipo2.AbstractElementHandler)14 ElementHandler (org.adempiere.pipo2.ElementHandler)14 SQLException (java.sql.SQLException)10 PreparedStatement (java.sql.PreparedStatement)9 ResultSet (java.sql.ResultSet)9 AdempiereException (org.adempiere.exceptions.AdempiereException)8 DBException (org.adempiere.exceptions.DBException)5 PackoutItem (org.adempiere.pipo2.PackoutItem)5 DatabaseAccessException (org.adempiere.pipo2.exception.DatabaseAccessException)5 Query (org.compiere.model.Query)4 X_AD_Menu (org.compiere.model.X_AD_Menu)3 GenericPO (org.adempiere.model.GenericPO)2 PoExporter (org.adempiere.pipo2.PoExporter)2 MColumn (org.compiere.model.MColumn)2 MTableIndex (org.compiere.model.MTableIndex)2 X_AD_InfoColumn (org.compiere.model.X_AD_InfoColumn)2