2
* AbstractGDIGenerator.java
4
* Created on April 4, 2006, 9:23 AM
6
* To change this template, choose Tools | Template Manager
7
* and open the template in the editor.
10
package com.sun.grid.cull;
12
import java.util.logging.Level;
13
import java.util.logging.Logger;
16
* Abstract helper class for generating code which performs GDI actions
18
public abstract class AbstractGDIGenerator {
20
protected Logger logger = Logger.getLogger("cullconv");
22
/* classname of the cull object without packagename */
23
protected String classname;
25
protected String name;
27
/* key is the name of the primary key field, value is the java type */
28
protected java.util.Map<String,String> primaryKeys = new java.util.HashMap<String,String>();
30
protected com.sun.grid.cull.CullObject cullObject;
32
public AbstractGDIGenerator(String name, String classname,
33
com.sun.grid.cull.CullObject cullObject) {
35
this.classname = classname;
36
this.cullObject = cullObject;
39
public void addPrimaryKey(String name, String type) {
40
primaryKeys.put(name, type);
43
public void addPrimaryKeys(CullObject cullObj, JavaHelper jh) {
45
for(int i = 0; i < cullObj.getPrimaryKeyCount(); i++ ) {
46
CullAttr attr = cullObj.getPrimaryKeyAttr(i);
47
addPrimaryKey(attr.getName(), jh.getClassName(attr.getType()));
51
public int getPrimaryKeyCount() {
52
return primaryKeys.size();
54
public CullObject getCullObject() {
59
public void genMethods() {
61
if (cullObject.hasModifyOperation()) {
62
if(logger.isLoggable(Level.FINE)) {
63
logger.fine("generate update method for " + cullObject.getName());
67
if (cullObject.hasDeleteOperation()) {
68
if(logger.isLoggable(Level.FINE)) {
69
logger.fine("generate delete method for " + cullObject.getName());
72
genDeleteByPrimaryKeyMethod();
74
if (cullObject.hasAddOperation()) {
75
if(logger.isLoggable(Level.FINE)) {
76
logger.fine("generate add method for " + cullObject.getName());
80
if (cullObject.hasGetListOperation()) {
81
if(logger.isLoggable(Level.FINE)) {
82
logger.fine("generate get list method for " + cullObject.getName());
86
if (cullObject.hasGetOperation() ) {
88
if(cullObject.getPrimaryKeyCount() > 0) {
89
if(logger.isLoggable(Level.FINE)) {
90
logger.fine("generate get by primary key method for " + cullObject.getName());
92
genGetByPrimaryKeyMethod();
94
if(logger.isLoggable(Level.FINE)) {
95
logger.fine("generate gen get method for " + cullObject.getName());
102
protected abstract void genUpdateMethod();
103
protected abstract void genGetMethod();
104
protected abstract void genGetListMethod();
105
protected abstract void genGetByPrimaryKeyMethod();
106
protected abstract void genAddMethod();
107
protected abstract void genDeleteMethod();
108
protected abstract void genDeleteByPrimaryKeyMethod();
109
public abstract void genImport();