Project

General

Profile

« Previous | Next » 

Revision 9072

Added by Jing Tao almost 10 years ago

Implemented the feature to support the identifier(both sid and pid) feature in the objectLists method.

View differences:

src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
1463 1463
          if (count == null || count > MAXIMUM_DB_RECORD_COUNT) {
1464 1464
              count = MAXIMUM_DB_RECORD_COUNT;
1465 1465
          }
1466
          objectList = IdentifierManager.getInstance().querySystemMetadata(startTime, endTime, objectFormatId, replicaStatus, start, count);
1466
          boolean isSid = false;
1467
          if(identifier != null) {
1468
              isSid = IdentifierManager.getInstance().systemMetadataSIDExists(identifier);
1469
          }
1470
          objectList = IdentifierManager.getInstance().querySystemMetadata(startTime, endTime, objectFormatId, replicaStatus, start, count, identifier, isSid);
1467 1471
      } catch (Exception e) {
1468 1472
          throw new ServiceFailure("1580", "Error querying system metadata: " + e.getMessage());
1469 1473
      }
src/edu/ucsb/nceas/metacat/dataone/SyncAccessPolicy.java
344 344
			}
345 345

  
346 346
			// Get the total count of guids before we start syncing
347
			Identifier id = null;
348
            boolean isSid = false;
347 349
			try {
350
			    
348 351
				objsToSync = IdentifierManager.getInstance()
349 352
						.querySystemMetadata(startTime, endTime,
350
								objectFormatId, replicaStatus, start, count);
353
								objectFormatId, replicaStatus, start, count, id, isSid);
351 354

  
352 355
				logMetacat.debug("syncTask total # of guids: "
353 356
						+ objsToSync.getTotal() + ", count for this page: "
......
380 383
					objsToSync = IdentifierManager
381 384
							.getInstance()
382 385
							.querySystemMetadata(startTime, endTime,
383
									objectFormatId, replicaStatus, start, count);
386
									objectFormatId, replicaStatus, start, count, id, isSid);
384 387
				} catch (Exception e) {
385 388
					logMetacat.error("Error syncing ids");
386 389
					syncError = true;
src/edu/ucsb/nceas/metacat/IdentifierManager.java
1559 1559
     */
1560 1560
    public ObjectList querySystemMetadata(Date startTime, Date endTime,
1561 1561
        ObjectFormatIdentifier objectFormatId, boolean replicaStatus,
1562
        int start, int count) 
1562
        int start, int count, Identifier identifier, boolean isSID) 
1563 1563
        throws SQLException, PropertyNotFoundException, ServiceException {
1564 1564
        ObjectList ol = new ObjectList();
1565 1565
        DBConnection dbConn = null;
......
1579 1579
            boolean f1 = false;
1580 1580
            boolean f2 = false;
1581 1581
            boolean f3 = false;
1582
            boolean f4 = false;
1582 1583

  
1584

  
1583 1585
            if (startTime != null) {
1584 1586
                whereClauseSql += " where systemmetadata.date_modified >= ?";
1585 1587
                f1 = true;
......
1602 1604
                }
1603 1605
                f3 = true;
1604 1606
            }
1607
            
1608
            if(identifier != null && identifier.getValue() != null && !identifier.getValue().equals("")) {
1609
                if (!f1 && !f2 && !f3 ) {
1610
                    if(isSID) {
1611
                        whereClauseSql += " where series_id = ?";
1612
                    } else {
1613
                        whereClauseSql += " where guid = ?";
1614
                    }
1615
                    
1616
                } else {
1617
                    if(isSID) {
1618
                        whereClauseSql += " and series_id = ?";
1619
                    } else {
1620
                        whereClauseSql += " and guid = ?";
1621
                    }
1622
                }
1623
                f4 = true;
1624
            }
1605 1625

  
1606 1626
            if (!replicaStatus) {
1607 1627
                String currentNodeId = PropertyService.getInstance().getProperty("dataone.nodeId");
1608
                if (!f1 && !f2 && !f3) {
1628
                if (!f1 && !f2 && !f3 && !f4) {
1609 1629
                    whereClauseSql += " where authoritive_member_node = '" +
1610 1630
                        currentNodeId.trim() + "'";
1611 1631
                } else {
......
1614 1634
                }
1615 1635
            }
1616 1636
            
1637
           
1638
            
1617 1639
            // connection
1618 1640
            dbConn = DBConnectionPool.getDBConnection("IdentifierManager.querySystemMetadata");
1619 1641
            serialNumber = dbConn.getCheckOutSerialNumber();
......
1628 1650
            String countQuery = countSql + whereClauseSql;
1629 1651
            PreparedStatement countStmt = dbConn.prepareStatement(countQuery);
1630 1652

  
1631
            if (f1 && f2 && f3) {
1653
            if (f1 && f2 && f3 && f4) {
1632 1654
                fieldStmt.setTimestamp(1, new Timestamp(startTime.getTime()));
1633 1655
                fieldStmt.setTimestamp(2, new Timestamp(endTime.getTime()));
1634 1656
                fieldStmt.setString(3, objectFormatId.getValue());
1657
                fieldStmt.setString(4, identifier.getValue());
1635 1658
                // count
1636 1659
                countStmt.setTimestamp(1, new Timestamp(startTime.getTime()));
1637 1660
                countStmt.setTimestamp(2, new Timestamp(endTime.getTime()));
1638 1661
                countStmt.setString(3, objectFormatId.getValue());
1639
            } else if (f1 && f2 && !f3) {
1662
                countStmt.setString(4, identifier.getValue());
1663
            } if (f1 && f2 && f3 && !f4) {
1640 1664
                fieldStmt.setTimestamp(1, new Timestamp(startTime.getTime()));
1641 1665
                fieldStmt.setTimestamp(2, new Timestamp(endTime.getTime()));
1666
                fieldStmt.setString(3, objectFormatId.getValue());
1642 1667
                // count
1643 1668
                countStmt.setTimestamp(1, new Timestamp(startTime.getTime()));
1644 1669
                countStmt.setTimestamp(2, new Timestamp(endTime.getTime()));
1645
            } else if (f1 && !f2 && f3) {
1670
                countStmt.setString(3, objectFormatId.getValue());
1671
            } else if (f1 && f2 && !f3 && f4) {
1646 1672
                fieldStmt.setTimestamp(1, new Timestamp(startTime.getTime()));
1673
                fieldStmt.setTimestamp(2, new Timestamp(endTime.getTime()));
1674
                fieldStmt.setString(3, identifier.getValue());
1675
                // count
1676
                countStmt.setTimestamp(1, new Timestamp(startTime.getTime()));
1677
                countStmt.setTimestamp(2, new Timestamp(endTime.getTime()));
1678
                countStmt.setString(3, identifier.getValue());
1679
            } else if (f1 && f2 && !f3 && !f4) {
1680
                fieldStmt.setTimestamp(1, new Timestamp(startTime.getTime()));
1681
                fieldStmt.setTimestamp(2, new Timestamp(endTime.getTime()));
1682
                // count
1683
                countStmt.setTimestamp(1, new Timestamp(startTime.getTime()));
1684
                countStmt.setTimestamp(2, new Timestamp(endTime.getTime()));
1685
            } else if (f1 && !f2 && f3 && f4) {
1686
                fieldStmt.setTimestamp(1, new Timestamp(startTime.getTime()));
1647 1687
                fieldStmt.setString(2, objectFormatId.getValue());
1688
                fieldStmt.setString(3, identifier.getValue());
1648 1689
                // count
1649 1690
                countStmt.setTimestamp(1, new Timestamp(startTime.getTime()));
1650 1691
                countStmt.setString(2, objectFormatId.getValue());
1651
            } else if (f1 && !f2 && !f3) {
1692
                countStmt.setString(3, identifier.getValue());
1693
            } else if (f1 && !f2 && f3 && !f4) {
1652 1694
                fieldStmt.setTimestamp(1, new Timestamp(startTime.getTime()));
1695
                fieldStmt.setString(2, objectFormatId.getValue());
1653 1696
                // count
1654 1697
                countStmt.setTimestamp(1, new Timestamp(startTime.getTime()));
1655
            } else if (!f1 && f2 && f3) {
1698
                countStmt.setString(2, objectFormatId.getValue());
1699
            } else if (f1 && !f2 && !f3 && f4) {
1700
                fieldStmt.setTimestamp(1, new Timestamp(startTime.getTime()));
1701
                fieldStmt.setString(2, identifier.getValue());
1702
                // count
1703
                countStmt.setTimestamp(1, new Timestamp(startTime.getTime()));
1704
                countStmt.setString(2, identifier.getValue());
1705
            } else if (f1 && !f2 && !f3 && !f4) {
1706
                fieldStmt.setTimestamp(1, new Timestamp(startTime.getTime()));
1707
                // count
1708
                countStmt.setTimestamp(1, new Timestamp(startTime.getTime()));
1709
            } else if (!f1 && f2 && f3 && f4) {
1656 1710
                fieldStmt.setTimestamp(1, new Timestamp(endTime.getTime()));
1657 1711
                fieldStmt.setString(2, objectFormatId.getValue());
1712
                fieldStmt.setString(3, identifier.getValue());
1658 1713
                // count
1659 1714
                countStmt.setTimestamp(1, new Timestamp(endTime.getTime()));
1660 1715
                countStmt.setString(2, objectFormatId.getValue());
1661
            } else if (!f1 && !f2 && f3) {
1716
                countStmt.setString(3, identifier.getValue());
1717
            } else if (!f1 && f2 && f3 && !f4) {
1718
                fieldStmt.setTimestamp(1, new Timestamp(endTime.getTime()));
1719
                fieldStmt.setString(2, objectFormatId.getValue());
1720
                // count
1721
                countStmt.setTimestamp(1, new Timestamp(endTime.getTime()));
1722
                countStmt.setString(2, objectFormatId.getValue());
1723
            } else if (!f1 && !f2 && f3 && f4) {
1662 1724
                fieldStmt.setString(1, objectFormatId.getValue());
1725
                fieldStmt.setString(2, identifier.getValue());
1663 1726
                // count
1664 1727
                countStmt.setString(1, objectFormatId.getValue());
1665
            } else if (!f1 && f2 && !f3) {
1728
                countStmt.setString(2, identifier.getValue());
1729
            } else if (!f1 && !f2 && f3 && !f4) {
1730
                fieldStmt.setString(1, objectFormatId.getValue());
1731
                // count
1732
                countStmt.setString(1, objectFormatId.getValue());
1733
            } else if (!f1 && f2 && !f3 && f4) {
1666 1734
                fieldStmt.setTimestamp(1, new Timestamp(endTime.getTime()));
1735
                fieldStmt.setString(2, identifier.getValue());
1667 1736
                // count
1668 1737
                countStmt.setTimestamp(1, new Timestamp(endTime.getTime()));
1738
                countStmt.setString(2, identifier.getValue());
1739
            } else if (!f1 && f2 && !f3 && !f4) {
1740
                fieldStmt.setTimestamp(1, new Timestamp(endTime.getTime()));
1741
                // count
1742
                countStmt.setTimestamp(1, new Timestamp(endTime.getTime()));
1743
            } else if (!f1 && !f2 && !f3 && f4) {
1744
                fieldStmt.setString(1, identifier.getValue());
1745
                // count
1746
                countStmt.setString(1, identifier.getValue());
1747
            } else if (!f1 && !f2 && !f3 && !f4) {
1748
                //do nothing
1669 1749
            }
1670 1750

  
1671 1751
            logMetacat.debug("list objects fieldStmt: " + fieldStmt.toString());

Also available in: Unified diff