[DS-707] Generify Map usage

git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5615 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Graham Triggs
2010-10-24 20:41:34 +00:00
parent 4e808b6dac
commit 9fd9b94e26
7 changed files with 18 additions and 32 deletions

View File

@@ -40,7 +40,8 @@ import java.io.FileWriter;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -96,10 +97,10 @@ public class StructBuilder
private static org.jdom.Document xmlOutput = new org.jdom.Document(new Element("imported_structure"));
/** a hashtable to hold metadata for the collection being worked on */
private static Hashtable collectionMap = new Hashtable();
private static Map<String, String> collectionMap = new HashMap<String, String>();
/** a hashtable to hold metadata for the community being worked on */
private static Hashtable communityMap = new Hashtable();
private static Map<String, String> communityMap = new HashMap<String, String>();
/**
* Main method to be run from the command line to import a structure into
@@ -429,16 +430,12 @@ public class StructBuilder
// now update the metadata
Node tn = communities.item(i);
Enumeration keys = communityMap.keys();
while (keys.hasMoreElements())
for (Map.Entry<String, String> entry : communityMap.entrySet())
{
Node node = null;
String key = (String) keys.nextElement();
NodeList nl = XPathAPI.selectNodeList(tn, key);
NodeList nl = XPathAPI.selectNodeList(tn, entry.getKey());
if (nl.getLength() == 1)
{
node = nl.item(0);
community.setMetadata((String) communityMap.get(key), getStringValue(node));
community.setMetadata(entry.getValue(), getStringValue(nl.item(0)));
}
}
@@ -544,16 +541,12 @@ public class StructBuilder
// import the rest of the metadata
Node tn = collections.item(i);
Enumeration keys = collectionMap.keys();
while (keys.hasMoreElements())
for (Map.Entry<String, String> entry : collectionMap.entrySet())
{
Node node = null;
String key = (String) keys.nextElement();
NodeList nl = XPathAPI.selectNodeList(tn, key);
NodeList nl = XPathAPI.selectNodeList(tn, entry.getKey());
if (nl.getLength() == 1)
{
node = nl.item(0);
collection.setMetadata((String) collectionMap.get(key), getStringValue(node));
collection.setMetadata(entry.getValue(), getStringValue(nl.item(0)));
}
}

View File

@@ -691,14 +691,14 @@ public class ItemImport
System.out.println("Deleting items listed in mapfile: " + mapFile);
// read in the mapfile
Map myhash = readMapFile(mapFile);
Map<String, String> myhash = readMapFile(mapFile);
// now delete everything that appeared in the mapFile
Iterator i = myhash.keySet().iterator();
while (i.hasNext())
{
String itemID = (String) myhash.get(i.next());
String itemID = myhash.get(i.next());
if (itemID.indexOf('/') != -1)
{

View File

@@ -107,12 +107,6 @@ public class DCInputsReader
*/
private Map<String, List<List<Map<String, String>>>> formDefns = null;
/**
* Reference to the forms which allow, disallow or mandate files to be
* uploaded.
*/
private Map formFileUploadDefns = null;
/**
* Reference to the value-pairs map, computed from the forms definition file
*/

View File

@@ -100,7 +100,7 @@ public class SubmissionConfig implements Serializable
// loop through our steps, and create SubmissionStepConfig objects
for (int stepNum = 0; stepNum < steps.size(); stepNum++)
{
Map stepInfo = steps.get(stepNum);
Map<String, String> stepInfo = steps.get(stepNum);
SubmissionStepConfig step = new SubmissionStepConfig(stepInfo);
// Only add this step to the process if either:

View File

@@ -81,7 +81,7 @@ public class StatisticsLoggingConsumer implements Consumer
updateQuery, null, null);
// Get all the metadata
Map metadataStorageInfo = SolrLogger.getMetadataStorageInfo();
Map<String, String> metadataStorageInfo = SolrLogger.getMetadataStorageInfo();
List<String> storageFieldList = new ArrayList<String>();
List<List<Object>> storageValuesList = new ArrayList<List<Object>>();

View File

@@ -199,7 +199,7 @@ public class StatisticsDataGenerator {
solr.deleteByQuery("*:*");
solr.commit();
Map metadataStorageInfo = SolrLogger.getMetadataStorageInfo();
Map<String, String> metadataStorageInfo = SolrLogger.getMetadataStorageInfo();
String prevIp = null;
String dbfile = ConfigurationManager.getProperty("solr.dbfile");

View File

@@ -76,7 +76,7 @@ public class StatisticsImporter
private static LookupService geoipLookup;
/** Metadata storage information */
private static Map metadataStorageInfo;
private static Map<String, String> metadataStorageInfo;
/** Whether to skip the DNS reverse lookup or not */
private static boolean skipReverseDNS = false;
@@ -362,9 +362,8 @@ public class StatisticsImporter
if (dso instanceof Item) {
Item item = (Item) dso;
// Store the metadata
for (Object storedField : metadataStorageInfo.keySet()) {
String dcField = (String) metadataStorageInfo
.get(storedField);
for (String storedField : metadataStorageInfo.keySet()) {
String dcField = metadataStorageInfo.get(storedField);
DCValue[] vals = item.getMetadata(dcField.split("\\.")[0],
dcField.split("\\.")[1], dcField.split("\\.")[2],