Revision 7438
Added by ben leinfelder almost 12 years ago
src/edu/ucsb/nceas/metacat/IdentifierManager.java | ||
---|---|---|
59 | 59 |
import edu.ucsb.nceas.metacat.accesscontrol.XMLAccessDAO; |
60 | 60 |
import edu.ucsb.nceas.metacat.database.DBConnection; |
61 | 61 |
import edu.ucsb.nceas.metacat.database.DBConnectionPool; |
62 |
import edu.ucsb.nceas.metacat.database.DatabaseService; |
|
62 | 63 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
63 | 64 |
import edu.ucsb.nceas.metacat.shared.AccessException; |
64 | 65 |
import edu.ucsb.nceas.metacat.shared.ServiceException; |
... | ... | |
1477 | 1478 |
} |
1478 | 1479 |
|
1479 | 1480 |
// order the results for slicing ops |
1481 |
String finalQuery = null; |
|
1480 | 1482 |
if (count != 0) { |
1481 | 1483 |
sql += " order by guid "; |
1484 |
finalQuery = DatabaseService.getInstance().getDBAdapter().getPagedQuery(sql, start, count); |
|
1485 |
} else { |
|
1486 |
finalQuery = sql; |
|
1482 | 1487 |
} |
1483 | 1488 |
|
1484 | 1489 |
dbConn = DBConnectionPool.getDBConnection("IdentifierManager.querySystemMetadata"); |
1485 | 1490 |
serialNumber = dbConn.getCheckOutSerialNumber(); |
1486 |
PreparedStatement stmt = dbConn.prepareStatement(sql);
|
|
1491 |
PreparedStatement stmt = dbConn.prepareStatement(finalQuery);
|
|
1487 | 1492 |
|
1488 | 1493 |
if (f1 && f2 && f3) { |
1489 | 1494 |
stmt.setTimestamp(1, new Timestamp(startTime.getTime())); |
... | ... | |
1520 | 1525 |
ol.setTotal(total); |
1521 | 1526 |
} |
1522 | 1527 |
else { |
1523 |
// do the full query |
|
1524 |
for (int i = 0; i < start; i++) { |
|
1525 |
if (rs.next()) { |
|
1526 |
total++; |
|
1527 |
} else { |
|
1528 |
break; |
|
1529 |
} |
|
1530 |
} |
|
1531 |
|
|
1532 |
int countIndex = 0; |
|
1533 |
|
|
1528 |
|
|
1534 | 1529 |
while (rs.next()) { |
1535 |
total++; |
|
1536 |
if (countIndex >= count) { |
|
1537 |
// allow unlimited (negative number for count) |
|
1538 |
if (count > 0) { |
|
1539 |
break; |
|
1540 |
} |
|
1541 |
} |
|
1542 |
|
|
1530 |
|
|
1543 | 1531 |
String guid = rs.getString(1); |
1544 | 1532 |
// logMetacat.debug("query found doc with guid " + guid); |
1545 | 1533 |
// Timestamp dateUploaded = rs.getTimestamp(2); |
... | ... | |
1586 | 1574 |
|
1587 | 1575 |
oi.setSize(size); |
1588 | 1576 |
|
1589 |
// when requested count == 0, return an empty object list |
|
1590 |
if (count != 0) { |
|
1591 |
ol.addObjectInfo(oi); |
|
1592 |
} |
|
1593 |
countIndex++; |
|
1577 |
ol.addObjectInfo(oi); |
|
1578 |
|
|
1594 | 1579 |
} |
1595 | 1580 |
|
1596 |
// expend the resultset to get the total count of possible rows |
|
1597 |
while (rs.next()) { |
|
1598 |
total++; |
|
1599 |
} |
|
1600 | 1581 |
} |
1601 | 1582 |
|
1602 | 1583 |
// set the objectList |
1603 | 1584 |
ol.setStart(start); |
1604 |
ol.setCount(ol.sizeObjectInfoList());
|
|
1605 |
ol.setTotal(total);
|
|
1585 |
ol.setCount(count);
|
|
1586 |
ol.setTotal(ol.sizeObjectInfoList());
|
|
1606 | 1587 |
} |
1607 | 1588 |
|
1608 | 1589 |
finally { |
Also available in: Unified diff
use RDBMS-specific features to limit the resultset for paging the object list -- postgres and oracle have implementations. we don''t really support mssql so I skipped that one.