From 25cfe5ffc48a5e1ed4e9e1ad81ee1533f0b682b5 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 26 Apr 2007 08:46:31 +0000 Subject: [PATCH] Great contribution from Tim Heath! FR [ 1659903 ] Export & import WF in 2Pack Bug [ 1663186 ] 2pack is not exporting Dynamic Validation Contrib [ 1706928 ] 2Pack Workflow Import Functionality Contrib [ 1706940 ] 2Pack Workflow Export Functionality Contrib [ 1707038 ] 2Pack Dynamic Validation Rule Export Functionality Contrib [ 1707039 ] 2Pack Dynamic Validation Rule Import Functionality --- .../src/org/adempiere/pipo/PackInHandler.java | 575 ++++++++++++++---- base/src/org/adempiere/pipo/PackOut.java | 450 +++++++++++++- .../model/X_AD_Package_Exp_Detail.java | 24 +- .../316-trunk/008_2pack_enhancements.sql | 79 +++ 4 files changed, 1001 insertions(+), 127 deletions(-) create mode 100644 migration/316-trunk/008_2pack_enhancements.sql diff --git a/base/src/org/adempiere/pipo/PackInHandler.java b/base/src/org/adempiere/pipo/PackInHandler.java index 97c2797a7c..91abe8e275 100644 --- a/base/src/org/adempiere/pipo/PackInHandler.java +++ b/base/src/org/adempiere/pipo/PackInHandler.java @@ -46,6 +46,7 @@ import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; import org.compiere.Adempiere; import org.compiere.model.*; +import org.compiere.wf.*; import org.compiere.util.DB; import org.compiere.util.Env; import org.compiere.util.CLogger; @@ -61,6 +62,7 @@ import org.xml.sax.helpers.DefaultHandler; * @author Marco LOMBARDO, lombardo@mayking.com * @author Robert KLEIN, robeklein@hotmail * + * Contributor: William G. Heath - Import of workflows and dynamic validations */ public class PackInHandler extends DefaultHandler { @@ -88,7 +90,12 @@ public class PackInHandler extends DefaultHandler { private X_AD_ImpFormat_Row m_ImpFormat_row = null; private X_AD_ReportView m_Reportview = null; private X_AD_ReportView_Col m_Reportview_Col = null; + private X_AD_Val_Rule m_ValRule = null; private MTable m_Table = null; + private MWorkflow m_Workflow = null; + private MWFNode m_WFNode = null; + private MWFNodeNext m_WFNodeNext = null; + private MWFNextCondition m_WFNodeNextCondition = null; private MRole m_Role = null; private MColumn m_Column = null; private MTab m_Tab; @@ -101,7 +108,7 @@ public class PackInHandler extends DefaultHandler { public Object[] m_newValue = null; /** Set this if you want to update Dictionary */ public String m_UpdateMode = "true"; - String packageDirectory = null; + String packageDirectory = null; public String m_DatabaseType = "Oracle"; private boolean adempiereAD = false; private boolean adempieredata = false; @@ -150,7 +157,7 @@ public class PackInHandler extends DefaultHandler { if (Start_Doc==0){ PackIn pack = new PackIn(); packageDirectory = pack.m_Package_Dir; - m_UpdateMode = pack.m_UpdateMode; + m_UpdateMode = pack.m_UpdateMode; m_DatabaseType = pack.m_Database; File file = new File(""); fileSeperator = file.separator; @@ -521,40 +528,40 @@ public class PackInHandler extends DefaultHandler { String entitytype = atts.getValue("EntityType"); if (entitytype.compareTo("U") == 0 || entitytype.compareTo("D") == 0 && m_UpdateMode.compareTo("true") == 0) { String name = atts.getValue("Name"); - String tabname = atts.getValue("ADTabNameID"); - String colname = atts.getValue("ADColumnNameID"); -// log.info("Column Name ->"+colname); -// log.info("Database Name ->"+m_DatabaseType); - /** - //Adjust for difference between Oracle and PostgreSql DataTypes - if (m_DatabaseType.equals("Oracle")){ - if (colname.equals("TIMESTAMP")) - colname = "Date"; - else if (colname.equals("TIMESTAMP+Time")) - colname = "Date+Time"; - else if (colname.equals("NUMERIC")) - colname = "Number";} - else if (m_DatabaseType.equals("Sybase")){ - if (colname.equals("TIMESTAMP")) - colname = "Date"; - else if (colname.equals("TIMESTAMP+Time")) - colname = "Date+Time"; - else if (colname.equals("NUMERIC")) - colname = "Number";} - else if (m_DatabaseType.equals("PostgreSQL")){ - log.info("Before Column Name ->"+colname); - if (colname.equals("Date")) - colname = "TIMESTAMP"; - else if (colname.equals("Date+Time")) - colname = "TIMESTAMP+Time"; - else if (colname.equals("Number")) - colname = "NUMERIC"; - log.info("After Column Name ->"+colname); } + String tabname = atts.getValue("ADTabNameID"); + String colname = atts.getValue("ADColumnNameID"); +// log.info("Column Name ->"+colname); +// log.info("Database Name ->"+m_DatabaseType); + /** + //Adjust for difference between Oracle and PostgreSql DataTypes + if (m_DatabaseType.equals("Oracle")){ + if (colname.equals("TIMESTAMP")) + colname = "Date"; + else if (colname.equals("TIMESTAMP+Time")) + colname = "Date+Time"; + else if (colname.equals("NUMERIC")) + colname = "Number";} + else if (m_DatabaseType.equals("Sybase")){ + if (colname.equals("TIMESTAMP")) + colname = "Date"; + else if (colname.equals("TIMESTAMP+Time")) + colname = "Date+Time"; + else if (colname.equals("NUMERIC")) + colname = "Number";} + else if (m_DatabaseType.equals("PostgreSQL")){ + log.info("Before Column Name ->"+colname); + if (colname.equals("Date")) + colname = "TIMESTAMP"; + else if (colname.equals("Date+Time")) + colname = "TIMESTAMP+Time"; + else if (colname.equals("Number")) + colname = "NUMERIC"; + log.info("After Column Name ->"+colname); } **/ int tableid = get_IDWithColumn("AD_Table", "TableName", atts.getValue("ADTableNameID")); - int windowid = get_ID("AD_Window", atts.getValue("ADWindowNameID")); + int windowid = get_ID("AD_Window", atts.getValue("ADWindowNameID")); //log.info("Column Name ->"+colname); - int columnid = get_IDWithMasterAndColumn ("AD_Column","ColumnName", colname, "AD_Table", tableid); + int columnid = get_IDWithMasterAndColumn ("AD_Column","ColumnName", colname, "AD_Table", tableid); //log.info("ColumnID->"+columnid); sqlB = new StringBuffer ("select AD_Tab_ID from AD_Tab where AD_Window_ID = " + windowid + " and Name = '"+tabname +"'" @@ -695,30 +702,30 @@ public class PackInHandler extends DefaultHandler { name = atts.getValue("ADElementNameID"); id = get_IDWithColumn("AD_Element", "Name", name); m_Process_para.setAD_Element_ID(id); - name = atts.getValue("ADReferenceNameID"); - /** - //Adjust for difference between Oracle and PostgreSql DataTypes - if (m_DatabaseType.equals("Oracle")){ - if (name.equals("TIMESTAMP")) - name = "Date"; - else if (name.equals("TIMESTAMP+Time")) - name = "Date+Time"; - else if (name.equals("NUMERIC")) - name = "Number";} - else if (m_DatabaseType.equals("Sybase")){ - if (name.equals("TIMESTAMP")) - name = "Date"; - else if (name.equals("TIMESTAMP+Time")) - name = "Date+Time"; - else if (name.equals("NUMERIC")) - name = "Number";} - else if (m_DatabaseType.equals("PostgreSQL")){ - if (name.equals("Date")) - name = "TIMESTAMP"; - else if (name.equals("Date+Time")) - name = "TIMESTAMP+Time"; - else if (name.equals("Number")) - name = "NUMERIC";} + name = atts.getValue("ADReferenceNameID"); + /** + //Adjust for difference between Oracle and PostgreSql DataTypes + if (m_DatabaseType.equals("Oracle")){ + if (name.equals("TIMESTAMP")) + name = "Date"; + else if (name.equals("TIMESTAMP+Time")) + name = "Date+Time"; + else if (name.equals("NUMERIC")) + name = "Number";} + else if (m_DatabaseType.equals("Sybase")){ + if (name.equals("TIMESTAMP")) + name = "Date"; + else if (name.equals("TIMESTAMP+Time")) + name = "Date+Time"; + else if (name.equals("NUMERIC")) + name = "Number";} + else if (m_DatabaseType.equals("PostgreSQL")){ + if (name.equals("Date")) + name = "TIMESTAMP"; + else if (name.equals("Date+Time")) + name = "TIMESTAMP+Time"; + else if (name.equals("Number")) + name = "NUMERIC";} **/ id = get_IDWithColumn("AD_Reference", "Name", name); m_Process_para.setAD_Reference_ID(id); @@ -752,14 +759,370 @@ public class PackInHandler extends DefaultHandler { } } } + else if (elementValue.equals("dynvalrule")) { + log.info(elementValue+" "+atts.getValue("Name")); + String entitytype = atts.getValue("EntityType"); + //FIXME: understand how to change m_UpdateMode to true + //if (entitytype.equals("U") || entitytype.equals("D") && m_UpdateMode.equals("true")) { + if (entitytype.equals("U") || entitytype.equals("D")) { + String name = atts.getValue("Name"); + int id = get_IDWithColumn("AD_Val_Rule", "name", name); + + m_ValRule = new X_AD_Val_Rule(m_ctx, id, m_trxName); + if (id > 0){ + AD_Backup_ID = copyRecord("AD_Val_Rule",m_ValRule); + Object_Status = "Update"; + } + else{ + Object_Status = "New"; + AD_Backup_ID =0; + } + m_ValRule.setDescription(atts.getValue("Description").replaceAll("'","''").replaceAll(",","")); + m_ValRule.setEntityType(atts.getValue("EntityType")); + m_ValRule.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true); + m_ValRule.setName(name); + m_ValRule.setType(atts.getValue("Type")); + m_ValRule.setCode(atts.getValue("Code")); + if (m_ValRule.save(m_trxName) == true){ + record_log (1, m_ValRule.getName(),"Task", m_ValRule.get_ID(),AD_Backup_ID, Object_Status,"AD_Val_Rule",get_IDWithColumn("AD_Val_Rule", "Name", "AD_Val_Rule")); + } + else{ + record_log (0, m_ValRule.getName(),"Task", m_ValRule.get_ID(),AD_Backup_ID, Object_Status,"AD_Val_Rule",get_IDWithColumn("AD_Val_Rule", "Name", "AD_Val_Rule")); + } + } + } + // workflow element. + else if (elementValue.equals("workflow")) { + log.info("In PackInHandler.java with element workflow"); + log.info(elementValue+" "+atts.getValue("Name")); + String entitytype = atts.getValue("EntityType"); + log.info("entitytype "+atts.getValue("EntityType")); + + //FIXME: understand how to change m_UpdateMode to true + //if (entitytype.equals("U") || entitytype.equals("D") && m_UpdateMode.equals("true")) { + if (entitytype.equals("U") || entitytype.equals("D")) { + log.info("entitytype is a U or D"); + + String workflowName = atts.getValue("Name"); + + int id = get_IDWithColumn("AD_Workflow", "name", workflowName); + + m_Workflow = new MWorkflow(m_ctx, id, m_trxName); + if (id > 0){ + AD_Backup_ID = copyRecord("AD_Workflow",m_Workflow); + Object_Status = "Update"; + } + else{ + Object_Status = "New"; + AD_Backup_ID =0; + } + + if (atts.getValue("ADWorkflowResponsibleNameID")!= null){ + String name = atts.getValue("ADWorkflowResponsibleNameID"); + id = get_IDWithColumn("AD_WF_Responsible", "Name", name); + m_Workflow.setAD_WF_Responsible_ID(id); + } + if (atts.getValue("ADTableNameID")!= null){ + String Name = atts.getValue("ADTableNameID"); + id = get_IDWithColumn("AD_Table", "TableName", Name); + m_Workflow.setAD_Table_ID(id); + + } + if (atts.getValue("ADWorkflowProcessorNameID")!= null){ + String Name = atts.getValue("ADWorkflowProcessorNameID"); + id = get_IDWithColumn("AD_WorkflowProcessor", "Name", Name); + m_Workflow.setAD_WorkflowProcessor_ID(id); + + } + m_Workflow.setName(workflowName); + m_Workflow.setAccessLevel (atts.getValue("AccessLevel")); + m_Workflow.setDescription(atts.getValue("Description").replaceAll("'","''").replaceAll(",","")); + m_Workflow.setHelp(atts.getValue("Help").replaceAll("'","''").replaceAll(",","")); + m_Workflow.setDurationUnit(atts.getValue("DurationUnit")); + m_Workflow.setAuthor(atts.getValue("Author")); + m_Workflow.setVersion(Integer.valueOf(atts.getValue("Version"))); + m_Workflow.setPriority(Integer.valueOf(atts.getValue("Priority"))); + m_Workflow.setLimit(Integer.valueOf(atts.getValue("Limit"))); + m_Workflow.setDuration(Integer.valueOf(atts.getValue("Duration"))); + m_Workflow.setCost(Integer.valueOf(atts.getValue("Cost"))); + m_Workflow.setWorkingTime(Integer.valueOf(atts.getValue("WorkingTime"))); + m_Workflow.setWaitingTime(Integer.valueOf(atts.getValue("WaitingTime"))); + m_Workflow.setPublishStatus(atts.getValue("PublishStatus")); + m_Workflow.setWorkflowType(atts.getValue("WorkflowType")); + m_Workflow.setDocValueLogic(atts.getValue("DocValueLogic")); + m_Workflow.setIsValid(atts.getValue("isValid") != null ? Boolean.valueOf(atts.getValue("isValid")).booleanValue():true); + m_Workflow.setEntityType(atts.getValue("EntityType")); + m_Workflow.setAD_WF_Node_ID(-1); +// log.info("in3"); + attsOut.clear(); + log.info("about to execute m_Workflow.save"); + if (m_Workflow.save(m_trxName) == true){ + log.info("m_Workflow save success"); + record_log (1, m_Workflow.getName(),"Workflow", m_Workflow.get_ID(),AD_Backup_ID, Object_Status,"AD_Workflow",get_IDWithColumn("AD_Workflow", "Name", "AD_Workflow")); + } + else{ + log.info("m_Workflow save failure"); + record_log (0, m_Workflow.getName(),"Workflow", m_Workflow.get_ID(),AD_Backup_ID, Object_Status,"AD_Workflow",get_IDWithColumn("AD_Workflow", "Name", "AD_Workflow")); + } + } else { + log.info("entitytype is not a U or D"); + + } + } + // workflowNode element. + else if (elementValue.equals("workflowNode")) { + log.info("In PackInHandler.java with element workflowNode"); + log.info(elementValue+" "+atts.getValue("Name")); + String entitytype = atts.getValue("EntityType"); + log.info("entitytype "+atts.getValue("EntityType")); + + //FIXME: understand how to change m_UpdateMode to true + //if (entitytype.equals("U") || entitytype.equals("D") && m_UpdateMode.equals("true")) { + if (entitytype.equals("U") || entitytype.equals("D")) { + log.info("entitytype is a U or D"); + + String workflowName = atts.getValue("ADWorkflowNameID"); + + int workflowId = get_IDWithColumn("AD_Workflow", "name", workflowName); + + String workflowNodeName = atts.getValue("Name"); + + sqlB = new StringBuffer ("SELECT ad_wf_node_id FROM AD_WF_Node WHERE AD_Workflow_ID=? and Name =?"); + + int id = DB.getSQLValue(m_trxName,sqlB.toString(),workflowId,workflowNodeName); + + m_WFNode = new MWFNode(m_ctx, id, m_trxName); + if (id > 0){ + AD_Backup_ID = copyRecord("AD_WF_Node",m_WFNode); + Object_Status = "Update"; + } + else{ + Object_Status = "New"; + AD_Backup_ID =0; + } + m_WFNode.setName(workflowNodeName); + + String Name = atts.getValue("ADWorkflowNameID"); + id = get_IDWithColumn("AD_Workflow", "Name", Name); + m_WFNode.setAD_Workflow_ID(id); + if (atts.getValue("ADProcessNameID")!= null){ + Name = atts.getValue("ADProcessNameID"); + id = get_IDWithColumn("AD_Process", "Name", Name); + m_WFNode.setAD_Process_ID(id); + } + if (atts.getValue("ADFormNameID")!= null){ + String name = atts.getValue("ADFormNameID"); + id = get_IDWithColumn("AD_Form", "Name", name); + m_WFNode.setAD_Form_ID(id); + } + + if (atts.getValue("ADWorkflowResponsibleNameID")!= null){ + String name = atts.getValue("ADWorkflowResponsibleNameID"); + id = get_IDWithColumn("AD_WF_Responsible", "Name", name); + m_WFNode.setAD_WF_Responsible_ID(id); + } + + if (atts.getValue("ADWindowNameID")!= null){ + String name = atts.getValue("ADWindowNameID"); + id = get_IDWithColumn("AD_Window", "Name", name); + m_WFNode.setAD_Window_ID(id); + } + if (atts.getValue("ADImageNameID")!= null){ + String name = atts.getValue("ADImageNameID"); + id = get_IDWithColumn("AD_Image", "Name", name); + m_WFNode.setAD_Image_ID(id); + } + if (atts.getValue("ADWorkflowBlockNameID")!= null){ + String name = atts.getValue("ADWorkflowBlockNameID"); + id = get_IDWithColumn("AD_WF_Block", "Name", name); + m_WFNode.setAD_WF_Block_ID(id); + } + /* FIXME: Do we need TaskName ? + if (atts.getValue("ADTaskNameID")!=null){ + String name = atts.getValue("ADTaskNameID"); + sqlB = new StringBuffer ("SELECT AD_Task_ID FROM AD_Task WHERE Name= ?"); + taskid = DB.getSQLValue(m_trxName,sqlB.toString(),name); + } + */ + m_WFNode.setEntityType(atts.getValue("EntityType")); + m_WFNode.setAction(atts.getValue("Action")); + m_WFNode.setDocAction(atts.getValue("DocAction")); + m_WFNode.setDescription(atts.getValue("Description").replaceAll("'","''").replaceAll(",","")); + m_WFNode.setJoinElement(atts.getValue("JoinElement")); + m_WFNode.setSplitElement(atts.getValue("SplitElement")); + m_WFNode.setXPosition(Integer.valueOf(atts.getValue("XPosition"))); + m_WFNode.setYPosition(Integer.valueOf(atts.getValue("YPosition"))); + m_WFNode.setWaitingTime(Integer.valueOf(atts.getValue("WaitingTime"))); + m_WFNode.setWaitTime(Integer.valueOf(atts.getValue("WaitTime"))); + m_WFNode.setWorkingTime(Integer.valueOf(atts.getValue("WorkingTime"))); + m_WFNode.setCost(new BigDecimal(atts.getValue("Cost"))); + m_WFNode.setDuration(Integer.valueOf(atts.getValue("Duration"))); + m_WFNode.setPriority(Integer.valueOf(atts.getValue("Priority"))); + //FIXME: Failing for some reason on a "" + //m_WFNode.setStartMode(atts.getValue("StartMode")); + //FIXME: Failing for some reason on a "" + //m_WFNode.setSubflowExecution(atts.getValue("SubflowExecution")); + m_WFNode.setIsCentrallyMaintained(Boolean.valueOf(atts.getValue("IsCentrallyMaintained")).booleanValue()); + m_WFNode.setDynPriorityChange(new BigDecimal(atts.getValue("DynPriorityChange"))); + //m_WFNode.setAccessLevel (atts.getValue("AccessLevel")); + //FIXME: Failing for some reason on a "" + //m_WFNode.setDynPriorityUnit (atts.getValue("DynPriorityUnit")); + m_WFNode.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true); +// log.info("in3"); + attsOut.clear(); + log.info("about to execute m_WFNode.save"); + if (m_WFNode.save(m_trxName) == true){ + log.info("m_WFNode save success"); + record_log (1, m_WFNode.getName(),"WFNode", m_WFNode.get_ID(),AD_Backup_ID, Object_Status,"AD_WF_Node",get_IDWithColumn("AD_WF_Node", "Name", "AD_WF_Node")); + } + else{ + log.info("m_WFNode save failure"); + record_log (0, m_WFNode.getName(),"WFNode", m_WFNode.get_ID(),AD_Backup_ID, Object_Status,"AD_WF_Node",get_IDWithColumn("AD_WF_Node", "Name", "AD_WF_Node")); + } + } else { + log.info("entitytype is not a U or D"); + + } + } + // workflowNodeNext element. + else if (elementValue.equals("workflowNodeNext")) { + log.info("In PackInHandler.java with element workflowNodeNext"); + String entitytype = atts.getValue("EntityType"); + log.info("entitytype "+atts.getValue("EntityType")); + + //FIXME: understand how to change m_UpdateMode to true + //if (entitytype.equals("U") || entitytype.equals("D") && m_UpdateMode.equals("true")) { + if (entitytype.equals("U") || entitytype.equals("D")) { + log.info("entitytype is a U or D"); + + + String workflowName = atts.getValue("ADWorkflowNameID"); + + int workflowId = get_IDWithColumn("AD_Workflow", "name", workflowName); + + String workflowNodeName = atts.getValue("ADWorkflowNodeNameID"); + String workflowNodeNextName = atts.getValue("ADWorkflowNodeNextNameID"); + + sqlB = new StringBuffer ("SELECT ad_wf_node_id FROM AD_WF_Node WHERE AD_Workflow_ID=? and Name =?"); + + int wfNodeId = DB.getSQLValue(m_trxName,sqlB.toString(),workflowId,workflowNodeName); + + int wfNodeNextId = DB.getSQLValue(m_trxName,sqlB.toString(),workflowId,workflowNodeNextName); + + sqlB = new StringBuffer ("SELECT ad_wf_nodenext_id FROM AD_WF_NodeNext WHERE ad_wf_node_id =? and ad_wf_next_id =?"); + + //int id = get_IDWithColumn("AD_WF_Node", "name", workflowNodeName); + int id = DB.getSQLValue(m_trxName,sqlB.toString(),wfNodeId,wfNodeNextId); + + m_WFNodeNext = new MWFNodeNext(m_ctx, id, m_trxName); + if (id > 0){ + AD_Backup_ID = copyRecord("AD_WF_NodeNext",m_WFNodeNext); + Object_Status = "Update"; + } + else{ + Object_Status = "New"; + AD_Backup_ID =0; + } + m_WFNodeNext.setAD_WF_Node_ID(wfNodeId); + m_WFNodeNext.setAD_WF_Next_ID(wfNodeNextId); + m_WFNodeNext.setEntityType(atts.getValue("EntityType")); + m_WFNodeNext.setSeqNo(Integer.valueOf(atts.getValue("SeqNo"))); + m_WFNodeNext.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true); + m_WFNodeNext.setIsStdUserWorkflow(atts.getValue("IsStdUserWorkflow") != null ? Boolean.valueOf(atts.getValue("IsStdUserWorkflow")).booleanValue():true); +// log.info("m_WFNodeNext.get_ID: " + String.valueOf(m_WFNodeNext.get_ID)); + attsOut.clear(); + log.info("about to execute m_WFNodeNext.save"); + if (m_WFNodeNext.save(m_trxName) == true){ + log.info("m_WFNodeNext save success"); + record_log (1, String.valueOf(m_WFNodeNext.get_ID()),"WFNodeNext", m_WFNodeNext.get_ID(),AD_Backup_ID, Object_Status,"AD_WF_NodeNext",get_IDWithColumn("AD_WF_NodeNext", "ad_wf_nodenext_id", "AD_WF_NodeNext")); + } + else{ + log.info("m_WFNodeNext save failure"); + record_log (0, String.valueOf(m_WFNodeNext.get_ID()),"WFNode", m_WFNodeNext.get_ID(),AD_Backup_ID, Object_Status,"AD_WF_NodeNext",get_IDWithColumn("AD_WF_NodeNext", "ad_wf_nodenext_id", "AD_WF_NodeNext")); + } + } else { + log.info("entitytype is not a U or D"); + + } + } + // workflowNodeNextCondition element. + else if (elementValue.equals("workflowNodeNextCondition")) { + log.info("In PackInHandler.java with element workflowNodeNextCondition"); + String entitytype = atts.getValue("EntityType"); + log.info("entitytype "+atts.getValue("EntityType")); + + //FIXME: understand how to change m_UpdateMode to true + //if (entitytype.equals("U") || entitytype.equals("D") && m_UpdateMode.equals("true")) { + if (entitytype.equals("U") || entitytype.equals("D")) { + log.info("entitytype is a U or D"); + + + String workflowName = atts.getValue("ADWorkflowNameID"); + + int workflowId = get_IDWithColumn("AD_Workflow", "name", workflowName); + + String workflowNodeName = atts.getValue("ADWorkflowNodeNameID"); + String workflowNodeNextName = atts.getValue("ADWorkflowNodeNextNameID"); + + sqlB = new StringBuffer ("SELECT ad_wf_node_id FROM AD_WF_Node WHERE AD_Workflow_ID=? and Name =?"); + + int wfNodeId = DB.getSQLValue(m_trxName,sqlB.toString(),workflowId,workflowNodeName); + + int wfNodeNextId = DB.getSQLValue(m_trxName,sqlB.toString(),workflowId,workflowNodeNextName); + + sqlB = new StringBuffer ("SELECT ad_wf_nodenext_id FROM AD_WF_NodeNext WHERE ad_wf_node_id =? and ad_wf_next_id =?"); + int wfNodeNextTablePKId = DB.getSQLValue(m_trxName,sqlB.toString(),wfNodeId,wfNodeNextId); + + sqlB = new StringBuffer ("SELECT ad_wf_nextcondition_id FROM AD_WF_NextCondition WHERE ad_wf_nodenext_id =?"); + int id = DB.getSQLValue(m_trxName,sqlB.toString(),wfNodeNextTablePKId); + + m_WFNodeNextCondition = new MWFNextCondition(m_ctx, id, m_trxName); + if (id > 0){ + AD_Backup_ID = copyRecord("AD_WF_NextCondition",m_WFNodeNextCondition); + Object_Status = "Update"; + } + else{ + Object_Status = "New"; + AD_Backup_ID =0; + } + + sqlB = new StringBuffer ("SELECT AD_Column.ad_column_id FROM AD_Column, AD_Table WHERE AD_Column.ad_table_id = AD_Table.ad_table_id and AD_Table.name = '" + atts.getValue("ADTableNameID") + "' and AD_Column.name = ?"); + //int columnId = DB.getSQLValue(m_trxName,sqlB.toString(),atts.getValue("ADTableNameID"), atts.getValue("ADColumnNameID")); + int columnId = DB.getSQLValue(m_trxName,sqlB.toString(),atts.getValue("ADColumnNameID")); + m_WFNodeNextCondition.setAD_Column_ID(columnId); + + m_WFNodeNextCondition.setAD_WF_NodeNext_ID(wfNodeNextTablePKId); + m_WFNodeNextCondition.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true); + m_WFNodeNextCondition.setAD_WF_NodeNext_ID(wfNodeNextTablePKId); + m_WFNodeNextCondition.setSeqNo(Integer.valueOf(atts.getValue("SeqNo"))); + m_WFNodeNextCondition.setEntityType(atts.getValue("EntityType")); + m_WFNodeNextCondition.setAndOr(atts.getValue("AndOr")); + m_WFNodeNextCondition.setOperation(atts.getValue("Operation")); + m_WFNodeNextCondition.setValue(atts.getValue("Value")); + m_WFNodeNextCondition.setValue2(atts.getValue("Value2")); + attsOut.clear(); + log.info("about to execute m_WFNodeNextCondition.save"); + if (m_WFNodeNextCondition.save(m_trxName) == true){ + log.info("m_WFNodeNextCondition save success"); + record_log (1, String.valueOf(m_WFNodeNextCondition.get_ID()),"WFNextCondition", m_WFNodeNextCondition.get_ID(),AD_Backup_ID, Object_Status,"AD_WF_NextCondition",get_IDWithColumn("AD_WF_NextCondition", "ad_wf_nextcondition_id", "AD_WF_NextCondition")); + } + else{ + log.info("m_WFNodeNextCondition save failure"); + record_log (0, String.valueOf(m_WFNodeNextCondition.get_ID()),"WFNextCondition", m_WFNodeNextCondition.get_ID(),AD_Backup_ID, Object_Status,"AD_WF_NextCondition",get_IDWithColumn("AD_WF_NextCondition", "ad_wf_nextcondition_id", "AD_WF_NextCondition")); + } + } else { + log.info("entitytype is not a U or D"); + + } + } // table element. - else if (elementValue.equals("table")) { + else if (elementValue.equals("table")) { log.info(elementValue+" "+atts.getValue("ADTableNameID")); String entitytype = atts.getValue("EntityType"); if (entitytype.equals("U") || entitytype.equals("D") && m_UpdateMode.equals("true")) { - String tableName = atts.getValue("ADTableNameID"); + String tableName = atts.getValue("ADTableNameID"); int id = get_IDWithColumn("AD_Table", "TableName", tableName); @@ -800,7 +1163,7 @@ public class PackInHandler extends DefaultHandler { //m_Table.setLoadSeq(Integer.parseInt(atts.getValue("LoadSeq"))); m_Table.setName(atts.getValue("Name")); m_Table.setReplicationType(atts.getValue("ReplicationType")); - m_Table.setTableName(atts.getValue("TableName")); + m_Table.setTableName(atts.getValue("TableName")); // log.info("in3"); attsOut.clear(); if (m_Table.save(m_trxName) == true){ @@ -835,36 +1198,36 @@ public class PackInHandler extends DefaultHandler { String Name = atts.getValue("ADProcessNameID"); id = get_IDWithColumn("AD_Process", "Name", Name); m_Column.setAD_Process_ID(id); - Name = atts.getValue("ADReferenceNameID"); -// log.info("Column Name1 ->"+Name); -// log.info("Database Name ->"+m_DatabaseType); - /** - //Adjust for difference between Oracle and PostgreSql DataTypes - if (m_DatabaseType.equals("Oracle")){ - if (Name.equals("TIMESTAMP")) - Name = "Date"; - else if (Name.equals("TIMESTAMP+Time")) - Name = "Date+Time"; - else if (Name.equals("NUMERIC")) - Name = "Number";} - else if (m_DatabaseType.equals("Sybase")){ - if (Name.equals("TIMESTAMP")) - Name = "Date"; - else if (Name.equals("TIMESTAMP+Time")) - Name = "Date+Time"; - else if (Name.equals("NUMERIC")) - Name = "Number";} - else if (m_DatabaseType.equals("PostgreSQL")){ - if (Name.equals("Date")) - Name = "TIMESTAMP"; - else if (Name.equals("Date+Time")) - Name = "TIMESTAMP+Time"; - else if (Name.equals("Number")) - Name = "NUMERIC";} - **/ + Name = atts.getValue("ADReferenceNameID"); +// log.info("Column Name1 ->"+Name); +// log.info("Database Name ->"+m_DatabaseType); + /** + //Adjust for difference between Oracle and PostgreSql DataTypes + if (m_DatabaseType.equals("Oracle")){ + if (Name.equals("TIMESTAMP")) + Name = "Date"; + else if (Name.equals("TIMESTAMP+Time")) + Name = "Date+Time"; + else if (Name.equals("NUMERIC")) + Name = "Number";} + else if (m_DatabaseType.equals("Sybase")){ + if (Name.equals("TIMESTAMP")) + Name = "Date"; + else if (Name.equals("TIMESTAMP+Time")) + Name = "Date+Time"; + else if (Name.equals("NUMERIC")) + Name = "Number";} + else if (m_DatabaseType.equals("PostgreSQL")){ + if (Name.equals("Date")) + Name = "TIMESTAMP"; + else if (Name.equals("Date+Time")) + Name = "TIMESTAMP+Time"; + else if (Name.equals("Number")) + Name = "NUMERIC";} + **/ // log.info("Column Name2 ->"+Name); id = get_IDWithColumn("AD_Reference", "Name", Name); - m_Column.setAD_Reference_ID(id); + m_Column.setAD_Reference_ID(id); // log.info("Column ID ->"+id); Name = atts.getValue("ADTableNameID"); id = get_IDWithColumn("AD_Table", "TableName", Name); @@ -1749,11 +2112,11 @@ public class PackInHandler extends DefaultHandler { try { packagePath = packageDirectory; File parentDirectory = new File(packagePath); - while (!parentDirectory.getName().equals("packages")){ + while (!parentDirectory.getName().equals("packages")){ parentDirectory = parentDirectory.getParentFile(); - } + } parentDirectory = parentDirectory.getParentFile(); - sourcePath = parentDirectory.getCanonicalPath(); + sourcePath = parentDirectory.getCanonicalPath(); } catch (IOException e1) { System.out.println("Can't find compiere-all directory."); } @@ -1768,7 +2131,7 @@ public class PackInHandler extends DefaultHandler { } } - + //Correct target directory for proper file seperator String fullDirectory = sourcePath+targetDirectory; String targetDirectoryModified=null; @@ -2138,11 +2501,11 @@ public class PackInHandler extends DefaultHandler { log.log(Level.SEVERE,"SQLSatement", e); } } - else if (elementValue.equals("reference")) { + else if (elementValue.equals("reference")) { log.info(elementValue+" "+atts.getValue("name")); String entitytype = atts.getValue("EntityType"); - String name = atts.getValue("name"); + String name = atts.getValue("name"); if (entitytype.compareTo("U") == 0 || entitytype.compareTo("D") == 0 && m_UpdateMode.compareTo("true") == 0 ) { int id = get_ID("AD_Reference", name); @@ -2533,8 +2896,8 @@ public class PackInHandler extends DefaultHandler { //StringBuffer sqlC = new StringBuffer ("select "+tableName+"_ID from "+tableName+" where "+columnName+"="+value.toString()); if (!tableName.startsWith("AD_")) - sqlB = sqlB.append(" and AD_Client_ID=?"); - //here! + sqlB = sqlB.append(" and AD_Client_ID=?"); + //here! sqlB = sqlB.append(" Order By "+tableName+"_ID"); try { PreparedStatement pstmt = DB.prepareStatement(sqlB.toString(), m_trxName); @@ -2543,7 +2906,7 @@ public class PackInHandler extends DefaultHandler { else if (value instanceof Integer) pstmt.setInt(1, ((Integer)value).intValue()); if (!tableName.startsWith("AD_")) - pstmt.setInt(2, m_AD_Client_ID); + pstmt.setInt(2, m_AD_Client_ID); ResultSet rs = pstmt.executeQuery(); if (rs.next()) @@ -2945,12 +3308,12 @@ public class PackInHandler extends DefaultHandler { DatabaseMetaData dbm; try { dbm = conn.getMetaData(); - // check if table is there - ResultSet tables = null; - if (m_DatabaseType.equals("Oracle")) - tables = dbm.getTables(null, null, tablename.toUpperCase(), null ); - else if (m_DatabaseType.equals("PostgreSQL")) - tables = dbm.getTables(null, null, tablename.toLowerCase(), null ); + // check if table is there + ResultSet tables = null; + if (m_DatabaseType.equals("Oracle")) + tables = dbm.getTables(null, null, tablename.toUpperCase(), null ); + else if (m_DatabaseType.equals("PostgreSQL")) + tables = dbm.getTables(null, null, tablename.toLowerCase(), null ); if (tables.next()) { log.info ("Table Found"); @@ -2982,7 +3345,7 @@ public class PackInHandler extends DefaultHandler { + "PRIMARY KEY( "+tablename.toUpperCase() +"_ID)"+")" ); try { - PreparedStatement pstmt = DB.prepareStatement(sqlB.toString(),ResultSet.TYPE_FORWARD_ONLY, + PreparedStatement pstmt = DB.prepareStatement(sqlB.toString(),ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE, null); pstmt.executeUpdate(); MSequence.createTableSequence (m_ctx, "AD_Package_Imp", m_trxName); @@ -3053,7 +3416,7 @@ public class PackInHandler extends DefaultHandler { + "PRIMARY KEY( "+tablename.toUpperCase() +"_ID)"+")" ); try { - PreparedStatement pstmt = DB.prepareStatement(sqlB.toString(),ResultSet.TYPE_FORWARD_ONLY, + PreparedStatement pstmt = DB.prepareStatement(sqlB.toString(),ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE, null); pstmt.executeUpdate(); MSequence.createTableSequence (m_ctx, "AD_Package_Imp_Detail", m_trxName); @@ -3086,7 +3449,7 @@ public class PackInHandler extends DefaultHandler { + "PRIMARY KEY( "+tablename.toUpperCase() +"_ID)"+")" ); try { - PreparedStatement pstmt = DB.prepareStatement(sqlB.toString(),ResultSet.TYPE_FORWARD_ONLY, + PreparedStatement pstmt = DB.prepareStatement(sqlB.toString(),ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE, null); pstmt.executeUpdate(); MSequence.createTableSequence (m_ctx, "AD_Package_Imp_Backup", m_trxName); diff --git a/base/src/org/adempiere/pipo/PackOut.java b/base/src/org/adempiere/pipo/PackOut.java index e3dcb80124..417e53cb30 100644 --- a/base/src/org/adempiere/pipo/PackOut.java +++ b/base/src/org/adempiere/pipo/PackOut.java @@ -50,13 +50,11 @@ import org.compiere.model.X_AD_Ref_List; import org.compiere.model.X_AD_ReportView; import org.compiere.model.X_AD_ReportView_Col; import org.compiere.model.X_AD_Role; -import org.compiere.model.X_AD_Window_Access; -import org.compiere.model.X_AD_Process_Access; -import org.compiere.model.X_AD_Form_Access; -import org.compiere.model.X_AD_Workflow_Access; -import org.compiere.model.X_AD_Task_Access; -import org.compiere.model.X_AD_Role_OrgAccess; -import org.compiere.model.X_AD_User_Roles; +import org.compiere.model.X_AD_Workflow; +import org.compiere.model.X_AD_Val_Rule; +import org.compiere.model.X_AD_WF_Node; +import org.compiere.model.X_AD_WF_NodeNext; +import org.compiere.model.X_AD_WF_NextCondition; import org.compiere.util.DB; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; @@ -69,6 +67,7 @@ import org.compiere.process.*; * @author Robert Klein * @version $Id: PackOut.java,v 1.0 * + * Contributor: William G. Heath - Export of workflows and dynamic validations */ public class PackOut extends SvrProcess @@ -78,6 +77,11 @@ public class PackOut extends SvrProcess private X_AD_Window m_Window = null; private X_AD_Process_Para m_Processpara = null; private X_AD_Table m_Table = null; + private X_AD_Workflow m_Workflow = null; + private X_AD_WF_Node m_WF_Node = null; + private X_AD_WF_NodeNext m_WF_NodeNext = null; + private X_AD_WF_NextCondition m_WF_NodeNextCondition = null; + private X_AD_Val_Rule m_ValRule = null; private X_AD_Column m_Column = null; private X_AD_Tab m_Tab = null; private X_AD_PrintFormat m_Printformat = null; @@ -96,21 +100,12 @@ public class PackOut extends SvrProcess private X_AD_Preference m_Preference= null; private X_AD_ImpFormat m_ImpFormat= null; private X_AD_ImpFormat_Row m_ImpFormat_Row= null; - private X_AD_Window_Access m_Window_Access = null; - private X_AD_Process_Access m_Process_Access = null; - private X_AD_Form_Access m_Form_Access = null; - private X_AD_Workflow_Access m_Workflow_Access = null; - private X_AD_Task_Access m_Task_Access = null; - private X_AD_Role_OrgAccess m_Role_OrgAccess = null; - private X_AD_User_Roles m_User_Role = null; private String PackOutVer = "005"; private String packagedir = null; private String packagename = null; private String includesdir = null; private int Table_ID[] = new int [1000]; private int Table_Count = 0; - private int PK_AD_Client_ID = 0; - private int PK_AD_Org_ID = 0; String fileSeperator=null; /** * Prepare - e.g., get Parameters. @@ -247,7 +242,7 @@ public class PackOut extends SvrProcess atts.addAttribute("","","PackOutVer","CDATA",PackOutVer); hd_menu.startElement("","","adempiereAD",atts); - atts.clear(); + atts.clear(); String sql = "SELECT * FROM AD_Package_Exp_Detail WHERE AD_Package_Exp_ID = "+p_PackOut_ID+" ORDER BY Line ASC"; PreparedStatement pstmt = null; @@ -294,11 +289,14 @@ public class PackOut extends SvrProcess CreateSnipit (rs.getString("Destination_Directory"),rs.getString("Destination_FileName"),rs.getString("AD_Package_Code_Old"), rs.getString("AD_Package_Code_New"), rs.getString("ReleaseNo"), atts, hd_menu); else if (Type.compareTo("F") == 0) - //TODO Create Workflow CreateWorkflow (rs.getInt("AD_Workflow_ID"), atts, hd_menu); + else if (Type.compareTo("V") == 0) + CreateDynamicRuleValidation(rs.getInt("AD_Val_Rule_ID"), atts, hd_menu); else if (Type.compareTo("C") == 0){ + log.log(Level.SEVERE,"In PackOut.java handling Code or Other 2pack module creation"); String fullDirectory = rs1.getString("File_Directory") + rs1.getString("Name")+rs.getString("Target_Directory"); + log.log(Level.SEVERE,"fullDirectory" + fullDirectory); String targetDirectoryModified=null; char fileseperator1 = '/'; char fileseperator2 = '\\'; @@ -594,10 +592,149 @@ public class PackOut extends SvrProcess CopyFile (sourceName, copyName ); } + public void CreateDynamicRuleValidation (int AD_Val_Rule_ID, AttributesImpl atts, TransformerHandler hd_menu) throws SAXException + { + log.info(""); + + String sql = "SELECT Name FROM AD_Val_Rule WHERE AD_Val_Rule_ID= " + AD_Val_Rule_ID; + + PreparedStatement pstmt = null; + pstmt = DB.prepareStatement (sql, get_TrxName()); + + try { + + ResultSet rs = pstmt.executeQuery(); + + while (rs.next()) + { + m_ValRule = new X_AD_Val_Rule (getCtx(), AD_Val_Rule_ID, null); + atts = createdynamicvalidationruleBinding(atts,m_ValRule); + hd_menu.startElement("","","dynvalrule",atts); + hd_menu.endElement("","","dynvalrule"); + } + 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; + } + } + public void CreateWorkflow (int AD_Workflow_ID, AttributesImpl atts, TransformerHandler hd_menu) throws SAXException { - //TODO Create workflow + log.info(""); + + 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; + + PreparedStatement pstmt = null; + pstmt = DB.prepareStatement (sql, get_TrxName()); + + try { + + ResultSet rs = pstmt.executeQuery(); + + while (rs.next()) + { + m_Workflow = new X_AD_Workflow (getCtx(), AD_Workflow_ID, null); + atts = createworkflowBinding(atts,m_Workflow); + hd_menu.startElement("","","workflow",atts); + String sql1 = "SELECT * FROM AD_WF_Node WHERE AD_Workflow_ID = " + AD_Workflow_ID; + + PreparedStatement pstmt1 = null; + pstmt1 = DB.prepareStatement (sql1, get_TrxName()); + + try { + + ResultSet rs1 = pstmt1.executeQuery(); + + while (rs1.next()){ + + if (rs1.getInt("AD_WF_Node_ID")>0) + m_WF_Node = new X_AD_WF_Node(getCtx(), rs1.getInt("AD_WF_Node_ID"), null); + + atts = createwf_nodeBinding(atts,m_WF_Node); + hd_menu.startElement("","","workflowNode",atts); + hd_menu.endElement("","","workflowNode"); + } + // Generated workflowNodeNext(s) and workflowNodeNextCondition(s) + ResultSet rs2 = pstmt1.executeQuery(); + while (rs2.next()){ + if (rs2.getInt("AD_WF_Node_ID")>0) + + m_WF_Node = new X_AD_WF_Node(getCtx(), rs2.getInt("AD_WF_Node_ID"), null); + ad_wf_nodenext_id = 0; + + sql = "SELECT ad_wf_nodenext_id from ad_wf_nodenext WHERE ad_wf_node_id = ?"; + ad_wf_nodenext_id = DB.getSQLValue(null,sql,m_WF_Node.getAD_WF_Node_ID()); + if (ad_wf_nodenext_id > 0){ + m_WF_NodeNext = new X_AD_WF_NodeNext(getCtx(), ad_wf_nodenext_id, null); + atts = createwf_nodenextBinding(atts,m_WF_NodeNext); + hd_menu.startElement("","","workflowNodeNext",atts); + hd_menu.endElement("","","workflowNodeNext"); + ad_wf_nodenextcondition_id = 0; + + sql = "SELECT ad_wf_nextcondition_id from ad_wf_nextcondition WHERE ad_wf_nodenext_id = ?"; + ad_wf_nodenextcondition_id = DB.getSQLValue(null,sql,m_WF_Node.getAD_WF_Node_ID()); + log.info("ad_wf_nodenextcondition_id: " + String.valueOf(ad_wf_nodenextcondition_id)); + if (ad_wf_nodenextcondition_id > 0){ + m_WF_NodeNextCondition = new X_AD_WF_NextCondition(getCtx(), ad_wf_nodenextcondition_id, null); + atts = createwf_nodenextconditionBinding(atts,m_WF_NodeNextCondition); + hd_menu.startElement("","","workflowNodeNextCondition",atts); + hd_menu.endElement("","","workflowNodeNextCondition"); + } + } + } + + rs2.close(); + 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; + } + hd_menu.endElement("","","workflow"); + } + 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; + } + } + + public void CreateWorkbench (int AD_Workbench_ID, AttributesImpl atts, TransformerHandler hd_menu) throws SAXException { @@ -1968,7 +2105,81 @@ public class PackOut extends SvrProcess atts.addAttribute("","","isRange","CDATA",(m_Processpara.isRange()== true ? "true":"false")); return atts; } + + public static AttributesImpl createdynamicvalidationruleBinding( AttributesImpl atts, X_AD_Val_Rule m_ValRule) + { + atts.clear(); + atts.addAttribute("","","Name","CDATA",(m_ValRule.getName () != null ? m_ValRule.getName ():"")); + //FIXME: may not need this I guess + //atts.addAttribute("","","AccessLevel","CDATA",(m_ValRule.getAccessLevel () != null ? m_ValRule.getAccessLevel ():"")); + atts.addAttribute("","","Code","CDATA",(m_ValRule.getCode() != null ? m_ValRule.getCode ():"")); + atts.addAttribute("","","Description","CDATA",(m_ValRule.getDescription () != null ? m_ValRule.getDescription ():"")); + atts.addAttribute("","","EntityType","CDATA",(m_ValRule.getEntityType () != null ? m_ValRule.getEntityType ():"")); + atts.addAttribute("","","Type","CDATA",(m_ValRule.getType () != null ? m_ValRule.getType ():"")); + atts.addAttribute("","","isActive","CDATA",(m_ValRule.isActive()== true ? "true":"false")); + return atts; + } + public static AttributesImpl createworkflowBinding( AttributesImpl atts, X_AD_Workflow m_Workflow) + { + String sql = null; + String name = null; + atts.clear(); + atts.addAttribute("","","Name","CDATA",(m_Workflow.getName () != null ? m_Workflow.getName ():"")); + if (m_Workflow.getAD_Table_ID()> 0 ){ + sql = "SELECT Name FROM AD_Table WHERE AD_Table_ID=?"; + name = DB.getSQLValueString(null,sql,m_Workflow.getAD_Table_ID()); + atts.addAttribute("","","ADTableNameID","CDATA",name); + } + else + atts.addAttribute("","","ADTableNameID","CDATA",""); + + if (m_Workflow.getAD_WF_Node_ID()> 0 ){ + sql = "SELECT Name FROM AD_WF_Node WHERE AD_WF_Node_ID=?"; + name = DB.getSQLValueString(null,sql,m_Workflow.getAD_WF_Node_ID()); + atts.addAttribute("","","ADWorkflowNodeNameID","CDATA",name); + } + else + atts.addAttribute("","","ADWorkflowNodeNameID","CDATA",""); + if (m_Workflow.getAD_WF_Responsible_ID()> 0 ){ + sql = "SELECT Name FROM AD_WF_Responsible WHERE AD_WF_Responsible_ID=?"; + name = DB.getSQLValueString(null,sql,m_Workflow.getAD_WF_Responsible_ID()); + atts.addAttribute("","","ADWorkflowResponsibleNameID","CDATA",name); + } + else + atts.addAttribute("","","ADWorkflowResponsibleNameID","CDATA",""); + if (m_Workflow.getAD_WorkflowProcessor_ID()> 0 ){ + sql = "SELECT Name FROM AD_WorkflowProcessor_ID WHERE AD_WorkflowProcessor_ID=?"; + name = DB.getSQLValueString(null,sql,m_Workflow.getAD_WorkflowProcessor_ID()); + atts.addAttribute("","","ADWorkflowProcessorNameID","CDATA",name); + } + else + atts.addAttribute("","","ADWorkflowProcessorNameID","CDATA",""); + atts.addAttribute("","","AccessLevel","CDATA",(m_Workflow.getAccessLevel () != null ? m_Workflow.getAccessLevel ():"")); + atts.addAttribute("","","DurationUnit","CDATA",(m_Workflow.getDurationUnit() != null ? m_Workflow.getDurationUnit ():"")); + atts.addAttribute("","","Help","CDATA",(m_Workflow.getHelp() != null ? m_Workflow.getHelp():"")); + atts.addAttribute("","","Description","CDATA",(m_Workflow.getDescription () != null ? m_Workflow.getDescription ():"")); + atts.addAttribute("","","EntityType","CDATA",(m_Workflow.getEntityType () != null ? m_Workflow.getEntityType ():"")); + atts.addAttribute("","","Author","CDATA",(m_Workflow.getAuthor () != null ? m_Workflow.getAuthor ():"")); + atts.addAttribute("","","Version","CDATA",(""+m_Workflow.getVersion() != null ? ""+m_Workflow.getVersion ():"")); + //FIXME: Handle dates + //atts.addAttribute("","","ValidFrom","CDATA",(m_Workflow.getValidFrom ().toGMTString() != null ? m_Workflow.getValidFrom().toGMTString():"")); + //atts.addAttribute("","","ValidTo","CDATA",(m_Workflow.getValidTo ().toGMTString() != null ? m_Workflow.getValidTo().toGMTString():"")); + atts.addAttribute("","","Priority","CDATA",(""+m_Workflow.getPriority ())); + atts.addAttribute("","","Limit","CDATA",(""+m_Workflow.getLimit())); + atts.addAttribute("","","Duration","CDATA",(""+m_Workflow.getDuration())); + atts.addAttribute("","","Cost","CDATA",(""+m_Workflow.getCost () )); + atts.addAttribute("","","WorkingTime","CDATA",(""+m_Workflow.getWorkingTime() )); + atts.addAttribute("","","WaitingTime","CDATA",(""+m_Workflow.getWaitingTime() )); + atts.addAttribute("","","PublishStatus","CDATA",(m_Workflow.getPublishStatus() != null ? m_Workflow.getPublishStatus():"")); + atts.addAttribute("","","WorkflowType","CDATA",(m_Workflow.getWorkflowType () != null ? m_Workflow.getWorkflowType ():"")); + atts.addAttribute("","","DocValueLogic","CDATA",(m_Workflow.getDocValueLogic() != null ? m_Workflow.getDocValueLogic():"")); + atts.addAttribute("","","isValid","CDATA",(m_Workflow.isValid()== true ? "true":"false")); + //Doesn't appear to be necessary + //atts.addAttribute("","","SetupTime","CDATA",(""+m_Workflow.getSetupTime() != null ? ""+m_Workflow.getSetupTime():"")); + return atts; + } + public static AttributesImpl createtableBinding( AttributesImpl atts, X_AD_Table m_Table) { String sql = null; @@ -2019,6 +2230,207 @@ public class PackOut extends SvrProcess atts.addAttribute("","","TableName","CDATA",(m_Table.getTableName () != null ? m_Table.getTableName ():"")); return atts; } + + public static AttributesImpl createwf_nodeBinding( AttributesImpl atts, X_AD_WF_Node m_WF_Node) + { + String sql = null; + String name = null; + atts.clear(); + + atts.addAttribute("","","Name","CDATA",(m_WF_Node.getName () != null ? m_WF_Node.getName():"")); + + if (m_WF_Node.getAD_Workflow_ID()> 0 ){ + sql = "SELECT Name FROM AD_Workflow WHERE AD_Workflow_ID=?"; + name = DB.getSQLValueString(null,sql,m_WF_Node.getAD_Workflow_ID()); + atts.addAttribute("","","ADWorkflowNameID","CDATA",name); + } + else + atts.addAttribute("","","ADWorkflowNameID","CDATA",""); + + if (m_WF_Node.getAD_Window_ID()> 0 ){ + sql = "SELECT Name FROM AD_Window WHERE AD_Window_ID=?"; + name = DB.getSQLValueString(null,sql,m_WF_Node.getAD_Window_ID()); + } + if (name != null ) + atts.addAttribute("","","ADWindowNameID","CDATA",name); + else + atts.addAttribute("","","ADWindowNameID","CDATA",""); + + if (m_WF_Node.getAD_Task_ID()> 0 ){ + sql = "SELECT Name FROM AD_Task WHERE AD_Task_ID=?"; + name = DB.getSQLValueString(null,sql,m_WF_Node.getAD_Task_ID()); + } + if (name != null ) + atts.addAttribute("","","ADTaskNameID","CDATA",name); + else + atts.addAttribute("","","ADTaskNameID","CDATA",""); + + if (m_WF_Node.getAD_Process_ID()> 0 ){ + sql = "SELECT Name FROM AD_Process WHERE AD_Process_ID=?"; + name = DB.getSQLValueString(null,sql,m_WF_Node.getAD_Process_ID()); + atts.addAttribute("","","ADProcessNameID","CDATA",name); + } + else + atts.addAttribute("","","ADProcessNameID","CDATA",""); + if (m_WF_Node.getAD_Form_ID()> 0 ){ + sql = "SELECT Name FROM AD_Form WHERE AD_Form_ID=?"; + name = DB.getSQLValueString(null,sql,m_WF_Node.getAD_Form_ID()); + atts.addAttribute("","","ADFormNameID","CDATA",name); + } + else + atts.addAttribute("","","ADFormNameID","CDATA",""); + if (m_WF_Node.getAD_WF_Block_ID()> 0 ){ + sql = "SELECT Name FROM AD_WF_Block WHERE AD_WF_Block_ID=?"; + name = DB.getSQLValueString(null,sql,m_WF_Node.getAD_WF_Block_ID()); + atts.addAttribute("","","ADWorkflowBlockNameID","CDATA",name); + } + else + atts.addAttribute("","","ADWorkflowBlockNameID","CDATA",""); + if (m_WF_Node.getAD_WF_Responsible_ID()> 0 ){ + sql = "SELECT Name FROM AD_WF_Responsible WHERE AD_WF_Responsible_ID=?"; + name = DB.getSQLValueString(null,sql,m_WF_Node.getAD_WF_Responsible_ID()); + atts.addAttribute("","","ADWorkflowResponsibleNameID","CDATA",name); + } + else + atts.addAttribute("","","ADWorkflowResponsibleNameID","CDATA",""); + + if (m_WF_Node.getAD_Image_ID()> 0 ){ + sql = "SELECT Name FROM AD_Image WHERE AD_Image_ID=?"; + name = DB.getSQLValueString(null,sql,m_WF_Node.getAD_Image_ID()); + } + if (name != null ) + atts.addAttribute("","","ADImageNameID","CDATA",name); + else + atts.addAttribute("","","ADImageNameID","CDATA",""); + if (m_WF_Node.getAD_Column_ID()> 0 ){ + sql = "SELECT ColumnName FROM AD_Column WHERE AD_Column_ID=?"; + name = DB.getSQLValueString(null,sql,m_WF_Node.getAD_Column_ID()); + atts.addAttribute("","","ADColumnNameID","CDATA",name); + } + else + atts.addAttribute("","","ADColumnNameID","CDATA",""); + atts.addAttribute("","","isActive","CDATA",(m_WF_Node.isActive()== true ? "true":"false")); + atts.addAttribute("","","Description","CDATA",(m_WF_Node.getDescription () != null ? m_WF_Node.getDescription ():"")); + atts.addAttribute("","","Help","CDATA",(m_WF_Node.getHelp () != null ? m_WF_Node.getHelp ():"")); + atts.addAttribute("","","isCentrallyMaintained","CDATA",(m_WF_Node.isCentrallyMaintained ()== true ? "true":"false")); + + atts.addAttribute("","","Action","CDATA",(m_WF_Node.getAction () != null ? m_WF_Node.getAction ():"")); + atts.addAttribute("","","EntityType","CDATA",(m_WF_Node.getEntityType () != null ? m_WF_Node.getEntityType ():"")); + atts.addAttribute("","","XPosition","CDATA",(""+m_WF_Node.getXPosition ())); + atts.addAttribute("","","YPosition","CDATA",(""+m_WF_Node.getYPosition ())); + atts.addAttribute("","","SubflowExecution","CDATA",(m_WF_Node.getSubflowExecution () != null ? m_WF_Node.getSubflowExecution ():"")); + atts.addAttribute("","","StartMode","CDATA",(m_WF_Node.getStartMode () != null ? m_WF_Node.getStartMode ():"")); + atts.addAttribute("","","Priority","CDATA",(""+m_WF_Node.getPriority ())); + atts.addAttribute("","","Duration","CDATA",(""+m_WF_Node.getDuration () )); + atts.addAttribute("","","Cost","CDATA",(""+m_WF_Node.getCost () )); + atts.addAttribute("","","WorkingTime","CDATA",(""+m_WF_Node.getWorkingTime() )); + atts.addAttribute("","","WaitingTime","CDATA",(""+m_WF_Node.getWaitingTime() )); + atts.addAttribute("","","JoinElement","CDATA",(m_WF_Node.getJoinElement() != null ? m_WF_Node.getJoinElement():"")); + atts.addAttribute("","","SplitElement","CDATA",(m_WF_Node.getSplitElement() != null ? m_WF_Node.getSplitElement():"")); + atts.addAttribute("","","WaitTime","CDATA",(""+m_WF_Node.getWaitTime() )); + atts.addAttribute("","","AttributeName","CDATA",(m_WF_Node.getAttributeName() != null ? m_WF_Node.getAttributeName():"")); + atts.addAttribute("","","AttributeValue","CDATA",(m_WF_Node.getAttributeValue() != null ? m_WF_Node.getAttributeValue():"")); + atts.addAttribute("","","DocAction","CDATA",(m_WF_Node.getDocAction() != null ? m_WF_Node.getDocAction():"")); + atts.addAttribute("","","DynPriorityUnit","CDATA",(m_WF_Node.getDynPriorityUnit() != null ? m_WF_Node.getDynPriorityUnit():"")); + atts.addAttribute("","","DynPriorityChange","CDATA",(""+m_WF_Node.getDynPriorityChange() )); + + return atts; + } + + public static AttributesImpl createwf_nodenextBinding( AttributesImpl atts, X_AD_WF_NodeNext m_WF_NodeNext) + //public AttributesImpl createwf_nodenextBinding( AttributesImpl atts, X_AD_WF_NodeNext m_WF_NodeNext, X_AD_WF_Node m_WF_Node) + { + String sql = null; + String name = null; + atts.clear(); + //log.log(Level.INFO,"m_WF_NodeNext.getAD_WF_Node_ID: ", m_WF_NodeNext.getAD_WF_Node_ID()); + //log.log(Level.INFO,"m_WF_NodeNext.getAD_WF_Next_ID: ", m_WF_NodeNext.getAD_WF_Next_ID()); + + if (m_WF_NodeNext.getAD_WF_Node_ID() > 0 ){ + sql = "SELECT AD_Workflow.Name FROM AD_Workflow, AD_WF_Node WHERE AD_Workflow.AD_Workflow_ID = AD_WF_Node.AD_Workflow_ID and AD_WF_Node.AD_WF_Node_ID =?"; + name = DB.getSQLValueString(null,sql,m_WF_NodeNext.getAD_WF_Node_ID()); + atts.addAttribute("","","ADWorkflowNameID","CDATA",name); + sql = "SELECT Name FROM AD_WF_Node WHERE AD_WF_Node_ID=?"; + name = DB.getSQLValueString(null,sql,m_WF_NodeNext.getAD_WF_Node_ID()); + atts.addAttribute("","","ADWorkflowNodeNameID","CDATA",name); + } + + if (m_WF_NodeNext.getAD_WF_Next_ID() > 0 ){ + sql = "SELECT Name FROM AD_WF_Node WHERE AD_WF_Node_ID=?"; + name = DB.getSQLValueString(null,sql,m_WF_NodeNext.getAD_WF_Next_ID()); + //log.log(Level.INFO,"node next name: ", name); + atts.addAttribute("","","ADWorkflowNodeNextNameID","CDATA",name); + } + + // FIXME: don't know if I need org_id or not + //sql = "SELECT Name FROM AD_Org WHERE AD_Org_ID=?"; + //name = DB.getSQLValueString(null,sql,org_id); + //atts.addAttribute("","","orgname","CDATA",name); + + atts.addAttribute("","","isActive","CDATA",(m_WF_NodeNext.isActive()== true ? "true":"false")); + atts.addAttribute("","","EntityType","CDATA",(m_WF_NodeNext.getEntityType () != null ? m_WF_NodeNext.getEntityType ():"")); + atts.addAttribute("","","Description","CDATA",(m_WF_NodeNext.getDescription () != null ? m_WF_NodeNext.getDescription ():"")); + atts.addAttribute("","","SeqNo","CDATA",(String.valueOf(m_WF_NodeNext.getSeqNo ()) != null ? String.valueOf(m_WF_NodeNext.getSeqNo ()):"")); + atts.addAttribute("","","IsStdUserWorkflow","CDATA",(String.valueOf(m_WF_NodeNext.isStdUserWorkflow ()) != null ? String.valueOf(m_WF_NodeNext.isStdUserWorkflow ()):"")); + + return atts; + } + + public static AttributesImpl createwf_nodenextconditionBinding( AttributesImpl atts, X_AD_WF_NextCondition m_WF_NodeNextCondition) + { + String sql = null; + String name = null; + atts.clear(); + + if (m_WF_NodeNextCondition.getAD_WF_NodeNext_ID() > 0 ){ + //FIXME: it appears nodes point back to themselves + // so a group by is necessary + sql = "SELECT AD_Workflow.Name FROM AD_Workflow, AD_WF_Node, AD_WF_NodeNext WHERE AD_Workflow.AD_Workflow_ID = AD_WF_Node.AD_Workflow_ID and AD_WF_Node.AD_WF_Node_ID = AD_WF_NodeNext.AD_WF_Node_ID and AD_WF_NodeNext.AD_WF_NodeNext_ID = ? group by AD_Workflow.Name"; + name = DB.getSQLValueString(null,sql,m_WF_NodeNextCondition.getAD_WF_NodeNext_ID()); + atts.addAttribute("","","ADWorkflowNameID","CDATA",name); + //FIXME: it appears nodes point back to themselves + // so a group by is necessary + sql = "SELECT AD_WF_Node.Name FROM AD_WF_Node, AD_WF_NodeNext WHERE AD_WF_Node.AD_WF_Node_ID = AD_WF_NodeNext.AD_WF_Node_ID and AD_WF_NodeNext.AD_WF_NodeNext_ID = ? group by AD_WF_Node.Name"; + name = DB.getSQLValueString(null,sql,m_WF_NodeNextCondition.getAD_WF_NodeNext_ID()); + atts.addAttribute("","","ADWorkflowNodeNameID","CDATA",name); + //FIXME: it appears nodes point back to themselves + // so a group by is necessary + sql = "SELECT AD_WF_Node.Name FROM AD_WF_Node, AD_WF_NodeNext, AD_WF_NextCondition WHERE AD_WF_Node.AD_WF_Node_ID = AD_WF_NodeNext.AD_WF_Next_ID and AD_WF_NodeNext.AD_WF_NodeNext_ID = ? group by AD_WF_Node.Name"; + name = DB.getSQLValueString(null,sql,m_WF_NodeNextCondition.getAD_WF_NodeNext_ID()); + //log.log(Level.INFO,"node next name: ", name); + atts.addAttribute("","","ADWorkflowNodeNextNameID","CDATA",name); + } + + if (m_WF_NodeNextCondition.getAD_Column_ID()> 0 ){ + + sql = "SELECT AD_Table.TableName FROM AD_Table, AD_Column, AD_WF_NextCondition WHERE AD_Column.AD_Table_ID=AD_Table.AD_Table_ID and AD_Column.AD_Column_ID = ?"; + name = DB.getSQLValueString(null,sql,m_WF_NodeNextCondition.getAD_Column_ID()); + atts.addAttribute("","","ADTableNameID","CDATA",name); + + sql = "SELECT ColumnName FROM AD_Column WHERE AD_Column_ID=?"; + name = DB.getSQLValueString(null,sql,m_WF_NodeNextCondition.getAD_Column_ID()); + atts.addAttribute("","","ADColumnNameID","CDATA",name); + } +else { + atts.addAttribute("","","ADTableNameID","CDATA",name); + atts.addAttribute("","","ADColumnNameID","CDATA",""); + } + + // FIXME: don't know if I need org_id or not + //sql = "SELECT Name FROM AD_Org WHERE AD_Org_ID=?"; + //name = DB.getSQLValueString(null,sql,org_id); + //atts.addAttribute("","","orgname","CDATA",name); + + atts.addAttribute("","","isActive","CDATA",(m_WF_NodeNextCondition.isActive()== true ? "true":"false")); + atts.addAttribute("","","EntityType","CDATA",(m_WF_NodeNextCondition.getEntityType () != null ? m_WF_NodeNextCondition.getEntityType ():"")); + atts.addAttribute("","","AndOr","CDATA",(m_WF_NodeNextCondition.getAndOr () != null ? m_WF_NodeNextCondition.getAndOr ():"")); + atts.addAttribute("","","Operation","CDATA",(m_WF_NodeNextCondition.getOperation () != null ? m_WF_NodeNextCondition.getOperation ():"")); + atts.addAttribute("","","Value","CDATA",(m_WF_NodeNextCondition.getValue () != null ? m_WF_NodeNextCondition.getValue ():"")); + atts.addAttribute("","","Value2","CDATA",(m_WF_NodeNextCondition.getValue2 () != null ? m_WF_NodeNextCondition.getValue2 ():"")); + atts.addAttribute("","","SeqNo","CDATA",(String.valueOf(m_WF_NodeNextCondition.getSeqNo ()) != null ? String.valueOf(m_WF_NodeNextCondition.getSeqNo ()):"")); + + return atts; + } public static AttributesImpl createcolumnBinding( AttributesImpl atts, X_AD_Column m_Column) { diff --git a/dbPort/src/org/compiere/model/X_AD_Package_Exp_Detail.java b/dbPort/src/org/compiere/model/X_AD_Package_Exp_Detail.java index 5160efba8a..d991835738 100644 --- a/dbPort/src/org/compiere/model/X_AD_Package_Exp_Detail.java +++ b/dbPort/src/org/compiere/model/X_AD_Package_Exp_Detail.java @@ -296,6 +296,24 @@ return ii.intValue(); } /** Column name AD_Table_ID */ public static final String COLUMNNAME_AD_Table_ID = "AD_Table_ID"; +/** Set Dynamic Validation. +@param AD_Val_Rule_ID Dynamic Validation Rule */ +public void setAD_Val_Rule_ID (int AD_Val_Rule_ID) +{ +if (AD_Val_Rule_ID <= 0) set_Value ("AD_Val_Rule_ID", null); + else +set_Value ("AD_Val_Rule_ID", Integer.valueOf(AD_Val_Rule_ID)); +} +/** Get Dynamic Validation. +@return Dynamic Validation Rule */ +public int getAD_Val_Rule_ID() +{ +Integer ii = (Integer)get_Value("AD_Val_Rule_ID"); +if (ii == null) return 0; +return ii.intValue(); +} +/** Column name AD_Val_Rule_ID */ +public static final String COLUMNNAME_AD_Val_Rule_ID = "AD_Val_Rule_ID"; /** Set Window. @param AD_Window_ID Data entry or display window */ public void setAD_Window_ID (int AD_Window_ID) @@ -666,6 +684,8 @@ public static final String TYPE_CodeSnipit = "SNI"; public static final String TYPE_SQLStatement = "SQL"; /** Table = T */ public static final String TYPE_Table = "T"; +/** Dynamic Validation Rule = V */ +public static final String TYPE_DynamicValidationRule = "V"; /** Window = W */ public static final String TYPE_Window = "W"; /** Form = X */ @@ -675,8 +695,8 @@ public static final String TYPE_Form = "X"; public void setType (String Type) { if (Type == null) throw new IllegalArgumentException ("Type is mandatory"); -if (Type.equals("B") || Type.equals("C") || Type.equals("D") || Type.equals("F") || Type.equals("IMP") || Type.equals("M") || Type.equals("P") || Type.equals("R") || Type.equals("S") || Type.equals("SNI") || Type.equals("SQL") || Type.equals("T") || Type.equals("W") || Type.equals("X")); - else throw new IllegalArgumentException ("Type Invalid value - " + Type + " - Reference_ID=50004 - B - C - D - F - IMP - M - P - R - S - SNI - SQL - T - W - X"); +if (Type.equals("B") || Type.equals("C") || Type.equals("D") || Type.equals("F") || Type.equals("IMP") || Type.equals("M") || Type.equals("P") || Type.equals("R") || Type.equals("S") || Type.equals("SNI") || Type.equals("SQL") || Type.equals("T") || Type.equals("V") || Type.equals("W") || Type.equals("X")); + else throw new IllegalArgumentException ("Type Invalid value - " + Type + " - Reference_ID=50004 - B - C - D - F - IMP - M - P - R - S - SNI - SQL - T - V - W - X"); if (Type.length() > 10) { log.warning("Length > 10 - truncated"); diff --git a/migration/316-trunk/008_2pack_enhancements.sql b/migration/316-trunk/008_2pack_enhancements.sql new file mode 100644 index 0000000000..f5cfce67f6 --- /dev/null +++ b/migration/316-trunk/008_2pack_enhancements.sql @@ -0,0 +1,79 @@ +ALTER TABLE AD_PACKAGE_EXP_DETAIL ADD ad_val_rule_id NUMBER(10); + +INSERT INTO AD_COLUMN + (ad_column_id, ad_client_id, ad_org_id, isactive, + created, + updated, createdby, + updatedby, NAME, description, + HELP, + VERSION, entitytype, columnname, ad_table_id, ad_reference_id, + fieldlength, iskey, isparent, ismandatory, isupdateable, + isidentifier, seqno, istranslated, isencrypted, + isselectioncolumn, ad_element_id, issyncdatabase, + isalwaysupdateable + ) + VALUES (50212, 0, 0, 'Y', + TO_DATE ('04/26/2007 03:24:26', 'MM/DD/YYYY HH24:MI:SS'), + TO_DATE ('04/26/2007 03:24:26', 'MM/DD/YYYY HH24:MI:SS'), 100, + 100, 'Dynamic Validation', 'Dynamic Validation Rule', + 'These rules define how an entry is determined to valid. You can use variables for dynamic (context sensitive) validation.', + 0, 'D', 'AD_Val_Rule_ID', 50006, 18, + 22, 'N', 'N', 'N', 'Y', + 'N', 0, 'N', 'N', + 'N', 139, 'N', + 'N' + ); + +INSERT INTO AD_FIELD + (ad_field_id, ad_client_id, ad_org_id, isactive, + created, createdby, + updated, updatedby, + NAME, description, + HELP, + iscentrallymaintained, ad_tab_id, ad_column_id, isdisplayed, + displaylogic, displaylength, isreadonly, seqno, issameline, + isheading, isfieldonly, isencrypted, entitytype + ) + VALUES (50182, 0, 0, 'Y', + TO_DATE ('04/26/2007 03:28:08', 'MM/DD/YYYY HH24:MI:SS'), 100, + TO_DATE ('04/26/2007 03:30:25', 'MM/DD/YYYY HH24:MI:SS'), 100, + 'Dynamic Validation', 'Dynamic Validation Rule', + 'These rules define how an entry is determined to valid. You can use variables for dynamic (context sensitive) validation.', + 'Y', 50006, 50212, 'Y', + '@Type@=''V''', 22, 'N', 245, 'N', + 'N', 'N', 'N', 'D' + ); + +INSERT INTO AD_REF_LIST + (ad_ref_list_id, ad_client_id, ad_org_id, isactive, + created, createdby, + updated, updatedby, + VALUE, NAME, ad_reference_id, entitytype + ) + VALUES (50041, 0, 0, 'Y', + TO_DATE ('04/26/2007 03:33:05', 'MM/DD/YYYY HH24:MI:SS'), 100, + TO_DATE ('04/26/2007 03:33:05', 'MM/DD/YYYY HH24:MI:SS'), 100, + 'V', 'Dynamic Validation Rule', 50004, 'D' + ); + +COMMIT ; + +UPDATE AD_SEQUENCE + SET currentnextsys = (SELECT MAX (ad_column_id) + 1 + FROM AD_COLUMN + WHERE ad_column_id < 1000000) + WHERE NAME = 'AD_Column'; + +UPDATE AD_SEQUENCE + SET currentnextsys = (SELECT MAX (ad_field_id) + 1 + FROM AD_FIELD + WHERE ad_field_id < 1000000) + WHERE NAME = 'AD_Field'; + +UPDATE AD_SEQUENCE + SET currentnextsys = (SELECT MAX (ad_ref_list_id) + 1 + FROM AD_REF_LIST + WHERE ad_ref_list_id < 1000000) + WHERE NAME = 'AD_Ref_List'; + +COMMIT ;