es.unex.sextante.modeler
Class ModelAlgorithm

java.lang.Object
  extended by es.unex.sextante.core.GeoAlgorithm
      extended by es.unex.sextante.modeler.ModelAlgorithm

public class ModelAlgorithm
extends GeoAlgorithm

An algorithm representing a model (a set of other geoalgorithms linked together in a workflow)

Author:
Victor Olaya volaya@unex.es

Constructor Summary
ModelAlgorithm()
          Creates a new model algorithm
 
Method Summary
 void addAlgorithm(GeoAlgorithm alg, java.lang.String sName)
          Adds a new algorithm to the model
 void addInput(Parameter param)
          Adds an input to the model
 boolean addInputAsignment(java.lang.String sParamName, java.lang.String sInputName, GeoAlgorithm alg)
          Adds an input assignment
 void defineCharacteristics()
          This method should be overridden and used to specify the parameters needed by the GeoAlgorithm, using the corresponding methods of the ParametersSet object.
 GeoAlgorithm getAlgorithm(java.lang.String sKey)
          Returns an algorithm from the ones used in this model
 java.lang.String[] getAlgorithmAsCommandLineSentences()
          Returns the command line expression that would create this instance of the algorithm
 java.util.ArrayList getAlgorithmKeys()
          Returns an arraylist with algorithm keys
 java.util.ArrayList getAlgorithms()
          Returns an arraylist with algorithms used in this model
 java.lang.String getCommandLineHelp()
          Returns a string containing the command line usage of the algorithm
 java.lang.String getFilename()
          Returns the filename associated with this model
 java.lang.String getInputAsignment(java.lang.String sParamName, GeoAlgorithm alg)
           
 java.util.ArrayList getInputAssignments()
           
 java.util.HashMap getInputAssignments(java.lang.String sKey)
           
 java.util.HashMap getInputs()
           
 GeoAlgorithm getNewInstance()
           
 boolean processAlgorithm()
          This method should implement the algorithm itself, using the values of the parameters and processing them.
 void removeAlgorithm(java.lang.String sKey)
          Removes an algorithm from the model
 void removeInput(Parameter param)
          Removes a parameter input
 void removeInput(java.lang.String sKey)
          Removes a parameter input
 void setFilename(java.lang.String sFilename)
          Sets the filename associated with this model
 void setValues(java.util.ArrayList algs, java.util.ArrayList algKeys, java.util.ArrayList assignments, java.util.HashMap inputs, OutputObjectsSet outputs)
          Sets the values used by the model algorithm
 void unassign(java.lang.String sAssignmentKey)
          Removes an assignment
 
Methods inherited from class es.unex.sextante.core.GeoAlgorithm
adjustRasterOutputExtent, execute, generatesLayers, generatesLayersOrTables, generatesUserDefinedRasterOutput, getCommandLineName, getGridExtent, getGroup, getName, getNumberOfLineVectorLayers, getNumberOfOutputObjects, getNumberOfParameters, getNumberOfPointVectorLayers, getNumberOfPolygonLayers, getNumberOfRasterLayers, getNumberOfTables, getNumberOfVectorLayers, getOutputObjects, getParameters, getProcessMetadata, hasCorrectParameterValues, isAutoExtent, isDeterminatedProcess, isSuitableForModelling, meetsDataRequirements, meetsRasterRequirements, meetsTableRequirements, meetsVectorRequirements, preprocessForModeller, requiresIndividualRasterLayers, requiresIndividualVectorLayers, requiresLineVectorLayers, requiresMultipleRasterBands, requiresMultipleRasterLayers, requiresMultipleTables, requiresMultipleVectorLayers, requiresNonDataObjects, requiresPoints, requiresPointVectorLayers, requiresPolygonVectorLayers, requiresRasterLayers, requiresTableFields, requiresTables, requiresVectorLayers, setGeneratesUserDefinedRasterOutput, setGridExtent, setGroup, setIsDeterminatedProcess, setName, setOutputObjects, setParameters, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ModelAlgorithm

public ModelAlgorithm()
Creates a new model algorithm

Method Detail

defineCharacteristics

public void defineCharacteristics()
Description copied from class: GeoAlgorithm
This method should be overridden and used to specify the parameters needed by the GeoAlgorithm, using the corresponding methods of the ParametersSet object. Also, output objects must be added, so SEXTANTE knows in advance which outputs will be generated by the algorithm. See the addOutputXXXX family of methods (GeoAlgorithm.addOutputRasterLayer(java.lang.String, java.lang.String, int, es.unex.sextante.outputs.IOutputChannel, es.unex.sextante.dataObjects.IRasterLayer), GeoAlgorithm.addOutputVectorLayer(java.lang.String, java.lang.String, int, es.unex.sextante.outputs.IOutputChannel, es.unex.sextante.dataObjects.IVectorLayer), etc.)

Specified by:
defineCharacteristics in class GeoAlgorithm

setValues

public void setValues(java.util.ArrayList algs,
                      java.util.ArrayList algKeys,
                      java.util.ArrayList assignments,
                      java.util.HashMap inputs,
                      OutputObjectsSet outputs)
Sets the values used by the model algorithm

Parameters:
algs - The list of algorithm used by the model
algKeys - a list of keys to identify the used algorithms
assignments - a list of assignments
inputs - the list of inputs of the algorithm
outputs - The output objects that the algorithm generates

processAlgorithm

public boolean processAlgorithm()
                         throws GeoAlgorithmExecutionException
Description copied from class: GeoAlgorithm
This method should implement the algorithm itself, using the values of the parameters and processing them.

Specified by:
processAlgorithm in class GeoAlgorithm
Returns:
true if the algorithm was correctly executed. False if it was canceled.
Throws:
GeoAlgorithmExecutionException - if there were problems during algorithm execution

addAlgorithm

public void addAlgorithm(GeoAlgorithm alg,
                         java.lang.String sName)
Adds a new algorithm to the model

Parameters:
alg - the algorithm to add
sName - the name to identify the algorithm

removeAlgorithm

public void removeAlgorithm(java.lang.String sKey)
Removes an algorithm from the model

Parameters:
sKey - the name to identify the algorithm to remove

addInputAsignment

public boolean addInputAsignment(java.lang.String sParamName,
                                 java.lang.String sInputName,
                                 GeoAlgorithm alg)
Adds an input assignment

Parameters:
sParamName - the name of the parameter
sInputName - the name of the input
alg - the algorithm
Returns:
true if could make the assignment

addInput

public void addInput(Parameter param)
              throws RepeatedParameterNameException
Adds an input to the model

Parameters:
param - the input parameter to add
Throws:
RepeatedParameterNameException

removeInput

public void removeInput(Parameter param)
Removes a parameter input

Parameters:
param - the parameter to remove

removeInput

public void removeInput(java.lang.String sKey)
Removes a parameter input

Parameters:
sKey - the name of the parameter to remove

unassign

public void unassign(java.lang.String sAssignmentKey)
Removes an assignment

Parameters:
sAssignmentKey - the key of the assignment to remove

getAlgorithmKeys

public java.util.ArrayList getAlgorithmKeys()
Returns an arraylist with algorithm keys

Returns:
an arraylist with algorithm keys

getAlgorithms

public java.util.ArrayList getAlgorithms()
Returns an arraylist with algorithms used in this model

Returns:
an arraylist with algorithms used in this model

getInputAssignments

public java.util.ArrayList getInputAssignments()

getInputs

public java.util.HashMap getInputs()

getAlgorithm

public GeoAlgorithm getAlgorithm(java.lang.String sKey)
Returns an algorithm from the ones used in this model

Parameters:
sKey - the key used to identify the algorithm to get
Returns:
an algorithm from the ones used in this model. Returns null if no algorithm with that key was found

getInputAssignments

public java.util.HashMap getInputAssignments(java.lang.String sKey)

getInputAsignment

public java.lang.String getInputAsignment(java.lang.String sParamName,
                                          GeoAlgorithm alg)

getNewInstance

public GeoAlgorithm getNewInstance()
                            throws java.lang.InstantiationException,
                                   java.lang.IllegalAccessException
Overrides:
getNewInstance in class GeoAlgorithm
Returns:
a new instance of the algorithm
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException

getFilename

public java.lang.String getFilename()
Returns the filename associated with this model

Returns:
the filename associated with this model

setFilename

public void setFilename(java.lang.String sFilename)
Sets the filename associated with this model

Parameters:
sFilename - the filename where this model is stored

getCommandLineHelp

public java.lang.String getCommandLineHelp()
Description copied from class: GeoAlgorithm
Returns a string containing the command line usage of the algorithm

Overrides:
getCommandLineHelp in class GeoAlgorithm
Returns:
a string containing the command line usage of the algorithm

getAlgorithmAsCommandLineSentences

public java.lang.String[] getAlgorithmAsCommandLineSentences()
Description copied from class: GeoAlgorithm
Returns the command line expression that would create this instance of the algorithm

Overrides:
getAlgorithmAsCommandLineSentences in class GeoAlgorithm
Returns:
A command line expression representing this algorithm