mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 10:04:21 +00:00
Fix problem searching by author in item mapping. Remove even more database contention (when editing / mapping items)
git-svn-id: http://scm.dspace.org/svn/repo/branches/dspace-1_5_x@2631 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -81,8 +81,8 @@ public interface BrowseCreateDAO
|
|||||||
public void deleteByItemID(String table, int itemID) throws BrowseException;
|
public void deleteByItemID(String table, int itemID) throws BrowseException;
|
||||||
|
|
||||||
public void deleteCommunityMappings(int itemID) throws BrowseException;
|
public void deleteCommunityMappings(int itemID) throws BrowseException;
|
||||||
public void insertCommunityMappings(int itemID) throws BrowseException;
|
public void updateCommunityMappings(int itemID) throws BrowseException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert an index record into the given table for the given item id. The Map should contain
|
* Insert an index record into the given table for the given item id. The Map should contain
|
||||||
|
@@ -534,17 +534,54 @@ public class BrowseCreateDAOOracle implements BrowseCreateDAO
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.dspace.browse.BrowseCreateDAO#insertCommunityMappings(java.lang.String, java.lang.String, java.lang.String)
|
* @see org.dspace.browse.BrowseCreateDAO#updateCommunityMappings(int)
|
||||||
*/
|
*/
|
||||||
public void insertCommunityMappings(int itemID) throws BrowseException
|
public void updateCommunityMappings(int itemID) throws BrowseException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// Get all the communities for this item
|
||||||
int[] commID = getAllCommunityIDs(itemID);
|
int[] commID = getAllCommunityIDs(itemID);
|
||||||
|
|
||||||
|
// Remove (set to -1) any duplicate communities
|
||||||
for (int i = 0; i < commID.length; i++)
|
for (int i = 0; i < commID.length; i++)
|
||||||
{
|
{
|
||||||
if (isFirstOccurrence(commID, i))
|
if (!isFirstOccurrence(commID, i))
|
||||||
|
commID[i] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find all existing mappings for this item
|
||||||
|
TableRowIterator tri = DatabaseManager.queryTable(context, "Communities2Item", "SELECT * FROM Communities2Item WHERE item_id=?", itemID);
|
||||||
|
if (tri != null)
|
||||||
|
{
|
||||||
|
while (tri.hasNext())
|
||||||
|
{
|
||||||
|
TableRow tr = tri.next();
|
||||||
|
|
||||||
|
// Check the item mappings to see if it contains this community mapping
|
||||||
|
boolean itemIsMapped = false;
|
||||||
|
int trCommID = tr.getIntColumn("community_id");
|
||||||
|
for (int i = 0; i < commID.length; i++)
|
||||||
|
{
|
||||||
|
// Found this community
|
||||||
|
if (commID[i] == trCommID)
|
||||||
|
{
|
||||||
|
// Flag it, and remove (-1) from the item mappings
|
||||||
|
itemIsMapped = true;
|
||||||
|
commID[i] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The item is no longer mapped to this community, so remove the database record
|
||||||
|
if (!itemIsMapped)
|
||||||
|
DatabaseManager.delete(context, tr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Any remaining mappings need to be added to the database
|
||||||
|
for (int i = 0; i < commID.length; i++)
|
||||||
|
{
|
||||||
|
if (commID[i] > -1)
|
||||||
{
|
{
|
||||||
TableRow row = DatabaseManager.create(context, "Communities2Item");
|
TableRow row = DatabaseManager.create(context, "Communities2Item");
|
||||||
row.setColumn("item_id", itemID);
|
row.setColumn("item_id", itemID);
|
||||||
|
@@ -535,17 +535,54 @@ public class BrowseCreateDAOPostgres implements BrowseCreateDAO
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.dspace.browse.BrowseCreateDAO#insertCommunityMappings(java.lang.String, java.lang.String, java.lang.String)
|
* @see org.dspace.browse.BrowseCreateDAO#updateCommunityMappings(int)
|
||||||
*/
|
*/
|
||||||
public void insertCommunityMappings(int itemID) throws BrowseException
|
public void updateCommunityMappings(int itemID) throws BrowseException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// Get all the communities for this item
|
||||||
int[] commID = getAllCommunityIDs(itemID);
|
int[] commID = getAllCommunityIDs(itemID);
|
||||||
|
|
||||||
|
// Remove (set to -1) any duplicate communities
|
||||||
for (int i = 0; i < commID.length; i++)
|
for (int i = 0; i < commID.length; i++)
|
||||||
{
|
{
|
||||||
if (isFirstOccurrence(commID, i))
|
if (!isFirstOccurrence(commID, i))
|
||||||
|
commID[i] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find all existing mappings for this item
|
||||||
|
TableRowIterator tri = DatabaseManager.queryTable(context, "Communities2Item", "SELECT * FROM Communities2Item WHERE item_id=?", itemID);
|
||||||
|
if (tri != null)
|
||||||
|
{
|
||||||
|
while (tri.hasNext())
|
||||||
|
{
|
||||||
|
TableRow tr = tri.next();
|
||||||
|
|
||||||
|
// Check the item mappings to see if it contains this community mapping
|
||||||
|
boolean itemIsMapped = false;
|
||||||
|
int trCommID = tr.getIntColumn("community_id");
|
||||||
|
for (int i = 0; i < commID.length; i++)
|
||||||
|
{
|
||||||
|
// Found this community
|
||||||
|
if (commID[i] == trCommID)
|
||||||
|
{
|
||||||
|
// Flag it, and remove (-1) from the item mappings
|
||||||
|
itemIsMapped = true;
|
||||||
|
commID[i] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The item is no longer mapped to this community, so remove the database record
|
||||||
|
if (!itemIsMapped)
|
||||||
|
DatabaseManager.delete(context, tr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Any remaining mappings need to be added to the database
|
||||||
|
for (int i = 0; i < commID.length; i++)
|
||||||
|
{
|
||||||
|
if (commID[i] > -1)
|
||||||
{
|
{
|
||||||
TableRow row = DatabaseManager.create(context, "Communities2Item");
|
TableRow row = DatabaseManager.create(context, "Communities2Item");
|
||||||
row.setColumn("item_id", itemID);
|
row.setColumn("item_id", itemID);
|
||||||
|
@@ -720,13 +720,20 @@ public class BrowseEngine
|
|||||||
// to do comparisons in other columns. The use of the focus value needs to be consistent
|
// to do comparisons in other columns. The use of the focus value needs to be consistent
|
||||||
// across the browse
|
// across the browse
|
||||||
SortOption so = scope.getSortOption();
|
SortOption so = scope.getSortOption();
|
||||||
String col = "sort_value";
|
if (so == null || so.getNumber() == 0)
|
||||||
|
{
|
||||||
|
if (browseIndex.getSortOption() != null)
|
||||||
|
so = browseIndex.getSortOption();
|
||||||
|
}
|
||||||
|
|
||||||
|
String col = "sort_1";
|
||||||
if (so.getNumber() > 0)
|
if (so.getNumber() > 0)
|
||||||
{
|
{
|
||||||
col = "sort_" + Integer.toString(so.getNumber());
|
col = "sort_" + Integer.toString(so.getNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
// now get the DAO to do the query for us, returning the highest
|
|
||||||
|
// now get the DAO to do the query for us, returning the highest
|
||||||
// string value in the given column in the given table for the
|
// string value in the given column in the given table for the
|
||||||
// item (I think)
|
// item (I think)
|
||||||
String max = dao.doMaxQuery(col, tableName, id);
|
String max = dao.doMaxQuery(col, tableName, id);
|
||||||
|
@@ -78,7 +78,7 @@ public class BrowserScope
|
|||||||
private String filterValueLang;
|
private String filterValueLang;
|
||||||
|
|
||||||
/** the item id focus of the browse */
|
/** the item id focus of the browse */
|
||||||
private int jumpItemId;
|
private int jumpItemId = -1;
|
||||||
|
|
||||||
/** the string value to start with */
|
/** the string value to start with */
|
||||||
private String startsWith;
|
private String startsWith;
|
||||||
|
@@ -362,9 +362,7 @@ public class IndexBrowse
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Delete community mappings - we'll add them again if necessary
|
boolean reqCommunityMappings = false;
|
||||||
dao.deleteCommunityMappings(item.getID());
|
|
||||||
|
|
||||||
Map<Integer, String> sortMap = getSortValues(item, itemMDMap);
|
Map<Integer, String> sortMap = getSortValues(item, itemMDMap);
|
||||||
if (item.isArchived() && !item.isWithdrawn())
|
if (item.isArchived() && !item.isWithdrawn())
|
||||||
{
|
{
|
||||||
@@ -376,7 +374,8 @@ public class IndexBrowse
|
|||||||
removeIndex(item.getID(), BrowseIndex.getWithdrawnBrowseIndex().getTableName());
|
removeIndex(item.getID(), BrowseIndex.getWithdrawnBrowseIndex().getTableName());
|
||||||
dao.insertIndex(BrowseIndex.getItemBrowseIndex().getTableName(), item.getID(), sortMap);
|
dao.insertIndex(BrowseIndex.getItemBrowseIndex().getTableName(), item.getID(), sortMap);
|
||||||
}
|
}
|
||||||
dao.insertCommunityMappings(item.getID());
|
|
||||||
|
reqCommunityMappings = true;
|
||||||
}
|
}
|
||||||
else if (item.isWithdrawn())
|
else if (item.isWithdrawn())
|
||||||
{
|
{
|
||||||
@@ -395,7 +394,17 @@ public class IndexBrowse
|
|||||||
removeIndex(item.getID(), BrowseIndex.getItemBrowseIndex().getTableName());
|
removeIndex(item.getID(), BrowseIndex.getItemBrowseIndex().getTableName());
|
||||||
removeIndex(item.getID(), BrowseIndex.getWithdrawnBrowseIndex().getTableName());
|
removeIndex(item.getID(), BrowseIndex.getWithdrawnBrowseIndex().getTableName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the community mappings if they are required, or remove them if they aren't
|
||||||
|
if (reqCommunityMappings)
|
||||||
|
{
|
||||||
|
dao.updateCommunityMappings(item.getID());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dao.deleteCommunityMappings(item.getID());
|
||||||
|
}
|
||||||
|
|
||||||
// Now update the metadata indexes
|
// Now update the metadata indexes
|
||||||
for (int i = 0; i < bis.length; i++)
|
for (int i = 0; i < bis.length; i++)
|
||||||
{
|
{
|
||||||
|
@@ -372,7 +372,6 @@ public class ItemMapServlet extends DSpaceServlet
|
|||||||
bs.setFilterValuePartial(true);
|
bs.setFilterValuePartial(true);
|
||||||
bs.setJumpToValue(null);
|
bs.setJumpToValue(null);
|
||||||
bs.setResultsPerPage(10000); // an arbitrary number (large) for the time being
|
bs.setResultsPerPage(10000); // an arbitrary number (large) for the time being
|
||||||
bs.setSortBy(0);
|
|
||||||
bs.setBrowseLevel(1);
|
bs.setBrowseLevel(1);
|
||||||
|
|
||||||
BrowseEngine be = new BrowseEngine(context);
|
BrowseEngine be = new BrowseEngine(context);
|
||||||
|
Reference in New Issue
Block a user