[teiid-commits] teiid SVN: r2061 - in trunk: adminshell/src/main/java and 18 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Fri Apr 16 17:15:35 EDT 2010


Author: shawkins
Date: 2010-04-16 17:15:33 -0400 (Fri, 16 Apr 2010)
New Revision: 2061

Added:
   trunk/adminshell/src/main/java/groovy/
   trunk/adminshell/src/main/java/groovy/sql/
   trunk/adminshell/src/main/java/groovy/sql/TeiidSql.java
   trunk/adminshell/src/main/java/org/teiid/adminshell/
   trunk/adminshell/src/main/java/org/teiid/adminshell/AdminHelpCommand.java
   trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
   trunk/adminshell/src/main/java/org/teiid/adminshell/GroovyAdminConsole.java
   trunk/adminshell/src/main/java/org/teiid/adminshell/GroovyAdminShell.java
   trunk/adminshell/src/main/java/org/teiid/adminshell/GroovySqlExtensions.java
   trunk/adminshell/src/main/java/org/teiid/adminshell/Help.java
   trunk/adminshell/src/main/java/org/teiid/adminshell/MigrationUtil.java
   trunk/adminshell/src/main/resources/org/
   trunk/adminshell/src/main/resources/org/codehaus/
   trunk/adminshell/src/main/resources/org/codehaus/groovy/
   trunk/adminshell/src/main/resources/org/codehaus/groovy/tools/
   trunk/adminshell/src/main/resources/org/codehaus/groovy/tools/shell/
   trunk/adminshell/src/main/resources/org/codehaus/groovy/tools/shell/commands.xml
   trunk/adminshell/src/main/resources/org/teiid/
   trunk/adminshell/src/main/resources/org/teiid/adminshell/
   trunk/adminshell/src/main/resources/org/teiid/adminshell/AdminHelpCommand.properties
   trunk/build/kit-adminshell/adminconsole.bat
   trunk/build/kit-adminshell/adminconsole.sh
   trunk/test-integration/common/src/test/java/org/teiid/jdbc/MetadataReader.java
   trunk/test-integration/common/src/test/java/org/teiid/jdbc/StringArrayReader.java
Removed:
   trunk/adminshell/src/main/java/bsh/
   trunk/adminshell/src/main/java/com/metamatrix/script/junit/
   trunk/adminshell/src/main/java/com/metamatrix/script/shell/
   trunk/adminshell/src/main/java/org/teiid/AdminShell.java
   trunk/adminshell/src/main/java/org/teiid/MigrationUtil.java
   trunk/adminshell/src/main/java/org/teiid/script/io/MetadataReader.java
   trunk/adminshell/src/main/java/org/teiid/script/io/StringArrayReader.java
   trunk/adminshell/src/main/resources/commands/
   trunk/adminshell/src/main/resources/scripts/
   trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-c.xml
   trunk/documentation/admin-guide/src/main/docbook/en-US/content/writing-tests.xml
Modified:
   trunk/adminshell/pom.xml
   trunk/adminshell/src/main/java/org/teiid/script/io/ResultSetReader.java
   trunk/build/kit-adminshell/adminshell.bat
   trunk/build/kit-adminshell/adminshell.sh
   trunk/build/kit-adminshell/migrate.bat
   trunk/build/kit-adminshell/migrate.sh
   trunk/documentation/admin-guide/src/main/docbook/en-US/adminshell_guide.xml
   trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-a.xml
   trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-b.xml
   trunk/documentation/admin-guide/src/main/docbook/en-US/content/connection-management.xml
   trunk/documentation/admin-guide/src/main/docbook/en-US/content/getting-started.xml
   trunk/documentation/admin-guide/src/main/docbook/en-US/content/introduction.xml
   trunk/documentation/admin-guide/src/main/docbook/en-US/content/working-with-scripts.xml
   trunk/test-integration/common/src/test/java/org/teiid/jdbc/AbstractQueryTest.java
Log:
TEIID-1052 re-implementing adminshell with groovy tools.

Modified: trunk/adminshell/pom.xml
===================================================================
--- trunk/adminshell/pom.xml	2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/adminshell/pom.xml	2010-04-16 21:15:33 UTC (rev 2061)
@@ -1,35 +1,59 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<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">
-  <parent>
-    <artifactId>teiid</artifactId>
-    <groupId>org.jboss.teiid</groupId>
-    <version>7.0.0-SNAPSHOT</version>
-  </parent>
-  <modelVersion>4.0.0</modelVersion>
-  <artifactId>teiid-adminshell</artifactId>
-  <name>Adminshell</name>
-  <description>Adminshell for Teiid</description>
-  <dependencies>
-    <dependency>
-      <groupId>org.jboss.teiid</groupId>
-      <artifactId>teiid-common-core</artifactId>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.jboss.teiid</groupId>
-      <artifactId>teiid-client</artifactId>
-      <scope>provided</scope>
-    </dependency>
-   
-    <dependency>
-      <groupId>beanshell</groupId>
-      <artifactId>bsh</artifactId>
-    </dependency>
-    
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.1</version>
-    </dependency>
-  </dependencies>
+<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">
+	<parent>
+		<artifactId>teiid</artifactId>
+		<groupId>org.jboss.teiid</groupId>
+		<version>7.0.0-SNAPSHOT</version>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>teiid-adminshell</artifactId>
+	<name>Adminshell</name>
+	<description>Adminshell for Teiid</description>
+	<dependencies>
+		<dependency>
+			<groupId>org.jboss.teiid</groupId>
+			<artifactId>teiid-common-core</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.jboss.teiid</groupId>
+			<artifactId>teiid-client</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.codehaus.groovy</groupId>
+			<artifactId>groovy-all</artifactId>
+			<version>1.7.2</version>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>3.8.1</version>
+		</dependency>
+        <dependency>
+            <groupId>jline</groupId>
+            <artifactId>jline</artifactId>
+            <version>0.9.94</version>
+            <scope>compile</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.fusesource.jansi</groupId>
+            <artifactId>jansi</artifactId>
+            <version>1.2.1</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-cli</groupId>
+            <artifactId>commons-cli</artifactId>
+            <version>1.2</version>
+            <scope>compile</scope>
+        </dependency>
+	</dependencies>
 </project>
\ No newline at end of file

Added: trunk/adminshell/src/main/java/groovy/sql/TeiidSql.java
===================================================================
--- trunk/adminshell/src/main/java/groovy/sql/TeiidSql.java	                        (rev 0)
+++ trunk/adminshell/src/main/java/groovy/sql/TeiidSql.java	2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,125 @@
+package groovy.sql;
+
+import groovy.lang.Closure;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.Statement;
+import java.util.Collection;
+import java.util.logging.Level;
+
+import org.teiid.client.plan.PlanNode;
+import org.teiid.jdbc.TeiidStatement;
+
+/**
+ * An extension of Groovy's Sql to support getting {@link TeiidStatement} specific properties.
+ */
+public final class TeiidSql extends Sql {
+	private int maxRows;
+	private PlanNode plan;
+	private Collection<org.teiid.client.plan.Annotation> annotations;
+	private String debugLog;
+	private SQLWarning warnings;
+
+	public TeiidSql(Connection connection) {
+		super(connection);
+	}
+	
+	@Override
+	protected void configure(Statement statement) {
+		super.configure(statement);
+		try {
+			statement.setMaxRows(maxRows);
+		} catch (SQLException e) {
+			LOG.log(Level.WARNING, "Caught exception setting max rows: " + e, e);
+		}
+		plan = null;
+		annotations = null;
+		debugLog = null;
+		warnings = null;
+	}
+	
+	/**
+	 * Overridden to fix passing the resultset to the closure
+	 */
+	@Override
+    public void eachRow(String sql, Closure metaClosure, Closure rowClosure) throws SQLException {
+        AbstractQueryCommand command = createQueryCommand(sql);
+        ResultSet results = null;
+        try {
+        	results = command.execute();
+            if (metaClosure != null) metaClosure.call(results.getMetaData());
+
+            GroovyResultSet groovyRS = new GroovyResultSetProxy(results).getImpl();
+            while (groovyRS.next()) {
+            	rowClosure.call(groovyRS);
+            }
+        } catch (SQLException e) {
+            LOG.warning("Failed to execute: " + sql + " because: " + e.getMessage());
+            throw e;
+        } finally {
+            command.closeResources();
+        }
+    }
+
+	@Override
+	protected void closeResources(Connection connection,
+			Statement statement) {
+		getPlanInfo(statement);
+		super.closeResources(connection, statement);
+	}
+
+	@Override
+	protected void closeResources(Connection connection,
+			Statement statement, ResultSet results) {
+		getPlanInfo(statement);
+		super.closeResources(connection, statement, results);
+	}
+
+	protected void getPlanInfo(Statement s) {
+		if (s == null) {
+			return;
+		}
+		TeiidStatement ts;
+		try {
+			ts = s.unwrap(TeiidStatement.class);
+		} catch (SQLException e) {
+			throw new RuntimeException(e);
+		}
+		plan = ts.getPlanDescription();
+		annotations = ts.getAnnotations();
+		debugLog = ts.getDebugLog();
+		try {
+			warnings = ts.getWarnings();
+		} catch (SQLException e) {
+			LOG.log(Level.WARNING, "Caught exception getting warnings: " + e, e);
+		}
+	}
+	
+	public SQLWarning getSQLWarnings() {
+		return warnings;
+	}
+
+	public int getMaxRows() {
+		return maxRows;
+	}
+
+	public void setMaxRows(int maxRows) {
+		this.maxRows = maxRows;
+	}
+
+	public PlanNode getPlan() {
+		return plan;
+	}
+
+	public Collection<org.teiid.client.plan.Annotation> getAnnotations() {
+		return annotations;
+	}
+
+	public String getDebugLog() {
+		return debugLog;
+	}
+	
+}
\ No newline at end of file


Property changes on: trunk/adminshell/src/main/java/groovy/sql/TeiidSql.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: trunk/adminshell/src/main/java/org/teiid/AdminShell.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/AdminShell.java	2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/adminshell/src/main/java/org/teiid/AdminShell.java	2010-04-16 21:15:33 UTC (rev 2061)
@@ -1,94 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintStream;
-
-import bsh.Capabilities;
-import bsh.EvalError;
-import bsh.Interpreter;
-
-import com.metamatrix.script.shell.FilePrintStream;
-import com.metamatrix.script.shell.ReaderInterceptor;
-import com.metamatrix.script.shell.SimpleParser;
-
-
-/** 
- * Invokes the BeanShell window, specifically designed for the metamatrix purposes.
- * The difference with this shell is, it will plug in a customer parser on top the
- * BeanShell, and load up all the MetaMatrix commands.
- */
-public class AdminShell {
-    
-    public static void main( String args[] ) throws IOException {
-        
-        boolean gui = Boolean.getBoolean("gui"); //$NON-NLS-1$
-        
-        if (args.length == 0) {
-            if ( !Capabilities.classExists( "bsh.util.Util" ) ) //$NON-NLS-1$
-                System.out.println("Can't find the BeanShell utilities..."); //$NON-NLS-1$
-        
-            String teiidHome = System.getenv("TEIID_HOME"); //$NON-NLS-1$
-            if (teiidHome == null) {
-            	teiidHome = System.getProperty("user.dir");  //$NON-NLS-1$
-            }
-            File logDir = new File(teiidHome, "log"); //$NON-NLS-1$
-            if (!logDir.exists()) {
-            	logDir.mkdirs();
-            }
-            
-            FileWriter logger = new FileWriter(teiidHome+"/log/adminscript.txt", true); //$NON-NLS-1$
-            PrintStream out = new FilePrintStream(System.out, teiidHome+"/log/adminshell.log"); //$NON-NLS-1$
-            
-            try {
-                SimpleParser p = new SimpleParser();
-                Interpreter interpreter = new Interpreter(new ReaderInterceptor(p, logger), out, out, true); 
-                interpreter.eval("importCommands(\"commands\")"); //$NON-NLS-1$
-                interpreter.eval("load(\"server\")"); //$NON-NLS-1$
-                
-                p.setInterpreter(interpreter);
-                
-                if (Capabilities.haveSwing() && gui) {
-                    //bsh.util.Util.startSplashScreen();
-                    interpreter.eval("desktop()"); //$NON-NLS-1$
-                    interpreter.getOut().flush();
-                } else {
-                    interpreter.run();
-                }
-            } catch ( EvalError e ) {
-               System.err.println("Couldn't start desktop: "+e); //$NON-NLS-1$
-            } finally {
-                logger.close();
-                out.close();
-            }
-        }
-        else {
-            // If we running a script file run as it is
-            Interpreter.main(args);
-        }
-    }
-    
-}

Deleted: trunk/adminshell/src/main/java/org/teiid/MigrationUtil.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/MigrationUtil.java	2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/adminshell/src/main/java/org/teiid/MigrationUtil.java	2010-04-16 21:15:33 UTC (rev 2061)
@@ -1,202 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-import java.util.zip.ZipOutputStream;
-
-import javax.xml.transform.Result;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import com.metamatrix.common.util.ApplicationInfo;
-import com.metamatrix.core.util.FileUtils;
-import com.metamatrix.core.util.ObjectConverterUtil;
-
- at SuppressWarnings("nls")
-public class MigrationUtil {
-
-	//TODO: sys out info on what ds needs creating
-	public static void main(String[] args) throws IOException, TransformerConfigurationException, TransformerFactoryConfigurationError, TransformerException {
-		if (args.length != 1) {
-			System.err.println(
-					"Teiid 7.0 VDB Migration Utility" +
-					"\n\nUsage:" +
-					"\n  A vdb or .def file must be specified as the only argument." +
-					"\n\nResult:"+
-					"\n  7.0 compatible replacement files will be created in the same directory " +
-					"\n  as your file." +
-					"\n  If you supply a vdb, the new vdb file will have a _70.vdb suffix." +
-					"\n  If you supply a dynamic vdb file, then two new files will be created: " +
-					"\n  <file name>-vdb.xml and <file name>-bindings.xml" +
-					"\n\nNote: this program will only create connector binding connection factories " +
-					"\n      if the bindings are present in the specified file." +
-					"\n\nNote: this program will NOT create the -ds.xml files needed by JBoss to " +
-					"\n      create underlying DataSource connection pools." +
-					"\n      You will need to manually create one -ds.xml for each JDBC DataSource " +
-					"\n      with a JNDI name of <connector binding name>DS, " +
-					"\n      where any spaces in the name are replace by _" +
-					"\n\nNode: depending upon the connectors used, you may need to manually edit the " +
-					"        -bindings.xml file."); 
-			System.exit(-1);
-		}
-		File file = new File(args[0]);
-		if (!file.exists()) {
-			System.err.println(args[0] + " does not exist."); //$NON-NLS-1$
-			System.exit(-1);
-		}
-		String fullName = file.getName();
-		String fileName = fullName.substring(0, fullName.length() - 4);
-		String ext = FileUtils.getExtension(file);
-		if (ext == null) {
-			System.err.println(fullName + " is not a vdb or xml file."); //$NON-NLS-1$
-			System.exit(-1);
-		}
-		ext = ext.toLowerCase();
-		if (ext.endsWith("vdb")) {
-			File dir = createTempDirectory();
-			try {
-				extract(file, dir);
-				File metainf = new File(dir, "META-INF");
-				File config = new File(dir, "ConfigurationInfo.def"); 
-				File manifest = new File(dir, "MetaMatrix-VdbManifestModel.xmi");
-				if (manifest.exists()) {
-					String configStr = ObjectConverterUtil.convertFileToString(config);
-					String manifestStr = ObjectConverterUtil.convertFileToString(manifest);
-					int index = configStr.lastIndexOf("</VDB>");
-					int manifestBegin = manifestStr.indexOf("<xmi");
-					configStr = configStr.substring(0, index) + manifestStr.substring(manifestBegin) + "</VDB>";
-					FileUtils.write(configStr.getBytes(), config);
-					manifest.delete();
-				}
-				transformConfig(config, "/vdb.xsl", new StreamResult(new File(metainf, "vdb.xml")));
-				transformConfig(config, "/connector.xsl", new StreamResult(new File(file.getParentFile(), fileName + "-bindings-ds.xml")));
-				config.delete();
-				FileOutputStream out = new FileOutputStream(new File(file.getParent(), fileName + "_70.vdb"));
-				ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(out));
-				int parentLength = dir.getPath().length();
-				addDirectory(dir, zos, parentLength);
-				zos.close();
-			} finally {
-				FileUtils.removeDirectoryAndChildren(dir);
-			}
-		} else if (ext.endsWith("xml") || ext.endsWith("def")){
-			File parent = file.getParentFile();
-			transformConfig(file, "/vdb.xsl", new StreamResult(new File(parent, fileName + "-vdb.xml")));
-			transformConfig(file, "/connector.xsl", new StreamResult(new File(parent, fileName + "-bindings-ds.xml")));
-		} else {
-			System.err.println(fullName + " is not a vdb or xml file.  Run with no arguments for help."); //$NON-NLS-1$
-			System.exit(-1);
-		}
-	}
-
-	private static void addDirectory(File dir, ZipOutputStream zos,
-			int parentLength) throws IOException {
-		String[] files = dir.list();
-		for (String entry : files) {
-			File f = new File(dir, entry);
-			if (f.isDirectory()) {
-				addDirectory(f, zos, parentLength);
-			} else {
-				ZipEntry e = new ZipEntry(f.getPath().substring(parentLength));
-				zos.putNextEntry(e);
-				FileUtils.write(f, zos);
-				zos.closeEntry();
-			}
-		}
-	}
-
-	private static void transformConfig(File config, String styleSheet, Result target)
-			throws TransformerFactoryConfigurationError,
-			TransformerConfigurationException, TransformerException {
-		TransformerFactory tf = TransformerFactory.newInstance();
-		Transformer t = tf.newTransformer(new StreamSource(MigrationUtil.class.getResourceAsStream(styleSheet)));
-		t.setParameter("version", ApplicationInfo.getInstance().getReleaseNumber()); //$NON-NLS-1$
-		t.transform(new StreamSource(config), target);
-	}
-
-	/**
-	 * Extract the given zip file to the given destination directory base.
-	 * 
-	 * @param zipFileName
-	 *            The full path and file name of the Zip file to extract.
-	 * @param destinationDirectory
-	 *            The root directory to extract to.
-	 * @throws IOException
-	 */
-	static void extract(final File sourceZipFile, File unzipDestinationDirectory) throws IOException {
-		// Open Zip file for reading
-		ZipFile zipFile = new ZipFile(sourceZipFile, ZipFile.OPEN_READ);
-
-		// Create an enumeration of the entries in the zip file
-		Enumeration zipFileEntries = zipFile.entries();
-
-		// Process each entry
-		while (zipFileEntries.hasMoreElements()) {
-			// grab a zip file entry
-			ZipEntry entry = (ZipEntry) zipFileEntries.nextElement();
-
-			String currentEntry = entry.getName();
-
-			File destFile = new File(unzipDestinationDirectory, currentEntry);
-
-			// grab file's parent directory structure
-			File destinationParent = destFile.getParentFile();
-
-			// create the parent directory structure if needed
-			destinationParent.mkdirs();
-
-			// extract file if not a directory
-			if (!entry.isDirectory()) {
-				ObjectConverterUtil.write(zipFile.getInputStream(entry),
-						destFile);
-			}
-		}
-		zipFile.close();
-	}
-
-	static File createTempDirectory() throws IOException {
-		File temp = File.createTempFile("temp", Long.toString(System.nanoTime()));
-
-		temp.delete();
-
-		if (!(temp.mkdir())) {
-			throw new IOException("Could not create temp directory: "
-					+ temp.getAbsolutePath());
-		}
-
-		return temp;
-	}
-
-}

Added: trunk/adminshell/src/main/java/org/teiid/adminshell/AdminHelpCommand.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/AdminHelpCommand.java	                        (rev 0)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/AdminHelpCommand.java	2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General public static
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General public static License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General public static
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminshell;
+
+import java.util.List;
+
+import org.codehaus.groovy.tools.shell.CommandSupport;
+import org.codehaus.groovy.tools.shell.Shell;
+
+public class AdminHelpCommand extends CommandSupport {
+
+	protected AdminHelpCommand(Shell shell) {
+		super(shell, "adminhelp", "\\ah");  //$NON-NLS-1$ //$NON-NLS-2$
+		
+		//hook to introduce default imports
+		shell.execute(GroovyAdminConsole.IMPORTS);
+	}
+
+	@Override
+	public Object execute(List args) {
+		if (args.size() > 1) {
+            fail(messages.format("error.unexpected_args", new Object[] {args.toString()}));  //$NON-NLS-1$
+        }
+		if (args.isEmpty()) {
+			AdminShell.adminHelp();
+		} else {
+			AdminShell.adminHelp(args.get(0).toString());
+		}
+		return null;
+	}
+
+}


Property changes on: trunk/adminshell/src/main/java/org/teiid/adminshell/AdminHelpCommand.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java	                        (rev 0)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java	2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,544 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General public static
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General public static License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General public static
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminshell;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.nio.charset.Charset;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Properties;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminFactory;
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.ConnectionFactory;
+import org.teiid.adminapi.ConnectionPoolStatistics;
+import org.teiid.adminapi.ProcessObject;
+import org.teiid.adminapi.PropertyDefinition;
+import org.teiid.adminapi.Request;
+import org.teiid.adminapi.Session;
+import org.teiid.adminapi.Transaction;
+import org.teiid.adminapi.VDB;
+import org.teiid.adminapi.WorkerPoolStatistics;
+import org.teiid.adminapi.Admin.DataSourceType;
+import org.teiid.adminshell.Help.Doc;
+
+import com.metamatrix.common.util.ReaderInputStream;
+import com.metamatrix.core.util.ObjectConverterUtil;
+
+/**
+ * Contextual shell wrapper around the AdminAPI, see {@link Admin}
+ */
+public class AdminShell {
+	
+	protected static Logger log = Logger.getLogger(AdminShell.class.getName());
+	
+	static Properties p;
+	private static int connectionCount = 1;
+	private static Admin internalAdmin;
+	private static String currentName;
+	private static HashMap<String, Admin> connections = new HashMap<String, Admin>();
+	private static Help help = new Help(AdminShell.class);
+	
+	@Doc(text="Get a named Admin connection to the specified server")
+	public static void connectAsAdmin(
+			@Doc(text = "url - URL in the format \"mm[s]://host:port\"") String url,
+			@Doc(text = "username") String username,
+			@Doc(text = "password") String password, 
+			@Doc(text = "connection name") String connectionName) throws AdminException {
+		internalAdmin = AdminFactory.getInstance().createAdmin(username, password.toCharArray(), url);
+		currentName = connectionName;
+		Admin old = connections.put(connectionName, internalAdmin);
+		if (old != null) {
+			System.out.println("Closing previous admin associated with " + connectionName);
+			old.close();
+		}
+	}
+
+	@Doc(text = "Connect as Admin using the defaults from connection.properties")
+	@SuppressWarnings("nls")
+	public static void connectAsAdmin() throws AdminException {
+		loadConnectionProperties();
+		connectAsAdmin(p.getProperty("admin.url", "mm://localhost:31443"), p.getProperty("admin.user", "admin"), 
+				p.getProperty("admin.password", "admin"), "conn-" + connectionCount++);
+	}
+
+	static void loadConnectionProperties() {
+		if (p != null) {
+			return;
+		}
+	    Properties props = new Properties();
+	    FileInputStream fis = null;
+	    try {
+		    fis = new FileInputStream("connection.properties"); //$NON-NLS-1$
+	    	props.load(fis);
+	    } catch (IOException e) {
+	    	log.log(Level.WARNING, "Could not load default connection properties.", e);
+	    } finally {
+	    	if (fis != null) {
+	    		try {
+					fis.close();
+				} catch (IOException e) {
+				}
+	    	}
+	    }	    
+	    p = props;
+	}
+	
+	@Doc(text = "Add a ConnectionFactory")
+	public static ConnectionFactory addConnectionFactory(
+			@Doc(text = "deployed name") String deployedName,
+			@Doc(text = "type name") String typeName, 
+			Properties properties) throws AdminException {
+		return getAdmin()
+				.addConnectionFactory(deployedName, typeName, properties);
+	}
+
+	@Doc(text = "Adds a role to the specified policy")
+	public static void addRoleToDataPolicy(
+			@Doc(text = "vdb name") String vdbName, 
+			@Doc(text = "vdb version") int vdbVersion,
+			@Doc(text = "policy name") String policyName, 
+			@Doc(text = "role") String role) throws AdminException {
+		getAdmin().addRoleToDataPolicy(vdbName, vdbVersion, policyName, role);
+	}
+
+	@Doc(text = "Assign a ConnectionFactory to a source Model")
+	public static void assignConnectionFactoryToModel(
+			@Doc(text = "vdb name") String vdbName,
+			@Doc(text = "vdb version") int vdbVersion,
+			@Doc(text = "model name") String modelName, 
+			@Doc(text = "source name") String sourceName, 
+			@Doc(text = "jndi name") String jndiName)
+			throws AdminException {
+		getAdmin().assignConnectionFactoryToModel(vdbName, vdbVersion, modelName,
+				sourceName, jndiName);
+	}
+
+	@Doc(text = "Cancel a request")
+	public static void cancelRequest(
+			@Doc(text = "session id") long sessionId, 
+			@Doc(text = "request id") long requestId)
+			throws AdminException {
+		getAdmin().cancelRequest(sessionId, requestId);
+	}
+
+	@Doc(text = "Clear the given cache")
+	public static void clearCache(
+			@Doc(text = "cache type") String cacheType) throws AdminException {
+		getAdmin().clearCache(cacheType);
+	}
+
+	@Doc(text = "Delete a ConnectionFactory")
+	public static void deleteConnectionFactory(
+			@Doc(text = "deployed name") String deployedName)
+			throws AdminException {
+		getAdmin().deleteConnectionFactory(deployedName);
+	}
+
+	@Doc(text = "Delete a Connector")
+	public static void deleteConnector(
+			@Doc(text = "name") String name) throws AdminException {
+		getAdmin().deleteConnector(name);
+	}
+
+	@Doc(text = "Delete a DataSource")
+	public static void deleteDataSource(
+			@Doc(text = "deployed name") String deploymentName) throws AdminException {
+		getAdmin().deleteDataSource(deploymentName);
+	}
+
+	@Doc(text = "Delete a VDB")
+	public static void deleteVDB(
+			@Doc(text = "vdb name") String vdbName, 
+			@Doc(text = "vdb version") int vdbVersion) throws AdminException {
+		getAdmin().deleteVDB(vdbName, vdbVersion);
+	}
+
+	@Doc(text = "Get all cache type Strings")
+	public static Collection<String> getCacheTypes() throws AdminException {
+		return getAdmin().getCacheTypes();
+	}
+
+	@Doc(text = "Get all ConnectionFactory instances")
+	public static Collection<ConnectionFactory> getConnectionFactories()
+			throws AdminException {
+		return getAdmin().getConnectionFactories();
+	}
+
+	@Doc(text = "Get all ConnectionFactory instances in the VDB")
+	public static Collection<ConnectionFactory> getConnectionFactoriesInVDB(
+			@Doc(text = "vdb name") String vdbName, 
+			@Doc(text = "vdb version") int vdbVersion) throws AdminException {
+		return getAdmin().getConnectionFactoriesInVDB(vdbName, vdbVersion);
+	}
+
+	@Doc(text = "Get the specified ConnectionFactory")
+	public static ConnectionFactory getConnectionFactory(
+			@Doc(text = "deployed name") String deployedName)
+			throws AdminException {
+		return getAdmin().getConnectionFactory(deployedName);
+	}
+
+	@Doc(text = "Get the ConnectionPoolStatistics for the given ConnectionFactory")
+	public static ConnectionPoolStatistics getConnectionFactoryStats(
+			@Doc(text = "deployed name") String deployedName) throws AdminException {
+		return getAdmin().getConnectionFactoryStats(deployedName);
+	}
+
+	@Doc(text = "Get all connector name Strings")
+	public static Set<String> getConnectorNames() throws AdminException {
+		return getAdmin().getConnectorNames();
+	}
+
+	@Doc(text = "Get all PropertyDefinition instances for the given connector")
+	public static Collection<PropertyDefinition> getConnectorPropertyDefinitions(
+			@Doc(text = "connector name") String connectorName) throws AdminException {
+		return getAdmin().getConnectorPropertyDefinitions(connectorName);
+	}
+
+	@Doc(text = "Get all ProperyDefinition instances for a DataSource")
+	public static Collection<PropertyDefinition> getDataSourcePropertyDefinitions()
+			throws AdminException {
+		return getAdmin().getDataSourcePropertyDefinitions();
+	}
+
+	@Doc(text = "Get the ProcessObject instances for the given identifier")
+	public static Collection<ProcessObject> getProcesses(
+			@Doc(text = "identifier") String processIdentifier)
+			throws AdminException {
+		return getAdmin().getProcesses(processIdentifier);
+	}
+
+	@Doc(text = "Get all Request instances")
+	public static Collection<Request> getRequests() throws AdminException {
+		return getAdmin().getRequests();
+	}
+
+	@Doc(text = "Get all Request instances for the given session")
+	public static Collection<Request> getRequestsForSession(
+			@Doc(text = "session id") long sessionId)
+			throws AdminException {
+		return getAdmin().getRequestsForSession(sessionId);
+	}
+
+	@Doc(text = "Get all Session instances")
+	public static Collection<Session> getSessions() throws AdminException {
+		return getAdmin().getSessions();
+	}
+
+	@Doc(text = "Get all Transaction instances")
+	public static Collection<Transaction> getTransactions() throws AdminException {
+		return getAdmin().getTransactions();
+	}
+
+	@Doc(text = "Get a specific VDB")
+	public static VDB getVDB(
+			@Doc(text = "vdb name") String vdbName, 
+			@Doc(text = "vdb version") int vbdVersion) throws AdminException {
+		return getAdmin().getVDB(vdbName, vbdVersion);
+	}
+
+	@Doc(text = "Get all VDB instances")
+	public static Set<VDB> getVDBs() throws AdminException {
+		return getAdmin().getVDBs();
+	}
+
+	@Doc(text = "Get WorkerPoolStatistics for the given WorkManager")
+	public static WorkerPoolStatistics getWorkManagerStats(
+			@Doc(text = "identifier") String identifier)
+			throws AdminException {
+		return getAdmin().getWorkManagerStats(identifier);
+	}
+
+	@Doc(text = "Remove a role for the data policy")
+	public static void removeRoleFromDataPolicy(
+			@Doc(text = "vdb name") String vdbName, 
+			@Doc(text = "vdb version") int vdbVersion,
+			@Doc(text = "policy name") String policyName, 
+			@Doc(text = "role name") String role) throws AdminException {
+		getAdmin()
+				.removeRoleFromDataPolicy(vdbName, vdbVersion, policyName, role);
+	}
+
+	@Doc(text = "Set a ConnectionFactory property")
+	public static void setConnectionFactoryProperty(
+			@Doc(text = "deployed name") String deployedName,
+			@Doc(text = "propery name") String propertyName, 
+			@Doc(text = "value") String propertyValue) throws AdminException {
+		getAdmin().setConnectionFactoryProperty(deployedName, propertyName,
+				propertyValue);
+	}
+
+	@Doc(text = "Set a runtime property")
+	public static void setRuntimeProperty(
+			@Doc(text = "name") String propertyName, 
+			@Doc(text = "value") String propertyValue)
+			throws AdminException {
+		getAdmin().setRuntimeProperty(propertyName, propertyValue);
+	}
+
+	@Doc(text = "Start a ConnectionFactory")
+	public static void startConnectionFactory(
+			@Doc(text = "deployed name") String deployedName)
+			throws AdminException {
+		getAdmin().startConnectionFactory(deployedName);
+	}
+
+	@Doc(text = "Stop a ConnectionFactory")
+	public static void stopConnectionFactory(
+			@Doc(text = "deployed name") String deployedName)
+			throws AdminException {
+		getAdmin().stopConnectionFactory(deployedName);
+	}
+
+	@Doc(text = "Terminate a session and associated requests")
+	public static void terminateSession(
+			@Doc(text = "session id") long sessionId) throws AdminException {
+		getAdmin().terminateSession(sessionId);
+	}
+
+	@Doc(text = "Terminate a transaction")
+	public static void terminateTransaction(
+			@Doc(text = "transaction id") String transactionId)
+			throws AdminException {
+		getAdmin().terminateTransaction(transactionId);
+	}
+	
+	@Doc(text = "Merge two vdbs")
+	public static void mergeVDBs(
+			@Doc(text = "source vdb name") String sourceVDBName, 
+			@Doc(text = "source vdb version") int sourceVDBVersion,
+			@Doc(text = "target vdb name") String targetVDBName, 
+			@Doc(text = "target vdb version") int targetVDBVersion) throws AdminException {
+		getAdmin().mergeVDBs(sourceVDBName, sourceVDBVersion, targetVDBName, targetVDBVersion);
+	}
+	
+	@Doc(text = "Checks if a ConnectionFactory exists")
+	public static boolean hasConnectionFactory(
+			@Doc(text = "deployed name") String factoryName) throws AdminException {
+	    Collection<ConnectionFactory> bindings = getAdmin().getConnectionFactories();
+	    
+	    for (ConnectionFactory binding:bindings) {
+	        if (binding.getName().equals(factoryName)) {
+	            return true;
+	        }        
+	    }            
+	    return false;
+	}
+
+	@Doc(text = "Checks if a Connector exists")
+	public static boolean hasConnector(
+			@Doc(text = "type name") String typeName) throws AdminException {
+	    Collection<String> types = getAdmin().getConnectorNames();
+
+	    for (String type:types) {
+	        if (type.equals(typeName)) {
+	            return true;
+	        }
+	    }
+	    return false;
+	}
+
+	@Doc(text = "Checks if a VDB exists")
+	public static boolean hasVDB(
+			@Doc(text = "vdb name") String vdbName) throws AdminException {
+	    Collection<VDB> vdbs = getAdmin().getVDBs();
+	    for (VDB vdb:vdbs) {
+	        if (vdb.getName().equals(vdbName)) {
+	            return true;
+	        }
+	    }
+	    return false;
+	}
+
+	@Doc(text = "Checks if a specific VDB version exists")
+	public static boolean hasVDB(
+			@Doc(text = "vdb name") String vdbName, 
+			@Doc(text = "vdb version") int version) throws AdminException {
+	    Collection<VDB> vdbs = getAdmin().getVDBs();
+	    for (VDB vdb:vdbs) {
+	        if (vdb.getName().equals(vdbName) && vdb.getVersion() == version) {
+	            return true;
+	        }
+	    }
+	    return false;
+	}
+
+	@Doc(text = "Export a Connector RAR to file")
+	public static void exportConnector(
+			@Doc(text = "connector name") String name, 
+			@Doc(text = "file name") String fileName) throws AdminException, IOException {
+	    InputStream contents = getAdmin().exportConnector(name);
+	    writeFile(name, fileName, contents);
+	}
+
+	@Doc(text = "Export a ConnectionFactory to an XML file")
+	public static void exportConnectionFactory(
+			@Doc(text = "deployed name") String deployedName, 
+			@Doc(text = "file name") String fileName) throws AdminException, IOException{
+	    Reader contents = getAdmin().exportConnectionFactory(deployedName);
+	    writeFile(deployedName, fileName, contents);
+	}
+
+	private static void writeFile(String deployedName, String fileName,
+			Reader contents) throws IOException, AdminProcessingException {
+		if (contents == null) {
+	    	throw new AdminProcessingException(deployedName + " not found for exporting");
+	    }
+    	ObjectConverterUtil.write(new ReaderInputStream(contents, Charset.forName("UTF-8")), fileName);	//$NON-NLS-1$
+	}
+	
+	private static void writeFile(String deployedName, String fileName,
+			InputStream contents) throws IOException, AdminProcessingException {
+		if (contents == null) {
+	    	throw new AdminProcessingException(deployedName + " not found for exporting");
+	    }
+		ObjectConverterUtil.write(contents, fileName);	
+	}
+	
+	@Doc(text = "Add a connector from a RAR file")
+	public static void addConnector(
+			@Doc(text = "name of the Connector") String name, 
+			@Doc(text = "RAR file name") String rarFile) throws FileNotFoundException, AdminException {
+		FileInputStream fis = new FileInputStream(new File(rarFile));
+		try {
+			getAdmin().addConnector(name, fis);
+		} finally {
+			try {
+				fis.close();
+			} catch (IOException e) {
+			}
+		}
+	}
+	
+	@Doc(text = "Export a VDB to file")
+	public static void exportVDB(
+			@Doc(text = "vdb name") String vdbName, 
+			@Doc(text = "vdb version") int vdbVersion, 
+			@Doc(text = "file name") String fileName) throws AdminException, IOException{
+	    InputStream contents = getAdmin().exportVDB(vdbName, vdbVersion);
+	    writeFile(vdbName, fileName, contents);
+	}
+	
+	@Doc(text = "Deploy a VDB from file")
+	public static void deployVDB(
+			@Doc(text = "file name") String vdbFile) throws AdminException, FileNotFoundException {
+		FileInputStream fis = new FileInputStream(new File(vdbFile));
+		try {
+			getAdmin().deployVDB(vdbFile, fis);
+		} finally {
+			try {
+				fis.close();
+			} catch (IOException e) {
+			}
+		}
+	}
+
+	@Doc(text = "Add a DataSource")
+	public static void addDataSource(
+			@Doc(text = "deployed name") String deploymentName, 
+			DataSourceType type,
+			Properties properties) throws AdminException {
+		getAdmin().addDataSource(deploymentName, type, properties);
+	}
+
+	@Doc(text = "Export the DataSource XML to file")
+	public static void exportDataSource(
+			@Doc(text = "deployed name") String deployedName,
+			@Doc(text = "file name") String fileName) throws AdminException, IOException {
+		Reader contents = getAdmin().exportDataSource(deployedName);
+		writeFile(deployedName, fileName, contents);
+	}
+	
+	@Doc(text = "Get the current Admin connection")
+	public static Admin getAdmin() {
+		if (internalAdmin == null) {
+	        throw new NullPointerException("Not connected.  You must call a \"connectAsAdmin\" method or choose an active connection via \"useConnection\".");
+	    }
+		return internalAdmin;
+	}
+	
+	@Doc(text = "Disconnect the current connection for the server")
+	public static void disconnect() {
+	    if (internalAdmin != null) {
+	    	internalAdmin.close();
+	    	internalAdmin = null;
+	    	currentName = null;
+	    	connections.remove(currentName);
+	    }  
+	}
+	
+	@Doc(text = "Disconnect all connections from the server")
+	public static void disconnectAll() {
+		for (Admin admin : connections.values()) {
+			admin.close();
+		}
+		connections.clear();
+		internalAdmin = null;
+		currentName = null;
+	}
+	
+	@Doc(text = "Use another connection")
+	public static void useConnection(
+			@Doc(text = "connection name") String name) {
+		Admin admin = connections.get(name);
+		if (admin == null) {
+			System.out.println("Warning: connection is not active for " + name);
+			return;
+		}
+		internalAdmin = admin;
+		currentName = name;
+	}
+
+	@Doc(text = "Returns the current connection name")
+	public static String getConnectionName() {
+	    return currentName;
+	}
+
+	@Doc(text = "Return all connection names")
+	public static Collection<String> getAllConnections() {
+	    return connections.keySet();
+	}
+	
+	@Doc(text = "Show help for all admin methods")
+	public static void adminHelp() {
+		help.help();
+	}
+	
+	@Doc(text = "Show help for the given admin method")
+	public static void adminHelp(
+			@Doc(text = "method name") String method) {
+		help.help(method);
+	}
+	
+}


Property changes on: trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/adminshell/src/main/java/org/teiid/adminshell/GroovyAdminConsole.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/GroovyAdminConsole.java	                        (rev 0)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/GroovyAdminConsole.java	2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General public static
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General public static License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General public static
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminshell;
+
+import groovy.lang.Binding;
+import groovy.lang.Closure;
+import groovy.lang.GroovyShell;
+import groovy.ui.Console;
+
+import java.io.File;
+
+import javax.swing.UIManager;
+
+import org.codehaus.groovy.runtime.StackTraceUtils;
+import org.teiid.adminapi.Admin;
+
+public class GroovyAdminConsole {
+	
+	public static final String IMPORTS = "import static " + AdminShell.class.getName() + ".*\n" +  //$NON-NLS-1$ //$NON-NLS-2$
+			"import static " + GroovySqlExtensions.class.getName() + ".*\n" + //$NON-NLS-1$ //$NON-NLS-2$
+			"import " + Admin.class.getPackage().getName() + ".*\n"; //$NON-NLS-1$ //$NON-NLS-2$
+	
+	public static void main(String[] args) throws Exception {
+        // allow the full stack traces to bubble up to the root logger
+        java.util.logging.Logger.getLogger(StackTraceUtils.STACK_LOG_NAME).setUseParentHandlers(true);
+
+        //when starting via main set the look and feel to system
+        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 
+
+        final Console console = new Console(Console.class.getClassLoader());
+        console.setBeforeExecution(new Closure(null) {
+        	public void doCall() {
+        		console.setShell(new GroovyShell(Console.class.getClassLoader(), new Binding()) {
+        			public Object run(String scriptText, String fileName, String[] args) throws org.codehaus.groovy.control.CompilationFailedException {
+        				return super.run(IMPORTS + scriptText, fileName, args);
+        			};
+        		});
+        	}
+		});
+        console.run();
+        if (args.length == 1) {
+        	console.loadScriptFile(new File(args[0]));
+        }
+	}
+
+}


Property changes on: trunk/adminshell/src/main/java/org/teiid/adminshell/GroovyAdminConsole.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/adminshell/src/main/java/org/teiid/adminshell/GroovyAdminShell.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/GroovyAdminShell.java	                        (rev 0)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/GroovyAdminShell.java	2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General public static
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General public static License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General public static
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminshell;
+
+import org.codehaus.groovy.tools.shell.Main;
+
+public class GroovyAdminShell {
+	
+	public static void main(String[] args) {
+		Main.main(args);
+	}
+
+}


Property changes on: trunk/adminshell/src/main/java/org/teiid/adminshell/GroovyAdminShell.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/adminshell/src/main/java/org/teiid/adminshell/GroovySqlExtensions.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/GroovySqlExtensions.java	                        (rev 0)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/GroovySqlExtensions.java	2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,122 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General public static
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General public static License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General public static
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminshell;
+
+import groovy.sql.TeiidSql;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+import java.sql.Types;
+import java.util.Properties;
+
+import org.teiid.jdbc.TeiidDriver;
+import org.teiid.net.TeiidURL;
+import org.teiid.script.io.ResultSetReader;
+
+/**
+ * Extensions of Groovy Sql support, which somewhat bridges the gap to our old adminshell sql logic
+ */
+public class GroovySqlExtensions {
+	
+	private static Help help = new Help(GroovySqlExtensions.class);
+	
+	@Help.Doc(text = "Get a Teiid connection - using connection.properties")
+	public static TeiidSql connect(
+			@Help.Doc(text = "url") String url) throws SQLException {
+		return connect(url, null, null);
+	}
+
+	@Help.Doc(text = "Get a Teiid connection")
+	public static TeiidSql connect(
+			@Help.Doc(text = "url") String url, 
+			@Help.Doc(text = "user") String user, 
+			@Help.Doc(text = "password") String password) throws SQLException {
+		Properties info = new Properties();
+		if (user != null) {
+			info.setProperty(TeiidURL.CONNECTION.USER_NAME, user);
+		}
+		if (password != null) {
+			info.setProperty(TeiidURL.CONNECTION.PASSWORD, password);
+		}
+		Connection c = TeiidDriver.getInstance().connect(url, info);
+		if (c == null) {
+			throw new SQLException("Invalid url " + url);
+		}
+		return new TeiidSql(c);
+	}
+	
+	@SuppressWarnings("nls")
+	@Help.Doc(text = "Get a SQL connection using the defaults from connection.properties")
+	public static TeiidSql connect() throws SQLException {
+		AdminShell.loadConnectionProperties();
+		return connect(AdminShell.p.getProperty("jdbc.url", "jdbc:teiid:VDB at mm://localhost:31000"), 
+				AdminShell.p.getProperty("jdbc.user", "admin"), AdminShell.p.getProperty("jdbc.password", "teiid"));
+	}
+	
+	@Help.Doc(text = "Alternate row to String method that pretty prints SQL/XML," +
+	" \ne.g. sql.eachRow(\"select * from tables\", {row -> println rowToString(row) })")
+	public static String rowToString(ResultSet results) throws SQLException {
+		StringBuilder sb = new StringBuilder();
+		//alternative toString - see GroovyResultSetExtension
+		int columnCount = results.getMetaData().getColumnCount();
+		for (int col = 1; col <= columnCount; col++) {
+		    int type = results.getMetaData().getColumnType(col);
+		    if (type == Types.BLOB) {
+		    	Object anObj = results.getObject(col);
+		        sb.append(anObj != null ? "BLOB" : "null"); //$NON-NLS-1$ //$NON-NLS-2$
+		    }
+		    else if (type == Types.SQLXML) {
+		    	SQLXML xml = results.getSQLXML(col);
+		    	sb.append(xml != null ? ResultSetReader.prettyPrint(xml) : "null"); //$NON-NLS-1$
+		    }
+		    else {
+		    	String str = results.getString(col);
+		        sb.append(str != null ? str : "null"); //$NON-NLS-1$
+		    }
+		    if (col != columnCount) {
+		        sb.append("    "); //$NON-NLS-1$ 
+		    }                    
+		}
+		return sb.toString();
+	}
+	
+	@Help.Doc(text = "Pretty prints the ResultSetMetadata")
+	public static String resultSetMetaDataToString(ResultSetMetaData rsmd) throws SQLException {
+		return ResultSetReader.resultSetMetaDataToString(rsmd, "    "); //$NON-NLS-1$
+	}
+	
+	@Help.Doc(text = "Show help for all Sql methods")
+	public static void sqlHelp() {
+		help.help();
+	}
+	
+	@Help.Doc(text = "Show help for the given Sql method")
+	public static void sqlHelp(
+			@Help.Doc(text = "method name") String method) {
+		help.help(method);
+	}
+
+}


Property changes on: trunk/adminshell/src/main/java/org/teiid/adminshell/GroovySqlExtensions.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/adminshell/src/main/java/org/teiid/adminshell/Help.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/Help.java	                        (rev 0)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/Help.java	2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminshell;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.TreeMap;
+
+/**
+ * A simple help system built off of scanning public static methods.
+ */
+public class Help {
+	
+	@Documented
+	@Retention(RetentionPolicy.RUNTIME)
+	@Target({ElementType.METHOD, ElementType.PARAMETER})
+	public @interface Doc {
+		String text();
+	}
+
+	private TreeMap<String, List<String>> help = new TreeMap<String, List<String>>();
+	private List<String> shortHelp = new ArrayList<String>();
+	
+	public Help(Class<?> clazz) {
+		Method[] methods = clazz.getMethods();
+		for (Method method : methods) {
+			if (!Modifier.isPublic(method.getModifiers()) || !Modifier.isStatic(method.getModifiers())) {
+				continue;
+			}
+			StringBuilder sb = new StringBuilder();
+			Help.Doc doc = method.getAnnotation(Help.Doc.class);
+			StringBuilder shortSb = new StringBuilder();
+			shortSb.append(method.getName()).append("("); //$NON-NLS-1$
+			if (method.getParameterTypes().length > 0) {
+				shortSb.append(method.getParameterTypes().length);
+			}
+			shortSb.append(")"); //$NON-NLS-1$
+			String shortHelpStr = String.format("  %-25s", shortSb.toString()); //$NON-NLS-1$ 
+			if (doc != null && doc.text() != null) {
+				sb.append("/*\n *").append(doc.text()).append("\n */\n"); //$NON-NLS-1$ //$NON-NLS-2$
+				shortHelpStr += " -- " + doc.text(); //$NON-NLS-1$ 
+			}
+			shortHelp.add(shortHelpStr);
+			Class<?> returnType = method.getReturnType();
+			sb.append(returnType.getSimpleName()).append(" "); //$NON-NLS-1$
+			sb.append(method.getName()).append("("); //$NON-NLS-1$
+			Class<?>[] params = method.getParameterTypes();
+			for (int i = 0; i < params.length; i++) {
+				if (i > 0) {
+					sb.append(","); //$NON-NLS-1$
+				}
+				sb.append("\n    ").append(params[i].getSimpleName()); //$NON-NLS-1$
+				Annotation[] annos = method.getParameterAnnotations()[i];
+				for (Annotation annotation : annos) {
+					if (!(annotation instanceof Help.Doc)) {
+						continue;
+					}
+					Help.Doc paramdoc = (Help.Doc)annotation;
+					if (paramdoc.text() != null) {
+						sb.append(" /* ").append(paramdoc.text()).append(" */"); //$NON-NLS-1$ //$NON-NLS-2$
+						break;
+					}
+				}
+			}
+			sb.append(")\n"); //$NON-NLS-1$
+			for(Class<?> exceptionClass : method.getExceptionTypes()) {
+				sb.append("  throws ").append(exceptionClass.getSimpleName()).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$
+			}
+			String key = method.getName().toUpperCase();
+			List<String> signatures = help.get(key);
+			if (signatures == null) {
+				signatures = new LinkedList<String>();
+				help.put(key, signatures);
+			}
+			signatures.add(sb.toString());
+		}
+		Collections.sort(shortHelp);
+	}
+	
+	public void help() {
+		System.out.println("/* method(arg count) -- description */"); //$NON-NLS-1$
+		for (String helpString : shortHelp) {
+			System.out.println(helpString);
+		}
+	}
+	
+	public void help(String method) {
+		List<String> helpStrings = null;
+		if (method != null) {
+			helpStrings = help.get(method.toUpperCase());
+		}
+		if (helpStrings != null) {
+			for (String helpString : helpStrings) {
+				System.out.println(helpString);
+			}
+		} else {
+			System.out.println("Unknown method");
+		}
+	}
+	
+}


Property changes on: trunk/adminshell/src/main/java/org/teiid/adminshell/Help.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: trunk/adminshell/src/main/java/org/teiid/adminshell/MigrationUtil.java (from rev 2036, trunk/adminshell/src/main/java/org/teiid/MigrationUtil.java)
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/MigrationUtil.java	                        (rev 0)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/MigrationUtil.java	2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,201 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminshell;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipOutputStream;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import com.metamatrix.common.util.ApplicationInfo;
+import com.metamatrix.core.util.FileUtils;
+import com.metamatrix.core.util.ObjectConverterUtil;
+
+ at SuppressWarnings("nls")
+public class MigrationUtil {
+
+	public static void main(String[] args) throws IOException, TransformerConfigurationException, TransformerFactoryConfigurationError, TransformerException {
+		if (args.length != 1) {
+			System.err.println(
+					"Teiid 7.0 VDB Migration Utility" +
+					"\n\nUsage:" +
+					"\n  A vdb or .def file must be specified as the only argument." +
+					"\n\nResult:"+
+					"\n  7.0 compatible replacement files will be created in the same directory " +
+					"\n  as your file." +
+					"\n  If you supply a vdb, the new vdb file will have a _70.vdb suffix." +
+					"\n  If you supply a dynamic vdb file, then two new files will be created: " +
+					"\n  <file name>-vdb.xml and <file name>-bindings.xml" +
+					"\n\nNote: this program will only create connector binding connection factories " +
+					"\n      if the bindings are present in the specified file." +
+					"\n\nNote: this program will NOT create the -ds.xml files needed by JBoss to " +
+					"\n      create underlying DataSource connection pools." +
+					"\n      You will need to manually create one -ds.xml for each JDBC DataSource " +
+					"\n      with a JNDI name of <connector binding name>DS, " +
+					"\n      where any spaces in the name are replace by _" +
+					"\n\nNode: depending upon the connectors used, you may need to manually edit the " +
+					"        -bindings.xml file."); 
+			System.exit(-1);
+		}
+		File file = new File(args[0]);
+		if (!file.exists()) {
+			System.err.println(args[0] + " does not exist."); //$NON-NLS-1$
+			System.exit(-1);
+		}
+		String fullName = file.getName();
+		String fileName = fullName.substring(0, fullName.length() - 4);
+		String ext = FileUtils.getExtension(file);
+		if (ext == null) {
+			System.err.println(fullName + " is not a vdb or xml file."); //$NON-NLS-1$
+			System.exit(-1);
+		}
+		ext = ext.toLowerCase();
+		if (ext.endsWith("vdb")) {
+			File dir = createTempDirectory();
+			try {
+				extract(file, dir);
+				File metainf = new File(dir, "META-INF");
+				File config = new File(dir, "ConfigurationInfo.def"); 
+				File manifest = new File(dir, "MetaMatrix-VdbManifestModel.xmi");
+				if (manifest.exists()) {
+					String configStr = ObjectConverterUtil.convertFileToString(config);
+					String manifestStr = ObjectConverterUtil.convertFileToString(manifest);
+					int index = configStr.lastIndexOf("</VDB>");
+					int manifestBegin = manifestStr.indexOf("<xmi");
+					configStr = configStr.substring(0, index) + manifestStr.substring(manifestBegin) + "</VDB>";
+					FileUtils.write(configStr.getBytes(), config);
+					manifest.delete();
+				}
+				transformConfig(config, "/vdb.xsl", new StreamResult(new File(metainf, "vdb.xml")));
+				transformConfig(config, "/connector.xsl", new StreamResult(new File(file.getParentFile(), fileName + "-bindings-ds.xml")));
+				config.delete();
+				FileOutputStream out = new FileOutputStream(new File(file.getParent(), fileName + "_70.vdb"));
+				ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(out));
+				int parentLength = dir.getPath().length();
+				addDirectory(dir, zos, parentLength);
+				zos.close();
+			} finally {
+				FileUtils.removeDirectoryAndChildren(dir);
+			}
+		} else if (ext.endsWith("xml") || ext.endsWith("def")){
+			File parent = file.getParentFile();
+			transformConfig(file, "/vdb.xsl", new StreamResult(new File(parent, fileName + "-vdb.xml")));
+			transformConfig(file, "/connector.xsl", new StreamResult(new File(parent, fileName + "-bindings-ds.xml")));
+		} else {
+			System.err.println(fullName + " is not a vdb or xml file.  Run with no arguments for help."); //$NON-NLS-1$
+			System.exit(-1);
+		}
+	}
+
+	private static void addDirectory(File dir, ZipOutputStream zos,
+			int parentLength) throws IOException {
+		String[] files = dir.list();
+		for (String entry : files) {
+			File f = new File(dir, entry);
+			if (f.isDirectory()) {
+				addDirectory(f, zos, parentLength);
+			} else {
+				ZipEntry e = new ZipEntry(f.getPath().substring(parentLength));
+				zos.putNextEntry(e);
+				FileUtils.write(f, zos);
+				zos.closeEntry();
+			}
+		}
+	}
+
+	private static void transformConfig(File config, String styleSheet, Result target)
+			throws TransformerFactoryConfigurationError,
+			TransformerConfigurationException, TransformerException {
+		TransformerFactory tf = TransformerFactory.newInstance();
+		Transformer t = tf.newTransformer(new StreamSource(MigrationUtil.class.getResourceAsStream(styleSheet)));
+		t.setParameter("version", ApplicationInfo.getInstance().getReleaseNumber()); //$NON-NLS-1$
+		t.transform(new StreamSource(config), target);
+	}
+
+	/**
+	 * Extract the given zip file to the given destination directory base.
+	 * 
+	 * @param zipFileName
+	 *            The full path and file name of the Zip file to extract.
+	 * @param destinationDirectory
+	 *            The root directory to extract to.
+	 * @throws IOException
+	 */
+	static void extract(final File sourceZipFile, File unzipDestinationDirectory) throws IOException {
+		// Open Zip file for reading
+		ZipFile zipFile = new ZipFile(sourceZipFile, ZipFile.OPEN_READ);
+
+		// Create an enumeration of the entries in the zip file
+		Enumeration zipFileEntries = zipFile.entries();
+
+		// Process each entry
+		while (zipFileEntries.hasMoreElements()) {
+			// grab a zip file entry
+			ZipEntry entry = (ZipEntry) zipFileEntries.nextElement();
+
+			String currentEntry = entry.getName();
+
+			File destFile = new File(unzipDestinationDirectory, currentEntry);
+
+			// grab file's parent directory structure
+			File destinationParent = destFile.getParentFile();
+
+			// create the parent directory structure if needed
+			destinationParent.mkdirs();
+
+			// extract file if not a directory
+			if (!entry.isDirectory()) {
+				ObjectConverterUtil.write(zipFile.getInputStream(entry),
+						destFile);
+			}
+		}
+		zipFile.close();
+	}
+
+	static File createTempDirectory() throws IOException {
+		File temp = File.createTempFile("temp", Long.toString(System.nanoTime()));
+
+		temp.delete();
+
+		if (!(temp.mkdir())) {
+			throw new IOException("Could not create temp directory: "
+					+ temp.getAbsolutePath());
+		}
+
+		return temp;
+	}
+
+}


Property changes on: trunk/adminshell/src/main/java/org/teiid/adminshell/MigrationUtil.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: trunk/adminshell/src/main/java/org/teiid/script/io/MetadataReader.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/script/io/MetadataReader.java	2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/adminshell/src/main/java/org/teiid/script/io/MetadataReader.java	2010-04-16 21:15:33 UTC (rev 2061)
@@ -1,91 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.script.io;
-
-import java.io.IOException;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-
-
-public class MetadataReader extends StringLineReader {
-
-	ResultSetMetaData source;
-    String delimiter = "    "; //$NON-NLS-1$
-
-    boolean firsttime = true;
-	int currentColumn = 0;
-    
-	public MetadataReader(ResultSetMetaData metadata, String delimiter) {
-		this.source = metadata;
-		this.delimiter = delimiter;
-	}
-	
-	@Override
-	protected String nextLine() throws IOException {
-		if (firsttime) {
-			this.firsttime = false;
-			return firstLine();
-		}
-		
-		try {
-			int count = this.source.getColumnCount();
-			if (this.currentColumn < count) {
-				this.currentColumn++;
-				return getNextRow();
-			}
-		} catch (SQLException e) {
-			 throw new IOException(e.getMessage());
-		}
-		return null;
-	}
-	
-    String firstLine() {
-        StringBuffer sb = new StringBuffer();
-        sb.append("ColumnName").append(delimiter); //$NON-NLS-1$
-        sb.append("ColumnType").append(delimiter); //$NON-NLS-1$
-        sb.append("ColumnTypeName").append(delimiter); //$NON-NLS-1$
-        sb.append("ColumnClassName").append(delimiter); //$NON-NLS-1$
-        sb.append("isNullable").append(delimiter); //$NON-NLS-1$
-        sb.append("TableName").append(delimiter); //$NON-NLS-1$
-        sb.append("SchemaName").append(delimiter); //$NON-NLS-1$
-        sb.append("CatalogName").append(delimiter); //$NON-NLS-1$
-        sb.append("\n"); //$NON-NLS-1$
-        return sb.toString();        
-    }	
-	
-	String getNextRow() throws SQLException {
-		StringBuffer sb = new StringBuffer();
-		
-		sb.append(source.getColumnName(currentColumn)).append(delimiter);
-		sb.append(source.getColumnType(currentColumn)).append(delimiter);
-		sb.append(source.getColumnTypeName(currentColumn)).append(delimiter);
-		sb.append(source.getColumnClassName(currentColumn)).append(delimiter);
-		sb.append(source.isNullable(currentColumn)).append(delimiter);
-		sb.append(source.getTableName(currentColumn)).append(delimiter);
-		sb.append(source.getSchemaName(currentColumn)).append(delimiter);
-		sb.append(source.getCatalogName(currentColumn)).append(delimiter);
-		sb.append("\n"); //$NON-NLS-1$
-		
-		return sb.toString();
-	}	
-}

Modified: trunk/adminshell/src/main/java/org/teiid/script/io/ResultSetReader.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/script/io/ResultSetReader.java	2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/adminshell/src/main/java/org/teiid/script/io/ResultSetReader.java	2010-04-16 21:15:33 UTC (rev 2061)
@@ -100,7 +100,7 @@
                 for (int i = 0; i < columnCount; i++) {
                     columnTypes[i] = metadata.getColumnType(i+1);
                 }
-                return firstLine(metadata);
+                return resultSetMetaDataToString(metadata, delimiter);
             }
             
             // if you get here then we are ready to read the results.
@@ -146,8 +146,9 @@
      * @return 
      * @throws SQLException
      */
-    String firstLine(ResultSetMetaData metadata) throws SQLException{
+    public static String resultSetMetaDataToString(ResultSetMetaData metadata, String delimiter) throws SQLException{
         StringBuffer sb = new StringBuffer();
+        int columnCount = metadata.getColumnCount();
         for (int col = 1; col <= columnCount; col++) {
             sb.append(metadata.getColumnName(col))
                 .append("[")          //$NON-NLS-1$
@@ -161,7 +162,7 @@
         return sb.toString();        
     }
     
-	String prettyPrint(SQLXML xml) throws SQLException {
+	public static String prettyPrint(SQLXML xml) throws SQLException {
 		try {
 			TransformerFactory transFactory = TransformerFactory.newInstance();
 			transFactory.setAttribute("indent-number", new Integer(2)); //$NON-NLS-1$

Deleted: trunk/adminshell/src/main/java/org/teiid/script/io/StringArrayReader.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/script/io/StringArrayReader.java	2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/adminshell/src/main/java/org/teiid/script/io/StringArrayReader.java	2010-04-16 21:15:33 UTC (rev 2061)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.script.io;
-
-import java.io.IOException;
-
-
-/** 
- * Converts a String Array object into a Reader object.
- */
-public class StringArrayReader extends StringLineReader {
-    String[] source = null;
-    int index = 0;
-    
-    public StringArrayReader(String[] src) {
-        this.source = src;
-    }
-
-    protected String nextLine() throws IOException {
-        if (index < this.source.length) {
-            return this.source[index++]+"\n"; //$NON-NLS-1$
-        }
-        return null;
-    }
-}

Added: trunk/adminshell/src/main/resources/org/codehaus/groovy/tools/shell/commands.xml
===================================================================
--- trunk/adminshell/src/main/resources/org/codehaus/groovy/tools/shell/commands.xml	                        (rev 0)
+++ trunk/adminshell/src/main/resources/org/codehaus/groovy/tools/shell/commands.xml	2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Copyright (C) 2003-2007 the original author or authors.
+
+    Licensed 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.
+-->
+
+<!-- $Id: commands.xml 12257 2008-05-04 08:51:41Z user57 $ -->
+
+<commands>
+    <command>org.codehaus.groovy.tools.shell.commands.HelpCommand</command>
+
+    <command>org.codehaus.groovy.tools.shell.commands.ExitCommand</command>
+
+    <command>org.codehaus.groovy.tools.shell.commands.ImportCommand</command>
+
+    <command>org.codehaus.groovy.tools.shell.commands.DisplayCommand</command>
+
+    <command>org.codehaus.groovy.tools.shell.commands.ClearCommand</command>
+
+    <command>org.codehaus.groovy.tools.shell.commands.ShowCommand</command>
+
+    <command>org.codehaus.groovy.tools.shell.commands.InspectCommand</command>
+
+    <command>org.codehaus.groovy.tools.shell.commands.PurgeCommand</command>
+
+    <command>org.codehaus.groovy.tools.shell.commands.EditCommand</command>
+
+    <command>org.codehaus.groovy.tools.shell.commands.LoadCommand</command>
+
+    <command>org.codehaus.groovy.tools.shell.commands.SaveCommand</command>
+
+    <command>org.codehaus.groovy.tools.shell.commands.RecordCommand</command>
+
+    <command>org.codehaus.groovy.tools.shell.commands.HistoryCommand</command>
+
+    <command>org.codehaus.groovy.tools.shell.commands.AliasCommand</command>
+
+    <command>org.codehaus.groovy.tools.shell.commands.SetCommand</command>
+
+    <command>org.codehaus.groovy.tools.shell.commands.ShadowCommand</command>
+    
+    <command>org.codehaus.groovy.tools.shell.commands.RegisterCommand</command>
+    
+    <command>org.teiid.adminshell.AdminHelpCommand</command>
+</commands>
+


Property changes on: trunk/adminshell/src/main/resources/org/codehaus/groovy/tools/shell/commands.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/adminshell/src/main/resources/org/teiid/adminshell/AdminHelpCommand.properties
===================================================================
--- trunk/adminshell/src/main/resources/org/teiid/adminshell/AdminHelpCommand.properties	                        (rev 0)
+++ trunk/adminshell/src/main/resources/org/teiid/adminshell/AdminHelpCommand.properties	2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,3 @@
+command.description=Display Teiid Admin Help
+command.usage=[<method>]
+command.help=Display the list of Teiid Admin methods or the help text for @|BOLD method|@.  This reports the same information as the adminHelp([method]) function.
\ No newline at end of file


Property changes on: trunk/adminshell/src/main/resources/org/teiid/adminshell/AdminHelpCommand.properties
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/build/kit-adminshell/adminconsole.bat
===================================================================
--- trunk/build/kit-adminshell/adminconsole.bat	                        (rev 0)
+++ trunk/build/kit-adminshell/adminconsole.bat	2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,79 @@
+ at ECHO OFF
+ at setlocal
+
+ at REM JBoss, Home of Professional Open Source.
+ at REM Copyright (C) 2008 Red Hat, Inc.
+ at REM Licensed to Red Hat, Inc. under one or more contributor 
+ at REM license agreements.  See the copyright.txt file in the
+ at REM distribution for a full listing of individual contributors.
+ at REM 
+ at REM This library is free software; you can redistribute it and/or
+ at REM modify it under the terms of the GNU Lesser General Public
+ at REM License as published by the Free Software Foundation; either
+ at REM version 2.1 of the License, or (at your option) any later version.
+ at REM 
+ at REM This library is distributed in the hope that it will be useful,
+ at REM but WITHOUT ANY WARRANTY; without even the implied warranty of
+ at REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ at REM Lesser General Public License for more details.
+ at REM 
+ at REM You should have received a copy of the GNU Lesser General Public
+ at REM License along with this library; if not, write to the Free Software
+ at REM Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ at REM 02110-1301 USA.
+
+ at REM This assumes it's run from its installation directory. It is also assumed there is a java
+ at REM executable defined along the PATH
+
+ at if not "%ECHO%" == ""  echo %ECHO%
+ at if "%OS%" == "Windows_NT" setlocal
+
+if "%OS%" == "Windows_NT" (
+  set "DIRNAME=%~dp0%"
+) else (
+  set DIRNAME=.\
+)
+
+pushd %DIRNAME%
+if "x%TEIID_HOME%" == "x" (
+  set "TEIID_HOME=%CD%"
+)
+popd
+
+set DIRNAME=
+
+if "x%JAVA_HOME%" == "x" (
+  set  JAVA=java
+  echo JAVA_HOME is not set. Unexpected results may occur.
+  echo Set JAVA_HOME to the directory of your local JDK to avoid this message.
+) else (
+  set "JAVA=%JAVA_HOME%\bin\java"
+  if exist "%JAVA_HOME%\lib\tools.jar" (
+    set "JAVAC_JAR=%JAVA_HOME%\lib\tools.jar"
+  )
+)
+
+set TEIID_CLASSPATH=%TEIID_HOME%\lib\patches\*;%TEIID_HOME%\lib\*;
+
+rem JVM memory allocation pool parameters. Modify as appropriate.
+set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx256m -XX:MaxPermSize=256m
+set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.config.file=log.properties
+
+echo ===============================================================================
+echo.
+echo   Teiid AdminShell Bootstrap Environment
+echo.
+echo   TEIID_HOME: %TEIID_HOME%
+echo.
+echo   JAVA: %JAVA%
+echo.
+echo   JAVA_OPTS: %JAVA_OPTS%
+echo.
+echo   CLASSPATH: %TEIID_CLASSPATH%
+echo.
+echo ===============================================================================
+echo.
+
+"%JAVA%" %JAVA_OPTS% ^
+   -classpath "%TEIID_CLASSPATH%" ^
+   org.teiid.adminshell.GroovyAdminConsole %*


Property changes on: trunk/build/kit-adminshell/adminconsole.bat
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/build/kit-adminshell/adminconsole.sh
===================================================================
--- trunk/build/kit-adminshell/adminconsole.sh	                        (rev 0)
+++ trunk/build/kit-adminshell/adminconsole.sh	2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+# JBoss, Home of Professional Open Source.
+# Copyright (C) 2008 Red Hat, Inc.
+# Licensed to Red Hat, Inc. under one or more contributor 
+# license agreements.  See the copyright.txt file in the
+# distribution for a full listing of individual contributors.
+# 
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+# 
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+# 
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+
+DIRNAME=`dirname $0`
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false;
+linux=false;
+case "`uname`" in
+    CYGWIN*)
+        cygwin=true
+        ;;
+        
+    Linux)
+        linux=true
+        ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+    [ -n "$TEIID_HOME" ] &&
+        TEIID_HOME=`cygpath --unix "$TEIID_HOME"`
+    [ -n "$JAVA_HOME" ] &&
+        JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Setup TEIID_HOME
+if [ "x$TEIID_HOME" = "x" ]; then
+    # get the full path (without any relative bits)
+    TEIID_HOME=`cd $DIRNAME; pwd`
+fi
+export TEIID_HOME
+
+# Setup the JVM
+if [ "x$JAVA" = "x" ]; then
+    if [ "x$JAVA_HOME" != "x" ]; then
+	JAVA="$JAVA_HOME/bin/java"
+    else
+	JAVA="java"
+    fi
+fi
+
+# JPDA options. Uncomment and modify as appropriate to enable remote debugging.
+# JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
+
+TEIID_CLASSPATH="$TEIID_HOME/lib/patches/*:$TEIID_HOME/lib/*"
+JAVA_OPTS="$JAVA_OPTS -Xms128m -Xmx256m -XX:MaxPermSize=256m"
+JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.config.file=log.properties"
+
+# Print the env settings
+echo "======================================================================"
+echo ""
+echo "  Teiid AdminShell Bootstrap Environment"
+echo ""
+echo "  TEIID_HOME  = $TEIID_HOME"
+echo "  CLASSPATH   = $TEIID_CLASSPATH"
+echo "  JAVA        = $JAVA"
+echo ""
+echo "======================================================================"
+echo ""
+
+$JAVA $JAVA_OPTS -cp $TEIID_CLASSPATH -Xmx256m  org.teiid.adminshell.GroovyAdminConsole $*
\ No newline at end of file


Property changes on: trunk/build/kit-adminshell/adminconsole.sh
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/build/kit-adminshell/adminshell.bat
===================================================================
--- trunk/build/kit-adminshell/adminshell.bat	2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/build/kit-adminshell/adminshell.bat	2010-04-16 21:15:33 UTC (rev 2061)
@@ -76,4 +76,4 @@
 
 "%JAVA%" %JAVA_OPTS% ^
    -classpath "%TEIID_CLASSPATH%" ^
-   org.teiid.AdminShell %*
+   org.teiid.adminshell.GroovyAdminShell %*

Modified: trunk/build/kit-adminshell/adminshell.sh
===================================================================
--- trunk/build/kit-adminshell/adminshell.sh	2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/build/kit-adminshell/adminshell.sh	2010-04-16 21:15:33 UTC (rev 2061)
@@ -79,4 +79,4 @@
 echo "======================================================================"
 echo ""
 
-$JAVA $JAVA_OPTS -cp $TEIID_CLASSPATH -Xmx256m  org.teiid.AdminShell $*
\ No newline at end of file
+$JAVA $JAVA_OPTS -cp $TEIID_CLASSPATH -Xmx256m  org.teiid.adminshell.GroovyAdminShell $*
\ No newline at end of file

Modified: trunk/build/kit-adminshell/migrate.bat
===================================================================
--- trunk/build/kit-adminshell/migrate.bat	2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/build/kit-adminshell/migrate.bat	2010-04-16 21:15:33 UTC (rev 2061)
@@ -61,4 +61,4 @@
 
 "%JAVA%" %JAVA_OPTS% ^
    -classpath "%TEIID_CLASSPATH%" ^
-   org.teiid.MigrationUtil %*
+   org.teiid.adminshell.MigrationUtil %*

Modified: trunk/build/kit-adminshell/migrate.sh
===================================================================
--- trunk/build/kit-adminshell/migrate.sh	2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/build/kit-adminshell/migrate.sh	2010-04-16 21:15:33 UTC (rev 2061)
@@ -67,4 +67,4 @@
 JAVA_OPTS="$JAVA_OPTS -Xms128m -Xmx256m -XX:MaxPermSize=256m"
 JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.config.file=log.properties"
 
-$JAVA $JAVA_OPTS -cp $TEIID_CLASSPATH -Xmx256m  org.teiid.MigrationUtil $*
\ No newline at end of file
+$JAVA $JAVA_OPTS -cp $TEIID_CLASSPATH -Xmx256m  org.teiid.adminshell.MigrationUtil $*
\ No newline at end of file

Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/adminshell_guide.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/adminshell_guide.xml	2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/adminshell_guide.xml	2010-04-16 21:15:33 UTC (rev 2061)
@@ -49,10 +49,8 @@
     <xi:include href="content/getting-started.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
     <xi:include href="content/working-with-scripts.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
     <xi:include href="content/connection-management.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
-    <xi:include href="content/writing-tests.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
     <xi:include href="content/appendix-a.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
     <xi:include href="content/appendix-b.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
-    <xi:include href="content/appendix-c.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
     
 </book>
 

Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-a.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-a.xml	2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-a.xml	2010-04-16 21:15:33 UTC (rev 2061)
@@ -6,7 +6,7 @@
         <para>Are there any pre-built scripts available?</para>
       </question>
       <answer>
-        <para>Yes, there are a few utility scripts are available in the "samples" directory with ".bsh" extension.</para>
+        <para>Currently no, but we will provide samples in subsequent releases.</para>
       </answer>
     </qandaentry>
     
@@ -15,38 +15,25 @@
         <para>I have written a very useful script to do XYZ, I would like this to be part of the distribution?</para>
       </question>
       <answer>
-        <para>Yes, we would love to hear from users. Please submit the script to Technical Support, and if this script found to be useful and generic enough for all the customers, we will include the script in the scripts library in the following releases.</para>
+        <para>Yes, we would love to hear from users. Please submit the script through the <ulink url="https://jira.jboss.org/jira/browse/TEIID">Teiid JIRA</ulink>, and if this script popular, we will include the script in the scripts library in the following releases.</para>
       </answer>
     </qandaentry>
 
     <qandaentry>
       <question>
-        <para>What is different between "connect(&lt;url&gt;)" method and "connectAsAdmin()"?</para>
+        <para>What is different between "connectAsAdmin()" and "connect()" ?</para>
       </question>
       <answer>
-        <para>Connect connects to the Teiid system using a VDB name, so you should be able to run any SQL command which is based on that VDB along with Admin method calls. If you use "connectAsAdmin" then you can run all the admin calls but you can not run any SQL commands, and you do not need a VDB to connect to the Teiid system.</para>
+        <para>The connectAsAdmin methods create a contextual connection to the AdminAPI of the Teiid Server.  The connect methods return an extension of the Groovy Sql object to be used for Sql calls to the Teiid Server.</para>
       </answer>
     </qandaentry>
 
     <qandaentry>
       <question>
-        <para>How can I turn on the debug?</para>
-      </question>
-      <answer>
-        <para>At command prompt type</para>
-        <programlisting><![CDATA[
-admin $ debug= true;   // to turn it ON
-admin $ debug= false; // to turn it OFF        
-        ]]></programlisting>        
-      </answer>
-    </qandaentry>
-
-    <qandaentry>
-      <question>
         <para>Is IDE support available for writing the scripts?</para>
       </question>
       <answer>
-        <para>Full IDE support is not available, however eclipse can be used as the editor for developing the scripts. Just set the “.bsh” extension association with Java editor, so all the color syntax is available for your script.</para>
+        <para>The AdminConsole tool is a light IDE.  Full IDE support is available for Groovy, but requires manual manipulation of the class path and script imports.  See <link linkend="other_environments">using AdminShell methods in other environments</link>.</para>
       </answer>
     </qandaentry>
 
@@ -55,24 +42,9 @@
         <para>Is debugging support available?</para>
       </question>
       <answer>
-        <para>No. Not for the scripts. However, if the scripts are calling into other Java code, those calls can be intercepted and can be run through debugger.</para>
+        <para>The interactive shell and console do have built-in support for inspection of the current state.  Performing line based debugging is beyond the scope of this document.</para>
       </answer>
     </qandaentry>
-    
-    <qandaentry>
-      <question>
-        <para>How to turn OFF interactive mode? How can I capture results to a file?</para>
-      </question>
-      <answer>
-        <para>Once you start the shell in the interactive mode, at the prompt enter the following</para>
-        <programlisting><![CDATA[
-          bsh.interactive=false;
-        ]]></programlisting>    
-        <para>this will turn off the interactive features like spitting the results to console. This is good way to capture
-        the results of the executed query. Use <emphasis>printResults(File)</emphasis> method to capture the previously executed
-        SQL command's results to the file handle supplied</para>    
-      </answer>
-    </qandaentry>    
-    
+        
   </qandaset>
 </appendix>
\ No newline at end of file

Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-b.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-b.xml	2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-b.xml	2010-04-16 21:15:33 UTC (rev 2061)
@@ -1,90 +1,24 @@
-<appendix id="assertion_list">
-  <title>Assert Commands Available</title>
-  <para>The following are the list of assert commands available in the Admin Shell to be used with the scripts.
-  </para>
-  <sect1>
-    <title>Assertions for SQL results</title>
-    <programlisting><![CDATA[
-/**
- * Assert that the result set has given number of rows.
- * @param count – Number of rows expected
- */
-assertRowCount(int count); 
-
-
-/**
- * Assert that the result set contents match those of supplied rows
- * @param expectedRows – expected rows 
- */
-assertResultsSetEquals(String[] expectedRows);
-
-/**
- * Assert that the result set contents match those of supplied rows in
- * a file
- * @param expectedRows – expected rows 
- */
-assertResultsSetEquals(File expected)        
-        ]]></programlisting>
-  </sect1>
-  <sect1>
-    <title>Assertions for checking any values</title>
-    <programlisting><![CDATA[
-/**
- * assert that the given expression is true or false
- */
-void assertTrue(boolean condition);
-void assertTrue(String message, boolean condition);
-void assertFalse(boolean condition);
-void assertFalse(String message, boolean condition);
-
-
-/**
- * Assert that two supplied values are equal
- */
-void assertEquals(boolean expected, boolean actual);
-void assertEquals(byte expected, byte actual);
-void assertEquals(char expected, char actual);
-void assertEquals(double expected,  double actual,double delta) ;
-void assertEquals(float expected, float actual,float delta);
-void assertEquals(int expected, int actual);
-void assertEquals(Object expected, Object actual);
-void assertEquals(long expected, long actual);
-void assertEquals(short expected, short actual) ;
-void assertEquals(String message,  boolean expected,  boolean actual);
-void assertEquals(String message, byte expected,byte actual);
-void assertEquals(String message, char expected,char actual);
-void assertEquals(String message, double expected,double actual,double delta);
-void assertEquals(String message, float expected,float actual,float delta);
-void assertEquals(String message, int expected, int actual);
-void assertEquals(String message, Object expected,Object actual);
-void assertEquals(String expected, String actual);
-void assertEquals(String message,String expected,String actual);
-void assertEquals(String message,long expected,long actual)
-void assertEquals(String message,short expected,short actual);
-
-/** 
- * Assert that the given object is either Null or Not Null
- */
-void assertNotNull(Object object);
-void assertNotNull(String message, Object object);
-void assertNull(Object object) ;
-void assertNull(String message, Object object);
-
-/**
- * Assertion to check if two supplied objects same objects or not
- * the difference here is these use == vs equals in the equals methods.
- */
-void assertNotSame(Object expected, Object actual) ;
-void assertNotSame(String message,Object expected,Object actual);
-void assertSame(Object expected, Object actual);
-void assertSame(String message,Object expected,Object actual);
-
-
-/**
- * Assertion to fail the program explicitly
- */
-void fail();
-void fail(String message);    
-    ]]></programlisting>    
-  </sect1>
+<appendix id="other_environments">
+	<title>Other Environments</title>
+	<para>The AdminShell methods (named contextual connections, AdminAPI
+		wrapper, and help system) have no direct dependencies on Groovy and be
+		used in other scripting languages.</para>
+	<para>To use the AdminShell methods in another language, simply import
+		the static methods and Admin classes into your script. You will also
+		need to ensure that the &lt;admin shell
+		dist&gt;/lib/teiid-{version}-client.jar and &lt;admin shell
+		dist&gt;/lib/teiid-adminshell-{version}.jar are in your class path. The
+		snippet below show import statements
+		that would work in Java,
+		BeanShell, Groovy, etc.</para>
+	<programlisting><![CDATA[
+import static org.teiid.adminshell.AdminShell.*;
+import org.teiid.adminapi.*;
+  ]]></programlisting>
+	<para>Note that the provided shell and console executables
+		automatically have the proper class path set and inject the proper
+		imports into running scripts. If you wish to use scripts in a
+		non-Teiid Groovy environment, you will need to manually add these
+		imports and add the admin/client jars to the class path. 
+ 	</para>
 </appendix>
\ No newline at end of file

Deleted: trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-c.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-c.xml	2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-c.xml	2010-04-16 21:15:33 UTC (rev 2061)
@@ -1,59 +0,0 @@
-<appendix id="jdbc_commands">
-  <title>JDBC Commands</title>
-  <para>The following are the list of commands available in the JDBC module, these will aid in executing SQL
-    commands in the Admin Shell. These commands can be used in your program once after the initial connection is
-    made</para>
-  <programlisting><![CDATA[
-/**
- * Executes a SQL Command
- */
-execute(String command);
-
-/**
- * Executes a SQL Command using the prepared statement. Note that command can contain ?
- * for input parameter place holders and the object array can contain the corresponding values. If 
- * command starts with “exec” then it will treat the command as the stored procedure call.
- */
-execute(String command, Object[] parms);
-
-/**
- * Executes a supplied commands in the string array using Batch mode
- * @param commands - array of commands
- */
-execute(String[] commands);
-
-/** 
- * Prints the previously executed ResultSet contents to system out; usally in the interactive more the 
- * resultset is automatically read, so this applies only in the script mode. 
- */
-printResults();
-
-/** 
- * Prints the previously executed ResultSet contents to a file.usally in the interactive more the 
- * resultset is automatically read, so this applies only in the script mode. 
- * @param File
- */
-printResults(File file);
-
-/** 
- * Prints the previously executed ResultSet to system out, in the form required by the assert call. Usally in 
- * the interactive more the resultset is automatically read, so this applies only in the script mode.
- * @param comparePrint - true - print in the format that can be used in the regression tests
- *                     - false - print to console  
- */
-printResults(boolean comparePrint);
-
-/**
- * Walks the ResultSet, but does not print any results. Good for performance testing. Usally in 
- * the interactive more the resultset is automatically read, so this applies only in the script mode.
- */
-walkResults();  
-
-/**
- * Shows the plan associated with the last executed statement.
- * @param xml - true - show in xml form
- *            - false - show in text form  
- */
-showPlan(boolean xml);
-  ]]></programlisting>      
-</appendix>
\ No newline at end of file

Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/connection-management.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/connection-management.xml	2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/connection-management.xml	2010-04-16 21:15:33 UTC (rev 2061)
@@ -5,89 +5,77 @@
   <sect1>
     <title>Default Connection Properties</title>
     <para>The file "connection.properties" in the installation directory of the AdminShell defines the default
-      connection properties with which user can connect to Teiid system. The following  properties can be
+      connection properties with which user can connect to Teiid system. The following properties can be
       defined using this file</para>
     <programlisting><![CDATA[
-server.host = <server host name or ip address>
-server.port = <server port number>
-user.name = <user name>
-user.password = <password>
-vdb.name = <vdb name>    
+admin.url = <server host name or ip address>
+admin.name = <user name>
+admin.password = <password>
+
+jdbc.url = <server host name or ip address>
+jdbc.user = <user name>
+jdbc.password = <password>
       ]]></programlisting>
-    <para>When properties file is found, a call to "connect()" without any input parameters, will connect to
-      the Teiid system using the properties defined in properties file. However, user can always pass in
+    <para>A call to "connect()" or "connectionAsAdmin()" without any input parameters, will connect to
+      the Teiid system using the properties defined in properties file. However, a user can always pass in
       parameters in the connect method to connect to a same or different server than one mentioned in the
-      “connection.properties”.  Look all the all the different connect methods using the “help()” method.  </para>
+      “connection.properties”.  Look all the all the different connect methods using the “adminHelp()” method.  </para>
     <para>Note that it is not secure to leave the passwords in clear text, as defined above. Please take
       necessary measures to secure the properties file, or do not use this feature and always pass in password
       interactively or some other secure way.</para>
     <para>Note: At any given time user can be actively connected to more than one system or have more than one
       connection to same system.  To manage the connections correctly each connection is created given a unique
-      connection name. To learn more about this look at Handling multiple Connections section.</para>
+      connection name. To learn more about this look at <link linkend="mutiple_connections">Handling Multiple Connections</link>.</para>
     <para />
   </sect1>
-  <sect1>
+  <sect1 id="mutiple_connections">
     <title>Handling Multiple Connections</title>
-    <para>Using AdminShell, user can actively manage more than one connection to a single or multiple Teiid
+    <para>Using AdminShell, a user can actively manage more than one connection to a single or multiple Teiid
       systems. For example, two separate connections can be maintained, one to the development server and one to
-      the integration server at the same time. This is possible because Admin Shell supports a feature called named
-      connections. </para>
-    <para>Every time a connection is made, it assigns a unique name to that connection and manages the
-      context  of the connection under that name.  Unless, user makes another connection all the commands executed
-      after the connection is made will use that connection.  If another connect command is executed then a new
-      connection is made with a unique name and execution will be switched to use the new connection that has been
-      created.  The previous connection will be held as it is in its current state, and will not be closed.</para>
+      the integration server at the same time. This is possible because AdminShell supports a feature called named
+      connections.</para>
+    <para>Every time a connection is made, the connection has an explicit or an implicitly assigned name.  
+      If another connect command is executed then a new
+      connection is made with a unique name and execution will be switched to use the new connection.  
+      The previous connection will be held as it is in its current state, and will not be closed.</para>
     <para />
     <para>In the interactive mode the name of the connection can found in the command prompt.  Also, you could
       use the following command in the interactive and script mode to find out the current connection's name</para>
     <programlisting><![CDATA[
-name = currentConnectionName();    
+name = getConnectionName();    
       ]]></programlisting>
-    <para>Knowing the names of the connection that user is working with is important, as this would enable
-      user to switch the active connection that they have currently working with another connection they have
-      previously made.  To switch the active connection, use the following command and supply the name of the
-      connection to be used</para>
+    <para>Knowing the names of the connection that user is working with is important to switch the active connection to a previous connection.  
+    To switch the active connection, use the following command and supply the name of the connection to be used</para>
     <para />
     <programlisting><![CDATA[
-useConnection(name);    
+useConnection("name");    
       ]]></programlisting>
     <para>If user supplies the same name as the active connection as they are currently participating in, then
-      this operation will simply return with out any modifications. There is no limitation as to how many
-      simultaneous connections that user can maintain, this is up to the script developer.</para>
+      this operation will simply return with out any modifications. There is no limitation the number of
+      simultaneous connections.</para>
     <para />
     <para>The following shows an example of using and switching between two connections.</para>
     <programlisting><![CDATA[
 // creates a connection 
-connect();	        	
+connectAsAdmin();	        	
 
 //capture the connection name
-conn1 = currentConnectionName();
+conn1 = getConnectionName();
 
-// run a SQL command using "conn1"
-select * from table;	
+deployVDB("file.vdb")
 
 // creates a second connection 
-connect();		
+connectAsAdmin();		
 
-conn2 = currentConnectionName();
+conn2 = getConnectionName();
 
-// runs a SQL command on the connection "conn2"
-select * from table;	
-	
+deployVDB("file.vdb")
+
 // switch the connection to "conn1"
 useConnection(conn1);	
 
-// run the SQL command using connection "conn1"
-select * from table;	
-
 // close the connection in the "conn1"
-disconnect();
-
-// switch to "conn2"
-useConnection(conn2);
-disconnect();
-
-exit();
+disconnectAll();
       ]]></programlisting>
   </sect1>
 </chapter>
\ No newline at end of file

Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/getting-started.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/getting-started.xml	2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/getting-started.xml	2010-04-16 21:15:33 UTC (rev 2061)
@@ -1,148 +1,138 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
 <chapter id="getting_started">
-  <title>Getting Started with Admin Shell</title>
-  <para>
-    To learn the basics of BeanShell (<ulink url="http://beanshell.org/">http://beanshell.org</ulink>) 
-    take a look at their documents and tutorials on their website A copy of the BeanShell document is also can
-    be found in the AdminShell installation directory. Learn how basic scripts can be written and get familiar with
-    some commonly used commands.
-  </para>
-  <para>Note: BeanShell documentation provided is of version 1.3, which is taken as is from their website,
-    for latest changes refer to BeanShell website. The BeanShell version 2.0b4 is currently being used in
-    AdminShell.</para>
-  <para>
-    Basic knowledge of the Java programming language is required in order to effectively design and develop
-    scripts using the AdminShell. To learn Java language  find learning resources at
-    <ulink url="http://java.sun.com/">http://java.sun.com</ulink>.
-  </para>
-  <para>You can learn about the Teiid administrative API either using “help()” command or find JavaDoc
-    for in the installation directory.</para>
-  <para>AdminShell is a specialized version of BeanShell with lots of pre-built libraries and scripts
-    designed to be  used with the Teiid system. AdminShell works in two different modes: interactive or script
-    run mode.</para>
-  <para>In interactive mode, user can invoke the tool and connect to a live Teiid system and issue any
-    ad-hoc commands to control the system or issue a SQL query against connected virtual database and view the
-    results. All the commands executed during interactive mode are automatically captured into a log file, more
-    on this later in the document.</para>
-  <para>In the script run mode, user can execute/play back previously developed scripts. This mode especially
-    useful to automate any testing or to perform any repeated configurations/migrations changes to a Teiid
-    system</para>  
-  
-  <sect1>
-    <title>Essential rules to follow in using AdminShell</title>
-    <para>To use AdminShell successfully, there are some syntactical rules you should keep in mind.</para>
-    <orderedlist>
-      <listitem>
-        <para>All the commands end with semi-colon [;]. Commands without any input parameters end with open
-          and close parentheses '()' and semi-colon at the end. Example:</para>
-        <programlisting><![CDATA[
-          help();
-        ]]></programlisting>          
-      </listitem>
-      <listitem>
-        <para>All commands are case sensitive. So, enter exactly as command is written.</para>
-      </listitem>
-      <listitem>
-        <para>If a command requires input parameter(s), they should be declared inside "(" and ")" and if they
-          are string based parameters then they should wrapped with double quotes. A command can have more than
-          one parameter. Example:</para>
-        <programlisting><![CDATA[
-          cd("/home/johndoe");
+	<title>Getting Started with AdminShell</title>
+	<para>
+		To learn the basics of
+		<ulink url="http://groovy.codehaus.org/">Groovy</ulink>
+		take a look at their documents and tutorials on their website.
+	</para>
+	<para>
+		Basic knowledge of the Java programming language and types is required
+		in order to effectively design and develop
+		scripts using the AdminShell. To learn Java language find learning resources
+		at <ulink url="http://java.sun.com/">http://java.sun.com</ulink>.
+	</para>
+	<para>You can learn about the Teiid administrative API either using
+		“adminHelp()” function or find JavaDoc
+		for in the installation directory.</para>
+	<para>AdminShell is a specialized version of Groovy which works in
+		several different modes: interactive shell, console, or script
+		run mode.</para>
+	<para>In interactive shell mode (launched via adminshell), the user can invoke connect to a live
+		Teiid system and issue any
+		ad-hoc commands to control the system. The interactive buffer can be used to
+		develop a scipt and the interactive session input and output can be
+		captured into a log file, more
+		on this later in the document.</para>
+	<para>In console mode (lanched via adminconsole), the user can develop and run scripts using a graphical text editor that supports syntax highlighting.</para>
+	<para>In the script run mode, the user can execute/play back previously
+		developed scripts. This mode especially
+		useful to automate any testing or to perform any repeated
+		configurations/migrations changes to a Teiid
+		system</para>
+	<sect1>
+		<title>Essential rules to follow in using AdminShell</title>
+		<para>To use AdminShell successfully, there are some basic syntactical rules
+			you should keep in mind.</para>
+		<orderedlist>
+			<listitem>
+				<para>In interactive mode, most commands (as seen by the help command) are used to control shell behavior and are not general Groovy scripting constructs. Admin methods will typically be called using functional notation:</para>
+				<programlisting><![CDATA[
+          connectAsAdmin()
         ]]></programlisting>
-      </listitem>
-      <listitem>
-        <para>Any other Java program can be invoked from script, if the required Java class libraries are
-          already in class path. Import the required classes and instantiate the class to execute. Example:
+			</listitem>
+			<listitem>
+				<para>All commands and functions are case sensitive.</para>
+			</listitem>
+			<listitem>
+				<para>An ending semicolon is optional for Groovy statements.</para>
+			</listitem>
+			<listitem>
+				<para>If a function requires input parameter(s), they should be
+					declared inside "(" and ")".  A function may have more than
+					one parameter.  String parameters can be wrapped in double or single quotes.  Example:</para>
+				<programlisting><![CDATA[
+          connectAsAdmin("mm://localhost:34413", "user", "password")
+        ]]></programlisting>
+			</listitem>
+			<listitem>
+				<para>Other Java methods and classes can be used from your scripts, if the
+					required Java class libraries are already in class path. You may place additional jars in the 
+					lib directory to have be automatically part of the class path.  An example showing an import:
         </para>
-        <programlisting><![CDATA[
-            import java.sql.*;
-            clazz = new MyClass();
-            clazz.doSomething();          
+				<programlisting><![CDATA[
+            import my.package.*;
+            myObject = new MyClass();
+            myObject.doSomething();          
           ]]></programlisting>
-      </listitem>
-      <listitem>
-        <para>
-          Take a look at a variety of commands available in Bean Shell  to be used along with your scripts. Some
-          of the common ones you can find at
-          <ulink url="http://beanshell.org/manual/bshmanual.html#Useful_BeanShell_Commands">http://beanshell.org/manual/bshmanual.html#Useful_BeanShell_Commands
-          </ulink>
-        </para>
-      </listitem>
-      <listitem>
-        <para>You can write and publish your own scripts. See How to write your own scripts?</para>
-        <para />
-      </listitem>
-    </orderedlist>
-    <para>To execute the commands in interactive mode you enter them first and press enter to execute, then
-      enter next command, so on.</para>
-    <para>To exit the tool in the interactive mode, first disconnect if you are connected to the Teiid
-      system by executing “disconnect();” then execute "exit();". In the script mode, when execution of the
-      script finishes the tool will exit automatically, however you still have to disconnect from Teiid
-      system in the script.</para>
-    <para>Note: If SSL is turned on the Teiid server, you would need to supply the correct certificates
-      for connection. Edit the command file used to execute the AdminShell and make sure correct trust store is
-      defined in the path.</para>
-  </sect1>
-  <sect1>
-    <title>Basic commands to get started</title>
-    <para>The list below contains some common commands used in AdminShell. The best way to learn scripting in the
-      AdminShell is to read the scripts in "samples" directory in the AdminShell kit's installation directory, and
-      experiment your own scripts using a developer instance of Teiid System.</para>
-    <programlisting><![CDATA[   
-print("xxx");   // print something to console
+			</listitem>
+		</orderedlist>
+		<para>To execute the commands and arbitrary script in interactive mode you enter them first
+			and press enter to execute, then
+			enter the next line, so on.</para>
+		<para>To exit the tool in the interactive mode, first disconnect if
+			you are connected to the Teiid
+			system by executing “disconnect();” then type "exit". In the script
+			mode, when execution of the
+			script finishes the tool will exit automatically, however you still have to
+			disconnect from Teiid
+			system in the script.</para>
+		<para>Note: If SSL is turned on the Teiid server, you would need to
+			supply the correct certificates for the connection.
+		</para>
+	</sect1>
+	<sect1>
+		<title>Basic commands to get started</title>
+		<para>The list below contains some common commands used in AdminShell.</para>
+		<programlisting><![CDATA[   
+println "xxx";   // print something to console
 
-help();        // shows all the available admin commands; 
+adminHelp();     // shows all the available admin commands; 
 
-connect();      // connect using connection.properties file
+sql = connect(); // get an extended Groovy Sql connection using connection.properties file
 
-connect(<URL>);   // connect to Teiid using the supplied URL
+sql.execute(<SQL>); // run any SQL command. 
 
-connectAsAdmin(<url>); // connect as admin; no need have the vdb name. SQL commands will not work under this connection
+connectAsAdmin(); // connect as admin; no need have the vdb name. SQL commands will not work under this connection
 
-execute(<SQL>); // run any SQL command. Note in interactive mode you can directly specify SQL on command line
+println getConnectionName();  // returns the current connection name
 
-currentConnectionName();  // returns the current connection name
-
 useConnection(<connection name>); // switches to using the given connection settings
 
 disconnect();   // disconnects the current connection in the context
-
-exit();   // exit the shell        
         ]]></programlisting>
-  </sect1>
-  <sect1>
-    <title>"help" command</title>
-    <para>This below command lists all the available administrative API commands in the AdminShell. Please note
-      that none of the BeanShell commands or custom commands will be shown in this list. Documentation is only
-      source for reviewing those commands presently.</para>
-    <programlisting><![CDATA[ 
-      admin $ help();
+	</sect1>
+	<sect1>
+		<title>Help</title>
+		<para>The adminHelp() methods lists all the available administrative API
+			methods in the AdminShell. Please note
+			that none of the Groovy Shell commands or other available function calls will be shown in
+			this list</para>
+		<programlisting><![CDATA[ 
+adminHelp();
     ]]></programlisting>
-    <para>To get a specific definition about a command and it's required input parameters , use the below form
-      of help. The example shown will show detailed JavaDoc description about "addVDB" method.</para>
-    <programlisting><![CDATA[ 
-admin $ help("deployVDB");
-    /**
-     * Deploy a {@link VDB} file.
-     * @param name  Name of the VDB file to save under
-     * @param VDB 	VDB.
-     * @throws AdminException
-     *             
-     * @return the {@link VDB} representing the current property values and runtime state.
-     */
-public void deployVDB(String fileName, InputStream vdb)
+		<para>To get a specific definition about a method and it's required
+			input parameters, use adminHelp("method")</para>
+		<programlisting><![CDATA[ 
+adminHelp("deployVDB");
+
+/*
+ *Deploy a VDB from file
+ */
+void deployVDB(
+    String /* file name */)
+  throws AdminException
+  throws FileNotFoundException
       ]]></programlisting>
-    <para />
-    <para>If not sure about exact command, and to narrow the list available commands, help can be used in the
-      following form, note the “*” at the end</para>
-    <programlisting><![CDATA[ 
-admin $   help(“get*”);
-      ]]></programlisting>
-    <para>This will list all the commands available that begin with “get”, for example “getConnectionFactories,
-      getVDBs” etc.</para>
-    <para>For every administrative API call, there is corresponding command in AdminShell. For a reference to
-      full administrative API, please look at “documents” sections in the installation directory.</para>
-  </sect1>
-  
+		<para />
+		<para>The sqlHelp() methods lists all Sql extension 
+			methods.</para>
+		<programlisting><![CDATA[ 
+sqlHelp();
+    ]]></programlisting>
+		<para>To get a specific definition about a method and it's required
+			input parameters, use sqlHelp("method")</para>
+		<para />
+	</sect1>
 </chapter>
\ No newline at end of file

Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/introduction.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/introduction.xml	2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/introduction.xml	2010-04-16 21:15:33 UTC (rev 2061)
@@ -1,56 +1,48 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
 <chapter id="introduction">
-  <title>Introduction Teiid Admin Shell</title>
-  <sect1>
-    <title>Introduction to AdminShell</title>
-    <para>
-      Admin Shell is a script based programming environment that enables user to access, monitor and control Teiid
-      Server. This tool is built using programming language called BeanShell (
-      <ulink url="http://beanshell.org/">http://beanshell.org</ulink>
-      ). Admin Shell can be used in ad-hoc scripting, or to run pre-defined scripts. It is not a graphical tool; it's a
-      command line driven environment.
-    </para>
-    <orderedlist>
-      <listitem>
-        <para>It is a fully functional programming environment with resource flow control and exception
-          management. Under the covers it is a fully functional Java programming environment.</para>
-      </listitem>
-      <listitem>
-        <para>It is an Administrative tool. The user can connect to a running Teiid Server and invoke any of
-          the Admin API methods, such as "addVDB" or "stopConnector", to control Teiid System just like using
-          Console. Since, this is script driven, these tasks can be automated and re-run at a later time.</para>
-      </listitem>
-      <listitem>
-        <para>It is a data access tool. The user can connect to a VDB, issue any SQL commands, and view the
-          results of the query.</para>
-      </listitem>
-      <listitem>
-        <para>It is a migration tool. This can be used to develop scripts like moving the Virtual Databases
-          (VDB), Connection Factories, and Configuration from one development environment to another. This will
-          enable users to test and automate their migration scripts before production deployments.</para>
-      </listitem>
-      <listitem>
-        <para>
-          It is a testing tool. The JUnit (
-          <ulink url="http://junit.org/">http://junit.org</ulink>
-          ) test framework is built into it. User can write regression tests for checking system health, or data
-          integrity that can be used to validate a system functionality automatically instead of manual
-          verification by QA personnel.
-        </para>
-      </listitem>
-    </orderedlist>
-    <sect2>
-      <title>Where can you find Admin Shell?</title>
-      <para>Admin Shell is distributed along with other Teiid downloads under "teiid-{version}-adminshell-dist.zip" name. Download and unzip this
-        file to any directory. Once you have unzipped the file, in root directory
-        you will find “adminshell” executable script to invoke the tool.</para>
-      <para>Windows: Double click or execute "adminshell.cmd"</para>
-      <para>*nix: Execute the "adminshell.sh" script</para>
-      <para>to invoke Admin Shell. This will initialize the shell and present you with a prompt:</para>
-      <programlisting><![CDATA[      
-          admin $
-      ]]></programlisting>       
-    </sect2>
-  </sect1>
+   <title>Introduction to Admin Tools</title>
+   <para>
+     AdminShell provides scripting based programming environments that enable user to access, monitor and control a Teiid
+     Server. The Shell and Console tools are built on ones provide by the Groovy (
+     <ulink url="http://groovy.codehaus.org/">http://groovy.codehaus.org/</ulink>
+     ) project.  The AdminShell tools be used in ad-hoc scripting or to run pre-defined scripts.  
+   </para>
+   <orderedlist>
+   	 <title>AdminShell features:</title>
+     <listitem>
+       <para>fully functional programming environment with resource flow control and exception
+         management. See <ulink url="http://groovy.codehaus.org/">Groovy</ulink> docs for the full power of the language.</para>
+     </listitem>
+     <listitem>
+       <para>quick administrative tool. The user can connect to a running Teiid Server and invoke any of
+         the Admin API methods, such as "deployVDB" or "stopConnectionFactory", to control Teiid System. 
+         Since this can be script driven, these tasks can be automated and re-run at a later time.</para>
+     </listitem>
+     <listitem>
+       <para>simplified data access tool. The user can connect to a VDB, issue any SQL commands, and view the
+         results of the query via <ulink url="http://groovy.codehaus.org/Database+features">Groovy Sql</ulink> extensions.</para>
+     </listitem>
+     <listitem>
+       <para>migration tool. This can be used to develop scripts like moving the Virtual Databases
+         (VDB), Connection Factories, and Configuration from one development environment to another. This will
+         enable users to test and automate their migration scripts before production deployments.</para>
+     </listitem>
+     <listitem>
+       <para>testing tool. The JUnit (
+         <ulink url="http://junit.org/">http://junit.org</ulink>
+         ) test framework is built in, see <ulink url="http://groovy.codehaus.org/Unit+Testing">Groovy Unit Tests</ulink>. User can write regression tests for checking system health, or data
+         integrity that can be used to validate a system functionality automatically instead of manual
+         verification by QA personnel.
+       </para>
+     </listitem>
+   </orderedlist>
+   <sect1>
+     <title>Where can you find AdminShell?</title>
+     <para>AdminShell is distributed along with other Teiid downloads under "teiid-{version}-adminshell-dist.zip" name. Download and unzip this
+       file to any directory. Once you have unzipped the file, in root directory
+       you will find "adminshell" and "adminconsole" executable scripts.</para>
+     <para>Windows: Double click or execute "adminshell.cmd"</para>
+     <para>*nix: Execute the "adminshell.sh" script</para>
+   </sect1>
 </chapter>
\ No newline at end of file

Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/working-with-scripts.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/working-with-scripts.xml	2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/working-with-scripts.xml	2010-04-16 21:15:33 UTC (rev 2061)
@@ -3,81 +3,49 @@
 <chapter id="working_with_scripts">
   <title>Working with Scripts</title>
   <sect1>
-    <title>How to write your own scripts</title>
-    <para>Open up a text editor, and enter all the commands in a editor and save the file “.bsh” extension and
-      place it in the distribution where Admin Shell tool can access it. Take  a look at the “samples” directory for
-      example scripts. For example:</para>
-    <programlisting><![CDATA[
-// foo.bsh
-importCommands("commands");
-load("server");
-
-connect();
-execute("select * from pm1.g1");
-printResults();
-disconnect();
-exit();
-    ]]></programlisting>
-    <para>and execute this script file using instructions in Executing script file in non-interactive mode
-      section.</para>
-    <para>All script files that need to be executed in the non-interactive mode must have the following two
-      lines at the beginning of the script file before execution. These two commands will load all the necessary
-      libraries into the shell before execution.</para>
-    <programlisting><![CDATA[
-importCommands("commands");
-load("server");
-        ]]></programlisting>
-  </sect1>
-  <sect1>
     <title>Executing script file in interactive mode</title>
-    <para>To execute a script file "foo.bsh" in a directory "some/directory" in interactive mode, execute as
+    <para>To execute a script file "foo.groovy" in a directory "some/directory" in the shell tool, execute as
       following</para>
     <programlisting><![CDATA[
-admin $ source ("some/directory/foo.bsh");
+. some/directory/foo.groovy
     ]]></programlisting>
-    <para>"foo.bsh" is read into current context of the shell as if you typed in the whole document. If
+    <para>"foo.groovy" is read into current context of the shell as if you typed in the whole document. If
       your script only contained method calls, you can explicitly invoke the call to execute.</para>
+    <para>Full execute syntax may also be used, and is required outside of the Shell tool:</para>
+    <programlisting><![CDATA[
+evaluate("some/directory/foo.groovy" as File)
+    ]]></programlisting>
   </sect1>
   <sect1>
     <title>Executing script file in non-interactive mode</title>
-    <para>To execute a script file "foo.bsh" in a directory "some/directory" in non-interactive mode, execute as
+    <para>To execute a script file "foo.groovy" in a directory "some/directory" in non-interactive mode, execute as
       following command at the command prompt</para>
     <programlisting><![CDATA[
-admin.sh some/directory/foo.bsh
+adminshell.sh . some/directory/foo.groovy
     ]]></programlisting>
-    <para>Note that, in the script mode it is NOT possible to pass in the command line parameters as</para>
+    <para>Parameters can be passed in as Java System properties. For example</para>
     <programlisting><![CDATA[
-admin.sh some/directory/foo.bsh One Two
+adminshell.sh -Dparam=value . some/directory/foo.groovy
     ]]></programlisting>
-    <para>The parameters can be passed in as Java system properties. For example</para>
+    <para>Inside the script file, you can access these properties using System.getProperty</para>
     <programlisting><![CDATA[
-admin.sh some/directory/foo.bsh input1=One input2=Two
+value = System.getProperty(“param”); // will return "value"
     ]]></programlisting>
-    <para>Inside the script file, you can access these properties using Java system property semantics</para>
-    <programlisting><![CDATA[
-value = System.getProperty(“input1”); // will return "One"
-    ]]></programlisting>
   </sect1>
   <sect1>
     <title>Log File and Recorded Script file</title>
-    <para>During the interactive mode, all the commands executed by the user are recorded in
-      "adminscript.txt" file.  This file can be found in the root installation directory. This file later can serve
-      as reference to commands that are executed or  will aid in converting commands executed in the interactive
-      mode into a standalone script, that can be run at a later time.</para>
+    <para>During the interactive mode, input is recorded in a history file. This file can be accessed via the up arrow in the interactive shell.
+    </para>
     <para>User can also capture the commands entered during a interactive session to their own script file by
       using “startRecording” and “stopRecording” commands. For example,</para>
     <para />
     <programlisting><![CDATA[
-admin $ startRecording (“directory/filename.bsh”);
-admin $ <commands..>
-admin $ stopRecording()    
+record start directory/filename.txt
+<commands and script ..>
+record stop    
     ]]></programlisting>
-    <para>in this case all the commands executed after the “startRecording” and before the “stopRecording” are
-      captured in the “directory/filename.bsh” file. This gives the user an option to capture only certain portions
-      of the interactive session tat they are interested in and ignore the rest of it.</para>
+    <para>All input and output between the start and stop are captured in the “directory/filename.txt” file. 
+      This gives the user an option to capture only certain portions of the interactive session and to later refine a script out of recorded file.</para>
     <para />
-    <para>Also note that all the output during the interactive mode is sent to "adminshell.log" file. In the
-      script mode, no such files are created.  In script mode, user can capture the standard out and redirect to a
-      file if they need the log file.</para>
   </sect1>
 </chapter>
\ No newline at end of file

Deleted: trunk/documentation/admin-guide/src/main/docbook/en-US/content/writing-tests.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/writing-tests.xml	2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/writing-tests.xml	2010-04-16 21:15:33 UTC (rev 2061)
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
-<chapter id="writing_tests">
-  <title>Writing Tests using AdminShell</title>
-  <para>
-    <ulink url="http://junit.org">JUnit</ulink>
-    testing framework is integrated into the AdminShell, so you can write regression tests and run tests in the JUnit
-    style. To write a test,
-    <orderedlist>
-      <listitem>
-        <para>start a method name which begins with "testxxxx()"</para>
-      </listitem>
-      <listitem>
-        <para>use method body to write actual test. Method body can contain any Admin Shell based script using Admin
-          API and JDBC commands</para>
-      </listitem>
-      <listitem>
-        <para>finally use “assertions” to validate results.</para>
-      </listitem>
-    </orderedlist>
-    For example:
-  </para>
-  <programlisting><![CDATA[ 
-testCountRows(){
-	connect();
-	execute("select * from table");
-
-	// make sure you have 100 rows
-	assertRowCount(100);		
-
-	disconnect();
-}
-
-testResults(){
-	connect();
-	execute("select * from table");
-
-	// defines the all the values you are expecting
-	String[] expected ={
-		{"col1[string]", "col2[int]"},
-		{"VALUE1", "100"}
-		..
-	};
-	
-	// make sure your results match to expected
-	assertResultSet(expected);		
-	disconnect();
-}
-
-// now actually run the above defined tests
-runTests();
-      ]]></programlisting>
-  <para>In the above example, “testCountRows”, made connection to a Teiid system and issued a query and made
-    sure that certain table has required number of rows. Where as “testResults” asserted that results match to a
-    certain set of pre-built results.</para>
-  <para>
-    Note the “runTests()” call at the end of the script, as this is the call which triggers the execution of the
-    tests defined in the script. There are various types asserts you can use in your scripts, for the all the
-    available assert types please refer to
-    <link linkend="assertion_list">Assertion Library</link>
-  </para>
-</chapter>
\ No newline at end of file

Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/AbstractQueryTest.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/AbstractQueryTest.java	2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/AbstractQueryTest.java	2010-04-16 21:15:33 UTC (rev 2061)
@@ -41,9 +41,7 @@
 import java.sql.Statement;
 
 import org.junit.After;
-import org.teiid.script.io.MetadataReader;
 import org.teiid.script.io.ResultSetReader;
-import org.teiid.script.io.StringArrayReader;
 
 
 

Copied: trunk/test-integration/common/src/test/java/org/teiid/jdbc/MetadataReader.java (from rev 2057, trunk/adminshell/src/main/java/org/teiid/script/io/MetadataReader.java)
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/MetadataReader.java	                        (rev 0)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/MetadataReader.java	2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.jdbc;
+
+import java.io.IOException;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+
+import org.teiid.script.io.StringLineReader;
+
+
+public class MetadataReader extends StringLineReader {
+
+	ResultSetMetaData source;
+    String delimiter = "    "; //$NON-NLS-1$
+
+    boolean firsttime = true;
+	int currentColumn = 0;
+    
+	public MetadataReader(ResultSetMetaData metadata, String delimiter) {
+		this.source = metadata;
+		this.delimiter = delimiter;
+	}
+	
+	@Override
+	protected String nextLine() throws IOException {
+		if (firsttime) {
+			this.firsttime = false;
+			return firstLine();
+		}
+		
+		try {
+			int count = this.source.getColumnCount();
+			if (this.currentColumn < count) {
+				this.currentColumn++;
+				return getNextRow();
+			}
+		} catch (SQLException e) {
+			 throw new IOException(e.getMessage());
+		}
+		return null;
+	}
+	
+    String firstLine() {
+        StringBuffer sb = new StringBuffer();
+        sb.append("ColumnName").append(delimiter); //$NON-NLS-1$
+        sb.append("ColumnType").append(delimiter); //$NON-NLS-1$
+        sb.append("ColumnTypeName").append(delimiter); //$NON-NLS-1$
+        sb.append("ColumnClassName").append(delimiter); //$NON-NLS-1$
+        sb.append("isNullable").append(delimiter); //$NON-NLS-1$
+        sb.append("TableName").append(delimiter); //$NON-NLS-1$
+        sb.append("SchemaName").append(delimiter); //$NON-NLS-1$
+        sb.append("CatalogName").append(delimiter); //$NON-NLS-1$
+        sb.append("\n"); //$NON-NLS-1$
+        return sb.toString();        
+    }	
+	
+	String getNextRow() throws SQLException {
+		StringBuffer sb = new StringBuffer();
+		
+		sb.append(source.getColumnName(currentColumn)).append(delimiter);
+		sb.append(source.getColumnType(currentColumn)).append(delimiter);
+		sb.append(source.getColumnTypeName(currentColumn)).append(delimiter);
+		sb.append(source.getColumnClassName(currentColumn)).append(delimiter);
+		sb.append(source.isNullable(currentColumn)).append(delimiter);
+		sb.append(source.getTableName(currentColumn)).append(delimiter);
+		sb.append(source.getSchemaName(currentColumn)).append(delimiter);
+		sb.append(source.getCatalogName(currentColumn)).append(delimiter);
+		sb.append("\n"); //$NON-NLS-1$
+		
+		return sb.toString();
+	}	
+}

Copied: trunk/test-integration/common/src/test/java/org/teiid/jdbc/StringArrayReader.java (from rev 2057, trunk/adminshell/src/main/java/org/teiid/script/io/StringArrayReader.java)
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/StringArrayReader.java	                        (rev 0)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/StringArrayReader.java	2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.jdbc;
+
+import java.io.IOException;
+
+import org.teiid.script.io.StringLineReader;
+
+
+/** 
+ * Converts a String Array object into a Reader object.
+ */
+public class StringArrayReader extends StringLineReader {
+    String[] source = null;
+    int index = 0;
+    
+    public StringArrayReader(String[] src) {
+        this.source = src;
+    }
+
+    protected String nextLine() throws IOException {
+        if (index < this.source.length) {
+            return this.source[index++]+"\n"; //$NON-NLS-1$
+        }
+        return null;
+    }
+}



More information about the teiid-commits mailing list