From: <pat...@us...> - 2009-01-24 19:34:28
|
Revision: 855 http://cishell.svn.sourceforge.net/cishell/?rev=855&view=rev Author: pataphil Date: 2009-01-24 19:34:25 +0000 (Sat, 24 Jan 2009) Log Message: ----------- Initial commit. Added Paths: ----------- trunk/templates/org.cishell.templates.database/.classpath trunk/templates/org.cishell.templates.database/.project trunk/templates/org.cishell.templates.database/.settings/ trunk/templates/org.cishell.templates.database/.settings/org.eclipse.jdt.core.prefs trunk/templates/org.cishell.templates.database/.settings/org.eclipse.pde.core.prefs trunk/templates/org.cishell.templates.database/META-INF/ trunk/templates/org.cishell.templates.database/META-INF/MANIFEST.MF trunk/templates/org.cishell.templates.database/build.properties trunk/templates/org.cishell.templates.database/src/ trunk/templates/org.cishell.templates.database/src/org/ trunk/templates/org.cishell.templates.database/src/org/cishell/ trunk/templates/org.cishell.templates.database/src/org/cishell/templates/ trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/ trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/Activator.java trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/SQLExecutionAlgorithm.java trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/SQLFormationException.java Added: trunk/templates/org.cishell.templates.database/.classpath =================================================================== --- trunk/templates/org.cishell.templates.database/.classpath (rev 0) +++ trunk/templates/org.cishell.templates.database/.classpath 2009-01-24 19:34:25 UTC (rev 855) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> Added: trunk/templates/org.cishell.templates.database/.project =================================================================== --- trunk/templates/org.cishell.templates.database/.project (rev 0) +++ trunk/templates/org.cishell.templates.database/.project 2009-01-24 19:34:25 UTC (rev 855) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.cishell.templates.database</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Added: trunk/templates/org.cishell.templates.database/.settings/org.eclipse.jdt.core.prefs =================================================================== --- trunk/templates/org.cishell.templates.database/.settings/org.eclipse.jdt.core.prefs (rev 0) +++ trunk/templates/org.cishell.templates.database/.settings/org.eclipse.jdt.core.prefs 2009-01-24 19:34:25 UTC (rev 855) @@ -0,0 +1,7 @@ +#Thu Jan 15 13:52:40 EST 2009 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 Added: trunk/templates/org.cishell.templates.database/.settings/org.eclipse.pde.core.prefs =================================================================== --- trunk/templates/org.cishell.templates.database/.settings/org.eclipse.pde.core.prefs (rev 0) +++ trunk/templates/org.cishell.templates.database/.settings/org.eclipse.pde.core.prefs 2009-01-24 19:34:25 UTC (rev 855) @@ -0,0 +1,4 @@ +#Thu Jan 15 13:52:40 EST 2009 +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false Added: trunk/templates/org.cishell.templates.database/META-INF/MANIFEST.MF =================================================================== --- trunk/templates/org.cishell.templates.database/META-INF/MANIFEST.MF (rev 0) +++ trunk/templates/org.cishell.templates.database/META-INF/MANIFEST.MF 2009-01-24 19:34:25 UTC (rev 855) @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.cishell.templates.database +Bundle-SymbolicName: org.cishell.templates.database;singleton:=true +Bundle-Version: 1.0.0 +X-AutoStart: true +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Import-Package: org.cishell.framework;version="1.0.0", + org.cishell.framework.algorithm;version="1.0.0", + org.cishell.framework.data;version="1.0.0", + org.cishell.service.database, + org.osgi.framework;version="1.3.0", + org.osgi.service.component;version="1.0.0", + org.osgi.service.log;version="1.3.0", + org.osgi.service.metatype;version="1.1.0" +Bundle-Activator: org.cishell.templates.database.Activator +Export-Package: org.cishell.templates.database Added: trunk/templates/org.cishell.templates.database/build.properties =================================================================== --- trunk/templates/org.cishell.templates.database/build.properties (rev 0) +++ trunk/templates/org.cishell.templates.database/build.properties 2009-01-24 19:34:25 UTC (rev 855) @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . Added: trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/Activator.java =================================================================== --- trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/Activator.java (rev 0) +++ trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/Activator.java 2009-01-24 19:34:25 UTC (rev 855) @@ -0,0 +1,20 @@ +package org.cishell.templates.database; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + } +} Added: trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/SQLExecutionAlgorithm.java =================================================================== --- trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/SQLExecutionAlgorithm.java (rev 0) +++ trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/SQLExecutionAlgorithm.java 2009-01-24 19:34:25 UTC (rev 855) @@ -0,0 +1,134 @@ +package org.cishell.templates.database; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.Dictionary; + +import javax.sql.DataSource; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.algorithm.AlgorithmExecutionException; +import org.cishell.framework.data.BasicData; +import org.cishell.framework.data.Data; +import org.cishell.service.database.DatabaseCreationException; +import org.cishell.service.database.DatabaseService; + +public abstract class SQLExecutionAlgorithm implements Algorithm { + protected Data[] data; + protected Dictionary parameters; + protected CIShellContext context; + + protected DatabaseService databaseService; + + public SQLExecutionAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) { + this.data = data; + this.parameters = parameters; + this.context = context; + + this.databaseService = (DatabaseService)context.getService(DatabaseService.class.getName()); + } + + // TODO: Update the output to have proper contents. (Since we're only using one + // database now, the ACTUAL (wrapped DataSource) should be the same, but new + // DataSourceWithIDs should be created as the output.) + public Data[] execute() throws AlgorithmExecutionException { + System.err.println("this.databaseService: " + this.databaseService); + // Unpack the in-data as a data source. + DataSource dataSource = (DataSource)this.data[0].getData(); + // Open a connection with the data source so we can perform SQL on the + // data source. + Connection dataSourceConnection = null; + // The statement is what will actually execute our SQL. + Statement sqlStatement = null; + + try { + dataSourceConnection = dataSource.getConnection(); + sqlStatement = dataSourceConnection.createStatement(); + } + catch (SQLException e) { + throw new AlgorithmExecutionException(e); + } + + String sqlStatementString = null; + + // Attempt to form our SQL query and update. + try { + sqlStatementString = formSQL(); + } + catch (SQLFormationException sqlFormationException) { + throw new AlgorithmExecutionException(sqlFormationException); + } + + // Success at this point (with forming the SQL), so execute it if it is not + // empty. + if (!sqlStatement.equals("")) { + try { + // If execute returns true, there is at least one result set. So, + // let's get those and turn them into data sources for our out-data + // YAY! + if (sqlStatement.execute(sqlStatementString)) { + // Used to store the list of + // result-sets-converted-to-new-databases that we're working on. + ArrayList resultSetsConvertedToNewDatabases = new ArrayList(); + + do { + // Get the current result set. + ResultSet resultSet = sqlStatement.getResultSet(); + + // Construct the new database out of the result set. + + DataSource newDatabase = null; + + /* try { + newDatabase = null; + // this.databaseService.createDatabase(resultSet); + } + catch (DatabaseCreationException e) { + throw new AlgorithmExecutionException(e); + } */ + + // Wrap the new database. + Data newDatabaseData = createOutDataFromDataSource(newDatabase); + + // Add the new out-data entry to our working list. + resultSetsConvertedToNewDatabases.add(newDatabaseData); + } + while (sqlStatement.getMoreResults()); + + // Convert the ArrayList to a Data[]. + Data[] finalResultSetsConvertedToNewDatabasesData = + new Data[resultSetsConvertedToNewDatabases.size()]; + + finalResultSetsConvertedToNewDatabasesData = + (Data[])resultSetsConvertedToNewDatabases.toArray + (finalResultSetsConvertedToNewDatabasesData); + + return manipulateFinalOutData + (finalResultSetsConvertedToNewDatabasesData); + } + } + catch (SQLException sqlException) { + throw new AlgorithmExecutionException(sqlException); + } + } + + // + return null; + } + + public String formSQL() throws SQLFormationException { + return ""; + } + + public Data createOutDataFromDataSource(DataSource dataSource) { + return new BasicData(dataSource, dataSource.getClass().getName()); + } + + public Data[] manipulateFinalOutData(Data[] outData) { + return outData; + } +} \ No newline at end of file Added: trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/SQLFormationException.java =================================================================== --- trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/SQLFormationException.java (rev 0) +++ trunk/templates/org.cishell.templates.database/src/org/cishell/templates/database/SQLFormationException.java 2009-01-24 19:34:25 UTC (rev 855) @@ -0,0 +1,24 @@ +package org.cishell.templates.database; + +public class SQLFormationException extends Exception { + + private static final long serialVersionUID = 1L; + + //Constructors from Exception superclass + + public SQLFormationException() { + super(); + } + + public SQLFormationException(String arg0) { + super(arg0); + } + + public SQLFormationException(Throwable arg0) { + super(arg0); + } + + public SQLFormationException(String arg0, Throwable arg1) { + super(arg0, arg1); + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |