org.mycore.frontend.redundancy.cli
Class MCRRedundancyCleanUpCommand

java.lang.Object
  extended by org.mycore.frontend.redundancy.cli.MCRRedundancyCleanUpCommand

public class MCRRedundancyCleanUpCommand
extends Object

Processes a redundancy xml-file to relink and delete duplicate mcr objects in the database.
Commandprocess:
(cleanUp [(process redundancy object[(replace links)* -> (delete mcrobject) -> (delete redundancy object xml entry)])*] -> [update xml document])

Author:
Matthias Eichner

Nested Class Summary
protected static class MCRRedundancyCleanUpCommand.AttributeValueFilter
          A jdom-filter which compares attribute values.
 
Constructor Summary
MCRRedundancyCleanUpCommand()
           
 
Method Summary
static List<String> cleanUp(String type)
          The start method.
static void deleteRedundancyElementEntry(String id)
          Deletes an processed redundancy element entry in the xml document.
protected static Element getRedunElementOfId(String id)
          Returns an redundancy object by the specified id.
protected static boolean isElementAlreadyExists(Element element)
          Checks if the element is equal to an element from the same parent.
static List<String> processRedundancyObject(String id)
          Creates the commands of an redundancy Object.
static void replaceLinks(String sourceId, String oldLink, String newLink)
          Replaces all links which are found in the source mcrobject xml-tree.
static void updateXMLDocument(String fileName)
          Updates the specified file with the static document xml-structure.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MCRRedundancyCleanUpCommand

public MCRRedundancyCleanUpCommand()
Method Detail

cleanUp

public static List<String> cleanUp(String type)
                            throws Exception
The start method.

Parameters:
type - The type.
Returns:
A commandlist of redundancy objects which have to processed.
Throws:
Exception

processRedundancyObject

public static List<String> processRedundancyObject(String id)
                                            throws Exception
Creates the commands of an redundancy Object.

Parameters:
id - The id of the redundancyObjects element.
Returns:
A list of commands.
Throws:
Exception

deleteRedundancyElementEntry

public static void deleteRedundancyElementEntry(String id)
Deletes an processed redundancy element entry in the xml document.

Parameters:
id - The id of the element.

getRedunElementOfId

protected static Element getRedunElementOfId(String id)
Returns an redundancy object by the specified id.

Parameters:
id - The id.
Returns:
The element or null.

replaceLinks

public static void replaceLinks(String sourceId,
                                String oldLink,
                                String newLink)
                         throws Exception
Replaces all links which are found in the source mcrobject xml-tree.

Parameters:
source - The source Id as String.
oldLink - The link which to replaced.
newLink - The new link.
Throws:
Exception

isElementAlreadyExists

protected static boolean isElementAlreadyExists(Element element)
Checks if the element is equal to an element from the same parent.

Parameters:
element - The element to check.
Returns:
If the element in the parent already exists.

updateXMLDocument

public static void updateXMLDocument(String fileName)
                              throws Exception
Updates the specified file with the static document xml-structure.

Parameters:
fileName -
Throws:
Exception