View Javadoc

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 com.salto.db.generator.Constants;
8   
9   import salto.tool.jdo.data.JdoInfo;
10  import salto.tool.jdo.util.CreatorUtil;
11  
12  public class EJB3HibernateDAOAndTestCasesPlugin extends
13  		EJB3AndHibernateDAOPlugin {
14  
15  	public String getLongDescription() {
16  		return "This plugin will generate Hibernate EJB3 POJOS, hibernate.cfg.xml, DAOs and a test case for each class.";
17  	}
18  
19  	public String getName() {
20  		return "EJB3HibernateDaoAndTestCases";
21  	}
22  
23  	public String getShortDescription() {
24  		return "EJB3 + Hibernate DAO + TestCases";
25  	}
26  
27  	public void execute(String className, JdoInfo info) throws Exception {
28  
29  		ejb3Plugin.execute(className, info);
30  
31  		CreatorUtil.getDoNameCreator().setPrefix(doPrefix);
32  		CreatorUtil.getDoNameCreator().setDefaultNameOffset(
33  				this.defaultNameOffset);
34  		Map context = new HashMap();
35  		context.put("jdoInfo", info);
36  		context.put("util", CreatorUtil.getInstance());
37  		context.put("templatePath", TEMPLATE_PATH);
38  		context.put("generatorVersion", Constants.GENERATOR_NAME + " / "
39  				+ this.getShortDescription());
40  		context.put("date", new Date());
41  		info.setJavaPckName(pckName);
42  		info.setJavaClassName(className);
43  
44  		runVelocity(TEMPLATE_PATH, "hibernatedao.vm", srcPath + "/"
45  				+ (pckName + ".hibernate").replace('.', '/') + "/", className
46  				+ "HibernateDAO.java", context);
47  
48  		runVelocity(TEMPLATE_PATH, "dao.vm", srcPath + "/"
49  				+ pckName.replace('.', '/') + "/", className + "DAO.java",
50  				context);
51  
52  		runVelocity(TEMPLATE_PATH, "test.vm", srcPath + "/"
53  				+ (pckName + ".test").replace('.', '/') + "/", className
54  				+ "DAOTest.java", context);
55  
56  	}
57  
58  }