edu.cmu.sei.osate.ui.actions
Class AbstractAnalysis

java.lang.Object
  extended by edu.cmu.sei.osate.ui.actions.AbstractAnalysis
All Implemented Interfaces:
IAnalysis

public abstract class AbstractAnalysis
extends java.lang.Object
implements IAnalysis

Provides common functionality for all analyses. Provides an error manager and ensures that the public methods are called in the correct order.

Author:
jseibel

Constructor Summary
AbstractAnalysis()
           
 
Method Summary
protected  java.lang.String getConfiguratorValue(java.lang.String key)
           
protected  AnalysisErrorReporterManager getErrorManager()
          Returns an error manager that should be used by the analysis.
protected  java.lang.String getMarkerType()
           
 java.lang.String getNotReadyToRunReason()
          If for some reason the run() method could not be called, the reason is given as a human readable String that can be displayed to the user.
protected  AObject getParameter()
           
protected  void propertyDefinitionNotFound(java.lang.String propertySet, java.lang.String propertyDefinition)
          Sets the notReadyToRunReason to the message that the specified PropertyDefinition could not be found.
 boolean readyToRun()
          For all analyses, this method ensures that the parameter still exists.
protected abstract  boolean readyToRunImpl()
          readyToRun() will call this method.
 boolean run()
          Execute the analysis based on the parameter.
protected abstract  boolean runImpl()
          run() will call this method.
 void setConfiguratorKeysAndValues(java.util.HashMap<java.lang.String,java.lang.String> keysAndValues)
           
protected  void setNotReadyToRunReason(java.lang.String reason)
          If readyToRunImpl() determines that the analysis cannot run, the reason should be reported to this method.
 void setParameter(org.eclipse.emf.common.util.URI parameterPath, java.lang.String readablePath)
          Depending on the analysis, the parameter is the model, ComponentImpl, SystemImpl, or other AObject that the analysis runs on.
protected  void unitLiteralNotFound(java.lang.String unitLiteral, UnitsType unitsType)
          Sets the notReadyToRunReason to the message that the specified UnitLiteral could not be found.
protected  void unitsTypeNotFound(java.lang.String propertySet, java.lang.String unitsType)
          Sets the notReadyToRunReason to the message that the specified UnitsType could not be found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractAnalysis

public AbstractAnalysis()
Method Detail

setParameter

public final void setParameter(org.eclipse.emf.common.util.URI parameterPath,
                               java.lang.String readablePath)
Description copied from interface: IAnalysis
Depending on the analysis, the parameter is the model, ComponentImpl, SystemImpl, or other AObject that the analysis runs on. The appropriate parameter is dependent on the specific edu.cmu.sei.osate.ui.analysis extension. setParameter does not validate the parameter. It is the responsibility of this method's caller to ensure that the parameter is appropriate according to the analysis' plugin.xml file.

Specified by:
setParameter in interface IAnalysis
Parameters:
parameterPath - The URI path of the parameter which can be found by calling EcoreUtil.getURI(EObject).
readablePath - A textual representation of the parameter including its location that can be displayed to the user.

setConfiguratorKeysAndValues

public final void setConfiguratorKeysAndValues(java.util.HashMap<java.lang.String,java.lang.String> keysAndValues)
Specified by:
setConfiguratorKeysAndValues in interface IAnalysis

readyToRun

public final boolean readyToRun()
Description copied from interface: IAnalysis
For all analyses, this method ensures that the parameter still exists. Depending on the specific analysis, this method might check if certain property definitions are available. If for some reason the analysis is not in a runnable state, the reason is reported as a String and can be retrieved through getNotReadyToRunReason().

Specified by:
readyToRun in interface IAnalysis
Returns:
true if the run() method can be called; false if it cannot.

getNotReadyToRunReason

public final java.lang.String getNotReadyToRunReason()
Description copied from interface: IAnalysis
If for some reason the run() method could not be called, the reason is given as a human readable String that can be displayed to the user.

Specified by:
getNotReadyToRunReason in interface IAnalysis
Returns:
The reason that run() could not be called.

run

public final boolean run()
Description copied from interface: IAnalysis
Execute the analysis based on the parameter. If the analysis passed, then true is returned. If the analysis failed, then false is returned. For most analyses, failure is reported through problem markers on the model, however this behavior is not guaranteed for all analyses. See each analysis for failure details.

Specified by:
run in interface IAnalysis
Returns:
true if the analysis passed; false if it failed.

getMarkerType

protected java.lang.String getMarkerType()

getErrorManager

protected final AnalysisErrorReporterManager getErrorManager()
Returns an error manager that should be used by the analysis. There is one error manager instance per analysis instance. The error manager is created in the run() method before it calls runImpl().

Returns:
The error manager for this analysis.

setNotReadyToRunReason

protected final void setNotReadyToRunReason(java.lang.String reason)
If readyToRunImpl() determines that the analysis cannot run, the reason should be reported to this method.

Parameters:
reason - A human readable description of why the analysis cannot run.

getParameter

protected final AObject getParameter()

getConfiguratorValue

protected final java.lang.String getConfiguratorValue(java.lang.String key)

propertyDefinitionNotFound

protected final void propertyDefinitionNotFound(java.lang.String propertySet,
                                                java.lang.String propertyDefinition)
Sets the notReadyToRunReason to the message that the specified PropertyDefinition could not be found.

Parameters:
propertySet - PropertySet that the PropertyDefinition was expected to be in.
propertyDefinition - PropertyDefinition that could not be found.

unitsTypeNotFound

protected final void unitsTypeNotFound(java.lang.String propertySet,
                                       java.lang.String unitsType)
Sets the notReadyToRunReason to the message that the specified UnitsType could not be found.

Parameters:
propertySet - PropertySet that the UnitsType was expected to be in.
unitsType - UnitsType that could not be found.

unitLiteralNotFound

protected final void unitLiteralNotFound(java.lang.String unitLiteral,
                                         UnitsType unitsType)
Sets the notReadyToRunReason to the message that the specified UnitLiteral could not be found.

Parameters:
unitLiteral - UnitLiteral that could not be found.
unitsType - UnitsType that the UnitLiteral was expected to be in.

readyToRunImpl

protected abstract boolean readyToRunImpl()
readyToRun() will call this method. All the checks to ensure that readyToRun() is called in the correct order are handled by readyToRun(). readyToRunImpl() is only called in the appropriate state. In other words, don't worry about checking the state when overriding readyToRunImpl(). The return value of readyToRunImpl() will be the return value of readyToRun().

Returns:
true if the run() method can be called; false if it cannot.

runImpl

protected abstract boolean runImpl()
run() will call this method. All the checks to ensure that run() is called in the correct order are handled by run(). runImpl() is only called in the appropriate state. In other words, don't worry about checking the state when overriding runImpl(). The return value of runImpl() will be the return value of run().

Returns:
true if the analysis passed; false if it failed.