Class BaseTransformMeta<Main extends ITransform,Data extends ITransformData>
- java.lang.Object
-
- org.apache.hop.pipeline.transform.BaseTransformMeta<Main,Data>
-
- All Implemented Interfaces:
Cloneable,ITransformMeta
- Direct Known Subclasses:
AbstractTransformMeta,BaseFileInputMeta,DummyMeta,InjectorMeta,Missing,TransformWithMappingMeta
public class BaseTransformMeta<Main extends ITransform,Data extends ITransformData> extends Object implements ITransformMeta, Cloneable
This class is responsible for implementing common functionality regarding transform meta, such as logging. All Hop transforms have an extension of this where private fields have been added with public accessors.For example, the "Text File Output" transform's TextFileOutputMeta class extends BaseTransformMeta by adding fields for the output file name, compression, file format, etc...
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.hop.pipeline.transform.ITransformMeta
ITransformMeta.TransformFactory
-
-
Field Summary
Fields Modifier and Type Field Description protected ArrayList<IHopAttribute>attributesprotected Database[]databasesdatabase connection object to use for searching fields & checking transformsprotected ILogChannellogstatic ILoggingObjectloggingObjectprotected TransformMetaparentTransformMeta
-
Constructor Summary
Constructors Constructor Description BaseTransformMeta()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidanalyseImpact(IVariables variables, List<DatabaseImpact> impact, PipelineMeta pipelineMeta, TransformMeta transformMeta, IRowMeta prev, String[] input, String[] output, IRowMeta info, IHopMetadataProvider metadataProvider)Each transform must be able to report on the impact it has on a database, table field, etc.voidcancelQueries()Call this to cancel trailing database queries (too long running, etc)voidcheck(List<ICheckResult> remarks, PipelineMeta pipelineMeta, TransformMeta transformMeta, IRowMeta prev, String[] input, String[] output, IRowMeta info, IVariables variables, IHopMetadataProvider metadataProvider)Checks the settings of this transform and puts the findings in a remarks List.Objectclone()Make an exact copy of this transform, make sure to explicitly copy Collections etc.voidconvertIOMetaToTransformNames()Convert defined IOMeta information to transform metadata.ITransformcreateTransform(TransformMeta transformMeta, ITransformData data, int copyNr, PipelineMeta pipelineMeta, Pipeline pipeline)ITransformDatacreateTransformData()Create a new instance of the appropriate data class.booleanexcludeFromCopyDistributeVerification()This method is added to exclude certain transforms from copy/distribute checking.booleanexcludeFromRowLayoutVerification()This method is added to exclude certain transforms from layout checking.StringexportResources(IVariables variables, Map<String,ResourceDefinition> definitions, IResourceNaming iResourceNaming, IHopMetadataProvider metadataProvider)Export resources.StringgetActiveReferencedObjectDescription()StringgetDialogClassName() * This returns the expected name for the dialog that edits a action.voidgetFields(IRowMeta inputRowMeta, String name, IRowMeta[] info, TransformMeta nextTransform, IVariables variables, IHopMetadataProvider metadataProvider)Gets the fields.ILogChannelgetLog()Gets the log.StringgetLogChannelId()Gets the log channel id.StringgetName()Gets the name.StringgetObjectCopy()Gets the object copy.LoggingObjectTypegetObjectType()Gets the object type.List<IStream>getOptionalStreams()ILoggingObjectgetParent()Gets the parent.TransformMetagetParentTransformMeta()Gets the parent transform meta.String[]getReferencedObjectDescriptions()IRowMetagetRequiredFields(IVariables variables)The natural way of data flow in a pipeline is source-to-target.List<ResourceReference>getResourceDependencies(IVariables variables, TransformMeta transformMeta)Get a list of all the resource dependencies that the transform is depending on.SqlStatementgetSqlStatements(IVariables variables, PipelineMeta pipelineMeta, TransformMeta transformMeta, IRowMeta prev, IHopMetadataProvider metadataProvider)Standard method to return an SqlStatement object with Sql statements that the transform needs in order to work correctly.PipelineMeta.PipelineType[]getSupportedPipelineTypes()IRowMetagetTableFields(IVariables variables)Gets the table fields.ITransformIOMetagetTransformIOMeta()Returns the Input/Output metadata for this transform.ITransformIOMetagetTransformIOMeta(boolean createIfAbsent)Returns the Input/Output metadata for this transform.DatabaseMeta[]getUsedDatabaseConnections()Deprecated.StringgetXml()Produces the XML string that describes this transform's information.voidhandleStreamSelection(IStream stream)When an optional stream is selected, this method is called to handled the ETL metadata implications of that.booleanhasChanged()Checks for changed.booleanisBasic()Checks if is basic.booleanisDebug()Checks if is debug.booleanisDetailed()Checks if is detailed.boolean[]isReferencedObjectEnabled()booleanisRowLevel()Checks if is row level.IHasFilenameloadReferencedObject(int index, IHopMetadataProvider metadataProvider, IVariables variables)Load the referenced objectvoidloadXml(Node transformNode, IHopMetadataProvider metadataProvider)Automatically load metadata from XML using @HopMetadataPropertyannotationsvoidlogBasic(String message)Log basic.voidlogBasic(String message, Object... arguments)Log basic.voidlogDebug(String message)Log debug.voidlogDebug(String message, Object... arguments)Log debug.voidlogDetailed(String message)Log detailed.voidlogDetailed(String message, Object... arguments)Log detailed.voidlogError(String message)Log error.voidlogError(String message, Object... arguments)Log error.voidlogError(String message, Throwable e)Log error.voidlogMinimal(String message)Log minimal.voidlogMinimal(String message, Object... arguments)Log minimal.voidlogRowlevel(String message)Log rowlevel.voidlogRowlevel(String message, Object... arguments)Log rowlevel.voidresetTransformIoMeta()Reset transform io meta.voidsearchInfoAndTargetTransforms(List<TransformMeta> transforms)Change transform names into transform objects to allow them to be name-changed etc.voidsetChanged()Sets the changed.voidsetChanged(boolean ch)Sets the changed.voidsetDefault()Set default valuesvoidsetParentTransformMeta(TransformMeta parentTransformMeta)Sets the parent transform meta.voidsetTransformIOMeta(ITransformIOMeta value)Sets the Input/Output metadata for this transform.booleansupportsErrorHandling()-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.hop.pipeline.transform.ITransformMeta
cleanAfterHopFromRemove, cleanAfterHopFromRemove, cleanAfterHopToRemove, passDataToServletOutput
-
-
-
-
Field Detail
-
loggingObject
public static final ILoggingObject loggingObject
-
databases
protected Database[] databases
database connection object to use for searching fields & checking transforms
-
parentTransformMeta
protected TransformMeta parentTransformMeta
-
log
protected ILogChannel log
-
attributes
protected ArrayList<IHopAttribute> attributes
-
-
Method Detail
-
createTransform
public ITransform createTransform(TransformMeta transformMeta, ITransformData data, int copyNr, PipelineMeta pipelineMeta, Pipeline pipeline)
- Specified by:
createTransformin interfaceITransformMeta
-
createTransformData
public ITransformData createTransformData()
Description copied from interface:ITransformMetaCreate a new instance of the appropriate data class. This data class implements the ITransformData. It basically contains the persisting data that needs to live on, even if a worker thread is terminated.- Specified by:
createTransformDatain interfaceITransformMeta- Returns:
- The appropriate ITransformData class.
-
clone
public Object clone()
Description copied from interface:ITransformMetaMake an exact copy of this transform, make sure to explicitly copy Collections etc.- Specified by:
clonein interfaceITransformMeta- Overrides:
clonein classObject- Returns:
- an exact copy of this transform
-
setDefault
public void setDefault()
Description copied from interface:ITransformMetaSet default values- Specified by:
setDefaultin interfaceITransformMeta
-
setChanged
public void setChanged(boolean ch)
Sets the changed.- Parameters:
ch- the new changed
-
setChanged
public void setChanged()
Sets the changed.- Specified by:
setChangedin interfaceITransformMeta
-
hasChanged
public boolean hasChanged()
Checks for changed.- Specified by:
hasChangedin interfaceITransformMeta- Returns:
- true, if successful
-
getTableFields
public IRowMeta getTableFields(IVariables variables)
Gets the table fields.- Specified by:
getTableFieldsin interfaceITransformMeta- Parameters:
variables-- Returns:
- the table fields
-
getXml
public String getXml() throws HopException
Produces the XML string that describes this transform's information.- Specified by:
getXmlin interfaceITransformMeta- Returns:
- String containing the XML describing this transform.
- Throws:
HopException- in case there is an XML conversion or encoding error
-
loadXml
public void loadXml(Node transformNode, IHopMetadataProvider metadataProvider) throws HopXmlException
Automatically load metadata from XML using @HopMetadataPropertyannotations- Specified by:
loadXmlin interfaceITransformMeta- Parameters:
transformNode-metadataProvider-- Throws:
HopXmlException
-
getFields
public void getFields(IRowMeta inputRowMeta, String name, IRowMeta[] info, TransformMeta nextTransform, IVariables variables, IHopMetadataProvider metadataProvider) throws HopTransformException
Gets the fields.- Specified by:
getFieldsin interfaceITransformMeta- Parameters:
inputRowMeta- the input row meta that is modified in this method to reflect the output row metadata of the transformname- Name of the transform to use as input for the origin field in the valuesinfo- Fields used as extra lookup informationnextTransform- the next transform that is targetedvariables- the variables The variable variables to use to replace variablesmetadataProvider- the MetaStore to use to load additional external data or metadata impacting the output fields- Throws:
HopTransformException- the hop transform exception
-
analyseImpact
public void analyseImpact(IVariables variables, List<DatabaseImpact> impact, PipelineMeta pipelineMeta, TransformMeta transformMeta, IRowMeta prev, String[] input, String[] output, IRowMeta info, IHopMetadataProvider metadataProvider) throws HopTransformException
Each transform must be able to report on the impact it has on a database, table field, etc.- Specified by:
analyseImpactin interfaceITransformMeta- Parameters:
variables- The variables to use to resolve expressionsimpact- The list of impacts @see org.apache.hop.pipelineMeta.DatabaseImpactpipelineMeta- The pipeline informationtransformMeta- The transform informationprev- The fields entering this transforminput- The previous transform namesoutput- The output transform namesinfo- The fields used as information by this transformmetadataProvider- the MetaStore to use to load additional external data or metadata impacting the output fields- Throws:
HopTransformException
-
getSqlStatements
public SqlStatement getSqlStatements(IVariables variables, PipelineMeta pipelineMeta, TransformMeta transformMeta, IRowMeta prev, IHopMetadataProvider metadataProvider) throws HopTransformException
Standard method to return an SqlStatement object with Sql statements that the transform needs in order to work correctly. This can mean "create table", "create index" statements but also "alter table ... add/drop/modify" statements.- Specified by:
getSqlStatementsin interfaceITransformMeta- Parameters:
variables-pipelineMeta- PipelineMeta object containing the complete pipelinetransformMeta- TransformMeta object containing the complete transformprev- Row containing meta-data for the input fields (no data)metadataProvider- the MetaStore to use to load additional external data or metadata impacting the output fields- Returns:
- The Sql Statements for this transform. If nothing has to be done, the SqlStatement.getSql() == null. @see SqlStatement
- Throws:
HopTransformException
-
cancelQueries
public void cancelQueries() throws HopDatabaseExceptionCall this to cancel trailing database queries (too long running, etc)- Specified by:
cancelQueriesin interfaceITransformMeta- Throws:
HopDatabaseException
-
getRequiredFields
public IRowMeta getRequiredFields(IVariables variables) throws HopException
The natural way of data flow in a pipeline is source-to-target. However, this makes mapping to target tables difficult to do. To help out here, we supply information to the pipeline meta-data model about which fields are required for a transform. This allows us to automate certain tasks like the mapping to pre-defined tables. The Table Output transform in this case will output the fields in the target table using this method.This default implementation returns an empty row meaning that no fields are required for this transform to operate.
- Specified by:
getRequiredFieldsin interfaceITransformMeta- Parameters:
variables- the variable variables to use to do variable substitution.- Returns:
- the required fields for this transforms meta data.
- Throws:
HopException- in case the required fields can't be determined
-
getUsedDatabaseConnections
@Deprecated(since="2.0") public DatabaseMeta[] getUsedDatabaseConnections()
Deprecated.This method returns all the database connections that are used by the transform.- Returns:
- an array of database connections meta-data. Return an empty array if no connections are used.
-
supportsErrorHandling
public boolean supportsErrorHandling()
- Specified by:
supportsErrorHandlingin interfaceITransformMeta- Returns:
- true if this transform supports error "reporting" on rows: the ability to send rows to a certain target transform.
-
excludeFromRowLayoutVerification
public boolean excludeFromRowLayoutVerification()
This method is added to exclude certain transforms from layout checking.- Specified by:
excludeFromRowLayoutVerificationin interfaceITransformMeta
-
excludeFromCopyDistributeVerification
public boolean excludeFromCopyDistributeVerification()
This method is added to exclude certain transforms from copy/distribute checking.- Specified by:
excludeFromCopyDistributeVerificationin interfaceITransformMeta
-
getResourceDependencies
public List<ResourceReference> getResourceDependencies(IVariables variables, TransformMeta transformMeta)
Get a list of all the resource dependencies that the transform is depending on.- Specified by:
getResourceDependenciesin interfaceITransformMeta- Returns:
- a list of all the resource dependencies that the transform is depending on
-
exportResources
public String exportResources(IVariables variables, Map<String,ResourceDefinition> definitions, IResourceNaming iResourceNaming, IHopMetadataProvider metadataProvider) throws HopException
Export resources.- Specified by:
exportResourcesin interfaceITransformMeta- Parameters:
variables- the variablesdefinitions- the definitionsiResourceNaming- the resource naming interfacemetadataProvider- The place to load additional information- Returns:
- the string
- Throws:
HopException- the hop exception
-
getDialogClassName
public String getDialogClassName()
 * This returns the expected name for the dialog that edits a action. The expected name is in the org.apache.hop.ui  * tree and has a class name that is the name of the action with 'Dialog' added to the end.  * * e.g. if the action is org.apache.hop.workflow.actions.zipfile.JobEntryZipFile the dialog would be  * org.apache.hop.ui.workflow.actions.zipfile.JobEntryZipFileDialog  *
 * If the dialog class for a action does not match this pattern it should override this method and return the  * appropriate class name  *  * @return full class name of the dialog 
- Specified by:
getDialogClassNamein interfaceITransformMeta
-
getParentTransformMeta
public TransformMeta getParentTransformMeta()
Gets the parent transform meta.- Specified by:
getParentTransformMetain interfaceITransformMeta- Returns:
- the parent transform meta
-
setParentTransformMeta
public void setParentTransformMeta(TransformMeta parentTransformMeta)
Sets the parent transform meta.- Specified by:
setParentTransformMetain interfaceITransformMeta- Parameters:
parentTransformMeta- the new parent transform meta
-
getLog
public ILogChannel getLog()
Gets the log.- Returns:
- the log
-
isBasic
public boolean isBasic()
Checks if is basic.- Returns:
- true, if is basic
-
isDetailed
public boolean isDetailed()
Checks if is detailed.- Returns:
- true, if is detailed
-
isDebug
public boolean isDebug()
Checks if is debug.- Returns:
- true, if is debug
-
isRowLevel
public boolean isRowLevel()
Checks if is row level.- Returns:
- true, if is row level
-
logMinimal
public void logMinimal(String message)
Log minimal.- Parameters:
message- the message
-
logMinimal
public void logMinimal(String message, Object... arguments)
Log minimal.- Parameters:
message- the messagearguments- the arguments
-
logBasic
public void logBasic(String message)
Log basic.- Parameters:
message- the message
-
logBasic
public void logBasic(String message, Object... arguments)
Log basic.- Parameters:
message- the messagearguments- the arguments
-
logDetailed
public void logDetailed(String message)
Log detailed.- Parameters:
message- the message
-
logDetailed
public void logDetailed(String message, Object... arguments)
Log detailed.- Parameters:
message- the messagearguments- the arguments
-
logDebug
public void logDebug(String message)
Log debug.- Parameters:
message- the message
-
logDebug
public void logDebug(String message, Object... arguments)
Log debug.- Parameters:
message- the messagearguments- the arguments
-
logRowlevel
public void logRowlevel(String message)
Log rowlevel.- Parameters:
message- the message
-
logRowlevel
public void logRowlevel(String message, Object... arguments)
Log rowlevel.- Parameters:
message- the messagearguments- the arguments
-
logError
public void logError(String message)
Log error.- Parameters:
message- the message
-
logError
public void logError(String message, Throwable e)
Log error.- Parameters:
message- the messagee- the e
-
logError
public void logError(String message, Object... arguments)
Log error.- Parameters:
message- the messagearguments- the arguments
-
getLogChannelId
public String getLogChannelId()
Gets the log channel id.- Returns:
- the log channel id
-
getName
public String getName()
Gets the name.- Returns:
- the name
-
getObjectCopy
public String getObjectCopy()
Gets the object copy.- Returns:
- the object copy
-
getObjectType
public LoggingObjectType getObjectType()
Gets the object type.- Returns:
- the object type
-
getParent
public ILoggingObject getParent()
Gets the parent.- Returns:
- the parent
-
getTransformIOMeta
public ITransformIOMeta getTransformIOMeta()
Description copied from interface:ITransformMetaReturns the Input/Output metadata for this transform.- Specified by:
getTransformIOMetain interfaceITransformMeta
-
getTransformIOMeta
public ITransformIOMeta getTransformIOMeta(boolean createIfAbsent)
Returns the Input/Output metadata for this transform. By default, each transform produces and accepts optional input.
-
setTransformIOMeta
public void setTransformIOMeta(ITransformIOMeta value)
Sets the Input/Output metadata for this transform. By default, each transform produces and accepts optional input.- Parameters:
value- the ITransformIOMeta to set for this transform.
-
getOptionalStreams
public List<IStream> getOptionalStreams()
- Specified by:
getOptionalStreamsin interfaceITransformMeta- Returns:
- The list of optional input streams. It allows the user to select from a list of possible actions like "New target transform"
-
handleStreamSelection
public void handleStreamSelection(IStream stream)
When an optional stream is selected, this method is called to handled the ETL metadata implications of that.- Specified by:
handleStreamSelectionin interfaceITransformMeta- Parameters:
stream- The optional stream to handle.
-
resetTransformIoMeta
public void resetTransformIoMeta()
Reset transform io meta.- Specified by:
resetTransformIoMetain interfaceITransformMeta
-
searchInfoAndTargetTransforms
public void searchInfoAndTargetTransforms(List<TransformMeta> transforms)
Change transform names into transform objects to allow them to be name-changed etc.- Specified by:
searchInfoAndTargetTransformsin interfaceITransformMeta- Parameters:
transforms- the transforms to reference
-
convertIOMetaToTransformNames
public void convertIOMetaToTransformNames()
Description copied from interface:ITransformMetaConvert defined IOMeta information to transform metadata. This is the inverse of method searchInfoAndTargetTransforms()- Specified by:
convertIOMetaToTransformNamesin interfaceITransformMeta
-
getSupportedPipelineTypes
public PipelineMeta.PipelineType[] getSupportedPipelineTypes()
- Returns:
- The supported pipeline types that this transform supports.
-
getReferencedObjectDescriptions
public String[] getReferencedObjectDescriptions()
- Specified by:
getReferencedObjectDescriptionsin interfaceITransformMeta- Returns:
- The objects referenced in the transform, like a mapping, a pipeline, a workflow, ...
-
isReferencedObjectEnabled
public boolean[] isReferencedObjectEnabled()
- Specified by:
isReferencedObjectEnabledin interfaceITransformMeta- Returns:
- true for each referenced object that is enabled or has a valid reference definition.
-
getActiveReferencedObjectDescription
public String getActiveReferencedObjectDescription()
- Specified by:
getActiveReferencedObjectDescriptionin interfaceITransformMeta- Returns:
- A description of the active referenced object in a pipeline. Null if nothing special needs to be done or if the active metadata isn't different from design.
-
check
public void check(List<ICheckResult> remarks, PipelineMeta pipelineMeta, TransformMeta transformMeta, IRowMeta prev, String[] input, String[] output, IRowMeta info, IVariables variables, IHopMetadataProvider metadataProvider)
Description copied from interface:ITransformMetaChecks the settings of this transform and puts the findings in a remarks List.- Specified by:
checkin interfaceITransformMeta- Parameters:
remarks-pipelineMeta-transformMeta-prev-input-output-info-metadataProvider-variables- the variable variables to resolve variable expressions with
-
loadReferencedObject
public IHasFilename loadReferencedObject(int index, IHopMetadataProvider metadataProvider, IVariables variables) throws HopException
Load the referenced object- Specified by:
loadReferencedObjectin interfaceITransformMeta- Parameters:
index- the referenced object index to load (in case there are multiple references)metadataProvider- the MetaStore to usevariables- the variable variables to use- Returns:
- the referenced object once loaded
- Throws:
HopException
-
-