1 19 24 25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule; 26 27 import java.util.List ; 28 import java.util.ResourceBundle ; 29 30 import org.netbeans.modules.j2ee.sun.dd.api.ejb.QueryMethod; 31 import org.netbeans.modules.j2ee.sun.dd.api.common.MethodParams; 32 import org.netbeans.modules.j2ee.sun.share.configbean.ConfigQuery; 33 import org.netbeans.modules.j2ee.sun.share.configbean.CmpEntityEjb; 34 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.MethodTableModel; 35 import org.netbeans.modules.j2ee.sun.share.configbean.StorageBeanFactory; 36 37 38 42 public class PrefetchDisabledModel extends MethodTableModel { 43 44 static final ResourceBundle bundle = 45 ResourceBundle.getBundle( 46 "org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule.Bundle"); 48 private CmpEntityEjb cmpEntityEjb; 49 50 private static final String [] columnNames = { 51 bundle.getString("LBL_Method"), bundle.getString("LBL_Disable"), }; 54 55 56 57 public PrefetchDisabledModel(CmpEntityEjb cmpEntityEjb, List methodList, 58 List prefetchedMethodList) { 59 super(methodList, prefetchedMethodList); 60 this.cmpEntityEjb = cmpEntityEjb; 61 } 62 63 64 public void setData(CmpEntityEjb cmpEntityEjb, List methodList, 65 List prefetchedMethodList){ 66 this.cmpEntityEjb = cmpEntityEjb; 67 setData(methodList, prefetchedMethodList); 68 } 69 70 71 public PrefetchDisabledModel() { 72 } 73 74 75 protected String [] getColumnNames(){ 76 return columnNames; 77 } 78 79 80 protected Class getColumnType(int column){ 81 return Object .class; 82 } 83 84 85 protected Object getValueAt(int column, Object object, int row){ 86 if(column == 0){ 87 ConfigQuery.MethodData method = (ConfigQuery.MethodData) object; 88 return method.getOperationName( ); 89 } else { 90 assert(false); 92 return null; 93 } 94 } 95 96 97 protected Object getDDValueAt(int column, Object ddObject){ 98 QueryMethod queryMethod = (QueryMethod) ddObject; 99 switch(column){ 100 default: { 101 assert(false); 103 return null; 104 } 105 } 106 } 107 108 109 protected void setDDValueAt(int column, Object ddObject, Object value){ 110 QueryMethod queryMethod = (QueryMethod) ddObject; 111 switch(column){ 112 default: { 113 assert(false); 115 } 116 } 117 } 118 119 120 protected Object getDDMethod(Object object){ 122 StorageBeanFactory storageFactory = cmpEntityEjb.getConfig().getStorageFactory(); 123 124 ConfigQuery.MethodData method = (ConfigQuery.MethodData) object; 125 QueryMethod queryMethod = storageFactory.createQueryMethod(); 126 127 queryMethod.setMethodName(method.getOperationName()); 128 List params = method.getParameters(); 129 MethodParams methodParams = queryMethod.newMethodParams(); 130 for(int i=0; i<params.size(); i++){ 131 methodParams.addMethodParam((String )params.get(i)); 132 } 133 queryMethod.setMethodParams(methodParams); 134 135 return queryMethod; 137 } 138 139 140 protected void addDDMethod(Object ddObject){ 141 QueryMethod ddMethod = (QueryMethod)ddObject; 142 cmpEntityEjb.addQueryMethod(ddMethod); 144 } 145 146 147 protected void removeDDMethod(Object ddObject){ 148 QueryMethod ddMethod = (QueryMethod)ddObject; 149 cmpEntityEjb.removeQueryMethod(ddMethod); 150 } 151 152 153 protected boolean areEqual(Object ddObject, Object object){ 156 QueryMethod ddMethod = (QueryMethod)ddObject; 157 ConfigQuery.MethodData method = (ConfigQuery.MethodData) object; 158 boolean returnValue = false; 159 160 161 String ddMethodName = ddMethod.getMethodName(); 162 String methodName = method.getOperationName(); 163 if(ddMethodName.equals(methodName)){ 164 MethodParams methodParams = ddMethod.getMethodParams(); 166 List params = method.getParameters(); 167 168 String ddParam; 169 String param; 170 for(int i=0; i<params.size(); i++){ 171 param = (String )params.get(i); 172 ddParam = methodParams.getMethodParam(i); 173 if(!param.equals(ddParam)){ 174 return false; 175 } 176 } 177 return true; 178 } else { 179 return false; 180 } 181 } 182 183 184 private void printMethod(QueryMethod queryMethod){ 185 System.out.println("PrefetchDisabledModel queryMethod:" + queryMethod); System.out.println("PrefetchDisabledModel queryMethod:" + queryMethod.toString()); System.out.println("PrefetchDisabledModel name :" + queryMethod.getMethodName() ); System.out.println("PrefetchDisabledModel params :" + queryMethod.getMethodParams() ); } 190 } 191 | Popular Tags |