org.mycore.frontend.redundancy
Class MCRRedundancyAbstractMapGenerator

java.lang.Object
  extended by org.mycore.frontend.redundancy.MCRRedundancyAbstractMapGenerator
Direct Known Subclasses:
MCRRedundancyDefaultMapGenerator, MCRRedundancyFastMapGenerator

public abstract class MCRRedundancyAbstractMapGenerator
extends Object

Abstract class for creating a redundancy map.

Author:
Matthias Eichner

Nested Class Summary
protected  class MCRRedundancyAbstractMapGenerator.DefaultCompareStringFormatter
           
protected  class MCRRedundancyAbstractMapGenerator.DefaultStringComparator
           
 
Field Summary
protected  Comparator<String> comparator
           
protected  MCRRedundancyFormattable<String> compareStringFormatter
           
protected  Element redundancyMap
           
protected  MCRRedundancyTypeData typeData
           
 
Constructor Summary
MCRRedundancyAbstractMapGenerator()
           
 
Method Summary
protected  boolean areConditionsEquals(Map<String,String> conditionMap1, Map<String,String> conditionMap2)
          Compares a condition map with another condition map.
protected  boolean areRedundancyObjectsEqual(MCRRedundancyObject obj1, MCRRedundancyObject obj2)
          Checks if the redundancy objects are equal.
protected  MCRCondition createCondition()
          Creates the search condition.
protected  Element createGroupElement(int id, Map<String,String> compareCriterias)
          Creates a group as element.
protected  Element createObjectElement(String id)
          Creates a single redundancy object element.
abstract  void createRedundancyMap()
          Main method to create the redundancy map.
 Comparator<String> getComparator()
           
protected  Map<String,String> getCompareCriteria(MCRHit mcrHit)
          Returns the compare criterias of a search hit.
protected  String getFileName()
           
 MCRRedundancyFormattable<String> getStringFormatter()
           
 void saveToFile()
          Saves the redundancy map to the file system.
 void setComparator(Comparator<String> comparator)
           
 void setStringFormatter(MCRRedundancyFormattable<String> stringFormatter)
           
 void setTypeData(MCRRedundancyTypeData typeData)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

typeData

protected MCRRedundancyTypeData typeData

redundancyMap

protected Element redundancyMap

comparator

protected Comparator<String> comparator

compareStringFormatter

protected MCRRedundancyFormattable<String> compareStringFormatter
Constructor Detail

MCRRedundancyAbstractMapGenerator

public MCRRedundancyAbstractMapGenerator()
Method Detail

setTypeData

public void setTypeData(MCRRedundancyTypeData typeData)

getFileName

protected String getFileName()

createCondition

protected MCRCondition createCondition()
Creates the search condition.

Returns:
a new search condition

getCompareCriteria

protected Map<String,String> getCompareCriteria(MCRHit mcrHit)
Returns the compare criterias of a search hit. The return map is a combination of fieldsToCompare and xpathToCompare.

Parameters:
mcrHit - the search hit
Returns:
a new compare criteria for an MyCoRe Object

areRedundancyObjectsEqual

protected boolean areRedundancyObjectsEqual(MCRRedundancyObject obj1,
                                            MCRRedundancyObject obj2)
Checks if the redundancy objects are equal.

Parameters:
obj1 - the first redundancy object
obj2 - the second redundancy object
Returns:
if they are equal

areConditionsEquals

protected boolean areConditionsEquals(Map<String,String> conditionMap1,
                                      Map<String,String> conditionMap2)
Compares a condition map with another condition map. Each key/value pair of the first condition map has to be equal to the second one.

Returns:
If the condition maps are equal.

setComparator

public void setComparator(Comparator<String> comparator)

getComparator

public Comparator<String> getComparator()

setStringFormatter

public void setStringFormatter(MCRRedundancyFormattable<String> stringFormatter)

getStringFormatter

public MCRRedundancyFormattable<String> getStringFormatter()

createRedundancyMap

public abstract void createRedundancyMap()
Main method to create the redundancy map.


saveToFile

public void saveToFile()
                throws FileNotFoundException,
                       IOException
Saves the redundancy map to the file system.

Throws:
FileNotFoundException
IOException

createGroupElement

protected Element createGroupElement(int id,
                                     Map<String,String> compareCriterias)
Creates a group as element. A group contains redundancy objects elements as childs.

Parameters:
id - the id of the group. its a increasing integer number.
name - the name of the group
Returns:
a new group element

createObjectElement

protected Element createObjectElement(String id)
Creates a single redundancy object element.

Parameters:
id - the id of the mcr object
Returns:
a new object element.