@@ -1278,8 +1278,8 @@ private final class ViewsLoader {
1278
1278
private static final int OBJECT_NOT_FOUND = -ErrorCode .X_42501 ;
1279
1279
private static final int UNEXPECTED_TOKEN = -ErrorCode .X_42581 ;
1280
1280
1281
- private final Map <String , String > notLoaded = new HashMap <>();
1282
- private final Map <String , String > notLoadedProcedure = new HashMap <>();
1281
+ private final Map <String , String > notLoaded = new LinkedHashMap <>();
1282
+ private final Map <String , String > notLoadedProcedure = new LinkedHashMap <>();
1283
1283
1284
1284
private boolean loadView (Query _q ) throws SQLException {
1285
1285
return loadView (_q , null );
@@ -1322,34 +1322,34 @@ private void registerQueryColumns(Query _q, int _seq) throws SQLException {
1322
1322
}
1323
1323
}
1324
1324
1325
- private boolean loadView (Query q , String queryWKT ) throws SQLException {
1326
- String qnn = SQLConverter .preEscapingIdentifier (q .getName ());
1325
+ private boolean loadView (Query _query , String queryWkt ) throws SQLException {
1326
+ String qnn = SQLConverter .preEscapingIdentifier (_query .getName ());
1327
1327
if (qnn == null ) {
1328
1328
return false ;
1329
1329
}
1330
- int seq = metadata .newTable (q .getName (), qnn , ObjectType .VIEW );
1331
- registerQueryColumns (q , seq );
1330
+ int seq = metadata .newTable (_query .getName (), qnn , ObjectType .VIEW );
1331
+ registerQueryColumns (_query , seq );
1332
1332
qnn = SQLConverter .completeEscaping (qnn , false );
1333
1333
qnn = SQLConverter .checkLang (qnn , conn , false );
1334
1334
if (qnn .indexOf (' ' ) > 0 ) {
1335
- SQLConverter .addWhiteSpacedTableNames (q .getName ());
1335
+ SQLConverter .addWhiteSpacedTableNames (_query .getName ());
1336
1336
}
1337
1337
1338
- String querySQL = queryWKT == null ? q . toSQLString () : queryWKT ;
1338
+ String querySql = Optional . ofNullable ( queryWkt ). orElse ( _query . toSQLString ()) ;
1339
1339
Pivot pivot = null ;
1340
- boolean isPivot = q .getType ().equals (Query .Type .CROSS_TAB );
1340
+ boolean isPivot = _query .getType ().equals (Query .Type .CROSS_TAB );
1341
1341
if (isPivot ) {
1342
1342
pivot = new Pivot (conn );
1343
1343
1344
- if (!pivot .parsePivot (querySQL ) || (querySQL = pivot .toSQL (q .getName ())) == null ) {
1345
- notLoaded .put (q .getName (), "cannot load this query" );
1344
+ if (!pivot .parsePivot (querySql ) || (querySql = pivot .toSQL (_query .getName ())) == null ) {
1345
+ notLoaded .put (_query .getName (), "cannot load this query" );
1346
1346
1347
1347
return false ;
1348
1348
}
1349
1349
1350
1350
}
1351
- querySQL = new DFunction (conn , querySQL ).toSQL ();
1352
- StringBuilder sb = new StringBuilder ("CREATE VIEW " ).append (qnn ).append (" AS " ).append (querySQL );
1351
+ querySql = new DFunction (conn , querySql ).toSQL ();
1352
+ StringBuilder sb = new StringBuilder ("CREATE VIEW " ).append (qnn ).append (" AS " ).append (querySql );
1353
1353
String v = null ;
1354
1354
try {
1355
1355
v = SQLConverter .convertSQL (sb .toString (), true ).getSql ();
@@ -1358,25 +1358,25 @@ private boolean loadView(Query q, String queryWKT) throws SQLException {
1358
1358
v = v .trim ().substring (0 , v .length () - 1 );
1359
1359
}
1360
1360
exec (v , false );
1361
- loadedQueries .add (q .getName ());
1362
- notLoaded .remove (q .getName ());
1361
+ loadedQueries .add (_query .getName ());
1362
+ notLoaded .remove (_query .getName ());
1363
1363
if (pivot != null ) {
1364
- pivot .registerPivot (SQLConverter .preEscapingIdentifier (q .getName ()));
1364
+ pivot .registerPivot (SQLConverter .preEscapingIdentifier (_query .getName ()));
1365
1365
}
1366
1366
return true ;
1367
1367
} catch (Exception _ex ) {
1368
1368
if (_ex instanceof SQLSyntaxErrorException ) {
1369
- if (queryWKT == null && ((SQLSyntaxErrorException ) _ex ).getErrorCode () == OBJECT_ALREADY_EXISTS ) {
1370
- return loadView (q , solveAmbiguous (querySQL ));
1369
+ if (queryWkt == null && OBJECT_ALREADY_EXISTS == ((SQLSyntaxErrorException ) _ex ).getErrorCode ()) {
1370
+ return loadView (_query , solveAmbiguous (querySql ));
1371
1371
} else {
1372
1372
SQLSyntaxErrorException sqle = (SQLSyntaxErrorException ) _ex ;
1373
- if (sqle .getErrorCode () == OBJECT_NOT_FOUND || sqle .getErrorCode () == UNEXPECTED_TOKEN ) {
1374
- ParametricQuery pq = new ParametricQuery (conn , (QueryImpl ) q );
1373
+ if (sqle .getErrorCode () == OBJECT_NOT_FOUND || UNEXPECTED_TOKEN == sqle .getErrorCode ()) {
1374
+ ParametricQuery pq = new ParametricQuery (conn , (QueryImpl ) _query );
1375
1375
pq .setIssueWithParameterName (sqle .getErrorCode () == UNEXPECTED_TOKEN );
1376
1376
pq .createSelect ();
1377
1377
if (pq .loaded ()) {
1378
- loadedQueries .add (q .getName ());
1379
- notLoaded .remove (q .getName ());
1378
+ loadedQueries .add (_query .getName ());
1379
+ notLoaded .remove (_query .getName ());
1380
1380
return true ;
1381
1381
}
1382
1382
@@ -1386,12 +1386,11 @@ private boolean loadView(Query q, String queryWKT) throws SQLException {
1386
1386
1387
1387
String cause = UcanaccessSQLException .explainCause (_ex );
1388
1388
1389
- notLoaded .put (q .getName (), ": " + cause );
1389
+ notLoaded .put (_query .getName (), ": " + cause );
1390
1390
1391
1391
if (!err ) {
1392
- logger .log (Level .WARNING , "Error occured at the first loading attempt of {0}" , q .getName ());
1393
- logger .log (Level .WARNING , "Converted view was: {0}" , v );
1394
- logger .log (Level .WARNING , "Error message was: {0}" , _ex .getMessage ());
1392
+ logger .log (Level .WARNING , "Error at first loading attempt of view \' '{0}\' ', converted view \' '{1}\' ', error {2}" ,
1393
+ _query .getName (), v , _ex .toString ());
1395
1394
err = true ;
1396
1395
}
1397
1396
return false ;
0 commit comments