use of org.compiere.model.X_AD_Process in project adempiere by adempiere.
the class ProcessElementHandler method startElement.
public void startElement(Properties ctx, Element element) throws SAXException {
String elementValue = element.getElementValue();
Attributes atts = element.attributes;
log.info(elementValue + " " + atts.getValue("Name"));
int id = 0;
String entitytype = atts.getValue("EntityType");
if (isProcessElement(ctx, entitytype)) {
String value = atts.getValue("Value");
// Get New process.
id = get_IDWithColumn(ctx, "AD_Process", "Value", value);
X_AD_Process m_Process = null;
int AD_Backup_ID = -1;
String Object_Status = null;
if (id > 0) {
m_Process = new X_AD_Process(ctx, id, getTrxName(ctx));
AD_Backup_ID = copyRecord(ctx, "AD_Process", m_Process);
Object_Status = "Update";
} else {
m_Process = new X_AD_Process(ctx, id, getTrxName(ctx));
if (id <= 0 && atts.getValue("AD_Process_ID") != null && Integer.parseInt(atts.getValue("AD_Process_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Process.setAD_Process_ID(Integer.parseInt(atts.getValue("AD_Process_ID")));
Object_Status = "New";
AD_Backup_ID = 0;
}
String name = atts.getValue("Name");
m_Process.setName(name);
name = atts.getValue("ADWorkflowNameID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_Workflow", "Name", name);
if (id <= 0) {
if (element.pass == 1) {
element.defer = true;
element.unresolved = "AD_Workflow: " + name;
return;
} else {
log.warning("AD_Workflow: " + name + " not found for Workflow: " + name);
}
}
if (id > 0)
m_Process.setAD_Workflow_ID(id);
}
name = atts.getValue("ADPrintFormatNameID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_PrintFormat", "Name", name);
if (id <= 0) {
if (element.pass == 1) {
element.defer = true;
element.unresolved = "AD_PrintFormat: " + name;
return;
} else {
log.warning("AD_PrintFormat: " + name + " not found for Process: " + m_Process.getName());
}
}
if (id > 0)
m_Process.setAD_PrintFormat_ID(id);
}
name = atts.getValue("ADReportViewNameID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_ReportView", "Name", name);
if (id <= 0) {
if (element.pass == 1) {
element.defer = true;
element.unresolved = "AD_ReportView: " + name;
return;
} else {
log.warning("AD_ReportView: " + name + " not found for Process: " + m_Process.getName());
}
}
if (id > 0)
m_Process.setAD_ReportView_ID(id);
}
name = atts.getValue("ADFormNameID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_Form", "Name", name);
if (id <= 0) {
element.defer = true;
element.unresolved = "AD_Form: " + name;
return;
}
m_Process.setAD_Form_ID(id);
}
name = atts.getValue("ADBrowseNameID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_Browse", "Name", name);
if (id <= 0) {
element.defer = true;
element.unresolved = "AD_Browse: " + name;
return;
}
m_Process.setAD_Browse_ID(id);
}
m_Process.setAccessLevel(atts.getValue("AccessLevel"));
m_Process.setClassname(getStringValue(atts, "Classname"));
m_Process.setDescription(getStringValue(atts, "Description"));
m_Process.setEntityType(atts.getValue("EntityType"));
m_Process.setHelp(getStringValue(atts, "Help"));
m_Process.setIsBetaFunctionality(Boolean.valueOf(atts.getValue("isBetaFunctionality")).booleanValue());
m_Process.setIsDirectPrint(Boolean.valueOf(atts.getValue("isDirectPrint")).booleanValue());
m_Process.setIsReport(Boolean.valueOf(atts.getValue("isReport")).booleanValue());
m_Process.setName(atts.getValue("Name"));
m_Process.setProcedureName(getStringValue(atts, "ProcedureName"));
m_Process.setStatistic_Count(0);
m_Process.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
m_Process.setStatistic_Seconds(0);
m_Process.setValue(atts.getValue("Value"));
m_Process.setWorkflowValue(atts.getValue("WorkflowValue"));
m_Process.setShowHelp((getStringValue(atts, "ShowHelp")));
m_Process.setJasperReport(getStringValue(atts, "JasperReport"));
if (m_Process.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Process.getName(), "Process", m_Process.get_ID(), AD_Backup_ID, Object_Status, "AD_Process", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Process"));
element.recordId = m_Process.getAD_Process_ID();
} else {
record_log(ctx, 0, m_Process.getName(), "Process", m_Process.get_ID(), AD_Backup_ID, Object_Status, "AD_Process", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Process"));
throw new POSaveFailedException("Process");
}
} else {
element.skip = true;
}
}
use of org.compiere.model.X_AD_Process in project adempiere by adempiere.
the class ProcessElementHandler method create.
public void create(Properties ctx, TransformerHandler document) throws SAXException {
int AD_Process_ID = Env.getContextAsInt(ctx, "AD_Process_ID");
if (processes.contains(AD_Process_ID))
return;
processes.add(AD_Process_ID);
PackOut packOut = (PackOut) ctx.get("PackOutProcess");
String sqlW = "SELECT AD_Process_ID FROM AD_PROCESS WHERE AD_PROCESS_ID = " + AD_Process_ID;
AttributesImpl atts = new AttributesImpl();
PreparedStatement pstmt1 = null;
pstmt1 = DB.prepareStatement(sqlW, getTrxName(ctx));
try {
ResultSet rs1 = pstmt1.executeQuery();
while (rs1.next()) {
X_AD_Process m_Process = new X_AD_Process(ctx, rs1.getInt("AD_Process_ID"), null);
log.log(Level.INFO, "AD_ReportView_ID: " + m_Process.getAD_Process_ID());
if (m_Process.isReport() && m_Process.getAD_ReportView_ID() > 0) {
packOut.createReportview(m_Process.getAD_ReportView_ID(), document);
}
if (m_Process.isReport() && m_Process.getAD_PrintFormat_ID() > 0) {
packOut.createPrintFormat(m_Process.getAD_PrintFormat_ID(), document);
}
if (m_Process.getAD_Workflow_ID() > 0) {
packOut.createWorkflow(m_Process.getAD_Workflow_ID(), document);
}
if (m_Process.getAD_Form_ID() > 0) {
packOut.createForm(m_Process.getAD_Form_ID(), document);
}
if (m_Process.getAD_Browse_ID() > 0) {
packOut.createBrowse(m_Process.getAD_Browse_ID(), document);
}
createProcessBinding(atts, m_Process);
document.startElement("", "", "process", atts);
// processpara tags
String sqlP = "SELECT * FROM AD_PROCESS_PARA WHERE AD_PROCESS_ID = " + AD_Process_ID + " ORDER BY " + X_AD_Process_Para.COLUMNNAME_SeqNo + "," + X_AD_Process_Para.COLUMNNAME_AD_Process_Para_ID;
PreparedStatement pstmtP = null;
pstmtP = DB.prepareStatement(sqlP, getTrxName(ctx));
try {
ResultSet rsP = pstmtP.executeQuery();
while (rsP.next()) {
if (rsP.getInt("AD_Reference_ID") > 0)
packOut.createReference(rsP.getInt("AD_Reference_ID"), document);
if (rsP.getInt("AD_Reference_Value_ID") > 0)
packOut.createReference(rsP.getInt("AD_Reference_Value_ID"), document);
if (rsP.getInt("AD_Val_Rule_ID") > 0)
packOut.createDynamicRuleValidation(rsP.getInt("AD_Val_Rule_ID"), document);
createProcessPara(ctx, document, rsP.getInt("AD_Process_Para_ID"));
}
rsP.close();
pstmtP.close();
pstmtP = null;
} catch (Exception e) {
log.log(Level.SEVERE, "getProcess_Para", e);
if (e instanceof SAXException)
throw (SAXException) e;
else if (e instanceof SQLException)
throw new DatabaseAccessException("Failed to export process.", e);
else if (e instanceof RuntimeException)
throw (RuntimeException) e;
else
throw new RuntimeException("Failed to export process.", e);
} finally {
try {
if (pstmtP != null)
pstmtP.close();
} catch (Exception e) {
}
pstmtP = null;
}
document.endElement("", "", "process");
}
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;
}
}
Aggregations