Revision 915 org.gvsig.oracle/trunk/org.gvsig.oracle/org.gvsig.oracle.provider/src/main/java/org/gvsig/oracle/dal/OracleSQLBuilder.java

View differences:

OracleSQLBuilder.java
148 148
        STMT_GRANT_privileges_ON_table_TO_role = "GRANT {0} ON {1} TO {2}";
149 149

  
150 150
    }
151

  
151
    
152
    public OracleHelper getHelper() {
153
        return (OracleHelper) super.getHelper();
154
    }
155
    
152 156
    @Override
153 157
    public Formatter formatter() {
154 158
        if (this.formatter == null) {
......
234 238
            StringBuilder builder = new StringBuilder();
235 239

  
236 240
            builder.append("CREATE TABLE ");
237
            builder.append(getFullTableName(this.table()));
241
            builder.append(this.table().toString());
238 242
            builder.append(" (");
239 243
            boolean first = true;
240 244

  
......
332 336

  
333 337
            if (pks.size() > 0) {
334 338
                builder = new StringBuilder("ALTER TABLE ");
335
                builder.append(getFullTableName(this.table()));
339
                builder.append(this.table().toString());
336 340
                builder.append(" ADD PRIMARY KEY (");
337 341
                for (int i = 0; i < pks.size(); i++) {
338 342
                    if (i != 0) {
......
356 360
                    sql = MessageFormat.format(
357 361
                            ADD_SERIAL_COLUMN_TRIGGER_QUERY,
358 362
                            autoTriggerName,
359
                            getFullTableName(this.table()),
363
                            this.table().toString(),
360 364
                            column.getName(),
361 365
                            sequenceName
362 366
                    );
......
429 433
        }
430 434
    }
431 435

  
432
    private String getFullTableName(TableNameBuilder table) {
433
        if (table.has_database()) {
434
            if (table.has_schema()) {
435
                return as_identifier(table.getDatabase()) + "."
436
                        + as_identifier(table.getSchema()) + "."
437
                        + as_identifier(table.getName().toUpperCase());
438
            }
439
        } else {
440
            if (table.has_schema()) {
441
                return as_identifier(table.getSchema()) + "."
442
                        + as_identifier(table.getName().toUpperCase());
443
            }
444
        }
445
        return as_identifier(table.getName().toUpperCase());
446
    }
447

  
448 436
    public class OracleSelectBuilder extends SelectBuilderBase {
449 437

  
450 438
        @Override
......
612 600
            return this.toString(formatter());
613 601
        }
614 602

  
603
        protected String databaseName2provider() {
604
            return null;
605
        }
606

  
607
        protected String schemaName2provider() {
608
            return this.schemaName;
609
        }
610

  
611
        protected String tableName2provider() {
612
            boolean forceUpperCase = true;
613
            OracleConnectionParameters params = getHelper().getConnectionParameters();
614
            if (params != null) {
615
                forceUpperCase = params.getForceUppercaseInTableName();
616
            }
617
            if( forceUpperCase ) {
618
                return StringUtils.upperCase(this.tableName);
619
            }
620
            return this.tableName;
621
        }
622

  
623

  
615 624
        @Override
616 625
        public String toString(Formatter<ExpressionBuilder.Value> formatter) {
617 626
            if (formatter != null && formatter.canApply(this)) {
618 627
                return formatter.format(this);
619 628
            }
620 629
            if (this.has_schema()) {
621
                return as_identifier(this.schemaName) + "."
622
                        + as_identifier(this.tableName);
630
                return as_identifier(this.schemaName2provider()) + "."
631
                        + as_identifier(this.tableName2provider());
623 632
            }
624 633

  
625
            JDBCConnectionParameters params = helper.getConnectionParameters();
634
            OracleConnectionParameters params = getHelper().getConnectionParameters();
626 635
            if (params != null) {
627 636
                if ((StringUtils.isNotBlank(params.getUser()))) {
628 637
                    return as_identifier(params.getUser()) + "."
629
                            + as_identifier(this.tableName);
638
                            + as_identifier(this.tableName2provider());
630 639
                }
631 640
            }
632
            return as_identifier(this.tableName);
641
            return as_identifier(this.tableName2provider());
633 642
        }
634 643
    }
635 644

  
......
1287 1296
    public int getMaxRecomendedSQLLength() {
1288 1297
        return 2048;
1289 1298
    }
1290

  
1299
    
1291 1300
}

Also available in: Unified diff