mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-14 13:33:08 +00:00
[DS-707] Generify Map usage
git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5592 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -224,7 +224,7 @@ public class ItemComparator implements Comparator
|
|||||||
|
|
||||||
// We want to sort using Strings, but also keep track of
|
// We want to sort using Strings, but also keep track of
|
||||||
// which DCValue the value came from.
|
// which DCValue the value came from.
|
||||||
Map values = new HashMap();
|
Map<String, Integer> values = new HashMap<String, Integer>();
|
||||||
|
|
||||||
for (int i = 0; i < dcvalues.length; i++)
|
for (int i = 0; i < dcvalues.length; i++)
|
||||||
{
|
{
|
||||||
@@ -241,11 +241,11 @@ public class ItemComparator implements Comparator
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set valueSet = values.keySet();
|
Set<String> valueSet = values.keySet();
|
||||||
String chosen = max ? (String) Collections.max(valueSet)
|
String chosen = max ? Collections.max(valueSet)
|
||||||
: (String) Collections.min(valueSet);
|
: Collections.min(valueSet);
|
||||||
|
|
||||||
int index = ((Integer) values.get(chosen)).intValue();
|
int index = (values.get(chosen)).intValue();
|
||||||
|
|
||||||
return normalizeTitle(dcvalues[index]);
|
return normalizeTitle(dcvalues[index]);
|
||||||
}
|
}
|
||||||
|
@@ -81,7 +81,7 @@ public class MetadataField
|
|||||||
private TableRow row;
|
private TableRow row;
|
||||||
|
|
||||||
// cache of field by ID (Integer)
|
// cache of field by ID (Integer)
|
||||||
private static Map id2field = null;
|
private static Map<Integer, MetadataField> id2field = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -356,7 +356,7 @@ public class MetadataField
|
|||||||
*/
|
*/
|
||||||
public static MetadataField[] findAll(Context context) throws SQLException
|
public static MetadataField[] findAll(Context context) throws SQLException
|
||||||
{
|
{
|
||||||
List fields = new ArrayList();
|
List<MetadataField> fields = new ArrayList<MetadataField>();
|
||||||
|
|
||||||
// Get all the metadatafieldregistry rows
|
// Get all the metadatafieldregistry rows
|
||||||
TableRowIterator tri = DatabaseManager.queryTable(context, "MetadataFieldRegistry",
|
TableRowIterator tri = DatabaseManager.queryTable(context, "MetadataFieldRegistry",
|
||||||
@@ -395,7 +395,7 @@ public class MetadataField
|
|||||||
public static MetadataField[] findAllInSchema(Context context, int schemaID)
|
public static MetadataField[] findAllInSchema(Context context, int schemaID)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
List fields = new ArrayList();
|
List<MetadataField> fields = new ArrayList<MetadataField>();
|
||||||
|
|
||||||
// Get all the metadatafieldregistry rows
|
// Get all the metadatafieldregistry rows
|
||||||
TableRowIterator tri = DatabaseManager.queryTable(context,"MetadataFieldRegistry",
|
TableRowIterator tri = DatabaseManager.queryTable(context,"MetadataFieldRegistry",
|
||||||
@@ -639,7 +639,7 @@ public class MetadataField
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (MetadataField) id2field.get(iid);
|
return id2field.get(iid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// invalidate the cache e.g. after something modifies DB state.
|
// invalidate the cache e.g. after something modifies DB state.
|
||||||
@@ -658,7 +658,7 @@ public class MetadataField
|
|||||||
{
|
{
|
||||||
if (!isCacheInitialized())
|
if (!isCacheInitialized())
|
||||||
{
|
{
|
||||||
HashMap new_id2field = new HashMap();
|
Map<Integer, MetadataField> new_id2field = new HashMap<Integer, MetadataField>();
|
||||||
log.info("Loading MetadataField elements into cache.");
|
log.info("Loading MetadataField elements into cache.");
|
||||||
|
|
||||||
// Grab rows from DB
|
// Grab rows from DB
|
||||||
|
@@ -87,10 +87,10 @@ public class MetadataSchema
|
|||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
// cache of schema by ID (Integer)
|
// cache of schema by ID (Integer)
|
||||||
private static Map id2schema = null;
|
private static Map<Integer, MetadataSchema> id2schema = null;
|
||||||
|
|
||||||
// cache of schema by short name
|
// cache of schema by short name
|
||||||
private static Map name2schema = null;
|
private static Map<String, MetadataSchema> name2schema = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -395,7 +395,7 @@ public class MetadataSchema
|
|||||||
*/
|
*/
|
||||||
public static MetadataSchema[] findAll(Context context) throws SQLException
|
public static MetadataSchema[] findAll(Context context) throws SQLException
|
||||||
{
|
{
|
||||||
List schemas = new ArrayList();
|
List<MetadataSchema> schemas = new ArrayList<MetadataSchema>();
|
||||||
|
|
||||||
// Get all the metadataschema rows
|
// Get all the metadataschema rows
|
||||||
TableRowIterator tri = DatabaseManager.queryTable(context, "MetadataSchemaRegistry",
|
TableRowIterator tri = DatabaseManager.queryTable(context, "MetadataSchemaRegistry",
|
||||||
@@ -553,7 +553,7 @@ public class MetadataSchema
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (MetadataSchema) id2schema.get(iid);
|
return id2schema.get(iid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -585,7 +585,7 @@ public class MetadataSchema
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (MetadataSchema) name2schema.get(shortName);
|
return name2schema.get(shortName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// invalidate the cache e.g. after something modifies DB state.
|
// invalidate the cache e.g. after something modifies DB state.
|
||||||
@@ -606,8 +606,8 @@ public class MetadataSchema
|
|||||||
if (!isCacheInitialized())
|
if (!isCacheInitialized())
|
||||||
{
|
{
|
||||||
log.info("Loading schema cache for fast finds");
|
log.info("Loading schema cache for fast finds");
|
||||||
HashMap new_id2schema = new HashMap();
|
Map<Integer, MetadataSchema> new_id2schema = new HashMap<Integer, MetadataSchema>();
|
||||||
HashMap new_name2schema = new HashMap();
|
Map<String, MetadataSchema> new_name2schema = new HashMap<String, MetadataSchema>();
|
||||||
|
|
||||||
TableRowIterator tri = DatabaseManager.queryTable(context,"MetadataSchemaRegistry",
|
TableRowIterator tri = DatabaseManager.queryTable(context,"MetadataSchemaRegistry",
|
||||||
"SELECT * from MetadataSchemaRegistry");
|
"SELECT * from MetadataSchemaRegistry");
|
||||||
|
Reference in New Issue
Block a user