...
This will be a fairly simple proxy implementation. Specifically, it will be closest to being a virtual proxy, in that it will appear to be a regular Item object, but will have a slightly smarter implementation (not loading metadata until requested, keeping track of what has changed to make updates more efficient etc).
Code Block |
---|
public class ItemProxy extends Item
{ // Overrides relevant methods of Item. }
|
...
This isn't final, but it's a good start.
Code Block |
---|
public interface ItemDAO extends ContentDAO implements CRUD<Item>, Link<Item, Bundle> { public Item create() throws AuthorizeException; public Item retrieve(int id); public Item retrieve(UUID uuid); public void update(Item item) throws AuthorizeException; public void delete(int id) throws AuthorizeException; public List<Item> getItems(); public List<Item> getItemsBySubmitter(EPerson eperson); public List<Item> getItemsByCollection(Collection collection); public List<Item> getParentItems(Bundle bundle); } |
org.dspace.content.dao.ItemDAOFactory
Code Block |
---|
public class ItemDAOFactory { public static ItemDAO getInstance(Context context) { // Eventually, the implementation that is returned will be // defined in the configuration. return new ItemDAOPostgres(context); } } |
org.dspace.content.dao.postgres.ItemDAOPostgres
This is a fairly straightforward implementation of the above interface. As much as possible, code from the original Item class will be used. For instance, this is how getItems() is implemented:
Code Block |
---|
public List<Item> getItems() { try { TableRowIterator tri = DatabaseManager.queryTable(context, "item", "SELECT item_id FROM item WHERE in_archive = '1'"); List<Item> items = new ArrayList<Item>(); for (TableRow row : tri.toList()) { int id = row.getIntColumn("item_id"); items.add(retrieve(id)); } return items; } catch (SQLException sqle){ // Need to think more carefully about how we deal with SQLExceptions throw new RuntimeException(sqle); } } |
Some changes have been made to eliminate {{ItemIterator}}s, and to generally make things a little more consistent with the rest of the code (this looks almost identical to, eg, CollectionDAO.getCollections().
...