org.mycore.frontend.cli
Class MCRObjectCommands

java.lang.Object
  extended by org.mycore.frontend.cli.MCRAbstractCommands
      extended by org.mycore.frontend.cli.MCRObjectCommands
All Implemented Interfaces:
MCRExternalCommandInterface

public class MCRObjectCommands
extends MCRAbstractCommands

Provides static methods that implement commands for the MyCoRe command line interface.

Version:
$Revision: 15621 $ $Date: 2009-07-25 08:32:01 +0200 (Sat, 25 Jul 2009) $
Author:
Jens Kupferschmidt, Frank Luetzenkirchen

Field Summary
static String DEFAULT_TRANSFORMER
          Default transformer script
 
Fields inherited from class org.mycore.frontend.cli.MCRAbstractCommands
command, CONFIG
 
Constructor Summary
MCRObjectCommands()
          The empty constructor.
 
Method Summary
static void checkMetadataSearch(String type)
          Checks existence of MCRObjectID type {0} in search index and rapairs missing ones in search index.
static void checkSelected()
          The method checks the existence of selected MCRObjects in SQL store.
static boolean checkXMLFile(String fileName)
          The method parse and check an XML file.
static void delete(String ID)
          Delete a MCRObject from the datastore.
static List<String> deleteAllObjects(String type)
          Delete all MCRObject from the datastore for a given type.
static void deleteFromTo(String IDfrom, String IDto)
          Delete MCRObject's form ID to ID from the datastore.
static void deleteSelected()
          Delete all selected MCRObjects from the datastore.
static void export(String ID, String dirname, String style)
          Export an MCRObject to a file named MCRObjectID .xml in a directory.
static void export(String fromID, String toID, String dirname, String style)
          Save any MCRObject's to files named MCRObjectID .xml in a directory.
static List<String> exportAllObjects(String type, String dirname, String style)
          Save all MCRObject's to files named MCRObjectID .xml in a dirnamedirectory for the data type type.
static List<String> exportSelected(String dirname, String style)
           
static void getLastID(String base)
          Get the last used MCRObjectID for the given MCRObjectID base.
static void getNextID(String base)
          Get the next free MCRObjectID for the given MCRObjectID base.
static List<String> getSelectedObjectIDs()
           
static List<String> loadFromDirectory(String directory)
          Load MCRObject's from all XML files in a directory.
static boolean loadFromFile(String file)
          Load a MCRObjects from an XML file.
static boolean loadFromFile(String file, boolean importMode)
          Load a MCRObjects from an XML file.
static void notifySearcher(String mode, String index)
          Inform Searcher what is going on.
static void removeFromSearchindex(String index)
          The method removes all selected entries from search index.
static List<String> repairMetadataSearch(String type)
          The method start the repair of the metadata search for a given MCRObjectID type.
static void repairMetadataSearchForID(String id)
          The method start the repair of the metadata search for a given MCRObjectID as String.
static void selectObjectsWithQuery(String querystring)
          Builds a resulset with a query.
static void setSelectedObjectIDs(List<String> selected)
           
static void showLastID(String base)
          Shows the last used MCRObjectIDs.
static void showNextID(String base)
          Shows the next free MCRObjectIDs.
static List<String> updateFromDirectory(String directory)
          Update MCRObject's from all XML files in a directory.
static boolean updateFromFile(String file)
          Update a MCRObject's from an XML file.
static boolean updateFromFile(String file, boolean importMode)
          Update a MCRObject's from an XML file.
 
Methods inherited from class org.mycore.frontend.cli.MCRAbstractCommands
getPossibleCommands
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TRANSFORMER

public static final String DEFAULT_TRANSFORMER
Default transformer script

See Also:
Constant Field Values
Constructor Detail

MCRObjectCommands

public MCRObjectCommands()
The empty constructor.

Method Detail

setSelectedObjectIDs

public static void setSelectedObjectIDs(List<String> selected)

getSelectedObjectIDs

public static List<String> getSelectedObjectIDs()

deleteAllObjects

public static final List<String> deleteAllObjects(String type)
                                           throws MCRActiveLinkException
Delete all MCRObject from the datastore for a given type.

Parameters:
type - the type of the MCRObjects that should be deleted
Throws:
MCRActiveLinkException

delete

public static final void delete(String ID)
                         throws MCRActiveLinkException
Delete a MCRObject from the datastore.

Parameters:
ID - the ID of the MCRObject that should be deleted
Throws:
MCRActiveLinkException

deleteFromTo

public static final void deleteFromTo(String IDfrom,
                                      String IDto)
                               throws MCRActiveLinkException
Delete MCRObject's form ID to ID from the datastore.

Parameters:
IDfrom - the start ID for deleting the MCRObjects
IDto - the stop ID for deleting the MCRObjects
Throws:
MCRActiveLinkException

loadFromDirectory

public static final List<String> loadFromDirectory(String directory)
                                            throws MCRActiveLinkException
Load MCRObject's from all XML files in a directory.

Parameters:
directory - the directory containing the XML files
Throws:
MCRActiveLinkException

updateFromDirectory

public static final List<String> updateFromDirectory(String directory)
                                              throws MCRActiveLinkException
Update MCRObject's from all XML files in a directory.

Parameters:
directory - the directory containing the XML files
Throws:
MCRActiveLinkException

loadFromFile

public static final boolean loadFromFile(String file)
                                  throws MCRActiveLinkException
Load a MCRObjects from an XML file.

Parameters:
file - the location of the xml file
Throws:
MCRActiveLinkException

loadFromFile

public static final boolean loadFromFile(String file,
                                         boolean importMode)
                                  throws MCRActiveLinkException
Load a MCRObjects from an XML file.

Parameters:
file - the location of the xml file
importMode - if true, servdates are taken from xml file
Throws:
MCRActiveLinkException

updateFromFile

public static final boolean updateFromFile(String file)
                                    throws MCRActiveLinkException
Update a MCRObject's from an XML file.

Parameters:
file - the location of the xml file
Throws:
MCRActiveLinkException

updateFromFile

public static final boolean updateFromFile(String file,
                                           boolean importMode)
                                    throws MCRActiveLinkException
Update a MCRObject's from an XML file.

Parameters:
file - the location of the xml file
importMode - if true, servdates are taken from xml file
Throws:
MCRActiveLinkException

showNextID

public static final void showNextID(String base)
Shows the next free MCRObjectIDs.

Parameters:
base - the base String of the MCRObjectID

showLastID

public static final void showLastID(String base)
Shows the last used MCRObjectIDs.

Parameters:
base - the base String of the MCRObjectID

export

public static final void export(String ID,
                                String dirname,
                                String style)
Export an MCRObject to a file named MCRObjectID .xml in a directory. The method use the converter stylesheet mcr_style_object.xsl.

Parameters:
ID - the ID of the MCRObject to be save.
dirname - the dirname to store the object
style - the type of the stylesheet

export

public static final void export(String fromID,
                                String toID,
                                String dirname,
                                String style)
Save any MCRObject's to files named MCRObjectID .xml in a directory. The saving starts with fromID and runs to toID. ID's they was not found will skiped. The method use the converter stylesheet mcr_style_object.xsl.

Parameters:
fromID - the ID of the MCRObject from be save.
toID - the ID of the MCRObject to be save.
dirname - the filename to store the object
style - the type of the stylesheet

exportAllObjects

public static final List<String> exportAllObjects(String type,
                                                  String dirname,
                                                  String style)
Save all MCRObject's to files named MCRObjectID .xml in a dirnamedirectory for the data type type. The method use the converter stylesheet mcr_style_object.xsl.

Parameters:
fromID - the ID of the MCRObject from be save.
toID - the ID of the MCRObject to be save.
dirname - the filename to store the object
style - the type of the stylesheet

getNextID

public static final void getNextID(String base)
Get the next free MCRObjectID for the given MCRObjectID base.

Parameters:
base - the MCRObjectID base string

getLastID

public static final void getLastID(String base)
Get the last used MCRObjectID for the given MCRObjectID base.

Parameters:
base - the MCRObjectID base string

checkXMLFile

public static final boolean checkXMLFile(String fileName)
The method parse and check an XML file.

Parameters:
fileName - the location of the xml file

repairMetadataSearch

public static final List<String> repairMetadataSearch(String type)
The method start the repair of the metadata search for a given MCRObjectID type.

Parameters:
type - the MCRObjectID type

repairMetadataSearchForID

public static final void repairMetadataSearchForID(String id)
The method start the repair of the metadata search for a given MCRObjectID as String.

Parameters:
id - the MCRObjectID as String

selectObjectsWithQuery

public static final void selectObjectsWithQuery(String querystring)
Builds a resulset with a query. Used in later command to do work with.

Parameters:
querystring - MCRQuery as String

deleteSelected

public static final void deleteSelected()
                                 throws MCRActiveLinkException
Delete all selected MCRObjects from the datastore.

Throws:
MCRActiveLinkException

exportSelected

public static final List<String> exportSelected(String dirname,
                                                String style)

removeFromSearchindex

public static final void removeFromSearchindex(String index)
The method removes all selected entries from search index.

Parameters:
index - index of searcher

checkSelected

public static final void checkSelected()
The method checks the existence of selected MCRObjects in SQL store.


checkMetadataSearch

public static final void checkMetadataSearch(String type)
Checks existence of MCRObjectID type {0} in search index and rapairs missing ones in search index.

Parameters:
type - the MCRObjectID type

notifySearcher

public static final void notifySearcher(String mode,
                                        String index)
Inform Searcher what is going on.

Parameters:
mode - what is going on, for example rebuild insert ... finish
index - of searcher