1 package com.salto.db.generator.plugin; 2 3 import java.util.Date; 4 import java.util.HashMap; 5 import java.util.Map; 6 7 import org.apache.velocity.Template; 8 import org.apache.velocity.app.Velocity; 9 10 import com.salto.db.generator.Constants; 11 12 import salto.tool.jdo.data.JdoInfo; 13 import salto.tool.jdo.util.CreatorUtil; 14 15 public class SpringEJB3AndHibernateDAOAndTestCasesPlugin extends 16 SpringEJB3AndHibernateDAOPlugin { 17 18 public void execute(String className, JdoInfo info) throws Exception { 19 20 super.execute(className, info); 21 22 CreatorUtil.getDoNameCreator().setPrefix(doPrefix); 23 CreatorUtil.getDoNameCreator().setDefaultNameOffset( 24 this.defaultNameOffset); 25 Map context = new HashMap(); 26 context.put("jdoInfo", info); 27 context.put("util", CreatorUtil.getInstance()); 28 context.put("templatePath", TEMPLATE_PATH); 29 context.put("generatorVersion", Constants.GENERATOR_NAME + " / " 30 + this.getShortDescription()); 31 context.put("date", new Date()); 32 info.setJavaPckName(pckName); 33 info.setJavaClassName(className); 34 35 runVelocity(TEMPLATE_PATH, "test.vm", srcPath + "/" 36 + (pckName + ".test").replace('.', '/') + "/", className 37 + "DAOTest.java", context); 38 39 } 40 41 public String getLongDescription() { 42 return "This plugin will generate Hibernate EJB3 POJOS, hibernate.cfg.xml, Spring DAOs for each class and unit tests for each dao."; 43 } 44 45 public String getName() { 46 return "SpringEJB3AndHibernateDaoAndTestCases"; 47 } 48 49 public String getShortDescription() { 50 return "EJB3 + Spring/Hibernate DAO + TestCases"; 51 } 52 53 public void postExecute(JdoInfo[] infos) throws Exception { 54 55 super.postExecute(infos); 56 CreatorUtil.getDoNameCreator().setPrefix(doPrefix); 57 CreatorUtil.getDoNameCreator().setDefaultNameOffset( 58 this.defaultNameOffset); 59 Map context = new HashMap(); 60 context.put("jdoInfos", infos); 61 context.put("connInfo", infos[0].getConnInfo()); 62 context.put("util", CreatorUtil.getInstance()); 63 context.put("templatePath", TEMPLATE_PATH); 64 context.put("generatorVersion", Constants.GENERATOR_NAME + " / " 65 + this.getShortDescription()); 66 context.put("date", new Date()); 67 context.put("dialect", this.ejb3Plugin); 68 context.put("pckName", pckName); 69 context.put("hibernateDialectHelper", new HibernateDialectHelper()); 70 context.put("annotations", String.valueOf(ejb3Plugin 71 .isGenerateAnnotations())); 72 runVelocity(TEMPLATE_PATH, "applicationContext-test.xml.vm", srcPath, 73 "applicationContext-test.xml", context); 74 } 75 76 }