use of org.compiere.model.X_AD_Workflow in project adempiere by adempiere.
the class WorkflowElementHandler method create.
public void create(Properties ctx, TransformerHandler document) throws SAXException {
int AD_Workflow_ID = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Workflow_ID);
if (workflows.contains(AD_Workflow_ID))
return;
workflows.add(AD_Workflow_ID);
String sql = "SELECT Name FROM AD_Workflow WHERE AD_Workflow_ID= " + AD_Workflow_ID;
int ad_wf_nodenext_id = 0;
int ad_wf_nodenextcondition_id = 0;
AttributesImpl atts = new AttributesImpl();
PreparedStatement pstmt = null;
ResultSet rs = null;
pstmt = DB.prepareStatement(sql, getTrxName(ctx));
try {
rs = pstmt.executeQuery();
while (rs.next()) {
X_AD_Workflow m_Workflow = new X_AD_Workflow(ctx, AD_Workflow_ID, null);
createWorkflowBinding(atts, m_Workflow);
document.startElement("", "", "workflow", atts);
String sql1 = "SELECT AD_WF_Node_ID FROM AD_WF_Node WHERE AD_Workflow_ID = " + AD_Workflow_ID + " ORDER BY " + X_AD_WF_Node.COLUMNNAME_AD_WF_Node_ID;
PreparedStatement pstmt1 = null;
ResultSet rs1 = null;
try {
pstmt1 = DB.prepareStatement(sql1, getTrxName(ctx));
// Generated workflowNodeNext(s) and
// workflowNodeNextCondition(s)
rs1 = pstmt1.executeQuery();
while (rs1.next()) {
int nodeId = rs1.getInt("AD_WF_Node_ID");
createNode(ctx, document, nodeId);
ad_wf_nodenext_id = 0;
String sqlnn = "SELECT AD_WF_NodeNext_ID FROM AD_WF_NodeNext WHERE AD_WF_Node_ID = ?" + " ORDER BY " + X_AD_WF_NodeNext.COLUMNNAME_AD_WF_NodeNext_ID;
PreparedStatement pstmtnn = null;
ResultSet rsnn = null;
try {
pstmtnn = DB.prepareStatement(sqlnn, getTrxName(ctx));
pstmtnn.setInt(1, nodeId);
rsnn = pstmtnn.executeQuery();
while (rsnn.next()) {
ad_wf_nodenext_id = rsnn.getInt("AD_WF_NodeNext_ID");
if (ad_wf_nodenext_id > 0) {
createNodeNext(ctx, document, ad_wf_nodenext_id);
ad_wf_nodenextcondition_id = 0;
String sqlnnc = "SELECT AD_WF_NextCondition_ID FROM AD_WF_NextCondition WHERE AD_WF_NodeNext_ID = ?" + " ORDER BY " + X_AD_WF_NextCondition.COLUMNNAME_AD_WF_NextCondition_ID;
PreparedStatement pstmtnnc = null;
ResultSet rsnnc = null;
try {
pstmtnnc = DB.prepareStatement(sqlnnc, getTrxName(ctx));
pstmtnnc.setInt(1, ad_wf_nodenext_id);
rsnnc = pstmtnnc.executeQuery();
while (rsnnc.next()) {
ad_wf_nodenextcondition_id = rsnnc.getInt("AD_WF_NextCondition_ID");
log.info("ad_wf_nodenextcondition_id: " + String.valueOf(ad_wf_nodenextcondition_id));
if (ad_wf_nodenextcondition_id > 0) {
createNodeNextCondition(ctx, document, ad_wf_nodenextcondition_id);
}
}
} finally {
DB.close(rsnnc, pstmtnnc);
rsnnc = null;
pstmtnnc = null;
}
}
}
} finally {
DB.close(rsnn, pstmtnn);
rsnn = null;
pstmtnn = null;
}
}
} finally {
DB.close(rs1, pstmt1);
rs1 = null;
pstmt1 = null;
document.endElement("", "", "workflow");
}
}
} catch (Exception e) {
log.log(Level.SEVERE, "Workflow", e);
if (e instanceof SAXException)
throw (SAXException) e;
else if (e instanceof SQLException)
throw new DatabaseAccessException("Failed to export workflow.", e);
else
throw new RuntimeException("Failed to export workflow.", e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
}
Aggregations