You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by li...@apache.org on 2016/12/08 00:45:39 UTC
[12/38] incubator-trafodion git commit: convert trafci project into
maven project
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/main/java/org/trafodion/ci/UserInterruption.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/main/java/org/trafodion/ci/UserInterruption.java b/core/conn/trafci/src/main/java/org/trafodion/ci/UserInterruption.java
new file mode 100644
index 0000000..431d189
--- /dev/null
+++ b/core/conn/trafci/src/main/java/org/trafodion/ci/UserInterruption.java
@@ -0,0 +1,36 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+package org.trafodion.ci;
+
+public class UserInterruption extends Exception
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ UserInterruption()
+ {
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/main/java/org/trafodion/ci/Utils.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/main/java/org/trafodion/ci/Utils.java b/core/conn/trafci/src/main/java/org/trafodion/ci/Utils.java
new file mode 100644
index 0000000..54184a6
--- /dev/null
+++ b/core/conn/trafci/src/main/java/org/trafodion/ci/Utils.java
@@ -0,0 +1,381 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.ci;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.regex.*;
+
+public class Utils
+{
+
+ static HashMap<String, String> xmlHashMap = new HashMap<String, String>();
+
+ Utils()
+ {
+
+ }
+
+
+
+ static String trimSQLTerminator(String qryStr,String sqlTerminator)
+ {
+ if (qryStr.toUpperCase().endsWith(sqlTerminator))
+ {
+ qryStr = qryStr.substring(0,qryStr.length()- sqlTerminator.length());
+ }
+
+ return qryStr;
+ }
+
+ String formatString(String output,int colWidth,char fillchar,String appendStr)
+ {
+ if (output == null)
+ {
+ return null;
+ }
+
+
+
+ if (appendStr != null)
+ {
+ colWidth=colWidth - appendStr.length();
+ }
+
+ output=formatString(output,colWidth,fillchar);
+
+ if (appendStr != null && output != null)
+ {
+ output+=appendStr;
+ }
+
+
+ return output;
+
+ }
+ //dead code. Removed by Kevin Xu
+/*
+ String formatStringWordwrap(String output,int colWidth,char fillchar,String appendStr)
+ {
+ int beginIndex,endIndex;
+ String valueStr;
+
+ if (output == null)
+ {
+ return null;
+ }
+
+ // This is the case where the length of the value exceeds the
+ // column width
+ if ((appendStr !=null) && (appendStr.length()> colWidth-output.length()))
+ {
+ //print atleast five fill characters
+ int labelWidth = output.length() + 5;
+ StringBuffer blankOutput = new StringBuffer();
+ for (int i=0;i<labelWidth;i++)
+ blankOutput.append(' ');
+
+ output=formatString(output,labelWidth,fillchar);
+
+ //break the value into multiple strings to print
+ //on separate lines
+ colWidth = colWidth-labelWidth;
+ for (beginIndex=0,endIndex=colWidth;
+ endIndex<=appendStr.length();
+ beginIndex=endIndex,endIndex+=colWidth)
+ {
+ valueStr = appendStr.substring(beginIndex,endIndex);
+ if (beginIndex==0)
+ output+=valueStr;
+ else
+ output = output + SessionDefaults.lineSeperator + blankOutput + valueStr ;
+
+ }
+ if (endIndex > appendStr.length())
+ output = output + SessionDefaults.lineSeperator + blankOutput + appendStr.substring(beginIndex);
+
+ return output;
+ }
+
+ if (appendStr != null)
+ {
+ colWidth=colWidth - appendStr.length();
+ }
+
+ output=formatString(output,colWidth,fillchar);
+
+ if (appendStr != null && output != null)
+ {
+ output+=appendStr;
+ }
+
+
+ return output;
+
+ }
+*/
+ String formatString(String output,int colWidth,char fillchar)
+ {
+ StringBuffer outBuffer=null;
+
+ if (output == null)
+ {
+ return null;
+ }
+
+ outBuffer=new StringBuffer(output);
+
+
+ if (outBuffer.length() <= colWidth)
+ {
+ for (int i=outBuffer.length();i<colWidth;i++)
+ outBuffer.append(fillchar);
+
+ }
+
+ return outBuffer.toString();
+
+ }
+
+ // Change the string to lowerCase and capitalize the starting character and any character
+ // followed by _ and remove _(under score)
+ //dead code. Removed by Kevin Xu
+/*
+ String initCap(String value)
+ {
+ StringBuffer buffer=null;
+
+ if (value == null)
+ return value;
+
+ buffer=new StringBuffer();
+
+ char[] valueArray=value.toLowerCase().toCharArray();
+
+ // capitalize the first character
+
+ buffer.append(Character.toUpperCase(valueArray[0]));
+
+ boolean changeCase=false;
+
+ for (int i=1;i<valueArray.length;i++)
+ {
+ if (valueArray[i] =='_')
+ {
+ changeCase=true;
+ i++;
+ }
+ else
+ changeCase=false;
+
+ if (changeCase)
+ buffer.append(Character.toUpperCase(valueArray[i]));
+ else
+ buffer.append(valueArray[i]);
+ }
+
+ return buffer.toString();
+
+
+ }
+
+ public String trimSingleQuote(String value)
+ {
+ if (value!=null && value.startsWith("'") && value.endsWith("'"))
+ {
+ value=value.substring(1,value.length()-1);
+ value=value.replaceAll("''","'");
+ }
+ return value;
+ }
+ */
+ public String trimDoubleQuote(String value)
+ {
+ if (value!=null && value.startsWith("\"") && value.endsWith("\""))
+ {
+ value=value.substring(1,value.length()-1);
+ //value=value.replaceAll("''","'");
+ }
+ return value;
+ }
+ //dead code. Removed by Kevin Xu
+/*
+ public String uppQuoteStr(String strValue)
+ {
+ if (strValue != null && !isQuoted(strValue))
+ return strValue.toUpperCase();
+ else
+ return strValue;
+
+ }
+
+ boolean isQuoted(String source)
+ {
+ if (source != null)
+ {
+ source=source.trim();
+ if (source.startsWith("\"") && source.endsWith("\""))
+ return true;
+ else
+ return false;
+ }
+
+ return false;
+ }
+*/
+ public String getTimeinWords(long time)
+ {
+ int hrs = getHrs(time);
+ int mins = getMinutes(time);
+ int secs = getSeconds(time);
+ int msecs = getMilliseconds(time);
+ StringBuffer sb = new StringBuffer();
+
+ if (hrs > 0)
+ {
+ sb.append(hrs);
+ sb.append(" hours and ");
+ }
+ if (mins > 0)
+ {
+ sb.append(mins);
+ sb.append(" minutes and ");
+ }
+ //if (secs != 0) {
+ if (secs > 0 && secs != 1)
+ {
+ sb.append(secs);
+ sb.append(" seconds.");
+ }
+ if ((secs == 0 || secs == 1) && msecs >= 0)
+ sb.append("1 second.");
+
+ return sb.toString();
+ }
+
+ public String millisecondsToString(long time)
+ {
+ int milliseconds = getMilliseconds(time);
+ int seconds = getSeconds(time);
+ int minutes = getMinutes(time);
+ int hours = getHrs(time);
+ String millisecondsStr = (milliseconds<10 ? "00" : (milliseconds<100 ? "0" : ""))+milliseconds;
+ String secondsStr = (seconds<10 ? "0" : "")+seconds;
+ String minutesStr = (minutes<10 ? "0" : "")+minutes;
+ String hoursStr = (hours<10 ? "0" : "")+hours;
+ return new String(hoursStr+":"+minutesStr+":"+secondsStr+"."+millisecondsStr);
+
+ }
+
+ public int getMilliseconds(long time)
+ {
+ return (int)(time % 1000);
+ }
+ public int getSeconds(long time)
+ {
+ return (int)((time/1000) % 60);
+ }
+ public int getMinutes(long time)
+ {
+ return (int)((time/60000) % 60);
+ }
+ public int getHrs(long time)
+ {
+ return (int)((time/3600000) % 24);
+ }
+
+ public String formatXMLdata(String xmlData)
+ {
+
+ Pattern p = Pattern.compile("(<|&|\'|\"|>)");
+ Matcher m = p.matcher(xmlData);
+ StringBuffer strBuf = new StringBuffer();
+ while (m.find())
+ {
+ m.appendReplacement(strBuf, (String) xmlHashMap.get(m.group() ));
+ }
+ m.appendTail(strBuf);
+ return strBuf.toString();
+ }
+
+ static
+ {
+ xmlHashMap.put("&", "&");
+ xmlHashMap.put("<", "<");
+ xmlHashMap.put(">", ">");
+ xmlHashMap.put("\"", """);
+ xmlHashMap.put("\'", "'");
+ }
+
+ public String rtrim(String tmpStr)
+ {
+ tmpStr = tmpStr.replaceAll("\\s+$","");
+ return tmpStr;
+ }
+
+ public String removeSpaces(String str)
+ {
+ str = str.replaceAll("\\s+", "");
+ return str;
+ }
+
+ public static String execLocalhostCmd(String cmd) throws IOException
+ {
+
+ Runtime runtime = Runtime.getRuntime();
+ Process proc = runtime.exec(cmd);
+
+ InputStream is = proc.getInputStream();
+ InputStreamReader isr = new InputStreamReader(is);
+ BufferedReader bufReader = new BufferedReader(isr);
+
+ String line="";
+ StringBuffer sbuf =new StringBuffer("");
+ while ((line = bufReader.readLine()) != null) {
+ sbuf.append(line);
+ }
+
+ try {
+ if (proc.waitFor() != 0) {
+ //System.err.println("Exit Value = " + proc.exitValue());
+ }
+ }
+ catch (InterruptedException e) {
+ System.err.println(e);
+ }
+ return sbuf.toString();
+ }
+
+ public static String internalFormat2(String name)
+ {
+ int index = -1;
+ while((index = name.indexOf('"', index+2)) != -1)
+ {
+ name = name.substring(0,index) + "\\" +name.substring(index);
+ }
+ return name;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/main/java/org/trafodion/ci/ValidateQuery.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/main/java/org/trafodion/ci/ValidateQuery.java b/core/conn/trafci/src/main/java/org/trafodion/ci/ValidateQuery.java
new file mode 100644
index 0000000..fb40fb2
--- /dev/null
+++ b/core/conn/trafci/src/main/java/org/trafodion/ci/ValidateQuery.java
@@ -0,0 +1,412 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.ci;
+
+/*
+ * This class verifies the first key word of any sql string passed and
+ * categorizes the type of sql. The query type is set in the query object
+ */
+
+import java.util.HashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+//import java.util.Iterator;
+//import java.util.Map;
+//import java.util.TreeMap;
+
+
+public class ValidateQuery implements SessionDefaults
+{
+ private Query qryObj=null;
+ private HashMap<String, String> fKeyMap;
+ NullKeyWordException nke; // if the user enters blank throw this exception
+ InterfaceQueryException iqe; // if the token is not listed throw this exception
+ Session sessObj=null;
+
+
+
+
+ ValidateQuery(Session sessObj)
+ {
+ fKeyMap=new HashMap<String, String>();
+ loadfKeyConstants();
+ nke=new NullKeyWordException();
+ iqe=new InterfaceQueryException();
+ this.sessObj=sessObj;
+ }
+
+ public HashMap<String, String> getfKeyMap(){
+ return fKeyMap;
+ }
+
+ public Query getQuery()
+ {
+ return qryObj;
+ }
+ public void setQuery(Query qryObj)
+ {
+ this.qryObj = qryObj;
+ }
+
+ public void validate(Query qryObj,String sqlTerminator) throws NullKeyWordException
+ {
+ this.qryObj=qryObj;
+ String qryText= qryObj.getQueryText();
+
+ if (qryText != null)
+ {
+ qryText=Utils.trimSQLTerminator(qryText.trim(),sqlTerminator);
+ }
+
+ // check the query string and return NullKeyWord if its blank
+ if ((qryText== null)||( qryText !=null && qryText.trim().equals("")))
+ {
+ throw nke;
+ }
+
+ String fKeyWord=getFirstToken(qryText);
+
+ // this case should not happen because we are checking for non space characters
+ if (fKeyWord==null)
+ {
+ throw nke;
+ }
+
+ /*Check for Alias*/
+ if(sessObj.getAliasMap()!=null && qryText!=null)
+ {
+ if(!(qryText.trim().equals("")))
+ {
+ if(sessObj.getAliasMap().containsKey(fKeyWord.toUpperCase()))
+ {
+ qryText = qryObj.getQueryText().replaceFirst(replaceRegexCharacter(fKeyWord), sessObj.getAlias(fKeyWord.toUpperCase()));
+ qryObj.resetQueryText(qryText);
+ qryText=Utils.trimSQLTerminator(qryText.trim(),sqlTerminator);
+ fKeyWord=getFirstToken(qryText);
+ }
+ }
+ }
+
+ // if the first key word starts with @ , replace it with obey
+ if (fKeyWord.startsWith("@"))
+ {
+ fKeyWord="@";
+ qryText = qryText.replaceFirst("@", "@ ");
+ qryObj.resetQueryText(qryText);
+ }
+
+ //replace the first key word with its associated constant value
+ // from fKeyMap has table
+ fKeyWord = fKeyMap.get(fKeyWord.toUpperCase());
+
+ // if the constant value is not found, its defintely a sql or some other
+ // unknown tokens. so set the query type to SQL
+ // set the query id -1 as its unknown at this time
+ if (fKeyWord == null)
+ {
+ if (sessObj.getMode() == SQL_MODE )
+ qryObj.setQueryType(SQLQ);
+
+ qryObj.setMultiLine(true);
+ qryObj.setPassThrough(true);
+ qryObj.setQueryId(-1);
+ return;
+ }
+
+ // convert the string integer to int
+ // we dont need to catch exception here as we made sure
+ // that the constant is int and present in the fKeyMap
+ int fKeyId=Integer.parseInt(fKeyWord);
+
+ switch (fKeyId)
+ {
+ case PRUN:
+
+ qryObj.setQueryType(PRUNQ);
+ qryObj.setMultiLine(false);
+ qryObj.setPassThrough(false);
+ qryObj.setQueryId(fKeyId);
+ break;
+
+
+ case ALIAS:
+ qryObj.setQueryType(IQ);
+ qryObj.setMultiLine(true);
+ qryObj.setPassThrough(false);
+ qryObj.setQueryId(fKeyId);
+ break;
+
+ case EXIT:
+ case ED:
+ case EDIT:
+ case FC:
+ case CLEAR:
+ case SLASH:
+ case RUN:
+ case SECTION:
+ case LOCALHOST:
+ //case AT:
+ qryObj.setQueryType(IQ);
+ qryObj.setMultiLine(false);
+ qryObj.setPassThrough(false);
+ qryObj.setQueryId(fKeyId);
+ break;
+
+ case SET:
+ case SPOOL:
+ case SHOW:
+ case OBEY:
+ case LOG:
+ case MODE:
+ case RESET:
+ case ENV:
+ case SESSION:
+ case HISTORY:
+ case REPEAT:
+ case HELP:
+ case SAVEHIST:
+ case VERSION:
+ case DISCONNECT:
+ case CONNECT:
+ case RECONNECT:
+ case SRUN:
+ case ERROR:
+ case ONLINEDBDUMP:
+ case AUDIT:
+ case SCHEDULE:
+ case ALLOW:
+ case DENY:
+ case LIST:
+ case DELAY:
+ qryObj.setQueryType(IQ);
+ qryObj.setMultiLine(false);
+ qryObj.setPassThrough(false);
+ qryObj.setQueryId(fKeyId);
+ break;
+
+ case INVOKE:
+ case SHOWDDL:
+ case SHOWSHAPE:
+ case SHOWCONTROL:
+ case SHOWTRANSACTION:
+ case REORG:
+ case REORGANIZE:
+ case MAINTAIN:
+ case REPLICATE:
+ case SHOWLABEL:
+ case SHOWPLAN:
+ case EXPLAIN:
+ case GET:
+
+ //qryObj.setQueryType(SQLQ);
+ if (SQL_MODE == sessObj.getMode() || CS_MODE == sessObj.getMode())
+ qryObj.setQueryType(SQLQ);
+ else if (sessObj.getMode() == WMS_MODE)
+ qryObj.setQueryType(NSQ);
+ qryObj.setMultiLine(true);
+ qryObj.setPassThrough(true);
+ qryObj.setQueryId(fKeyId);
+ qryObj.setTrimOut(true); // set the trimout to true as we need to trim the result sets for all these cases
+ break;
+
+ case IF_THEN:
+ case LABEL:
+ case GOTO:
+ qryObj.setQueryType(CQ);
+ qryObj.setMultiLine((fKeyId == IF_THEN));
+ qryObj.setPassThrough(false);
+ qryObj.setQueryId(fKeyId);
+ break;
+
+
+ case DOTSQL:
+ case DOTCS:
+ case DOTNS:
+ case DOTWMS:
+ case DOTSEC:
+ qryObj.setQueryType(IQ);
+ qryObj.setMultiLine(false);
+ qryObj.setPassThrough(false);
+ qryObj.setQueryId(fKeyId);
+ break;
+
+ default:
+// if (sessObj.getMode()==SQL_MODE)
+ if (SQL_MODE == sessObj.getMode() || CS_MODE == sessObj.getMode())
+ qryObj.setQueryType(SQLQ);
+ else if (sessObj.getMode() == WMS_MODE)
+ qryObj.setQueryType(NSQ);
+ qryObj.setMultiLine(false);
+ qryObj.setPassThrough(false);
+ qryObj.setQueryId(fKeyId);
+ break;
+
+ }
+
+ }
+
+ // the first token will be any non-space characters as a word
+ // prefixed and suffixed with one or more spaces or
+ // line end
+ String getFirstToken(String fLine)
+ {
+ Pattern pat=Pattern.compile("^\\s*(\\S*)(\\s+.*|$)");
+ Matcher mat=pat.matcher(fLine);
+ if (mat.find())
+ {
+ return mat.group(1);
+ }
+ else
+ return null;
+ }
+
+ int getQueryId(String qryStr)
+ {
+ String fToken= getFirstToken(qryStr);
+ fToken = fKeyMap.get(fToken.toUpperCase());
+ if (fToken !=null)
+ return Integer.parseInt(fToken);
+ else
+ return -1;
+
+ }
+
+// public String trimSQLTerminator(String qryStr,String sqlTerminator)
+// {
+// if (qryStr.endsWith(sqlTerminator))
+// {
+// return qryStr.substring(0,qryStr.length()- sqlTerminator.length());
+// }
+// return qryStr;
+// }
+
+ // load all first keywords which needs to be processed
+ private void loadfKeyConstants()
+ {
+ fKeyMap.put("PRUN",""+PRUN);
+ fKeyMap.put("EXIT",""+EXIT);
+ fKeyMap.put("QUIT",""+EXIT);
+ fKeyMap.put("DISCONNECT",""+DISCONNECT);
+ fKeyMap.put("SET",""+SET);
+ fKeyMap.put("RESET",""+RESET);
+ fKeyMap.put("ED",""+ED);
+ fKeyMap.put("SPOOL",""+SPOOL);
+ fKeyMap.put("LOG",""+LOG);
+ fKeyMap.put("/",""+SLASH);
+ fKeyMap.put("RUN",""+RUN);
+ fKeyMap.put("SHOW",""+SHOW);
+ fKeyMap.put("@",""+OBEY);
+ fKeyMap.put("MODE",""+MODE);
+ fKeyMap.put("OBEY",""+OBEY);
+ fKeyMap.put("HISTORY",""+HISTORY);
+ fKeyMap.put("REPEAT",""+REPEAT);
+ fKeyMap.put("INVOKE",""+INVOKE);
+ fKeyMap.put("SHOWDDL",""+SHOWDDL);
+ fKeyMap.put("SHOWSHAPE",""+SHOWSHAPE);
+ fKeyMap.put("SHOWCONTROL",""+SHOWCONTROL);
+ fKeyMap.put("REORG",""+REORG);
+ fKeyMap.put("REORGANIZE",""+REORGANIZE);
+ fKeyMap.put("MAINTAIN",""+MAINTAIN);
+ fKeyMap.put("SHOWLABEL",""+SHOWLABEL);
+ fKeyMap.put("SHOWPLAN",""+SHOWPLAN);
+ fKeyMap.put("PREPARE",""+PREPARE);
+ fKeyMap.put("EXECUTE",""+EXECUTE);
+ fKeyMap.put("EXPLAIN",""+EXPLAIN);
+ fKeyMap.put("INFOSTATS",""+INFOSTATS);
+ fKeyMap.put("FC",""+FC);
+ fKeyMap.put("CALL",""+CALL);
+ fKeyMap.put("CLEAR",""+CLEAR);
+ fKeyMap.put("HELP",""+HELP);
+ fKeyMap.put("?SECTION",""+SECTION);
+ fKeyMap.put("SAVEHIST",""+SAVEHIST);
+ fKeyMap.put("VERSION",""+VERSION);
+ fKeyMap.put("ENV",""+ENV);
+ fKeyMap.put("SESSION",""+SESSION);
+ fKeyMap.put("CONNECT",""+CONNECT);
+ fKeyMap.put("RECONNECT",""+RECONNECT);
+ fKeyMap.put("GET",""+GET);
+ fKeyMap.put("LOCALHOST",""+LOCALHOST);
+ fKeyMap.put("LH",""+LOCALHOST);
+ fKeyMap.put("ERROR",""+ERROR);
+ fKeyMap.put("ONLINEDBDUMP",""+ONLINEDBDUMP);
+ fKeyMap.put("SRUN",""+SRUN);
+ fKeyMap.put("ALLOW",""+ALLOW);
+ fKeyMap.put("DENY",""+DENY);
+ fKeyMap.put("SCHEDULE",""+SCHEDULE);
+ fKeyMap.put("LIST",""+LIST);
+ fKeyMap.put("AUDIT",""+AUDIT);
+ fKeyMap.put("DELAY",""+DELAY);
+ fKeyMap.put("IF",""+IF_THEN);
+ fKeyMap.put("LABEL",""+LABEL);
+ fKeyMap.put("GOTO",""+GOTO);
+ fKeyMap.put("ALIAS",""+ALIAS);
+ fKeyMap.put(".SQL",""+DOTSQL);
+ fKeyMap.put(".CS",""+DOTCS);
+ fKeyMap.put(".NS",""+DOTNS);
+ fKeyMap.put(".WMS",""+DOTWMS);
+ fKeyMap.put(".SEC",""+DOTSEC);
+ fKeyMap.put("CONTROL",""+CONTROL);
+ fKeyMap.put("REPLICATE",""+REPLICATE);
+ fKeyMap.put("SHOWTRANSACTION",""+SHOWTRANSACTION);
+
+ }
+ /**
+ * Added 2010-02-26
+ * Replace reserved characters of regex with '\'+characters
+ * @param source
+ * @return
+ */
+ public String replaceRegexCharacter(String source)
+ {
+ if(source==null || source.length()==0)
+ return "";
+ StringBuilder stbReturn = new StringBuilder();
+ char[] analyStr=source.toCharArray();
+ if(analyStr.length>0)
+ {
+ for(int i=0;i<analyStr.length;i++)
+ {
+ switch(analyStr[i])
+ {
+ case '+':
+ case '?':
+ case '*':
+ case '.':
+ case '^':
+ case '{':
+ case '[':
+ case '(':
+ case ')':
+ case '$':
+ stbReturn.append('\\');
+ break;
+
+ }
+ stbReturn.append(analyStr[i]);
+ }
+ }
+
+ return stbReturn.toString();
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/main/java/org/trafodion/ci/ValidationException.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/main/java/org/trafodion/ci/ValidationException.java b/core/conn/trafci/src/main/java/org/trafodion/ci/ValidationException.java
new file mode 100644
index 0000000..e289751
--- /dev/null
+++ b/core/conn/trafci/src/main/java/org/trafodion/ci/ValidationException.java
@@ -0,0 +1,39 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+package org.trafodion.ci;
+
+public class ValidationException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8842989562052059377L;
+
+ ValidationException()
+ {
+
+ }
+
+ ValidationException(String msg)
+ {
+ super(msg);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/main/java/org/trafodion/ci/Vproc.java-tmpl
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/main/java/org/trafodion/ci/Vproc.java-tmpl b/core/conn/trafci/src/main/java/org/trafodion/ci/Vproc.java-tmpl
new file mode 100644
index 0000000..170922c
--- /dev/null
+++ b/core/conn/trafci/src/main/java/org/trafodion/ci/Vproc.java-tmpl
@@ -0,0 +1,36 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.ci;
+
+
+public class Vproc
+{
+ private static final String vprocStr = "@@@";
+ public static void main(String[] args)
+ {
+ System.out.println(vprocStr);
+ }
+ public static String getVproc()
+ {
+ return vprocStr;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/main/java/org/trafodion/ci/WCIUtils.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/main/java/org/trafodion/ci/WCIUtils.java b/core/conn/trafci/src/main/java/org/trafodion/ci/WCIUtils.java
new file mode 100644
index 0000000..63a9057
--- /dev/null
+++ b/core/conn/trafci/src/main/java/org/trafodion/ci/WCIUtils.java
@@ -0,0 +1,122 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.ci;
+
+import java.io.FileOutputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.io.IOException;
+
+public class WCIUtils
+{
+
+ // constants copied from wincon.h
+
+ /**
+ * Characters read by the ReadFile or ReadConsole function
+ * are written to the active screen buffer as they are read.
+ * This mode can be used only if the ENABLE_LINE_INPUT mode
+ * is also enabled.
+ */
+ private static final int ENABLE_ECHO_INPUT = 4;
+
+ private static boolean loaded = false;
+
+ String tmpDir=System.getProperty("java.io.tmpdir");
+ String userName=System.getProperty("user.name");
+ String archModel=System.getProperty("sun.arch.data.model");
+
+ public native void cls();
+ private native int getConsoleMode();
+ private native void setConsoleMode(final int mode);
+
+
+ public WCIUtils() throws IOException
+ {
+ if (!loaded)
+ {
+ copyDllFromURL();
+ if (archModel.equalsIgnoreCase("64"))
+ System.load(tmpDir + "WCIUtils64_" + userName + ".dll");
+ else
+ System.load(tmpDir + "WCIUtils32_" + userName + ".dll");
+ loaded = true;
+ }
+ }
+
+ public synchronized void enableEcho()
+ {
+ setConsoleMode( getConsoleMode() | ENABLE_ECHO_INPUT );
+ }
+
+ public synchronized void disableEcho()
+ {
+ setConsoleMode( getConsoleMode() & ~( ENABLE_ECHO_INPUT));
+ }
+
+
+ private synchronized void copyDllFromURL() throws IOException
+ {
+ File dest;
+ if (archModel.equalsIgnoreCase("64"))
+ dest = new File( tmpDir, "WCIUtils64_" + userName + ".dll" );
+ else
+ dest = new File( tmpDir, "WCIUtils32_" + userName + ".dll" );
+
+
+ // if the dll already exists in the local pc
+ // recopy the file it is not already loaded
+ if (dest.exists())
+ {
+ try
+ {
+ if (!dest.delete())
+ return;
+ }catch (Exception e)
+ {
+ dest=null;
+ return;
+ }
+ }
+
+ FileOutputStream os = new FileOutputStream( dest );
+ InputStream is;
+ if (archModel.equalsIgnoreCase("64"))
+ is=this.getClass().getResourceAsStream("WCIUtils64.dll");
+ else
+ is=this.getClass().getResourceAsStream("WCIUtils32.dll");
+
+ byte data[] = new byte[ 4096 ];
+ int ct;
+
+ while ((ct=is.read( data )) >= 0)
+ os.write( data, 0, ct );
+
+ is.close();
+ os.close();
+ os=null;
+ is=null;
+ dest=null;
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/main/java/org/trafodion/ci/Writer.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/main/java/org/trafodion/ci/Writer.java b/core/conn/trafci/src/main/java/org/trafodion/ci/Writer.java
new file mode 100644
index 0000000..c277342
--- /dev/null
+++ b/core/conn/trafci/src/main/java/org/trafodion/ci/Writer.java
@@ -0,0 +1,418 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.ci;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+
+public class Writer
+{
+
+ private ConsoleWriter cWriter=null;
+ private FileWriter lWriter=null;
+ private FileWriter sWriter=null;
+ private InterfaceSyntaxError ise=null;
+ private ConditionalSyntaxError cse=null;
+ private Parser parser = new Parser();
+ private int writerMode=SessionDefaults.CONSOLE_WRITE_MODE;
+ private Session sessObj=null;
+
+ Writer()
+ {
+ }
+
+ Writer(Session sessObj)
+ {
+ this.sessObj = sessObj;
+ }
+
+
+
+ public void write(String line) throws IOException
+ {
+ switch (writerMode)
+ {
+ case SessionDefaults.CONSOLE_WRITE_MODE:
+ cWriter.print(line);
+ break;
+ case SessionDefaults.LOG_WRITE_MODE:
+ lWriter.write(line);
+ break;
+ case SessionDefaults.SPOOL_WRITE_MODE:
+ sWriter.write(line);
+ break;
+ case SessionDefaults.CONSOLE_SPOOL_WRITE_MODE:
+ if (!sessObj.isQuietEnabled())
+ cWriter.print(line);
+ sWriter.write(line);
+
+ break;
+ }
+ }
+
+ public void writeln() throws IOException
+ {
+ switch (writerMode)
+ {
+ case SessionDefaults.CONSOLE_WRITE_MODE:
+ cWriter.println();
+ break;
+ case SessionDefaults.LOG_WRITE_MODE:
+ lWriter.writeln();
+ break;
+ case SessionDefaults.SPOOL_WRITE_MODE:
+ sWriter.writeln();
+ break;
+ case SessionDefaults.CONSOLE_SPOOL_WRITE_MODE:
+ if (!sessObj.isQuietEnabled())
+ cWriter.println();
+ sWriter.writeln();
+
+ break;
+ }
+ }
+
+ public void writeAllSQLExceptions(Session sessObj, SQLException sqle) throws IOException
+ {
+ do
+ {
+ if (!sessObj.isSessionAutoPrepare())
+ {
+ String errorInfo = parser.getErrorCode(
+ formatErrStr(sqle.toString(), sessObj),
+ sqle.getErrorCode());
+ if (errorInfo.equals("8822") && !sessObj.getQuery().getQueryText().trim().toUpperCase().startsWith("PREPARE "))
+ {
+ continue;
+ }
+ }
+ this.writeInterfaceError(sessObj,
+ new ErrorObject(formatErrStr(sqle.toString(), sessObj),
+ sqle.getErrorCode()));
+ } while ((sqle=sqle.getNextException()) != null);
+
+ // Print end tags if MARKUP is XML or HTML
+ this.writeEndTags(sessObj);
+ }
+
+ /*
+ * Writes all the warnings that are returned as part of the ResultSet
+ * whilst we are doing a fetch.
+ */
+ public void writeAllFetchWarnings(Session sessObj, SQLWarning sqlw,
+ int numCols) throws IOException {
+
+ /* Get the markup being currently used for the display. */
+ int outputMarkup = sessObj.getDisplayFormat();
+
+
+ /*
+ * Print starting tags.
+ */
+ if (SessionDefaults.XML_FORMAT == outputMarkup)
+ sessObj.getXmlObj().startFetchWarningListTag();
+ else if (SessionDefaults.HTML_FORMAT == outputMarkup)
+ sessObj.getHtmlObj().startFetchWarningListTable(numCols);
+
+
+ /*
+ * Loop thru' all the warnings.
+ */
+ while (null != sqlw) {
+ String errStr = formatErrStr(sqlw.toString(), sessObj);
+
+ switch(outputMarkup) {
+ case SessionDefaults.XML_FORMAT :
+ case SessionDefaults.HTML_FORMAT :
+ ErrorObject eo = new ErrorObject(parser.getErrorCode(errStr,sqlw.getErrorCode()),
+ errStr, 'W');
+ if (SessionDefaults.XML_FORMAT == outputMarkup)
+ sessObj.getXmlObj().handleFetchWarnings(eo);
+ else
+ sessObj.getHtmlObj().handleFetchWarnings(eo);
+
+ break;
+
+ default:
+ writeln(errStr);
+ break;
+
+ } /* End of switch on display output markup. */
+
+
+ /* Get the next warning in this warning chain. */
+ sqlw=sqlw.getNextWarning();
+
+
+ } /* End of WHILE there are more warnings to process. */
+
+
+ /*
+ * Print the ending tags.
+ */
+ if (SessionDefaults.XML_FORMAT == outputMarkup)
+ sessObj.getXmlObj().endFetchWarningListTag();
+ else if (SessionDefaults.HTML_FORMAT == outputMarkup)
+ sessObj.getHtmlObj().endFetchWarningListTable();
+
+ } /* End of writeAllFetchWarnings method. */
+
+ public void writeAllSQLWarnings(Session sessObj, SQLWarning sqlw) throws IOException
+ {
+ while ((sqlw!=null))
+ {
+ if (sessObj.getDisplayFormat() == SessionDefaults.XML_FORMAT)
+ sessObj.getXmlObj().handleWarnings(
+ new ErrorObject(parser.getErrorCode(
+ formatErrStr(sqlw.toString(), sessObj),
+ sqlw.getErrorCode()),
+ formatErrStr(sqlw.toString(), sessObj), 'W'));
+ else if (sessObj.getDisplayFormat() == SessionDefaults.HTML_FORMAT)
+ sessObj.getHtmlObj().handleWarnings(
+ new ErrorObject(parser.getErrorCode(
+ formatErrStr(sqlw.toString(), sessObj),
+ sqlw.getErrorCode()),
+ formatErrStr(sqlw.toString(), sessObj), 'W'));
+ else
+ writeln(formatErrStr(sqlw.toString(), sessObj));
+
+ sqlw=sqlw.getNextWarning();
+ }
+ }
+
+ public void writeSyntaxError(Session sessObj, String qryString, String remainderString) throws IOException
+ {
+ if (ise == null)
+ {
+ ise=new InterfaceSyntaxError();
+ }
+ writeInterfaceErrors(sessObj, ise.getSyntaxError(qryString,remainderString));
+ }
+
+ public void writeConditionalSyntaxError(Session sessObj, String qryString) throws IOException
+ {
+ if(cse == null )
+ {
+ cse=new ConditionalSyntaxError();
+ }
+ writeInterfaceErrors(sessObj, cse.getSyntaxError(qryString));
+ }
+
+ public void writeln(String line) throws IOException
+ {
+ write(line);
+ writeln();
+ }
+
+ private String formatErrStr(String errStr, Session sessObj)
+ {
+
+ if ((errStr.indexOf("org.trafodion.jdbc.t4") != -1)
+ || (errStr.indexOf("java.sql") != -1)
+ || (errStr.indexOf("org.trafodion.jdbc.t4.TrafT4") != -1))
+ {
+ if (errStr.indexOf(":")!=-1)
+ {
+ errStr =errStr.substring(errStr.indexOf(":")+1).trim();
+ }
+ else
+ {
+ return errStr;
+ }
+ }
+
+ return errStr;
+ }
+
+ public void writeElapsedTime(String time) throws IOException
+ {
+ writeln();
+ writeln("Elapsed: "+ time);
+ }
+
+ public ConsoleWriter getConsoleWriter()
+ {
+ return cWriter;
+ }
+ public void setConsoleWriter(ConsoleWriter writer)
+ {
+ cWriter = writer;
+ }
+ public FileWriter getSpoolWriter()
+ {
+ return sWriter;
+ }
+ public void setSpoolWriter(FileWriter sWriter)
+ {
+ this.sWriter = sWriter;
+ }
+ public FileWriter getLogWriter()
+ {
+ return lWriter;
+ }
+ public void setLogWriter(FileWriter lWriter)
+ {
+ this.lWriter = lWriter;
+ }
+ public int getWriterMode()
+ {
+ return this.writerMode;
+ }
+ public void setWriterMode(int writerMode)
+ {
+ this.writerMode = writerMode;
+ }
+
+ public void writeError(Session sessObj, ErrorObject errObj) throws IOException
+ {
+ this.writeInterfaceErrors(sessObj, errObj);
+ }
+
+ public void writeError(Session sessObj, char errType,ErrorObject errObj, String[] values) throws IOException
+ {
+ String errStr = errObj.errorMessage();
+ for (int i=0;i<values.length;i++)
+ errStr = errStr.replaceFirst("%s",values[i].toString());
+ this.writeError(sessObj, new ErrorObject(errObj.errorCode(), errStr));
+ }
+
+ public void writeExecutionTime(Session sessObj, Utils utilObj, Writer writer) throws IOException
+ {
+ String qryExecTime= "";
+ qryExecTime = " *** Total Query time was " + utilObj.getTimeinWords(sessObj.getQryExecEndTime());
+
+ if (sessObj.getDisplayFormat() == SessionDefaults.HTML_FORMAT)
+ sessObj.getHtmlObj().handleQryExecutionTime(qryExecTime);
+ else if (sessObj.getDisplayFormat() == SessionDefaults.XML_FORMAT)
+ sessObj.getXmlObj().handleQryExecutionTime(qryExecTime);
+ else if (sessObj.getDisplayFormat() == SessionDefaults.RAW_FORMAT)
+ writer.writeln(qryExecTime+SessionDefaults.lineSeperator);
+ }
+
+ public void writeStatusMsg(Session sessObj, Query qryObj, Utils utilObj, Writer writer) throws IOException
+ {
+ String elapsedTimeMsg = getElapsedTime(sessObj,qryObj, utilObj);
+ String statusMsg = sessObj.getLfProps().getStatus(qryObj) + SessionDefaults.lineSeperator;
+ writeStatusMsg(sessObj, statusMsg, elapsedTimeMsg, writer);
+ }
+
+ public void writeStatusMsg(Session sessObj, String statusMsg, String elapsedTimeMsg, Writer writer) throws IOException
+ {
+ if (sessObj.getDisplayFormat() == SessionDefaults.HTML_FORMAT)
+ sessObj.getHtmlObj().processHtml(elapsedTimeMsg);
+ else if (sessObj.getDisplayFormat() == SessionDefaults.XML_FORMAT)
+ {
+ sessObj.getXmlObj().processXml("",elapsedTimeMsg);
+ }
+ else if (sessObj.getDisplayFormat() == SessionDefaults.RAW_FORMAT)
+ {
+ if (null != statusMsg)
+ writer.write(statusMsg);
+ if (sessObj.isSessionTimingOn())
+ {
+ if (null != statusMsg)
+ writer.writeln();
+ writer.writeln(elapsedTimeMsg);
+
+ writer.printElapsedQuietMode(elapsedTimeMsg);
+ }
+ }
+
+ }
+
+ public String getElapsedTime(Session sessObj,Query qryObj,Utils utilObj)
+ {
+ String elapsedTimeMsg="";
+ if (sessObj.isSessionTimingOn())
+ {
+ elapsedTimeMsg = "Elapsed: " + utilObj.millisecondsToString(qryObj.getElapsedTime());
+ }
+ return elapsedTimeMsg;
+ }
+
+ public void printElapsedQuietMode(String elapsedTimeMsg){
+ if (sessObj.isSessionTimingOn())
+ {
+ if(writerMode == SessionDefaults.CONSOLE_SPOOL_WRITE_MODE &&
+ sessObj.isQuietEnabled() && sessObj.getCaller() != SessionDefaults.PRUNI)
+ {
+ try{
+ sessObj.setQuietEnabled(false);
+ writeln();
+ this.getConsoleWriter().println(elapsedTimeMsg);
+ }catch(IOException ioex){
+ ;
+ }
+ sessObj.setQuietEnabled(true);
+ }
+ }
+ }
+
+ // Print end tags if MARKUP is XML or HTML
+ public void writeEndTags (Session sessObj) throws IOException
+ {
+ if (sessObj.getDisplayFormat() == SessionDefaults.XML_FORMAT)
+ sessObj.getXmlObj().handleEndTags();
+ if (sessObj.getDisplayFormat() == SessionDefaults.HTML_FORMAT)
+ sessObj.getHtmlObj().handleEndTags();
+ }
+
+ //called when an SQL query returns an error.
+ public void writeInterfaceErrors(Session sessObj, String errorStr) throws IOException
+ {
+ writeInterfaceErrors(sessObj,new ErrorObject(errorStr));
+ }
+
+ // called when a single interface error occurs.
+ public void writeInterfaceErrors(Session sessObj, ErrorObject errorObj) throws IOException
+ {
+ writeInterfaceError(sessObj, errorObj);
+ //Catalog API calls - print the end tags in InterfaceQuery
+ int errorNo = Integer.parseInt(errorObj.errorCode());
+ if (!(errorNo >= 29416 && errorNo <= 29423))
+ writeEndTags(sessObj);
+ }
+
+ // called once for each error message in a series of errors.
+ public void writeInterfaceError(Session sessObj, ErrorObject errorObj) throws IOException
+ {
+ switch (sessObj.getDisplayFormat())
+ {
+ case SessionDefaults.HTML_FORMAT:
+ sessObj.getHtmlObj().handleErrors(errorObj);
+ break;
+ case SessionDefaults.XML_FORMAT:
+ sessObj.getXmlObj().handleErrors(errorObj);
+ break;
+ default:
+ writeln(errorObj.RAWOutputError());
+ break;
+ }
+
+ if (!errorObj.errorCode().equalsIgnoreCase(Parser.UNKNOWN_ERROR_CODE))
+ sessObj.setLastError(Integer.parseInt(errorObj.errorCode()));
+ }
+}
+
+
+
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/main/java/org/trafodion/ci/XMLDisplay.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/main/java/org/trafodion/ci/XMLDisplay.java b/core/conn/trafci/src/main/java/org/trafodion/ci/XMLDisplay.java
new file mode 100644
index 0000000..f121300
--- /dev/null
+++ b/core/conn/trafci/src/main/java/org/trafodion/ci/XMLDisplay.java
@@ -0,0 +1,75 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.ci;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+public class XMLDisplay implements IDisplay {
+
+ private Query qryObj;
+ private Writer writer=null;
+ private Session sessObj=null;
+
+ public XMLDisplay(Session sessObj)
+ {
+ if(sessObj!=null)
+ {
+ this.sessObj = sessObj;
+ this.writer=sessObj.getWriter();
+ this.qryObj=sessObj.getQuery();
+ }
+ }
+
+ public void output(OutputContents contents) throws IOException {
+ // TODO Auto-generated method stub
+ if(contents!=null)
+ {
+ this.writer=sessObj.getWriter();
+ this.qryObj=sessObj.getQuery();
+ //display header
+ ArrayList<OutputColumnAttribute> columns = contents.getColumns();
+ qryObj.setColCount(String.valueOf(columns.size()));
+
+ ArrayList<ArrayList<String>> alRows = contents.getRows();
+ if(alRows!=null && alRows.size()>0)
+ {
+ for(int i=0;i<alRows.size();i++)
+ {
+ ArrayList<String> alRow = alRows.get(i);
+ if(alRow!=null && alRow.size()>0)
+ {
+ for(int j=0;j<alRow.size();j++)
+ {
+ OutputColumnAttribute columnAttr = columns.get(j);
+ sessObj.getXmlObj().processXml(columnAttr.name,alRow.get(j));
+ writer.writeln();
+ }
+ }
+
+ }
+ }
+
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/main/java/org/trafodion/ci/XMLObject.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/main/java/org/trafodion/ci/XMLObject.java b/core/conn/trafci/src/main/java/org/trafodion/ci/XMLObject.java
new file mode 100644
index 0000000..469b1ef
--- /dev/null
+++ b/core/conn/trafci/src/main/java/org/trafodion/ci/XMLObject.java
@@ -0,0 +1,607 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+/**
+ *
+ *
+ * Class to display the Errors/Warnings/ResultSets/Status Messages in XML format
+ *
+ */
+
+package org.trafodion.ci;
+
+import java.io.*;
+
+public class XMLObject
+{
+
+ private Utils utilObj = null;
+// private Parser parser = null;
+ private Session sessObj = null;
+ private Writer writer = null;
+ private Query qryObj = null;
+ private QueryUtils qryUtilObj=null;
+
+ int rowCount = 0;
+ int colCount = 1;
+ int errorCount = 0;
+
+ public String _xmlNameSpaceTag="<?xml version=\"1.0\"?>";
+ private String encodingTag="";
+ public String _beginRootTag = "<Results>";
+ public String _endRootTag = "</Results>";
+
+ String _beginQueryTag = " <Query>";
+ String _endQueryTag = " </Query>";
+
+ boolean _beginRootElement = false;
+ boolean _errors = false;
+ boolean _warnings = false;
+ boolean _initDone = false;
+
+ String _beginRowTag = " <Row id=\"" ;
+ String _endRowTag = " </Row>";
+
+ String _beginCdataTag=" <![CDATA[";
+ String _endCdataTag = " ]]>";
+ String _endCdataTagEscaped = "]]>";
+
+ String _beginStatusTag = "<Status>";
+ String _endStatusTag = "</Status>";
+
+ String _beginErrorListTag = " <ErrorList>";
+ String _endErrorListTag = " </ErrorList>";
+
+ String _beginErrorCountTag = " <Error id=\"" ;
+ String _endErrorCountTag = " </Error>";
+
+ String _beginErrorCodeTag = " <ErrorCode>";
+ String _endErrorCodeTag = "</ErrorCode>";
+
+ String _beginMessageCodeTag = " <MessageCode>";
+ String _endMessageCodeTag = "</MessageCode>";
+
+ String _beginErrorMsgTag = " <ErrorMsg>";
+ String _endErrorMsgTag = "</ErrorMsg>";
+
+ String _beginMessageMsgTag = " <MessageText>";
+ String _endMessageMsgTag = "</MessageText>";
+
+ String _beginWarnListTag = " <WarningList>";
+ String _endWarnListTag = " </WarningList>";
+
+ String _beginWarnCountTag = " <Warning id=\"" ;
+ String _endWarnCountTag = " </Warning>";
+
+ String _beginWarnCodeTag = " <WarningCode>";
+ String _endWarnCodeTag = "</WarningCode>";
+
+ String _beginWarnMsgTag = " <WarningMsg>";
+ String _endWarnMsgTag = "</WarningMsg>";
+
+ public String _beginScriptsDirTag = "<ScriptsDirectory>";
+ public String _endStriptsDirTag = "</ScriptsDirectory>";
+
+ public String _beginLogsDirTag = "<LogsDirectory>";
+ public String _endLogsDirTag = "</LogsDirectory>";
+
+ public String _beginLogsO = "<OverWriteLog>";
+ public String _endLogsO = "</OverWriteLog>";
+
+ public String _beginConnTag = "<TotalConnections>";
+ public String _endConnTag = "</TotalConnections>";
+
+ public String _beginSeqIdTag = "<Seq id = \"";
+ public String _endSeqIdTag = "</Seq>";
+
+ public String _beginLogFileNameTag = " <LogFileName>";
+ public String _endLogFileNameTag = " </LogFileName>";
+
+ public String _beginTotalSqlsTag = " <TotalSqls>";
+ public String _endTotalSqlsTag = " </TotalSqls>";
+
+ public String _beginTotalErrors = " <Errors>";
+ public String _endTotalErrors = " </Errors>";
+
+ public String _beginTotalWarnings = " <Warnings>" ;
+ public String _endTotalWarnings = " </Warnings>" ;
+
+ public String _beginMinTag = "<TotalMinutes>";
+ public String _endMinTag = "</TotalMinutes>";
+
+ public String _endAttributeTag = "\">";
+
+ String _beginResultSetIdTag = " <ResultSet id=\"" ;
+ String _beginResultSetTag = " <ResultSet>" ;
+ String _endResultSetTag = " </ResultSet>";
+
+ String _beginExecutionTimeTag = " <ExecutionTime>";
+ String _endExecutionTimeTag = "</ExecutionTime>";
+
+ String statusMsg = "";
+ boolean perTableStats = false;
+
+
+
+ XMLObject ()
+ {
+ }
+
+ XMLObject (Session sessObj)
+ {
+ this.sessObj = sessObj;
+// parser = new Parser();
+ utilObj = new Utils();
+ qryUtilObj = new QueryUtils();
+
+ }
+
+ public void init()
+ {
+ this.writer=sessObj.getWriter();
+ this.qryObj=sessObj.getQuery();
+ _initDone = true;
+ }
+
+ public void processXml(String columnName, String output) throws IOException
+ {
+
+ if (!_initDone)
+ {
+ this.init();
+ this.handleStartTags();
+ //_initDone = true;
+ }
+ if (sessObj.isInOutandRS() && qryObj.getRsCount() >= 0)
+ {
+ // writer.writeln(" " + _beginResultSetTag);
+ qryObj.resetQueryText("SELECT *");
+ rowCount = 0;
+ colCount = 1;
+
+ }
+ if ((qryObj.getRowCount() != null))
+ {
+
+ if ((_warnings) || ((rowCount==0 && Integer.parseInt(qryObj.getRowCount())==0) || (rowCount != Integer.parseInt(qryObj.getRowCount()))))
+ {
+ this.handleStartTags();
+ }
+
+ if ((qryObj.isTrimOut() && !qryUtilObj.isGetStatsCmd(qryObj)) || (perTableStats) )
+ {
+ writer.writeln(" " + _endCdataTag);
+ perTableStats = false;
+ }
+
+ if (_warnings && !sessObj.isWriteParams())
+ writer.writeln(_endWarnListTag);
+
+ if ((sessObj.isImplicitGetStatsQry()) && qryUtilObj.isGetStatsCmd(qryObj))
+ {
+ statusMsg = "";
+ sessObj.getDbQryObj().resetQryObj();
+ sessObj.setImplicitGetStatsQry(false);
+ }
+ else
+ {
+ statusMsg = sessObj.getLfProps().getStatus(qryObj);
+ }
+ if (!((output.equals("")) && statusMsg.equals("")))
+ writer.write(_beginStatusTag + _beginCdataTag + statusMsg + output + _endCdataTag + _endStatusTag +SessionDefaults.lineSeperator);
+ this.handleEndTags();
+ return;
+ }
+
+ if (qryObj.isTrimOut())
+ {
+ if (qryUtilObj.isGetStatsCmd(qryObj) && !perTableStats)
+ {
+ if (!(output.trim().equals("")))
+ printGetStatsOutput(output.trim());
+ }
+ else
+ writer.write(output.trim());
+ }else
+ {
+ if (colCount == 1)
+ {
+ if (_warnings && sessObj.isWriteParams())
+ writer.writeln(_endWarnListTag);
+ if (sessObj.isSPJRS() && rowCount == 0 || (sessObj.isInOutandRS()))
+ {
+ writer.write( _beginResultSetIdTag + (qryObj.getRsCount()+1) + _endAttributeTag + SessionDefaults.lineSeperator);
+ sessObj.setInOutandRS(false);
+ }
+ writer.write(_beginRowTag + (rowCount+1) + _endAttributeTag + SessionDefaults.lineSeperator);
+
+ }
+ writer.write(" <"+columnName+">"+utilObj.formatXMLdata(output.trim())+"</"+columnName+">");
+
+ if (qryObj.getColCount() != null)
+ {
+ colCount++;
+ if (colCount > Integer.parseInt(qryObj.getColCount()))
+ {
+ writer.write(SessionDefaults.lineSeperator+_endRowTag);
+ rowCount++;
+ colCount=1;
+ }
+ }
+ }
+ }
+
+ public void handleStartTags() throws IOException
+ {
+ if (!_beginRootElement)
+ {
+ if (sessObj.getISOMapping() == 10)
+ {
+ encodingTag = "encoding=\"" + "Shift_JIS"+ "\"";
+ _xmlNameSpaceTag = "<?xml version=\"1.0\" " + encodingTag + "?>";
+ }
+ else
+ {
+ _xmlNameSpaceTag = "<?xml version=\"1.0\"?>";
+ }
+
+ writer.writeln(_xmlNameSpaceTag);
+ writer.writeln(_beginRootTag);
+
+ if (qryObj.getQueryText() != null)
+ {
+ writer.writeln(_beginQueryTag);
+
+ if (sessObj.isSPJRS() && qryObj.getRowCount() == "0")
+ qryObj.resetQueryText(sessObj.getDbQryObj().qryText);
+
+ //Escape "]]>" if it appears within QueryText
+ writer.writeln(" " + _beginCdataTag + sessObj.getQuery().getQueryText().replaceAll(_endCdataTag.trim(), _endCdataTagEscaped)+ _endCdataTag);
+ writer.writeln(_endQueryTag);
+
+ if (qryObj.isTrimOut())
+ writer.writeln(" " + _beginCdataTag);
+
+ if (sessObj.isSPJRS() && qryObj.getRsCount() > 0)
+ {
+ writer.writeln(" " + _beginResultSetTag);
+ qryObj.resetQueryText("SELECT *");
+ }
+ }
+
+ _beginRootElement = true;
+ }
+
+ }
+
+ public void handleEndTags() throws IOException
+ {
+ if (_initDone)
+ {
+ if (_errors)
+ writer.writeln(_endErrorListTag);
+
+ if (sessObj.isSPJRS())
+ {
+ writer.write(SessionDefaults.lineSeperator+_endResultSetTag);
+ }
+ else
+ {
+ if (!(sessObj.isImplicitGetStatsQry())) {
+ writer.write(_endRootTag+SessionDefaults.lineSeperator);
+ _beginRootElement = false;
+ }
+ }
+
+ _errors = false;
+ _warnings = false;
+ errorCount = 0;
+ rowCount = 0;
+ colCount = 1;
+ _initDone = false;
+ sessObj.setWriteParams(false);
+ }
+ }
+
+ public void handleErrors(ErrorObject errorObj) throws IOException
+ {
+ if (errorObj != null)
+ {
+ if (!_initDone)
+ {
+ this.init();
+ }
+
+ boolean notBegin=false;
+ if(notBegin = !_beginRootElement)
+ {
+ this.handleStartTags();
+ }
+
+ if (errorObj.errorCode() == Parser.UNKNOWN_ERROR_CODE)
+ {
+ writeServerMessage(errorObj);
+ }
+ else if(errorObj.errorType == 'I')
+ {
+ writeInformational(errorObj);
+ }
+ else if(errorObj.errorType == 'W')
+ {
+ handleWarnings(errorObj);
+ }
+ else
+ {
+ if (notBegin)
+ {
+ writer.writeln(_beginErrorListTag);
+ _errors = true;
+ }
+ writeErrors(errorObj);
+ }
+ }
+ }
+ public void writeServerMessage(ErrorObject errorObj) throws IOException
+ {
+ String escapedErrorMessage = errorObj.errorMessage().replaceAll(_endCdataTag.trim(), _endCdataTagEscaped);
+ //escape any instance of the substring "]]>" that appears in errorStr. It is escaped by replacing it with the _endCdataTagEscaped string.
+ writer.writeln(_beginCdataTag + escapedErrorMessage + _endCdataTag);
+ }
+ public void writeInformational(ErrorObject errorObj) throws IOException
+ {
+ String escapedErrorMessage = errorObj.errorMessage().replaceAll(_endCdataTag.trim(), _endCdataTagEscaped);
+ // writer.writeln(_beginMessageCodeTag + errorObj.errorCode() + _endMessageCodeTag);
+ //escape any instance of the substring "]]>" that appears in errorStr. It is escaped by replacing it with the _endCdataTagEscaped string.
+ writer.writeln(_beginMessageMsgTag + _beginCdataTag + escapedErrorMessage + _endCdataTag + _endMessageMsgTag);
+ }
+
+ public void writeErrors(ErrorObject errorObj) throws IOException
+ {
+ String escapedErrorMessage = errorObj.errorMessage().replaceAll(_endCdataTag.trim(), _endCdataTagEscaped);
+ writer.write(_beginErrorCountTag + ++errorCount + _endAttributeTag + SessionDefaults.lineSeperator );
+ writer.writeln(_beginErrorCodeTag + errorObj.errorCode() + _endErrorCodeTag);
+
+ //escape any instance of the substring "]]>" that appears in errorStr. It is escaped by replacing it with the _endCdataTagEscaped string.
+ writer.writeln(_beginErrorMsgTag + _beginCdataTag + escapedErrorMessage + _endCdataTag + _endErrorMsgTag);
+ writer.writeln(_endErrorCountTag);
+ }
+ //dead code. Removed by Kevin Xu
+/*
+ public void writeWarnings(ErrorObject errorObj) throws IOException
+ {
+ String escapedErrorMessage = errorObj.errorMessage().replaceAll(_endCdataTag.trim(), _endCdataTagEscaped);
+ writer.write(_beginErrorCountTag + ++errorCount + _endAttributeTag + SessionDefaults.lineSeperator );
+ writer.writeln(_beginErrorCodeTag + errorObj.errorCode() + _endErrorCodeTag);
+
+ //escape any instance of the substring "]]>" that appears in errorStr. It is escaped by replacing it with the _endCdataTagEscaped string.
+ writer.writeln(_beginErrorMsgTag + _beginCdataTag + escapedErrorMessage + _endCdataTag + _endErrorMsgTag);
+ writer.writeln(_endErrorCountTag);
+ }
+*/
+ /**
+ * Method to print a top level xml tag below the root element of the
+ * marked up xml document.
+ */
+ private void printTopLevelXMLTag(String theTag) throws IOException {
+ /* Check if we need to do the initialization. */
+ if (!_initDone)
+ this.init();
+
+ /* Check if we need to setup and create the tags. */
+ if (!_beginRootElement)
+ this.handleStartTags();
+
+
+ if ((null != theTag) && (0 < theTag.length() ) )
+ writer.writeln(theTag);
+
+ } /* End of printTopLevelXMLTag method. */
+
+
+
+ /**
+ * Method to print the warning list start tag for all warnings
+ * encountered during a fetch operation.
+ */
+ public void startFetchWarningListTag() throws IOException {
+ printTopLevelXMLTag(_beginWarnListTag);
+
+ } /* End of startFetchWarningListTag method. */
+
+
+
+ /**
+ * Method to print the warning list end tag for all warnings
+ * encountered during a fetch operation.
+ */
+ public void endFetchWarningListTag() throws IOException {
+ printTopLevelXMLTag(_endWarnListTag);
+
+ } /* End of endFetchWarningListTag method. */
+
+
+
+ /**
+ * Method to print warnings encountered during a fetch operation. These
+ * warnings need to printed in a separate warning list within the scope
+ * of the fetch.
+ * Oh, this whole xml/html markup piece is so very messy!! :^(
+ */
+ public void handleFetchWarnings(ErrorObject errorObj) throws IOException {
+ /* Check if we need to do the initialization. */
+ if (!_initDone)
+ this.init();
+
+ /* Check if we need to setup and create the tags. */
+ if (!_beginRootElement)
+ this.handleStartTags();
+
+
+ if (errorObj != null) {
+ writer.writeln(_beginWarnCountTag + ++errorCount + _endAttributeTag);
+ writer.writeln(_beginWarnCodeTag + errorObj.errorCode() +
+ _endWarnCodeTag);
+ writer.writeln(_beginWarnMsgTag + errorObj.errorMessage() +
+ _endWarnMsgTag);
+ writer.writeln(_endWarnCountTag);
+ }
+
+ } /* End of handleFetchWarnings method. */
+
+ public void handleWarnings(ErrorObject errorObj) throws IOException
+ {
+ if (!_initDone)
+ {
+ this.init();
+ //_initDone = true;
+ }
+
+ if (!_beginRootElement)
+ {
+ this.handleStartTags();
+ writer.writeln(_beginWarnListTag);
+ _warnings = true;
+ }
+
+ if (errorObj != null)
+ {
+ writer.write(_beginWarnCountTag + ++errorCount + _endAttributeTag + SessionDefaults.lineSeperator );
+ writer.writeln(_beginWarnCodeTag + errorObj.errorCode() + _endWarnCodeTag);
+ writer.writeln(_beginWarnMsgTag + errorObj.errorMessage() + _endWarnMsgTag);
+ writer.writeln(_endWarnCountTag);
+ }
+ }
+
+ public void handlePrunSummary(ConsoleWriter cWriter, PrunSummary summaryObj,String elapsedTime) throws IOException
+ {
+ this.init();
+ this.handleStartTags();
+ cWriter.println(_beginCdataTag);
+ cWriter.println(" " + SessionDefaults.lineSeperator+"PARALLELRUN(PRUN) SUMMARY");
+ cWriter.println(_endCdataTag);
+ cWriter.println("<Summary>");
+ cWriter.println(" <TotalFilesPresent>" + summaryObj.getTotalScriptFiles() + "</TotalFilesPresent>");
+ cWriter.println(" <TotalFilesProcessed>" + summaryObj.getTotalScriptFilesProcessed() + "</TotalFilesProcessed>");
+ cWriter.println(" <TotalQueriesProcessed>" + summaryObj.getTotalSQLsProcessed() + "</TotalQueriesProcessed>");
+ cWriter.println(" <TotalErrors>" + summaryObj.getTotalSQLErrors() + "</TotalErrors>");
+ cWriter.println(" <TotalWarnings>" + summaryObj.getTotalSQLWarnings() + "</TotalWarnings>");
+ cWriter.println(" <TotalSuccesses>" + summaryObj.getTotalSQLSuccess() + "</TotalSuccesses>");
+ cWriter.println(" <TotalConnections>" + summaryObj.getTotalConnections() + "</TotalConnections>");
+ cWriter.println(" <TotalConnectionFailures>" + summaryObj.getTotalConnectionFailures() + "</TotalConnectionFailures>");
+ if (sessObj.isSessionTimingOn())
+ cWriter.println(" <ElapsedTime>" + elapsedTime.trim() + "</ElapsedTime>");
+ cWriter.println("</Summary>");
+
+ //reset _initDone to false since it is automatically set to true in this.init();
+ _initDone = false;
+ }
+
+ public void handlePrunSummary(FileWriter fWriter, PrunSummary summaryObj, String summaryEnd, String elapsedTime) throws IOException
+ {
+
+ fWriter.writeln(_beginCdataTag + "PARALLELRUN(PRUN) SUMMARY" + _endCdataTag);
+ fWriter.writeln("<Summary>");
+ fWriter.writeln(" <TotalFilesPresent>" + summaryObj.getTotalScriptFiles() + "</TotalFilesPresent>");
+ fWriter.writeln(" <TotalFilesProcessed>" + summaryObj.getTotalScriptFilesProcessed() + "</TotalFilesProcessed>");
+ fWriter.writeln(" <TotalQueriesProcessed>" + summaryObj.getTotalSQLsProcessed() + "</TotalQueriesProcessed>");
+ fWriter.writeln(" <TotalErrors>" + summaryObj.getTotalSQLErrors() + "</TotalErrors>");
+ fWriter.writeln(" <TotalWarnings>" + summaryObj.getTotalSQLWarnings() + "</TotalWarnings>");
+ fWriter.writeln(" <TotalSuccesses>" + summaryObj.getTotalSQLSuccess() + "</TotalSuccesses>");
+ fWriter.writeln(" <TotalConnections>" + summaryObj.getTotalConnections() + "</TotalConnections>");
+ fWriter.writeln(" <TotalConnectionFailures>" + summaryObj.getTotalConnectionFailures() + "</TotalConnectionFailures>");
+ fWriter.writeln("</Summary>");
+ fWriter.writeln(_beginCdataTag + summaryEnd + _endCdataTag);
+ if (sessObj.isSessionTimingOn())
+ fWriter.writeln(_beginCdataTag + elapsedTime.trim() + _endCdataTag);
+ fWriter.writeln(_endRootTag);
+ this._initDone = false;
+ }
+
+ public void handleQryExecutionTime(String qryExecTime) throws IOException
+ {
+
+ if (!_initDone)
+ {
+ this.init();
+ this.handleStartTags();
+ //_initDone = true;
+ }
+ writer.write(_beginExecutionTimeTag + _beginCdataTag + qryExecTime + _endCdataTag + _endExecutionTimeTag +SessionDefaults.lineSeperator);
+ }
+
+ public String checkColumnNames(String colHeader)
+ {
+ String colName = null;
+ String xmlColHeader = colHeader;
+ if (xmlColHeader.startsWith("(", 0) && xmlColHeader.endsWith(")"))
+ colName = xmlColHeader.substring(1, xmlColHeader.length()-1);
+ else
+ colName = colHeader;
+ return colName;
+ }
+
+ public void printGetStatsOutput(String line) throws IOException
+ {
+ int i=0;
+ String columnNameTag = "";
+ String columnData = null;
+
+ if (line.trim().equals(""))
+ return;
+
+ if (line.startsWith("Table Name") || line.startsWith("Id"))
+ {
+ writer.writeln(" " + _beginCdataTag);
+ writer.writeln(" " + line);
+ perTableStats = true;
+ return;
+ }
+ String outputArr[] = line.split(" ");
+ for (i=0;i<outputArr.length; i++)
+ {
+ if (!outputArr[i].matches("^(\\-[0-9]|[0-9]|\\\\|NONE|CLOSE|SQL_|MX|PERTABLE|ACCUMULATED|PROGRESS|DEFAULT|OPERATOR|DEALLOCATED|select).*"))
+ columnNameTag += outputArr[i];
+ else
+ break;
+ }
+
+ for (int j=Math.max(0,(i-1));j<outputArr.length; j++)
+ {
+ if (!outputArr[j].trim().equals(""))
+ {
+ if (columnData == null)
+ columnData = outputArr[j];
+ else
+ columnData+=" " + outputArr[j];
+ }
+ }
+
+ String xmlColTag = "Missing_tag";
+ if (null != columnNameTag && 0 < columnNameTag.length())
+ xmlColTag = checkColumnNames(columnNameTag);
+
+ if (columnData!= null)
+ writer.write("<"+xmlColTag+">"+utilObj.formatXMLdata(columnData.trim())+"</"+xmlColTag+">");
+
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/main/java/org/trafodion/ci/help/common_common.help
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/main/java/org/trafodion/ci/help/common_common.help b/core/conn/trafci/src/main/java/org/trafodion/ci/help/common_common.help
new file mode 100644
index 0000000..697cc3e
--- /dev/null
+++ b/core/conn/trafci/src/main/java/org/trafodion/ci/help/common_common.help
@@ -0,0 +1,457 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+ @@@@@HELP
+
+ The command interface supports these commands:
+
+ @ LOG SHOW ALIAS
+ ALIAS OBEY SHOW ALIASES
+ CLEAR QUIT SHOW COLSEP
+ CONNECT RECONNECT SHOW ERRORCODE
+ DELAY REPEAT SHOW HISTOPT
+ DISCONNECT RESET LASTERROR SHOW IDLETIMEOUT
+ ENV SAVEHIST SHOW LASTERROR
+ EXIT SESSION (SHOW SESSION) SHOW MARKUP
+ SET COLSEP SHOW REMOTEPROCESS
+ FC SET CONNECTOPT ROLE SHOW ROLE
+ GOTO SET HISTOPT SHOW SESSION
+ HELP SET IDLETIMEOUT SHOW TIME
+ HISTORY SET MARKUP SHOW TIMING
+ IF...THEN SET PROMPT SPOOL
+ LABEL SET TIME VERSION
+ LOCALHOST SET TIMING
+
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SET
+
+ The command interface supports these SET commands:
+
+ SET COLSEP SET IDLETIMEOUT SET TIME
+ SET CONNECTOPT ROLE SET MARKUP SET TIMING
+ SET HISTOPT SET PROMPT
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SHOW
+
+ The command interface supports these SHOW commands:
+
+ SHOW ALIAS SHOW IDLETIMEOUT SHOW SESSION
+ SHOW ALIASES SHOW LASTERROR SHOW TIME
+ SHOW COLSEP SHOW MARKUP SHOW TIMING
+ SHOW ERRORCODE SHOW REMOTEPROCESS
+ SHOW HISTOPT SHOW ROLE
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@@
+
+ The @ command executes the SQL statements and interface commands contained
+ in a specified script file. The @ command is executed the same as the OBEY
+ command.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@ALIAS
+
+ The ALIAS command allows you to map a string to any interface or SQL
+ command. The syntax of the interface or SQL command is checked only on
+ execution of the mapped string. This command replaces only the first token
+ of a command string, which allows the rest of the tokens to be treated as
+ parameters.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@CLEAR
+
+ The CLEAR command clears the interface window so that only the prompt
+ appears at the top of the window. CLEAR does not clear the log file or
+ reset the settings of the session.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@CONNECT
+
+ The CONNECT command creates a new connection to the Trafodion platform from
+ the current or existing Command Interface session.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@DELAY
+
+ The DELAY command allows the Command Interface session to be in sleep
+ mode for the specified interval.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@DISCONNECT
+
+ The DISCONNECT command terminates the connection from the Trafodion
+ platform, not from the Command Interface.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@ENV
+
+ ENV displays attributes of the current Command Interface session. You
+ can also use the SESSION and SHOW SESSION commands to perform the same
+ function.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@EXIT
+
+ The EXIT command disconnects from and exits the Command Interface.
+ EXIT can return a status code. If no status code is specified, zero is
+ returned by default. In addition, a conditional statement can be appended
+ to the command.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@FC
+
+ The FC command allows you to edit and reissue a command in the history
+ buffer of a Command Interface session. You can display the commands
+ in the history buffer by using the HISTORY command.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@GOTO
+
+ The GOTO command allows you to jump to a designated point in the command
+ history. The point in the command history is designated by a LABEL
+ command. All commands executed after a GOTO statement are ignored until
+ the specified label is set. To set a label, use the LABEL command.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@HISTORY
+
+ The HISTORY command displays recently executed commands, identifying each
+ command by a number that you can use to reexecute or edit the command.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@IF...THEN
+
+ IF...THEN statements allow for the conditional execution of actions. If
+ the condition is met, the action is executed; otherwise, no action is
+ taken.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@LABEL
+
+ The LABEL command marks a point in the command history that you can jump
+ to by using the GOTO command.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@LOCALHOST
+
+ The LOCALHOST command allows you to execute client machine commands.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@LOG
+
+ The LOG command logs the entered commands and their output from the
+ Command Interface to a log file. If this is an obey script file, then
+ the command text from the obey script file is shown on the console.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@MODE
+
+ This command is no longer supported in TRAFCI.
+
+ @@@@@OBEY
+
+ The OBEY command executes the SQL statements and interface commands of a
+ specified script file or an entire directory. This command accepts a
+ single filename or a filename with a wild-card pattern specified.
+ Executing the OBEY command without optional parameters prompts you to
+ enter a filename. If a filename is not specified, then *.sql is used.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@QUIT
+
+ The QUIT command disconnects from and exits the Command Interface.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@RECONNECT
+
+ The RECONNECT command creates a new connection to the Trafodion platform
+ using the login credentials of the last successful connection.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@REPEAT
+
+ The REPEAT command reexecutes a previous command.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@RESET LASTERROR
+
+ The RESET LASTERROR command resets the last error code to 0.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SAVEHIST
+
+ The SAVEHIST command saves the session history in a user-specified file.
+ The session history consists of a list of the commands that were executed
+ in the Command Interface session before the SAVEHIST command.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SET COLSEP
+
+ The SET COLSEP command sets the column separator and allows you to control
+ the formatting of the result displayed for SQL queries. The SET COLSEP
+ command specifies a delimiter value to use for separating columns in each
+ row of the results. The default delimiter is " "(white space).
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SET CONNECTOPT ROLE
+
+ The SET CONNECTOPT ROLE command changes the role during a Command Interface
+ session.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SET HISTOPT
+
+ The SET HISTOPT command sets the history option and controls how commands
+ are added to the history buffer. By default, commands within a script file
+ are not added to history. If the history option is set to "ALL," all the
+ commands in the script file are added to the history buffer. If no options
+ are specified, DEFAULT is used.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SET IDLETIMEOUT
+
+ The SET IDLETIMEOUT command sets the idle timeout value for the current
+ session. The idle timeout value of a session determines when the session
+ expires after a period of inactivity. The default is 30 minutes.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SET MARKUP
+
+ The SET MARKUP command sets the markup format and controls how results are
+ displayed by the Command Interface.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SET PROMPT
+
+ The SET PROMPT command sets the prompt of the current session to a
+ specified string and/or to the session variables, which start with %. The
+ default prompt is SQL> in SQL mode.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SET TIME
+
+ The SET TIME command causes the local time of the client workstation to be
+ displayed as part of the interface prompt. By default, the local time is
+ not displayed in the interface prompt.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SET TIMING
+
+ The SET TIMING command causes the elapsed time to be displayed after each
+ SQL statement executes. This command does not cause the elapsed time of
+ interface commands to be displayed. By default, the elapsed time is off.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SHOW ALIAS
+
+ The SHOW ALIAS command displays all or a set of aliases available in the
+ current Command Interface session. If a pattern is specified, all aliases
+ matching the pattern are displayed. By default, all aliases in the current
+ session are displayed.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SHOW ALIASES
+
+ The SHOW ALIASES command displays all the aliases available in the current
+ Command Interface session.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SHOW COLSEP
+
+ The SHOW COLSEP command displays the value of the column separator for the
+ current Command Interface session.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SHOW ERRORCODE
+
+ The SHOW ERRORCODE command is an alias for the SHOW LASTERROR command.
+ ERRORCODE is an alias for LASTERROR.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SHOW HISTOPT
+
+ The SHOW HISTOPT command displays the value that has been set for the
+ history option.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SHOW IDLETIMEOUT
+
+ The SHOW IDLETIMEOUT command displays the idle timeout value of the
+ current Command Interface session. The idle timeout value of a session
+ determines when the session expires after a period of inactivity.
+ The default is 30 minutes.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SHOW LASTERROR
+
+ The SHOW LASTERROR command displays the error of the last SQL statement
+ that was executed. If the query was successful, 0 is returned; otherwise
+ an SQL error code is returned.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SHOW MARKUP
+
+ The SHOW MARKUP command displays the value set for the markup option.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SHOW MODE
+
+ This command is no longer supported in TRAFCI.
+
+ @@@@@SHOW REMOTEPROCESS
+
+ The SHOW REMOTEPROCESS command displays the process name of the DCS
+ server that is handling the current connection.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SHOW ROLE
+
+ The SHOW ROLE command displays the role in which you are currently logged
+ on during an TRAFCI session.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SHOW SESSION & SESSION
+
+ SHOW SESSION or SESSION displays attributes of the current Command
+ Interface session. You can also use the ENV command to perform the
+ same function.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SHOW TIME
+
+ The SHOW TIME command displays whether the setting for the local time in
+ the interface prompt is ON or OFF.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SHOW TIMING
+
+ The SHOW TIMING command displays whether the setting for the elapsed time
+ is ON or OFF.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@SPOOL
+
+ The SPOOL command logs the entered commands and their output from the
+ Command Interface to a log file.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
+
+ @@@@@VERSION
+
+ The VERSION command displays the build versions of the Trafodion platform,
+ Trafodion Connectivity Services, Trafodion JDBC Type 4 Driver, and Command
+ Interface.
+
+ For more information, see the Trafodion Command Interface
+ (TRAFCI) Guide.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/main/java/org/trafodion/ci/help/help_file.idx
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/main/java/org/trafodion/ci/help/help_file.idx b/core/conn/trafci/src/main/java/org/trafodion/ci/help/help_file.idx
new file mode 100644
index 0000000..035ccbd
--- /dev/null
+++ b/core/conn/trafci/src/main/java/org/trafodion/ci/help/help_file.idx
@@ -0,0 +1,30 @@
+# @@@ START COPYRIGHT @@@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# @@@ END COPYRIGHT @@@
+
+###########################################################
+## This is the main index file for all other help files. ##
+###########################################################
+
+#Common Commands
+common:common = common_common_help.idx
+
+#Mode SQL
+sql:common = sql_common_help.idx