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);
}
}
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);
}
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);
}
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);
}
}
}
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);
}
}
Aggregations