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) { element.defer = true; element.unresolved = "AD_Workflow: " + name; return; } 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; } }
private AttributesImpl createProcessBinding(AttributesImpl atts, X_AD_Process m_Process) { String sql = null; String name = null; atts.clear(); if (m_Process.getAD_Process_ID() <= PackOut.MAX_OFFICIAL_ID) atts.addAttribute( "", "", "AD_Process_ID", "CDATA", Integer.toString(m_Process.getAD_Process_ID())); atts.addAttribute( "", "", "Name", "CDATA", (m_Process.getName() != null ? m_Process.getName() : "")); if (m_Process.getAD_Workflow_ID() > 0) { sql = "SELECT Name FROM AD_Workflow WHERE AD_Workflow_ID=?"; name = DB.getSQLValueString(null, sql, m_Process.getAD_Workflow_ID()); atts.addAttribute("", "", "ADWorkflowNameID", "CDATA", name); } else atts.addAttribute("", "", "ADWorkflowNameID", "CDATA", ""); if (m_Process.getAD_Process_ID() > 0) { sql = "SELECT Name FROM AD_Process WHERE AD_Process_ID=?"; name = DB.getSQLValueString(null, sql, m_Process.getAD_Process_ID()); atts.addAttribute("", "", "ADProcessNameID", "CDATA", name); } else atts.addAttribute("", "", "ADProcessNameID", "CDATA", ""); if (m_Process.getAD_PrintFormat_ID() > 0) { sql = "SELECT Name FROM AD_PrintFormat WHERE AD_PrintFormat_ID=?"; name = DB.getSQLValueString(null, sql, m_Process.getAD_PrintFormat_ID()); atts.addAttribute("", "", "ADPrintFormatNameID", "CDATA", name); } else atts.addAttribute("", "", "ADPrintFormatNameID", "CDATA", ""); if (m_Process.getAD_ReportView_ID() > 0) { sql = "SELECT Name FROM AD_ReportView WHERE AD_ReportView_ID=?"; name = DB.getSQLValueString(null, sql, m_Process.getAD_ReportView_ID()); atts.addAttribute("", "", "ADReportViewNameID", "CDATA", name); } else atts.addAttribute("", "", "ADReportViewNameID", "CDATA", ""); if (m_Process.getAD_Form_ID() > 0) { sql = "SELECT Name FROM AD_Form WHERE AD_Form_ID=?"; name = DB.getSQLValueString(null, sql, m_Process.getAD_Form_ID()); atts.addAttribute("", "", "ADFormNameID", "CDATA", name); } else atts.addAttribute("", "", "ADFormNameID", "CDATA", ""); if (m_Process.getAD_Browse_ID() > 0) { sql = "SELECT Name FROM AD_Browse WHERE AD_Browse_ID=?"; name = DB.getSQLValueString(null, sql, m_Process.getAD_Browse_ID()); atts.addAttribute("", "", "ADBrowseNameID", "CDATA", name); } else atts.addAttribute("", "", "ADBrowseNameID", "CDATA", ""); atts.addAttribute( "", "", "AccessLevel", "CDATA", (m_Process.getAccessLevel() != null ? m_Process.getAccessLevel() : "")); atts.addAttribute( "", "", "Classname", "CDATA", (m_Process.getClassname() != null ? m_Process.getClassname() : "")); atts.addAttribute( "", "", "Description", "CDATA", (m_Process.getDescription() != null ? m_Process.getDescription() : "")); atts.addAttribute( "", "", "EntityType", "CDATA", (m_Process.getEntityType() != null ? m_Process.getEntityType() : "")); atts.addAttribute( "", "", "Help", "CDATA", (m_Process.getHelp() != null ? m_Process.getHelp() : "")); atts.addAttribute( "", "", "isBetaFunctionality", "CDATA", (m_Process.isBetaFunctionality() == true ? "true" : "false")); atts.addAttribute( "", "", "isDirectPrint", "CDATA", (m_Process.isDirectPrint() == true ? "true" : "false")); atts.addAttribute( "", "", "isReport", "CDATA", (m_Process.isReport() == true ? "true" : "false")); atts.addAttribute( "", "", "isActive", "CDATA", (m_Process.isActive() == true ? "true" : "false")); atts.addAttribute( "", "", "ProcedureName", "CDATA", (m_Process.getProcedureName() != null ? m_Process.getProcedureName() : "")); atts.addAttribute("", "", "StatisticCount", "CDATA", "0"); atts.addAttribute("", "", "StatisticSeconds", "CDATA", "0"); atts.addAttribute( "", "", "Value", "CDATA", (m_Process.getValue() != null ? m_Process.getValue() : "")); atts.addAttribute( "", "", "WorkflowValue", "CDATA", (m_Process.getWorkflowValue() != null ? m_Process.getWorkflowValue() : "")); atts.addAttribute( "", "", "ShowHelp", "CDATA", (m_Process.getShowHelp() != null ? m_Process.getShowHelp() : "")); atts.addAttribute( "", "", "JasperReport", "CDATA", (m_Process.getJasperReport() != null ? m_Process.getJasperReport() : "")); return atts; }