1 19 20 package org.openbravo.erpCommon.ad_actionButton; 21 22 import org.openbravo.erpCommon.utility.SequenceIdData; 23 import org.openbravo.base.secureApp.*; 24 import org.openbravo.xmlEngine.XmlDocument; 25 import org.openbravo.erpCommon.utility.Utility; 26 import org.openbravo.utils.FormatUtilities; 27 import org.openbravo.exception.*; 28 import java.io.*; 29 import javax.servlet.*; 30 import javax.servlet.http.*; 31 import java.sql.*; 32 33 import org.openbravo.data.*; 34 35 import java.sql.Connection ; 37 38 39 public class Test_In extends HttpSecureAppServlet { 40 41 42 static int WARNING; 43 static int YES_NO_OPTION; 44 static int NO; 45 46 47 Connection conn; 50 51 52 public void init (ServletConfig config) { 53 super.init(config); 54 boolHist = false; 55 } 56 57 public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 58 try { 59 conn = getTransactionConnection(); 60 } catch (NoConnectionAvailableException ex) { 61 throw new ServletException("@CODE=NoConnectionAvailable"); 62 } catch (SQLException ex2) { 63 throw new ServletException("@CODE=" + Integer.toString(ex2.getErrorCode()) + "@" + ex2.getMessage()); 64 } 65 VariablesSecureApp vars = new VariablesSecureApp(request); 66 67 if (vars.commandIn("DEFAULT")) { 68 String strProcessId = vars.getStringParameter("inpProcessId"); 69 String strWindow = vars.getStringParameter("inpwindowId"); 70 String strTab = vars.getStringParameter("inpTabId"); 71 String strKey = vars.getRequiredGlobalVariable("inpatTestId", strWindow + "|AT_Test_ID"); 72 printPage(response, vars, strKey, strWindow, strTab, strProcessId); 73 } else if (vars.commandIn("SAVE")) { 74 TestLine tl = new TestLine(vars, "inpFile", false, "AplicaciĆ³n de gestiĆ³n", "", false, this); 75 String strWindow = vars.getStringParameter("inpwindowId"); 76 String strKey = vars.getStringParameter("inpatTestId"); 77 vars.setSessionValue(strWindow + "|AT_Test_ID", strKey); 78 String strTab = vars.getStringParameter("inpTabId"); 79 ActionButtonDefaultData[] tab = ActionButtonDefaultData.windowName(this, strTab); 80 String strWindowPath="", strTabName=""; 81 if (tab!=null && tab.length!=0) { 82 strTabName = FormatUtilities.replace(tab[0].name); 83 strWindowPath = "../" + FormatUtilities.replace(tab[0].description) + "/" + strTabName + "_Relation.html"; 84 } else strWindowPath = strDefaultServlet; 85 String messageResult = processButton(vars, tl.getFieldProvider(), strKey, strWindow); 86 vars.setSessionValue(strWindow + "|" + strTabName + ".message", messageResult); 87 printPageClosePopUp(response, vars, strWindowPath); 88 } else pageErrorPopUp(response); 89 } 90 91 92 String processButton(VariablesSecureApp vars, FieldProvider[] dataLineas, String strTestId, String windowId) { 93 94 if (dataLineas==null) return ""; 95 String strCommandId=""; 96 String strType = "C"; 97 String strLineId =""; 98 int intSeqNo = 10; 99 try { 100 if (!TestInData.countLines(this, strTestId).equals("0")) return "Las lineas del test ya han sido importadas previamente"; 101 for (int i=0;i<dataLineas.length;i++) { 102 strCommandId = dataLineas[i].getField("comando"); 103 if (strCommandId != null){ 104 TestInData[] datacomando = TestInData.select(conn, this, strCommandId); 105 strLineId = SequenceIdData.getSequence(this, "AT_Line", vars.getClient()); 106 TestInData.insert(this, strLineId, vars.getClient(), vars.getOrg(), vars.getUser(), strTestId, strCommandId, String.valueOf(intSeqNo), dataLineas[i].getField("arg1"), dataLineas[i].getField("arg2"), dataLineas[i].getField("arg3"), strType, datacomando[0].argno, datacomando[0].arghelp1, datacomando[0].arghelp2, datacomando[0].arghelp3); 107 intSeqNo = intSeqNo + 10; 108 } 109 } 110 return Utility.messageBD(this, "ProcessOK", vars.getLanguage()); 111 } catch (Exception e) { 112 e.printStackTrace(); 113 log4j.warn(e); 114 return Utility.messageBD(this, "ProcessRunError", vars.getLanguage()); 115 } 116 } 117 118 119 void printPage(HttpServletResponse response, VariablesSecureApp vars, String strKey, String windowId, String strTab, String strProcessId) 120 throws IOException, ServletException { 121 if (log4j.isDebugEnabled()) log4j.debug("Output: Button process Project Close"); 122 123 ActionButtonDefaultData[] data = null; 124 String strHelp="", strDescription=""; 125 if (vars.getLanguage().equals("en_US")) data = ActionButtonDefaultData.select(this, strProcessId); 126 else data = ActionButtonDefaultData.selectLanguage(this, vars.getLanguage(), strProcessId); 127 128 if (data!=null && data.length!=0) { 129 strDescription = data[0].description; 130 strHelp = data[0].help; 131 } 132 String [] discard = {""}; 133 if (strHelp.equals("")) discard[0] = new String ("helpDiscard"); 134 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/Test_In", discard).createXmlDocument(); 135 xmlDocument.setParameter("key", strKey); 136 xmlDocument.setParameter("window", windowId); 137 xmlDocument.setParameter("tab", strTab); 138 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 139 xmlDocument.setParameter("question", Utility.messageBD(this, "StartProcess?", vars.getLanguage())); 140 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 141 xmlDocument.setParameter("description", strDescription); 142 xmlDocument.setParameter("help", strHelp); 143 144 response.setContentType("text/html; charset=UTF-8"); 145 PrintWriter out = response.getWriter(); 146 out.println(xmlDocument.print()); 147 out.close(); 148 } 149 150 public String getServletInfo() { 151 return "Servlet Project set Type"; 152 } } 154 | Popular Tags |