KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > erpCommon > ad_process > ImportAccountServlet


1 /*
2  ******************************************************************************
3  * The contents of this file are subject to the Compiere License Version 1.1
4  * ("License"); You may not use this file except in compliance with the License
5  * You may obtain a copy of the License at http://www.compiere.org/license.html
6  * Software distributed under the License is distributed on an "AS IS" basis,
7  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
8  * the specific language governing rights and limitations under the License.
9  * The Original Code is Compiere ERP & CRM Business Solution
10  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
11  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
12  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
13  * Contributor(s): Openbravo SL
14  * Contributions are Copyright (C) 2001-2006 Openbravo S.L.
15  ******************************************************************************
16 */

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 JavaDoc process = ImportData.processId(this, "ImportAccount");
48         String JavaDoc strTabId = vars.getGlobalVariable("inpTabId", "ImportAccountServlet|tabId");
49         String JavaDoc strWindowId = vars.getGlobalVariable("inpwindowId", "ImportAccountServlet|windowId");
50         String JavaDoc strDeleteOld = vars.getStringParameter("inpDeleteOld", "Y");
51         String JavaDoc strCElementId = vars.getStringParameter("inpElementId", "");
52         String JavaDoc strUpdateDefault = vars.getStringParameter("inpUpdateDefault", "Y");
53         String JavaDoc 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 JavaDoc strWindowPath="";
59       String JavaDoc 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 JavaDoc 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 JavaDoc strProcessId, String JavaDoc strWindowId, String JavaDoc strTabId, String JavaDoc strDeleteOld, String JavaDoc strCElementId, String JavaDoc strUpdateDefault, String JavaDoc strCreateNewCombination) throws IOException, ServletException {
76       if (log4j.isDebugEnabled()) log4j.debug("Output: process ImportAccountServlet");
77       ActionButtonDefaultData[] data = null;
78       String JavaDoc 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 JavaDoc[] discard = {""};
86       if (strHelp.equals("")) discard[0] = new String JavaDoc("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 JavaDoc 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 JavaDoc getServletInfo() {
116     return "Servlet ImportAccountServlet";
117   } // end of getServletInfo() method
118
}
119
120
Popular Tags