// Path: src/main/java/fr/inria/gforge/spoon/transformation/dbaccess/annotation/DBType.java
// public enum DBType {
//     RELATIONAL,
//     OBJECT,
//     FILE
// }
// 
// Path: src/main/java/fr/inria/gforge/spoon/transformation/dbaccess/template/DBCodeTemplate.java
// public class DBCodeTemplate extends ExtensionTemplate {
//     @Parameter
//     public String _database_;
// 
//     @Parameter
//     public String _username_;
// 
//     @Parameter
//     public String _password_;
// 
//     @Parameter
//     public String _tableName_;
// 
//     @Parameter
//     public String _columnName_;
// 
//     Connection connection;
// 
//     @Local
//     String key;
// 
//     public DBCodeTemplate(Factory f, String database, String username,
//             String password, String tableName) {
//         this._database_ = database;
//         this._username_ = username;
//         this._password_ = password;
//         this._tableName_ = tableName;
//     }
// 
//     public void initializerCode() {
//         try {
//             Class.forName("org.postgresql.Driver");
//         } catch (ClassNotFoundException e) {
//             e.printStackTrace();
//             return;
//         }
//         try {
//             connection = DriverManager.getConnection("jdbc:postgresql:"
//                     + _database_, _username_, _password_);
//         } catch (SQLException e) {
//             new Exception("failed to connect to the database with "
//                     + "jdbc:postgresql:" + _database_ + "," + _username_ + ","
//                     + _password_).printStackTrace();
//         }
//     }
// 
//     public String accessCode() {
//         String query = "select " + _columnName_ + " from " + _tableName_
//                 + " where key=" + key;
//         Statement s = null;
//         try {
//             s = connection.createStatement();
//             ResultSet rs = s.executeQuery(query);
//             rs.first();
//             return rs.getString(1);
//         } catch (java.sql.SQLException ex12) {
//             ex12.printStackTrace();
//         } finally {
//             try {
//                 s.close();
//             } catch (Exception ex13) {
//                 ex13.printStackTrace();
//             }
//         }
//         return null;
//     }
// 
// }


import fr.inria.gforge.spoon.transformation.dbaccess.annotation.DBAccess;
import fr.inria.gforge.spoon.transformation.dbaccess.annotation.DBType;
import fr.inria.gforge.spoon.transformation.dbaccess.template.DBCodeTemplate;
import org.apache.log4j.Level;
import spoon.processing.AbstractAnnotationProcessor;
import spoon.reflect.code.CtStatement;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtConstructor;
import spoon.reflect.declaration.CtMethod;
import spoon.reflect.factory.Factory;
import spoon.template.Substitution;
package fr.inria.gforge.spoon.transformation.dbaccess.processing;


public class DBAccessProcessor extends
		AbstractAnnotationProcessor<DBAccess, CtClass<?>> {

	public void process(DBAccess dbAccess, CtClass<?> target) {
		Factory f = target.getFactory();
// Path: src/main/java/fr/inria/gforge/spoon/transformation/dbaccess/annotation/DBType.java
// public enum DBType {
//     RELATIONAL,
//     OBJECT,
//     FILE
// }
// 
// Path: src/main/java/fr/inria/gforge/spoon/transformation/dbaccess/template/DBCodeTemplate.java
// public class DBCodeTemplate extends ExtensionTemplate {
//     @Parameter
//     public String _database_;
// 
//     @Parameter
//     public String _username_;
// 
//     @Parameter
//     public String _password_;
// 
//     @Parameter
//     public String _tableName_;
// 
//     @Parameter
//     public String _columnName_;
// 
//     Connection connection;
// 
//     @Local
//     String key;
// 
//     public DBCodeTemplate(Factory f, String database, String username,
//             String password, String tableName) {
//         this._database_ = database;
//         this._username_ = username;
//         this._password_ = password;
//         this._tableName_ = tableName;
//     }
// 
//     public void initializerCode() {
//         try {
//             Class.forName("org.postgresql.Driver");
//         } catch (ClassNotFoundException e) {
//             e.printStackTrace();
//             return;
//         }
//         try {
//             connection = DriverManager.getConnection("jdbc:postgresql:"
//                     + _database_, _username_, _password_);
//         } catch (SQLException e) {
//             new Exception("failed to connect to the database with "
//                     + "jdbc:postgresql:" + _database_ + "," + _username_ + ","
//                     + _password_).printStackTrace();
//         }
//     }
// 
//     public String accessCode() {
//         String query = "select " + _columnName_ + " from " + _tableName_
//                 + " where key=" + key;
//         Statement s = null;
//         try {
//             s = connection.createStatement();
//             ResultSet rs = s.executeQuery(query);
//             rs.first();
//             return rs.getString(1);
//         } catch (java.sql.SQLException ex12) {
//             ex12.printStackTrace();
//         } finally {
//             try {
//                 s.close();
//             } catch (Exception ex13) {
//                 ex13.printStackTrace();
//             }
//         }
//         return null;
//     }
// 
// }


// Path: src/main/java/fr/inria/gforge/spoon/transformation/dbaccess/processing/DBAccessProcessor.java
import fr.inria.gforge.spoon.transformation.dbaccess.annotation.DBAccess;
import fr.inria.gforge.spoon.transformation.dbaccess.annotation.DBType;
import fr.inria.gforge.spoon.transformation.dbaccess.template.DBCodeTemplate;
import org.apache.log4j.Level;
import spoon.processing.AbstractAnnotationProcessor;
import spoon.reflect.code.CtStatement;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtConstructor;
import spoon.reflect.declaration.CtMethod;
import spoon.reflect.factory.Factory;
import spoon.template.Substitution;

package fr.inria.gforge.spoon.transformation.dbaccess.processing;


public class DBAccessProcessor extends
		AbstractAnnotationProcessor<DBAccess, CtClass<?>> {

	public void process(DBAccess dbAccess, CtClass<?> target) {
		Factory f = target.getFactory();
		DBType t = dbAccess.type();