1 17 18 package org.openbravo.erpCommon.ad_process; 19 20 import org.openbravo.erpCommon.ad_actionButton.*; 21 import org.openbravo.erpCommon.utility.Utility; 22 import org.openbravo.erpCommon.utility.ComboTableData; 23 import org.openbravo.utils.FormatUtilities; 24 import org.openbravo.base.secureApp.HttpSecureAppServlet; 25 import org.openbravo.base.secureApp.VariablesSecureApp; 26 import org.openbravo.xmlEngine.XmlDocument; 27 import java.io.*; 28 import javax.servlet.*; 29 import javax.servlet.http.*; 30 31 32 public class ImportAccountServlet extends HttpSecureAppServlet { 33 34 35 public void init (ServletConfig config) { 36 super.init(config); 37 boolHist = false; 38 } 39 40 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 41 VariablesSecureApp vars = new VariablesSecureApp(request); 42 43 if (!Utility.hasProcessAccess(this, vars, "", "ImportAccount")) { 44 bdError(response, "AccessTableNoView", vars.getLanguage()); 45 return; 46 } 47 String process = ImportData.processId(this, "ImportAccount"); 48 String strTabId = vars.getGlobalVariable("inpTabId", "ImportAccountServlet|tabId"); 49 String strWindowId = vars.getGlobalVariable("inpwindowId", "ImportAccountServlet|windowId"); 50 String strDeleteOld = vars.getStringParameter("inpDeleteOld", "Y"); 51 String strCElementId = vars.getStringParameter("inpElementId", ""); 52 String strUpdateDefault = vars.getStringParameter("inpUpdateDefault", "Y"); 53 String strCreateNewCombination = vars.getStringParameter("inpCreateNewCombination", "Y"); 54 if (vars.commandIn("DEFAULT")) { 55 printPage(response, vars, process, strWindowId, strTabId, strDeleteOld, strCElementId, strUpdateDefault, strCreateNewCombination); 56 } else if (vars.commandIn("SAVE")) { 57 ActionButtonDefaultData[] tab = ActionButtonDefaultData.windowName(this, strTabId); 58 String strWindowPath=""; 59 String strTabName=""; 60 if (tab!=null && tab.length!=0) { 61 strTabName = FormatUtilities.replace(tab[0].name); 62 if (tab[0].help.equals("Y")) strWindowPath="../utility/WindowTree_FS.html?inpTabId=" + strTabId; 63 else strWindowPath = "../" + FormatUtilities.replace(tab[0].description) + "/" + strTabName + "_Relation.html"; 64 } else strWindowPath = strDefaultServlet; 65 66 ImportAccount acc = new ImportAccount(this, process, strDeleteOld.equals("Y"), strCElementId, strUpdateDefault.equals("Y"), strCreateNewCombination.equals("Y")); 67 acc.startProcess(vars); 68 String strMessage = acc.getLog(); 69 if (!strMessage.equals("")) vars.setSessionValue(strWindowId + "|" + strTabName + ".message", strMessage); 70 printPageClosePopUp(response, vars, strWindowPath); 71 } else pageErrorPopUp(response); 72 } 73 74 75 void printPage(HttpServletResponse response, VariablesSecureApp vars, String strProcessId, String strWindowId, String strTabId, String strDeleteOld, String strCElementId, String strUpdateDefault, String strCreateNewCombination) throws IOException, ServletException { 76 if (log4j.isDebugEnabled()) log4j.debug("Output: process ImportAccountServlet"); 77 ActionButtonDefaultData[] data = null; 78 String strHelp="", strDescription=""; 79 if (vars.getLanguage().equals("en_US")) data = ActionButtonDefaultData.select(this, strProcessId); 80 else data = ActionButtonDefaultData.selectLanguage(this, vars.getLanguage(), strProcessId); 81 if (data!=null && data.length!=0) { 82 strDescription = data[0].description; 83 strHelp = data[0].help; 84 } 85 String [] discard = {""}; 86 if (strHelp.equals("")) discard[0] = new String ("helpDiscard"); 87 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_process/ImportAccountServlet").createXmlDocument(); 88 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 89 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 90 xmlDocument.setParameter("question", Utility.messageBD(this, "StartProcess?", vars.getLanguage())); 91 xmlDocument.setParameter("description", strDescription); 92 xmlDocument.setParameter("help", strHelp); 93 xmlDocument.setParameter("windowId", strWindowId); 94 xmlDocument.setParameter("tabId", strTabId); 95 xmlDocument.setParameter("deleteOld", strDeleteOld); 96 xmlDocument.setParameter("updateDefault", strUpdateDefault); 97 xmlDocument.setParameter("createNewCombination", strCreateNewCombination); 98 99 try { 100 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "C_Element_ID", "", "", Utility.getContext(this, vars, "#User_Org", strWindowId), Utility.getContext(this, vars, "#User_Client", strWindowId), 0); 101 Utility.fillSQLParameters(this, vars, null, comboTableData, strWindowId, ""); 102 xmlDocument.setData("reportC_ELEMENT","liststructure", comboTableData.select(false)); 103 comboTableData = null; 104 } catch (Exception ex) { 105 throw new ServletException(ex); 106 } 107 108 109 response.setContentType("text/html; charset=UTF-8"); 110 PrintWriter out = response.getWriter(); 111 out.println(xmlDocument.print()); 112 out.close(); 113 } 114 115 public String getServletInfo() { 116 return "Servlet ImportAccountServlet"; 117 } } 119 120 | Popular Tags |