use of org.adempiere.pipo.PackOut in project adempiere by adempiere.
the class ReportViewElementHandler method create.
public void create(Properties ctx, TransformerHandler document) throws SAXException {
PackOut packOut = (PackOut) ctx.get("PackOutProcess");
int AD_ReportView_ID = Env.getContextAsInt(ctx, "AD_ReportView_ID");
if (views.contains(AD_ReportView_ID))
return;
views.add(AD_ReportView_ID);
String sql = "SELECT * FROM AD_ReportView WHERE AD_ReportView_ID= " + AD_ReportView_ID;
PreparedStatement pstmt = null;
pstmt = DB.prepareStatement(sql, getTrxName(ctx));
AttributesImpl atts = new AttributesImpl();
try {
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
X_AD_ReportView m_Reportview = new X_AD_ReportView(ctx, rs.getInt("AD_Reportview_ID"), null);
atts = createReportViewBinding(atts, m_Reportview);
document.startElement("", "", "reportview", atts);
document.endElement("", "", "reportview");
String sql1 = "SELECT * FROM AD_Printformat WHERE AD_Reportview_ID=" + AD_ReportView_ID + " AND AD_Client_ID=" + Env.getAD_Client_ID(ctx) + " ORDER BY " + X_AD_PrintFormat.COLUMNNAME_AD_PrintFormat_ID;
PreparedStatement pstmt1 = null;
pstmt1 = DB.prepareStatement(sql1, getTrxName(ctx));
try {
ResultSet rs1 = pstmt1.executeQuery();
while (rs1.next()) {
// Export Table if neccessary
packOut.createTable(rs1.getInt("AD_Table_ID"), document);
packOut.createPrintFormat(rs1.getInt("AD_Printformat_ID"), document);
}
rs1.close();
pstmt1.close();
pstmt1 = null;
} finally {
try {
if (pstmt1 != null)
pstmt1.close();
} catch (Exception e) {
}
pstmt1 = null;
}
atts.clear();
sql1 = "SELECT * FROM AD_ReportView_Col WHERE AD_Reportview_ID= " + AD_ReportView_ID;
pstmt1 = null;
pstmt1 = DB.prepareStatement(sql1, getTrxName(ctx));
try {
ResultSet rs1 = pstmt1.executeQuery();
while (rs1.next()) {
createReportViewCol(ctx, document, rs1.getInt("AD_ReportView_Col_ID"));
}
rs1.close();
pstmt1.close();
pstmt1 = null;
} finally {
try {
if (pstmt1 != null)
pstmt1.close();
} catch (Exception e) {
}
pstmt1 = null;
}
}
rs.close();
pstmt.close();
pstmt = null;
} catch (Exception e) {
log.log(Level.SEVERE, "reportview", e);
if (e instanceof SAXException)
throw (SAXException) e;
else if (e instanceof SQLException)
throw new DatabaseAccessException("Failed to export report view.", e);
else if (e instanceof RuntimeException)
throw (RuntimeException) e;
else
throw new RuntimeException("Failed to export report view.", e);
} finally {
try {
if (pstmt != null)
pstmt.close();
} catch (Exception e) {
}
pstmt = null;
}
}
use of org.adempiere.pipo.PackOut in project adempiere by adempiere.
the class ViewColumnElementHandler method create.
public void create(Properties ctx, TransformerHandler document) throws SAXException {
int AD_View_Column_ID = Env.getContextAsInt(ctx, X_AD_View_Column.COLUMNNAME_AD_View_Column_ID);
MViewColumn m_ColumnView = new MViewColumn(ctx, AD_View_Column_ID, null);
AttributesImpl atts = new AttributesImpl();
createViewColumnBinding(atts, m_ColumnView);
PackOut packOut = (PackOut) ctx.get("PackOutProcess");
document.startElement("", "", "viewcolumn", atts);
document.endElement("", "", "viewcolumn");
}
use of org.adempiere.pipo.PackOut in project adempiere by adempiere.
the class ViewElementHandler method create.
public void create(Properties ctx, TransformerHandler document) throws SAXException {
int AD_View_ID = Env.getContextAsInt(ctx, "AD_View_ID");
PackOut packOut = (PackOut) ctx.get("PackOutProcess");
X_AD_View m_View = new X_AD_View(ctx, AD_View_ID, null);
AttributesImpl atts = new AttributesImpl();
createViewBinding(atts, m_View);
document.startElement("", "", "view", atts);
// Tab Tag
StringBuilder whereClause = new StringBuilder(I_AD_View.COLUMNNAME_AD_View_ID).append("=?");
List<MViewDefinition> viewDefinitions = new Query(ctx, I_AD_View_Definition.Table_Name, whereClause.toString(), getTrxName(ctx)).setParameters(m_View.getAD_View_ID()).setOrderBy(X_AD_View_Definition.COLUMNNAME_SeqNo + "," + X_AD_View_Definition.COLUMNNAME_AD_View_Definition_ID).list();
for (MViewDefinition vd : viewDefinitions) {
//Is not export table definition because maybe cause changes in tables
//So that of tables should are created before to import Browser
//packOut.createTable(vd.getAD_Table_ID(), document);
createViewDefinition(ctx, document, vd.getAD_View_Definition_ID());
}
// Loop tags.
document.endElement("", "", "view");
}
use of org.adempiere.pipo.PackOut in project adempiere by adempiere.
the class TabElementHandler method create.
public void create(Properties ctx, TransformerHandler document) throws SAXException {
PackOut packOut = (PackOut) ctx.get("PackOutProcess");
int AD_Tab_ID = Env.getContextAsInt(ctx, X_AD_Tab.COLUMNNAME_AD_Tab_ID);
X_AD_Tab m_Tab = new X_AD_Tab(ctx, AD_Tab_ID, getTrxName(ctx));
AttributesImpl atts = new AttributesImpl();
createTabBinding(atts, m_Tab);
document.startElement("", "", "tab", atts);
//Fields tags.
String sql = "SELECT * FROM AD_FIELD WHERE AD_TAB_ID = " + AD_Tab_ID + "ORDER BY SEQNO asc, " + X_AD_Field.COLUMNNAME_AD_Field_ID;
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 (Exception e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
throw new DatabaseAccessException("Failed to export window tab", e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
document.endElement("", "", "tab");
if (m_Tab.getAD_Process_ID() > 0) {
packOut.createProcess(m_Tab.getAD_Process_ID(), document);
}
}
use of org.adempiere.pipo.PackOut in project adempiere by adempiere.
the class TableElementHandler method create.
public void create(Properties ctx, TransformerHandler document) throws SAXException {
int AD_Table_ID = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Table_ID);
PackOut packOut = (PackOut) ctx.get("PackOutProcess");
boolean exported = isTableProcess(ctx, AD_Table_ID);
AttributesImpl atts = new AttributesImpl();
//Export table if not already done so
if (!exported) {
String sql = "SELECT Name FROM AD_Table WHERE AD_Table_ID= " + AD_Table_ID;
PreparedStatement pstmt = null;
pstmt = DB.prepareStatement(sql, getTrxName(ctx));
try {
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
X_AD_Table m_Table = new X_AD_Table(ctx, AD_Table_ID, null);
createTableBinding(atts, m_Table);
document.startElement("", "", "table", atts);
String sql1 = "SELECT * FROM AD_Column WHERE AD_Table_ID = " + AD_Table_ID + // Export key column as the first one
" ORDER BY IsKey DESC, AD_Column_ID";
PreparedStatement pstmt1 = null;
pstmt1 = DB.prepareStatement(sql1, getTrxName(ctx));
try {
ResultSet rs1 = pstmt1.executeQuery();
while (rs1.next()) {
packOut.createAdElement(rs1.getInt("AD_Element_ID"), document);
if (rs1.getInt("AD_Reference_ID") > 0)
packOut.createReference(rs1.getInt("AD_Reference_ID"), document);
if (rs1.getInt("AD_Reference_Value_ID") > 0)
packOut.createReference(rs1.getInt("AD_Reference_Value_ID"), document);
if (rs1.getInt("AD_Process_ID") > 0)
packOut.createProcess(rs1.getInt("AD_Process_ID"), document);
if (rs1.getInt("AD_Val_Rule_ID") > 0)
packOut.createDynamicRuleValidation(rs1.getInt("AD_Val_Rule_ID"), document);
createColumn(ctx, document, rs1.getInt("AD_Column_ID"));
}
rs1.close();
pstmt1.close();
pstmt1 = null;
} catch (Exception e) {
log.log(Level.SEVERE, "getProcess", e);
} finally {
try {
if (pstmt1 != null)
pstmt1.close();
} catch (Exception e) {
}
pstmt1 = null;
}
document.endElement("", "", "table");
}
rs.close();
pstmt.close();
pstmt = null;
} catch (Exception e) {
log.log(Level.SEVERE, "getProcess", e);
} finally {
try {
if (pstmt != null)
pstmt.close();
} catch (Exception e) {
}
pstmt = null;
}
}
}
Aggregations