| 1 |
|
package org.apache.torque.engine.database.model; |
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
import java.util.ArrayList; |
| 23 |
|
import java.util.Collections; |
| 24 |
|
import java.util.Hashtable; |
| 25 |
|
import java.util.Iterator; |
| 26 |
|
import java.util.List; |
| 27 |
|
import java.util.Map; |
| 28 |
|
import org.apache.commons.collections.map.ListOrderedMap; |
| 29 |
|
import org.apache.commons.lang.StringUtils; |
| 30 |
|
|
| 31 |
|
import org.apache.commons.logging.Log; |
| 32 |
|
import org.apache.commons.logging.LogFactory; |
| 33 |
|
|
| 34 |
|
import org.apache.torque.engine.EngineException; |
| 35 |
|
|
| 36 |
|
import org.xml.sax.Attributes; |
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
@author |
| 42 |
|
@author |
| 43 |
|
@author |
| 44 |
|
@author |
| 45 |
|
@author |
| 46 |
|
@author |
| 47 |
|
@author |
| 48 |
|
@version |
| 49 |
|
|
|
|
|
| 0% |
Uncovered Elements: 421 (421) |
Complexity: 128 |
Complexity Density: 0.51 |
|
| 50 |
|
public class Table implements IDMethod { |
| 51 |
|
|
| 52 |
|
private static Log log = LogFactory.getLog(Table.class); |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
private List columnList; |
| 56 |
|
private List foreignKeys; |
| 57 |
|
private List indices; |
| 58 |
|
private List unices; |
| 59 |
|
private List idMethodParameters; |
| 60 |
|
private String name; |
| 61 |
|
private String description; |
| 62 |
|
private String javaName; |
| 63 |
|
private String idMethod; |
| 64 |
|
private String javaNamingMethod; |
| 65 |
|
private Database tableParent; |
| 66 |
|
private List referrers; |
| 67 |
|
private List foreignTableNames; |
| 68 |
|
private boolean containsForeignPK; |
| 69 |
|
private Column inheritanceColumn; |
| 70 |
|
private boolean skipSql; |
| 71 |
|
private boolean abstractValue; |
| 72 |
|
private String alias; |
| 73 |
|
private String enterface; |
| 74 |
|
private String pkg; |
| 75 |
|
private String baseClass; |
| 76 |
|
private String basePeer; |
| 77 |
|
private Hashtable columnsByName; |
| 78 |
|
private Hashtable columnsByJavaName; |
| 79 |
|
private boolean needsTransactionInPostgres; |
| 80 |
|
private boolean heavyIndexing; |
| 81 |
|
private boolean forReferenceOnly; |
| 82 |
|
private Map options; |
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 87 |
0
|
public Table() {... |
| 88 |
0
|
this(null); |
| 89 |
|
} |
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
@param |
| 95 |
|
|
| 96 |
|
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
| 97 |
0
|
public Table(String name) {... |
| 98 |
0
|
this.name = name; |
| 99 |
0
|
columnList = new ArrayList(); |
| 100 |
0
|
foreignKeys = new ArrayList(5); |
| 101 |
0
|
indices = new ArrayList(5); |
| 102 |
0
|
unices = new ArrayList(5); |
| 103 |
0
|
columnsByName = new Hashtable(); |
| 104 |
0
|
columnsByJavaName = new Hashtable(); |
| 105 |
0
|
options = Collections.synchronizedMap(new ListOrderedMap()); |
| 106 |
|
} |
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
@param |
| 112 |
|
|
| 113 |
|
@param |
| 114 |
|
|
| 115 |
|
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 3 |
Complexity Density: 0.19 |
|
| 116 |
0
|
public void loadFromXML(Attributes attrib, String defaultIdMethod) {... |
| 117 |
0
|
name = attrib.getValue("name"); |
| 118 |
0
|
javaName = attrib.getValue("javaName"); |
| 119 |
0
|
idMethod = attrib.getValue("idMethod"); |
| 120 |
|
|
| 121 |
|
|
| 122 |
|
|
| 123 |
0
|
javaNamingMethod = attrib.getValue("javaNamingMethod"); |
| 124 |
0
|
if (javaNamingMethod == null) { |
| 125 |
0
|
javaNamingMethod = getDatabase().getDefaultJavaNamingMethod(); |
| 126 |
|
} |
| 127 |
|
|
| 128 |
0
|
if ("null".equals(idMethod)) { |
| 129 |
0
|
idMethod = defaultIdMethod; |
| 130 |
|
} |
| 131 |
0
|
skipSql = "true".equals(attrib.getValue("skipSql")); |
| 132 |
|
|
| 133 |
0
|
abstractValue = "true".equals(attrib.getValue("abstract")); |
| 134 |
0
|
baseClass = attrib.getValue("baseClass"); |
| 135 |
0
|
basePeer = attrib.getValue("basePeer"); |
| 136 |
0
|
alias = attrib.getValue("alias"); |
| 137 |
0
|
heavyIndexing = "true".equals(attrib.getValue("heavyIndexing")) || (!"false".equals(attrib.getValue("heavyIndexing")) && getDatabase().isHeavyIndexing()); |
| 138 |
0
|
description = attrib.getValue("description"); |
| 139 |
0
|
enterface = attrib.getValue("interface"); |
| 140 |
|
} |
| 141 |
|
|
| 142 |
|
|
| 143 |
|
|
| 144 |
|
|
| 145 |
|
|
| 146 |
|
|
| 147 |
|
|
| 148 |
|
|
| 149 |
|
|
| 150 |
|
|
| 151 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 152 |
0
|
public void doFinalInitialization() {... |
| 153 |
|
|
| 154 |
|
|
| 155 |
0
|
if (heavyIndexing) { |
| 156 |
0
|
doHeavyIndexing(); |
| 157 |
|
} |
| 158 |
|
|
| 159 |
|
|
| 160 |
|
|
| 161 |
0
|
doNaming(); |
| 162 |
|
} |
| 163 |
|
|
| 164 |
|
|
| 165 |
|
|
| 166 |
|
|
| 167 |
|
|
| 168 |
|
|
| 169 |
|
|
| 170 |
|
|
| 171 |
|
|
| 172 |
|
|
| 173 |
|
|
| 174 |
|
|
| 175 |
|
|
| 176 |
|
|
| 177 |
|
|
| 178 |
|
|
| 179 |
|
|
| 180 |
|
|
| 181 |
|
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 182 |
0
|
private void doHeavyIndexing() {... |
| 183 |
0
|
if (log.isDebugEnabled()) { |
| 184 |
0
|
log.debug("doHeavyIndex() called on table " + name); |
| 185 |
|
} |
| 186 |
|
|
| 187 |
0
|
List pk = getPrimaryKey(); |
| 188 |
0
|
int size = pk.size(); |
| 189 |
|
|
| 190 |
0
|
try { |
| 191 |
|
|
| 192 |
|
|
| 193 |
|
|
| 194 |
0
|
for (int i = 1; i < size; i++) { |
| 195 |
0
|
addIndex(new Index(this, pk.subList(i, size))); |
| 196 |
|
} |
| 197 |
|
} catch (EngineException e) { |
| 198 |
0
|
log.error(e, e); |
| 199 |
|
} |
| 200 |
|
} |
| 201 |
|
|
| 202 |
|
|
| 203 |
|
|
| 204 |
|
|
|
|
|
| 0% |
Uncovered Elements: 35 (35) |
Complexity: 8 |
Complexity Density: 0.35 |
|
| 205 |
0
|
private void doNaming() {... |
| 206 |
0
|
int i; |
| 207 |
0
|
int size; |
| 208 |
0
|
String name; |
| 209 |
|
|
| 210 |
|
|
| 211 |
0
|
try { |
| 212 |
0
|
for (i = 0, size = foreignKeys.size(); i < size; i++) { |
| 213 |
0
|
ForeignKey fk = (ForeignKey) foreignKeys.get(i); |
| 214 |
0
|
name = fk.getName(); |
| 215 |
0
|
if (StringUtils.isEmpty(name)) { |
| 216 |
0
|
name = acquireConstraintName("FK", i + 1); |
| 217 |
0
|
fk.setName(name); |
| 218 |
|
} |
| 219 |
|
} |
| 220 |
|
|
| 221 |
0
|
for (i = 0, size = indices.size(); i < size; i++) { |
| 222 |
0
|
Index index = (Index) indices.get(i); |
| 223 |
0
|
name = index.getName(); |
| 224 |
0
|
if (StringUtils.isEmpty(name)) { |
| 225 |
0
|
name = acquireConstraintName("I", i + 1); |
| 226 |
0
|
index.setName(name); |
| 227 |
|
} |
| 228 |
|
} |
| 229 |
|
|
| 230 |
0
|
for (i = 0, size = unices.size(); i < size; i++) { |
| 231 |
0
|
Unique unique = (Unique) unices.get(i); |
| 232 |
0
|
name = unique.getName(); |
| 233 |
0
|
if (StringUtils.isEmpty(name)) { |
| 234 |
0
|
name = acquireConstraintName("U", i + 1); |
| 235 |
0
|
unique.setName(name); |
| 236 |
|
} |
| 237 |
|
} |
| 238 |
|
} catch (EngineException nameAlreadyInUse) { |
| 239 |
0
|
log.error(nameAlreadyInUse, nameAlreadyInUse); |
| 240 |
|
} |
| 241 |
|
} |
| 242 |
|
|
| 243 |
|
|
| 244 |
|
|
| 245 |
|
|
| 246 |
|
@param |
| 247 |
|
|
| 248 |
|
@param |
| 249 |
|
|
| 250 |
|
@return |
| 251 |
|
@throws |
| 252 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
| 253 |
0
|
private final String acquireConstraintName(String nameType, int nbr) throws EngineException {... |
| 254 |
0
|
List inputs = new ArrayList(4); |
| 255 |
0
|
inputs.add(getDatabase()); |
| 256 |
0
|
inputs.add(getName()); |
| 257 |
0
|
inputs.add(nameType); |
| 258 |
0
|
inputs.add(new Integer(nbr)); |
| 259 |
0
|
return NameFactory.generateName(NameFactory.CONSTRAINT_GENERATOR, inputs); |
| 260 |
|
} |
| 261 |
|
|
| 262 |
|
|
| 263 |
|
|
| 264 |
|
|
| 265 |
|
@return |
| 266 |
|
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 4 |
Complexity Density: 0.8 |
|
| 267 |
0
|
public String getBaseClass() {... |
| 268 |
0
|
if (isAlias() && baseClass == null) { |
| 269 |
0
|
return alias; |
| 270 |
0
|
} else if (baseClass == null) { |
| 271 |
0
|
return getDatabase().getBaseClass(); |
| 272 |
|
} else { |
| 273 |
0
|
return baseClass; |
| 274 |
|
} |
| 275 |
|
} |
| 276 |
|
|
| 277 |
|
|
| 278 |
|
|
| 279 |
|
|
| 280 |
|
@param |
| 281 |
|
|
| 282 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 283 |
0
|
public void setBaseClass(String v) {... |
| 284 |
0
|
this.baseClass = v; |
| 285 |
|
} |
| 286 |
|
|
| 287 |
|
|
| 288 |
|
|
| 289 |
|
|
| 290 |
|
@return |
| 291 |
|
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 4 |
Complexity Density: 0.8 |
|
| 292 |
0
|
public String getBasePeer() {... |
| 293 |
0
|
if (isAlias() && basePeer == null) { |
| 294 |
0
|
return alias + "Peer"; |
| 295 |
0
|
} else if (basePeer == null) { |
| 296 |
0
|
return getDatabase().getBasePeer(); |
| 297 |
|
} else { |
| 298 |
0
|
return basePeer; |
| 299 |
|
} |
| 300 |
|
} |
| 301 |
|
|
| 302 |
|
|
| 303 |
|
|
| 304 |
|
|
| 305 |
|
@param |
| 306 |
|
|
| 307 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 308 |
0
|
public void setBasePeer(String v) {... |
| 309 |
0
|
this.basePeer = v; |
| 310 |
|
} |
| 311 |
|
|
| 312 |
|
|
| 313 |
|
|
| 314 |
|
|
| 315 |
|
@param |
| 316 |
|
|
| 317 |
|
@return |
| 318 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
| 319 |
0
|
public Column addColumn(Attributes attrib) {... |
| 320 |
0
|
Column col = new Column(); |
| 321 |
0
|
col.setTable(this); |
| 322 |
0
|
col.setCorrectGetters(false); |
| 323 |
0
|
col.loadFromXML(attrib); |
| 324 |
0
|
addColumn(col); |
| 325 |
0
|
return col; |
| 326 |
|
} |
| 327 |
|
|
| 328 |
|
|
| 329 |
|
|
| 330 |
|
|
| 331 |
|
@param |
| 332 |
|
|
| 333 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
| 334 |
0
|
public void addColumn(Column col) {... |
| 335 |
0
|
col.setTable(this); |
| 336 |
0
|
if (col.isInheritance()) { |
| 337 |
0
|
inheritanceColumn = col; |
| 338 |
|
} |
| 339 |
0
|
columnList.add(col); |
| 340 |
0
|
columnsByName.put(col.getName(), col); |
| 341 |
0
|
columnsByJavaName.put(col.getJavaName(), col); |
| 342 |
0
|
col.setPosition(columnList.size()); |
| 343 |
0
|
needsTransactionInPostgres |= col.requiresTransactionInPostgres(); |
| 344 |
|
} |
| 345 |
|
|
| 346 |
|
|
| 347 |
|
|
| 348 |
|
|
| 349 |
|
@param |
| 350 |
|
|
| 351 |
|
@return |
| 352 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 353 |
0
|
public ForeignKey addForeignKey(Attributes attrib) {... |
| 354 |
0
|
ForeignKey fk = new ForeignKey(); |
| 355 |
0
|
fk.loadFromXML(attrib); |
| 356 |
0
|
addForeignKey(fk); |
| 357 |
0
|
return fk; |
| 358 |
|
} |
| 359 |
|
|
| 360 |
|
|
| 361 |
|
|
| 362 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 363 |
0
|
public Column getChildrenColumn() {... |
| 364 |
0
|
return inheritanceColumn; |
| 365 |
|
} |
| 366 |
|
|
| 367 |
|
|
| 368 |
|
|
| 369 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
| 370 |
0
|
public List getChildrenNames() {... |
| 371 |
0
|
if (inheritanceColumn == null || !inheritanceColumn.isEnumeratedClasses()) { |
| 372 |
0
|
return null; |
| 373 |
|
} |
| 374 |
0
|
List children = inheritanceColumn.getChildren(); |
| 375 |
0
|
List names = new ArrayList(children.size()); |
| 376 |
0
|
for (int i = 0; i < children.size(); i++) { |
| 377 |
0
|
names.add(((Inheritance) children.get(i)).getClassName()); |
| 378 |
|
} |
| 379 |
0
|
return names; |
| 380 |
|
} |
| 381 |
|
|
| 382 |
|
|
| 383 |
|
|
| 384 |
|
|
| 385 |
|
@param |
| 386 |
|
|
| 387 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 388 |
0
|
public void addReferrer(ForeignKey fk) {... |
| 389 |
0
|
if (referrers == null) { |
| 390 |
0
|
referrers = new ArrayList(5); |
| 391 |
|
} |
| 392 |
0
|
referrers.add(fk); |
| 393 |
|
} |
| 394 |
|
|
| 395 |
|
|
| 396 |
|
|
| 397 |
|
|
| 398 |
|
@return |
| 399 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 400 |
0
|
public List getReferrers() {... |
| 401 |
0
|
return referrers; |
| 402 |
|
} |
| 403 |
|
|
| 404 |
|
|
| 405 |
|
|
| 406 |
|
|
| 407 |
|
@param |
| 408 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 409 |
0
|
public void setContainsForeignPK(boolean b) {... |
| 410 |
0
|
containsForeignPK = b; |
| 411 |
|
} |
| 412 |
|
|
| 413 |
|
|
| 414 |
|
|
| 415 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 416 |
0
|
public boolean getContainsForeignPK() {... |
| 417 |
0
|
return containsForeignPK; |
| 418 |
|
} |
| 419 |
|
|
| 420 |
|
|
| 421 |
|
|
| 422 |
|
|
| 423 |
|
@return |
| 424 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 425 |
0
|
public List getForeignTableNames() {... |
| 426 |
0
|
if (foreignTableNames == null) { |
| 427 |
0
|
foreignTableNames = new ArrayList(1); |
| 428 |
|
} |
| 429 |
0
|
return foreignTableNames; |
| 430 |
|
} |
| 431 |
|
|
| 432 |
|
|
| 433 |
|
|
| 434 |
|
|
| 435 |
|
@param |
| 436 |
|
|
| 437 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 438 |
0
|
public void addForeignKey(ForeignKey fk) {... |
| 439 |
0
|
fk.setTable(this); |
| 440 |
0
|
foreignKeys.add(fk); |
| 441 |
|
|
| 442 |
0
|
if (foreignTableNames == null) { |
| 443 |
0
|
foreignTableNames = new ArrayList(5); |
| 444 |
|
} |
| 445 |
0
|
if (!foreignTableNames.contains(fk.getForeignTableName())) { |
| 446 |
0
|
foreignTableNames.add(fk.getForeignTableName()); |
| 447 |
|
} |
| 448 |
|
} |
| 449 |
|
|
| 450 |
|
|
| 451 |
|
|
| 452 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 453 |
0
|
public boolean requiresTransactionInPostgres() {... |
| 454 |
0
|
return needsTransactionInPostgres; |
| 455 |
|
} |
| 456 |
|
|
| 457 |
|
|
| 458 |
|
|
| 459 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 460 |
0
|
public IdMethodParameter addIdMethodParameter(Attributes attrib) {... |
| 461 |
0
|
IdMethodParameter imp = new IdMethodParameter(); |
| 462 |
0
|
imp.loadFromXML(attrib); |
| 463 |
0
|
addIdMethodParameter(imp); |
| 464 |
0
|
return imp; |
| 465 |
|
} |
| 466 |
|
|
| 467 |
|
|
| 468 |
|
|
| 469 |
|
|
| 470 |
|
|
| 471 |
|
@param |
| 472 |
|
|
| 473 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 474 |
0
|
public void addIdMethodParameter(IdMethodParameter imp) {... |
| 475 |
0
|
imp.setTable(this); |
| 476 |
0
|
if (idMethodParameters == null) { |
| 477 |
0
|
idMethodParameters = new ArrayList(2); |
| 478 |
|
} |
| 479 |
0
|
idMethodParameters.add(imp); |
| 480 |
|
} |
| 481 |
|
|
| 482 |
|
|
| 483 |
|
|
| 484 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 485 |
0
|
public void addIndex(Index index) {... |
| 486 |
0
|
index.setTable(this); |
| 487 |
0
|
indices.add(index); |
| 488 |
|
} |
| 489 |
|
|
| 490 |
|
|
| 491 |
|
|
| 492 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 493 |
0
|
public Index addIndex(Attributes attrib) {... |
| 494 |
0
|
Index index = new Index(); |
| 495 |
0
|
index.loadFromXML(attrib); |
| 496 |
0
|
addIndex(index); |
| 497 |
0
|
return index; |
| 498 |
|
} |
| 499 |
|
|
| 500 |
|
|
| 501 |
|
|
| 502 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 503 |
0
|
public void addUnique(Unique unique) {... |
| 504 |
0
|
unique.setTable(this); |
| 505 |
0
|
unices.add(unique); |
| 506 |
|
} |
| 507 |
|
|
| 508 |
|
|
| 509 |
|
|
| 510 |
|
|
| 511 |
|
@param |
| 512 |
|
|
| 513 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 514 |
0
|
public Unique addUnique(Attributes attrib) {... |
| 515 |
0
|
Unique unique = new Unique(); |
| 516 |
0
|
unique.loadFromXML(attrib); |
| 517 |
0
|
addUnique(unique); |
| 518 |
0
|
return unique; |
| 519 |
|
} |
| 520 |
|
|
| 521 |
|
|
| 522 |
|
|
| 523 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 524 |
0
|
public String getName() {... |
| 525 |
0
|
return name; |
| 526 |
|
} |
| 527 |
|
|
| 528 |
|
|
| 529 |
|
|
| 530 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 531 |
0
|
public void setName(String newName) {... |
| 532 |
0
|
name = newName; |
| 533 |
|
} |
| 534 |
|
|
| 535 |
|
|
| 536 |
|
|
| 537 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 538 |
0
|
public String getDescription() {... |
| 539 |
0
|
return description; |
| 540 |
|
} |
| 541 |
|
|
| 542 |
|
|
| 543 |
|
|
| 544 |
|
|
| 545 |
|
@param |
| 546 |
|
|
| 547 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 548 |
0
|
public void setDescription(String newDescription) {... |
| 549 |
0
|
description = newDescription; |
| 550 |
|
} |
| 551 |
|
|
| 552 |
|
|
| 553 |
|
|
| 554 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
| 555 |
0
|
public String getJavaName() {... |
| 556 |
0
|
if (javaName == null) { |
| 557 |
0
|
List inputs = new ArrayList(2); |
| 558 |
0
|
inputs.add(name); |
| 559 |
0
|
inputs.add(javaNamingMethod); |
| 560 |
0
|
try { |
| 561 |
0
|
javaName = NameFactory.generateName(NameFactory.JAVA_GENERATOR, inputs); |
| 562 |
|
} catch (EngineException e) { |
| 563 |
0
|
log.error(e, e); |
| 564 |
|
} |
| 565 |
|
} |
| 566 |
0
|
return javaName; |
| 567 |
|
} |
| 568 |
|
|
| 569 |
|
|
| 570 |
|
|
| 571 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 572 |
0
|
public void setJavaName(String javaName) {... |
| 573 |
0
|
this.javaName = javaName; |
| 574 |
|
} |
| 575 |
|
|
| 576 |
|
|
| 577 |
|
|
| 578 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 579 |
0
|
public String getIdMethod() {... |
| 580 |
0
|
if (idMethod == null) { |
| 581 |
0
|
return IDMethod.NO_ID_METHOD; |
| 582 |
|
} else { |
| 583 |
0
|
return idMethod; |
| 584 |
|
} |
| 585 |
|
} |
| 586 |
|
|
| 587 |
|
|
| 588 |
|
|
| 589 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 590 |
0
|
public void setIdMethod(String idMethod) {... |
| 591 |
0
|
this.idMethod = idMethod; |
| 592 |
|
} |
| 593 |
|
|
| 594 |
|
|
| 595 |
|
|
| 596 |
|
|
| 597 |
|
@return |
| 598 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 599 |
0
|
public boolean isSkipSql() {... |
| 600 |
0
|
return (skipSql || isAlias() || isForReferenceOnly()); |
| 601 |
|
} |
| 602 |
|
|
| 603 |
|
|
| 604 |
|
|
| 605 |
|
|
| 606 |
|
@param |
| 607 |
|
|
| 608 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 609 |
0
|
public void setSkipSql(boolean v) {... |
| 610 |
0
|
this.skipSql = v; |
| 611 |
|
} |
| 612 |
|
|
| 613 |
|
|
| 614 |
|
|
| 615 |
|
|
| 616 |
|
@return |
| 617 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 618 |
0
|
public String getAlias() {... |
| 619 |
0
|
return alias; |
| 620 |
|
} |
| 621 |
|
|
| 622 |
|
|
| 623 |
|
|
| 624 |
|
|
| 625 |
|
@return |
| 626 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 627 |
0
|
public boolean isAlias() {... |
| 628 |
0
|
return (alias != null); |
| 629 |
|
} |
| 630 |
|
|
| 631 |
|
|
| 632 |
|
|
| 633 |
|
|
| 634 |
|
@param |
| 635 |
|
|
| 636 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 637 |
0
|
public void setAlias(String v) {... |
| 638 |
0
|
this.alias = v; |
| 639 |
|
} |
| 640 |
|
|
| 641 |
|
|
| 642 |
|
|
| 643 |
|
|
| 644 |
|
@return |
| 645 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 646 |
0
|
public String getInterface() {... |
| 647 |
0
|
return enterface; |
| 648 |
|
} |
| 649 |
|
|
| 650 |
|
|
| 651 |
|
|
| 652 |
|
|
| 653 |
|
@param |
| 654 |
|
|
| 655 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 656 |
0
|
public void setInterface(String v) {... |
| 657 |
0
|
this.enterface = v; |
| 658 |
|
} |
| 659 |
|
|
| 660 |
|
|
| 661 |
|
|
| 662 |
|
|
| 663 |
|
|
| 664 |
|
|
| 665 |
|
@return |
| 666 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 667 |
0
|
public boolean isAbstract() {... |
| 668 |
0
|
return abstractValue; |
| 669 |
|
} |
| 670 |
|
|
| 671 |
|
|
| 672 |
|
|
| 673 |
|
|
| 674 |
|
|
| 675 |
|
|
| 676 |
|
@param |
| 677 |
|
|
| 678 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 679 |
0
|
public void setAbstract(boolean v) {... |
| 680 |
0
|
this.abstractValue = v; |
| 681 |
|
} |
| 682 |
|
|
| 683 |
|
|
| 684 |
|
|
| 685 |
|
|
| 686 |
|
@return |
| 687 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 688 |
0
|
public String getPackage() {... |
| 689 |
0
|
if (pkg != null) { |
| 690 |
0
|
return pkg; |
| 691 |
|
} else { |
| 692 |
0
|
return this.getDatabase().getPackage(); |
| 693 |
|
} |
| 694 |
|
} |
| 695 |
|
|
| 696 |
|
|
| 697 |
|
|
| 698 |
|
|
| 699 |
|
@param |
| 700 |
|
|
| 701 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 702 |
0
|
public void setPackage(String v) {... |
| 703 |
0
|
this.pkg = v; |
| 704 |
|
} |
| 705 |
|
|
| 706 |
|
|
| 707 |
|
|
| 708 |
|
|
| 709 |
|
@return |
| 710 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 711 |
0
|
public List getColumns() {... |
| 712 |
0
|
return columnList; |
| 713 |
|
} |
| 714 |
|
|
| 715 |
|
|
| 716 |
|
|
| 717 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 718 |
0
|
public int getNumColumns() {... |
| 719 |
0
|
return columnList.size(); |
| 720 |
|
} |
| 721 |
|
|
| 722 |
|
|
| 723 |
|
|
| 724 |
|
|
| 725 |
|
@return |
| 726 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 727 |
0
|
public List getForeignKeys() {... |
| 728 |
0
|
return foreignKeys; |
| 729 |
|
} |
| 730 |
|
|
| 731 |
|
|
| 732 |
|
|
| 733 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 734 |
0
|
public List getIdMethodParameters() {... |
| 735 |
0
|
return idMethodParameters; |
| 736 |
|
} |
| 737 |
|
|
| 738 |
|
|
| 739 |
|
|
| 740 |
|
|
| 741 |
|
@return |
| 742 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 743 |
0
|
public String getSequenceName() {... |
| 744 |
0
|
String result = null; |
| 745 |
0
|
if (getIdMethod().equals(NATIVE)) { |
| 746 |
0
|
List idMethodParams = getIdMethodParameters(); |
| 747 |
0
|
if (idMethodParams == null) { |
| 748 |
0
|
result = getName() + "_SEQ"; |
| 749 |
|
} else { |
| 750 |
0
|
result = ((IdMethodParameter) idMethodParams.get(0)).getValue(); |
| 751 |
|
} |
| 752 |
|
} |
| 753 |
0
|
return result; |
| 754 |
|
} |
| 755 |
|
|
| 756 |
|
|
| 757 |
|
|
| 758 |
|
|
| 759 |
|
@return |
| 760 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 761 |
0
|
public List getIndices() {... |
| 762 |
0
|
return indices; |
| 763 |
|
} |
| 764 |
|
|
| 765 |
|
|
| 766 |
|
|
| 767 |
|
|
| 768 |
|
@return |
| 769 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 770 |
0
|
public List getUnices() {... |
| 771 |
0
|
return unices; |
| 772 |
|
} |
| 773 |
|
|
| 774 |
|
|
| 775 |
|
|
| 776 |
|
|
| 777 |
|
@param |
| 778 |
|
|
| 779 |
|
@return |
| 780 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 781 |
0
|
public Column getColumn(String name) {... |
| 782 |
0
|
return (Column) columnsByName.get(name); |
| 783 |
|
} |
| 784 |
|
|
| 785 |
|
|
| 786 |
|
|
| 787 |
|
|
| 788 |
|
@param |
| 789 |
|
|
| 790 |
|
@return |
| 791 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 792 |
0
|
public Column getColumnByJavaName(String javaName) {... |
| 793 |
0
|
return (Column) columnsByJavaName.get(javaName); |
| 794 |
|
} |
| 795 |
|
|
| 796 |
|
|
| 797 |
|
|
| 798 |
|
|
| 799 |
|
|
| 800 |
|
@param |
| 801 |
|
|
| 802 |
|
@return |
| 803 |
|
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
| 804 |
0
|
public ForeignKey getForeignKey(String col) {... |
| 805 |
0
|
ForeignKey firstFK = null; |
| 806 |
0
|
for (Iterator iter = foreignKeys.iterator(); iter.hasNext();) { |
| 807 |
0
|
ForeignKey key = (ForeignKey) iter.next(); |
| 808 |
0
|
if (key.getLocalColumns().contains(col)) { |
| 809 |
0
|
if (firstFK == null) { |
| 810 |
0
|
firstFK = key; |
| 811 |
|
} else { |
| 812 |
|
|
| 813 |
|
|
| 814 |
|
|
| 815 |
|
|
| 816 |
|
} |
| 817 |
|
} |
| 818 |
|
} |
| 819 |
0
|
return firstFK; |
| 820 |
|
} |
| 821 |
|
|
| 822 |
|
|
| 823 |
|
|
| 824 |
|
|
| 825 |
|
@param |
| 826 |
|
|
| 827 |
|
@return |
| 828 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 829 |
0
|
public boolean containsColumn(Column col) {... |
| 830 |
0
|
return columnList.contains(col); |
| 831 |
|
} |
| 832 |
|
|
| 833 |
|
|
| 834 |
|
|
| 835 |
|
|
| 836 |
|
@param |
| 837 |
|
|
| 838 |
|
@return |
| 839 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 840 |
0
|
public boolean containsColumn(String name) {... |
| 841 |
0
|
return (getColumn(name) != null); |
| 842 |
|
} |
| 843 |
|
|
| 844 |
|
|
| 845 |
|
|
| 846 |
|
|
| 847 |
|
@param |
| 848 |
|
|
| 849 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 850 |
0
|
public void setDatabase(Database parent) {... |
| 851 |
0
|
tableParent = parent; |
| 852 |
|
} |
| 853 |
|
|
| 854 |
|
|
| 855 |
|
|
| 856 |
|
|
| 857 |
|
@return |
| 858 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 859 |
0
|
public Database getDatabase() {... |
| 860 |
0
|
return tableParent; |
| 861 |
|
} |
| 862 |
|
|
| 863 |
|
|
| 864 |
|
|
| 865 |
|
|
| 866 |
|
@return |
| 867 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 868 |
0
|
public boolean isForReferenceOnly() {... |
| 869 |
0
|
return forReferenceOnly; |
| 870 |
|
} |
| 871 |
|
|
| 872 |
|
|
| 873 |
|
|
| 874 |
|
|
| 875 |
|
@param |
| 876 |
|
|
| 877 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 878 |
0
|
public void setForReferenceOnly(boolean v) {... |
| 879 |
0
|
this.forReferenceOnly = v; |
| 880 |
|
} |
| 881 |
|
|
| 882 |
|
|
| 883 |
|
|
| 884 |
|
|
| 885 |
|
@return |
| 886 |
|
|
|
|
|
| 0% |
Uncovered Elements: 51 (51) |
Complexity: 13 |
Complexity Density: 0.48 |
|
| 887 |
0
|
public String toString() {... |
| 888 |
0
|
StringBuffer result = new StringBuffer(); |
| 889 |
|
|
| 890 |
0
|
result.append("<table name=\"").append(name).append('\"'); |
| 891 |
|
|
| 892 |
0
|
if (javaName != null) { |
| 893 |
0
|
result.append(" javaName=\"").append(javaName).append('\"'); |
| 894 |
|
} |
| 895 |
|
|
| 896 |
0
|
if (idMethod != null) { |
| 897 |
0
|
result.append(" idMethod=\"").append(idMethod).append('\"'); |
| 898 |
|
} |
| 899 |
|
|
| 900 |
0
|
if (skipSql) { |
| 901 |
0
|
result.append(" skipSql=\"").append(new Boolean(skipSql)).append('\"'); |
| 902 |
|
} |
| 903 |
|
|
| 904 |
0
|
if (abstractValue) { |
| 905 |
0
|
result.append(" abstract=\"").append(new Boolean(abstractValue)).append('\"'); |
| 906 |
|
} |
| 907 |
|
|
| 908 |
0
|
if (baseClass != null) { |
| 909 |
0
|
result.append(" baseClass=\"").append(baseClass).append('\"'); |
| 910 |
|
} |
| 911 |
|
|
| 912 |
0
|
if (basePeer != null) { |
| 913 |
0
|
result.append(" basePeer=\"").append(basePeer).append('\"'); |
| 914 |
|
} |
| 915 |
|
|
| 916 |
0
|
result.append(">\n"); |
| 917 |
|
|
| 918 |
0
|
if (columnList != null) { |
| 919 |
0
|
for (Iterator iter = columnList.iterator(); iter.hasNext();) { |
| 920 |
0
|
result.append(iter.next()); |
| 921 |
|
} |
| 922 |
|
} |
| 923 |
|
|
| 924 |
0
|
if (foreignKeys != null) { |
| 925 |
0
|
for (Iterator iter = foreignKeys.iterator(); iter.hasNext();) { |
| 926 |
0
|
result.append(iter.next()); |
| 927 |
|
} |
| 928 |
|
} |
| 929 |
|
|
| 930 |
0
|
if (idMethodParameters != null) { |
| 931 |
0
|
Iterator iter = idMethodParameters.iterator(); |
| 932 |
0
|
while (iter.hasNext()) { |
| 933 |
0
|
result.append(iter.next()); |
| 934 |
|
} |
| 935 |
|
} |
| 936 |
|
|
| 937 |
0
|
result.append("</table>\n"); |
| 938 |
|
|
| 939 |
0
|
return result.toString(); |
| 940 |
|
} |
| 941 |
|
|
| 942 |
|
|
| 943 |
|
|
| 944 |
|
|
| 945 |
|
@return |
| 946 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 947 |
0
|
public List getPrimaryKey() {... |
| 948 |
0
|
List pk = new ArrayList(columnList.size()); |
| 949 |
|
|
| 950 |
0
|
Iterator iter = columnList.iterator(); |
| 951 |
0
|
while (iter.hasNext()) { |
| 952 |
0
|
Column col = (Column) iter.next(); |
| 953 |
0
|
if (col.isPrimaryKey()) { |
| 954 |
0
|
pk.add(col); |
| 955 |
|
} |
| 956 |
|
} |
| 957 |
0
|
return pk; |
| 958 |
|
} |
| 959 |
|
|
| 960 |
|
|
| 961 |
|
|
| 962 |
|
|
| 963 |
|
@return |
| 964 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 965 |
0
|
public boolean hasPrimaryKey() {... |
| 966 |
0
|
return (getPrimaryKey().size() > 0); |
| 967 |
|
} |
| 968 |
|
|
| 969 |
|
|
| 970 |
|
|
| 971 |
|
|
| 972 |
|
@return |
| 973 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 974 |
0
|
public String printPrimaryKey() {... |
| 975 |
0
|
return printList(columnList); |
| 976 |
|
} |
| 977 |
|
|
| 978 |
|
|
| 979 |
|
|
| 980 |
|
|
| 981 |
|
@param |
| 982 |
|
|
| 983 |
|
@return |
| 984 |
|
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
| 985 |
0
|
private String printList(List list) {... |
| 986 |
0
|
StringBuffer result = new StringBuffer(); |
| 987 |
0
|
boolean comma = false; |
| 988 |
0
|
for (Iterator iter = list.iterator(); iter.hasNext();) { |
| 989 |
0
|
Column col = (Column) iter.next(); |
| 990 |
0
|
if (col.isPrimaryKey()) { |
| 991 |
0
|
if (comma) { |
| 992 |
0
|
result.append(','); |
| 993 |
|
} else { |
| 994 |
0
|
comma = true; |
| 995 |
|
} |
| 996 |
0
|
result.append(col.getName()); |
| 997 |
|
} |
| 998 |
|
} |
| 999 |
0
|
return result.toString(); |
| 1000 |
|
} |
| 1001 |
|
|
| 1002 |
|
|
| 1003 |
|
|
| 1004 |
|
|
| 1005 |
|
@param |
| 1006 |
|
|
| 1007 |
|
@since |
| 1008 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 1009 |
0
|
public void setCorrectGetters(Boolean value) {... |
| 1010 |
0
|
boolean correctGetters = value != null && value.booleanValue(); |
| 1011 |
0
|
for (Iterator it = columnList.iterator(); it.hasNext();) { |
| 1012 |
0
|
Column col = (Column) it.next(); |
| 1013 |
0
|
col.setCorrectGetters(correctGetters); |
| 1014 |
|
} |
| 1015 |
|
} |
| 1016 |
|
|
| 1017 |
|
|
| 1018 |
|
|
| 1019 |
|
|
| 1020 |
|
@param |
| 1021 |
|
|
| 1022 |
|
@param |
| 1023 |
|
|
| 1024 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1025 |
0
|
public void addOption(String key, String value) {... |
| 1026 |
0
|
options.put(key, value); |
| 1027 |
|
} |
| 1028 |
|
|
| 1029 |
|
|
| 1030 |
|
|
| 1031 |
|
|
| 1032 |
|
@param |
| 1033 |
|
|
| 1034 |
|
@return |
| 1035 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1036 |
0
|
public String getOption(String key) {... |
| 1037 |
0
|
return (String) options.get(key); |
| 1038 |
|
} |
| 1039 |
|
|
| 1040 |
|
|
| 1041 |
|
|
| 1042 |
|
|
| 1043 |
|
|
| 1044 |
|
|
| 1045 |
|
|
| 1046 |
|
|
| 1047 |
|
@return |
| 1048 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1049 |
0
|
public Map getOptions() {... |
| 1050 |
0
|
return options; |
| 1051 |
|
} |
| 1052 |
|
} |