mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
[DS-734] Improve efficiency of Database accesses
git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5706 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -621,11 +621,11 @@ public class BitstreamFormat
|
|||||||
// Rewrite extensions
|
// Rewrite extensions
|
||||||
for (int i = 0; i < extensions.size(); i++)
|
for (int i = 0; i < extensions.size(); i++)
|
||||||
{
|
{
|
||||||
String s = (String) extensions.get(i);
|
String s = extensions.get(i);
|
||||||
TableRow r = DatabaseManager.create(bfContext, "fileextension");
|
TableRow r = DatabaseManager.row("fileextension");
|
||||||
r.setColumn("bitstream_format_id", getID());
|
r.setColumn("bitstream_format_id", getID());
|
||||||
r.setColumn("extension", s);
|
r.setColumn("extension", s);
|
||||||
DatabaseManager.update(bfContext, r);
|
DatabaseManager.insert(bfContext, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseManager.update(bfContext, bfRow);
|
DatabaseManager.update(bfContext, bfRow);
|
||||||
|
@@ -480,11 +480,10 @@ public class Bundle extends DSpaceObject
|
|||||||
AuthorizeManager.inheritPolicies(ourContext, this, b);
|
AuthorizeManager.inheritPolicies(ourContext, this, b);
|
||||||
|
|
||||||
// Add the mapping row to the database
|
// Add the mapping row to the database
|
||||||
TableRow mappingRow = DatabaseManager.create(ourContext,
|
TableRow mappingRow = DatabaseManager.row("bundle2bitstream");
|
||||||
"bundle2bitstream");
|
|
||||||
mappingRow.setColumn("bundle_id", getID());
|
mappingRow.setColumn("bundle_id", getID());
|
||||||
mappingRow.setColumn("bitstream_id", b.getID());
|
mappingRow.setColumn("bitstream_id", b.getID());
|
||||||
DatabaseManager.update(ourContext, mappingRow);
|
DatabaseManager.insert(ourContext, mappingRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -946,12 +946,12 @@ public class Collection extends DSpaceObject
|
|||||||
+ getID() + ",item_id=" + item.getID()));
|
+ getID() + ",item_id=" + item.getID()));
|
||||||
|
|
||||||
// Create mapping
|
// Create mapping
|
||||||
TableRow row = DatabaseManager.create(ourContext, "collection2item");
|
TableRow row = DatabaseManager.row("collection2item");
|
||||||
|
|
||||||
row.setColumn("collection_id", getID());
|
row.setColumn("collection_id", getID());
|
||||||
row.setColumn("item_id", item.getID());
|
row.setColumn("item_id", item.getID());
|
||||||
|
|
||||||
DatabaseManager.update(ourContext, row);
|
DatabaseManager.insert(ourContext, row);
|
||||||
|
|
||||||
ourContext.addEvent(new Event(Event.ADD, Constants.COLLECTION, getID(), Constants.ITEM, item.getID(), item.getHandle()));
|
ourContext.addEvent(new Event(Event.ADD, Constants.COLLECTION, getID(), Constants.ITEM, item.getID(), item.getHandle()));
|
||||||
}
|
}
|
||||||
|
@@ -880,15 +880,14 @@ public class Community extends DSpaceObject
|
|||||||
if (!tri.hasNext())
|
if (!tri.hasNext())
|
||||||
{
|
{
|
||||||
// No existing mapping, so add one
|
// No existing mapping, so add one
|
||||||
TableRow mappingRow = DatabaseManager.create(ourContext,
|
TableRow mappingRow = DatabaseManager.row("community2collection");
|
||||||
"community2collection");
|
|
||||||
|
|
||||||
mappingRow.setColumn("community_id", getID());
|
mappingRow.setColumn("community_id", getID());
|
||||||
mappingRow.setColumn("collection_id", c.getID());
|
mappingRow.setColumn("collection_id", c.getID());
|
||||||
|
|
||||||
ourContext.addEvent(new Event(Event.ADD, Constants.COMMUNITY, getID(), Constants.COLLECTION, c.getID(), c.getHandle()));
|
ourContext.addEvent(new Event(Event.ADD, Constants.COMMUNITY, getID(), Constants.COLLECTION, c.getID(), c.getHandle()));
|
||||||
|
|
||||||
DatabaseManager.update(ourContext, mappingRow);
|
DatabaseManager.insert(ourContext, mappingRow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -956,15 +955,14 @@ public class Community extends DSpaceObject
|
|||||||
if (!tri.hasNext())
|
if (!tri.hasNext())
|
||||||
{
|
{
|
||||||
// No existing mapping, so add one
|
// No existing mapping, so add one
|
||||||
TableRow mappingRow = DatabaseManager.create(ourContext,
|
TableRow mappingRow = DatabaseManager.row("community2community");
|
||||||
"community2community");
|
|
||||||
|
|
||||||
mappingRow.setColumn("parent_comm_id", getID());
|
mappingRow.setColumn("parent_comm_id", getID());
|
||||||
mappingRow.setColumn("child_comm_id", c.getID());
|
mappingRow.setColumn("child_comm_id", c.getID());
|
||||||
|
|
||||||
ourContext.addEvent(new Event(Event.ADD, Constants.COMMUNITY, getID(), Constants.COMMUNITY, c.getID(), c.getHandle()));
|
ourContext.addEvent(new Event(Event.ADD, Constants.COMMUNITY, getID(), Constants.COMMUNITY, c.getID(), c.getHandle()));
|
||||||
|
|
||||||
DatabaseManager.update(ourContext, mappingRow);
|
DatabaseManager.insert(ourContext, mappingRow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@@ -1258,10 +1258,10 @@ public class Item extends DSpaceObject
|
|||||||
bundles.add(b);
|
bundles.add(b);
|
||||||
|
|
||||||
// Insert the mapping
|
// Insert the mapping
|
||||||
TableRow mappingRow = DatabaseManager.create(ourContext, "item2bundle");
|
TableRow mappingRow = DatabaseManager.row("item2bundle");
|
||||||
mappingRow.setColumn("item_id", getID());
|
mappingRow.setColumn("item_id", getID());
|
||||||
mappingRow.setColumn("bundle_id", b.getID());
|
mappingRow.setColumn("bundle_id", b.getID());
|
||||||
DatabaseManager.update(ourContext, mappingRow);
|
DatabaseManager.insert(ourContext, mappingRow);
|
||||||
|
|
||||||
ourContext.addEvent(new Event(Event.ADD, Constants.ITEM, getID(), Constants.BUNDLE, b.getID(), b.getName()));
|
ourContext.addEvent(new Event(Event.ADD, Constants.ITEM, getID(), Constants.BUNDLE, b.getID(), b.getName()));
|
||||||
}
|
}
|
||||||
|
@@ -261,10 +261,10 @@ public class MetadataSchema
|
|||||||
|
|
||||||
|
|
||||||
// Create a table row and update it with the values
|
// Create a table row and update it with the values
|
||||||
row = DatabaseManager.create(context, "MetadataSchemaRegistry");
|
row = DatabaseManager.row("MetadataSchemaRegistry");
|
||||||
row.setColumn("namespace", namespace);
|
row.setColumn("namespace", namespace);
|
||||||
row.setColumn("short_id", name);
|
row.setColumn("short_id", name);
|
||||||
DatabaseManager.update(context, row);
|
DatabaseManager.insert(context, row);
|
||||||
|
|
||||||
// invalidate our fast-find cache.
|
// invalidate our fast-find cache.
|
||||||
decache();
|
decache();
|
||||||
|
@@ -270,7 +270,7 @@ public class WorkspaceItem implements InProgressSubmission
|
|||||||
i.update();
|
i.update();
|
||||||
|
|
||||||
// Create the workspace item row
|
// Create the workspace item row
|
||||||
TableRow row = DatabaseManager.create(c, "workspaceitem");
|
TableRow row = DatabaseManager.row("workspaceitem");
|
||||||
|
|
||||||
row.setColumn("item_id", i.getID());
|
row.setColumn("item_id", i.getID());
|
||||||
row.setColumn("collection_id", coll.getID());
|
row.setColumn("collection_id", coll.getID());
|
||||||
@@ -280,7 +280,7 @@ public class WorkspaceItem implements InProgressSubmission
|
|||||||
+ "item_id=" + i.getID() + "collection_id="
|
+ "item_id=" + i.getID() + "collection_id="
|
||||||
+ coll.getID()));
|
+ coll.getID()));
|
||||||
|
|
||||||
DatabaseManager.update(c, row);
|
DatabaseManager.insert(c, row);
|
||||||
|
|
||||||
WorkspaceItem wi = new WorkspaceItem(c, row);
|
WorkspaceItem wi = new WorkspaceItem(c, row);
|
||||||
|
|
||||||
|
@@ -227,13 +227,13 @@ public class AccountManager
|
|||||||
// If it already exists, just re-issue it
|
// If it already exists, just re-issue it
|
||||||
if (rd == null)
|
if (rd == null)
|
||||||
{
|
{
|
||||||
rd = DatabaseManager.create(context, "RegistrationData");
|
rd = DatabaseManager.row("RegistrationData");
|
||||||
rd.setColumn("token", Utils.generateHexKey());
|
rd.setColumn("token", Utils.generateHexKey());
|
||||||
|
|
||||||
// don't set expiration date any more
|
// don't set expiration date any more
|
||||||
// rd.setColumn("expires", getDefaultExpirationDate());
|
// rd.setColumn("expires", getDefaultExpirationDate());
|
||||||
rd.setColumn("email", email);
|
rd.setColumn("email", email);
|
||||||
DatabaseManager.update(context, rd);
|
DatabaseManager.insert(context, rd);
|
||||||
|
|
||||||
// This is a potential problem -- if we create the callback
|
// This is a potential problem -- if we create the callback
|
||||||
// and then crash, registration will get SNAFU-ed.
|
// and then crash, registration will get SNAFU-ed.
|
||||||
|
@@ -1153,11 +1153,10 @@ public class Group extends DSpaceObject
|
|||||||
{
|
{
|
||||||
EPerson e = i.next();
|
EPerson e = i.next();
|
||||||
|
|
||||||
TableRow mappingRow = DatabaseManager.create(myContext,
|
TableRow mappingRow = DatabaseManager.row("epersongroup2eperson");
|
||||||
"epersongroup2eperson");
|
|
||||||
mappingRow.setColumn("eperson_id", e.getID());
|
mappingRow.setColumn("eperson_id", e.getID());
|
||||||
mappingRow.setColumn("eperson_group_id", getID());
|
mappingRow.setColumn("eperson_group_id", getID());
|
||||||
DatabaseManager.update(myContext, mappingRow);
|
DatabaseManager.insert(myContext, mappingRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
epeopleChanged = false;
|
epeopleChanged = false;
|
||||||
@@ -1178,11 +1177,10 @@ public class Group extends DSpaceObject
|
|||||||
{
|
{
|
||||||
Group g = i.next();
|
Group g = i.next();
|
||||||
|
|
||||||
TableRow mappingRow = DatabaseManager.create(myContext,
|
TableRow mappingRow = DatabaseManager.row("group2group");
|
||||||
"group2group");
|
|
||||||
mappingRow.setColumn("parent_id", getID());
|
mappingRow.setColumn("parent_id", getID());
|
||||||
mappingRow.setColumn("child_id", g.getID());
|
mappingRow.setColumn("child_id", g.getID());
|
||||||
DatabaseManager.update(myContext, mappingRow);
|
DatabaseManager.insert(myContext, mappingRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
// groups changed, now change group cache
|
// groups changed, now change group cache
|
||||||
@@ -1315,15 +1313,12 @@ public class Group extends DSpaceObject
|
|||||||
|
|
||||||
for (Integer child : parent.getValue())
|
for (Integer child : parent.getValue())
|
||||||
{
|
{
|
||||||
TableRow row = DatabaseManager.create(myContext,
|
TableRow row = DatabaseManager.row("group2groupcache");
|
||||||
"group2groupcache");
|
|
||||||
|
|
||||||
int childID = child.intValue();
|
|
||||||
|
|
||||||
row.setColumn("parent_id", parentID);
|
row.setColumn("parent_id", parentID);
|
||||||
row.setColumn("child_id", childID);
|
row.setColumn("child_id", child);
|
||||||
|
|
||||||
DatabaseManager.update(myContext, row);
|
DatabaseManager.insert(myContext, row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -115,10 +115,10 @@ public class Subscribe
|
|||||||
if (!r.hasNext())
|
if (!r.hasNext())
|
||||||
{
|
{
|
||||||
// Not subscribed, so add them
|
// Not subscribed, so add them
|
||||||
TableRow row = DatabaseManager.create(context, "subscription");
|
TableRow row = DatabaseManager.row("subscription");
|
||||||
row.setColumn("eperson_id", eperson.getID());
|
row.setColumn("eperson_id", eperson.getID());
|
||||||
row.setColumn("collection_id", collection.getID());
|
row.setColumn("collection_id", collection.getID());
|
||||||
DatabaseManager.update(context, row);
|
DatabaseManager.insert(context, row);
|
||||||
|
|
||||||
log.info(LogManager.getHeader(context, "subscribe",
|
log.info(LogManager.getHeader(context, "subscribe",
|
||||||
"eperson_id=" + eperson.getID() + ",collection_id="
|
"eperson_id=" + eperson.getID() + ",collection_id="
|
||||||
|
@@ -174,11 +174,10 @@ public class Supervisor {
|
|||||||
{
|
{
|
||||||
// make a table row in the database table, and update with the relevant
|
// make a table row in the database table, and update with the relevant
|
||||||
// details
|
// details
|
||||||
TableRow row = DatabaseManager.create(context,
|
TableRow row = DatabaseManager.row("epersongroup2workspaceitem");
|
||||||
"epersongroup2workspaceitem");
|
|
||||||
row.setColumn("workspace_item_id", wsItemID);
|
row.setColumn("workspace_item_id", wsItemID);
|
||||||
row.setColumn("eperson_group_id", groupID);
|
row.setColumn("eperson_group_id", groupID);
|
||||||
DatabaseManager.update(context,row);
|
DatabaseManager.insert(context,row);
|
||||||
|
|
||||||
// If a default policy type has been requested, apply the policies using
|
// If a default policy type has been requested, apply the policies using
|
||||||
// the DSpace API for doing so
|
// the DSpace API for doing so
|
||||||
|
@@ -122,10 +122,10 @@ public class HarvestedCollection
|
|||||||
* @return a new HarvestInstance object
|
* @return a new HarvestInstance object
|
||||||
*/
|
*/
|
||||||
public static HarvestedCollection create(Context c, int collectionId) throws SQLException {
|
public static HarvestedCollection create(Context c, int collectionId) throws SQLException {
|
||||||
TableRow row = DatabaseManager.create(c, "harvested_collection");
|
TableRow row = DatabaseManager.row("harvested_collection");
|
||||||
row.setColumn("collection_id", collectionId);
|
row.setColumn("collection_id", collectionId);
|
||||||
row.setColumn("harvest_type", 0);
|
row.setColumn("harvest_type", 0);
|
||||||
DatabaseManager.update(c, row);
|
DatabaseManager.insert(c, row);
|
||||||
|
|
||||||
return new HarvestedCollection(c, row);
|
return new HarvestedCollection(c, row);
|
||||||
}
|
}
|
||||||
|
@@ -140,10 +140,10 @@ public class HarvestedItem
|
|||||||
* @return a new HarvestedItem object
|
* @return a new HarvestedItem object
|
||||||
*/
|
*/
|
||||||
public static HarvestedItem create(Context c, int itemId, String itemOAIid) throws SQLException {
|
public static HarvestedItem create(Context c, int itemId, String itemOAIid) throws SQLException {
|
||||||
TableRow row = DatabaseManager.create(c, "harvested_item");
|
TableRow row = DatabaseManager.row("harvested_item");
|
||||||
row.setColumn("item_id", itemId);
|
row.setColumn("item_id", itemId);
|
||||||
row.setColumn("oai_id", itemOAIid);
|
row.setColumn("oai_id", itemOAIid);
|
||||||
DatabaseManager.update(c, row);
|
DatabaseManager.insert(c, row);
|
||||||
|
|
||||||
return new HarvestedItem(c, row);
|
return new HarvestedItem(c, row);
|
||||||
}
|
}
|
||||||
|
@@ -292,7 +292,7 @@ public class BitstreamStorageManager
|
|||||||
{
|
{
|
||||||
tempContext = new Context();
|
tempContext = new Context();
|
||||||
|
|
||||||
bitstream = DatabaseManager.create(tempContext, "Bitstream");
|
bitstream = DatabaseManager.row("Bitstream");
|
||||||
bitstream.setColumn("deleted", true);
|
bitstream.setColumn("deleted", true);
|
||||||
bitstream.setColumn("internal_id", id);
|
bitstream.setColumn("internal_id", id);
|
||||||
|
|
||||||
@@ -303,7 +303,7 @@ public class BitstreamStorageManager
|
|||||||
*/
|
*/
|
||||||
bitstream.setColumn("store_number", incoming);
|
bitstream.setColumn("store_number", incoming);
|
||||||
|
|
||||||
DatabaseManager.update(tempContext, bitstream);
|
DatabaseManager.insert(tempContext, bitstream);
|
||||||
|
|
||||||
tempContext.complete();
|
tempContext.complete();
|
||||||
}
|
}
|
||||||
@@ -400,11 +400,11 @@ public class BitstreamStorageManager
|
|||||||
try {
|
try {
|
||||||
tempContext = new Context();
|
tempContext = new Context();
|
||||||
|
|
||||||
bitstream = DatabaseManager.create(tempContext, "Bitstream");
|
bitstream = DatabaseManager.row("Bitstream");
|
||||||
bitstream.setColumn("deleted", true);
|
bitstream.setColumn("deleted", true);
|
||||||
bitstream.setColumn("internal_id", sInternalId);
|
bitstream.setColumn("internal_id", sInternalId);
|
||||||
bitstream.setColumn("store_number", assetstore);
|
bitstream.setColumn("store_number", assetstore);
|
||||||
DatabaseManager.update(tempContext, bitstream);
|
DatabaseManager.insert(tempContext, bitstream);
|
||||||
|
|
||||||
tempContext.complete();
|
tempContext.complete();
|
||||||
} catch (SQLException sqle) {
|
} catch (SQLException sqle) {
|
||||||
|
@@ -188,9 +188,10 @@ public class WorkflowManager
|
|||||||
recordStart(c, myitem);
|
recordStart(c, myitem);
|
||||||
|
|
||||||
// create the WorkflowItem
|
// create the WorkflowItem
|
||||||
TableRow row = DatabaseManager.create(c, "workflowitem");
|
TableRow row = DatabaseManager.row("workflowitem");
|
||||||
row.setColumn("item_id", myitem.getID());
|
row.setColumn("item_id", myitem.getID());
|
||||||
row.setColumn("collection_id", wsi.getCollection().getID());
|
row.setColumn("collection_id", wsi.getCollection().getID());
|
||||||
|
DatabaseManager.insert(c, row);
|
||||||
|
|
||||||
WorkflowItem wfi = new WorkflowItem(c, row);
|
WorkflowItem wfi = new WorkflowItem(c, row);
|
||||||
|
|
||||||
@@ -803,10 +804,10 @@ public class WorkflowManager
|
|||||||
// FIXME: Remove license
|
// FIXME: Remove license
|
||||||
// FIXME: Provenance statement?
|
// FIXME: Provenance statement?
|
||||||
// Create the new workspace item row
|
// Create the new workspace item row
|
||||||
TableRow row = DatabaseManager.create(c, "workspaceitem");
|
TableRow row = DatabaseManager.row("workspaceitem");
|
||||||
row.setColumn("item_id", myitem.getID());
|
row.setColumn("item_id", myitem.getID());
|
||||||
row.setColumn("collection_id", mycollection.getID());
|
row.setColumn("collection_id", mycollection.getID());
|
||||||
DatabaseManager.update(c, row);
|
DatabaseManager.insert(c, row);
|
||||||
|
|
||||||
int wsi_id = row.getIntColumn("workspace_item_id");
|
int wsi_id = row.getIntColumn("workspace_item_id");
|
||||||
WorkspaceItem wi = WorkspaceItem.find(c, wsi_id);
|
WorkspaceItem wi = WorkspaceItem.find(c, wsi_id);
|
||||||
@@ -890,10 +891,10 @@ public class WorkflowManager
|
|||||||
{
|
{
|
||||||
// can we get away without creating a tasklistitem class?
|
// can we get away without creating a tasklistitem class?
|
||||||
// do we want to?
|
// do we want to?
|
||||||
TableRow tr = DatabaseManager.create(c, "tasklistitem");
|
TableRow tr = DatabaseManager.row("tasklistitem");
|
||||||
tr.setColumn("eperson_id", epa[i].getID());
|
tr.setColumn("eperson_id", epa[i].getID());
|
||||||
tr.setColumn("workflow_id", wi.getID());
|
tr.setColumn("workflow_id", wi.getID());
|
||||||
DatabaseManager.update(c, tr);
|
DatabaseManager.insert(c, tr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -76,6 +76,7 @@
|
|||||||
- [DS-697] Allow media filter plugins to register their input formats directly
|
- [DS-697] Allow media filter plugins to register their input formats directly
|
||||||
- [DS-732] Browse performance improvements
|
- [DS-732] Browse performance improvements
|
||||||
- [DS-733] Load testing utilities
|
- [DS-733] Load testing utilities
|
||||||
|
- [DS-734] Improve database efficiency
|
||||||
|
|
||||||
(Graham Triggs, Mark Wood)
|
(Graham Triggs, Mark Wood)
|
||||||
- [DS-707] General improvements to performance, bug fixes and style
|
- [DS-707] General improvements to performance, bug fixes and style
|
||||||
|
Reference in New Issue
Block a user