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:48 UTC

[21/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/installer_pom.xml
----------------------------------------------------------------------
diff --git a/core/conn/trafci/installer_pom.xml b/core/conn/trafci/installer_pom.xml
new file mode 100644
index 0000000..650c4c2
--- /dev/null
+++ b/core/conn/trafci/installer_pom.xml
@@ -0,0 +1,86 @@
+<!-- @@@ START COPYRIGHT @@@ (C) Copyright 2015 Esgyn Corporation @@@ END 
+	COPYRIGHT @@@ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.trafodion</groupId>
+	<artifactId>trafciInstaller</artifactId>
+	<packaging>jar</packaging>
+	<version>2.2.0</version>
+	<name>Trafodion Trafci</name>
+	<properties>
+		<basedir>.</basedir>
+		<traf-jdbc-version>${env.TRAFODION_VER}</traf-jdbc-version>
+		<trafci-version>${env.TRAFODION_VER}</trafci-version>
+	</properties>
+	<build>
+		<finalName>trafciInstaller</finalName>
+		<sourceDirectory>install</sourceDirectory>
+		<resources>
+			<resource>
+				<directory>${basedir}/src/main/resources</directory>
+				<excludes>
+					<exclude>install_jar.xml</exclude>
+					<exclude>install_tar.xml</exclude>
+				</excludes>
+			</resource>
+		</resources>
+		<outputDirectory>target/installer-classes</outputDirectory>
+		<plugins>
+			<plugin>
+				<artifactId>maven-antrun-plugin</artifactId>
+				<version>1.8</version>
+				<executions>
+					<execution>
+						<phase>generate-sources</phase>
+						<configuration>
+							<target>
+								<copy file="${basedir}/utils/trafci.cmd-tmpl" tofile="${basedir}/utils/trafci.cmd"
+									overwrite="true"></copy>
+								<copy file="${basedir}/utils/trafci.sh-tmpl" tofile="${basedir}/utils/trafci.sh"
+									overwrite="true">
+								</copy>
+								<echo message="BUILD trafodion prod version ${env.TRAFODION_VER_PROD}" />
+								<replace file="${basedir}/utils/trafci.cmd" token="@prodver@"
+									value="${env.TRAFODION_VER_PROD}" />
+								<replace file="${basedir}/utils/trafci.cmd" token="@copyrighthdr@"
+									value="${env.PRODUCT_COPYRIGHT_HEADER}" />
+								<replace file="${basedir}/utils/trafci.sh" token="##prodver##"
+									value="${env.TRAFODION_VER_PROD}" />
+								<replace file="${basedir}/utils/trafci.sh" token="##copyrighthdr##"
+									value="${env.PRODUCT_COPYRIGHT_HEADER}" />
+							</target>
+						</configuration>
+						<goals>
+							<goal>run</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<artifactId>maven-assembly-plugin</artifactId>
+				<configuration>
+					<appendAssemblyId>false</appendAssemblyId>
+					<descriptors>
+						<descriptor>src/main/resources/install_jar.xml</descriptor>
+						<descriptor>src/main/resources/install_tar.xml</descriptor>
+					</descriptors>
+					<archive>
+						<manifest>
+							<mainClass>Installer</mainClass>
+						</manifest>
+					</archive>
+				</configuration>
+				<executions>
+					<execution>
+						<id>make-assembly</id>
+						<phase>package</phase>
+						<goals>
+							<goal>single</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/pom.xml
----------------------------------------------------------------------
diff --git a/core/conn/trafci/pom.xml b/core/conn/trafci/pom.xml
new file mode 100644
index 0000000..159b2c6
--- /dev/null
+++ b/core/conn/trafci/pom.xml
@@ -0,0 +1,97 @@
+<!-- @@@ START COPYRIGHT @@@ (C) Copyright 2015 Esgyn Corporation @@@ END 
+	COPYRIGHT @@@ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.trafodion</groupId>
+	<artifactId>trafci</artifactId>
+	<packaging>jar</packaging>
+	<version>2.2.0</version>
+	<name>Trafodion Trafci</name>
+	<properties>
+		<jettyVersion>9.2.6.v20141205</jettyVersion>
+		<env.TRAFODION_VER>2.2.0</env.TRAFODION_VER>
+		<traf-jdbc-version>${env.TRAFODION_VER}</traf-jdbc-version>
+		<trafci-version>${env.TRAFODION_VER}</trafci-version>
+	</properties>
+	<dependencies>
+		<dependency>
+			<groupId>org.trafodion.jdbc.t4</groupId>
+			<artifactId>jdbcT4</artifactId>
+			<version>${traf-jdbc-version}</version>
+		</dependency>
+	</dependencies>
+	<build>
+		<finalName>trafci</finalName>
+		<resources>
+			<resource>
+				<directory>${basedir}/src/main/java</directory>
+				<includes>
+					<include>**/*.idx</include>
+					<include>**/*.help</include>
+					<include>**/*.properties</include>
+				</includes>
+			</resource>
+			<resource>
+				<directory>${basedir}/src/main/resources</directory>
+				<excludes>
+					<exclude>install_jar.xml</exclude>
+					<exclude>install_tar.xml</exclude>
+				</excludes>
+			</resource>
+			<!-- <resource><directory>${basedir}/src/main/java/org/trafodion/ci/help</directory></resource> -->
+		</resources>
+		<plugins>
+			<plugin>
+				<artifactId>maven-antrun-plugin</artifactId>
+				<version>1.8</version>
+				<executions>
+					<execution>
+						<phase>generate-sources</phase>
+						<configuration>
+							<target>
+							<property name="vproc.version" value="TrafCI_Build_${bldId}"/>
+							<property name="vproc.dir" value="${basedir}/src/main/java/org/trafodion/ci"/>
+							<property name="Install.dir" value="${basedir}/install"/>
+								<copy file="${vproc.dir}/Vproc.java-tmpl" tofile="${vproc.dir}/Vproc.java"
+									overwrite="true"></copy>
+								<copy file="${Install.dir}/Installer.java-tmpl" tofile="${Install.dir}/Installer.java"
+									overwrite="true"></copy>
+								<echo message="BUILD Vproc version ${vproc.version}" />
+								<replace file="${vproc.dir}/Vproc.java" token="@@@"
+									value="${vproc.version}" />
+								<replace file="${Install.dir}/Installer.java"
+									token="@@@VPROC@@@" value="${vproc.version}" />
+							</target>
+						</configuration>
+						<goals>
+							<goal>run</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<version>3.5.1</version>
+				<configuration>
+					<source>1.7</source>
+					<target>1.7</target>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-jar-plugin</artifactId>
+				<version>2.3.1</version>
+				<configuration>
+					<archive>
+						<manifest>
+							<mainClass>org/trafodion/ci/Vproc</mainClass>
+						</manifest>
+					</archive>
+					<outputDirectory>${basedir}/lib</outputDirectory>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/main/java/org/trafodion/ci/AWTExceptionHandler.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/main/java/org/trafodion/ci/AWTExceptionHandler.java b/core/conn/trafci/src/main/java/org/trafodion/ci/AWTExceptionHandler.java
new file mode 100644
index 0000000..eceaada
--- /dev/null
+++ b/core/conn/trafci/src/main/java/org/trafodion/ci/AWTExceptionHandler.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 AWTExceptionHandler{
+    
+    public AWTExceptionHandler(){
+    }
+    
+    public void handle(Throwable t)
+    { 
+        if(Boolean.getBoolean("trafci.enableTrace"))
+        {
+            System.out.println("TrafCI Captured AWT Stack Trace:");
+            t.printStackTrace();
+        }
+    } 
+}  

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/main/java/org/trafodion/ci/CSVDisplay.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/main/java/org/trafodion/ci/CSVDisplay.java b/core/conn/trafci/src/main/java/org/trafodion/ci/CSVDisplay.java
new file mode 100644
index 0000000..2db7575
--- /dev/null
+++ b/core/conn/trafci/src/main/java/org/trafodion/ci/CSVDisplay.java
@@ -0,0 +1,90 @@
+// @@@ 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 CSVDisplay implements IDisplay {
+
+	private Query qryObj;
+	private Writer writer=null;
+	private Session sessObj=null;
+	private int colCount=1;
+	
+	public CSVDisplay(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 contents
+			ArrayList<OutputColumnAttribute> columns = contents.getColumns();
+			ArrayList<ArrayList<String>> alRows = contents.getRows();
+			qryObj.setColCount(String.valueOf(columns.size()));
+			
+			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++)
+						{
+							writer.write(alRow.get(j));
+				            if (qryObj.getColCount() != null)
+				            {
+				               if (colCount == Integer.parseInt(qryObj.getColCount()))
+				               {
+				                  writer.write(SessionDefaults.lineSeperator);
+				                  colCount=1;
+				                  break;
+				               }
+				            }
+				            colCount++;
+				            if (sessObj.getStrDisplayFormat().equalsIgnoreCase("COLSEP"))
+				               writer.write(sessObj.getSessionColSep());
+				            else
+				               writer.write(",");
+				            //wrong code
+//				            break;
+						}
+					}
+					
+				}
+
+			}
+		}
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/main/java/org/trafodion/ci/Column.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/main/java/org/trafodion/ci/Column.java b/core/conn/trafci/src/main/java/org/trafodion/ci/Column.java
new file mode 100644
index 0000000..ac506a1
--- /dev/null
+++ b/core/conn/trafci/src/main/java/org/trafodion/ci/Column.java
@@ -0,0 +1,131 @@
+// @@@ 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 Column
+{
+
+   Column()
+   {
+   }
+
+   int maxColSize = 0;
+   int actualColValSize = 0;
+   int maxDisplayColSize = 0;
+   int currentIndexPos = 0;
+   String columnName = null;
+
+   boolean isColWrap = false;
+   boolean isLeftAligned = true;
+   boolean isDone = false;
+   boolean isTrim=false;
+   boolean isHeader = false;
+
+   String colVal = null;
+   String fillerStr = null;
+   char fillChar = ' ';
+
+   // This method set the length for each column
+   public void setLength (int maxColSize, int maxDisplayColSize)
+   {
+      this.maxColSize = maxColSize;
+      this.maxDisplayColSize = maxDisplayColSize;
+      //Set columns wrapped to true if metadata colsize is greater than display colsize
+      this.isColWrap = this.maxColSize >  this.maxDisplayColSize?true:false;
+      //If columns are wrapped then, set the maximum display size to be that set by the session object
+		if (!isColWrap)
+			this.maxDisplayColSize = this.maxColSize;
+
+      //this.maxDisplayColSize = this.isColWrap?this.maxDisplayColSize:this.maxColSize;
+   }
+
+   // This method sets the filler character of space for each column based on the data for each column
+   public void setFillChar(char fillChar)
+   {
+      StringBuffer fillBuf = new StringBuffer();
+
+      for (int i = 0; i < this.maxDisplayColSize; i++)
+      {
+         fillBuf.append(fillChar);
+      }
+
+      this.fillerStr = fillBuf.toString();
+      fillBuf = null;
+   }
+
+   // This method set the column value
+   public void setColValue(String colVal)
+   {
+      if (this.isTrim)
+      {
+         colVal= colVal.trim(); //Remove the extra blanks 
+      }
+      this.actualColValSize = colVal.length();
+      //if column data length is greater than meta data legth then substring it to metadata length
+      this.colVal = this.actualColValSize > this.maxColSize?colVal.substring(0, this.maxColSize):colVal;
+      this.currentIndexPos = 0;
+      this.isDone = false;
+      this.isHeader =false;
+   }
+
+   public String getColValue()
+   {
+
+      if (isDone)
+         return this.fillerStr;
+
+      if (!this.isColWrap)
+      {
+         isDone = true;
+
+         if (this.isLeftAligned || this.isHeader)
+            return this.colVal.substring(this.currentIndexPos)+this.fillerStr.substring(this.colVal.substring(this.currentIndexPos).length(),this.maxDisplayColSize);
+         else
+            return this.fillerStr.substring(this.colVal.substring(this.currentIndexPos).length(),this.maxDisplayColSize)+this.colVal.substring(this.currentIndexPos);
+      }
+
+      if (currentIndexPos + this.maxDisplayColSize <= this.actualColValSize)
+      {
+         this.currentIndexPos += this.maxDisplayColSize;
+         return this.colVal.substring(this.currentIndexPos - this.maxDisplayColSize,this.currentIndexPos);
+      }
+      isDone = true;
+      if (this.isLeftAligned || this.isHeader)
+         return this.colVal.substring(this.currentIndexPos)+this.fillerStr.substring(this.colVal.substring(this.currentIndexPos).length(),this.maxDisplayColSize);
+      else
+         return this.fillerStr.substring(this.colVal.substring(this.currentIndexPos).length(),this.maxDisplayColSize)+this.colVal.substring(this.currentIndexPos);
+   }
+
+   public void setLeftAligned(boolean isLeftAligned)
+   {
+      this.isLeftAligned = isLeftAligned;
+   }
+
+   public boolean isDone()
+   {
+      return this.isDone;
+   }
+
+   public void setTrim(boolean isTrim)
+   {
+      this.isTrim=isTrim;
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/main/java/org/trafodion/ci/ConditionalQuery.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/main/java/org/trafodion/ci/ConditionalQuery.java b/core/conn/trafci/src/main/java/org/trafodion/ci/ConditionalQuery.java
new file mode 100644
index 0000000..fba85ba
--- /dev/null
+++ b/core/conn/trafci/src/main/java/org/trafodion/ci/ConditionalQuery.java
@@ -0,0 +1,435 @@
+// @@@ 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.HashMap;
+import java.util.regex.Pattern;
+
+public class ConditionalQuery extends QueryWrapper implements SessionDefaults{
+	
+	private HashMap<String, String> cqKeyMap = null;
+   	private String gotoLabel = "";				// the label we are waiting to see
+   	private int variableType = -1;
+	private int valueType = -1;
+	private String strPendingAction = null;
+   	
+   	/* types of values passed to conditional statements */
+   	private static final int VARIABLE = 0;
+   	private static final int STRING = 1;
+   	private static final int INTEGER = 2;
+   	/* enums not available in 1.4 :( */
+   	
+   	
+	/* Constructor */
+	public ConditionalQuery(){}
+	
+	public ConditionalQuery(Session sessObj){
+	    super(sessObj);
+	    cqKeyMap = new HashMap<String, String>();
+	    loadCqKeyWordMap();
+	}
+	
+	public void execute() throws ConditionalQueryException, UserInterruption, IOException
+	{
+		// reset error
+		cqe.setError(null);
+		
+		String label = null;
+		init();
+		isMultiLine = sessObj.getQuery().isMultiLine();
+		blankLiner = false;
+		readQuery();
+		blankLiner = true;
+		
+        // get the QueryId and directly process that command
+        switch (sessObj.getQuery().getQueryId())
+        {
+        	case IF_THEN:
+				if(!getGotoLabel().equals(""))
+					break;
+				
+				// reset types
+				valueType = -1;
+				variableType = -1;
+				
+				String variable = parser.getConditionalVariable(this.queryStr);
+				String operator = parser.getConditionalOperator(this.queryStr);
+				String value = parser.getConditionalValue(this.queryStr);
+				String action = parser.getConditionalAction(this.queryStr);
+				
+				if(variable == null || operator == null || value == null || action == null){
+					throw cqe;
+				}
+				
+				/* strip begin/end quotes and beginning % from variable */
+				variable = format(variable, true);
+				
+				if(variableType != STRING)
+				{
+					Object tmpObj = getValue(variable);
+					
+					if(tmpObj == null)
+					{
+						if(isInteger(variable))
+						{
+							variableType = INTEGER;
+						}
+						else
+						{
+							/* not a valid integer, must have been an unresolved variable */
+						    ErrorObject varNotFound = new ErrorObject(SessionError.VARIABLE_NOT_FOUND.errorCode(), 
+						                                              SessionError.VARIABLE_NOT_FOUND.errorMessage() + "'" + variable + "'.");
+							cqe.setError(varNotFound);
+							throw cqe;
+						}
+					}
+					else
+					{
+						variable = tmpObj.toString();
+						variableType = VARIABLE;
+					}
+					
+				}
+				
+				/* strip begin/end quotes and beginning % from value */
+				value = format(value, false);
+				
+				if(valueType != STRING)
+				{
+					Object tmpObj = getValue(value);
+					
+					if(tmpObj == null)
+					{
+						if(isInteger(value))
+							valueType = INTEGER;
+						else
+						{
+							/* not a valid integer, must have been an unresolved variable */
+						    ErrorObject varNotFound = new ErrorObject(SessionError.VARIABLE_NOT_FOUND.errorCode(), 
+						                                              SessionError.VARIABLE_NOT_FOUND.errorMessage() + "'" + value + "'.");
+							cqe.setError(varNotFound);
+							throw cqe;
+						}
+					}
+					else
+					{
+						value = tmpObj.toString();
+						valueType = VARIABLE;
+					}
+				}
+				
+				if(compare(variable, operator, value))
+				{
+					/* condition passed, set pending action */
+					strPendingAction = action + sessObj.getSessionSQLTerminator();
+				}
+				else
+				{
+					/* condition failed, do not set a pending action */
+					strPendingAction = null;
+				}
+				break;
+				
+			case GOTO:
+				if(!getGotoLabel().equals(""))
+					break;
+				
+				parser.getNextKeyToken(); // skip first token
+				label = parser.getNextValueToken();
+                
+				if(parser.hasMoreTokens())
+                    writeSyntaxError(this.queryStr,parser.getRemainderStr());
+                else
+                {
+    				if(label != null){
+    					setGotoLabel(label);
+                        writer.writeln();
+                        
+                        ErrorObject goto_msg = new ErrorObject(SessionError.GOTO_MESSAGE.errorCode(), 
+												SessionError.GOTO_MESSAGE.errorMessage() + label + "'command is encountered.",SessionError.GOTO_MESSAGE.errorType);
+                        writer.writeError(sessObj, goto_msg);
+                        
+    				}else
+    				    writeSyntaxError(this.queryStr,parser.getRemainderStr());
+                }
+                
+				break;
+				
+			case LABEL:
+				parser.getNextKeyToken(); // skip first token
+				label = parser.getNextValueToken();
+				
+				if(parser.hasMoreTokens())
+				    writeSyntaxError(this.queryStr,parser.getRemainderStr());
+				else
+				{
+    				if(label != null)
+    				{
+    				    if(label.equals(getGotoLabel())){
+    				        writer.writeln();
+                            writer.writeError(sessObj, SessionError.MATCHING_LABEL);
+    				        setGotoLabel("");
+    				    }
+    				}else if(getGotoLabel().equals(""))
+    				    writeSyntaxError(this.queryStr,parser.getRemainderStr());
+    				else
+    				{
+                        /* give a warning */
+                        ErrorObject labelWarning = new ErrorObject(SessionError.LABEL_WARNING.errorCode(), 
+                                                                  SessionError.LABEL_WARNING.errorMessage(),'W');
+                        cqe.setError(labelWarning);
+                        throw cqe;
+    				}
+				}
+				
+				break;
+		}
+	}
+
+	// change throws UserInterruption to custom error
+	public Object getValue(String variable) throws ConditionalQueryException
+	{
+		/* get the variable's value */
+		Object variableValue = null;
+		
+		if(variable.startsWith("?"))
+		{
+			variableValue = sessObj.getSessParams(variable.substring(1));
+			if(variableValue == null)
+			{
+			    ErrorObject paramNotFound = new ErrorObject(SessionError.PARAM_NOT_FOUND.errorCode(), 
+			                                                SessionError.PARAM_NOT_FOUND.errorMessage() + variable + " was not found");
+				cqe.setError(paramNotFound);
+				throw cqe;
+			}
+		}
+		else
+		{
+			variableValue = sessObj.getEnv(variable);
+		}
+		
+		return variableValue;
+	}
+	public boolean compare(String variable, String operator, String value) throws ConditionalQueryException
+	{
+		int compareType = -1;
+		
+		if(valueType != variableType)
+		{
+			if(valueType == VARIABLE)
+				compareType = variableType;
+			else if(variableType == VARIABLE)
+				compareType = valueType;
+			else if(variableType == INTEGER && valueType == STRING ||
+						variableType == STRING && valueType == INTEGER)
+			{
+				if(variableType == STRING)
+					cqe.setError(SessionError.STR_INT_COMPARISON);
+				else
+					cqe.setError(SessionError.INT_STR_COMPARISON);
+				
+				throw cqe;
+			}
+		}
+		else{
+			/* if both are variables, see if both are integers, 
+			 * otherwise treat them as strings
+			 */
+			if(valueType == VARIABLE)
+			{
+				if(isInteger(variable) && isInteger(value))
+					valueType = INTEGER;
+				else
+					valueType = STRING;
+			}
+			compareType = valueType;
+		}
+		
+		switch(compareType){
+			case STRING:
+					if(operator.equals("=") || operator.equals("=="))
+					{
+						return variable.equals(value);	
+					}
+					else if(operator.equals("<>") || operator.equals("!=") || 
+					        operator.equals("~=") || operator.equals("^="))
+					{
+						return !variable.equals(value);
+					}
+					else
+					{
+						
+					    if(operator.equals("<") || operator.equals(">") || operator.equals("<=") ||  operator.equals(">="))
+					    {
+				             ErrorObject invalidStrComp = new ErrorObject(SessionError.INVALID_STRING_COMPARE.errorCode(), 
+                                                                         SessionError.INVALID_STRING_COMPARE.errorMessage() + "'" + operator + "'.");
+      
+					        cqe.setError(invalidStrComp);
+					    }
+					    
+					    // invalid operator exception
+						throw cqe;
+					}
+					/* break not necessary, this is unreachable */
+			case INTEGER:
+					try
+					{
+						if(!(isInteger(variable) && isInteger(value)))
+						{
+							if(isInteger(value))
+								cqe.setError(SessionError.STR_INT_COMPARISON);
+							else
+								cqe.setError(SessionError.INT_STR_COMPARISON);
+							
+							throw cqe;
+						}
+						else
+						{
+							
+							int variableInt = Integer.parseInt(variable);
+							int valueInt = Integer.parseInt(value);
+							
+							if(operator.equals("=") || operator.equals("=="))
+							{
+								return variableInt == valueInt;	
+							}
+							else if(operator.equals("<>") || operator.equals("!=") || 
+							        operator.equals("~=") || operator.equals("^="))
+							{
+								return variableInt != valueInt;
+							}
+							else if(operator.equals("<"))
+							{
+								return variableInt < valueInt;
+							}
+							else if(operator.equals(">"))
+							{
+								return variableInt > valueInt;
+							}
+							else if(operator.equals("<="))
+							{
+								return variableInt <= valueInt;
+							}
+							else if(operator.equals(">="))
+							{
+								return variableInt >= valueInt;
+							}
+							else
+							{
+								// invalid operator exception
+								throw cqe;
+							}
+						}
+					}
+					catch(NumberFormatException nfe)
+					{
+						// TODO: FIX ERROR
+						nfe.printStackTrace();
+					}
+					/* break not necessary, this is unreachable */
+		}
+		
+		return false;
+	}
+	
+	/* strip out beginning % and quotes */
+	private String format(String var, boolean isVariable)
+	{
+		String temp = var;
+		
+		if(var.startsWith("%"))
+			temp = var.substring(1, var.length());
+		
+		
+		if(temp.startsWith("\"") && temp.endsWith("\""))
+		{
+			if(temp.length() > 2)
+				temp = temp.substring(1, temp.length()-1);
+			else
+				temp = "";
+			
+			if(isVariable)
+				variableType = STRING;
+			else
+				valueType = STRING;
+		}
+		
+		return temp;
+	}
+	
+	private void loadCqKeyWordMap()
+	{
+		cqKeyMap.put("IF", ""+IF_THEN);
+		cqKeyMap.put("LABEL", ""+LABEL);
+		cqKeyMap.put("GOTO", ""+GOTO);
+	}
+	
+	public boolean isInteger(String str)
+	{
+		return Pattern.matches("^-?\\d+$",str); 
+	}
+	
+	
+	/* 
+     * repeated code from interface query, perhaps move out of IQ and make public somewhere else?
+     */
+    private void writeSyntaxError(String queryStr, String remainderStr) throws IOException
+    {
+        sessObj.getQuery().setStatusCode(-1); // update the error code to -1
+        
+        if(sessObj.getDisplayFormat() != SessionDefaults.XML_FORMAT)
+            writer.writeln();
+        
+        writer.writeSyntaxError(sessObj, this.queryStr,remainderStr);
+    }
+    
+    /* Getter/Setter Methods ****/
+	
+	private void setGotoLabel(String label){
+		this.gotoLabel = label;
+	}
+	
+	public String getGotoLabel(){
+		return this.gotoLabel;
+	}
+
+	public String getPendingAction(){
+		String tmpAction = strPendingAction;
+		strPendingAction = null;
+		return tmpAction;
+	}
+	
+	public boolean isPendingAction()
+	{
+		return strPendingAction != null;
+	}
+	
+	public void setQueryString(String q){
+		this.queryStr = q;
+	}
+	
+	public String getQueryString(){
+		return this.queryStr;
+	}
+	
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/main/java/org/trafodion/ci/ConditionalQueryException.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/main/java/org/trafodion/ci/ConditionalQueryException.java b/core/conn/trafci/src/main/java/org/trafodion/ci/ConditionalQueryException.java
new file mode 100644
index 0000000..bbce043
--- /dev/null
+++ b/core/conn/trafci/src/main/java/org/trafodion/ci/ConditionalQueryException.java
@@ -0,0 +1,43 @@
+// @@@ 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 ConditionalQueryException extends Exception{
+
+	/**
+	 * 
+	 */
+    ErrorObject errMsg = null;
+	private static final long serialVersionUID = 1L;
+
+	ConditionalQueryException()
+	{
+		super();
+	}
+	
+	public ErrorObject getErrorMsg(){
+		return this.errMsg;
+	}
+	
+	public void setError(ErrorObject err){
+	    this.errMsg = err;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/main/java/org/trafodion/ci/ConditionalSyntaxError.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/main/java/org/trafodion/ci/ConditionalSyntaxError.java b/core/conn/trafci/src/main/java/org/trafodion/ci/ConditionalSyntaxError.java
new file mode 100644
index 0000000..b8d09e7
--- /dev/null
+++ b/core/conn/trafci/src/main/java/org/trafodion/ci/ConditionalSyntaxError.java
@@ -0,0 +1,123 @@
+// @@@ 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.util.regex.Pattern;
+import java.util.regex.Matcher;
+
+public class ConditionalSyntaxError  {
+
+	
+	private StringBuffer errMesg=null;
+	private String errPrefix= "";
+
+	Pattern patVariable = Pattern.compile("^((?i:IF)(\\s|\\n)+((\"(\"(?=\")|\\\\(?=\")|.)*?\")|[^(\\n|\\s|!=|<>|>=|<=|>|<|=|==)]+)?)(.+)?\\z", Pattern.DOTALL);
+	Pattern patOperator = Pattern.compile("^((?i:IF)(\\s|\\n)+((\"(\"(?=\")|\\\\(?=\")|.)*?\")|[^(\\n|\\s|!=|<>|>=|<=|>|<|=|==)]+)(\\s|\\n)*(!=|<>|>=|<=|>|<|==|=)?)(.*)\\z", Pattern.DOTALL);
+	Pattern patValue    = Pattern.compile("^((?i:IF)(\\s|\\n)+((\"(\"(?=\")|\\\\(?=\")|.)*?\")|[^(\\n|\\s|!=|<>|>=|<=|>|<|=|==)]+)(\\s|\\n)*(!=|<>|>=|<=|>|<|==|=)(\\s|\\n)*((\"(\"(?=\")|\\\\(?=\")|.)*?\")|[^(\\s|\\n|!=|<>|>=|<=|>|<|=|==)]+)?)(.+)\\z", Pattern.DOTALL);
+
+	ConditionalSyntaxError()
+	{
+		
+	}
+	
+	public String testVariable(String qryString){
+		Matcher m = patVariable.matcher(qryString);
+		if(m.find())
+			return m.group(m.groupCount());
+		
+		return null;
+	}
+	
+	public String testOperator(String qryString){
+		Matcher m = patOperator.matcher(qryString);
+		if(m.find())
+			return m.group(m.groupCount());
+		
+		return null;	
+	}
+	
+	public String testValue(String qryString){
+		Matcher m = patValue.matcher(qryString);
+		if(m.find())
+			return m.group(m.groupCount()).trim();		
+		
+		return null;
+	}
+	
+	public void setSyntaxError(String qryString, String errLoc)
+	{
+		if(errMesg == null)
+		{
+			errMesg=new StringBuffer();
+		}
+	
+		this.errMesg.delete(0,errMesg.length());
+		
+		this.errMesg.append(errPrefix);
+		this.errMesg.append("\n");
+		this.errMesg.append(qryString);
+		this.errMesg.append("\n");
+
+		for(int i=0; i < qryString.length()-errLoc.length();i++)
+			this.errMesg.append(" ");
+		
+		this.errMesg.append("^");		
+	}
+	
+	public ErrorObject getSyntaxError(String qryString)
+	{
+		
+		if(qryString != null)
+		{
+			qryString=qryString.replaceAll("\\n"," ").trim();
+		}
+
+		String testVar = testVariable(qryString);
+		String testOp = testOperator(qryString);
+		String testVal = testValue(qryString);
+
+		String errLoc = "";
+		
+		if(testVal != null)
+		{
+			errPrefix = "A conditional syntax error occurred at or before:";
+			errLoc = testVal;
+		}
+		else if(testOp != null)
+		{
+			errPrefix = "A conditional operator syntax error occurred at or before:";
+			errLoc = testOp;
+		}
+		else
+		{
+			errPrefix = "A conditional variable syntax error occurred at or before:";
+			if(testVar == null)
+				testVar = qryString.charAt(qryString.length()-1)+"";
+
+			errLoc = testVar;
+		}
+		
+		setSyntaxError(qryString, errLoc);
+		return new ErrorObject(SessionError.GENERIC_SYNTAX_ERROR_CODE, errMesg.toString());
+	}
+	
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/main/java/org/trafodion/ci/ConsoleReader.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/main/java/org/trafodion/ci/ConsoleReader.java b/core/conn/trafci/src/main/java/org/trafodion/ci/ConsoleReader.java
new file mode 100644
index 0000000..4e8545e
--- /dev/null
+++ b/core/conn/trafci/src/main/java/org/trafodion/ci/ConsoleReader.java
@@ -0,0 +1,218 @@
+// @@@ 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.InputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import sun.misc.Signal;
+import sun.misc.SignalHandler;
+
+public class ConsoleReader
+{
+
+   private BufferedReader br=null;
+   private InputStream in=null;
+   private String line=null;
+   String newLine=SessionDefaults.lineSeperator;
+   String defaultEncoding="ISO-8859-1";
+   SignalHandler CTRLCHandler=null;
+   Signal INTSignal=null;
+   private boolean queryInterrupted=false;
+   private boolean doTrace = Boolean.getBoolean("trafci.enableTrace");
+   
+   StringBuffer lineBuffer=null;
+   private String prompt = SessionDefaults.DEFAULT_SQL_PROMPT;
+   private boolean time = false;
+   private boolean ampmFmt = false;
+   private MaskingThread mt=null;
+   WCIUtils wcs=null;
+
+   ConsoleReader()
+   {
+      newLine=System.getProperty("line.separator");
+      defaultEncoding=System.getProperty("file.encoding");
+    
+      CTRLCHandler = new MySignalHandlerClass();
+      try {
+      INTSignal=new Signal("INT");
+      } catch (Exception e) {}
+   }
+
+   public void setPrompt(String ps, boolean time, boolean ampmFmt)
+   {
+      this.prompt = ps;
+      this.time = time;
+      this.ampmFmt = ampmFmt;
+   }
+
+   public void setMaskingThread(MaskingThread mt, WCIUtils wcs)
+   {
+      this.mt = mt;
+      this.wcs=wcs;
+   }
+ 
+   private class MySignalHandlerClass implements SignalHandler
+   {
+      public void handle(Signal sig)
+      {
+         if (null != lineBuffer)  
+            lineBuffer.setLength(0);
+
+         queryInterrupted = true;
+        
+         if (mt!=null)
+         {
+            mt.stopMasking();
+            if (wcs!= null)wcs.enableEcho();
+         }
+
+         String timeStamp = "";
+         SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss ");
+         if (time)
+         {
+            if (ampmFmt)
+               timeStamp = DateFormat.getTimeInstance().format(new Date())+ " ";
+            else
+               timeStamp = sdf.format(new Date());
+         }
+
+         System.out.print("^C"+SessionDefaults.lineSeperator+SessionDefaults.lineSeperator + timeStamp+prompt);
+      }
+   }
+
+   public void initialize() throws IOException
+   {
+      this.in=System.in;
+   }
+
+   public String getLine() throws IOException, UserInterruption
+   {
+      next();
+      return this.line;
+   }
+
+   public String readLine() throws UnsupportedEncodingException, UserInterruption, IOException
+   {
+      StringBuffer lineBuffer=null;
+      lineBuffer=new StringBuffer();
+	  int i=-1;
+            
+      try {
+         if (CTRLCHandler != null)
+         {
+            Signal.handle(INTSignal, CTRLCHandler);
+         }
+      } catch (Exception e) {}
+
+      while (true)
+      {
+         queryInterrupted = false;
+         this.in.mark(1);
+         try{
+         if ((i = this.in.read()) != -1)
+         {
+            if (queryInterrupted)
+            {
+               in.reset();
+               throw new UserInterruption();
+            }
+
+            lineBuffer.append((char)i);
+            line = lineBuffer.toString();
+            
+            if (!defaultEncoding.equalsIgnoreCase("Cp1047")) 
+            {
+               byte[] ba=line.getBytes("ISO-8859-1"); // added for nls character support
+               line=new String(ba,defaultEncoding);
+            }
+            
+            if (line != null && line.endsWith(newLine))
+            {
+               return line.substring(0,line.length() - newLine.length());
+            }
+         }
+         }catch (ArrayIndexOutOfBoundsException e)
+         	{        	 
+        	 	 System.out.println(SessionError.OUT_OF_BOUNDS);
+        	 	 
+        	 if(doTrace)
+        	 {
+        		 e.printStackTrace();
+        	 }
+         	}
+                 
+         if (queryInterrupted)
+         {
+            in.reset();
+            throw new UserInterruption();
+
+         }
+      }
+
+   }
+
+   public boolean next() throws IOException, UserInterruption
+   {
+      //line=this.br.readLine();
+      line=this.readLine();
+      return true;
+   }
+
+   public void close() throws IOException
+   {
+      this.br.close();
+      this.br=null;
+   }
+
+   public boolean isQueryInterrupted()
+   {
+      return queryInterrupted;
+   }
+
+   public void setQueryInterrupted(boolean queryInterrupted)
+   {
+      this.queryInterrupted = queryInterrupted;
+   }
+
+   public boolean isInteractive()
+   {
+      int num = 1;
+      try
+      {
+         num = this.in.available();
+         //System.out.println("\nNumber of input stream bytes=" + num);
+      }
+      catch (IOException ioe)
+      {
+         return false;
+      }
+
+      return (num <= 0 ? true:false);
+   }
+
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/de7e7d4e/core/conn/trafci/src/main/java/org/trafodion/ci/ConsoleWriter.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/src/main/java/org/trafodion/ci/ConsoleWriter.java b/core/conn/trafci/src/main/java/org/trafodion/ci/ConsoleWriter.java
new file mode 100644
index 0000000..dac2110
--- /dev/null
+++ b/core/conn/trafci/src/main/java/org/trafodion/ci/ConsoleWriter.java
@@ -0,0 +1,130 @@
+// @@@ 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.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+
+public class ConsoleWriter
+{
+   private PrintStream ps=null;
+   private PrintStream systemOS = System.out;
+   private ByteArrayOutputStream out=null;
+   private boolean consoleOut=true;
+
+   ConsoleWriter()
+   {
+   }
+
+   /*public void initializeByteArray()
+   {
+   out=new ByteArrayOutputStream();
+   System.setOut(new PrintStream(out));
+   consoleOut=false;
+   }*/
+
+   public void initialize() throws IOException
+   {	   
+	   setupOutputStream();
+   }
+   
+   private void setupOutputStream() {
+      if (consoleOut) {
+    	  System.setOut(systemOS);
+      }
+      else
+      {
+         out=new ByteArrayOutputStream();
+         System.setOut(new PrintStream(out));
+      }
+      
+      this.ps = System.out;
+   }
+
+
+   public void println(String line)
+   {
+      this.ps.println(line);
+   }
+
+   public void print(String line)
+   {
+      this.ps.print(line);
+   }
+
+   public void println()
+   {
+      this.ps.println();
+   }
+
+   public void setConsoleOut(boolean consoleOut)
+   {
+      this.consoleOut=consoleOut;
+      setupOutputStream();
+   }
+
+   public boolean getConsoleOut()
+   {
+      return this.consoleOut;
+   }
+   /*
+   public void println(String line)
+   {
+   System.out.println(line);
+   }
+
+   public void print(String line)
+   {
+   System.out.print(line);
+   }
+
+   public void println()
+   {
+   System.out.println();
+   }
+   */
+   public String getResult()
+   {
+      if (out == null)
+      {
+         return null;
+      }
+      else
+      {
+         return out.toString();
+      }
+   }
+
+   public void resetStream()
+   {
+      if (this.out != null)
+      {
+         this.out.reset();
+      }
+   }
+
+   public void close()
+   {
+      this.ps.close();
+   }
+
+}