// -- build a map of collection code versus repository name for
// -- assigning the categories
Map <String,String> codes = new HashMap<String,String>();
Map <String,String> catCodes = new HashMap<String,String>();
final MetadataCategoryRepository categoryRepository = this.context.getBean(MetadataCategoryRepository.class);
// -- add new category for each repository
boolean addcateg = false;
for (String repo : params.getRepositories()) {
Element repoElem = Xml.selectElement(repositories, "record[id='"+repo+"']");
if (repoElem != null) {
Element repoId = repoElem.getChild("id");
String repoName = repoElem.getChildText("name");
codes.put(repoId.getAttributeValue("serverCode")+":"+repoId.getAttributeValue("code"), repoName);
// create a result holder for this repository
serverResults.getServerResult(repoName);
// sanitize the name of the category
String categName = repoName.replaceAll("[^\\w]","");
categName = categName.toLowerCase();
catCodes.put(repoId.getAttributeValue("serverCode")+":"+repoId.getAttributeValue("code"), categName);
if (categoryRepository.findOneByNameIgnoreCase(categName) == null) {
MetadataCategory category = new MetadataCategory();
category.setName(categName);
categoryRepository.save(category);
addcateg = true;
}
}
}
if (addcateg) {
categoryRepository.flush();
}
// --- return only maximum hits as directed by the harvest params
int nrGroups = (numberOfHits / groupSize) + 1;
for (int i = 1; i <= nrGroups; i++) {