1
2
3
4
5
6
7 package org.asyrinx.joey.gen.command.rdb2java.standard;
8
9 import java.util.Iterator;
10
11 import org.apache.commons.lang.StringUtils;
12 import org.asyrinx.joey.gen.command.rdb.CopyAncestorOption;
13 import org.asyrinx.joey.gen.command.rdb2java.PackagingStrategy;
14 import org.asyrinx.joey.gen.model.Element;
15 import org.asyrinx.joey.gen.model.java.Entity;
16 import org.asyrinx.joey.gen.model.java.JavaEnumeration;
17 import org.asyrinx.joey.gen.model.java.PackageType;
18
19 /***
20 * @author takeshi
21 */
22 public class SimplePackaging implements PackagingStrategy {
23
24 /***
25 *
26 */
27 public SimplePackaging() {
28 super();
29 }
30
31 private CopyAncestorOption copyPackageNames = new CopyAncestorOption(JavaOptions.JAVA_PACKAGE);
32
33
34
35
36
37
38 public String getPackageName(Element element) {
39 return copyPackageNames.getOptionValue(element);
40 }
41
42 public static final String PACKAGE_TEMPLATE_SYMBOL = "${packageType}";
43
44
45
46
47
48
49 public void preparePackageNames(Entity entity) {
50 final String template = entity.getPackageTemplate();
51 for (Iterator i = PackageType.getElements().iterator(); i.hasNext();) {
52 fiPackageType packageType = (PackageType) i/next()/package-summary.html">nal PackageType packageType = (PackageType) i.next();
53 entity.setPackage(packageType.getName(), genPackageName(template, packageType));
54 }
55 }
56
57 /***
58 * @param template
59 * @param packageType
60 * @return
61 */
62 private String genPackageName(final String template, final PackageType packageType) {/package-summary.html">ong> String genPackageName(final String template, final PackageType packageType) {
63 final</strong> String packageName = StringUtils.replace(template, PACKAGE_TEMPLATE_SYMBOL, packageType.getName());
64 return</strong> packageName;
65 }
66
67
68
69
70
71
72 public void preparePackageName(JavaEnumeration enum) {
73 enum.setPackageName(genPackageName(enum.getPackageName(), PackageType.ENTITY));
74 }
75
76 }