mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
[DS-732] Refactor pruning distinct ids to allow for arbitrary number of distinct ids to be pruned
git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5707 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
*/
|
||||
package org.dspace.browse;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -842,21 +843,25 @@ public class BrowseCreateDAOOracle implements BrowseCreateDAO
|
||||
|
||||
if (distinctIds != null && distinctIds.size() > 0)
|
||||
{
|
||||
query.append(" AND ").append(table).append(".id IN (");
|
||||
for (int i = 0; i < distinctIds.size(); i++)
|
||||
query.append(" AND ").append(table).append(".id=?");
|
||||
PreparedStatement stmt = null;
|
||||
try
|
||||
{
|
||||
if (i > 0)
|
||||
stmt = context.getDBConnection().prepareStatement(query.toString());
|
||||
for (Integer distinctId : distinctIds)
|
||||
{
|
||||
query.append(", ?");
|
||||
}
|
||||
else
|
||||
{
|
||||
query.append("?");
|
||||
stmt.setInt(1, distinctId);
|
||||
stmt.execute();
|
||||
stmt.clearParameters();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (stmt != null)
|
||||
{
|
||||
stmt.close();
|
||||
}
|
||||
}
|
||||
query.append(")");
|
||||
|
||||
DatabaseManager.updateQuery(context, query.toString(), distinctIds.toArray(new Integer[distinctIds.size()]));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -37,6 +37,7 @@
|
||||
*/
|
||||
package org.dspace.browse;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -844,21 +845,25 @@ public class BrowseCreateDAOPostgres implements BrowseCreateDAO
|
||||
|
||||
if (distinctIds != null && distinctIds.size() > 0)
|
||||
{
|
||||
query.append(" AND ").append(table).append(".id IN (");
|
||||
for (int i = 0; i < distinctIds.size(); i++)
|
||||
query.append(" AND ").append(table).append(".id=?");
|
||||
PreparedStatement stmt = null;
|
||||
try
|
||||
{
|
||||
if (i > 0)
|
||||
stmt = context.getDBConnection().prepareStatement(query.toString());
|
||||
for (Integer distinctId : distinctIds)
|
||||
{
|
||||
query.append(", ?");
|
||||
}
|
||||
else
|
||||
{
|
||||
query.append("?");
|
||||
stmt.setInt(1, distinctId);
|
||||
stmt.execute();
|
||||
stmt.clearParameters();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (stmt != null)
|
||||
{
|
||||
stmt.close();
|
||||
}
|
||||
}
|
||||
query.append(")");
|
||||
|
||||
DatabaseManager.updateQuery(context, query.toString(), distinctIds.toArray(new Integer[distinctIds.size()]));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -34,6 +34,7 @@
|
||||
|
||||
package org.dspace.browse;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -965,21 +966,25 @@ public class MockBrowseCreateDAOOracle
|
||||
|
||||
if (distinctIds != null && distinctIds.size() > 0)
|
||||
{
|
||||
query.append(" AND ").append(table).append(".id IN (");
|
||||
for (int i = 0; i < distinctIds.size(); i++)
|
||||
query.append(" AND ").append(table).append(".id=?");
|
||||
PreparedStatement stmt = null;
|
||||
try
|
||||
{
|
||||
if (i > 0)
|
||||
stmt = internalContext.getDBConnection().prepareStatement(query.toString());
|
||||
for (Integer distinctId : distinctIds)
|
||||
{
|
||||
query.append(", ?");
|
||||
}
|
||||
else
|
||||
{
|
||||
query.append("?");
|
||||
stmt.setInt(1, distinctId);
|
||||
stmt.execute();
|
||||
stmt.clearParameters();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (stmt != null)
|
||||
{
|
||||
stmt.close();
|
||||
}
|
||||
}
|
||||
query.append(")");
|
||||
|
||||
DatabaseManager.updateQuery(internalContext, query.toString(), distinctIds.toArray(new Integer[distinctIds.size()]));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user