diff --git a/base/src/org/adempiere/pipo/AbstractElementHandler.java b/base/src/org/adempiere/pipo/AbstractElementHandler.java index 26d9c36429..acfd9fd446 100644 --- a/base/src/org/adempiere/pipo/AbstractElementHandler.java +++ b/base/src/org/adempiere/pipo/AbstractElementHandler.java @@ -32,6 +32,7 @@ import org.compiere.model.POInfo; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; +import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; @@ -77,8 +78,8 @@ public abstract class AbstractElementHandler implements ElementHandler { int objectIDBackup, String objectStatus, String tableName, int AD_Table_ID) throws SAXException{ String recordLayout; int id = 0; - TransformerHandler hd_document = getDocument(ctx); - AttributesImpl attsOut = getDocumentAttributes(ctx); + TransformerHandler hd_document = getLogDocument(ctx); + AttributesImpl attsOut = new AttributesImpl(); if (success == 1){ //hd_documemt.startElement("","","Successfull",attsOut); recordLayout = "Type:"+objectType + " - Name:"+objectName + " - ID:"+objectID +" - Action:"+objectStatus+" - Success"; @@ -386,19 +387,10 @@ public abstract class AbstractElementHandler implements ElementHandler { * @param ctx * @return TransformerHandler */ - protected TransformerHandler getDocument(Properties ctx) { - return (TransformerHandler)ctx.get("Document"); + protected TransformerHandler getLogDocument(Properties ctx) { + return (TransformerHandler)ctx.get("LogDocument"); } - /** - * Get share document attributes - * @param ctx - * @return AttributesImpl - */ - protected AttributesImpl getDocumentAttributes(Properties ctx) { - return (AttributesImpl)ctx.get("DocumentAttributes"); - } - /** * @param ctx * @return package directory @@ -420,4 +412,15 @@ public abstract class AbstractElementHandler implements ElementHandler { return true; } } + + /** + * return null for empty string (""). + * @param atts + * @param qName + * @return string value + */ + protected String getStringValue(Attributes atts, String qName) { + String s = atts.getValue(qName); + return ("".equals(s) ? null : s); + } } diff --git a/base/src/org/adempiere/pipo/PackInHandler.java b/base/src/org/adempiere/pipo/PackInHandler.java index a44408326b..d04a4ea213 100644 --- a/base/src/org/adempiere/pipo/PackInHandler.java +++ b/base/src/org/adempiere/pipo/PackInHandler.java @@ -76,7 +76,6 @@ import org.adempiere.pipo.handler.TaskElementHandler; import org.adempiere.pipo.handler.UserRoleElementHandler; import org.adempiere.pipo.handler.WindowAccessElementHandler; import org.adempiere.pipo.handler.WindowElementHandler; -import org.adempiere.pipo.handler.WorkbenchElementHandler; import org.adempiere.pipo.handler.WorkflowAccessElementHandler; import org.adempiere.pipo.handler.WorkflowElementHandler; import org.adempiere.pipo.handler.WorkflowNodeElementHandler; @@ -119,8 +118,7 @@ public class PackInHandler extends DefaultHandler { private int AD_Package_Imp_Inst_ID=0; private CLogger log = CLogger.getCLogger("PackIn"); private OutputStream fw_document = null; - private TransformerHandler hd_document = null; - private AttributesImpl attsOut = null; + private TransformerHandler logDocument = null; private StreamResult streamResult_document = null; private SAXTransformerFactory tf_document = null; private Transformer serializer_document = null; @@ -161,18 +159,16 @@ public class PackInHandler extends DefaultHandler { tf_document = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); try { - hd_document = tf_document.newTransformerHandler(); + logDocument = tf_document.newTransformerHandler(); } catch (TransformerConfigurationException e2) { log.info ("startElement:"+e2); } - serializer_document = hd_document.getTransformer(); + serializer_document = logDocument.getTransformer(); serializer_document.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1"); serializer_document.setOutputProperty(OutputKeys.INDENT,"yes"); - hd_document.setResult(streamResult_document); - hd_document.startDocument(); - attsOut = new AttributesImpl(); - attsOut.clear(); - hd_document.processingInstruction("xml-stylesheet","type=\"text/css\" href=\"adempiereDocument.css\""); + logDocument.setResult(streamResult_document); + logDocument.startDocument(); + logDocument.processingInstruction("xml-stylesheet","type=\"text/css\" href=\"adempiereDocument.css\""); Properties tmp = new Properties(); if (m_ctx != null) tmp.putAll(m_ctx); @@ -222,7 +218,6 @@ public class PackInHandler extends DefaultHandler { handlers.put("taskaccess", new TaskAccessElementHandler()); handlers.put("impformat", new ImpFormatElementHandler()); handlers.put("impformatrow", new ImpFormatRowElementHandler()); - handlers.put("workbench", new WorkbenchElementHandler()); handlers.put("codesnipit", new CodeSnipitElementHandler()); handlers.put("distfile", new DistFileElementHandler()); handlers.put("reportview", new ReportViewElementHandler()); @@ -262,40 +257,41 @@ public class PackInHandler extends DefaultHandler { if (elementValue.equals("adempiereAD")) { log.info("adempiereAD updateMode="+m_UpdateMode); //Start package log - hd_document.startElement("","","adempiereDocument",attsOut); - hd_document.startElement("","","header",attsOut); - hd_document.characters((atts.getValue("Name")+" Install Log").toCharArray(),0,(atts.getValue("Name")+" Install Log").length()); - hd_document.endElement("","","header"); - hd_document.startElement("","","H3",attsOut); - hd_document.characters(("Package Name:" ).toCharArray(),0,("Package Name:" ).length()); - hd_document.endElement("","","H3"); - hd_document.startElement("","","packagename4log",attsOut); - hd_document.characters(atts.getValue("Name").toCharArray(),0,atts.getValue("Name").length()); - hd_document.endElement("","","packagename4log"); - hd_document.startElement("","","H3",attsOut); - hd_document.characters(("Version:" ).toCharArray(),0,("Version:" ).length()); - hd_document.endElement("","","H3"); - hd_document.startElement("","","Version",attsOut); - hd_document.characters(atts.getValue("Version").toCharArray(),0,atts.getValue("Version").length()); - hd_document.endElement("","","Version"); - hd_document.startElement("","","H3",attsOut); - hd_document.characters(("Package Install Date:" ).toCharArray(),0,("Package Install Date:" ).length()); - hd_document.endElement("","","H3"); - hd_document.startElement("","","installDate",attsOut); - hd_document.characters(logDate.toCharArray(),0,logDate.length()); - hd_document.endElement("","","installDate"); - hd_document.startElement("","","H3",attsOut); - hd_document.characters(("Min. Compiere Version:" ).toCharArray(),0,("Min. Compiere Version:" ).length()); - hd_document.endElement("","","H3"); - hd_document.startElement("","","CompVer",attsOut); - hd_document.characters(atts.getValue("CompVer").toCharArray(),0,atts.getValue("CompVer").length()); - hd_document.endElement("","","CompVer"); - hd_document.startElement("","","H3",attsOut); - hd_document.characters(("Min. Database Date:" ).toCharArray(),0,("Min. Database Date:" ).length()); - hd_document.endElement("","","H3"); - hd_document.startElement("","","DataBase",attsOut); - hd_document.characters(atts.getValue("DataBase").toCharArray(),0,atts.getValue("DataBase").length()); - hd_document.endElement("","","DataBase"); + AttributesImpl attsOut = new AttributesImpl(); + logDocument.startElement("","","adempiereDocument",attsOut); + logDocument.startElement("","","header",attsOut); + logDocument.characters((atts.getValue("Name")+" Install Log").toCharArray(),0,(atts.getValue("Name")+" Install Log").length()); + logDocument.endElement("","","header"); + logDocument.startElement("","","H3",attsOut); + logDocument.characters(("Package Name:" ).toCharArray(),0,("Package Name:" ).length()); + logDocument.endElement("","","H3"); + logDocument.startElement("","","packagename4log",attsOut); + logDocument.characters(atts.getValue("Name").toCharArray(),0,atts.getValue("Name").length()); + logDocument.endElement("","","packagename4log"); + logDocument.startElement("","","H3",attsOut); + logDocument.characters(("Version:" ).toCharArray(),0,("Version:" ).length()); + logDocument.endElement("","","H3"); + logDocument.startElement("","","Version",attsOut); + logDocument.characters(atts.getValue("Version").toCharArray(),0,atts.getValue("Version").length()); + logDocument.endElement("","","Version"); + logDocument.startElement("","","H3",attsOut); + logDocument.characters(("Package Install Date:" ).toCharArray(),0,("Package Install Date:" ).length()); + logDocument.endElement("","","H3"); + logDocument.startElement("","","installDate",attsOut); + logDocument.characters(logDate.toCharArray(),0,logDate.length()); + logDocument.endElement("","","installDate"); + logDocument.startElement("","","H3",attsOut); + logDocument.characters(("Min. Compiere Version:" ).toCharArray(),0,("Min. Compiere Version:" ).length()); + logDocument.endElement("","","H3"); + logDocument.startElement("","","CompVer",attsOut); + logDocument.characters(atts.getValue("CompVer").toCharArray(),0,atts.getValue("CompVer").length()); + logDocument.endElement("","","CompVer"); + logDocument.startElement("","","H3",attsOut); + logDocument.characters(("Min. Database Date:" ).toCharArray(),0,("Min. Database Date:" ).length()); + logDocument.endElement("","","H3"); + logDocument.startElement("","","DataBase",attsOut); + logDocument.characters(atts.getValue("DataBase").toCharArray(),0,atts.getValue("DataBase").length()); + logDocument.endElement("","","DataBase"); createImp_Sum_table ("AD_Package_Imp_Backup"); createImp_Sum_table ("AD_Package_Imp"); @@ -383,8 +379,7 @@ public class PackInHandler extends DefaultHandler { Env.setContext(m_ctx, "UpdateMode", m_UpdateMode); Env.setContext(m_ctx, "TrxName", m_trxName); Env.setContext(m_ctx, "PackageDirectory", packageDirectory); - m_ctx.put("Document", hd_document); - m_ctx.put("DocumentAttributes", attsOut); + m_ctx.put("LogDocument", logDocument); m_ctx.put("PackInProcess", packIn); } else if (elementValue.equals("menu")) { @@ -633,8 +628,8 @@ public class PackInHandler extends DefaultHandler { if (no == -1) log.info("Update to package list failed"); - hd_document.endElement("","","adempiereDocument"); - hd_document.endDocument(); + logDocument.endElement("","","adempiereDocument"); + logDocument.endDocument(); try { fw_document.close(); } diff --git a/base/src/org/adempiere/pipo/PackOut.java b/base/src/org/adempiere/pipo/PackOut.java index 78d67916ec..02f58f8160 100644 --- a/base/src/org/adempiere/pipo/PackOut.java +++ b/base/src/org/adempiere/pipo/PackOut.java @@ -46,7 +46,6 @@ import org.adempiere.pipo.handler.SQLStatementElementHandler; import org.adempiere.pipo.handler.TableElementHandler; import org.adempiere.pipo.handler.TaskElementHandler; import org.adempiere.pipo.handler.WindowElementHandler; -import org.adempiere.pipo.handler.WorkbenchElementHandler; import org.adempiere.pipo.handler.WorkflowElementHandler; import org.compiere.model.X_AD_Package_Exp; import org.compiere.model.X_AD_Package_Exp_Detail; @@ -86,7 +85,6 @@ public class PackOut extends SvrProcess ReportViewElementHandler reportViewHandler = new ReportViewElementHandler(); DataElementHandler dataHandler = new DataElementHandler(); TableElementHandler tableHandler = new TableElementHandler(); - WorkbenchElementHandler workbenchHandler = new WorkbenchElementHandler(); RoleElementHandler roleHandler = new RoleElementHandler(); SQLStatementElementHandler sqlHandler = new SQLStatementElementHandler(); ImpFormatElementHandler impFormtHandler = new ImpFormatElementHandler(); @@ -246,28 +244,26 @@ public class PackOut extends SvrProcess String Type = rs.getString(X_AD_Package_Exp_Detail.COLUMNNAME_Type); log.info(rs.getString(X_AD_Package_Exp_Detail.COLUMNNAME_Line)); if (Type.compareTo("M") == 0){ - createMenu(rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Menu_ID), atts, packOutDocument ); + createMenu(rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Menu_ID), packOutDocument ); } else if (Type.compareTo("P") == 0) - createProcess ( rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Process_ID), atts, packOutDocument ); + createProcess ( rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Process_ID), packOutDocument ); else if (Type.compareTo("R") == 0) - createReportview ( rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_ReportView_ID), atts, packOutDocument ); + createReportview ( rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_ReportView_ID), packOutDocument ); else if (Type.compareTo("D") == 0) - createData ( rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Table_ID), rs.getString(X_AD_Package_Exp_Detail.COLUMNNAME_SQLStatement), atts, packOutDocument ); + createData ( rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Table_ID), rs.getString(X_AD_Package_Exp_Detail.COLUMNNAME_SQLStatement), packOutDocument ); else if (Type.compareTo("T") == 0) - createTable (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Table_ID), atts, packOutDocument); + createTable (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Table_ID), packOutDocument); else if (Type.compareTo("X") == 0) - createForm (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Form_ID), atts, packOutDocument); + createForm (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Form_ID), packOutDocument); else if (Type.compareTo("W") == 0) - createWindow (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Window_ID), atts, packOutDocument); - else if (Type.compareTo("B") == 0) - createWorkbench (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Workbench_ID), atts, packOutDocument); + createWindow (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Window_ID), packOutDocument); else if (Type.compareTo("S") == 0) - createRoles (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Role_ID), atts, packOutDocument); + createRoles (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Role_ID), packOutDocument); else if (Type.compareTo("SQL") == 0) - createSQL (rs.getString(X_AD_Package_Exp_Detail.COLUMNNAME_SQLStatement), rs.getString(X_AD_Package_Exp_Detail.COLUMNNAME_DBType), atts, packOutDocument); + createSQL (rs.getString(X_AD_Package_Exp_Detail.COLUMNNAME_SQLStatement), rs.getString(X_AD_Package_Exp_Detail.COLUMNNAME_DBType), packOutDocument); else if (Type.compareTo("IMP") == 0) - createImpFormat (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_ImpFormat_ID), atts, packOutDocument); + createImpFormat (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_ImpFormat_ID), packOutDocument); else if (Type.compareTo("SNI") == 0) createSnipit( rs.getString(X_AD_Package_Exp_Detail.COLUMNNAME_Destination_Directory), @@ -275,15 +271,15 @@ public class PackOut extends SvrProcess rs.getString(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Package_Code_Old), rs.getString(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Package_Code_New), rs.getString(X_AD_Package_Exp_Detail.COLUMNNAME_ReleaseNo), - atts, packOutDocument); + packOutDocument); else if (Type.compareTo("F") == 0) - createWorkflow (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Workflow_ID), atts, packOutDocument); + createWorkflow (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Workflow_ID), packOutDocument); else if (Type.compareTo("V") == 0) - createDynamicRuleValidation(rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID), atts, packOutDocument); + createDynamicRuleValidation(rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID), packOutDocument); else if (Type.compareTo("MSG") == 0) - createMessage(rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Message_ID), atts, packOutDocument); + createMessage(rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Message_ID), packOutDocument); else if (Type.compareTo("PFT") == 0) - createPrintFormat(rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_PrintFormat_ID), atts, packOutDocument); + createPrintFormat(rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_PrintFormat_ID), packOutDocument); else if (Type.compareTo("C") == 0){ log.log(Level.INFO,"In PackOut.java handling Code or Other 2pack module creation"); @@ -332,7 +328,7 @@ public class PackOut extends SvrProcess rs.getString(X_AD_Package_Exp_Detail.COLUMNNAME_FileName), rs.getString(X_AD_Package_Exp_Detail.COLUMNNAME_Target_Directory), rs.getString(X_AD_Package_Exp_Detail.COLUMNNAME_ReleaseNo), - destinationDirectoryModified, atts, + destinationDirectoryModified, packOutDocument); } @@ -449,37 +445,56 @@ public class PackOut extends SvrProcess localContext = tmp; } - - public void createMenu(int AD_Menu_ID, AttributesImpl atts, - TransformerHandler packOutDocument) throws Exception { + private void copyCode (String sourceName, String copyName) + { + copyFile (sourceName, copyName ); + } + + /** + * + * @param AD_Menu_ID + * @param packOutDocument + * @throws Exception + */ + public void createMenu(int AD_Menu_ID, TransformerHandler packOutDocument) throws Exception { Env.setContext(getCtx(), "AD_Menu_ID", AD_Menu_ID); menuHandler.create(getCtx(), packOutDocument); getCtx().remove("AD_Menu_ID"); } - - public void copyCode (String sourceName, String copyName) - { - copyFile (sourceName, copyName ); - } - - public void createPrintFormat (int AD_PrintFormat_ID, AttributesImpl atts, - TransformerHandler packOutDocument) throws Exception + /** + * + * @param AD_PrintFormat_ID + * @param packOutDocument + * @throws Exception + */ + public void createPrintFormat (int AD_PrintFormat_ID, TransformerHandler packOutDocument) throws Exception { Env.setContext(getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_PrintFormat_ID, AD_PrintFormat_ID); printFormatHandler.create(getCtx(), packOutDocument); getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_PrintFormat_ID); } - public void createMessage (int AD_Message_ID, AttributesImpl atts, - TransformerHandler packOutDocument) throws Exception + /** + * + * @param AD_Message_ID + * @param packOutDocument + * @throws Exception + */ + public void createMessage (int AD_Message_ID, TransformerHandler packOutDocument) throws Exception { Env.setContext(getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Message_ID, AD_Message_ID); messageHandler.create(getCtx(), packOutDocument); getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Message_ID); } - public void createDynamicRuleValidation (int AD_Val_Rule_ID, AttributesImpl atts, + /** + * + * @param AD_Val_Rule_ID + * @param packOutDocument + * @throws Exception + */ + public void createDynamicRuleValidation (int AD_Val_Rule_ID, TransformerHandler packOutDocument) throws Exception { Env.setContext(getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID, AD_Val_Rule_ID); @@ -487,7 +502,13 @@ public class PackOut extends SvrProcess getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID); } - public void createWorkflow (int AD_Workflow_ID, AttributesImpl atts, TransformerHandler packOutDocument) + /** + * + * @param AD_Workflow_ID + * @param packOutDocument + * @throws SAXException + */ + public void createWorkflow (int AD_Workflow_ID, TransformerHandler packOutDocument) throws SAXException { Env.setContext(getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Workflow_ID, AD_Workflow_ID); @@ -495,14 +516,17 @@ public class PackOut extends SvrProcess getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Workflow_ID); } - public void createWorkbench (int AD_Workbench_ID, AttributesImpl atts, TransformerHandler packOutDocument) throws SAXException - { - Env.setContext(getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Workbench_ID, AD_Workbench_ID); - workbenchHandler.create(getCtx(), packOutDocument); - getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Workbench_ID); - } - - public void createDistributeFile (String FileName, String Source_Directory, String ReleaseNo,String Target_Directory, AttributesImpl atts, TransformerHandler packOutDocument) throws SAXException + /** + * + * @param FileName + * @param Source_Directory + * @param ReleaseNo + * @param Target_Directory + * @param atts + * @param packOutDocument + * @throws SAXException + */ + public void createDistributeFile (String FileName, String Source_Directory, String ReleaseNo,String Target_Directory, TransformerHandler packOutDocument) throws SAXException { Env.setContext(getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_FileName, FileName); Env.setContext(getCtx(), "Source_Directory", Source_Directory); @@ -515,35 +539,66 @@ public class PackOut extends SvrProcess getCtx().remove("Source_Directory"); } - public void createForm (int AD_Form_ID, AttributesImpl atts, TransformerHandler packOutDocument) throws SAXException + /** + * + * @param AD_Form_ID + * @param packOutDocument + * @throws SAXException + */ + public void createForm (int AD_Form_ID, TransformerHandler packOutDocument) throws SAXException { Env.setContext(getCtx(), "AD_Form_ID", AD_Form_ID); formHandler.create(getCtx(), packOutDocument); getCtx().remove("AD_Form_ID"); } - public void createTask (int AD_Task_ID, AttributesImpl atts, TransformerHandler packOutDocument) throws SAXException + /** + * + * @param AD_Task_ID + * @param packOutDocument + * @throws SAXException + */ + public void createTask (int AD_Task_ID, TransformerHandler packOutDocument) throws SAXException { Env.setContext(getCtx(), "AD_Task_ID", AD_Task_ID); taskHandler.create(getCtx(), packOutDocument); getCtx().remove("AD_Task_ID"); } - public void createProcess (int AD_Process_ID, AttributesImpl atts, TransformerHandler packOutDocument) throws SAXException + /** + * + * @param AD_Process_ID + * @param packOutDocument + * @throws SAXException + */ + public void createProcess (int AD_Process_ID, TransformerHandler packOutDocument) throws SAXException { Env.setContext(getCtx(), "AD_Process_ID", AD_Process_ID); processHandler.create(getCtx(), packOutDocument); getCtx().remove("AD_Process_ID"); } - public void createWindow (int AD_Window_ID, AttributesImpl atts, TransformerHandler packOutDocument) throws SAXException + /** + * + * @param AD_Window_ID + * @param packOutDocument + * @throws SAXException + */ + public void createWindow (int AD_Window_ID, TransformerHandler packOutDocument) throws SAXException { Env.setContext(getCtx(), "AD_Window_ID", AD_Window_ID); windowHandler.create(getCtx(), packOutDocument); getCtx().remove("AD_Window_ID"); } - public void createData (int table_id, String sql, AttributesImpl atts, TransformerHandler packOutDocument) throws SAXException + /** + * + * @param table_id + * @param sql + * @param packOutDocument + * @throws SAXException + */ + public void createData (int table_id, String sql, TransformerHandler packOutDocument) throws SAXException { Env.setContext(getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Table_ID, table_id); Env.setContext(getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_SQLStatement, sql); @@ -552,14 +607,27 @@ public class PackOut extends SvrProcess getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_SQLStatement); } - public void createReportview (int Reportview_id, AttributesImpl atts, TransformerHandler packOutDocument) throws SAXException + /** + * + * @param Reportview_id + * @param packOutDocument + * @throws SAXException + */ + public void createReportview (int Reportview_id, TransformerHandler packOutDocument) throws SAXException { Env.setContext(getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_ReportView_ID, Reportview_id); reportViewHandler.create(getCtx(), packOutDocument); getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_ReportView_ID); } - public void createSQL (String SQLStatement, String DBType,AttributesImpl atts, TransformerHandler packOutDocument) throws SAXException + /** + * + * @param SQLStatement + * @param DBType + * @param packOutDocument + * @throws SAXException + */ + public void createSQL (String SQLStatement, String DBType, TransformerHandler packOutDocument) throws SAXException { Env.setContext(getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_SQLStatement, SQLStatement); Env.setContext(getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_DBType, DBType); @@ -568,7 +636,18 @@ public class PackOut extends SvrProcess getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_DBType); } - public void createSnipit (String FileDir, String FileName, String OldCode, String NewCode, String ReleaseNo, AttributesImpl atts, TransformerHandler packOutDocument) throws SAXException + /** + * + * @param FileDir + * @param FileName + * @param OldCode + * @param NewCode + * @param ReleaseNo + * @param atts + * @param packOutDocument + * @throws SAXException + */ + public void createSnipit (String FileDir, String FileName, String OldCode, String NewCode, String ReleaseNo, TransformerHandler packOutDocument) throws SAXException { Env.setContext(getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_File_Directory, FileDir); Env.setContext(getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_FileName, FileName); @@ -583,21 +662,39 @@ public class PackOut extends SvrProcess getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_ReleaseNo); } - public void createRoles (int Role_id, AttributesImpl atts, TransformerHandler packOutDocument) throws SAXException + /** + * + * @param Role_id + * @param packOutDocument + * @throws SAXException + */ + public void createRoles (int Role_id, TransformerHandler packOutDocument) throws SAXException { Env.setContext(getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Role_ID, Role_id); roleHandler.create(getCtx(), packOutDocument); getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Role_ID); } - public void createReference (int Reference_id, AttributesImpl atts, TransformerHandler packOutDocument) throws SAXException + /** + * + * @param Reference_id + * @param packOutDocument + * @throws SAXException + */ + public void createReference (int Reference_id, TransformerHandler packOutDocument) throws SAXException { Env.setContext(getCtx(), X_AD_Reference.COLUMNNAME_AD_Reference_ID, Reference_id); referenceHandler.create(getCtx(), packOutDocument); getCtx().remove(X_AD_Reference.COLUMNNAME_AD_Reference_ID); } - public void createImpFormat (int import_id, AttributesImpl atts, TransformerHandler packOutDocument) throws SAXException + /** + * + * @param import_id + * @param packOutDocument + * @throws SAXException + */ + public void createImpFormat (int import_id, TransformerHandler packOutDocument) throws SAXException { Env.setContext(getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_ImpFormat_ID, import_id); impFormtHandler.create(getCtx(), packOutDocument); @@ -605,7 +702,13 @@ public class PackOut extends SvrProcess } - public void createTable (int table_id, AttributesImpl atts, TransformerHandler packOutDocument) throws SAXException + /** + * + * @param table_id + * @param packOutDocument + * @throws SAXException + */ + public void createTable (int table_id, TransformerHandler packOutDocument) throws SAXException { Env.setContext(getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Table_ID, table_id); tableHandler.create(getCtx(), packOutDocument); diff --git a/base/src/org/adempiere/pipo/handler/ColumnElementHandler.java b/base/src/org/adempiere/pipo/handler/ColumnElementHandler.java index 38443f1984..4a6a926122 100644 --- a/base/src/org/adempiere/pipo/handler/ColumnElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/ColumnElementHandler.java @@ -110,20 +110,18 @@ public class ColumnElementHandler extends AbstractElementHandler { Name = atts.getValue("ADReferenceNameValueID"); id = get_IDWithColumn(ctx, "AD_Reference", "Name", Name); m_Column.setAD_Reference_Value_ID(id); - m_Column.setCallout(atts.getValue("Callout")); - m_Column.setColumnSQL(atts.getValue("ColumnSQL")); + m_Column.setCallout(getStringValue(atts, "Callout")); + m_Column.setColumnSQL(getStringValue(atts, "ColumnSQL")); m_Column.setColumnName(atts.getValue("ColumnName")); - m_Column.setDefaultValue(atts.getValue("DefaultValue")); - m_Column.setDescription(atts.getValue("Description").replaceAll( - "'", "''").replaceAll(",", "")); + m_Column.setDefaultValue(getStringValue(atts, "DefaultValue")); + m_Column.setDescription(getStringValue(atts, "Description")); m_Column.setEntityType(atts.getValue("EntityType")); if (Integer.parseInt(atts.getValue("FieldLength")) > 0) m_Column.setFieldLength(Integer.parseInt(atts .getValue("FieldLength"))); - m_Column.setHelp(atts.getValue("Help").replaceAll("'", "''") - .replaceAll(",", "")); + m_Column.setHelp(getStringValue(atts, "Help")); m_Column.setIsActive(atts.getValue("isActive") != null ? Boolean .valueOf(atts.getValue("isActive")).booleanValue() : true); m_Column.setIsAlwaysUpdateable((Boolean.valueOf(atts @@ -147,16 +145,16 @@ public class ColumnElementHandler extends AbstractElementHandler { m_Column.setIsUpdateable((Boolean.valueOf(atts .getValue("isUpdateable")).booleanValue())); m_Column.setName(atts.getValue("Name")); - m_Column.setReadOnlyLogic(atts.getValue("ReadOnlyLogic")); + m_Column.setReadOnlyLogic(getStringValue(atts, "ReadOnlyLogic")); if (Integer.parseInt(atts.getValue("SeqNo")) > 0) m_Column.setSeqNo(Integer.parseInt(atts.getValue("SeqNo"))); - m_Column.setVFormat(atts.getValue("VFormat")); - if (atts.getValue("ValueMax") != null) + m_Column.setVFormat(getStringValue(atts, "VFormat")); + if (getStringValue(atts, "ValueMax") != null) m_Column.setValueMax(atts.getValue("ValueMax")); - if (atts.getValue("ValueMin") != null) + if (getStringValue(atts, "ValueMin") != null) m_Column.setValueMin(atts.getValue("ValueMin")); - if (atts.getValue("Version") != null) + if (getStringValue(atts, "Version") != null) m_Column.setVersion(new BigDecimal(atts.getValue("Version"))); // Setup Element. diff --git a/base/src/org/adempiere/pipo/handler/DynValRuleElementHandler.java b/base/src/org/adempiere/pipo/handler/DynValRuleElementHandler.java index fec3403296..2768b32e63 100644 --- a/base/src/org/adempiere/pipo/handler/DynValRuleElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/DynValRuleElementHandler.java @@ -18,6 +18,8 @@ package org.adempiere.pipo.handler; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.List; import java.util.Properties; import java.util.logging.Level; @@ -25,6 +27,7 @@ import javax.xml.transform.sax.TransformerHandler; import org.adempiere.pipo.AbstractElementHandler; import org.adempiere.pipo.Element; +import org.adempiere.pipo.exception.POSaveFailedException; import org.compiere.model.X_AD_Package_Exp_Detail; import org.compiere.model.X_AD_Val_Rule; import org.compiere.util.DB; @@ -35,6 +38,8 @@ import org.xml.sax.helpers.AttributesImpl; public class DynValRuleElementHandler extends AbstractElementHandler { + private List rules = new ArrayList(); + public void startElement(Properties ctx, Element element) throws SAXException { String elementValue = element.getElementValue(); Attributes atts = element.attributes; @@ -55,7 +60,7 @@ public class DynValRuleElementHandler extends AbstractElementHandler { Object_Status = "New"; AD_Backup_ID =0; } - m_ValRule.setDescription(atts.getValue("Description").replaceAll("'","''")); + m_ValRule.setDescription(getStringValue(atts, "Description")); m_ValRule.setEntityType(atts.getValue("EntityType")); m_ValRule.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true); m_ValRule.setName(name); @@ -66,6 +71,7 @@ public class DynValRuleElementHandler extends AbstractElementHandler { } else{ record_log (ctx, 0, m_ValRule.getName(),"Task", m_ValRule.get_ID(),AD_Backup_ID, Object_Status,"AD_Val_Rule",get_IDWithColumn(ctx, "AD_Val_Rule", "Name", "AD_Val_Rule")); + throw new POSaveFailedException("Failed to save dynamic validation rule."); } } else { element.skip = true; @@ -79,6 +85,9 @@ public class DynValRuleElementHandler extends AbstractElementHandler { public void create(Properties ctx, TransformerHandler document) throws SAXException { int AD_Val_Rule_ID = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID); + if (rules.contains(AD_Val_Rule_ID)) + return; + rules.add(AD_Val_Rule_ID); String sql = "SELECT Name FROM AD_Val_Rule WHERE AD_Val_Rule_ID= " + AD_Val_Rule_ID; AttributesImpl atts = new AttributesImpl(); PreparedStatement pstmt = null; diff --git a/base/src/org/adempiere/pipo/handler/FieldElementHandler.java b/base/src/org/adempiere/pipo/handler/FieldElementHandler.java index f6914e452d..cd3239c69d 100644 --- a/base/src/org/adempiere/pipo/handler/FieldElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/FieldElementHandler.java @@ -24,6 +24,7 @@ import javax.xml.transform.sax.TransformerHandler; import org.adempiere.pipo.AbstractElementHandler; import org.adempiere.pipo.Element; import org.adempiere.pipo.PackIn; +import org.adempiere.pipo.exception.POSaveFailedException; import org.compiere.model.MField; import org.compiere.model.X_AD_Field; import org.compiere.util.DB; @@ -133,15 +134,15 @@ public class FieldElementHandler extends AbstractElementHandler { m_Field.setSeqNo(Integer.parseInt(atts.getValue("SeqNo"))); m_Field.setDisplayLength(Integer.parseInt(atts .getValue("DisplayLength"))); - m_Field.setDescription(atts.getValue("Description").replaceAll( - "'", "''").replaceAll(",", "")); - m_Field.setHelp(atts.getValue("Help").replaceAll("'", "''") - .replaceAll(",", "")); + m_Field.setDescription(getStringValue(atts, "Description")); + m_Field.setHelp(getStringValue(atts, "Help")); m_Field.setIsActive(atts.getValue("isActive") != null ? Boolean .valueOf(atts.getValue("isActive")).booleanValue() : true); - m_Field.setSortNo(new BigDecimal(atts.getValue("SortNo"))); - m_Field.setDisplayLogic(atts.getValue("DisplayLogic")); + String sortNo = getStringValue(atts, "SortNo"); + if (sortNo != null) + m_Field.setSortNo(new BigDecimal(sortNo)); + m_Field.setDisplayLogic(getStringValue(atts, "DisplayLogic")); if (m_Field.save(getTrxName(ctx)) == true) { record_log(ctx, 1, m_Field.getName(), "Field", m_Field .get_ID(), AD_Backup_ID, Object_Status, "AD_Field", @@ -153,6 +154,7 @@ public class FieldElementHandler extends AbstractElementHandler { .get_ID(), AD_Backup_ID, Object_Status, "AD_Field", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Field")); + throw new POSaveFailedException("Failed to save field definition."); } } else { element.defer = true; diff --git a/base/src/org/adempiere/pipo/handler/FormElementHandler.java b/base/src/org/adempiere/pipo/handler/FormElementHandler.java index 1f9fe70cbe..ca0969c223 100644 --- a/base/src/org/adempiere/pipo/handler/FormElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/FormElementHandler.java @@ -22,6 +22,7 @@ import javax.xml.transform.sax.TransformerHandler; import org.adempiere.pipo.AbstractElementHandler; import org.adempiere.pipo.Element; +import org.adempiere.pipo.exception.POSaveFailedException; import org.compiere.model.MForm; import org.compiere.model.X_AD_Form; import org.compiere.util.DB; @@ -55,9 +56,9 @@ public class FormElementHandler extends AbstractElementHandler { m_Form.setClassname (atts.getValue("Classname")); m_Form.setIsBetaFunctionality (Boolean.valueOf(atts.getValue("isBetaFunctionality")).booleanValue()); m_Form.setAccessLevel(atts.getValue("AccessLevel")); - m_Form.setDescription(atts.getValue("Description").replaceAll("'","''")); + m_Form.setDescription(getStringValue(atts, "Description")); m_Form.setEntityType(atts.getValue("EntityType")); - m_Form.setHelp(atts.getValue("Help")); + m_Form.setHelp(getStringValue(atts, "Help")); m_Form.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true); m_Form.setName(atts.getValue("Name")); @@ -66,6 +67,7 @@ public class FormElementHandler extends AbstractElementHandler { } else{ record_log (ctx, 0, m_Form.getName(),"Form", m_Form.get_ID(),AD_Backup_ID, Object_Status,"AD_Form",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Form")); + throw new POSaveFailedException("Failed to save form definition"); } } else { element.skip = true; @@ -93,11 +95,14 @@ public class FormElementHandler extends AbstractElementHandler { if (m_Form.getAD_Form_ID()> 0 ){ sql = "SELECT Name FROM AD_Form WHERE AD_Form_ID=?"; name = DB.getSQLValueString(null,sql,m_Form.getAD_Form_ID()); + if (name != null ) + atts.addAttribute("","","ADFormNameID","CDATA",name); + else + atts.addAttribute("","","ADFormNameID","CDATA",""); + } else { + atts.addAttribute("","","ADFormNameID","CDATA",""); } - if (name != null ) - atts.addAttribute("","","ADFormNameID","CDATA",name); - else - atts.addAttribute("","","ADFormNameID","CDATA",""); + atts.addAttribute("","","Classname","CDATA",(m_Form.getClassname () != null ? m_Form.getClassname ():"")); atts.addAttribute("","","isBetaFunctionality","CDATA",(m_Form.isBetaFunctionality()== true ? "true":"false")); atts.addAttribute("","","AccessLevel","CDATA",(m_Form.getAccessLevel () != null ? m_Form.getAccessLevel ():"")); diff --git a/base/src/org/adempiere/pipo/handler/ImpFormatElementHandler.java b/base/src/org/adempiere/pipo/handler/ImpFormatElementHandler.java index af355a6e7a..d60015c16b 100644 --- a/base/src/org/adempiere/pipo/handler/ImpFormatElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/ImpFormatElementHandler.java @@ -76,7 +76,7 @@ public class ImpFormatElementHandler extends AbstractElementHandler { .valueOf(atts.getValue("isProcessing")).booleanValue() : true); m_ImpFormat.setName(atts.getValue("Name")); - m_ImpFormat.setDescription(atts.getValue("Description")); + m_ImpFormat.setDescription(getStringValue(atts,"Description")); m_ImpFormat.setFormatType(atts.getValue("FormatType")); if (m_ImpFormat.save(getTrxName(ctx)) == true) { record_log(ctx, 1, m_ImpFormat.getName(), "ImpFormat", m_ImpFormat @@ -88,7 +88,7 @@ public class ImpFormatElementHandler extends AbstractElementHandler { .get_ID(), AD_Backup_ID, Object_Status, "AD_ImpFormat", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_ImpFormat")); - throw new POSaveFailedException("ImpFormat"); + throw new POSaveFailedException("Failed to save Import Format."); } } diff --git a/base/src/org/adempiere/pipo/handler/ImpFormatRowElementHandler.java b/base/src/org/adempiere/pipo/handler/ImpFormatRowElementHandler.java index 840b0c30cb..1f749225f7 100644 --- a/base/src/org/adempiere/pipo/handler/ImpFormatRowElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/ImpFormatRowElementHandler.java @@ -97,7 +97,7 @@ public class ImpFormatRowElementHandler extends AbstractElementHandler { } else{ record_log (ctx, 0, m_ImpFormat_row.getName(),"ImpFormat", m_ImpFormat_row.get_ID(),AD_Backup_ID, Object_Status,"AD_ImpFormat",get_IDWithColumn(ctx, "AD_Table", "TableName", "m_ImpFormat_row")); - throw new POSaveFailedException("ImpFormatRow"); + throw new POSaveFailedException("Failed to import Import Format Row."); } } diff --git a/base/src/org/adempiere/pipo/handler/MenuElementHandler.java b/base/src/org/adempiere/pipo/handler/MenuElementHandler.java index 9a23f4e911..0cbe0d8228 100644 --- a/base/src/org/adempiere/pipo/handler/MenuElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/MenuElementHandler.java @@ -128,8 +128,7 @@ public class MenuElementHandler extends AbstractElementHandler { .getValue("Action") : " "); if (action.compareTo(" ") > -1) m_Menu.setAction(action); - m_Menu.setDescription(atts.getValue("Description") - .replaceAll("'", "''").replaceAll(",", "")); + m_Menu.setDescription(getStringValue(atts, "Description")); m_Menu.setEntityType(atts.getValue("EntityType")); m_Menu.setIsReadOnly(Boolean.valueOf(atts.getValue("isReadOnly")) .booleanValue()); @@ -386,28 +385,23 @@ public class MenuElementHandler extends AbstractElementHandler { || rs.getInt("AD_WORKBENCH_ID") > 0) { // Call CreateWindow. if (rs.getInt("AD_WINDOW_ID") > 0) { - packOut.createWindow(rs.getInt("AD_WINDOW_ID"), atts, document); + packOut.createWindow(rs.getInt("AD_WINDOW_ID"), document); } // Call CreateProcess. else if (rs.getInt("AD_PROCESS_ID") > 0) { - packOut.createProcess(rs.getInt("AD_PROCESS_ID"), atts, document); + packOut.createProcess(rs.getInt("AD_PROCESS_ID"), document); } // Call CreateTask. else if (rs.getInt("AD_TASK_ID") > 0) { - packOut.createTask(rs.getInt("AD_TASK_ID"), atts, document); + packOut.createTask(rs.getInt("AD_TASK_ID"), document); } // Call CreateForm. else if (rs.getInt("AD_FORM_ID") > 0) { - packOut.createForm(rs.getInt("AD_FORM_ID"), atts, document); - } - // Call CreateWorkbench - else if (rs.getInt("AD_WORKBENCH_ID") > 0) { - packOut.createWorkbench(rs.getInt("AD_WORKBENCH_ID"), atts, - document); + packOut.createForm(rs.getInt("AD_FORM_ID"), document); } // Call CreateWorkflow else if (rs.getInt("AD_Workflow_ID") > 0) { - packOut.createWorkflow(rs.getInt("AD_Workflow_ID"), atts, + packOut.createWorkflow(rs.getInt("AD_Workflow_ID"), document); } // Call CreateModule because entry is a summary menu @@ -460,29 +454,24 @@ public class MenuElementHandler extends AbstractElementHandler { || rs.getInt("AD_WORKBENCH_ID") > 0) { // Call CreateWindow. if (rs.getInt("AD_WINDOW_ID") > 0) { - packOut.createWindow(rs.getInt("AD_WINDOW_ID"), atts, document); + packOut.createWindow(rs.getInt("AD_WINDOW_ID"), document); } // Call CreateProcess. else if (rs.getInt("AD_PROCESS_ID") > 0) { - packOut.createProcess(rs.getInt("AD_PROCESS_ID"), atts, + packOut.createProcess(rs.getInt("AD_PROCESS_ID"), document); } // Call CreateTask. else if (rs.getInt("AD_TASK_ID") > 0) { - packOut.createTask(rs.getInt("AD_TASK_ID"), atts, document); + packOut.createTask(rs.getInt("AD_TASK_ID"), document); } // Call CreateForm. else if (rs.getInt("AD_FORM_ID") > 0) { - packOut.createForm(rs.getInt("AD_FORM_ID"), atts, document); - } - // Call CreateWorkbench - else if (rs.getInt("AD_WORKBENCH_ID") > 0) { - packOut.createWorkbench(rs.getInt("AD_WORKBENCH_ID"), atts, - document); + packOut.createForm(rs.getInt("AD_FORM_ID"), document); } // Call CreateWorkflow else if (rs.getInt("AD_Workflow_ID") > 0) { - packOut.createWorkflow(rs.getInt("AD_Workflow_ID"), atts, + packOut.createWorkflow(rs.getInt("AD_Workflow_ID"), document); } // Call CreateModule because entry is a summary menu diff --git a/base/src/org/adempiere/pipo/handler/MessageElementHandler.java b/base/src/org/adempiere/pipo/handler/MessageElementHandler.java index 45488a7101..bbe4809866 100644 --- a/base/src/org/adempiere/pipo/handler/MessageElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/MessageElementHandler.java @@ -25,6 +25,7 @@ import javax.xml.transform.sax.TransformerHandler; import org.adempiere.pipo.AbstractElementHandler; import org.adempiere.pipo.Element; +import org.adempiere.pipo.exception.POSaveFailedException; import org.compiere.model.MMessage; import org.compiere.model.X_AD_Message; import org.compiere.model.X_AD_Package_Exp_Detail; @@ -56,8 +57,8 @@ public class MessageElementHandler extends AbstractElementHandler { Object_Status = "New"; AD_Backup_ID =0; } - m_Message.setMsgText(atts.getValue("MsgText").replaceAll("'","''")); - m_Message.setMsgTip(atts.getValue("MsgTip").replaceAll("'","''")); + m_Message.setMsgText(getStringValue(atts, "MsgText")); + m_Message.setMsgTip(getStringValue(atts, "MsgTip")); m_Message.setEntityType(atts.getValue("EntityType")); m_Message.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true); m_Message.setValue(value); @@ -67,6 +68,7 @@ public class MessageElementHandler extends AbstractElementHandler { } else{ record_log (ctx, 0, m_Message.getValue(),"Message", m_Message.get_ID(),AD_Backup_ID, Object_Status,"AD_Message",get_IDWithColumn(ctx, "AD_Message", "value", "AD_Message")); + throw new POSaveFailedException("Failed to save message."); } } else { element.skip = true; diff --git a/base/src/org/adempiere/pipo/handler/PreferenceElementHandler.java b/base/src/org/adempiere/pipo/handler/PreferenceElementHandler.java index a70e87a35c..d3f0c5dca1 100644 --- a/base/src/org/adempiere/pipo/handler/PreferenceElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/PreferenceElementHandler.java @@ -75,7 +75,7 @@ public class PreferenceElementHandler extends AbstractElementHandler { m_Preference.get_ID(), AD_Backup_ID, Object_Status, "AD_Preference", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Preference")); - throw new POSaveFailedException("Preference"); + throw new POSaveFailedException("Failed to save Preference"); } } diff --git a/base/src/org/adempiere/pipo/handler/PrintFormatElementHandler.java b/base/src/org/adempiere/pipo/handler/PrintFormatElementHandler.java index 4d108996e3..34b6360d39 100644 --- a/base/src/org/adempiere/pipo/handler/PrintFormatElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/PrintFormatElementHandler.java @@ -134,10 +134,9 @@ public class PrintFormatElementHandler extends AbstractElementHandler { m_PrintFormat.setAD_PrintPaper_ID(id); } - m_PrintFormat.setDescription(atts.getValue("Description").replaceAll( - "'", "''").replaceAll(",", "")); + m_PrintFormat.setDescription(getStringValue(atts, "Description")); m_PrintFormat.setName(atts.getValue("Name")); - m_PrintFormat.setPrinterName(atts.getValue("PrinterName")); + m_PrintFormat.setPrinterName(getStringValue(atts, "PrinterName")); m_PrintFormat.setFooterMargin(Integer.parseInt(atts .getValue("FooterMargin"))); @@ -167,7 +166,7 @@ public class PrintFormatElementHandler extends AbstractElementHandler { m_PrintFormat.get_ID(), AD_Backup_ID, Object_Status, "AD_PrintFormat", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_PrintFormat")); - throw new POSaveFailedException("PrintFormat"); + throw new POSaveFailedException("Failed to save Print Format"); } } diff --git a/base/src/org/adempiere/pipo/handler/PrintFormatItemElementHandler.java b/base/src/org/adempiere/pipo/handler/PrintFormatItemElementHandler.java index ffd0a8716f..87c387d7ec 100644 --- a/base/src/org/adempiere/pipo/handler/PrintFormatItemElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/PrintFormatItemElementHandler.java @@ -126,7 +126,7 @@ public class PrintFormatItemElementHandler extends AbstractElementHandler { m_PrintFormatItem.setAD_PrintFont_ID(id); } - m_PrintFormatItem.setPrintName(atts.getValue("PrintName")); + m_PrintFormatItem.setPrintName(getStringValue(atts, "PrintName")); m_PrintFormatItem.setName(atts.getValue("Name")); m_PrintFormatItem.setPrintAreaType(atts.getValue("PrintAreaType")); diff --git a/base/src/org/adempiere/pipo/handler/ProcessElementHandler.java b/base/src/org/adempiere/pipo/handler/ProcessElementHandler.java index aca685efe9..df388c7f52 100644 --- a/base/src/org/adempiere/pipo/handler/ProcessElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/ProcessElementHandler.java @@ -116,12 +116,10 @@ public class ProcessElementHandler extends AbstractElementHandler { } m_Process.setAccessLevel(atts.getValue("AccessLevel")); - m_Process.setClassname(atts.getValue("Classname")); - m_Process.setDescription(atts.getValue("Description").replaceAll( - "'", "''").replaceAll(",", "")); + m_Process.setClassname(getStringValue(atts, "Classname")); + m_Process.setDescription(getStringValue(atts, "Description")); m_Process.setEntityType(atts.getValue("EntityType")); - m_Process.setHelp(atts.getValue("Help").replaceAll("'", "''") - .replaceAll(",", "")); + m_Process.setHelp(getStringValue(atts, "Help")); m_Process.setIsBetaFunctionality(Boolean.valueOf( atts.getValue("isBetaFunctionality")).booleanValue()); m_Process.setIsDirectPrint(Boolean.valueOf( @@ -130,13 +128,15 @@ public class ProcessElementHandler extends AbstractElementHandler { .booleanValue()); m_Process.setName(atts.getValue("Name")); - m_Process.setProcedureName(atts.getValue("ProcedureName")); + 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", @@ -161,7 +161,7 @@ public class ProcessElementHandler extends AbstractElementHandler { throws SAXException { int AD_Process_ID = Env.getContextAsInt(ctx, "AD_Process_ID"); PackOut packOut = (PackOut) ctx.get("PackOutProcess"); - String sqlW = "SELECT * FROM AD_PROCESS WHERE AD_PROCESS_ID = " + String sqlW = "SELECT AD_Process_ID FROM AD_PROCESS WHERE AD_PROCESS_ID = " + AD_Process_ID; AttributesImpl atts = new AttributesImpl(); @@ -173,26 +173,23 @@ public class ProcessElementHandler extends AbstractElementHandler { X_AD_Process m_Process = new X_AD_Process(ctx, rs1 .getInt("AD_Process_ID"), null); log.log(Level.INFO, "AD_ReportView_ID: " - + rs1.getInt("AD_ReportView_ID")); + + m_Process.getAD_Process_ID()); - if (rs1.getString("IsReport").equals('Y') - && rs1.getInt("AD_ReportView_ID") > 0) { - - packOut.createReportview(rs1.getInt("AD_ReportView_ID"), - atts, document); - } - if (rs1.getString("IsReport").equals('Y') - && rs1.getInt("AD_PrintFormat_ID") > 0) { - - packOut.createPrintFormat(rs1.getInt("AD_PrintFormat_ID"), - atts, document); - } - if (rs1.getInt("AD_Workflow_ID") > 0) { - - packOut.createWorkflow(rs1.getInt("AD_Workflow_ID"), atts, + if (m_Process.isReport() && m_Process.getAD_ReportView_ID() > 0) { + packOut.createReportview(m_Process.getAD_ReportView_ID(), document); } - atts = createProcessBinding(atts, m_Process); + 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); + } + createProcessBinding(atts, m_Process); document.startElement("", "", "process", atts); // processpara tags String sqlP = "SELECT * FROM AD_PROCESS_PARA WHERE AD_PROCESS_ID = " @@ -204,10 +201,10 @@ public class ProcessElementHandler extends AbstractElementHandler { while (rsP.next()) { if (rsP.getInt("AD_Reference_ID") > 0) packOut.createReference(rsP - .getInt("AD_Reference_ID"), atts, document); + .getInt("AD_Reference_ID"), document); if (rsP.getInt("AD_Reference_Value_ID") > 0) packOut.createReference(rsP - .getInt("AD_Reference_Value_ID"), atts, + .getInt("AD_Reference_Value_ID"), document); createProcessPara(ctx, document, rsP @@ -325,6 +322,10 @@ public class ProcessElementHandler extends AbstractElementHandler { 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; } } diff --git a/base/src/org/adempiere/pipo/handler/ProcessParaElementHandler.java b/base/src/org/adempiere/pipo/handler/ProcessParaElementHandler.java index a25187a79f..77d308fa28 100644 --- a/base/src/org/adempiere/pipo/handler/ProcessParaElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/ProcessParaElementHandler.java @@ -136,21 +136,19 @@ public class ProcessParaElementHandler extends AbstractElementHandler { m_Process_para.setAD_Val_Rule_ID(id); } - m_Process_para.setDefaultValue(atts.getValue("DefaultValue")); - m_Process_para.setDefaultValue2(atts.getValue("DefaultValue2")); - m_Process_para.setDescription(atts.getValue("Description") - .replaceAll("'", "''").replaceAll(",", "")); + m_Process_para.setDefaultValue(getStringValue(atts, "DefaultValue")); + m_Process_para.setDefaultValue2(getStringValue(atts, "DefaultValue2")); + m_Process_para.setDescription(getStringValue(atts,"Description")); - m_Process_para.setHelp(atts.getValue("Help").replaceAll("'", "''") - .replaceAll(",", "")); + m_Process_para.setHelp(getStringValue(atts,"Help")); m_Process_para .setIsActive(atts.getValue("isActive") != null ? Boolean .valueOf(atts.getValue("isActive")).booleanValue() : true); - m_Process_para.setVFormat(atts.getValue("VFormat")); - m_Process_para.setValueMax(atts.getValue("ValueMax")); - m_Process_para.setValueMin(atts.getValue("ValueMin")); + m_Process_para.setVFormat(getStringValue(atts,"VFormat")); + m_Process_para.setValueMax(getStringValue(atts,"ValueMax")); + m_Process_para.setValueMin(getStringValue(atts,"ValueMin")); m_Process_para.setSeqNo(Integer.parseInt(atts.getValue("SeqNo"))); m_Process_para.setFieldLength(Integer.parseInt(atts .getValue("FieldLength"))); diff --git a/base/src/org/adempiere/pipo/handler/ReferenceElementHandler.java b/base/src/org/adempiere/pipo/handler/ReferenceElementHandler.java index e7d972b252..e938da02a0 100644 --- a/base/src/org/adempiere/pipo/handler/ReferenceElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/ReferenceElementHandler.java @@ -75,11 +75,9 @@ public class ReferenceElementHandler extends AbstractElementHandler { AD_Backup_ID = 0; } - m_Reference.setDescription(atts.getValue("Description").replaceAll( - "'", "''").replaceAll(",", "")); + m_Reference.setDescription(getStringValue(atts,"Description")); m_Reference.setEntityType(atts.getValue("EntityType")); - m_Reference.setHelp(atts.getValue("Help").replaceAll("'", "''") - .replaceAll(",", "")); + m_Reference.setHelp(getStringValue(atts,"Help")); m_Reference.setIsActive(atts.getValue("isActive") != null ? Boolean .valueOf(atts.getValue("isActive")).booleanValue() : true); m_Reference.setName(atts.getValue("name")); @@ -111,6 +109,11 @@ public class ReferenceElementHandler extends AbstractElementHandler { throws SAXException { int Reference_id = Env.getContextAsInt(ctx, X_AD_Reference.COLUMNNAME_AD_Reference_ID); + + if (references.contains(Reference_id)) + return; + + references.add(Reference_id); AttributesImpl atts = new AttributesImpl(); String sql = "SELECT * FROM AD_Reference WHERE AD_Reference_ID= " + Reference_id; diff --git a/base/src/org/adempiere/pipo/handler/ReferenceListElementHandler.java b/base/src/org/adempiere/pipo/handler/ReferenceListElementHandler.java index 5ffc368591..ea990fcdf0 100644 --- a/base/src/org/adempiere/pipo/handler/ReferenceListElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/ReferenceListElementHandler.java @@ -62,7 +62,7 @@ public class ReferenceListElementHandler extends AbstractElementHandler { } m_Ref_List.setAD_Reference_ID(AD_Reference_ID); - m_Ref_List.setDescription(atts.getValue("Description").replaceAll("'", "''")); + m_Ref_List.setDescription(getStringValue(atts,"Description")); m_Ref_List.setEntityType(atts.getValue("EntityType")); m_Ref_List.setName(atts.getValue("Name")); m_Ref_List.setValue(value); @@ -110,20 +110,26 @@ public class ReferenceListElementHandler extends AbstractElementHandler { sql = "SELECT Name FROM AD_Ref_List WHERE AD_Ref_List_ID=?"; name = DB.getSQLValueString(null, sql, m_Ref_List .getAD_Ref_List_ID()); - } - if (name != null) - atts.addAttribute("", "", "ADReflistNameID", "CDATA", name); - else + if (name != null) + atts.addAttribute("", "", "ADReflistNameID", "CDATA", name); + else + atts.addAttribute("", "", "ADReflistNameID", "CDATA", ""); + } else { atts.addAttribute("", "", "ADReflistNameID", "CDATA", ""); + } + if (m_Ref_List.getAD_Reference_ID() > 0) { sql = "SELECT Name FROM AD_Reference WHERE AD_Reference_ID=?"; name = DB.getSQLValueString(null, sql, m_Ref_List .getAD_Reference_ID()); - } - if (name != null) - atts.addAttribute("", "", "ADRefenceNameID", "CDATA", name); - else + if (name != null) + atts.addAttribute("", "", "ADRefenceNameID", "CDATA", name); + else + atts.addAttribute("", "", "ADRefenceNameID", "CDATA", ""); + } else { atts.addAttribute("", "", "ADRefenceNameID", "CDATA", ""); + } + atts.addAttribute("", "", "Description", "CDATA", (m_Ref_List .getDescription() != null ? m_Ref_List.getDescription() : "")); atts.addAttribute("", "", "EntityType", "CDATA", (m_Ref_List diff --git a/base/src/org/adempiere/pipo/handler/ReportViewColElementHandler.java b/base/src/org/adempiere/pipo/handler/ReportViewColElementHandler.java index 73b77c0e43..387ab94573 100644 --- a/base/src/org/adempiere/pipo/handler/ReportViewColElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/ReportViewColElementHandler.java @@ -42,10 +42,36 @@ public class ReportViewColElementHandler extends AbstractElementHandler { log.info(elementValue + " " + atts.getValue("ADReportViewColID")); String entitytype = atts.getValue("EntityType"); - String name = atts.getValue("ADReportViewColID"); - + if (isProcessElement(ctx, entitytype)) { - int id = get_ID(ctx, "AD_Reportview_Col", name); + String name = atts.getValue("ADReportviewNameID"); + int AD_ReportView_ID = get_IDWithColumn(ctx, "AD_ReportView", "Name", name); + if (AD_ReportView_ID <= 0) { + element.defer = true; + return; + } + + name = atts.getValue("ADColumnNameID"); + int AD_Column_ID = 0; + if (name != null && name.trim().length() > 0) { + AD_Column_ID = get_IDWithColumn(ctx, "AD_Column", "Name", name); + if (AD_Column_ID <= 0) { + element.defer = true; + return; + } + } + + String functionColumn = getStringValue(atts, "FunctionColumn"); + StringBuffer sql = new StringBuffer("SELECT AD_Reportview_Col_ID FROM AD_Reportview_Col ") + .append(" WHERE AD_Column_ID "); + if (AD_Column_ID > 0) + sql.append(" = " + AD_Column_ID); + else + sql.append(" IS NULL "); + sql.append(" AND FunctionColumn = ?"); + + int id = DB.getSQLValue(getTrxName(ctx), sql.toString(), functionColumn); + if (id < 0) id = 0; X_AD_ReportView_Col m_Reportview_Col = new X_AD_ReportView_Col(ctx, id, getTrxName(ctx)); if (id > 0) { @@ -56,31 +82,22 @@ public class ReportViewColElementHandler extends AbstractElementHandler { Object_Status = "New"; AD_Backup_ID = 0; } - name = atts.getValue("ADReportviewnameID"); - id = get_IDWithColumn(ctx, "AD_ReportView", "Name", name); - if (id <= 0) { - element.defer = true; - return; - } - m_Reportview_Col.setAD_ReportView_ID(id); + + boolean isGroupFunction = Boolean.valueOf( + atts.getValue("isGroupFunction")).booleanValue(); + + m_Reportview_Col.setAD_ReportView_ID(AD_ReportView_ID); - name = atts.getValue("ADColumnNameID"); - if (name != null && name.trim().length() > 0) { - id = get_IDWithColumn(ctx, "AD_Column", "Name", name); - if (id <= 0) { - element.defer = true; - return; - } + if (AD_Column_ID > 0) { m_Reportview_Col.setAD_Column_ID(id); } - m_Reportview_Col.setFunctionColumn(atts.getValue("ADColumnNameID")); + m_Reportview_Col.setFunctionColumn(functionColumn); m_Reportview_Col .setIsActive(atts.getValue("isActive") != null ? Boolean .valueOf(atts.getValue("isActive")).booleanValue() : true); - m_Reportview_Col.setIsGroupFunction(Boolean.valueOf( - atts.getValue("ADColumnNameID")).booleanValue()); + m_Reportview_Col.setIsGroupFunction(isGroupFunction); if (m_Reportview_Col.save(getTrxName(ctx)) == true) { record_log(ctx, 1, "" + m_Reportview_Col.getAD_ReportView_ID(), "Reportview_Col", m_Reportview_Col.get_ID(), @@ -129,20 +146,12 @@ public class ReportViewColElementHandler extends AbstractElementHandler { atts.addAttribute("", "", "ADColumnNameID", "CDATA", ""); if (m_Reportview_Col.getAD_ReportView_ID() > 0) { - sql = "SELECT Name FROM AD_Reference WHERE AD_Reportview_ID=?"; + sql = "SELECT Name FROM AD_Reportview WHERE AD_Reportview_ID=?"; name = DB.getSQLValueString(null, sql, m_Reportview_Col .getAD_ReportView_ID()); - atts.addAttribute("", "", "ADReportviewnameID", "CDATA", name); + atts.addAttribute("", "", "ADReportviewNameID", "CDATA", name); } else - atts.addAttribute("", "", "ADColumnNameID", "CDATA", ""); - - if (m_Reportview_Col.getAD_ReportView_Col_ID() > 0) { - sql = "SELECT Name FROM AD_Reference WHERE AD_ReportView_Col_ID=?"; - name = DB.getSQLValueString(null, sql, m_Reportview_Col - .getAD_ReportView_Col_ID()); - atts.addAttribute("", "", "ADReportViewColID", "CDATA", name); - } else - atts.addAttribute("", "", "ADColumnNameID", "CDATA", ""); + atts.addAttribute("", "", "ADReportviewNameID", "CDATA", ""); atts.addAttribute("", "", "FunctionColumn", "CDATA", (m_Reportview_Col .getFunctionColumn() != null ? m_Reportview_Col diff --git a/base/src/org/adempiere/pipo/handler/ReportViewElementHandler.java b/base/src/org/adempiere/pipo/handler/ReportViewElementHandler.java index 4ce2dcdf82..d3bea7e20c 100644 --- a/base/src/org/adempiere/pipo/handler/ReportViewElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/ReportViewElementHandler.java @@ -85,14 +85,13 @@ public class ReportViewElementHandler extends AbstractElementHandler { } m_Reportview.setAD_Table_ID(id); - m_Reportview.setDescription(atts.getValue("Description").replaceAll( - "'", "''").replaceAll(",", "")); + m_Reportview.setDescription(getStringValue(atts,"Description")); m_Reportview.setEntityType(atts.getValue("EntityType")); m_Reportview.setName(atts.getValue("Name")); m_Reportview.setIsActive(atts.getValue("isActive") != null ? Boolean .valueOf(atts.getValue("isActive")).booleanValue() : true); - m_Reportview.setOrderByClause(atts.getValue("OrderByClause")); - m_Reportview.setWhereClause(atts.getValue("WhereClause")); + m_Reportview.setOrderByClause(getStringValue(atts,"OrderByClause")); + m_Reportview.setWhereClause(getStringValue(atts,"WhereClause")); if (m_Reportview.save(getTrxName(ctx)) == true) { record_log(ctx, 1, m_Reportview.getName(), "Reportview", m_Reportview.get_ID(), AD_Backup_ID, Object_Status, @@ -136,10 +135,10 @@ public class ReportViewElementHandler extends AbstractElementHandler { ResultSet rs1 = pstmt1.executeQuery(); while (rs1.next()) { // Export Table if neccessary - packOut.createTable(rs1.getInt("AD_Table_ID"), atts, + packOut.createTable(rs1.getInt("AD_Table_ID"), document); packOut.createPrintFormat(rs1 - .getInt("AD_Printformat_ID"), atts, document); + .getInt("AD_Printformat_ID"), document); } rs1.close(); pstmt1.close(); diff --git a/base/src/org/adempiere/pipo/handler/RoleElementHandler.java b/base/src/org/adempiere/pipo/handler/RoleElementHandler.java index ade063396f..a14cebc93d 100644 --- a/base/src/org/adempiere/pipo/handler/RoleElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/RoleElementHandler.java @@ -115,9 +115,10 @@ public class RoleElementHandler extends AbstractElementHandler { m_Role.setC_Currency_ID(id); } - m_Role.setDescription(atts.getValue("Description") - .replaceAll("'", "''").replaceAll(",", "")); - m_Role.setAmtApproval(new BigDecimal(atts.getValue("AmtApproval"))); + m_Role.setDescription(getStringValue(atts,"Description")); + String amtApproval = getStringValue(atts,"AmtApproval"); + if (amtApproval != null) + m_Role.setAmtApproval(new BigDecimal(amtApproval)); m_Role.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf( atts.getValue("isActive")).booleanValue() : true); m_Role @@ -162,6 +163,17 @@ public class RoleElementHandler extends AbstractElementHandler { : true); m_Role.setPreferenceType(atts.getValue("PreferenceType")); m_Role.setUserLevel(atts.getValue("UserLevel")); + m_Role.setAllow_Info_Account(Boolean.valueOf(atts.getValue("AllowInfoAccount"))); + m_Role.setAllow_Info_Asset(Boolean.valueOf(atts.getValue("AllowInfoAsset"))); + m_Role.setAllow_Info_BPartner(Boolean.valueOf(atts.getValue("AllowInfoBPartner"))); + m_Role.setAllow_Info_CashJournal(Boolean.valueOf(atts.getValue("AllowInfoCashJournal"))); + m_Role.setAllow_Info_InOut(Boolean.valueOf(atts.getValue("AllowInfoInOut"))); + m_Role.setAllow_Info_Invoice(Boolean.valueOf(atts.getValue("AllowInfoInvoice"))); + m_Role.setAllow_Info_Order(Boolean.valueOf(atts.getValue("AllowInfoOrder"))); + m_Role.setAllow_Info_Payment(Boolean.valueOf(atts.getValue("AllowInfoPayment"))); + m_Role.setAllow_Info_Product(Boolean.valueOf(atts.getValue("AllowInfoProduct"))); + m_Role.setAllow_Info_Resource(Boolean.valueOf(atts.getValue("AllowInfoResource"))); + m_Role.setAllow_Info_Schedule(Boolean.valueOf(atts.getValue("AllowInfoSchedule"))); if (m_Role.save(getTrxName(ctx)) == true) { @@ -473,7 +485,19 @@ public class RoleElementHandler extends AbstractElementHandler { .getPreferenceType() : "")); atts.addAttribute("", "", "UserLevel", "CDATA", (m_Role.getUserLevel() != null ? m_Role.getUserLevel() : "")); - + + atts.addAttribute("", "", "AllowInfoAccount", "CDATA", Boolean.toString(m_Role.isAllow_Info_Account())); + atts.addAttribute("", "", "AllowInfoAsset", "CDATA", Boolean.toString(m_Role.isAllow_Info_Asset())); + atts.addAttribute("", "", "AllowInfoBPartner", "CDATA", Boolean.toString(m_Role.isAllow_Info_BPartner())); + atts.addAttribute("", "", "AllowInfoCashJournal", "CDATA", Boolean.toString(m_Role.isAllow_Info_CashJournal())); + atts.addAttribute("", "", "AllowInfoInOut", "CDATA", Boolean.toString(m_Role.isAllow_Info_InOut())); + atts.addAttribute("", "", "AllowInfoInvoice", "CDATA", Boolean.toString(m_Role.isAllow_Info_Invoice())); + atts.addAttribute("", "", "AllowInfoOrder", "CDATA", Boolean.toString(m_Role.isAllow_Info_Order())); + atts.addAttribute("", "", "AllowInfoPayment", "CDATA", Boolean.toString(m_Role.isAllow_Info_Payment())); + atts.addAttribute("", "", "AllowInfoProduct", "CDATA", Boolean.toString(m_Role.isAllow_Info_Product())); + atts.addAttribute("", "", "AllowInfoResource", "CDATA", Boolean.toString(m_Role.isAllow_Info_Resource())); + atts.addAttribute("", "", "AllowInfoSchedule", "CDATA", Boolean.toString(m_Role.isAllow_Info_Schedule())); + return atts; } } diff --git a/base/src/org/adempiere/pipo/handler/TabElementHandler.java b/base/src/org/adempiere/pipo/handler/TabElementHandler.java index 1eaba83cca..c3dad1e2da 100644 --- a/base/src/org/adempiere/pipo/handler/TabElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/TabElementHandler.java @@ -92,51 +92,51 @@ public class TabElementHandler extends AbstractElementHandler { sqlB = null; m_Tab.setName(name); id = 0; - if (atts.getValue("ADColumnSortYesNoNameID")!= null){ + if (getStringValue(atts,"ADColumnSortYesNoNameID")!= null){ name = atts.getValue("ADColumnSortYesNoNameID"); id = get_IDWithColumn(ctx, "AD_Column", "Name", name); m_Tab.setAD_ColumnSortYesNo_ID(id); } - if (atts.getValue("ADColumnSortOrderNameID")!= null){ + if (getStringValue(atts,"ADColumnSortOrderNameID")!= null){ name = atts.getValue("ADColumnSortOrderNameID"); id = get_IDWithColumn(ctx, "AD_Column", "Name", name); m_Tab.setAD_ColumnSortOrder_ID(id); } - if (atts.getValue("ADImageNameID")!= null){ + if (getStringValue(atts,"ADImageNameID")!= null){ name = atts.getValue("ADImageNameID"); id = get_IDWithColumn(ctx, "AD_Image", "Name", name); m_Tab.setAD_Image_ID(id); } - if (atts.getValue("ADProcessNameID")!= null){ + if (getStringValue(atts,"ADProcessNameID")!= null){ name = atts.getValue("ADProcessNameID"); id = get_IDWithColumn(ctx, "AD_Process", "Name", name); m_Tab.setAD_Process_ID(id); } - if (atts.getValue("ADTableNameID")!= null){ + if (getStringValue(atts,"ADTableNameID")!= null){ name = atts.getValue("ADTableNameID"); id = get_IDWithColumn(ctx, "AD_Table", "TableName", name); m_Tab.setAD_Table_ID(id); } - if (atts.getValue("ADColumnNameID")!= null){ + if (getStringValue(atts,"ADColumnNameID")!= null){ name = atts.getValue("ADColumnNameID"); id = get_IDWithMasterAndColumn (ctx, "AD_Column","Name", atts.getValue("ADColumnNameID"), "AD_Table", get_IDWithColumn(ctx,"AD_Table", "TableName", atts.getValue("ADTableNameID"))); m_Tab.setAD_Column_ID(id); } - if (atts.getValue("ADWindowNameID")!= null){ + if (getStringValue(atts,"ADWindowNameID")!= null){ name = atts.getValue("ADWindowNameID"); id = get_IDWithColumn(ctx, "AD_Window", "Name", name); m_Tab.setAD_Window_ID(id); } - if (atts.getValue("IncludedTabNameID")!= null){ + if (getStringValue(atts,"IncludedTabNameID")!= null){ name = atts.getValue("IncludedTabNameID"); id = get_IDWithColumn(ctx, "AD_Tab", "Name", name); m_Tab.setIncluded_Tab_ID(id); } m_Tab.setCommitWarning(atts.getValue("CommitWarning")); - m_Tab.setDescription(atts.getValue("Description").replaceAll("'","''")); + m_Tab.setDescription(getStringValue(atts,"Description")); m_Tab.setEntityType (atts.getValue("EntityType")); m_Tab.setHasTree(Boolean.valueOf(atts.getValue("isHasTree")).booleanValue()); - m_Tab.setHelp (atts.getValue("Help").replaceAll("'","''")); + m_Tab.setHelp (getStringValue(atts,"Help")); m_Tab.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true); m_Tab.setImportFields (atts.getValue("ImportFields")); m_Tab.setIsInfoTab (Boolean.valueOf(atts.getValue("isInfoTab")).booleanValue()); @@ -145,21 +145,21 @@ public class TabElementHandler extends AbstractElementHandler { m_Tab.setIsSortTab (Boolean.valueOf(atts.getValue("isSortTab")).booleanValue()); m_Tab.setIsTranslationTab (Boolean.valueOf(atts.getValue("IsTranslationTab")).booleanValue()); m_Tab.setName (atts.getValue("Name")); - m_Tab.setOrderByClause (atts.getValue("OrderByClause")); + m_Tab.setOrderByClause (getStringValue(atts,"OrderByClause")); m_Tab.setProcessing(false); m_Tab.setSeqNo (Integer.parseInt(atts.getValue("SeqNo"))); m_Tab.setTabLevel (Integer.parseInt(atts.getValue("TabLevel"))); - m_Tab.setWhereClause (atts.getValue("WhereClause")); - if (atts.getValue("ReadOnlyLogic") != null) { + m_Tab.setWhereClause (getStringValue(atts,"WhereClause")); + if (getStringValue(atts,"ReadOnlyLogic") != null) { m_Tab.setReadOnlyLogic(atts.getValue("ReadOnlyLogic")); } - if (atts.getValue("DisplayLogic") != null) { + if (getStringValue(atts,"DisplayLogic") != null) { m_Tab.setDisplayLogic(atts.getValue("DisplayLogic")); } - if (atts.getValue("isInsertRecord") != null) { + if (getStringValue(atts,"isInsertRecord") != null) { m_Tab.setIsInsertRecord(Boolean.valueOf(atts.getValue("isInsertRecord")).booleanValue()); } - if (atts.getValue("isAdvancedTab") != null) { + if (getStringValue(atts,"isAdvancedTab") != null) { m_Tab.setIsAdvancedTab(Boolean.valueOf(atts.getValue("isAdvancedTab")).booleanValue()); } if (m_Tab.save(getTrxName(ctx)) == true){ @@ -221,7 +221,7 @@ public class TabElementHandler extends AbstractElementHandler { if(m_Tab.getAD_Process_ID() > 0 ) { - packOut.createProcess(m_Tab.getAD_Process_ID(), atts, document); + packOut.createProcess(m_Tab.getAD_Process_ID(), document); } } diff --git a/base/src/org/adempiere/pipo/handler/TableElementHandler.java b/base/src/org/adempiere/pipo/handler/TableElementHandler.java index e9dd3737e4..102b85a816 100644 --- a/base/src/org/adempiere/pipo/handler/TableElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/TableElementHandler.java @@ -80,22 +80,23 @@ public class TableElementHandler extends AbstractElementHandler { String Name = atts.getValue("ADWindowNameID"); id = get_IDWithColumn(ctx, "AD_Window", "Name", Name); m_Table.setAD_Window_ID(id); - Name = atts.getValue("POWindowNameID"); + Name = getStringValue(atts,"POWindowNameID"); if (Name != null){ id = get_IDWithColumn(ctx, "AD_Window", "Name", Name); m_Table.setPO_Window_ID(id); } - else - Name = atts.getValue("ADValRuleNameID"); - id = get_IDWithColumn(ctx, "AD_Val_Rule", "Name", Name); - m_Table.setAD_Val_Rule_ID(id); + Name = getStringValue(atts,"ADValRuleNameID"); + if (Name != null) { + id = get_IDWithColumn(ctx, "AD_Val_Rule", "Name", Name); + m_Table.setAD_Val_Rule_ID(id); + } m_Table.setAccessLevel (atts.getValue("AccessLevel")); - m_Table.setDescription(atts.getValue("Description").replaceAll("'","''")); + m_Table.setDescription(getStringValue(atts,"Description")); m_Table.setEntityType(atts.getValue("EntityType")); - m_Table.setHelp(atts.getValue("Help").replaceAll("'","''")); + m_Table.setHelp(getStringValue(atts,"Help")); m_Table.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true); - m_Table.setImportTable(atts.getValue("ImportTable")); + m_Table.setImportTable(getStringValue(atts,"ImportTable")); m_Table.setIsChangeLog(Boolean.valueOf(atts.getValue("isChangeLog")).booleanValue()); m_Table.setIsDeleteable(Boolean.valueOf(atts.getValue("isDeleteable")).booleanValue()); m_Table.setIsHighVolume(Boolean.valueOf(atts.getValue("isHighVolume")).booleanValue()); @@ -103,10 +104,8 @@ public class TableElementHandler extends AbstractElementHandler { m_Table.setIsView(Boolean.valueOf(atts.getValue("isView")).booleanValue()); //m_Table.setLoadSeq(Integer.parseInt(atts.getValue("LoadSeq"))); m_Table.setName(atts.getValue("Name")); - m_Table.setReplicationType(atts.getValue("ReplicationType")); + m_Table.setReplicationType(getStringValue(atts,"ReplicationType")); m_Table.setTableName(atts.getValue("TableName")); -// log.info("in3"); - getDocumentAttributes(ctx).clear(); if (m_Table.save(getTrxName(ctx)) == true){ record_log (ctx, 1, m_Table.getName(),"Table", m_Table.get_ID(),AD_Backup_ID, Object_Status,"AD_Table",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Table")); tables.add(m_Table.getAD_Table_ID()); @@ -163,16 +162,16 @@ public class TableElementHandler extends AbstractElementHandler { while (rs1.next()){ if (rs1.getInt("AD_Reference_ID")>0) - packOut.createReference (rs1.getInt("AD_Reference_ID"), atts, document); + packOut.createReference (rs1.getInt("AD_Reference_ID"), document); if (rs1.getInt("AD_Reference_Value_ID")>0) - packOut.createReference (rs1.getInt("AD_Reference_Value_ID"), atts, document); + packOut.createReference (rs1.getInt("AD_Reference_Value_ID"), document); if (rs1.getInt("AD_Process_ID")>0) - packOut.createProcess (rs1.getInt("AD_Process_ID"), atts, document); + packOut.createProcess (rs1.getInt("AD_Process_ID"), document); if (rs1.getInt("AD_Val_Rule_ID")>0) - packOut.createDynamicRuleValidation (rs1.getInt("AD_Val_Rule_ID"), atts, document); + packOut.createDynamicRuleValidation (rs1.getInt("AD_Val_Rule_ID"), document); createColumn(ctx, document, rs1.getInt("AD_Column_ID")); } diff --git a/base/src/org/adempiere/pipo/handler/TaskAccessElementHandler.java b/base/src/org/adempiere/pipo/handler/TaskAccessElementHandler.java index 08bca89058..1b0f121db8 100644 --- a/base/src/org/adempiere/pipo/handler/TaskAccessElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/TaskAccessElementHandler.java @@ -40,13 +40,13 @@ public class TaskAccessElementHandler extends AbstractElementHandler { int taskid =0; StringBuffer sqlB = null; Attributes atts = element.attributes; - if (atts.getValue("rolename")!=null){ + if (getStringValue(atts,"rolename")!=null){ String name = atts.getValue("rolename"); sqlB = new StringBuffer ("SELECT AD_Role_ID FROM AD_Role WHERE Name= ?"); roleid = DB.getSQLValue(getTrxName(ctx),sqlB.toString(),name); } - if (atts.getValue("taskname")!=null){ + if (getStringValue(atts,"taskname")!=null){ String name = atts.getValue("taskname"); sqlB = new StringBuffer ("SELECT AD_Task_ID FROM AD_Task WHERE Name= ?"); taskid = DB.getSQLValue(getTrxName(ctx),sqlB.toString(),name); diff --git a/base/src/org/adempiere/pipo/handler/TaskElementHandler.java b/base/src/org/adempiere/pipo/handler/TaskElementHandler.java index b6acaa993a..144331f40e 100644 --- a/base/src/org/adempiere/pipo/handler/TaskElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/TaskElementHandler.java @@ -53,15 +53,13 @@ public class TaskElementHandler extends AbstractElementHandler { AD_Backup_ID = 0; } m_Task.setAccessLevel(atts.getValue("AccessLevel")); - m_Task.setDescription(atts.getValue("Description").replaceAll("'", - "''").replaceAll(",", "")); + m_Task.setDescription(getStringValue(atts,"Description")); m_Task.setEntityType(atts.getValue("EntityType")); - m_Task.setHelp(atts.getValue("Help").replaceAll("'", "''") - .replaceAll(",", "")); + m_Task.setHelp(getStringValue(atts,"Help")); m_Task.setIsActive(atts.getValue("isActive") != null ? Boolean .valueOf(atts.getValue("isActive")).booleanValue() : true); m_Task.setName(name); - m_Task.setOS_Command(atts.getValue("OS_Command")); + m_Task.setOS_Command(getStringValue(atts,"OS_Command")); if (m_Task.save(getTrxName(ctx)) == true) { record_log(ctx, 1, m_Task.getName(), "Task", m_Task.get_ID(), AD_Backup_ID, Object_Status, "AD_Task", @@ -101,11 +99,14 @@ public class TaskElementHandler extends AbstractElementHandler { if (m_Task.getAD_Task_ID() > 0) { sql = "SELECT Name FROM AD_Task WHERE AD_Task_ID=?"; name = DB.getSQLValueString(null, sql, m_Task.getAD_Task_ID()); - } - if (name != null) - atts.addAttribute("", "", "ADTaskNameID", "CDATA", name); - else + if (name != null) + atts.addAttribute("", "", "ADTaskNameID", "CDATA", name); + else + atts.addAttribute("", "", "ADTaskNameID", "CDATA", ""); + } else { atts.addAttribute("", "", "ADTaskNameID", "CDATA", ""); + } + atts.addAttribute("", "", "AccessLevel", "CDATA", (m_Task .getAccessLevel() != null ? m_Task.getAccessLevel() : "")); atts.addAttribute("", "", "Description", "CDATA", (m_Task diff --git a/base/src/org/adempiere/pipo/handler/WindowElementHandler.java b/base/src/org/adempiere/pipo/handler/WindowElementHandler.java index ff039b0a5c..97e2b5a5b8 100644 --- a/base/src/org/adempiere/pipo/handler/WindowElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/WindowElementHandler.java @@ -99,11 +99,9 @@ public class WindowElementHandler extends AbstractElementHandler { m_Window.setAD_Color_ID(id); } - m_Window.setDescription(atts.getValue("Description").replaceAll( - "'", "''").replaceAll(",", "")); + m_Window.setDescription(getStringValue(atts,"Description")); m_Window.setEntityType(atts.getValue("EntityType")); - m_Window.setHelp(atts.getValue("Help").replaceAll("'", "''") - .replaceAll(",", "")); + m_Window.setHelp(getStringValue(atts,"Help")); m_Window.setIsActive(atts.getValue("isActive") != null ? Boolean .valueOf(atts.getValue("isActive")).booleanValue() : true); m_Window.setIsBetaFunctionality(Boolean.valueOf( @@ -162,7 +160,7 @@ public class WindowElementHandler extends AbstractElementHandler { String name = rs.getString("NAME"); String tablename = DB.getSQLValueString(null, tableSql, table_id); - packOut.createTable(rs.getInt("AD_Table_ID"), atts, document); + packOut.createTable(rs.getInt("AD_Table_ID"), document); createTab(ctx, document, rs.getInt("AD_Tab_ID")); } rs.close(); diff --git a/base/src/org/adempiere/pipo/handler/WorkbenchElementHandler.java b/base/src/org/adempiere/pipo/handler/WorkbenchElementHandler.java deleted file mode 100644 index f893150283..0000000000 --- a/base/src/org/adempiere/pipo/handler/WorkbenchElementHandler.java +++ /dev/null @@ -1,204 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * - * Copyright (C) 2005 Robert Klein. robeklein@hotmail.com - * Contributor(s): Low Heng Sin hengsin@avantz.com - *****************************************************************************/ -package org.adempiere.pipo.handler; - -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.util.Properties; -import java.util.logging.Level; - -import javax.xml.transform.sax.TransformerHandler; - -import org.adempiere.pipo.AbstractElementHandler; -import org.adempiere.pipo.Element; -import org.compiere.model.X_AD_Package_Exp_Detail; -import org.compiere.model.X_AD_Workbench; -import org.compiere.model.X_AD_WorkbenchWindow; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.AttributesImpl; - -public class WorkbenchElementHandler extends AbstractElementHandler { - - public void startElement(Properties ctx, Element element) throws SAXException { - String elementValue = element.getElementValue(); - int AD_Backup_ID = -1; - String Object_Status = null; - Attributes atts = element.attributes; - log.info(elementValue+" "+atts.getValue("ADWorkbenchNameID")); - String entitytype = atts.getValue("EntityType"); - String name = atts.getValue("ADWorkbenchNameID"); - if (isProcessElement(ctx, entitytype)) { - int id = get_ID(ctx, "AD_Workbench", name); - X_AD_Workbench m_Workbench = new X_AD_Workbench(ctx, id, getTrxName(ctx)); - if (id > 0){ - AD_Backup_ID = copyRecord(ctx, "AD_Workbench",m_Workbench); - Object_Status = "Update"; - } - else{ - Object_Status = "New"; - AD_Backup_ID =0; - } - - int tableid = get_IDWithColumn(ctx, "AD_Table", "TableName", atts.getValue("ADTableNameID")); - int columnid = get_IDWithMasterAndColumn (ctx, "AD_Column","ColumnName", atts.getValue("ADColumnNameID"), "AD_Table", tableid); - m_Workbench.setAD_Column_ID(columnid); - m_Workbench.setDescription(atts.getValue("Description").replaceAll("'","''")); - m_Workbench.setEntityType(atts.getValue("EntityType")); - m_Workbench.setHelp(atts.getValue("Help").replaceAll("'","''")); - m_Workbench.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true); - m_Workbench.setName(atts.getValue("Name")); - //m_Workbench.setPA_Goal_ID(Integer.parseInt(atts.getValue("PAGoalID"))); - if (m_Workbench.save(getTrxName(ctx)) == true){ - record_log (ctx, 1, m_Workbench.getName(),"Workbench", m_Workbench.get_ID(),AD_Backup_ID, Object_Status,"AD_Workbench",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Workbench")); - } - else{ - record_log (ctx, 0, m_Workbench.getName(),"Workbench", m_Workbench.get_ID(),AD_Backup_ID, Object_Status,"AD_Workbench",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Workbench")); - } - } else { - element.skip = true; - } - } - - public void endElement(Properties ctx, Element element) throws SAXException { - } - - public void create(Properties ctx, TransformerHandler document) - throws SAXException { - int AD_Workbench_ID = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Workbench_ID); - X_AD_Workbench m_Workbench = new X_AD_Workbench (ctx, AD_Workbench_ID, null); - AttributesImpl atts = new AttributesImpl(); - createWorkbenchBinding(atts,m_Workbench); - document.startElement("","","workbench",atts); - //Workbenchwindow tags - String sqlP = "SELECT * FROM AD_WorkbenchWindow WHERE AD_WORKBENCH_ID = " + AD_Workbench_ID; - PreparedStatement pstmtP = null; - pstmtP = DB.prepareStatement (sqlP, getTrxName(ctx)); - try { - ResultSet rsP = pstmtP.executeQuery(); - while (rsP.next()) - { - X_AD_WorkbenchWindow m_Workbenchwindow = new X_AD_WorkbenchWindow (ctx, rsP.getInt("AD_Workbench_Window_ID"), null); - atts = createWorkbenchWindowBinding(atts,m_Workbenchwindow); - document.startElement("","","workbenchwindow",atts); - document.endElement("","","workbenchwindow"); - } - rsP.close(); - pstmtP.close(); - pstmtP = null; - } - catch (Exception e) - { - log.log(Level.SEVERE,"getWorkbench_Window", e); - } - finally - { - try { - if (pstmtP != null) - pstmtP.close (); - } - catch (Exception e) - {} - pstmtP = null; - } - document.endElement("","","workbench"); - - } - - private AttributesImpl createWorkbenchBinding( AttributesImpl atts, X_AD_Workbench m_Workbench) - { - String sql = null; - String name = null; - atts.clear(); - if (m_Workbench.getAD_Workbench_ID()> 0 ){ - sql = "SELECT Name FROM AD_Workbench WHERE AD_Workbench_ID=?"; - name = DB.getSQLValueString(null,sql,m_Workbench.getAD_Workbench_ID()); - } - if (name != null ) - atts.addAttribute("","","ADWorkbenchNameID","CDATA",name); - else - atts.addAttribute("","","ADWorkbenchNameID","CDATA",""); - if (m_Workbench.getAD_Column_ID()> 0 ){ - sql = "SELECT ColumnName FROM AD_Column WHERE AD_Column_ID=?"; - name = DB.getSQLValueString(null,sql,m_Workbench.getAD_Column_ID()); - } - if (name != null ) - atts.addAttribute("","","ADColumnNameID","CDATA",name); - else - atts.addAttribute("","","ADColumnNameID","CDATA",""); - atts.addAttribute("","","Description","CDATA",(m_Workbench.getDescription () != null ? m_Workbench.getDescription ():"")); - atts.addAttribute("","","EntityType","CDATA",(m_Workbench.getEntityType () != null ? m_Workbench.getEntityType ():"")); - atts.addAttribute("","","Help","CDATA",(m_Workbench.getHelp () != null ? m_Workbench.getHelp ():"")); - atts.addAttribute("","","isActive","CDATA",(m_Workbench.isActive()== true ? "true":"false")); - atts.addAttribute("","","Name","CDATA",(m_Workbench.getName () != null ? m_Workbench.getName ():"")); - //atts.addAttribute("","","PA_Goal_ID","CDATA",(m_Workbench.getPA_Goal_ID() > 0 ? "" + m_Workbench.getPA_Goal_ID ():"")); - return atts; - } - - private AttributesImpl createWorkbenchWindowBinding( AttributesImpl atts, X_AD_WorkbenchWindow m_Workbenchwindow) - { - String sql = null; - String name = null; - atts.clear(); - if (m_Workbenchwindow.getAD_Process_ID()> 0 ){ - sql = "SELECT Name FROM AD_Process WHERE AD_Process_ID=?"; - name = DB.getSQLValueString(null,sql,m_Workbenchwindow.getAD_Process_ID()); - atts.addAttribute("","","name","CDATA",name); - } - else - atts.addAttribute("","","name","CDATA",""); - if (m_Workbenchwindow.getAD_Workbench_ID()> 0 ){ - sql = "SELECT Name FROM AD_Workbench WHERE AD_Workbench_ID=?"; - name = DB.getSQLValueString(null,sql,m_Workbenchwindow.getAD_Workbench_ID()); - } - if (name != null ) - atts.addAttribute("","","ADWorkbenchNameID","CDATA",name); - else - atts.addAttribute("","","ADWorkbenchNameID","CDATA",""); - if (m_Workbenchwindow.getAD_Form_ID()> 0 ){ - sql = "SELECT Name FROM AD_Form WHERE AD_Form_ID=?"; - name = DB.getSQLValueString(null,sql,m_Workbenchwindow.getAD_Form_ID()); - } - if (name != null ) - atts.addAttribute("","","ADFormNameID","CDATA",name); - else - atts.addAttribute("","","ADFormNameID","CDATA",""); - if (m_Workbenchwindow.getAD_Window_ID()> 0 ){ - sql = "SELECT Name FROM AD_Window WHERE AD_Window_ID=?"; - name = DB.getSQLValueString(null,sql,m_Workbenchwindow.getAD_Window_ID()); - } - if (name != null ) - atts.addAttribute("","","ADWindowNameID","CDATA",name); - else - atts.addAttribute("","","ADWindowNameID","CDATA",""); - if (m_Workbenchwindow.getAD_Task_ID()> 0 ){ - sql = "SELECT Name FROM AD_Task WHERE AD_Task_ID=?"; - name = DB.getSQLValueString(null,sql,m_Workbenchwindow.getAD_Task_ID()); - } - if (name != null ) - atts.addAttribute("","","ADTaskNameID","CDATA",name); - else - atts.addAttribute("","","ADTaskNameID","CDATA",""); - atts.addAttribute("","","EntityType","CDATA",(m_Workbenchwindow.getEntityType () != null ? m_Workbenchwindow.getEntityType ():"")); - atts.addAttribute("","","SeqNo","CDATA",(m_Workbenchwindow.getSeqNo () > 0 ? "" + m_Workbenchwindow.getSeqNo ():"")); - atts.addAttribute("","","isActive","CDATA",(m_Workbenchwindow.isActive()== true ? "true":"false")); - atts.addAttribute("","","isPrimary","CDATA",(m_Workbenchwindow.isPrimary()== true ? "true":"false")); - return atts; - } -} diff --git a/base/src/org/adempiere/pipo/handler/WorkflowAccessElementHandler.java b/base/src/org/adempiere/pipo/handler/WorkflowAccessElementHandler.java index bdfa237964..9ce6572192 100644 --- a/base/src/org/adempiere/pipo/handler/WorkflowAccessElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/WorkflowAccessElementHandler.java @@ -40,13 +40,13 @@ public class WorkflowAccessElementHandler extends AbstractElementHandler { int workflowid =0; StringBuffer sqlB = null; Attributes atts = element.attributes; - if (atts.getValue("rolename")!=null){ + if (getStringValue(atts,"rolename")!=null){ String name = atts.getValue("rolename"); sqlB = new StringBuffer ("SELECT AD_Role_ID FROM AD_Role WHERE Name= ?"); roleid = DB.getSQLValue(getTrxName(ctx),sqlB.toString(),name); } - if (atts.getValue("workflowname")!=null){ + if (getStringValue(atts,"workflowname")!=null){ String name = atts.getValue("workflowname"); sqlB = new StringBuffer ("SELECT AD_Workflow_ID FROM AD_Workflow WHERE Name= ?"); workflowid = DB.getSQLValue(getTrxName(ctx),sqlB.toString(),name); diff --git a/base/src/org/adempiere/pipo/handler/WorkflowElementHandler.java b/base/src/org/adempiere/pipo/handler/WorkflowElementHandler.java index 632bd86a90..3d9069f16a 100644 --- a/base/src/org/adempiere/pipo/handler/WorkflowElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/WorkflowElementHandler.java @@ -115,30 +115,32 @@ public class WorkflowElementHandler extends AbstractElementHandler { } 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.setDescription(getStringValue(atts,"Description")); + m_Workflow.setHelp(getStringValue(atts,"Help")); + m_Workflow.setDurationUnit(getStringValue(atts,"DurationUnit")); + m_Workflow.setAuthor(getStringValue(atts,"Author")); + if(getStringValue(atts, "Version") != null) + m_Workflow.setVersion(Integer.valueOf(atts.getValue("Version"))); + if(getStringValue(atts, "Priority") != null) + m_Workflow.setPriority(Integer.valueOf(atts.getValue("Priority"))); + if(getStringValue(atts, "Limit") != null) + m_Workflow.setLimit(Integer.valueOf(atts.getValue("Limit"))); + if(getStringValue(atts, "Duration") != null) + m_Workflow.setDuration(Integer.valueOf(atts.getValue("Duration"))); + if(getStringValue(atts, "Cost") != null) + 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.setDocValueLogic(getStringValue(atts,"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"); - getDocumentAttributes(ctx).clear(); log.info("about to execute m_Workflow.save"); if (m_Workflow.save(getTrxName(ctx)) == true) { log.info("m_Workflow save success"); @@ -168,6 +170,10 @@ public class WorkflowElementHandler extends AbstractElementHandler { 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; @@ -184,10 +190,10 @@ public class WorkflowElementHandler extends AbstractElementHandler { while (rs.next()) { X_AD_Workflow m_Workflow = new X_AD_Workflow(ctx, AD_Workflow_ID, null); - X_AD_WF_Node m_WF_Node = null; + createWorkflowBinding(atts, m_Workflow); document.startElement("", "", "workflow", atts); - String sql1 = "SELECT * FROM AD_WF_Node WHERE AD_Workflow_ID = " + String sql1 = "SELECT AD_WF_Node_ID FROM AD_WF_Node WHERE AD_Workflow_ID = " + AD_Workflow_ID; PreparedStatement pstmt1 = null; @@ -204,8 +210,7 @@ public class WorkflowElementHandler extends AbstractElementHandler { 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()); + ad_wf_nodenext_id = DB.getSQLValue(null, sql, nodeId); if (ad_wf_nodenext_id > 0) { createNodeNext(ctx, document, ad_wf_nodenext_id); @@ -213,7 +218,7 @@ public class WorkflowElementHandler extends AbstractElementHandler { 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()); + sql, nodeId); log .info("ad_wf_nodenextcondition_id: " + String diff --git a/base/src/org/adempiere/pipo/handler/WorkflowNodeElementHandler.java b/base/src/org/adempiere/pipo/handler/WorkflowNodeElementHandler.java index b8422f078f..abfde451c5 100644 --- a/base/src/org/adempiere/pipo/handler/WorkflowNodeElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/WorkflowNodeElementHandler.java @@ -169,37 +169,38 @@ public class WorkflowNodeElementHandler extends AbstractElementHandler { * 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.setAction(getStringValue(atts,"Action")); + m_WFNode.setDocAction(getStringValue(atts, "DocAction")); + m_WFNode.setDescription(getStringValue(atts,"Description")); 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"))); + if (getStringValue(atts, "XPosition") != null) + m_WFNode.setXPosition(Integer.valueOf(atts.getValue("XPosition"))); + if (getStringValue(atts, "YPosition") != null) + m_WFNode.setYPosition(Integer.valueOf(atts.getValue("YPosition"))); m_WFNode.setWaitingTime(Integer.valueOf(atts .getValue("WaitingTime"))); - m_WFNode.setWaitTime(Integer.valueOf(atts.getValue("WaitTime"))); + if (getStringValue(atts, "WaitTime") != null) + 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"))); - String startMode = atts.getValue("StartMode"); - m_WFNode.setStartMode(("".equals(startMode) ? null : startMode)); - String subFlowExecution = atts.getValue("SubflowExecution"); - m_WFNode.setSubflowExecution(("".equals(subFlowExecution) ? null : subFlowExecution)); + if (getStringValue(atts, "Cost") != null) + m_WFNode.setCost(new BigDecimal(atts.getValue("Cost"))); + if (getStringValue(atts, "Duration") != null) + m_WFNode.setDuration(Integer.valueOf(atts.getValue("Duration"))); + if (getStringValue(atts, "Priority") != null) + m_WFNode.setPriority(Integer.valueOf(atts.getValue("Priority"))); + m_WFNode.setStartMode(getStringValue(atts, "StartMode")); + m_WFNode.setSubflowExecution(getStringValue(atts,"SubflowExecution")); m_WFNode.setIsCentrallyMaintained(Boolean.valueOf( atts.getValue("IsCentrallyMaintained")).booleanValue()); - m_WFNode.setDynPriorityChange(new BigDecimal(atts + if (getStringValue(atts,"DynPriorityChange") != null) + m_WFNode.setDynPriorityChange(new BigDecimal(atts .getValue("DynPriorityChange"))); // m_WFNode.setAccessLevel (atts.getValue("AccessLevel")); - String dynPriorityUnit = atts.getValue("DynPriorityUnit"); - m_WFNode.setDynPriorityUnit (("".equals(dynPriorityUnit) ? null : dynPriorityUnit)); + m_WFNode.setDynPriorityUnit (getStringValue(atts,"DynPriorityUnit")); m_WFNode.setIsActive(atts.getValue("isActive") != null ? Boolean .valueOf(atts.getValue("isActive")).booleanValue() : true); - // log.info("in3"); - getDocumentAttributes(ctx).clear(); log.info("about to execute m_WFNode.save"); if (m_WFNode.save(getTrxName(ctx)) == true) { log.info("m_WFNode save success"); diff --git a/base/src/org/adempiere/pipo/handler/WorkflowNodeNextConditionElementHandler.java b/base/src/org/adempiere/pipo/handler/WorkflowNodeNextConditionElementHandler.java index 938095647e..0dc2a14684 100644 --- a/base/src/org/adempiere/pipo/handler/WorkflowNodeNextConditionElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/WorkflowNodeNextConditionElementHandler.java @@ -123,7 +123,7 @@ public class WorkflowNodeNextConditionElementHandler extends m_WFNodeNextCondition.setOperation(atts.getValue("Operation")); m_WFNodeNextCondition.setValue(atts.getValue("Value")); m_WFNodeNextCondition.setValue2(atts.getValue("Value2")); - getDocumentAttributes(ctx).clear(); + log.info("about to execute m_WFNodeNextCondition.save"); if (m_WFNodeNextCondition.save(getTrxName(ctx)) == true) { log.info("m_WFNodeNextCondition save success"); diff --git a/base/src/org/adempiere/pipo/handler/WorkflowNodeNextElementHandler.java b/base/src/org/adempiere/pipo/handler/WorkflowNodeNextElementHandler.java index 24d1541443..5003366c8c 100644 --- a/base/src/org/adempiere/pipo/handler/WorkflowNodeNextElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/WorkflowNodeNextElementHandler.java @@ -93,8 +93,6 @@ public class WorkflowNodeNextElementHandler extends AbstractElementHandler { 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)); - getDocumentAttributes(ctx).clear(); log.info("about to execute m_WFNodeNext.save"); if (m_WFNodeNext.save(getTrxName(ctx)) == true){ log.info("m_WFNodeNext save success");