Commit f7058df2eb20efc5c4a9abf28b65c05a9ba02a09

Authored by Fernando Ribeiro
1 parent c688b47e70

DS-2517 replace erroneous sql column with correct column

Replaced Item.java item_id by resource_id
dspace-api/src/main/java/org/dspace/content/Item.java
... ... @@ -182,7 +182,7 @@ public class Item extends DSpaceObject
182 182 i.update();
183 183 context.restoreAuthSystemState();
184 184  
185   - context.addEvent(new Event(Event.CREATE, Constants.ITEM, i.getID(),
  185 + context.addEvent(new Event(Event.CREATE, Constants.ITEM, i.getID(),
186 186 null, i.getIdentifiers(context)));
187 187  
188 188 log.info(LogManager.getHeader(context, "create_item", "item_id="
... ... @@ -208,7 +208,7 @@ public class Item extends DSpaceObject
208 208  
209 209 return new ItemIterator(context, rows);
210 210 }
211   -
  211 +
212 212 /**
213 213 * Get all "final" items in the archive, both archived ("in archive" flag) or
214 214 * withdrawn items are included. The order of the list is indeterminate.
... ... @@ -263,7 +263,7 @@ public class Item extends DSpaceObject
263 263 }
264 264  
265 265 String query = "SELECT item.* FROM metadatavalue,item WHERE item.in_archive='1' " +
266   - "AND item.item_id = metadatavalue.item_id AND metadata_field_id = ?";
  266 + "AND item.item_id = metadatavalue.resource_id AND metadata_field_id = ?";
267 267 TableRowIterator rows = null;
268 268 if (Item.ANY.equals(authority)) {
269 269 rows = DatabaseManager.queryTable(context, "item", query, mdf.getFieldID());
... ... @@ -688,7 +688,7 @@ public class Item extends DSpaceObject
688 688 }
689 689 }
690 690 }
691   -
  691 +
692 692 Bundle[] bundleArray = new Bundle[bundles.size()];
693 693 bundleArray = (Bundle[]) bundles.toArray(bundleArray);
694 694  
... ... @@ -792,8 +792,8 @@ public class Item extends DSpaceObject
792 792 mappingRow.setColumn("bundle_id", b.getID());
793 793 DatabaseManager.insert(ourContext, mappingRow);
794 794  
795   - ourContext.addEvent(new Event(Event.ADD, Constants.ITEM, getID(),
796   - Constants.BUNDLE, b.getID(), b.getName(),
  795 + ourContext.addEvent(new Event(Event.ADD, Constants.ITEM, getID(),
  796 + Constants.BUNDLE, b.getID(), b.getName(),
797 797 getIdentifiers(ourContext)));
798 798 }
799 799  
... ... @@ -818,7 +818,7 @@ public class Item extends DSpaceObject
818 818  
819 819 // Remove from internal list of bundles
820 820 Bundle[] bunds = getBundles();
821   -
  821 +
822 822 for (int i = 0; i < bunds.length; i++)
823 823 {
824 824 if (b.getID() == bunds[i].getID())
... ... @@ -835,7 +835,7 @@ public class Item extends DSpaceObject
835 835 "AND bundle_id= ? ",
836 836 getID(), b.getID());
837 837  
838   - ourContext.addEvent(new Event(Event.REMOVE, Constants.ITEM, getID(),
  838 + ourContext.addEvent(new Event(Event.REMOVE, Constants.ITEM, getID(),
839 839 Constants.BUNDLE, b.getID(), b.getName(), getIdentifiers(ourContext)));
840 840  
841 841 // If the bundle is orphaned, it's removed
... ... @@ -1101,7 +1101,7 @@ public class Item extends DSpaceObject
1101 1101 clearDetails();
1102 1102 }
1103 1103  
1104   - ourContext.addEvent(new Event(Event.MODIFY, Constants.ITEM, getID(),
  1104 + ourContext.addEvent(new Event(Event.MODIFY, Constants.ITEM, getID(),
1105 1105 null, getIdentifiers(ourContext)));
1106 1106 modified = false;
1107 1107 }
... ... @@ -1155,7 +1155,7 @@ public class Item extends DSpaceObject
1155 1155 // Update item in DB
1156 1156 update();
1157 1157  
1158   - ourContext.addEvent(new Event(Event.MODIFY, Constants.ITEM, getID(),
  1158 + ourContext.addEvent(new Event(Event.MODIFY, Constants.ITEM, getID(),
1159 1159 "WITHDRAW", getIdentifiers(ourContext)));
1160 1160  
1161 1161 // remove all authorization policies, saving the custom ones
... ... @@ -1198,7 +1198,7 @@ public class Item extends DSpaceObject
1198 1198 {
1199 1199 prov.append(colls[i].getMetadata("name")).append(" (ID: ").append(colls[i].getID()).append(")\n");
1200 1200 }
1201   -
  1201 +
1202 1202 // Clear withdrawn flag
1203 1203 itemRow.setColumn("withdrawn", false);
1204 1204  
... ... @@ -1214,7 +1214,7 @@ public class Item extends DSpaceObject
1214 1214 // Update item in DB
1215 1215 update();
1216 1216  
1217   - ourContext.addEvent(new Event(Event.MODIFY, Constants.ITEM, getID(),
  1217 + ourContext.addEvent(new Event(Event.MODIFY, Constants.ITEM, getID(),
1218 1218 "REINSTATE", getIdentifiers(ourContext)));
1219 1219  
1220 1220 // authorization policies
... ... @@ -1248,7 +1248,7 @@ public class Item extends DSpaceObject
1248 1248 // leaving the database in an inconsistent state
1249 1249 AuthorizeManager.authorizeAction(ourContext, this, Constants.REMOVE);
1250 1250  
1251   - ourContext.addEvent(new Event(Event.DELETE, Constants.ITEM, getID(),
  1251 + ourContext.addEvent(new Event(Event.DELETE, Constants.ITEM, getID(),
1252 1252 getHandle(), getIdentifiers(ourContext)));
1253 1253  
1254 1254 log.info(LogManager.getHeader(ourContext, "delete_item", "item_id="
... ... @@ -1296,10 +1296,10 @@ public class Item extends DSpaceObject
1296 1296  
1297 1297 // remove all of our authorization policies
1298 1298 AuthorizeManager.removeAllPolicies(ourContext, this);
1299   -
  1299 +
1300 1300 // Remove any Handle
1301 1301 HandleManager.unbindHandle(ourContext, this);
1302   -
  1302 +
1303 1303 // remove version attached to the item
1304 1304 removeVersion();
1305 1305  
... ... @@ -1307,7 +1307,7 @@ public class Item extends DSpaceObject
1307 1307 // Finally remove item row
1308 1308 DatabaseManager.delete(ourContext, itemRow);
1309 1309 }
1310   -
  1310 +
1311 1311 private void removeVersion() throws AuthorizeException, SQLException
1312 1312 {
1313 1313 VersioningService versioningService = new DSpace().getSingletonService(VersioningService.class);
... ... @@ -1621,7 +1621,7 @@ public class Item extends DSpaceObject
1621 1621 {
1622 1622 AuthorizeManager.authorizeAction(ourContext, this, Constants.WRITE);
1623 1623 }
1624   -
  1624 +
1625 1625 // Move the Item from one Collection to the other
1626 1626 to.addItem(this);
1627 1627 from.removeItem(this);
... ... @@ -1657,12 +1657,12 @@ public class Item extends DSpaceObject
1657 1657  
1658 1658 // Note that updating the owning collection above will have the same effect,
1659 1659 // so we only do this here if the owning collection hasn't changed.
1660   -
1661   - ourContext.addEvent(new Event(Event.MODIFY, Constants.ITEM, getID(),
  1660 +
  1661 + ourContext.addEvent(new Event(Event.MODIFY, Constants.ITEM, getID(),
1662 1662 null, getIdentifiers(ourContext)));
1663 1663 }
1664 1664 }
1665   -
  1665 +
1666 1666 /**
1667 1667 * Check the bundle ORIGINAL to see if there are any uploaded files
1668 1668 *
... ... @@ -1690,7 +1690,7 @@ public class Item extends DSpaceObject
1690 1690 }
1691 1691 return true;
1692 1692 }
1693   -
  1693 +
1694 1694 /**
1695 1695 * Get the collections this item is not in.
1696 1696 *
... ... @@ -1707,13 +1707,13 @@ public class Item extends DSpaceObject
1707 1707 {
1708 1708 return notLinkedCollections;
1709 1709 }
1710   -
  1710 +
1711 1711 int i = 0;
1712   -
  1712 +
1713 1713 for (Collection collection : allCollections)
1714 1714 {
1715 1715 boolean alreadyLinked = false;
1716   -
  1716 +
1717 1717 for (Collection linkedCommunity : linkedCollections)
1718 1718 {
1719 1719 if (collection.getID() == linkedCommunity.getID())
... ... @@ -1722,13 +1722,13 @@ public class Item extends DSpaceObject
1722 1722 break;
1723 1723 }
1724 1724 }
1725   -
  1725 +
1726 1726 if (!alreadyLinked)
1727 1727 {
1728 1728 notLinkedCollections[i++] = collection;
1729 1729 }
1730 1730 }
1731   -
  1731 +
1732 1732 return notLinkedCollections;
1733 1733 }
1734 1734  
... ... @@ -1761,7 +1761,7 @@ public class Item extends DSpaceObject
1761 1761  
1762 1762 return false;
1763 1763 }
1764   -
  1764 +
1765 1765 public String getName()
1766 1766 {
1767 1767 return getMetadataFirstValue(MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
... ... @@ -1795,7 +1795,7 @@ public class Item extends DSpaceObject
1795 1795 throw new IllegalArgumentException(
1796 1796 "No such metadata field: schema=" + schema + ", element=" + element + ", qualifier=" + qualifier);
1797 1797 }
1798   -
  1798 +
1799 1799 String query = "SELECT item.* FROM metadatavalue,item WHERE item.in_archive='1' "+
1800 1800 "AND item.item_id = metadatavalue.resource_id AND metadata_field_id = ? AND resource_type_id = ?";
1801 1801 TableRowIterator rows = null;
... ... @@ -1810,7 +1810,7 @@ public class Item extends DSpaceObject
1810 1810 }
1811 1811 return new ItemIterator(context, rows);
1812 1812 }
1813   -
  1813 +
1814 1814 public DSpaceObject getAdminObject(int action) throws SQLException
1815 1815 {
1816 1816 DSpaceObject adminObject = null;
... ... @@ -1840,7 +1840,7 @@ public class Item extends DSpaceObject
1840 1840 }
1841 1841 }
1842 1842 }
1843   -
  1843 +
1844 1844 switch (action)
1845 1845 {
1846 1846 case Constants.ADD:
... ... @@ -1924,7 +1924,7 @@ public class Item extends DSpaceObject
1924 1924 }
1925 1925 return adminObject;
1926 1926 }
1927   -
  1927 +
1928 1928 public DSpaceObject getParentObject() throws SQLException
1929 1929 {
1930 1930 Collection ownCollection = getOwningCollection();
... ...