com.googlecode.sarasvati.load
Interface GraphLoader<G extends Graph>

All Known Implementing Classes:
AbstractGraphLoader, GraphLoaderImpl

public interface GraphLoader<G extends Graph>

Interface for loading process definitions into a GraphRepository. Should not be considered thread-safe.

Author:
Paul Lorenz

Method Summary
 boolean isLoaded(String name)
          Returns true if the graph has been loaded into the associated GraphRepository, false otherwise.
 void load(File file)
          Loads the given XML process definition file.
 void loadDefinition(ProcessDefinition procDef)
          Loads the given process definition.
 void loadDefinition(ProcessDefinition procDef, String customId)
          Loads the given process definition, giving it the passed in custom identifier.
<T> void
loadDefinition(ProcessDefinitionTranslator<T> translator, T source)
          Takes a ProcessDefinitionTranslator, applies it to the given source and loads the resulting ProcessDefinition.
<T> void
loadDefinition(ProcessDefinitionTranslator<T> translator, T source, String customId)
          Takes a ProcessDefinitionTranslator, applies it to the given source and loads the resulting ProcessDefinition.
 List<LoadResult> loadNewAndChanged(File baseDir)
          Loads all new and changed process definitions under the given base directory.
 List<LoadResult> loadNewAndChanged(File baseDir, FilenameFilter filter)
          Loads all new and changed process definitions under the given base directory that match the given file name filter.
 List<LoadResult> loadWithDependencies(String name, ProcessDefinitionResolver resolver)
          Loads the named process definition.
 

Method Detail

loadDefinition

void loadDefinition(ProcessDefinition procDef)
                    throws SarasvatiLoadException
Loads the given process definition.

Equivalent to loadDefinition( procDef, null )

Throws:
SarasvatiLoadException
See Also:
loadDefinition(ProcessDefinition, String)

loadDefinition

void loadDefinition(ProcessDefinition procDef,
                    String customId)
                    throws SarasvatiLoadException
Loads the given process definition, giving it the passed in custom identifier.

Parameters:
procDef - The process definition to load
customId - The custom identifier to give the loaded process definition
Throws:
SarasvatiLoadException - Thrown if an error occurs during load, or the loader has a validator which throws an exception.

isLoaded

boolean isLoaded(String name)
Returns true if the graph has been loaded into the associated GraphRepository, false otherwise.

Parameters:
name - The name of the graph being searched for
Returns:
true if the graph has been loaded into the associated GraphRepository, false otherwise.

loadNewAndChanged

List<LoadResult> loadNewAndChanged(File baseDir)
                                   throws SarasvatiLoadException
Loads all new and changed process definitions under the given base directory. Uses the default file name filter, which matches all files with the .wf.xml extension.

Equivalent to loadNewAndChanged( baseDir, null );

Throws:
SarasvatiLoadException
See Also:
loadNewAndChanged(File, FilenameFilter)

loadNewAndChanged

List<LoadResult> loadNewAndChanged(File baseDir,
                                   FilenameFilter filter)
                                   throws SarasvatiLoadException
Loads all new and changed process definitions under the given base directory that match the given file name filter.

This method works as follows:

  1. It finds and parse all process definitions under the given base directory that match the given filename filter.
  2. A SHA-1 hash is calculated for each process definition. This hash is based on the sorted contents of the process definition. Changes in the ordering of the file and changes to whitespace outside of elements containing text will not result in a hash change.
  3. The process definitions are sorted by dependency, that for any given process definition, its dependencies will be inspected first.
  4. The sorted set of process definitions will be inspected.
    • If a process definition is new, i.e. it does not exist in the GraphRepository, it will be marked for load
    • If a process definition is updated, i.e. the SHA-1 hash does not match the value in Graph.getCustomId() for the new graph of the same name in the repository, it will be marked for load.
    • If a dependency (referenced external) of a process definition is marked for load, the process definition will also be marked for load.
  • All process definitions marked for load will then be loaded, in dependency order.
  • Parameters:
    baseDir - The directory under which to recursively search for process definitions
    filter - The filename filter to use to find process definition files. May be null, in which case the default filter is used. The default filter matches all files with the .wf.xml extension.
    Returns:
    The list of load results, which indicate which process definitions have been loaded and the reason why they were loaded (new, updated, dependency changed).
    Throws:
    SarasvatiLoadException - Thrown if an error occurs during the load or if the GraphValidator throws an exception.

    loadDefinition

    <T> void loadDefinition(ProcessDefinitionTranslator<T> translator,
                            T source)
                        throws SarasvatiLoadException
    Takes a ProcessDefinitionTranslator, applies it to the given source and loads the resulting ProcessDefinition.

    Equivalent to loadDefinition( translator, source, null )

    Throws:
    SarasvatiLoadException
    See Also:
    loadDefinition(ProcessDefinitionTranslator, Object, String)

    loadDefinition

    <T> void loadDefinition(ProcessDefinitionTranslator<T> translator,
                            T source,
                            String customId)
                        throws SarasvatiLoadException
    Takes a ProcessDefinitionTranslator, applies it to the given source and loads the resulting ProcessDefinition.

    Type Parameters:
    T - The type of input that the process definition translator takes.
    Parameters:
    translator - Class which takes an input and returns a ProcessDefinition
    source - The input for the translator (usually an XML file).
    customId - The custom ID to give the graph. Example usage is a SHA-1 hash of the process definition.
    Throws:
    SarasvatiLoadException - Thrown if an error occurs during the load or if the GraphValidator throws an exception.

    loadWithDependencies

    List<LoadResult> loadWithDependencies(String name,
                                          ProcessDefinitionResolver resolver)
                                          throws SarasvatiLoadException
    Loads the named process definition. The given resolver is used to find the process definition and any of its dependencies that have not yet been loaded. The process definition is only and its dependencies are only loaded if they are new, have changed or dependencies have changed.

    Parameters:
    name - The name of the process definition to load
    resolver - The resolver to use in finding the process definition and its dependencies.
    Returns:
    The list of load results, which indicate which process definitions have been loaded and the reason why they were loaded (new, updated, dependency changed).
    Throws:
    SarasvatiLoadException - Thrown if an error occurs during the load or if the GraphValidator throws an exception.

    load

    void load(File file)
              throws SarasvatiLoadException
    Loads the given XML process definition file.

    Equivalent to loadDefinition( new XmlLoader(), file );

    Parameters:
    file - The xml file to load
    Throws:
    SarasvatiLoadException - Thrown if an error occurs during the load or if the GraphValidator throws an exception.