src_fm_fc_ms_ff
stringlengths 43
86.8k
| target
stringlengths 20
276k
|
|---|---|
TransMeta extends AbstractMeta implements XMLInterface, Comparator<TransMeta>, Comparable<TransMeta>, Cloneable, ResourceExportInterface,
RepositoryElementInterface, LoggingObjectInterface { public Object realClone( boolean doClear ) { try { TransMeta transMeta = (TransMeta) super.clone(); if ( doClear ) { transMeta.clear(); } else { transMeta.databases = new ArrayList<>(); transMeta.steps = new ArrayList<>(); transMeta.hops = new ArrayList<>(); transMeta.notes = new ArrayList<>(); transMeta.dependencies = new ArrayList<>(); transMeta.partitionSchemas = new ArrayList<>(); transMeta.slaveServers = new ArrayList<>(); transMeta.clusterSchemas = new ArrayList<>(); transMeta.namedParams = new NamedParamsDefault(); transMeta.stepChangeListeners = new ArrayList<>(); } for ( DatabaseMeta db : databases ) { transMeta.addDatabase( (DatabaseMeta) db.clone() ); } for ( StepMeta step : steps ) { transMeta.addStep( (StepMeta) step.clone() ); } for ( StepMeta step : transMeta.getSteps() ) { final StepMetaInterface stepMetaInterface = step.getStepMetaInterface(); if ( stepMetaInterface != null ) { final StepIOMetaInterface stepIOMeta = stepMetaInterface.getStepIOMeta(); if ( stepIOMeta != null ) { for ( StreamInterface stream : stepIOMeta.getInfoStreams() ) { String streamStepName = stream.getStepname(); if ( streamStepName != null ) { StepMeta streamStepMeta = transMeta.findStep( streamStepName ); stream.setStepMeta( streamStepMeta ); } } } } } for ( TransHopMeta hop : hops ) { transMeta.addTransHop( (TransHopMeta) hop.clone() ); } for ( NotePadMeta note : notes ) { transMeta.addNote( (NotePadMeta) note.clone() ); } for ( TransDependency dep : dependencies ) { transMeta.addDependency( (TransDependency) dep.clone() ); } for ( SlaveServer slave : slaveServers ) { transMeta.getSlaveServers().add( (SlaveServer) slave.clone() ); } for ( ClusterSchema schema : clusterSchemas ) { transMeta.getClusterSchemas().add( schema.clone() ); } for ( PartitionSchema schema : partitionSchemas ) { transMeta.getPartitionSchemas().add( (PartitionSchema) schema.clone() ); } for ( String key : listParameters() ) { transMeta.addParameterDefinition( key, getParameterDefault( key ), getParameterDescription( key ) ); } return transMeta; } catch ( Exception e ) { e.printStackTrace(); return null; } } TransMeta(); TransMeta( VariableSpace parent ); TransMeta( String filename, String name ); @Deprecated TransMeta( String filename, String name, String[] arguments ); TransMeta( String fname ); TransMeta( String fname, VariableSpace parentVariableSpace ); TransMeta( String fname, boolean setInternalVariables ); TransMeta( String fname, Repository rep ); TransMeta( String fname, Repository rep, boolean setInternalVariables ); TransMeta( String fname, Repository rep, boolean setInternalVariables, VariableSpace parentVariableSpace ); TransMeta( String fname, Repository rep, boolean setInternalVariables, VariableSpace parentVariableSpace,
OverwritePrompter prompter ); TransMeta( String fname, IMetaStore metaStore, Repository rep, boolean setInternalVariables,
VariableSpace parentVariableSpace, OverwritePrompter prompter ); TransMeta( InputStream xmlStream, Repository rep, boolean setInternalVariables,
VariableSpace parentVariableSpace, OverwritePrompter prompter ); TransMeta( Node transnode, Repository rep ); @Override int compare( TransMeta t1, TransMeta t2 ); @Override int compareTo( TransMeta o ); @Override boolean equals( Object obj ); @Override Object clone(); Object realClone( boolean doClear ); @Override void clear(); void addStep( StepMeta stepMeta ); void addOrReplaceStep( StepMeta stepMeta ); void addTransHop( TransHopMeta hi ); void addDependency( TransDependency td ); void addStep( int p, StepMeta stepMeta ); void addTransHop( int p, TransHopMeta hi ); void addDependency( int p, TransDependency td ); List<StepMeta> getSteps(); StepMeta getStep( int i ); TransHopMeta getTransHop( int i ); TransDependency getDependency( int i ); void removeStep( int i ); void removeTransHop( int i ); void removeTransHop( TransHopMeta hop ); void removeDependency( int i ); void removeAllDependencies(); int nrSteps(); int nrTransHops(); int nrDependencies(); int nrStepChangeListeners(); void setStep( int i, StepMeta stepMeta ); void setTransHop( int i, TransHopMeta hi ); List<StepMeta> getUsedSteps(); StepMeta findStep( String name ); StepMeta findStep( String name, StepMeta exclude ); TransHopMeta findTransHop( String name ); TransHopMeta findTransHopFrom( StepMeta fromstep ); List<TransHopMeta> findAllTransHopFrom( StepMeta fromstep ); TransHopMeta findTransHop( TransHopMeta hi ); TransHopMeta findTransHop( StepMeta from, StepMeta to ); TransHopMeta findTransHop( StepMeta from, StepMeta to, boolean disabledToo ); TransHopMeta findTransHopTo( StepMeta tostep ); boolean isStepInformative( StepMeta this_step, StepMeta prev_step ); @Deprecated int findNrPrevSteps( String stepname ); @Deprecated int findNrPrevSteps( String stepname, boolean info ); int findNrPrevSteps( StepMeta stepMeta ); @Deprecated StepMeta findPrevStep( String stepname, int nr ); @Deprecated StepMeta findPrevStep( String stepname, int nr, boolean info ); StepMeta findPrevStep( StepMeta stepMeta, int nr ); @Deprecated int findNrPrevSteps( StepMeta stepMeta, boolean info ); @Deprecated StepMeta findPrevStep( StepMeta stepMeta, int nr, boolean info ); List<StepMeta> findPreviousSteps( StepMeta stepMeta ); List<StepMeta> findPreviousSteps( StepMeta stepMeta, boolean info ); StepMeta[] getInfoStep( StepMeta stepMeta ); int findNrInfoSteps( StepMeta stepMeta ); RowMetaInterface getPrevInfoFields( String stepname ); RowMetaInterface getPrevInfoFields( StepMeta stepMeta ); @Deprecated int findNrNextSteps( StepMeta stepMeta ); @Deprecated StepMeta findNextStep( StepMeta stepMeta, int nr ); StepMeta[] getPrevSteps( StepMeta stepMeta ); String[] getPrevStepNames( String stepname ); String[] getPrevStepNames( StepMeta stepMeta ); @Deprecated StepMeta[] getNextSteps( StepMeta stepMeta ); List<StepMeta> findNextSteps( StepMeta stepMeta ); String[] getNextStepNames( StepMeta stepMeta ); StepMeta getStep( int x, int y, int iconsize ); boolean partOfTransHop( StepMeta stepMeta ); RowMetaInterface getStepFields( String stepname ); RowMetaInterface getStepFields( StepMeta stepMeta ); RowMetaInterface getStepFields( StepMeta[] stepMeta ); RowMetaInterface getStepFields( StepMeta stepMeta, ProgressMonitorListener monitor ); RowMetaInterface getStepFields( StepMeta stepMeta, StepMeta targetStep, ProgressMonitorListener monitor ); RowMetaInterface getPrevStepFields( String stepname ); RowMetaInterface getPrevStepFields( StepMeta stepMeta ); RowMetaInterface getPrevStepFields( StepMeta stepMeta, ProgressMonitorListener monitor ); RowMetaInterface getThisStepFields( String stepname, RowMetaInterface row ); RowMetaInterface getThisStepFields( StepMeta stepMeta, StepMeta nextStep, RowMetaInterface row ); RowMetaInterface getThisStepFields( StepMeta stepMeta, StepMeta nextStep, RowMetaInterface row,
ProgressMonitorListener monitor ); boolean isUsingPartitionSchema( PartitionSchema partitionSchema ); boolean isUsingAClusterSchema(); boolean isUsingClusterSchema( ClusterSchema clusterSchema ); boolean isUsingSlaveServer( SlaveServer slaveServer ); boolean isRepReference(); boolean isFileReference(); static boolean isRepReference( String exactFilename, String exactTransname ); static boolean isFileReference( String exactFilename, String exactTransname ); int indexOfTransHop( TransHopMeta hi ); int indexOfStep( StepMeta stepMeta ); @Override String getFileType(); @Override String[] getFilterNames(); @Override String[] getFilterExtensions(); @Override String getDefaultExtension(); @Override String getXML(); String getXML( boolean includeSteps, boolean includeDatabase, boolean includeSlaves, boolean includeClusters,
boolean includePartitions ); void loadXML( Node transnode, Repository rep, boolean setInternalVariables ); void loadXML( Node transnode, Repository rep, boolean setInternalVariables, VariableSpace parentVariableSpace ); void loadXML( Node transnode, Repository rep, boolean setInternalVariables, VariableSpace parentVariableSpace,
OverwritePrompter prompter ); void loadXML( Node transnode, String fname, Repository rep, boolean setInternalVariables,
VariableSpace parentVariableSpace, OverwritePrompter prompter ); void loadXML( Node transnode, String fname, IMetaStore metaStore, Repository rep, boolean setInternalVariables,
VariableSpace parentVariableSpace, OverwritePrompter prompter ); byte[] getKey(); void setKey( byte[] key ); boolean isPrivateKey(); void setPrivateKey( boolean privateKey ); @Override boolean loadSharedObject( SharedObjectInterface object ); List<StepMeta> getTransHopSteps( boolean all ); boolean isStepUsedInTransHops( StepMeta stepMeta ); boolean isAnySelectedStepUsedInTransHops(); @Override void clearChanged(); boolean haveStepsChanged(); boolean haveHopsChanged(); boolean havePartitionSchemasChanged(); boolean haveClusterSchemasChanged(); @Override boolean hasChanged(); boolean hasLoop( StepMeta stepMeta ); void selectAll(); void unselectAll(); Point[] getSelectedStepLocations(); Point[] getSelectedNoteLocations(); List<StepMeta> getSelectedSteps(); String[] getSelectedStepNames(); int[] getStepIndexes( List<StepMeta> steps ); Point getMaximum(); Point getMinimum(); String[] getStepNames(); StepMeta[] getStepsArray(); boolean findPrevious( StepMeta startStep, StepMeta stepToFind ); void sortSteps(); void sortHops(); Map<StepMeta, Map<StepMeta, Boolean>> sortStepsNatural(); void sortHopsNatural(); void analyseImpact( List<DatabaseImpact> impact, ProgressMonitorListener monitor ); String getAlternativeStepname( String stepname ); List<SQLStatement> getSQLStatements(); List<SQLStatement> getSQLStatements( ProgressMonitorListener monitor ); String getSQLStatementsString(); @Deprecated void checkSteps( List<CheckResultInterface> remarks, boolean only_selected, ProgressMonitorListener monitor ); void checkSteps( List<CheckResultInterface> remarks, boolean only_selected, ProgressMonitorListener monitor,
VariableSpace space, Repository repository, IMetaStore metaStore ); @Deprecated List<RowMetaAndData> getResultRows(); @Deprecated void setResultRows( List<RowMetaAndData> resultRows ); String getPathAndName(); @Deprecated String[] getArguments(); @Deprecated void setArguments( String[] arguments ); @Deprecated Hashtable<String, Counter> getCounters(); @Deprecated void setCounters( Hashtable<String, Counter> counters ); List<TransDependency> getDependencies(); void setDependencies( List<TransDependency> dependencies ); DatabaseMeta getMaxDateConnection(); void setMaxDateConnection( DatabaseMeta maxDateConnection ); double getMaxDateDifference(); void setMaxDateDifference( double maxDateDifference ); String getMaxDateField(); void setMaxDateField( String maxDateField ); double getMaxDateOffset(); void setMaxDateOffset( double maxDateOffset ); String getMaxDateTable(); void setMaxDateTable( String maxDateTable ); int getSizeRowset(); void setSizeRowset( int sizeRowset ); DBCache getDbCache(); void setDbCache( DBCache dbCache ); String getTransversion(); void setTransversion( String n ); void setTransstatus( int n ); int getTransstatus(); @Override String toString(); void cancelQueries(); Map<String, String> getUsedArguments( String[] arguments ); int getSleepTimeEmpty(); int getSleepTimeFull(); void setSleepTimeEmpty( int sleepTimeEmpty ); void setSleepTimeFull( int sleepTimeFull ); boolean isDatabaseConnectionUsed( DatabaseMeta databaseMeta ); List<StringSearchResult> getStringList( boolean searchSteps, boolean searchDatabases, boolean searchNotes,
boolean includePasswords ); List<StringSearchResult> getStringList( boolean searchSteps, boolean searchDatabases, boolean searchNotes ); List<String> getUsedVariables(); @Deprecated Result getPreviousResult(); @Deprecated void setPreviousResult( Result previousResult ); @Deprecated List<ResultFile> getResultFiles(); @Deprecated void setResultFiles( List<ResultFile> resultFiles ); List<PartitionSchema> getPartitionSchemas(); void setPartitionSchemas( List<PartitionSchema> partitionSchemas ); String[] getPartitionSchemasNames(); boolean isFeedbackShown(); void setFeedbackShown( boolean feedbackShown ); int getFeedbackSize(); void setFeedbackSize( int feedbackSize ); boolean isUsingUniqueConnections(); void setUsingUniqueConnections( boolean usingUniqueConnections ); List<ClusterSchema> getClusterSchemas(); void setClusterSchemas( List<ClusterSchema> clusterSchemas ); String[] getClusterSchemaNames(); PartitionSchema findPartitionSchema( String name ); ClusterSchema findClusterSchema( String name ); void addOrReplacePartitionSchema( PartitionSchema partitionSchema ); void addOrReplaceClusterSchema( ClusterSchema clusterSchema ); boolean isUsingThreadPriorityManagment(); void setUsingThreadPriorityManagment( boolean usingThreadPriorityManagment ); void checkRowMixingStatically( StepMeta stepMeta, ProgressMonitorListener monitor ); @Override void setInternalKettleVariables( VariableSpace var ); StepMeta findMappingInputStep( String stepname ); StepMeta findMappingOutputStep( String stepname ); List<ResourceReference> getResourceDependencies(); @Override String exportResources( VariableSpace space, Map<String, ResourceDefinition> definitions,
ResourceNamingInterface resourceNamingInterface, Repository repository, IMetaStore metaStore ); SlaveStepCopyPartitionDistribution getSlaveStepCopyPartitionDistribution(); void setSlaveStepCopyPartitionDistribution(
SlaveStepCopyPartitionDistribution slaveStepCopyPartitionDistribution ); ClusterSchema findFirstUsedClusterSchema(); boolean isSlaveTransformation(); void setSlaveTransformation( boolean slaveTransformation ); boolean isCapturingStepPerformanceSnapShots(); void setCapturingStepPerformanceSnapShots( boolean capturingStepPerformanceSnapShots ); long getStepPerformanceCapturingDelay(); void setStepPerformanceCapturingDelay( long stepPerformanceCapturingDelay ); String getStepPerformanceCapturingSizeLimit(); void setStepPerformanceCapturingSizeLimit( String stepPerformanceCapturingSizeLimit ); void clearCaches(); @Override RepositoryObjectType getRepositoryElementType(); LogChannelInterface getLogChannel(); @Override String getLogChannelId(); @Override LoggingObjectType getObjectType(); TransLogTable getTransLogTable(); void setTransLogTable( TransLogTable transLogTable ); PerformanceLogTable getPerformanceLogTable(); void setPerformanceLogTable( PerformanceLogTable performanceLogTable ); StepLogTable getStepLogTable(); void setStepLogTable( StepLogTable stepLogTable ); List<LogTableInterface> getLogTables(); TransformationType getTransformationType(); void setTransformationType( TransformationType transformationType ); void writeXML( String filename ); boolean hasRepositoryReferences(); void lookupRepositoryReferences( Repository repository ); MetricsLogTable getMetricsLogTable(); void setMetricsLogTable( MetricsLogTable metricsLogTable ); @Override boolean isGatheringMetrics(); @Override void setGatheringMetrics( boolean gatheringMetrics ); @Override boolean isForcingSeparateLogging(); @Override void setForcingSeparateLogging( boolean forcingSeparateLogging ); void addStepChangeListener( StepMetaChangeListenerInterface listener ); void addStepChangeListener( int p, StepMetaChangeListenerInterface list ); void removeStepChangeListener( StepMetaChangeListenerInterface list ); void notifyAllListeners( StepMeta oldMeta, StepMeta newMeta ); boolean containsStepMeta( StepMeta stepMeta ); List<MissingTrans> getMissingTrans(); void addMissingTrans( MissingTrans trans ); void removeMissingTrans( MissingTrans trans ); @Override boolean hasMissingPlugins(); @Override NamedClusterEmbedManager getNamedClusterEmbedManager( ); static final String XML_TAG; static final String STRING_TRANSMETA; static final RepositoryObjectType REPOSITORY_ELEMENT_TYPE; static final int BORDER_INDENT; static final String[] desc_type_undo; static final String XML_TAG_ORDER; static final String XML_TAG_NOTEPADS; static final String XML_TAG_PARAMETERS; static final String XML_TAG_PARTITIONSCHEMAS; static final String XML_TAG_SLAVESERVERS; static final String XML_TAG_CLUSTERSCHEMAS; static final String XML_TAG_STEP_ERROR_HANDLING; }
|
@Test public void testCloneWithParam() throws Exception { TransMeta transMeta = new TransMeta( "transFile", "myTrans" ); transMeta.addParameterDefinition( "key", "defValue", "description" ); Object clone = transMeta.realClone( true ); assertNotNull( clone ); }
|
TransMeta extends AbstractMeta implements XMLInterface, Comparator<TransMeta>, Comparable<TransMeta>, Cloneable, ResourceExportInterface,
RepositoryElementInterface, LoggingObjectInterface { public void loadXML( Node transnode, Repository rep, boolean setInternalVariables ) throws KettleXMLException, KettleMissingPluginsException { loadXML( transnode, rep, setInternalVariables, null ); } TransMeta(); TransMeta( VariableSpace parent ); TransMeta( String filename, String name ); @Deprecated TransMeta( String filename, String name, String[] arguments ); TransMeta( String fname ); TransMeta( String fname, VariableSpace parentVariableSpace ); TransMeta( String fname, boolean setInternalVariables ); TransMeta( String fname, Repository rep ); TransMeta( String fname, Repository rep, boolean setInternalVariables ); TransMeta( String fname, Repository rep, boolean setInternalVariables, VariableSpace parentVariableSpace ); TransMeta( String fname, Repository rep, boolean setInternalVariables, VariableSpace parentVariableSpace,
OverwritePrompter prompter ); TransMeta( String fname, IMetaStore metaStore, Repository rep, boolean setInternalVariables,
VariableSpace parentVariableSpace, OverwritePrompter prompter ); TransMeta( InputStream xmlStream, Repository rep, boolean setInternalVariables,
VariableSpace parentVariableSpace, OverwritePrompter prompter ); TransMeta( Node transnode, Repository rep ); @Override int compare( TransMeta t1, TransMeta t2 ); @Override int compareTo( TransMeta o ); @Override boolean equals( Object obj ); @Override Object clone(); Object realClone( boolean doClear ); @Override void clear(); void addStep( StepMeta stepMeta ); void addOrReplaceStep( StepMeta stepMeta ); void addTransHop( TransHopMeta hi ); void addDependency( TransDependency td ); void addStep( int p, StepMeta stepMeta ); void addTransHop( int p, TransHopMeta hi ); void addDependency( int p, TransDependency td ); List<StepMeta> getSteps(); StepMeta getStep( int i ); TransHopMeta getTransHop( int i ); TransDependency getDependency( int i ); void removeStep( int i ); void removeTransHop( int i ); void removeTransHop( TransHopMeta hop ); void removeDependency( int i ); void removeAllDependencies(); int nrSteps(); int nrTransHops(); int nrDependencies(); int nrStepChangeListeners(); void setStep( int i, StepMeta stepMeta ); void setTransHop( int i, TransHopMeta hi ); List<StepMeta> getUsedSteps(); StepMeta findStep( String name ); StepMeta findStep( String name, StepMeta exclude ); TransHopMeta findTransHop( String name ); TransHopMeta findTransHopFrom( StepMeta fromstep ); List<TransHopMeta> findAllTransHopFrom( StepMeta fromstep ); TransHopMeta findTransHop( TransHopMeta hi ); TransHopMeta findTransHop( StepMeta from, StepMeta to ); TransHopMeta findTransHop( StepMeta from, StepMeta to, boolean disabledToo ); TransHopMeta findTransHopTo( StepMeta tostep ); boolean isStepInformative( StepMeta this_step, StepMeta prev_step ); @Deprecated int findNrPrevSteps( String stepname ); @Deprecated int findNrPrevSteps( String stepname, boolean info ); int findNrPrevSteps( StepMeta stepMeta ); @Deprecated StepMeta findPrevStep( String stepname, int nr ); @Deprecated StepMeta findPrevStep( String stepname, int nr, boolean info ); StepMeta findPrevStep( StepMeta stepMeta, int nr ); @Deprecated int findNrPrevSteps( StepMeta stepMeta, boolean info ); @Deprecated StepMeta findPrevStep( StepMeta stepMeta, int nr, boolean info ); List<StepMeta> findPreviousSteps( StepMeta stepMeta ); List<StepMeta> findPreviousSteps( StepMeta stepMeta, boolean info ); StepMeta[] getInfoStep( StepMeta stepMeta ); int findNrInfoSteps( StepMeta stepMeta ); RowMetaInterface getPrevInfoFields( String stepname ); RowMetaInterface getPrevInfoFields( StepMeta stepMeta ); @Deprecated int findNrNextSteps( StepMeta stepMeta ); @Deprecated StepMeta findNextStep( StepMeta stepMeta, int nr ); StepMeta[] getPrevSteps( StepMeta stepMeta ); String[] getPrevStepNames( String stepname ); String[] getPrevStepNames( StepMeta stepMeta ); @Deprecated StepMeta[] getNextSteps( StepMeta stepMeta ); List<StepMeta> findNextSteps( StepMeta stepMeta ); String[] getNextStepNames( StepMeta stepMeta ); StepMeta getStep( int x, int y, int iconsize ); boolean partOfTransHop( StepMeta stepMeta ); RowMetaInterface getStepFields( String stepname ); RowMetaInterface getStepFields( StepMeta stepMeta ); RowMetaInterface getStepFields( StepMeta[] stepMeta ); RowMetaInterface getStepFields( StepMeta stepMeta, ProgressMonitorListener monitor ); RowMetaInterface getStepFields( StepMeta stepMeta, StepMeta targetStep, ProgressMonitorListener monitor ); RowMetaInterface getPrevStepFields( String stepname ); RowMetaInterface getPrevStepFields( StepMeta stepMeta ); RowMetaInterface getPrevStepFields( StepMeta stepMeta, ProgressMonitorListener monitor ); RowMetaInterface getThisStepFields( String stepname, RowMetaInterface row ); RowMetaInterface getThisStepFields( StepMeta stepMeta, StepMeta nextStep, RowMetaInterface row ); RowMetaInterface getThisStepFields( StepMeta stepMeta, StepMeta nextStep, RowMetaInterface row,
ProgressMonitorListener monitor ); boolean isUsingPartitionSchema( PartitionSchema partitionSchema ); boolean isUsingAClusterSchema(); boolean isUsingClusterSchema( ClusterSchema clusterSchema ); boolean isUsingSlaveServer( SlaveServer slaveServer ); boolean isRepReference(); boolean isFileReference(); static boolean isRepReference( String exactFilename, String exactTransname ); static boolean isFileReference( String exactFilename, String exactTransname ); int indexOfTransHop( TransHopMeta hi ); int indexOfStep( StepMeta stepMeta ); @Override String getFileType(); @Override String[] getFilterNames(); @Override String[] getFilterExtensions(); @Override String getDefaultExtension(); @Override String getXML(); String getXML( boolean includeSteps, boolean includeDatabase, boolean includeSlaves, boolean includeClusters,
boolean includePartitions ); void loadXML( Node transnode, Repository rep, boolean setInternalVariables ); void loadXML( Node transnode, Repository rep, boolean setInternalVariables, VariableSpace parentVariableSpace ); void loadXML( Node transnode, Repository rep, boolean setInternalVariables, VariableSpace parentVariableSpace,
OverwritePrompter prompter ); void loadXML( Node transnode, String fname, Repository rep, boolean setInternalVariables,
VariableSpace parentVariableSpace, OverwritePrompter prompter ); void loadXML( Node transnode, String fname, IMetaStore metaStore, Repository rep, boolean setInternalVariables,
VariableSpace parentVariableSpace, OverwritePrompter prompter ); byte[] getKey(); void setKey( byte[] key ); boolean isPrivateKey(); void setPrivateKey( boolean privateKey ); @Override boolean loadSharedObject( SharedObjectInterface object ); List<StepMeta> getTransHopSteps( boolean all ); boolean isStepUsedInTransHops( StepMeta stepMeta ); boolean isAnySelectedStepUsedInTransHops(); @Override void clearChanged(); boolean haveStepsChanged(); boolean haveHopsChanged(); boolean havePartitionSchemasChanged(); boolean haveClusterSchemasChanged(); @Override boolean hasChanged(); boolean hasLoop( StepMeta stepMeta ); void selectAll(); void unselectAll(); Point[] getSelectedStepLocations(); Point[] getSelectedNoteLocations(); List<StepMeta> getSelectedSteps(); String[] getSelectedStepNames(); int[] getStepIndexes( List<StepMeta> steps ); Point getMaximum(); Point getMinimum(); String[] getStepNames(); StepMeta[] getStepsArray(); boolean findPrevious( StepMeta startStep, StepMeta stepToFind ); void sortSteps(); void sortHops(); Map<StepMeta, Map<StepMeta, Boolean>> sortStepsNatural(); void sortHopsNatural(); void analyseImpact( List<DatabaseImpact> impact, ProgressMonitorListener monitor ); String getAlternativeStepname( String stepname ); List<SQLStatement> getSQLStatements(); List<SQLStatement> getSQLStatements( ProgressMonitorListener monitor ); String getSQLStatementsString(); @Deprecated void checkSteps( List<CheckResultInterface> remarks, boolean only_selected, ProgressMonitorListener monitor ); void checkSteps( List<CheckResultInterface> remarks, boolean only_selected, ProgressMonitorListener monitor,
VariableSpace space, Repository repository, IMetaStore metaStore ); @Deprecated List<RowMetaAndData> getResultRows(); @Deprecated void setResultRows( List<RowMetaAndData> resultRows ); String getPathAndName(); @Deprecated String[] getArguments(); @Deprecated void setArguments( String[] arguments ); @Deprecated Hashtable<String, Counter> getCounters(); @Deprecated void setCounters( Hashtable<String, Counter> counters ); List<TransDependency> getDependencies(); void setDependencies( List<TransDependency> dependencies ); DatabaseMeta getMaxDateConnection(); void setMaxDateConnection( DatabaseMeta maxDateConnection ); double getMaxDateDifference(); void setMaxDateDifference( double maxDateDifference ); String getMaxDateField(); void setMaxDateField( String maxDateField ); double getMaxDateOffset(); void setMaxDateOffset( double maxDateOffset ); String getMaxDateTable(); void setMaxDateTable( String maxDateTable ); int getSizeRowset(); void setSizeRowset( int sizeRowset ); DBCache getDbCache(); void setDbCache( DBCache dbCache ); String getTransversion(); void setTransversion( String n ); void setTransstatus( int n ); int getTransstatus(); @Override String toString(); void cancelQueries(); Map<String, String> getUsedArguments( String[] arguments ); int getSleepTimeEmpty(); int getSleepTimeFull(); void setSleepTimeEmpty( int sleepTimeEmpty ); void setSleepTimeFull( int sleepTimeFull ); boolean isDatabaseConnectionUsed( DatabaseMeta databaseMeta ); List<StringSearchResult> getStringList( boolean searchSteps, boolean searchDatabases, boolean searchNotes,
boolean includePasswords ); List<StringSearchResult> getStringList( boolean searchSteps, boolean searchDatabases, boolean searchNotes ); List<String> getUsedVariables(); @Deprecated Result getPreviousResult(); @Deprecated void setPreviousResult( Result previousResult ); @Deprecated List<ResultFile> getResultFiles(); @Deprecated void setResultFiles( List<ResultFile> resultFiles ); List<PartitionSchema> getPartitionSchemas(); void setPartitionSchemas( List<PartitionSchema> partitionSchemas ); String[] getPartitionSchemasNames(); boolean isFeedbackShown(); void setFeedbackShown( boolean feedbackShown ); int getFeedbackSize(); void setFeedbackSize( int feedbackSize ); boolean isUsingUniqueConnections(); void setUsingUniqueConnections( boolean usingUniqueConnections ); List<ClusterSchema> getClusterSchemas(); void setClusterSchemas( List<ClusterSchema> clusterSchemas ); String[] getClusterSchemaNames(); PartitionSchema findPartitionSchema( String name ); ClusterSchema findClusterSchema( String name ); void addOrReplacePartitionSchema( PartitionSchema partitionSchema ); void addOrReplaceClusterSchema( ClusterSchema clusterSchema ); boolean isUsingThreadPriorityManagment(); void setUsingThreadPriorityManagment( boolean usingThreadPriorityManagment ); void checkRowMixingStatically( StepMeta stepMeta, ProgressMonitorListener monitor ); @Override void setInternalKettleVariables( VariableSpace var ); StepMeta findMappingInputStep( String stepname ); StepMeta findMappingOutputStep( String stepname ); List<ResourceReference> getResourceDependencies(); @Override String exportResources( VariableSpace space, Map<String, ResourceDefinition> definitions,
ResourceNamingInterface resourceNamingInterface, Repository repository, IMetaStore metaStore ); SlaveStepCopyPartitionDistribution getSlaveStepCopyPartitionDistribution(); void setSlaveStepCopyPartitionDistribution(
SlaveStepCopyPartitionDistribution slaveStepCopyPartitionDistribution ); ClusterSchema findFirstUsedClusterSchema(); boolean isSlaveTransformation(); void setSlaveTransformation( boolean slaveTransformation ); boolean isCapturingStepPerformanceSnapShots(); void setCapturingStepPerformanceSnapShots( boolean capturingStepPerformanceSnapShots ); long getStepPerformanceCapturingDelay(); void setStepPerformanceCapturingDelay( long stepPerformanceCapturingDelay ); String getStepPerformanceCapturingSizeLimit(); void setStepPerformanceCapturingSizeLimit( String stepPerformanceCapturingSizeLimit ); void clearCaches(); @Override RepositoryObjectType getRepositoryElementType(); LogChannelInterface getLogChannel(); @Override String getLogChannelId(); @Override LoggingObjectType getObjectType(); TransLogTable getTransLogTable(); void setTransLogTable( TransLogTable transLogTable ); PerformanceLogTable getPerformanceLogTable(); void setPerformanceLogTable( PerformanceLogTable performanceLogTable ); StepLogTable getStepLogTable(); void setStepLogTable( StepLogTable stepLogTable ); List<LogTableInterface> getLogTables(); TransformationType getTransformationType(); void setTransformationType( TransformationType transformationType ); void writeXML( String filename ); boolean hasRepositoryReferences(); void lookupRepositoryReferences( Repository repository ); MetricsLogTable getMetricsLogTable(); void setMetricsLogTable( MetricsLogTable metricsLogTable ); @Override boolean isGatheringMetrics(); @Override void setGatheringMetrics( boolean gatheringMetrics ); @Override boolean isForcingSeparateLogging(); @Override void setForcingSeparateLogging( boolean forcingSeparateLogging ); void addStepChangeListener( StepMetaChangeListenerInterface listener ); void addStepChangeListener( int p, StepMetaChangeListenerInterface list ); void removeStepChangeListener( StepMetaChangeListenerInterface list ); void notifyAllListeners( StepMeta oldMeta, StepMeta newMeta ); boolean containsStepMeta( StepMeta stepMeta ); List<MissingTrans> getMissingTrans(); void addMissingTrans( MissingTrans trans ); void removeMissingTrans( MissingTrans trans ); @Override boolean hasMissingPlugins(); @Override NamedClusterEmbedManager getNamedClusterEmbedManager( ); static final String XML_TAG; static final String STRING_TRANSMETA; static final RepositoryObjectType REPOSITORY_ELEMENT_TYPE; static final int BORDER_INDENT; static final String[] desc_type_undo; static final String XML_TAG_ORDER; static final String XML_TAG_NOTEPADS; static final String XML_TAG_PARAMETERS; static final String XML_TAG_PARTITIONSCHEMAS; static final String XML_TAG_SLAVESERVERS; static final String XML_TAG_CLUSTERSCHEMAS; static final String XML_TAG_STEP_ERROR_HANDLING; }
|
@Test public void testLoadXml() throws KettleException { String directory = "/home/admin"; Node jobNode = Mockito.mock( Node.class ); NodeList nodeList = new NodeList() { ArrayList<Node> nodes = new ArrayList<>( ); { Node nodeInfo = Mockito.mock( Node.class ); Mockito.when( nodeInfo.getNodeName() ).thenReturn( TransMeta.XML_TAG_INFO ); Mockito.when( nodeInfo.getChildNodes() ).thenReturn( this ); Node nodeDirectory = Mockito.mock( Node.class ); Mockito.when( nodeDirectory.getNodeName() ).thenReturn( "directory" ); Node child = Mockito.mock( Node.class ); Mockito.when( nodeDirectory.getFirstChild() ).thenReturn( child ); Mockito.when( child.getNodeValue() ).thenReturn( directory ); nodes.add( nodeDirectory ); nodes.add( nodeInfo ); } @Override public Node item( int index ) { return nodes.get( index ); } @Override public int getLength() { return nodes.size(); } }; Mockito.when( jobNode.getChildNodes() ).thenReturn( nodeList ); Repository rep = Mockito.mock( Repository.class ); RepositoryDirectory repDirectory = new RepositoryDirectory( new RepositoryDirectory( new RepositoryDirectory(), "home" ), "admin" ); Mockito.when( rep.findDirectory( Mockito.eq( directory ) ) ).thenReturn( repDirectory ); TransMeta meta = new TransMeta(); VariableSpace variableSpace = Mockito.mock( VariableSpace.class ); Mockito.when( variableSpace.listVariables() ).thenReturn( new String[0] ); meta.loadXML( jobNode, null, Mockito.mock( IMetaStore.class ), rep, false, variableSpace, Mockito.mock( OverwritePrompter.class ) ); meta.setInternalKettleVariables( null ); Assert.assertEquals( repDirectory.getPath(), meta.getVariable( Const.INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY ) ); }
|
TransMeta extends AbstractMeta implements XMLInterface, Comparator<TransMeta>, Comparable<TransMeta>, Cloneable, ResourceExportInterface,
RepositoryElementInterface, LoggingObjectInterface { public List<StepMeta> getUsedSteps() { List<StepMeta> list = new ArrayList<>(); for ( StepMeta stepMeta : steps ) { if ( isStepUsedInTransHops( stepMeta ) ) { list.add( stepMeta ); } } if ( list.isEmpty() && getSteps().size() == 1 ) { list = getSteps(); } return list; } TransMeta(); TransMeta( VariableSpace parent ); TransMeta( String filename, String name ); @Deprecated TransMeta( String filename, String name, String[] arguments ); TransMeta( String fname ); TransMeta( String fname, VariableSpace parentVariableSpace ); TransMeta( String fname, boolean setInternalVariables ); TransMeta( String fname, Repository rep ); TransMeta( String fname, Repository rep, boolean setInternalVariables ); TransMeta( String fname, Repository rep, boolean setInternalVariables, VariableSpace parentVariableSpace ); TransMeta( String fname, Repository rep, boolean setInternalVariables, VariableSpace parentVariableSpace,
OverwritePrompter prompter ); TransMeta( String fname, IMetaStore metaStore, Repository rep, boolean setInternalVariables,
VariableSpace parentVariableSpace, OverwritePrompter prompter ); TransMeta( InputStream xmlStream, Repository rep, boolean setInternalVariables,
VariableSpace parentVariableSpace, OverwritePrompter prompter ); TransMeta( Node transnode, Repository rep ); @Override int compare( TransMeta t1, TransMeta t2 ); @Override int compareTo( TransMeta o ); @Override boolean equals( Object obj ); @Override Object clone(); Object realClone( boolean doClear ); @Override void clear(); void addStep( StepMeta stepMeta ); void addOrReplaceStep( StepMeta stepMeta ); void addTransHop( TransHopMeta hi ); void addDependency( TransDependency td ); void addStep( int p, StepMeta stepMeta ); void addTransHop( int p, TransHopMeta hi ); void addDependency( int p, TransDependency td ); List<StepMeta> getSteps(); StepMeta getStep( int i ); TransHopMeta getTransHop( int i ); TransDependency getDependency( int i ); void removeStep( int i ); void removeTransHop( int i ); void removeTransHop( TransHopMeta hop ); void removeDependency( int i ); void removeAllDependencies(); int nrSteps(); int nrTransHops(); int nrDependencies(); int nrStepChangeListeners(); void setStep( int i, StepMeta stepMeta ); void setTransHop( int i, TransHopMeta hi ); List<StepMeta> getUsedSteps(); StepMeta findStep( String name ); StepMeta findStep( String name, StepMeta exclude ); TransHopMeta findTransHop( String name ); TransHopMeta findTransHopFrom( StepMeta fromstep ); List<TransHopMeta> findAllTransHopFrom( StepMeta fromstep ); TransHopMeta findTransHop( TransHopMeta hi ); TransHopMeta findTransHop( StepMeta from, StepMeta to ); TransHopMeta findTransHop( StepMeta from, StepMeta to, boolean disabledToo ); TransHopMeta findTransHopTo( StepMeta tostep ); boolean isStepInformative( StepMeta this_step, StepMeta prev_step ); @Deprecated int findNrPrevSteps( String stepname ); @Deprecated int findNrPrevSteps( String stepname, boolean info ); int findNrPrevSteps( StepMeta stepMeta ); @Deprecated StepMeta findPrevStep( String stepname, int nr ); @Deprecated StepMeta findPrevStep( String stepname, int nr, boolean info ); StepMeta findPrevStep( StepMeta stepMeta, int nr ); @Deprecated int findNrPrevSteps( StepMeta stepMeta, boolean info ); @Deprecated StepMeta findPrevStep( StepMeta stepMeta, int nr, boolean info ); List<StepMeta> findPreviousSteps( StepMeta stepMeta ); List<StepMeta> findPreviousSteps( StepMeta stepMeta, boolean info ); StepMeta[] getInfoStep( StepMeta stepMeta ); int findNrInfoSteps( StepMeta stepMeta ); RowMetaInterface getPrevInfoFields( String stepname ); RowMetaInterface getPrevInfoFields( StepMeta stepMeta ); @Deprecated int findNrNextSteps( StepMeta stepMeta ); @Deprecated StepMeta findNextStep( StepMeta stepMeta, int nr ); StepMeta[] getPrevSteps( StepMeta stepMeta ); String[] getPrevStepNames( String stepname ); String[] getPrevStepNames( StepMeta stepMeta ); @Deprecated StepMeta[] getNextSteps( StepMeta stepMeta ); List<StepMeta> findNextSteps( StepMeta stepMeta ); String[] getNextStepNames( StepMeta stepMeta ); StepMeta getStep( int x, int y, int iconsize ); boolean partOfTransHop( StepMeta stepMeta ); RowMetaInterface getStepFields( String stepname ); RowMetaInterface getStepFields( StepMeta stepMeta ); RowMetaInterface getStepFields( StepMeta[] stepMeta ); RowMetaInterface getStepFields( StepMeta stepMeta, ProgressMonitorListener monitor ); RowMetaInterface getStepFields( StepMeta stepMeta, StepMeta targetStep, ProgressMonitorListener monitor ); RowMetaInterface getPrevStepFields( String stepname ); RowMetaInterface getPrevStepFields( StepMeta stepMeta ); RowMetaInterface getPrevStepFields( StepMeta stepMeta, ProgressMonitorListener monitor ); RowMetaInterface getThisStepFields( String stepname, RowMetaInterface row ); RowMetaInterface getThisStepFields( StepMeta stepMeta, StepMeta nextStep, RowMetaInterface row ); RowMetaInterface getThisStepFields( StepMeta stepMeta, StepMeta nextStep, RowMetaInterface row,
ProgressMonitorListener monitor ); boolean isUsingPartitionSchema( PartitionSchema partitionSchema ); boolean isUsingAClusterSchema(); boolean isUsingClusterSchema( ClusterSchema clusterSchema ); boolean isUsingSlaveServer( SlaveServer slaveServer ); boolean isRepReference(); boolean isFileReference(); static boolean isRepReference( String exactFilename, String exactTransname ); static boolean isFileReference( String exactFilename, String exactTransname ); int indexOfTransHop( TransHopMeta hi ); int indexOfStep( StepMeta stepMeta ); @Override String getFileType(); @Override String[] getFilterNames(); @Override String[] getFilterExtensions(); @Override String getDefaultExtension(); @Override String getXML(); String getXML( boolean includeSteps, boolean includeDatabase, boolean includeSlaves, boolean includeClusters,
boolean includePartitions ); void loadXML( Node transnode, Repository rep, boolean setInternalVariables ); void loadXML( Node transnode, Repository rep, boolean setInternalVariables, VariableSpace parentVariableSpace ); void loadXML( Node transnode, Repository rep, boolean setInternalVariables, VariableSpace parentVariableSpace,
OverwritePrompter prompter ); void loadXML( Node transnode, String fname, Repository rep, boolean setInternalVariables,
VariableSpace parentVariableSpace, OverwritePrompter prompter ); void loadXML( Node transnode, String fname, IMetaStore metaStore, Repository rep, boolean setInternalVariables,
VariableSpace parentVariableSpace, OverwritePrompter prompter ); byte[] getKey(); void setKey( byte[] key ); boolean isPrivateKey(); void setPrivateKey( boolean privateKey ); @Override boolean loadSharedObject( SharedObjectInterface object ); List<StepMeta> getTransHopSteps( boolean all ); boolean isStepUsedInTransHops( StepMeta stepMeta ); boolean isAnySelectedStepUsedInTransHops(); @Override void clearChanged(); boolean haveStepsChanged(); boolean haveHopsChanged(); boolean havePartitionSchemasChanged(); boolean haveClusterSchemasChanged(); @Override boolean hasChanged(); boolean hasLoop( StepMeta stepMeta ); void selectAll(); void unselectAll(); Point[] getSelectedStepLocations(); Point[] getSelectedNoteLocations(); List<StepMeta> getSelectedSteps(); String[] getSelectedStepNames(); int[] getStepIndexes( List<StepMeta> steps ); Point getMaximum(); Point getMinimum(); String[] getStepNames(); StepMeta[] getStepsArray(); boolean findPrevious( StepMeta startStep, StepMeta stepToFind ); void sortSteps(); void sortHops(); Map<StepMeta, Map<StepMeta, Boolean>> sortStepsNatural(); void sortHopsNatural(); void analyseImpact( List<DatabaseImpact> impact, ProgressMonitorListener monitor ); String getAlternativeStepname( String stepname ); List<SQLStatement> getSQLStatements(); List<SQLStatement> getSQLStatements( ProgressMonitorListener monitor ); String getSQLStatementsString(); @Deprecated void checkSteps( List<CheckResultInterface> remarks, boolean only_selected, ProgressMonitorListener monitor ); void checkSteps( List<CheckResultInterface> remarks, boolean only_selected, ProgressMonitorListener monitor,
VariableSpace space, Repository repository, IMetaStore metaStore ); @Deprecated List<RowMetaAndData> getResultRows(); @Deprecated void setResultRows( List<RowMetaAndData> resultRows ); String getPathAndName(); @Deprecated String[] getArguments(); @Deprecated void setArguments( String[] arguments ); @Deprecated Hashtable<String, Counter> getCounters(); @Deprecated void setCounters( Hashtable<String, Counter> counters ); List<TransDependency> getDependencies(); void setDependencies( List<TransDependency> dependencies ); DatabaseMeta getMaxDateConnection(); void setMaxDateConnection( DatabaseMeta maxDateConnection ); double getMaxDateDifference(); void setMaxDateDifference( double maxDateDifference ); String getMaxDateField(); void setMaxDateField( String maxDateField ); double getMaxDateOffset(); void setMaxDateOffset( double maxDateOffset ); String getMaxDateTable(); void setMaxDateTable( String maxDateTable ); int getSizeRowset(); void setSizeRowset( int sizeRowset ); DBCache getDbCache(); void setDbCache( DBCache dbCache ); String getTransversion(); void setTransversion( String n ); void setTransstatus( int n ); int getTransstatus(); @Override String toString(); void cancelQueries(); Map<String, String> getUsedArguments( String[] arguments ); int getSleepTimeEmpty(); int getSleepTimeFull(); void setSleepTimeEmpty( int sleepTimeEmpty ); void setSleepTimeFull( int sleepTimeFull ); boolean isDatabaseConnectionUsed( DatabaseMeta databaseMeta ); List<StringSearchResult> getStringList( boolean searchSteps, boolean searchDatabases, boolean searchNotes,
boolean includePasswords ); List<StringSearchResult> getStringList( boolean searchSteps, boolean searchDatabases, boolean searchNotes ); List<String> getUsedVariables(); @Deprecated Result getPreviousResult(); @Deprecated void setPreviousResult( Result previousResult ); @Deprecated List<ResultFile> getResultFiles(); @Deprecated void setResultFiles( List<ResultFile> resultFiles ); List<PartitionSchema> getPartitionSchemas(); void setPartitionSchemas( List<PartitionSchema> partitionSchemas ); String[] getPartitionSchemasNames(); boolean isFeedbackShown(); void setFeedbackShown( boolean feedbackShown ); int getFeedbackSize(); void setFeedbackSize( int feedbackSize ); boolean isUsingUniqueConnections(); void setUsingUniqueConnections( boolean usingUniqueConnections ); List<ClusterSchema> getClusterSchemas(); void setClusterSchemas( List<ClusterSchema> clusterSchemas ); String[] getClusterSchemaNames(); PartitionSchema findPartitionSchema( String name ); ClusterSchema findClusterSchema( String name ); void addOrReplacePartitionSchema( PartitionSchema partitionSchema ); void addOrReplaceClusterSchema( ClusterSchema clusterSchema ); boolean isUsingThreadPriorityManagment(); void setUsingThreadPriorityManagment( boolean usingThreadPriorityManagment ); void checkRowMixingStatically( StepMeta stepMeta, ProgressMonitorListener monitor ); @Override void setInternalKettleVariables( VariableSpace var ); StepMeta findMappingInputStep( String stepname ); StepMeta findMappingOutputStep( String stepname ); List<ResourceReference> getResourceDependencies(); @Override String exportResources( VariableSpace space, Map<String, ResourceDefinition> definitions,
ResourceNamingInterface resourceNamingInterface, Repository repository, IMetaStore metaStore ); SlaveStepCopyPartitionDistribution getSlaveStepCopyPartitionDistribution(); void setSlaveStepCopyPartitionDistribution(
SlaveStepCopyPartitionDistribution slaveStepCopyPartitionDistribution ); ClusterSchema findFirstUsedClusterSchema(); boolean isSlaveTransformation(); void setSlaveTransformation( boolean slaveTransformation ); boolean isCapturingStepPerformanceSnapShots(); void setCapturingStepPerformanceSnapShots( boolean capturingStepPerformanceSnapShots ); long getStepPerformanceCapturingDelay(); void setStepPerformanceCapturingDelay( long stepPerformanceCapturingDelay ); String getStepPerformanceCapturingSizeLimit(); void setStepPerformanceCapturingSizeLimit( String stepPerformanceCapturingSizeLimit ); void clearCaches(); @Override RepositoryObjectType getRepositoryElementType(); LogChannelInterface getLogChannel(); @Override String getLogChannelId(); @Override LoggingObjectType getObjectType(); TransLogTable getTransLogTable(); void setTransLogTable( TransLogTable transLogTable ); PerformanceLogTable getPerformanceLogTable(); void setPerformanceLogTable( PerformanceLogTable performanceLogTable ); StepLogTable getStepLogTable(); void setStepLogTable( StepLogTable stepLogTable ); List<LogTableInterface> getLogTables(); TransformationType getTransformationType(); void setTransformationType( TransformationType transformationType ); void writeXML( String filename ); boolean hasRepositoryReferences(); void lookupRepositoryReferences( Repository repository ); MetricsLogTable getMetricsLogTable(); void setMetricsLogTable( MetricsLogTable metricsLogTable ); @Override boolean isGatheringMetrics(); @Override void setGatheringMetrics( boolean gatheringMetrics ); @Override boolean isForcingSeparateLogging(); @Override void setForcingSeparateLogging( boolean forcingSeparateLogging ); void addStepChangeListener( StepMetaChangeListenerInterface listener ); void addStepChangeListener( int p, StepMetaChangeListenerInterface list ); void removeStepChangeListener( StepMetaChangeListenerInterface list ); void notifyAllListeners( StepMeta oldMeta, StepMeta newMeta ); boolean containsStepMeta( StepMeta stepMeta ); List<MissingTrans> getMissingTrans(); void addMissingTrans( MissingTrans trans ); void removeMissingTrans( MissingTrans trans ); @Override boolean hasMissingPlugins(); @Override NamedClusterEmbedManager getNamedClusterEmbedManager( ); static final String XML_TAG; static final String STRING_TRANSMETA; static final RepositoryObjectType REPOSITORY_ELEMENT_TYPE; static final int BORDER_INDENT; static final String[] desc_type_undo; static final String XML_TAG_ORDER; static final String XML_TAG_NOTEPADS; static final String XML_TAG_PARAMETERS; static final String XML_TAG_PARTITIONSCHEMAS; static final String XML_TAG_SLAVESERVERS; static final String XML_TAG_CLUSTERSCHEMAS; static final String XML_TAG_STEP_ERROR_HANDLING; }
|
@Test public void testTransWithOneStepIsConsideredUsed() throws Exception { TransMeta transMeta = new TransMeta( getClass().getResource( "one-step-trans.ktr" ).getPath() ); assertEquals( 1, transMeta.getUsedSteps().size() ); }
|
ZipFileMeta extends BaseStepMeta implements StepMetaInterface { public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException { readData( stepnode ); } ZipFileMeta(); String getDynamicSourceFileNameField(); void setDynamicSourceFileNameField( String sourcefilenamefield ); String getBaseFolderField(); void setBaseFolderField( String baseFolderField ); String getMoveToFolderField(); void setMoveToFolderField( String movetofolderfield ); String getDynamicTargetFileNameField(); void setDynamicTargetFileNameField( String targetfilenamefield ); boolean isaddTargetFileNametoResult(); boolean isOverwriteZipEntry(); boolean isCreateParentFolder(); boolean isKeepSouceFolder(); void setKeepSouceFolder( boolean value ); void setaddTargetFileNametoResult( boolean addresultfilenames ); void setOverwriteZipEntry( boolean overwritezipentry ); void setCreateParentFolder( boolean createparentfolder ); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); Object clone(); void setDefault(); String getXML(); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ); StepDataInterface getStepData(); boolean supportsErrorHandling(); int getOperationType(); static int getOperationTypeByDesc( String tt ); void setOperationType( int operationType ); static String getOperationTypeDesc( int i ); static final String[] operationTypeDesc; static final String[] operationTypeCode; static final int OPERATION_TYPE_NOTHING; static final int OPERATION_TYPE_MOVE; static final int OPERATION_TYPE_DELETE; }
|
@Test public void testLoadAndGetXml() throws Exception { ZipFileMeta zipFileMeta = new ZipFileMeta(); Node stepnode = getTestNode(); DatabaseMeta dbMeta = mock( DatabaseMeta.class ); IMetaStore metaStore = mock( IMetaStore.class ); StepMeta mockParentStepMeta = mock( StepMeta.class ); zipFileMeta.setParentStepMeta( mockParentStepMeta ); TransMeta mockTransMeta = mock( TransMeta.class ); NamedClusterEmbedManager embedManager = mock( NamedClusterEmbedManager.class ); when( mockParentStepMeta.getParentTransMeta() ).thenReturn( mockTransMeta ); when( mockTransMeta.getNamedClusterEmbedManager() ).thenReturn( embedManager ); zipFileMeta.loadXML( stepnode, Collections.singletonList( dbMeta ), metaStore ); assertXmlOutputMeta( zipFileMeta ); }
|
ZipFileMeta extends BaseStepMeta implements StepMetaInterface { public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException { try { sourcefilenamefield = rep.getStepAttributeString( id_step, "sourcefilenamefield" ); targetfilenamefield = rep.getStepAttributeString( id_step, "targetfilenamefield" ); baseFolderField = rep.getStepAttributeString( id_step, "baseFolderField" ); operationType = getOperationTypeByCode( Const.NVL( rep.getStepAttributeString( id_step, "operation_type" ), "" ) ); addresultfilenames = rep.getStepAttributeBoolean( id_step, "addresultfilenames" ); overwritezipentry = rep.getStepAttributeBoolean( id_step, "overwritezipentry" ); createparentfolder = rep.getStepAttributeBoolean( id_step, "createparentfolder" ); keepsourcefolder = rep.getStepAttributeBoolean( id_step, "keepsourcefolder" ); movetofolderfield = rep.getStepAttributeString( id_step, "movetofolderfield" ); } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "ZipFileMeta.Exception.UnexpectedErrorReadingStepInfo" ), e ); } } ZipFileMeta(); String getDynamicSourceFileNameField(); void setDynamicSourceFileNameField( String sourcefilenamefield ); String getBaseFolderField(); void setBaseFolderField( String baseFolderField ); String getMoveToFolderField(); void setMoveToFolderField( String movetofolderfield ); String getDynamicTargetFileNameField(); void setDynamicTargetFileNameField( String targetfilenamefield ); boolean isaddTargetFileNametoResult(); boolean isOverwriteZipEntry(); boolean isCreateParentFolder(); boolean isKeepSouceFolder(); void setKeepSouceFolder( boolean value ); void setaddTargetFileNametoResult( boolean addresultfilenames ); void setOverwriteZipEntry( boolean overwritezipentry ); void setCreateParentFolder( boolean createparentfolder ); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); Object clone(); void setDefault(); String getXML(); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ); StepDataInterface getStepData(); boolean supportsErrorHandling(); int getOperationType(); static int getOperationTypeByDesc( String tt ); void setOperationType( int operationType ); static String getOperationTypeDesc( int i ); static final String[] operationTypeDesc; static final String[] operationTypeCode; static final int OPERATION_TYPE_NOTHING; static final int OPERATION_TYPE_MOVE; static final int OPERATION_TYPE_DELETE; }
|
@Test public void testReadRep() throws Exception { ZipFileMeta zipFileMeta = new ZipFileMeta(); Repository rep = mock( Repository.class ); IMetaStore metastore = mock( IMetaStore.class ); DatabaseMeta dbMeta = mock( DatabaseMeta.class ); StringObjectId oid = new StringObjectId( "oid" ); when( rep.getStepAttributeString( oid, "sourcefilenamefield" ) ).thenReturn( SOURCE_FILENAME ); when( rep.getStepAttributeString( oid, "targetfilenamefield" ) ).thenReturn( TARGET_FILENAME ); when( rep.getStepAttributeString( oid, "baseFolderField" ) ).thenReturn( BASE_FOLDER ); when( rep.getStepAttributeString( oid, "operation_type" ) ).thenReturn( OPERATION_TYPE ); when( rep.getStepAttributeBoolean( oid, "addresultfilenames" ) ).thenReturn( ADD_RESULT_FILENAME ); when( rep.getStepAttributeBoolean( oid, "overwritezipentry" ) ).thenReturn( OVERWRITE_ZIP_ENTRY ); when( rep.getStepAttributeBoolean( oid, "createparentfolder" ) ).thenReturn( CREATE_PARENT_FOLDER ); when( rep.getStepAttributeBoolean( oid, "keepsourcefolder" ) ).thenReturn( KEEP_SOURCE_FOLDER ); when( rep.getStepAttributeString( oid, "movetofolderfield" ) ).thenReturn( MOVE_TO_FOLDER_FIELD ); zipFileMeta.readRep( rep, metastore, oid, Collections.singletonList( dbMeta ) ); assertEquals( SOURCE_FILENAME, zipFileMeta.getDynamicSourceFileNameField() ); assertEquals( TARGET_FILENAME, zipFileMeta.getDynamicTargetFileNameField() ); assertEquals( BASE_FOLDER, zipFileMeta.getBaseFolderField() ); assertEquals( ZipFileMeta.getOperationTypeByDesc( OPERATION_TYPE ), zipFileMeta.getOperationType() ); assertEquals( MOVE_TO_FOLDER_FIELD, zipFileMeta.getMoveToFolderField() ); assertTrue( zipFileMeta.isaddTargetFileNametoResult() ); assertTrue( zipFileMeta.isOverwriteZipEntry() ); assertTrue( zipFileMeta.isKeepSouceFolder() ); assertTrue( zipFileMeta.isCreateParentFolder() ); Mockito.reset( rep, metastore ); StringObjectId transid = new StringObjectId( "transid" ); zipFileMeta.saveRep( rep, metastore, transid, oid ); verify( rep ).saveStepAttribute( transid, oid, "sourcefilenamefield", SOURCE_FILENAME ); verify( rep ).saveStepAttribute( transid, oid, "targetfilenamefield", TARGET_FILENAME ); verify( rep ).saveStepAttribute( transid, oid, "baseFolderField", BASE_FOLDER ); verify( rep ).saveStepAttribute( transid, oid, "operation_type", OPERATION_TYPE ); verify( rep ).saveStepAttribute( transid, oid, "addresultfilenames", ADD_RESULT_FILENAME ); verify( rep ).saveStepAttribute( transid, oid, "overwritezipentry", OVERWRITE_ZIP_ENTRY ); verify( rep ).saveStepAttribute( transid, oid, "createparentfolder", CREATE_PARENT_FOLDER ); verify( rep ).saveStepAttribute( transid, oid, "keepsourcefolder", KEEP_SOURCE_FOLDER ); verify( rep ).saveStepAttribute( transid, oid, "movetofolderfield", MOVE_TO_FOLDER_FIELD ); Mockito.verifyNoMoreInteractions( rep, metastore ); }
|
ZipFileMeta extends BaseStepMeta implements StepMetaInterface { public void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository, IMetaStore metaStore ) { CheckResult cr; String error_message = ""; if ( Utils.isEmpty( sourcefilenamefield ) ) { error_message = BaseMessages.getString( PKG, "ZipFileMeta.CheckResult.SourceFileFieldMissing" ); cr = new CheckResult( CheckResult.TYPE_RESULT_ERROR, error_message, stepMeta ); remarks.add( cr ); } else { error_message = BaseMessages.getString( PKG, "ZipFileMeta.CheckResult.TargetFileFieldOK" ); cr = new CheckResult( CheckResult.TYPE_RESULT_OK, error_message, stepMeta ); remarks.add( cr ); } if ( input.length > 0 ) { cr = new CheckResult( CheckResult.TYPE_RESULT_OK, BaseMessages.getString( PKG, "ZipFileMeta.CheckResult.ReceivingInfoFromOtherSteps" ), stepMeta ); remarks.add( cr ); } else { cr = new CheckResult( CheckResult.TYPE_RESULT_ERROR, BaseMessages.getString( PKG, "ZipFileMeta.CheckResult.NoInpuReceived" ), stepMeta ); remarks.add( cr ); } } ZipFileMeta(); String getDynamicSourceFileNameField(); void setDynamicSourceFileNameField( String sourcefilenamefield ); String getBaseFolderField(); void setBaseFolderField( String baseFolderField ); String getMoveToFolderField(); void setMoveToFolderField( String movetofolderfield ); String getDynamicTargetFileNameField(); void setDynamicTargetFileNameField( String targetfilenamefield ); boolean isaddTargetFileNametoResult(); boolean isOverwriteZipEntry(); boolean isCreateParentFolder(); boolean isKeepSouceFolder(); void setKeepSouceFolder( boolean value ); void setaddTargetFileNametoResult( boolean addresultfilenames ); void setOverwriteZipEntry( boolean overwritezipentry ); void setCreateParentFolder( boolean createparentfolder ); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); Object clone(); void setDefault(); String getXML(); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ); StepDataInterface getStepData(); boolean supportsErrorHandling(); int getOperationType(); static int getOperationTypeByDesc( String tt ); void setOperationType( int operationType ); static String getOperationTypeDesc( int i ); static final String[] operationTypeDesc; static final String[] operationTypeCode; static final int OPERATION_TYPE_NOTHING; static final int OPERATION_TYPE_MOVE; static final int OPERATION_TYPE_DELETE; }
|
@Test public void testCheck() { ZipFileMeta zipFileMeta = new ZipFileMeta(); zipFileMeta.setDefault(); TransMeta transMeta = mock( TransMeta.class ); StepMeta stepInfo = mock( StepMeta.class ); RowMetaInterface prev = mock( RowMetaInterface.class ); Repository repos = mock( Repository.class ); IMetaStore metastore = mock( IMetaStore.class ); RowMetaInterface info = mock( RowMetaInterface.class ); ArrayList<CheckResultInterface> remarks = new ArrayList<>(); zipFileMeta.check( remarks, transMeta, stepInfo, prev, new String[]{"input"}, new String[]{"output"}, info, new Variables(), repos, metastore ); assertEquals( 2, remarks.size() ); assertEquals( "Source Filename field is missing!", remarks.get( 0 ).getText() ); assertEquals( "Step is receiving info from other steps.", remarks.get( 1 ).getText() ); remarks = new ArrayList<>(); zipFileMeta = new ZipFileMeta(); zipFileMeta.setDynamicSourceFileNameField( "sourceFileField" ); zipFileMeta.check( remarks, transMeta, stepInfo, prev, new String[0], new String[]{"output"}, info, new Variables(), repos, metastore ); assertEquals( 2, remarks.size() ); assertEquals( "Target Filename field was specified", remarks.get( 0 ).getText() ); assertEquals( "No input received from other steps!", remarks.get( 1 ).getText() ); }
|
DataHandler extends AbstractXulEventHandler { public void onPoolingCheck() { if ( poolingCheck != null ) { boolean dis = !poolingCheck.isChecked(); if ( poolSizeBox != null ) { poolSizeBox.setDisabled( dis ); } if ( maxPoolSizeBox != null ) { maxPoolSizeBox.setDisabled( dis ); } if ( poolSizeLabel != null ) { poolSizeLabel.setDisabled( dis ); } if ( maxPoolSizeLabel != null ) { maxPoolSizeLabel.setDisabled( dis ); } if ( poolParameterTree != null ) { poolParameterTree.setDisabled( dis ); } if ( poolingParameterDescriptionLabel != null ) { poolingParameterDescriptionLabel.setDisabled( dis ); } if ( poolingDescriptionLabel != null ) { poolingDescriptionLabel.setDisabled( dis ); } if ( poolingDescription != null ) { poolingDescription.setDisabled( dis ); } } } DataHandler(); void loadConnectionData(); void loadAccessData(); void editOptions( int index ); void clearOptionsData(); void getOptionHelp(); void setDeckChildIndex(); void onPoolingCheck(); void onClusterCheck(); Object getData(); void setData( Object data ); void pushCache(); void popCache(); void onCancel(); void onOK(); void testDatabaseConnection(); void restoreDefaults(); void poolingRowChange( int idx ); void disablePortIfInstancePopulated(); void handleUseSecurityCheckbox(); static final SortedMap<String, DatabaseInterface> connectionMap; static final Map<String, String> connectionNametoID; }
|
@Test public void testOnPoolingCheck() throws Exception { }
|
ZipFileMeta extends BaseStepMeta implements StepMetaInterface { public StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta transMeta, Trans trans ) { return new ZipFile( stepMeta, stepDataInterface, cnr, transMeta, trans ); } ZipFileMeta(); String getDynamicSourceFileNameField(); void setDynamicSourceFileNameField( String sourcefilenamefield ); String getBaseFolderField(); void setBaseFolderField( String baseFolderField ); String getMoveToFolderField(); void setMoveToFolderField( String movetofolderfield ); String getDynamicTargetFileNameField(); void setDynamicTargetFileNameField( String targetfilenamefield ); boolean isaddTargetFileNametoResult(); boolean isOverwriteZipEntry(); boolean isCreateParentFolder(); boolean isKeepSouceFolder(); void setKeepSouceFolder( boolean value ); void setaddTargetFileNametoResult( boolean addresultfilenames ); void setOverwriteZipEntry( boolean overwritezipentry ); void setCreateParentFolder( boolean createparentfolder ); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); Object clone(); void setDefault(); String getXML(); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ); StepDataInterface getStepData(); boolean supportsErrorHandling(); int getOperationType(); static int getOperationTypeByDesc( String tt ); void setOperationType( int operationType ); static String getOperationTypeDesc( int i ); static final String[] operationTypeDesc; static final String[] operationTypeCode; static final int OPERATION_TYPE_NOTHING; static final int OPERATION_TYPE_MOVE; static final int OPERATION_TYPE_DELETE; }
|
@Test public void testGetStep() throws Exception { StepMeta stepInfo = mock( StepMeta.class ); when( stepInfo.getName() ).thenReturn( "Zip Step Name" ); StepDataInterface stepData = mock( StepDataInterface.class ); TransMeta transMeta = mock( TransMeta.class ); when( transMeta.findStep( "Zip Step Name" ) ).thenReturn( stepInfo ); Trans trans = mock( Trans.class ); ZipFileMeta zipFileMeta = new ZipFileMeta(); ZipFile zipFile = (ZipFile) zipFileMeta.getStep( stepInfo, stepData, 0, transMeta, trans ); assertEquals( stepInfo, zipFile.getStepMeta() ); assertEquals( stepData, zipFile.getStepDataInterface() ); assertEquals( transMeta, zipFile.getTransMeta() ); assertEquals( trans, zipFile.getTrans() ); assertEquals( 0, zipFile.getCopy() ); }
|
TextFileOutput extends BaseStep implements StepInterface { protected boolean closeFile() { boolean retval = false; try { if ( data.writer != null ) { data.writer.flush(); if ( data.cmdProc != null ) { if ( log.isDebug() ) { logDebug( "Closing output stream" ); } data.writer.close(); if ( log.isDebug() ) { logDebug( "Closed output stream" ); } } } data.writer = null; if ( data.cmdProc != null ) { if ( log.isDebug() ) { logDebug( "Ending running external command" ); } int procStatus = data.cmdProc.waitFor(); try { data.cmdProc.getErrorStream().close(); data.cmdProc.getOutputStream().flush(); data.cmdProc.getOutputStream().close(); data.cmdProc.getInputStream().close(); } catch ( IOException e ) { if ( log.isDetailed() ) { logDetailed( "Warning: Error closing streams: " + e.getMessage() ); } } data.cmdProc = null; if ( log.isBasic() && procStatus != 0 ) { logBasic( "Command exit status: " + procStatus ); } } else { if ( log.isDebug() ) { logDebug( "Closing normal file ..." ); } if ( data.out != null ) { data.out.close(); } if ( data.fos != null ) { data.fos.close(); data.fos = null; } } retval = true; } catch ( Exception e ) { logError( "Exception trying to close file: " + e.toString() ); setErrors( 1 ); retval = false; } return retval; } TextFileOutput( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); synchronized boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); void writeRowToFile( RowMetaInterface rowMeta, Object[] r ); String buildFilename( String filename, boolean ziparchive ); void openNewFile( String baseFilename ); boolean checkPreviouslyOpened( String filename ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); boolean containsSeparatorOrEnclosure( byte[] source, byte[] separator, byte[] enclosure ); public TextFileOutputMeta meta; public TextFileOutputData data; }
|
@Test public void testCloseFileDataOutIsNullCase() { textFileOutput = new TextFileOutput( stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans ); textFileOutput.data = Mockito.mock( TextFileOutputData.class ); Assert.assertNull( textFileOutput.data.out ); textFileOutput.closeFile(); }
@Test public void testCloseFileDataOutIsNotNullCase() throws IOException { textFileOutput = new TextFileOutput( stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans ); textFileOutput.data = Mockito.mock( TextFileOutputData.class ); textFileOutput.data.out = Mockito.mock( CompressionOutputStream.class ); textFileOutput.closeFile(); Mockito.verify( textFileOutput.data.out, Mockito.times( 1 ) ).close(); }
|
TextFileOutput extends BaseStep implements StepInterface { public void writeRowToFile( RowMetaInterface rowMeta, Object[] r ) throws KettleStepException { try { if ( meta.getOutputFields() == null || meta.getOutputFields().length == 0 ) { for ( int i = 0; i < rowMeta.size(); i++ ) { if ( i > 0 && data.binarySeparator.length > 0 ) { data.writer.write( data.binarySeparator ); } ValueMetaInterface v = rowMeta.getValueMeta( i ); Object valueData = r[i]; writeField( v, valueData, null ); } data.writer.write( data.binaryNewline ); } else { for ( int i = 0; i < meta.getOutputFields().length; i++ ) { if ( i > 0 && data.binarySeparator.length > 0 ) { data.writer.write( data.binarySeparator ); } ValueMetaInterface v = rowMeta.getValueMeta( data.fieldnrs[i] ); Object valueData = r[data.fieldnrs[i]]; writeField( v, valueData, data.binaryNullValue[i] ); } data.writer.write( data.binaryNewline ); } incrementLinesOutput(); } catch ( Exception e ) { throw new KettleStepException( "Error writing line", e ); } } TextFileOutput( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); synchronized boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); void writeRowToFile( RowMetaInterface rowMeta, Object[] r ); String buildFilename( String filename, boolean ziparchive ); void openNewFile( String baseFilename ); boolean checkPreviouslyOpened( String filename ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); boolean containsSeparatorOrEnclosure( byte[] source, byte[] separator, byte[] enclosure ); public TextFileOutputMeta meta; public TextFileOutputData data; }
|
@Test public void testFastDumpDisableStreamEncodeTest() throws Exception { textFileOutput = new TextFileOutputTestHandler( stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans ); textFileOutput.meta = stepMockHelper.processRowsStepMetaInterface; String testString = "ÖÜä"; String inputEncode = "UTF-8"; String outputEncode = "Windows-1252"; Object[] rows = {testString.getBytes( inputEncode )}; ValueMetaBase valueMetaInterface = new ValueMetaBase( "test", ValueMetaInterface.TYPE_STRING ); valueMetaInterface.setStringEncoding( inputEncode ); valueMetaInterface.setStorageType( ValueMetaInterface.STORAGE_TYPE_BINARY_STRING ); valueMetaInterface.setStorageMetadata( new ValueMetaString() ); TextFileOutputData data = new TextFileOutputData(); data.binarySeparator = " ".getBytes(); data.binaryEnclosure = "\"".getBytes(); data.binaryNewline = "\n".getBytes(); textFileOutput.data = data; RowMeta rowMeta = new RowMeta(); rowMeta.addValueMeta( valueMetaInterface ); Mockito.doReturn( outputEncode ).when( stepMockHelper.processRowsStepMetaInterface ).getEncoding(); textFileOutput.data.writer = Mockito.mock( BufferedOutputStream.class ); textFileOutput.writeRowToFile( rowMeta, rows ); Mockito.verify( textFileOutput.data.writer, Mockito.times( 1 ) ).write( testString.getBytes( outputEncode ) ); }
|
Rest extends BaseStep implements StepInterface { MultivaluedMapImpl createMultivalueMap( String paramName, String paramValue ) { MultivaluedMapImpl queryParams = new MultivaluedMapImpl(); queryParams.add( paramName, UriComponent.encode( paramValue, UriComponent.Type.QUERY_PARAM ) ); return queryParams; } Rest( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta, Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
|
@Test public void testCreateMultivalueMap() { StepMeta stepMeta = new StepMeta(); stepMeta.setName( "TestRest" ); TransMeta transMeta = new TransMeta(); transMeta.setName( "TestRest" ); transMeta.addStep( stepMeta ); Rest rest = new Rest( stepMeta, Mockito.mock( StepDataInterface.class ), 1, transMeta, Mockito.mock( Trans.class ) ); MultivaluedMapImpl map = rest.createMultivalueMap( "param1", "{a:{[val1]}}" ); String val1 = map.getFirst( "param1" ); Assert.assertTrue( val1.contains( "%7D" ) ); }
|
JoinRows extends BaseStep implements StepInterface { public void dispose( StepMetaInterface smi, StepDataInterface sdi ) { meta = (JoinRowsMeta) smi; data = (JoinRowsData) sdi; if ( data.file != null ) { for ( int i = 1; i < data.file.length; i++ ) { if ( data.file[i] != null ) { data.file[i].delete(); } } } super.dispose( meta, data ); } JoinRows( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); @SuppressWarnings( "unchecked" ) void initialize(); Object[] getRowData( int filenr ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); @Override void batchComplete(); }
|
@Test public void checkThatMethodPerformedWithoutError() throws Exception { getJoinRows().dispose( meta, data ); }
@Test public void disposeDataFiles() throws Exception { File mockFile1 = mock( File.class ); File mockFile2 = mock( File.class ); data.file = new File[] {null, mockFile1, mockFile2}; getJoinRows().dispose( meta, data ); verify( mockFile1, times( 1 ) ).delete(); verify( mockFile2, times( 1 ) ).delete(); }
|
JoinRows extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (JoinRowsMeta) smi; data = (JoinRowsData) sdi; if ( first ) { first = false; initialize(); } if ( data.caching ) { if ( !cacheInputRow() ) { return false; } } else { if ( !outputRow() ) { return false; } } return true; } JoinRows( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); @SuppressWarnings( "unchecked" ) void initialize(); Object[] getRowData( int filenr ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); @Override void batchComplete(); }
|
@Test public void testJoinRowsStep() throws Exception { JoinRowsMeta joinRowsMeta = new JoinRowsMeta(); joinRowsMeta.setMainStepname( "main step name" ); joinRowsMeta.setPrefix( "out" ); joinRowsMeta.setCacheSize( 3 ); JoinRowsData joinRowsData = new JoinRowsData(); JoinRows joinRows = getJoinRows(); joinRows.getTrans().setRunning( true ); joinRows.init( joinRowsMeta, joinRowsData ); List<RowSet> rowSets = new ArrayList<>(); rowSets.add( getRowSetWithData( 3, "main --", true ) ); rowSets.add( getRowSetWithData( 3, "secondary --", false ) ); joinRows.setInputRowSets( rowSets ); RowStepCollector rowStepCollector = new RowStepCollector(); joinRows.addRowListener( rowStepCollector ); joinRows.getLogChannel().setLogLevel( LogLevel.ROWLEVEL ); KettleLogStore.init(); while ( true ) { if ( !joinRows.processRow( joinRowsMeta, joinRowsData ) ) { break; } } rowStepCollector.getRowsWritten(); assertEquals( 9, rowStepCollector.getRowsWritten().size() ); assertEquals( 6, rowStepCollector.getRowsRead().size() ); Object[][] expectedResult = createExpectedResult(); List<Object[]> rowWritten = rowStepCollector.getRowsWritten().stream().map( RowMetaAndData::getData ).collect( Collectors.toList() ); for ( int i = 0; i < 9; i++ ) { assertTrue( Arrays.equals( expectedResult[i], rowWritten.get( i ) ) ); } }
|
DimensionLookup extends BaseStep implements StepInterface { public Long dimInsert( RowMetaInterface inputRowMeta, Object[] row, Long technicalKey, boolean newEntry, Long versionNr, Date dateFrom, Date dateTo ) throws KettleException { DatabaseMeta databaseMeta = meta.getDatabaseMeta(); if ( data.prepStatementInsert == null && data.prepStatementUpdate == null ) { RowMetaInterface insertRowMeta = new RowMeta(); String sql = "INSERT INTO " + data.schemaTable + "( "; if ( !isAutoIncrement() ) { sql += databaseMeta.quoteField( meta.getKeyField() ) + ", "; insertRowMeta.addValueMeta( data.outputRowMeta.getValueMeta( inputRowMeta.size() ) ); } else { if ( databaseMeta.needsPlaceHolder() ) { sql += "0, "; } } sql += databaseMeta.quoteField( meta.getVersionField() ) + ", " + databaseMeta.quoteField( meta.getDateFrom() ) + ", " + databaseMeta.quoteField( meta.getDateTo() ); insertRowMeta.addValueMeta( new ValueMetaInteger( meta.getVersionField() ) ); insertRowMeta.addValueMeta( new ValueMetaDate( meta.getDateFrom() ) ); insertRowMeta.addValueMeta( new ValueMetaDate( meta.getDateTo() ) ); for ( int i = 0; i < meta.getKeyLookup().length; i++ ) { sql += ", " + databaseMeta.quoteField( meta.getKeyLookup()[i] ); insertRowMeta.addValueMeta( inputRowMeta.getValueMeta( data.keynrs[i] ) ); } for ( int i = 0; i < meta.getFieldLookup().length; i++ ) { if ( !DimensionLookupMeta.isUpdateTypeWithoutArgument( meta.isUpdate(), meta.getFieldUpdate()[i] ) ) { sql += ", " + databaseMeta.quoteField( meta.getFieldLookup()[i] ); insertRowMeta.addValueMeta( inputRowMeta.getValueMeta( data.fieldnrs[i] ) ); } } for ( int i = 0; i < meta.getFieldUpdate().length; i++ ) { ValueMetaInterface valueMeta = null; switch ( meta.getFieldUpdate()[i] ) { case DimensionLookupMeta.TYPE_UPDATE_DATE_INSUP: case DimensionLookupMeta.TYPE_UPDATE_DATE_INSERTED: valueMeta = new ValueMetaDate( meta.getFieldLookup()[i] ); break; case DimensionLookupMeta.TYPE_UPDATE_LAST_VERSION: valueMeta = new ValueMetaBoolean( meta.getFieldLookup()[i] ); break; default: break; } if ( valueMeta != null ) { sql += ", " + databaseMeta.quoteField( valueMeta.getName() ); insertRowMeta.addValueMeta( valueMeta ); } } sql += ") VALUES ("; if ( !isAutoIncrement() ) { sql += "?, "; } sql += "?, ?, ?"; for ( int i = 0; i < data.keynrs.length; i++ ) { sql += ", ?"; } for ( int i = 0; i < meta.getFieldLookup().length; i++ ) { if ( !DimensionLookupMeta.isUpdateTypeWithoutArgument( meta.isUpdate(), meta.getFieldUpdate()[i] ) ) { sql += ", ?"; } } for ( int i = 0; i < meta.getFieldUpdate().length; i++ ) { switch ( meta.getFieldUpdate()[i] ) { case DimensionLookupMeta.TYPE_UPDATE_DATE_INSUP: case DimensionLookupMeta.TYPE_UPDATE_DATE_INSERTED: case DimensionLookupMeta.TYPE_UPDATE_LAST_VERSION: sql += ", ?"; break; default: break; } } sql += " )"; try { if ( technicalKey == null && databaseMeta.supportsAutoGeneratedKeys() ) { logDetailed( "SQL w/ return keys=[" + sql + "]" ); data.prepStatementInsert = data.db.getConnection().prepareStatement( databaseMeta.stripCR( sql ), Statement.RETURN_GENERATED_KEYS ); } else { logDetailed( "SQL=[" + sql + "]" ); data.prepStatementInsert = data.db.getConnection().prepareStatement( databaseMeta.stripCR( sql ) ); } } catch ( SQLException ex ) { throw new KettleDatabaseException( "Unable to prepare dimension insert :" + Const.CR + sql, ex ); } RowMetaInterface updateRowMeta = new RowMeta(); String sql_upd = "UPDATE " + data.schemaTable + Const.CR; sql_upd += "SET " + databaseMeta.quoteField( meta.getDateTo() ) + " = ?" + Const.CR; updateRowMeta.addValueMeta( new ValueMetaDate( meta.getDateTo() ) ); for ( int i = 0; i < meta.getFieldUpdate().length; i++ ) { ValueMetaInterface valueMeta = null; switch ( meta.getFieldUpdate()[i] ) { case DimensionLookupMeta.TYPE_UPDATE_DATE_INSUP: case DimensionLookupMeta.TYPE_UPDATE_DATE_UPDATED: valueMeta = new ValueMetaDate( meta.getFieldLookup()[i] ); break; case DimensionLookupMeta.TYPE_UPDATE_LAST_VERSION: valueMeta = new ValueMetaBoolean( meta.getFieldLookup()[i] ); break; default: break; } if ( valueMeta != null ) { sql_upd += ", " + databaseMeta.quoteField( valueMeta.getName() ) + " = ?" + Const.CR; updateRowMeta.addValueMeta( valueMeta ); } } sql_upd += "WHERE "; for ( int i = 0; i < meta.getKeyLookup().length; i++ ) { if ( i > 0 ) { sql_upd += "AND "; } sql_upd += databaseMeta.quoteField( meta.getKeyLookup()[i] ) + " = ?" + Const.CR; updateRowMeta.addValueMeta( inputRowMeta.getValueMeta( data.keynrs[i] ) ); } sql_upd += "AND " + databaseMeta.quoteField( meta.getVersionField() ) + " = ? "; updateRowMeta.addValueMeta( new ValueMetaInteger( meta.getVersionField() ) ); try { logDetailed( "Preparing update: " + Const.CR + sql_upd + Const.CR ); data.prepStatementUpdate = data.db.getConnection().prepareStatement( databaseMeta.stripCR( sql_upd ) ); } catch ( SQLException ex ) { throw new KettleDatabaseException( "Unable to prepare dimension update :" + Const.CR + sql_upd, ex ); } data.insertRowMeta = insertRowMeta; data.updateRowMeta = updateRowMeta; } Object[] insertRow = new Object[data.insertRowMeta.size()]; int insertIndex = 0; if ( !isAutoIncrement() ) { insertRow[insertIndex++] = technicalKey; } insertRow[insertIndex++] = versionNr; switch ( data.startDateChoice ) { case DimensionLookupMeta.START_DATE_ALTERNATIVE_NONE: insertRow[insertIndex++] = dateFrom; break; case DimensionLookupMeta.START_DATE_ALTERNATIVE_SYSDATE: insertRow[insertIndex++] = dateFrom; break; case DimensionLookupMeta.START_DATE_ALTERNATIVE_START_OF_TRANS: insertRow[insertIndex++] = getTrans().getStartDate(); break; case DimensionLookupMeta.START_DATE_ALTERNATIVE_NULL: insertRow[insertIndex++] = null; break; case DimensionLookupMeta.START_DATE_ALTERNATIVE_COLUMN_VALUE: insertRow[insertIndex++] = inputRowMeta.getDate( row, data.startDateFieldIndex ); break; default: throw new KettleStepException( BaseMessages.getString( PKG, "DimensionLookup.Exception.IllegalStartDateSelection", Integer.toString( data.startDateChoice ) ) ); } insertRow[insertIndex++] = dateTo; for ( int i = 0; i < data.keynrs.length; i++ ) { insertRow[insertIndex++] = row[data.keynrs[i]]; } for ( int i = 0; i < data.fieldnrs.length; i++ ) { if ( data.fieldnrs[i] >= 0 ) { insertRow[insertIndex++] = row[data.fieldnrs[i]]; } } for ( int i = 0; i < meta.getFieldUpdate().length; i++ ) { switch ( meta.getFieldUpdate()[i] ) { case DimensionLookupMeta.TYPE_UPDATE_DATE_INSUP: case DimensionLookupMeta.TYPE_UPDATE_DATE_INSERTED: insertRow[insertIndex++] = new Date(); break; case DimensionLookupMeta.TYPE_UPDATE_LAST_VERSION: insertRow[insertIndex++] = Boolean.TRUE; break; default: break; } } if ( isDebug() ) { logDebug( "rins, size=" + data.insertRowMeta.size() + ", values=" + data.insertRowMeta.getString( insertRow ) ); } data.db.setValues( data.insertRowMeta, insertRow, data.prepStatementInsert ); data.db.insertRow( data.prepStatementInsert ); if ( isDebug() ) { logDebug( "Row inserted!" ); } if ( technicalKey == null && databaseMeta.supportsAutoGeneratedKeys() ) { try { RowMetaAndData keys = data.db.getGeneratedKeys( data.prepStatementInsert ); if ( keys.getRowMeta().size() > 0 ) { technicalKey = keys.getRowMeta().getInteger( keys.getData(), 0 ); } else { throw new KettleDatabaseException( "Unable to retrieve value of auto-generated technical key : no value found!" ); } } catch ( Exception e ) { throw new KettleDatabaseException( "Unable to retrieve value of auto-generated technical key : unexpected error: ", e ); } } if ( !newEntry ) { Object[] updateRow = new Object[data.updateRowMeta.size()]; int updateIndex = 0; switch ( data.startDateChoice ) { case DimensionLookupMeta.START_DATE_ALTERNATIVE_NONE: updateRow[updateIndex++] = dateFrom; break; case DimensionLookupMeta.START_DATE_ALTERNATIVE_SYSDATE: updateRow[updateIndex++] = new Date(); break; case DimensionLookupMeta.START_DATE_ALTERNATIVE_START_OF_TRANS: updateRow[updateIndex++] = getTrans().getCurrentDate(); break; case DimensionLookupMeta.START_DATE_ALTERNATIVE_NULL: updateRow[updateIndex++] = null; break; case DimensionLookupMeta.START_DATE_ALTERNATIVE_COLUMN_VALUE: updateRow[updateIndex++] = inputRowMeta.getDate( row, data.startDateFieldIndex ); break; default: throw new KettleStepException( BaseMessages.getString( "DimensionLookup.Exception.IllegalStartDateSelection", Integer.toString( data.startDateChoice ) ) ); } for ( int i = 0; i < meta.getFieldUpdate().length; i++ ) { switch ( meta.getFieldUpdate()[i] ) { case DimensionLookupMeta.TYPE_UPDATE_DATE_INSUP: updateRow[updateIndex++] = new Date(); break; case DimensionLookupMeta.TYPE_UPDATE_LAST_VERSION: updateRow[updateIndex++] = Boolean.FALSE; break; case DimensionLookupMeta.TYPE_UPDATE_DATE_UPDATED: updateRow[updateIndex++] = new Date(); break; default: break; } } for ( int i = 0; i < data.keynrs.length; i++ ) { updateRow[updateIndex++] = row[data.keynrs[i]]; } updateRow[updateIndex++] = versionNr - 1; if ( isRowLevel() ) { logRowlevel( "UPDATE using rupd=" + data.updateRowMeta.getString( updateRow ) ); } data.db.setValues( data.updateRowMeta, updateRow, data.prepStatementUpdate ); if ( isDebug() ) { logDebug( "Values set for update (" + data.updateRowMeta.size() + ")" ); } data.db.insertRow( data.prepStatementUpdate ); if ( isDebug() ) { logDebug( "Row updated!" ); } } return technicalKey; } DimensionLookup( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); @Override boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); Long dimInsert( RowMetaInterface inputRowMeta, Object[] row, Long technicalKey, boolean newEntry,
Long versionNr, Date dateFrom, Date dateTo ); @Override boolean isRowLevel(); @Override boolean isDebug(); void dimUpdate( RowMetaInterface rowMeta, Object[] row, Long dimkey, Date valueDate ); void dimPunchThrough( RowMetaInterface rowMeta, Object[] row ); void checkDimZero(); @Override boolean init( StepMetaInterface smi, StepDataInterface sdi ); @Override void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
|
@Test public void testDimInsert() throws Exception { RowMetaInterface rowMetaInterface = mock( RowMetaInterface.class ); Object[] objects = mock( List.class ).toArray(); Date date = mock( Date.class ); dimensionLookupSpy.dimInsert( rowMetaInterface, objects, new Long( "132323" ), true, null, date, date ); verify( databaseMeta, times( 0 ) ).supportsAutoGeneratedKeys(); dimensionLookupSpy.dimInsert( rowMetaInterface, objects, null, true, null, date, date ); verify( databaseMeta, times( 2 ) ).supportsAutoGeneratedKeys(); }
|
DimensionLookupMeta extends BaseStepMeta implements StepMetaInterface, ProvidesModelerMeta { @Override public void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { for ( ValueMetaInterface valueMeta : row.getValueMetaList() ) { valueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_NORMAL ); valueMeta.setTrimType( ValueMetaInterface.TRIM_TYPE_NONE ); } if ( Utils.isEmpty( keyField ) ) { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Error.NoTechnicalKeySpecified" ); logError( message ); throw new KettleStepException( message ); } ValueMetaInterface v = new ValueMetaInteger( keyField ); if ( keyRename != null && keyRename.length() > 0 ) { v.setName( keyRename ); } v.setLength( 9 ); v.setPrecision( 0 ); v.setOrigin( name ); row.addValueMeta( v ); if ( !update && fieldLookup.length > 0 ) { Database db = null; try { if ( databaseMeta != null ) { db = createDatabaseObject(); RowMetaInterface extraFields = getDatabaseTableFields( db, schemaName, tableName ); for ( int i = 0; i < fieldLookup.length; i++ ) { v = extraFields.searchValueMeta( fieldLookup[i] ); if ( v == null ) { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Exception.UnableToFindReturnField", fieldLookup[i] ); logError( message ); throw new KettleStepException( message ); } if ( fieldStream[i] != null && fieldStream[i].length() > 0 ) { v.setName( fieldStream[i] ); } v.setOrigin( name ); row.addValueMeta( v ); } } else { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Exception.UnableToRetrieveDataTypeOfReturnField" ); logError( message ); throw new KettleStepException( message ); } } catch ( Exception e ) { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Exception.UnableToRetrieveDataTypeOfReturnField2" ); logError( message ); throw new KettleStepException( message, e ); } finally { if ( db != null ) { db.disconnect(); } } } } DimensionLookupMeta(); @Override String getTableName(); void setTableName( String tablename ); @Override DatabaseMeta getDatabaseMeta(); void setDatabaseMeta( DatabaseMeta database ); @Injection( name = "CONNECTION_NAME" ) void setConnection( String connectionName ); boolean isUpdate(); void setUpdate( boolean update ); boolean isAutoIncrement(); void setAutoIncrement( boolean autoIncrement ); void setTechKeyCreation( String techKeyCreation ); String getTechKeyCreation(); int getCommitSize(); void setCommitSize( int commitSize ); String getDateField(); void setDateField( String dateField ); String getDateFrom(); void setDateFrom( String dateFrom ); String getDateTo(); void setDateTo( String dateTo ); String[] getFieldLookup(); void setFieldLookup( String[] fieldLookup ); String[] getFieldStream(); void setFieldStream( String[] fieldStream ); int[] getFieldUpdate(); void setFieldUpdate( int[] fieldUpdate ); int[] getReturnType(); void setReturnType( int[] returnType ); String getKeyField(); void setKeyField( String keyField ); String[] getKeyLookup(); void setKeyLookup( String[] keyLookup ); String getKeyRename(); void setKeyRename( String keyRename ); String[] getKeyStream(); void setKeyStream( String[] keyStream ); int getMaxYear(); void setMaxYear( int maxYear ); int getMinYear(); void setMinYear( int minYear ); String getSequenceName(); void setSequenceName( String sequenceName ); String getVersionField(); void setVersionField( String versionField ); void actualizeWithInjectedValues(); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void allocate( int nrkeys, int nrfields ); @Override Object clone(); static final int getUpdateType( boolean upd, String ty ); static final String getUpdateType( boolean upd, int t ); static final String getUpdateTypeCode( boolean upd, int t ); static final int getStartDateAlternative( String string ); static final String getStartDateAlternativeCode( int alternative ); static final String getStartDateAlternativeDesc( int alternative ); static final String[] getStartDateAlternativeCodes(); static final String[] getStartDateAlternativeDescriptions(); static final boolean isUpdateTypeWithoutArgument( boolean update, int type ); @Override void setDefault(); @Override void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); @Override String getXML(); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); Date getMinDate(); Date getMaxDate(); @Override void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
IMetaStore metaStore ); @Override RowMetaInterface getTableFields(); @Override SQLStatement getSQLStatements( TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
Repository repository, IMetaStore metaStore ); @Override void analyseImpact( List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
String[] input, String[] output, RowMetaInterface info, Repository repository, IMetaStore metaStore ); @Override StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr,
Trans trans ); @Override StepDataInterface getStepData(); @Override DatabaseMeta[] getUsedDatabaseConnections(); @Override String getSchemaName(); @Override String getMissingDatabaseConnectionInformationMessage(); void setSchemaName( String schemaName ); int getCacheSize(); void setCacheSize( int cacheSize ); boolean isUsingStartDateAlternative(); void setUsingStartDateAlternative( boolean usingStartDateAlternative ); int getStartDateAlternative(); void setStartDateAlternative( int startDateAlternative ); String getStartDateFieldName(); void setStartDateFieldName( String startDateFieldName ); boolean isPreloadingCache(); void setPreloadingCache( boolean preloadingCache ); boolean useBatchUpdate(); void setUseBatchUpdate( boolean useBatchUpdate ); @Override RowMeta getRowMeta( final StepDataInterface stepData ); @Override List<String> getDatabaseFields(); @Override List<String> getStreamFields(); void normalizeAllocationFields(); @AfterInjection void afterInjectionSynchronization(); static final int TYPE_UPDATE_DIM_INSERT; static final int TYPE_UPDATE_DIM_UPDATE; static final int TYPE_UPDATE_DIM_PUNCHTHROUGH; static final int TYPE_UPDATE_DATE_INSUP; static final int TYPE_UPDATE_DATE_INSERTED; static final int TYPE_UPDATE_DATE_UPDATED; static final int TYPE_UPDATE_LAST_VERSION; static final String[] typeDesc; static final String[] typeCodes; static final String[] typeDescLookup; static final int START_DATE_ALTERNATIVE_NONE; static final int START_DATE_ALTERNATIVE_SYSDATE; static final int START_DATE_ALTERNATIVE_START_OF_TRANS; static final int START_DATE_ALTERNATIVE_NULL; static final int START_DATE_ALTERNATIVE_COLUMN_VALUE; static String CREATION_METHOD_AUTOINC; static String CREATION_METHOD_SEQUENCE; static String CREATION_METHOD_TABLEMAX; }
|
@Test public void testGetFields() throws Exception { RowMeta extraFields = new RowMeta(); extraFields.addValueMeta( new ValueMetaString( "field1" ) ); DatabaseMeta dbMeta = mock( DatabaseMeta.class ); DimensionLookupMeta meta = spy( new DimensionLookupMeta() ); meta.setUpdate( false ); meta.setKeyField( null ); meta.setFieldLookup( new String[] { "field1" } ); meta.setFieldStream( new String[] { "" } ); meta.setDatabaseMeta( dbMeta ); doReturn( extraFields ).when( meta ).getDatabaseTableFields( (Database) anyObject(), anyString(), anyString() ); doReturn( mock( LogChannelInterface.class ) ).when( meta ).getLog(); RowMeta row = new RowMeta(); try { meta.getFields( row, "DimensionLookupMetaTest", new RowMeta[] { row }, null, null, null, null ); } catch ( Throwable e ) { Assert.assertTrue( e.getMessage().contains( BaseMessages.getString( DimensionLookupMeta.class, "DimensionLookupMeta.Error.NoTechnicalKeySpecified" ) ) ); } }
|
DataHandler extends AbstractXulEventHandler { public void onClusterCheck() { if ( clusteringCheck != null ) { boolean dis = !clusteringCheck.isChecked(); if ( clusterParameterTree != null ) { clusterParameterTree.setDisabled( dis ); } if ( clusterParameterDescriptionLabel != null ) { clusterParameterDescriptionLabel.setDisabled( dis ); } } } DataHandler(); void loadConnectionData(); void loadAccessData(); void editOptions( int index ); void clearOptionsData(); void getOptionHelp(); void setDeckChildIndex(); void onPoolingCheck(); void onClusterCheck(); Object getData(); void setData( Object data ); void pushCache(); void popCache(); void onCancel(); void onOK(); void testDatabaseConnection(); void restoreDefaults(); void poolingRowChange( int idx ); void disablePortIfInstancePopulated(); void handleUseSecurityCheckbox(); static final SortedMap<String, DatabaseInterface> connectionMap; static final Map<String, String> connectionNametoID; }
|
@Test public void testOnClusterCheck() throws Exception { }
|
SelectValuesMeta extends BaseStepMeta implements StepMetaInterface { public void setSelectName( String[] selectName ) { resizeSelectFields( selectName.length ); for ( int i = 0; i < selectFields.length; i++ ) { selectFields[i].setName( selectName[i] ); } } SelectValuesMeta(); String[] getDeleteName(); void setDeleteName( String[] deleteName ); void setSelectName( String[] selectName ); String[] getSelectName(); void setSelectRename( String[] selectRename ); String[] getSelectRename(); void setSelectLength( int[] selectLength ); int[] getSelectLength(); void setSelectPrecision( int[] selectPrecision ); int[] getSelectPrecision(); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void allocate( int nrFields, int nrRemove, int nrMeta ); @Override Object clone(); @Override void setDefault(); void getSelectFields( RowMetaInterface inputRowMeta, String name ); void getDeleteFields( RowMetaInterface inputRowMeta ); @Deprecated void getMetadataFields( RowMetaInterface inputRowMeta, String name ); void getMetadataFields( RowMetaInterface inputRowMeta, String name, VariableSpace space ); @Override void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); @Override String getXML(); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); @Override void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
IMetaStore metaStore ); @Override StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta transMeta,
Trans trans ); @Override StepDataInterface getStepData(); boolean isSelectingAndSortingUnspecifiedFields(); void setSelectingAndSortingUnspecifiedFields( boolean selectingAndSortingUnspecifiedFields ); SelectMetadataChange[] getMeta(); void setMeta( SelectMetadataChange[] meta ); @Override boolean supportsErrorHandling(); SelectField[] getSelectFields(); void setSelectFields( SelectField[] selectFields ); List<FieldnameLineage> getFieldnameLineage(); static final int UNDEFINED; }
|
@Test public void setSelectName() { selectValuesMeta.setSelectName( new String[] { FIRST_FIELD, SECOND_FIELD } ); assertArrayEquals( new String[] { FIRST_FIELD, SECOND_FIELD }, selectValuesMeta.getSelectName() ); }
|
SelectValuesMeta extends BaseStepMeta implements StepMetaInterface { public String[] getSelectName() { String[] selectName = new String[selectFields.length]; for ( int i = 0; i < selectName.length; i++ ) { selectName[i] = selectFields[i].getName(); } return selectName; } SelectValuesMeta(); String[] getDeleteName(); void setDeleteName( String[] deleteName ); void setSelectName( String[] selectName ); String[] getSelectName(); void setSelectRename( String[] selectRename ); String[] getSelectRename(); void setSelectLength( int[] selectLength ); int[] getSelectLength(); void setSelectPrecision( int[] selectPrecision ); int[] getSelectPrecision(); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void allocate( int nrFields, int nrRemove, int nrMeta ); @Override Object clone(); @Override void setDefault(); void getSelectFields( RowMetaInterface inputRowMeta, String name ); void getDeleteFields( RowMetaInterface inputRowMeta ); @Deprecated void getMetadataFields( RowMetaInterface inputRowMeta, String name ); void getMetadataFields( RowMetaInterface inputRowMeta, String name, VariableSpace space ); @Override void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); @Override String getXML(); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); @Override void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
IMetaStore metaStore ); @Override StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta transMeta,
Trans trans ); @Override StepDataInterface getStepData(); boolean isSelectingAndSortingUnspecifiedFields(); void setSelectingAndSortingUnspecifiedFields( boolean selectingAndSortingUnspecifiedFields ); SelectMetadataChange[] getMeta(); void setMeta( SelectMetadataChange[] meta ); @Override boolean supportsErrorHandling(); SelectField[] getSelectFields(); void setSelectFields( SelectField[] selectFields ); List<FieldnameLineage> getFieldnameLineage(); static final int UNDEFINED; }
|
@Test public void getSelectName() { assertArrayEquals( new String[0], selectValuesMeta.getSelectName() ); }
|
SelectValuesMeta extends BaseStepMeta implements StepMetaInterface { public void setSelectRename( String[] selectRename ) { if ( selectRename.length > selectFields.length ) { resizeSelectFields( selectRename.length ); } for ( int i = 0; i < selectFields.length; i++ ) { if ( i < selectRename.length ) { selectFields[i].setRename( selectRename[i] ); } else { selectFields[i].setRename( null ); } } } SelectValuesMeta(); String[] getDeleteName(); void setDeleteName( String[] deleteName ); void setSelectName( String[] selectName ); String[] getSelectName(); void setSelectRename( String[] selectRename ); String[] getSelectRename(); void setSelectLength( int[] selectLength ); int[] getSelectLength(); void setSelectPrecision( int[] selectPrecision ); int[] getSelectPrecision(); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void allocate( int nrFields, int nrRemove, int nrMeta ); @Override Object clone(); @Override void setDefault(); void getSelectFields( RowMetaInterface inputRowMeta, String name ); void getDeleteFields( RowMetaInterface inputRowMeta ); @Deprecated void getMetadataFields( RowMetaInterface inputRowMeta, String name ); void getMetadataFields( RowMetaInterface inputRowMeta, String name, VariableSpace space ); @Override void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); @Override String getXML(); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); @Override void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
IMetaStore metaStore ); @Override StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta transMeta,
Trans trans ); @Override StepDataInterface getStepData(); boolean isSelectingAndSortingUnspecifiedFields(); void setSelectingAndSortingUnspecifiedFields( boolean selectingAndSortingUnspecifiedFields ); SelectMetadataChange[] getMeta(); void setMeta( SelectMetadataChange[] meta ); @Override boolean supportsErrorHandling(); SelectField[] getSelectFields(); void setSelectFields( SelectField[] selectFields ); List<FieldnameLineage> getFieldnameLineage(); static final int UNDEFINED; }
|
@Test public void setSelectRename() { selectValuesMeta.setSelectRename( new String[] { FIRST_FIELD, SECOND_FIELD } ); assertArrayEquals( new String[] { FIRST_FIELD, SECOND_FIELD }, selectValuesMeta.getSelectRename() ); }
|
SelectValuesMeta extends BaseStepMeta implements StepMetaInterface { public String[] getSelectRename() { String[] selectRename = new String[selectFields.length]; for ( int i = 0; i < selectRename.length; i++ ) { selectRename[i] = selectFields[i].getRename(); } return selectRename; } SelectValuesMeta(); String[] getDeleteName(); void setDeleteName( String[] deleteName ); void setSelectName( String[] selectName ); String[] getSelectName(); void setSelectRename( String[] selectRename ); String[] getSelectRename(); void setSelectLength( int[] selectLength ); int[] getSelectLength(); void setSelectPrecision( int[] selectPrecision ); int[] getSelectPrecision(); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void allocate( int nrFields, int nrRemove, int nrMeta ); @Override Object clone(); @Override void setDefault(); void getSelectFields( RowMetaInterface inputRowMeta, String name ); void getDeleteFields( RowMetaInterface inputRowMeta ); @Deprecated void getMetadataFields( RowMetaInterface inputRowMeta, String name ); void getMetadataFields( RowMetaInterface inputRowMeta, String name, VariableSpace space ); @Override void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); @Override String getXML(); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); @Override void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
IMetaStore metaStore ); @Override StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta transMeta,
Trans trans ); @Override StepDataInterface getStepData(); boolean isSelectingAndSortingUnspecifiedFields(); void setSelectingAndSortingUnspecifiedFields( boolean selectingAndSortingUnspecifiedFields ); SelectMetadataChange[] getMeta(); void setMeta( SelectMetadataChange[] meta ); @Override boolean supportsErrorHandling(); SelectField[] getSelectFields(); void setSelectFields( SelectField[] selectFields ); List<FieldnameLineage> getFieldnameLineage(); static final int UNDEFINED; }
|
@Test public void getSelectRename() { assertArrayEquals( new String[0], selectValuesMeta.getSelectRename() ); }
|
SelectValuesMeta extends BaseStepMeta implements StepMetaInterface { public void setSelectLength( int[] selectLength ) { if ( selectLength.length > selectFields.length ) { resizeSelectFields( selectLength.length ); } for ( int i = 0; i < selectFields.length; i++ ) { if ( i < selectLength.length ) { selectFields[i].setLength( selectLength[i] ); } else { selectFields[i].setLength( UNDEFINED ); } } } SelectValuesMeta(); String[] getDeleteName(); void setDeleteName( String[] deleteName ); void setSelectName( String[] selectName ); String[] getSelectName(); void setSelectRename( String[] selectRename ); String[] getSelectRename(); void setSelectLength( int[] selectLength ); int[] getSelectLength(); void setSelectPrecision( int[] selectPrecision ); int[] getSelectPrecision(); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void allocate( int nrFields, int nrRemove, int nrMeta ); @Override Object clone(); @Override void setDefault(); void getSelectFields( RowMetaInterface inputRowMeta, String name ); void getDeleteFields( RowMetaInterface inputRowMeta ); @Deprecated void getMetadataFields( RowMetaInterface inputRowMeta, String name ); void getMetadataFields( RowMetaInterface inputRowMeta, String name, VariableSpace space ); @Override void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); @Override String getXML(); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); @Override void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
IMetaStore metaStore ); @Override StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta transMeta,
Trans trans ); @Override StepDataInterface getStepData(); boolean isSelectingAndSortingUnspecifiedFields(); void setSelectingAndSortingUnspecifiedFields( boolean selectingAndSortingUnspecifiedFields ); SelectMetadataChange[] getMeta(); void setMeta( SelectMetadataChange[] meta ); @Override boolean supportsErrorHandling(); SelectField[] getSelectFields(); void setSelectFields( SelectField[] selectFields ); List<FieldnameLineage> getFieldnameLineage(); static final int UNDEFINED; }
|
@Test public void setSelectLength() { selectValuesMeta.setSelectLength( new int[] { 1, 2 } ); assertArrayEquals( new int[] { 1, 2 }, selectValuesMeta.getSelectLength() ); }
|
SelectValuesMeta extends BaseStepMeta implements StepMetaInterface { public int[] getSelectLength() { int[] selectLength = new int[selectFields.length]; for ( int i = 0; i < selectLength.length; i++ ) { selectLength[i] = selectFields[i].getLength(); } return selectLength; } SelectValuesMeta(); String[] getDeleteName(); void setDeleteName( String[] deleteName ); void setSelectName( String[] selectName ); String[] getSelectName(); void setSelectRename( String[] selectRename ); String[] getSelectRename(); void setSelectLength( int[] selectLength ); int[] getSelectLength(); void setSelectPrecision( int[] selectPrecision ); int[] getSelectPrecision(); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void allocate( int nrFields, int nrRemove, int nrMeta ); @Override Object clone(); @Override void setDefault(); void getSelectFields( RowMetaInterface inputRowMeta, String name ); void getDeleteFields( RowMetaInterface inputRowMeta ); @Deprecated void getMetadataFields( RowMetaInterface inputRowMeta, String name ); void getMetadataFields( RowMetaInterface inputRowMeta, String name, VariableSpace space ); @Override void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); @Override String getXML(); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); @Override void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
IMetaStore metaStore ); @Override StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta transMeta,
Trans trans ); @Override StepDataInterface getStepData(); boolean isSelectingAndSortingUnspecifiedFields(); void setSelectingAndSortingUnspecifiedFields( boolean selectingAndSortingUnspecifiedFields ); SelectMetadataChange[] getMeta(); void setMeta( SelectMetadataChange[] meta ); @Override boolean supportsErrorHandling(); SelectField[] getSelectFields(); void setSelectFields( SelectField[] selectFields ); List<FieldnameLineage> getFieldnameLineage(); static final int UNDEFINED; }
|
@Test public void getSelectLength() { assertArrayEquals( new int[0], selectValuesMeta.getSelectLength() ); }
|
SelectValuesMeta extends BaseStepMeta implements StepMetaInterface { public void setSelectPrecision( int[] selectPrecision ) { if ( selectPrecision.length > selectFields.length ) { resizeSelectFields( selectPrecision.length ); } for ( int i = 0; i < selectFields.length; i++ ) { if ( i < selectPrecision.length ) { selectFields[i].setPrecision( selectPrecision[i] ); } else { selectFields[i].setPrecision( UNDEFINED ); } } } SelectValuesMeta(); String[] getDeleteName(); void setDeleteName( String[] deleteName ); void setSelectName( String[] selectName ); String[] getSelectName(); void setSelectRename( String[] selectRename ); String[] getSelectRename(); void setSelectLength( int[] selectLength ); int[] getSelectLength(); void setSelectPrecision( int[] selectPrecision ); int[] getSelectPrecision(); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void allocate( int nrFields, int nrRemove, int nrMeta ); @Override Object clone(); @Override void setDefault(); void getSelectFields( RowMetaInterface inputRowMeta, String name ); void getDeleteFields( RowMetaInterface inputRowMeta ); @Deprecated void getMetadataFields( RowMetaInterface inputRowMeta, String name ); void getMetadataFields( RowMetaInterface inputRowMeta, String name, VariableSpace space ); @Override void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); @Override String getXML(); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); @Override void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
IMetaStore metaStore ); @Override StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta transMeta,
Trans trans ); @Override StepDataInterface getStepData(); boolean isSelectingAndSortingUnspecifiedFields(); void setSelectingAndSortingUnspecifiedFields( boolean selectingAndSortingUnspecifiedFields ); SelectMetadataChange[] getMeta(); void setMeta( SelectMetadataChange[] meta ); @Override boolean supportsErrorHandling(); SelectField[] getSelectFields(); void setSelectFields( SelectField[] selectFields ); List<FieldnameLineage> getFieldnameLineage(); static final int UNDEFINED; }
|
@Test public void setSelectPrecision() { selectValuesMeta.setSelectPrecision( new int[] { 1, 2 } ); assertArrayEquals( new int[] { 1, 2 }, selectValuesMeta.getSelectPrecision() ); }
|
SelectValuesMeta extends BaseStepMeta implements StepMetaInterface { public int[] getSelectPrecision() { int[] selectPrecision = new int[selectFields.length]; for ( int i = 0; i < selectPrecision.length; i++ ) { selectPrecision[i] = selectFields[i].getPrecision(); } return selectPrecision; } SelectValuesMeta(); String[] getDeleteName(); void setDeleteName( String[] deleteName ); void setSelectName( String[] selectName ); String[] getSelectName(); void setSelectRename( String[] selectRename ); String[] getSelectRename(); void setSelectLength( int[] selectLength ); int[] getSelectLength(); void setSelectPrecision( int[] selectPrecision ); int[] getSelectPrecision(); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void allocate( int nrFields, int nrRemove, int nrMeta ); @Override Object clone(); @Override void setDefault(); void getSelectFields( RowMetaInterface inputRowMeta, String name ); void getDeleteFields( RowMetaInterface inputRowMeta ); @Deprecated void getMetadataFields( RowMetaInterface inputRowMeta, String name ); void getMetadataFields( RowMetaInterface inputRowMeta, String name, VariableSpace space ); @Override void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); @Override String getXML(); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); @Override void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
IMetaStore metaStore ); @Override StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta transMeta,
Trans trans ); @Override StepDataInterface getStepData(); boolean isSelectingAndSortingUnspecifiedFields(); void setSelectingAndSortingUnspecifiedFields( boolean selectingAndSortingUnspecifiedFields ); SelectMetadataChange[] getMeta(); void setMeta( SelectMetadataChange[] meta ); @Override boolean supportsErrorHandling(); SelectField[] getSelectFields(); void setSelectFields( SelectField[] selectFields ); List<FieldnameLineage> getFieldnameLineage(); static final int UNDEFINED; }
|
@Test public void getSelectPrecision() { assertArrayEquals( new int[0], selectValuesMeta.getSelectPrecision() ); }
|
SelectValues extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (SelectValuesMeta) smi; data = (SelectValuesData) sdi; Object[] rowData = getRow(); if ( rowData == null ) { setOutputDone(); return false; } Object[] rowCopy = null; if ( getStepMeta().isDoingErrorHandling() ) { rowCopy = getInputRowMeta().cloneRow( rowData ); } if ( log.isRowLevel() ) { logRowlevel( BaseMessages.getString( PKG, "SelectValues.Log.GotRowFromPreviousStep" ) + getInputRowMeta().getString( rowData ) ); } if ( first ) { first = false; data.selectRowMeta = getInputRowMeta().clone(); meta.getSelectFields( data.selectRowMeta, getStepname() ); data.deselectRowMeta = data.selectRowMeta.clone(); meta.getDeleteFields( data.deselectRowMeta ); data.metadataRowMeta = data.deselectRowMeta.clone(); meta.getMetadataFields( data.metadataRowMeta, getStepname(), this ); } try { Object[] outputData = rowData; if ( data.select ) { outputData = selectValues( getInputRowMeta(), outputData ); } if ( data.deselect ) { outputData = removeValues( data.selectRowMeta, outputData ); } if ( data.metadata ) { outputData = metadataValues( data.deselectRowMeta, outputData ); } if ( outputData == null ) { setOutputDone(); return false; } putRow( data.metadataRowMeta, outputData ); if ( log.isRowLevel() ) { logRowlevel( BaseMessages.getString( PKG, "SelectValues.Log.WroteRowToNextStep" ) + data.metadataRowMeta.getString( outputData ) ); } } catch ( KettleException e ) { if ( getStepMeta().isDoingErrorHandling() ) { String field; if ( e instanceof KettleConversionException ) { List<ValueMetaInterface> fields = ( (KettleConversionException) e ).getFields(); field = fields.isEmpty() ? null : fields.get( 0 ).getName(); } else { field = null; } putError( getInputRowMeta(), rowCopy, 1, e.getMessage(), field, "SELECT001" ); } else { throw e; } } if ( checkFeedback( getLinesRead() ) ) { logBasic( BaseMessages.getString( PKG, "SelectValues.Log.LineNumber" ) + getLinesRead() ); } return true; } SelectValues( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); }
|
@Test public void testPDI16368() throws Exception { StepMockHelper<SelectValuesMeta, StepDataInterface> helper = StepMockUtil.getStepMockHelper( SelectValuesMeta.class, "SelectValuesTest2" ); SelectValuesHandler step2 = null; Object[] inputRow2 = null; RowMeta inputRowMeta = null; SelectValuesMeta stepMeta = null; SelectValuesData stepData = null; ValueMetaInterface vmi = null; step2 = new SelectValuesHandler( helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans ); step2 = spy( step2 ); inputRow2 = new Object[] { new BigDecimal( "589" ) }; doReturn( inputRow2 ).when( step2 ).getRow(); doNothing().when( step2 ) .putError( any( RowMetaInterface.class ), any( Object[].class ), anyLong(), anyString(), anyString(), anyString() ); inputRowMeta = new RowMeta(); inputRowMeta.addValueMeta( new ValueMetaBigNumber( SELECTED_FIELD ) ); step2.setInputRowMeta( inputRowMeta ); stepMeta = new SelectValuesMeta(); stepMeta.allocate( 1, 0, 1 ); stepMeta.getSelectFields()[0] = new SelectField(); stepMeta.getSelectFields()[0].setName( SELECTED_FIELD ); stepMeta.getMeta()[ 0 ] = new SelectMetadataChange( stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_INTEGER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, null ); stepData = new SelectValuesData(); stepData.select = true; stepData.metadata = true; stepData.firstselect = true; stepData.firstmetadata = true; step2.processRow( stepMeta, stepData ); vmi = step2.rowMeta.getValueMeta( 0 ); assertEquals( ValueMetaBase.DEFAULT_BIG_NUMBER_FORMAT_MASK, vmi.getConversionMask() ); step2 = new SelectValuesHandler( helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans ); step2 = spy( step2 ); doReturn( inputRow2 ).when( step2 ).getRow(); doNothing().when( step2 ) .putError( any( RowMetaInterface.class ), any( Object[].class ), anyLong(), anyString(), anyString(), anyString() ); inputRowMeta = new RowMeta(); inputRowMeta.addValueMeta( new ValueMetaBigNumber( SELECTED_FIELD ) ); step2.setInputRowMeta( inputRowMeta ); stepMeta = new SelectValuesMeta(); stepMeta.allocate( 1, 0, 1 ); stepMeta.getSelectFields()[0] = new SelectField(); stepMeta.getSelectFields()[0].setName( SELECTED_FIELD ); stepMeta.getMeta()[ 0 ] = new SelectMetadataChange( stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_NUMBER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, null ); stepData = new SelectValuesData(); stepData.select = true; stepData.metadata = true; stepData.firstselect = true; stepData.firstmetadata = true; step2.processRow( stepMeta, stepData ); vmi = step2.rowMeta.getValueMeta( 0 ); assertEquals( ValueMetaBase.DEFAULT_BIG_NUMBER_FORMAT_MASK, vmi.getConversionMask() ); step2 = new SelectValuesHandler( helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans ); step2 = spy( step2 ); inputRow2 = new Object[] { new Long( "589" ) }; doReturn( inputRow2 ).when( step2 ).getRow(); doNothing().when( step2 ) .putError( any( RowMetaInterface.class ), any( Object[].class ), anyLong(), anyString(), anyString(), anyString() ); inputRowMeta = new RowMeta(); inputRowMeta.addValueMeta( new ValueMetaInteger( SELECTED_FIELD ) ); step2.setInputRowMeta( inputRowMeta ); stepMeta = new SelectValuesMeta(); stepMeta.allocate( 1, 0, 1 ); stepMeta.getSelectFields()[0] = new SelectField(); stepMeta.getSelectFields()[0].setName( SELECTED_FIELD ); stepMeta.getMeta()[ 0 ] = new SelectMetadataChange( stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_BIGNUMBER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, null ); stepData = new SelectValuesData(); stepData.select = true; stepData.metadata = true; stepData.firstselect = true; stepData.firstmetadata = true; step2.processRow( stepMeta, stepData ); vmi = step2.rowMeta.getValueMeta( 0 ); assertEquals( ValueMetaBase.DEFAULT_INTEGER_FORMAT_MASK, vmi.getConversionMask() ); step2 = new SelectValuesHandler( helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans ); step2.setVariable( Const.KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS, "Y" ); step2 = spy( step2 ); inputRow2 = new Object[] { new BigDecimal( "589" ) }; doReturn( inputRow2 ).when( step2 ).getRow(); doNothing().when( step2 ) .putError( any( RowMetaInterface.class ), any( Object[].class ), anyLong(), anyString(), anyString(), anyString() ); inputRowMeta = new RowMeta(); inputRowMeta.addValueMeta( new ValueMetaBigNumber( SELECTED_FIELD ) ); step2.setInputRowMeta( inputRowMeta ); stepMeta = new SelectValuesMeta(); stepMeta.allocate( 1, 0, 1 ); stepMeta.getSelectFields()[0] = new SelectField(); stepMeta.getSelectFields()[0].setName( SELECTED_FIELD ); stepMeta.getMeta()[ 0 ] = new SelectMetadataChange( stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_INTEGER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, null ); stepData = new SelectValuesData(); stepData.select = true; stepData.metadata = true; stepData.firstselect = true; stepData.firstmetadata = true; step2.processRow( stepMeta, stepData ); vmi = step2.rowMeta.getValueMeta( 0 ); assertEquals( ValueMetaBase.DEFAULT_INTEGER_FORMAT_MASK, vmi.getConversionMask() ); step2 = new SelectValuesHandler( helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans ); step2.setVariable( Const.KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS, "Y" ); step2 = spy( step2 ); doReturn( inputRow2 ).when( step2 ).getRow(); doNothing().when( step2 ) .putError( any( RowMetaInterface.class ), any( Object[].class ), anyLong(), anyString(), anyString(), anyString() ); inputRowMeta = new RowMeta(); inputRowMeta.addValueMeta( new ValueMetaBigNumber( SELECTED_FIELD ) ); step2.setInputRowMeta( inputRowMeta ); stepMeta = new SelectValuesMeta(); stepMeta.allocate( 1, 0, 1 ); stepMeta.getSelectFields()[0] = new SelectField(); stepMeta.getSelectFields()[0].setName( SELECTED_FIELD ); stepMeta.getMeta()[ 0 ] = new SelectMetadataChange( stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_NUMBER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, null ); stepData = new SelectValuesData(); stepData.select = true; stepData.metadata = true; stepData.firstselect = true; stepData.firstmetadata = true; step2.processRow( stepMeta, stepData ); vmi = step2.rowMeta.getValueMeta( 0 ); assertEquals( ValueMetaBase.DEFAULT_NUMBER_FORMAT_MASK, vmi.getConversionMask() ); step2 = new SelectValuesHandler( helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans ); step2.setVariable( Const.KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS, "Y" ); step2 = spy( step2 ); inputRow2 = new Object[] { new Long( "589" ) }; doReturn( inputRow2 ).when( step2 ).getRow(); doNothing().when( step2 ) .putError( any( RowMetaInterface.class ), any( Object[].class ), anyLong(), anyString(), anyString(), anyString() ); inputRowMeta = new RowMeta(); inputRowMeta.addValueMeta( new ValueMetaInteger( SELECTED_FIELD ) ); step2.setInputRowMeta( inputRowMeta ); stepMeta = new SelectValuesMeta(); stepMeta.allocate( 1, 0, 1 ); stepMeta.getSelectFields()[0] = new SelectField(); stepMeta.getSelectFields()[0].setName( SELECTED_FIELD ); stepMeta.getMeta()[ 0 ] = new SelectMetadataChange( stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_BIGNUMBER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, null ); stepData = new SelectValuesData(); stepData.select = true; stepData.metadata = true; stepData.firstselect = true; stepData.firstmetadata = true; step2.processRow( stepMeta, stepData ); vmi = step2.rowMeta.getValueMeta( 0 ); assertEquals( ValueMetaBase.DEFAULT_BIG_NUMBER_FORMAT_MASK, vmi.getConversionMask() ); }
@Test public void testPDI16368() throws Exception { SelectValuesHandler step2 = null; Object[] inputRow2 = null; RowMeta inputRowMeta = null; SelectValuesMeta stepMeta = null; SelectValuesData stepData = null; ValueMetaInterface vmi = null; step2 = new SelectValuesHandler( helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans ); step2 = spy( step2 ); inputRow2 = new Object[] { new BigDecimal( "589" ) }; doReturn( inputRow2 ).when( step2 ).getRow(); doNothing().when( step2 ) .putError( any( RowMetaInterface.class ), any( Object[].class ), anyLong(), anyString(), anyString(), anyString() ); inputRowMeta = new RowMeta(); inputRowMeta.addValueMeta( new ValueMetaBigNumber( SELECTED_FIELD ) ); step2.setInputRowMeta( inputRowMeta ); stepMeta = new SelectValuesMeta(); stepMeta.allocate( 1, 0, 1 ); stepMeta.getSelectFields()[0] = new SelectField(); stepMeta.getSelectFields()[0].setName( SELECTED_FIELD ); stepMeta.getMeta()[ 0 ] = new SelectMetadataChange( stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_INTEGER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, null ); stepData = new SelectValuesData(); stepData.select = true; stepData.metadata = true; stepData.firstselect = true; stepData.firstmetadata = true; step2.processRow( stepMeta, stepData ); vmi = step2.rowMeta.getValueMeta( 0 ); assertEquals( ValueMetaBase.DEFAULT_BIG_NUMBER_FORMAT_MASK, vmi.getConversionMask() ); step2 = new SelectValuesHandler( helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans ); step2 = spy( step2 ); doReturn( inputRow2 ).when( step2 ).getRow(); doNothing().when( step2 ) .putError( any( RowMetaInterface.class ), any( Object[].class ), anyLong(), anyString(), anyString(), anyString() ); inputRowMeta = new RowMeta(); inputRowMeta.addValueMeta( new ValueMetaBigNumber( SELECTED_FIELD ) ); step2.setInputRowMeta( inputRowMeta ); stepMeta = new SelectValuesMeta(); stepMeta.allocate( 1, 0, 1 ); stepMeta.getSelectFields()[0] = new SelectField(); stepMeta.getSelectFields()[0].setName( SELECTED_FIELD ); stepMeta.getMeta()[ 0 ] = new SelectMetadataChange( stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_NUMBER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, null ); stepData = new SelectValuesData(); stepData.select = true; stepData.metadata = true; stepData.firstselect = true; stepData.firstmetadata = true; step2.processRow( stepMeta, stepData ); vmi = step2.rowMeta.getValueMeta( 0 ); assertEquals( ValueMetaBase.DEFAULT_BIG_NUMBER_FORMAT_MASK, vmi.getConversionMask() ); step2 = new SelectValuesHandler( helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans ); step2 = spy( step2 ); inputRow2 = new Object[] { new Long( "589" ) }; doReturn( inputRow2 ).when( step2 ).getRow(); doNothing().when( step2 ) .putError( any( RowMetaInterface.class ), any( Object[].class ), anyLong(), anyString(), anyString(), anyString() ); inputRowMeta = new RowMeta(); inputRowMeta.addValueMeta( new ValueMetaInteger( SELECTED_FIELD ) ); step2.setInputRowMeta( inputRowMeta ); stepMeta = new SelectValuesMeta(); stepMeta.allocate( 1, 0, 1 ); stepMeta.getSelectFields()[0] = new SelectField(); stepMeta.getSelectFields()[0].setName( SELECTED_FIELD ); stepMeta.getMeta()[ 0 ] = new SelectMetadataChange( stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_BIGNUMBER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, null ); stepData = new SelectValuesData(); stepData.select = true; stepData.metadata = true; stepData.firstselect = true; stepData.firstmetadata = true; step2.processRow( stepMeta, stepData ); vmi = step2.rowMeta.getValueMeta( 0 ); assertEquals( ValueMetaBase.DEFAULT_INTEGER_FORMAT_MASK, vmi.getConversionMask() ); step2 = new SelectValuesHandler( helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans ); step2.setVariable( Const.KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS, "Y" ); step2 = spy( step2 ); inputRow2 = new Object[] { new BigDecimal( "589" ) }; doReturn( inputRow2 ).when( step2 ).getRow(); doNothing().when( step2 ) .putError( any( RowMetaInterface.class ), any( Object[].class ), anyLong(), anyString(), anyString(), anyString() ); inputRowMeta = new RowMeta(); inputRowMeta.addValueMeta( new ValueMetaBigNumber( SELECTED_FIELD ) ); step2.setInputRowMeta( inputRowMeta ); stepMeta = new SelectValuesMeta(); stepMeta.allocate( 1, 0, 1 ); stepMeta.getSelectFields()[0] = new SelectField(); stepMeta.getSelectFields()[0].setName( SELECTED_FIELD ); stepMeta.getMeta()[ 0 ] = new SelectMetadataChange( stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_INTEGER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, null ); stepData = new SelectValuesData(); stepData.select = true; stepData.metadata = true; stepData.firstselect = true; stepData.firstmetadata = true; step2.processRow( stepMeta, stepData ); vmi = step2.rowMeta.getValueMeta( 0 ); assertEquals( ValueMetaBase.DEFAULT_INTEGER_FORMAT_MASK, vmi.getConversionMask() ); step2 = new SelectValuesHandler( helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans ); step2.setVariable( Const.KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS, "Y" ); step2 = spy( step2 ); doReturn( inputRow2 ).when( step2 ).getRow(); doNothing().when( step2 ) .putError( any( RowMetaInterface.class ), any( Object[].class ), anyLong(), anyString(), anyString(), anyString() ); inputRowMeta = new RowMeta(); inputRowMeta.addValueMeta( new ValueMetaBigNumber( SELECTED_FIELD ) ); step2.setInputRowMeta( inputRowMeta ); stepMeta = new SelectValuesMeta(); stepMeta.allocate( 1, 0, 1 ); stepMeta.getSelectFields()[0] = new SelectField(); stepMeta.getSelectFields()[0].setName( SELECTED_FIELD ); stepMeta.getMeta()[ 0 ] = new SelectMetadataChange( stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_NUMBER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, null ); stepData = new SelectValuesData(); stepData.select = true; stepData.metadata = true; stepData.firstselect = true; stepData.firstmetadata = true; step2.processRow( stepMeta, stepData ); vmi = step2.rowMeta.getValueMeta( 0 ); assertEquals( ValueMetaBase.DEFAULT_NUMBER_FORMAT_MASK, vmi.getConversionMask() ); step2 = new SelectValuesHandler( helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans ); step2.setVariable( Const.KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS, "Y" ); step2 = spy( step2 ); inputRow2 = new Object[] { new Long( "589" ) }; doReturn( inputRow2 ).when( step2 ).getRow(); doNothing().when( step2 ) .putError( any( RowMetaInterface.class ), any( Object[].class ), anyLong(), anyString(), anyString(), anyString() ); inputRowMeta = new RowMeta(); inputRowMeta.addValueMeta( new ValueMetaInteger( SELECTED_FIELD ) ); step2.setInputRowMeta( inputRowMeta ); stepMeta = new SelectValuesMeta(); stepMeta.allocate( 1, 0, 1 ); stepMeta.getSelectFields()[0] = new SelectField(); stepMeta.getSelectFields()[0].setName( SELECTED_FIELD ); stepMeta.getMeta()[ 0 ] = new SelectMetadataChange( stepMeta, SELECTED_FIELD, null, ValueMetaInterface.TYPE_BIGNUMBER, -2, -2, ValueMetaInterface.STORAGE_TYPE_NORMAL, null, false, null, null, false, null, null, null ); stepData = new SelectValuesData(); stepData.select = true; stepData.metadata = true; stepData.firstselect = true; stepData.firstmetadata = true; step2.processRow( stepMeta, stepData ); vmi = step2.rowMeta.getValueMeta( 0 ); assertEquals( ValueMetaBase.DEFAULT_BIG_NUMBER_FORMAT_MASK, vmi.getConversionMask() ); }
|
ScriptValuesMod extends BaseStep implements StepInterface { public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { meta = (ScriptValuesMetaMod) smi; data = (ScriptValuesModData) sdi; if ( super.init( smi, sdi ) ) { jsScripts = meta.getJSScripts(); for ( int j = 0; j < jsScripts.length; j++ ) { switch ( jsScripts[ j ].getScriptType() ) { case ScriptValuesScript.TRANSFORM_SCRIPT: strTransformScript = jsScripts[ j ].getScript(); break; case ScriptValuesScript.START_SCRIPT: strStartScript = jsScripts[ j ].getScript(); break; case ScriptValuesScript.END_SCRIPT: strEndScript = jsScripts[ j ].getScript(); break; default: break; } } return true; } return false; } ScriptValuesMod( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); Object getValueFromJScript( Object result, int i ); RowMetaInterface getOutputRowMeta(); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); static final int SKIP_TRANSFORMATION; static final int ABORT_TRANSFORMATION; static final int ERROR_TRANSFORMATION; static final int CONTINUE_TRANSFORMATION; public Script script; }
|
@Test public void bigNumberAreNotTrimmedToInt() throws Exception { ScriptValuesMod step = StepMockUtil.getStep( ScriptValuesMod.class, ScriptValuesMetaMod.class, "test" ); RowMeta input = new RowMeta(); input.addValueMeta( new ValueMetaBigNumber( "value_int" ) ); input.addValueMeta( new ValueMetaBigNumber( "value_double" ) ); step.setInputRowMeta( input ); step = spy( step ); doReturn( new Object[] { BigDecimal.ONE, BigDecimal.ONE } ).when( step ).getRow(); ScriptValuesMetaMod meta = new ScriptValuesMetaMod(); meta.setCompatible( false ); meta.allocate( 2 ); meta.setFieldname( new String[] { "value_int", "value_double" } ); meta.setType( new int[] { ValueMetaInterface.TYPE_BIGNUMBER, ValueMetaInterface.TYPE_BIGNUMBER } ); meta.setReplace( new boolean[] { true, true } ); meta.setJSScripts( new ScriptValuesScript[] { new ScriptValuesScript( ScriptValuesScript.TRANSFORM_SCRIPT, "script", "value_int = 10.00;\nvalue_double = 10.50" ) } ); ScriptValuesModData data = new ScriptValuesModData(); step.init( meta, data ); Object[] expectedRow = { BigDecimal.TEN, new BigDecimal( "10.5" ) }; Object[] row = TransTestingUtil.execute( step, meta, data, 1, false ).get( 0 ); TransTestingUtil.assertResult( expectedRow, row ); }
@Test public void variableIsSetInScopeOfStep() throws Exception { ScriptValuesMod step = StepMockUtil.getStep( ScriptValuesMod.class, ScriptValuesMetaMod.class, "test" ); RowMeta input = new RowMeta(); input.addValueMeta( new ValueMetaString( "str" ) ); step.setInputRowMeta( input ); step = spy( step ); doReturn( new Object[] { "" } ).when( step ).getRow(); ScriptValuesMetaMod meta = new ScriptValuesMetaMod(); meta.setCompatible( false ); meta.allocate( 1 ); meta.setFieldname( new String[] { "str" } ); meta.setType( new int[] { ValueMetaInterface.TYPE_STRING } ); meta.setReplace( new boolean[] { true } ); meta.setJSScripts( new ScriptValuesScript[] { new ScriptValuesScript( ScriptValuesScript.TRANSFORM_SCRIPT, "script", "setVariable('temp', 'pass', 'r');\nstr = getVariable('temp', 'fail');" ) } ); ScriptValuesModData data = new ScriptValuesModData(); step.init( meta, data ); Object[] expectedRow = { "pass" }; Object[] row = TransTestingUtil.execute( step, meta, data, 1, false ).get( 0 ); TransTestingUtil.assertResult( expectedRow, row ); }
|
DataHandler extends AbstractXulEventHandler { public void onCancel() { close(); } DataHandler(); void loadConnectionData(); void loadAccessData(); void editOptions( int index ); void clearOptionsData(); void getOptionHelp(); void setDeckChildIndex(); void onPoolingCheck(); void onClusterCheck(); Object getData(); void setData( Object data ); void pushCache(); void popCache(); void onCancel(); void onOK(); void testDatabaseConnection(); void restoreDefaults(); void poolingRowChange( int idx ); void disablePortIfInstancePopulated(); void handleUseSecurityCheckbox(); static final SortedMap<String, DatabaseInterface> connectionMap; static final Map<String, String> connectionNametoID; }
|
@Test public void testOnCancel() throws Exception { }
|
SFTPPut extends BaseStep implements StepInterface { @VisibleForTesting void checkRemoteFilenameField( String remoteFilenameFieldName, SFTPPutData data ) throws KettleStepException { remoteFilenameFieldName = environmentSubstitute( remoteFilenameFieldName ); if ( !Utils.isEmpty( remoteFilenameFieldName ) ) { data.indexOfRemoteFilename = getInputRowMeta().indexOfValue( remoteFilenameFieldName ); if ( data.indexOfRemoteFilename == -1 ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.CanNotFindField", remoteFilenameFieldName ) ); } } } SFTPPut( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
|
@Test public void checkRemoteFilenameField_FieldNameIsBlank() throws Exception { SFTPPutData data = new SFTPPutData(); step.checkRemoteFilenameField( "", data ); assertEquals( -1, data.indexOfSourceFileFieldName ); }
@Test( expected = KettleStepException.class ) public void checkRemoteFilenameField_FieldNameIsSet_NotFound() throws Exception { step.setInputRowMeta( new RowMeta() ); step.checkRemoteFilenameField( "remoteFileName", new SFTPPutData() ); }
@Test public void checkRemoteFilenameField_FieldNameIsSet_Found() throws Exception { RowMeta rowMeta = rowOfStringsMeta( "some field", "remoteFileName" ); step.setInputRowMeta( rowMeta ); SFTPPutData data = new SFTPPutData(); step.checkRemoteFilenameField( "remoteFileName", data ); assertEquals( 1, data.indexOfRemoteFilename ); }
|
SFTPPut extends BaseStep implements StepInterface { @VisibleForTesting void checkSourceFileField( String sourceFilenameFieldName, SFTPPutData data ) throws KettleStepException { sourceFilenameFieldName = environmentSubstitute( sourceFilenameFieldName ); if ( Utils.isEmpty( sourceFilenameFieldName ) ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.SourceFileNameFieldMissing" ) ); } data.indexOfSourceFileFieldName = getInputRowMeta().indexOfValue( sourceFilenameFieldName ); if ( data.indexOfSourceFileFieldName == -1 ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.CanNotFindField", sourceFilenameFieldName ) ); } } SFTPPut( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
|
@Test( expected = KettleStepException.class ) public void checkSourceFileField_NameIsBlank() throws Exception { SFTPPutData data = new SFTPPutData(); step.checkSourceFileField( "", data ); }
@Test( expected = KettleStepException.class ) public void checkSourceFileField_NameIsSet_NotFound() throws Exception { step.setInputRowMeta( new RowMeta() ); step.checkSourceFileField( "sourceFile", new SFTPPutData() ); }
@Test public void checkSourceFileField_NameIsSet_Found() throws Exception { RowMeta rowMeta = rowOfStringsMeta( "some field", "sourceFileFieldName" ); step.setInputRowMeta( rowMeta ); SFTPPutData data = new SFTPPutData(); step.checkSourceFileField( "sourceFileFieldName", data ); assertEquals( 1, data.indexOfSourceFileFieldName ); }
|
SFTPPut extends BaseStep implements StepInterface { @VisibleForTesting void checkRemoteFoldernameField( String remoteFoldernameFieldName, SFTPPutData data ) throws KettleStepException { remoteFoldernameFieldName = environmentSubstitute( remoteFoldernameFieldName ); if ( Utils.isEmpty( remoteFoldernameFieldName ) ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.RemoteFolderNameFieldMissing" ) ); } data.indexOfRemoteDirectory = getInputRowMeta().indexOfValue( remoteFoldernameFieldName ); if ( data.indexOfRemoteDirectory == -1 ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.CanNotFindField", remoteFoldernameFieldName ) ); } } SFTPPut( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
|
@Test( expected = KettleStepException.class ) public void checkRemoteFoldernameField_NameIsBlank() throws Exception { SFTPPutData data = new SFTPPutData(); step.checkRemoteFoldernameField( "", data ); }
@Test( expected = KettleStepException.class ) public void checkRemoteFoldernameField_NameIsSet_NotFound() throws Exception { step.setInputRowMeta( new RowMeta() ); step.checkRemoteFoldernameField( "remoteFolder", new SFTPPutData() ); }
@Test public void checkRemoteFoldernameField_NameIsSet_Found() throws Exception { RowMeta rowMeta = rowOfStringsMeta( "some field", "remoteFoldernameFieldName" ); step.setInputRowMeta( rowMeta ); SFTPPutData data = new SFTPPutData(); step.checkRemoteFoldernameField( "remoteFoldernameFieldName", data ); assertEquals( 1, data.indexOfRemoteDirectory ); }
|
DataHandler extends AbstractXulEventHandler { public void onOK() { DatabaseMeta database = new DatabaseMeta(); this.getInfo( database ); boolean passed = checkPoolingParameters(); if ( !passed ) { return; } String[] remarks = database.checkParameters(); String message = ""; if ( remarks.length != 0 ) { for ( int i = 0; i < remarks.length; i++ ) { message = message.concat( "* " ).concat( remarks[i] ).concat( System.getProperty( "line.separator" ) ); } showMessage( message, false ); } else { if ( databaseMeta == null ) { databaseMeta = new DatabaseMeta(); } this.getInfo( databaseMeta ); databaseMeta.setChanged(); close(); } } DataHandler(); void loadConnectionData(); void loadAccessData(); void editOptions( int index ); void clearOptionsData(); void getOptionHelp(); void setDeckChildIndex(); void onPoolingCheck(); void onClusterCheck(); Object getData(); void setData( Object data ); void pushCache(); void popCache(); void onCancel(); void onOK(); void testDatabaseConnection(); void restoreDefaults(); void poolingRowChange( int idx ); void disablePortIfInstancePopulated(); void handleUseSecurityCheckbox(); static final SortedMap<String, DatabaseInterface> connectionMap; static final Map<String, String> connectionNametoID; }
|
@Test public void testOnOK() throws Exception { }
|
SFTPPut extends BaseStep implements StepInterface { @VisibleForTesting void checkDestinationFolderField( String realDestinationFoldernameFieldName, SFTPPutData data ) throws KettleStepException { realDestinationFoldernameFieldName = environmentSubstitute( realDestinationFoldernameFieldName ); if ( Utils.isEmpty( realDestinationFoldernameFieldName ) ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Log.DestinatFolderNameFieldNameMissing" ) ); } data.indexOfMoveToFolderFieldName = getInputRowMeta().indexOfValue( realDestinationFoldernameFieldName ); if ( data.indexOfMoveToFolderFieldName == -1 ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.CanNotFindField", realDestinationFoldernameFieldName ) ); } } SFTPPut( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
|
@Test( expected = KettleStepException.class ) public void checkDestinationFolderField_NameIsBlank() throws Exception { SFTPPutData data = new SFTPPutData(); step.checkDestinationFolderField( "", data ); }
@Test( expected = KettleStepException.class ) public void checkDestinationFolderField_NameIsSet_NotFound() throws Exception { step.setInputRowMeta( new RowMeta() ); step.checkDestinationFolderField( "destinationFolder", new SFTPPutData() ); }
@Test public void checkDestinationFolderField_NameIsSet_Found() throws Exception { RowMeta rowMeta = rowOfStringsMeta( "some field", "destinationFolderFieldName" ); step.setInputRowMeta( rowMeta ); SFTPPutData data = new SFTPPutData(); step.checkDestinationFolderField( "destinationFolderFieldName", data ); assertEquals( 1, data.indexOfMoveToFolderFieldName ); }
|
SFTPPut extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (SFTPPutMeta) smi; data = (SFTPPutData) sdi; boolean sendToErrorRow = false; String errorMessage = null; Object[] r = getRow(); if ( r == null ) { setOutputDone(); return false; } if ( first ) { first = false; try { String realServerName = environmentSubstitute( meta.getServerName() ); String realServerPort = environmentSubstitute( meta.getServerPort() ); String realUsername = environmentSubstitute( meta.getUserName() ); String realPassword = Encr.decryptPasswordOptionallyEncrypted( environmentSubstitute( meta.getPassword() ) ); String realKeyFilename = null; String realPassPhrase = null; if ( meta.isUseKeyFile() ) { realKeyFilename = environmentSubstitute( meta.getKeyFilename() ); if ( Utils.isEmpty( realKeyFilename ) ) { logError( BaseMessages.getString( PKG, "SFTPPut.Error.KeyFileMissing" ) ); return false; } if ( !KettleVFS.fileExists( realKeyFilename ) ) { logError( BaseMessages.getString( PKG, "SFTPPut.Error.KeyFileNotFound", realKeyFilename ) ); return false; } realPassPhrase = environmentSubstitute( meta.getKeyPassPhrase() ); } data.sftpclient = createSftpClient( realServerName, realServerPort, realUsername, realKeyFilename, realPassPhrase ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "SFTPPUT.Log.OpenedConnection", realServerName, realServerPort, realUsername ) ); } data.sftpclient.setCompression( meta.getCompression() ); String realProxyHost = environmentSubstitute( meta.getProxyHost() ); if ( !Utils.isEmpty( realProxyHost ) ) { data.sftpclient.setProxy( realProxyHost, environmentSubstitute( meta.getProxyPort() ), environmentSubstitute( meta .getProxyUsername() ), environmentSubstitute( meta.getProxyPassword() ), meta.getProxyType() ); } data.sftpclient.login( realPassword ); } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "SFTPPUT.Error.Connection" ), e ); } checkSourceFileField( meta.getSourceFileFieldName(), data ); checkRemoteFoldernameField( meta.getRemoteDirectoryFieldName(), data ); checkRemoteFilenameField( meta.getRemoteFilenameFieldName(), data ); if ( meta.getAfterFTPS() == JobEntrySFTPPUT.AFTER_FTPSPUT_MOVE ) { checkDestinationFolderField( meta.getDestinationFolderFieldName(), data ); } } String sourceData = getInputRowMeta().getString( r, data.indexOfSourceFileFieldName ); InputStream inputStream = null; FileObject destinationFolder = null; String destinationFilename; FileObject file = null; try { if ( Utils.isEmpty( sourceData ) ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.SourceDataEmpty" ) ); } if ( meta.isInputStream() ) { inputStream = new ByteArrayInputStream( sourceData.getBytes() ); if ( data.indexOfRemoteFilename == -1 ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.RemoteFilenameFieldMissing" ) ); } destinationFilename = getInputRowMeta().getString( r, data.indexOfRemoteFilename ); } else { file = KettleVFS.getFileObject( sourceData ); if ( !file.exists() ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.CanNotFindField", sourceData ) ); } inputStream = KettleVFS.getInputStream( file ); destinationFilename = file.getName().getBaseName(); } if ( file != null ) { if ( meta.getAfterFTPS() == JobEntrySFTPPUT.AFTER_FTPSPUT_MOVE ) { String realDestationFolder = getInputRowMeta().getString( r, data.indexOfMoveToFolderFieldName ); if ( Utils.isEmpty( realDestationFolder ) ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.MoveToDestinationFolderIsEmpty" ) ); } destinationFolder = KettleVFS.getFileObject( realDestationFolder ); if ( !destinationFolder.exists() ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.CanNotFindFolder", realDestationFolder ) ); } } } setSFTPDirectory( getInputRowMeta().getString( r, data.indexOfRemoteDirectory ) ); data.sftpclient.put( inputStream, destinationFilename ); if ( file != null ) { finishTheJob( file, sourceData, destinationFolder ); } putRow( getInputRowMeta(), r ); if ( checkFeedback( getLinesRead() ) ) { if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "SFTPPut.Log.LineNumber" ) + getLinesRead() ); } } } catch ( Exception e ) { if ( getStepMeta().isDoingErrorHandling() ) { sendToErrorRow = true; errorMessage = e.toString(); } else { logError( BaseMessages.getString( PKG, "SFTPPut.Log.ErrorInStep" ), e ); setErrors( 1 ); stopAll(); setOutputDone(); return false; } if ( sendToErrorRow ) { putError( getInputRowMeta(), r, 1, errorMessage, null, "SFTPPUT001" ); } } finally { try { if ( destinationFolder != null ) { destinationFolder.close(); } if ( file != null ) { file.close(); } if ( inputStream != null ) { inputStream.close(); } } catch ( Exception e ) { } } return true; } SFTPPut( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
|
@Test public void remoteFilenameFieldIsMandatoryWhenStreamingFromInputField() throws Exception { RowMeta rowMeta = rowOfStringsMeta( "sourceFilenameFieldName", "remoteDirectoryFieldName" ); step.setInputRowMeta( rowMeta ); doReturn( new Object[] { "qwerty", "asdfg" } ).when( step ).getRow(); SFTPPutMeta meta = new SFTPPutMeta(); meta.setInputStream( true ); meta.setPassword( "qwerty" ); meta.setSourceFileFieldName( "sourceFilenameFieldName" ); meta.setRemoteDirectoryFieldName( "remoteDirectoryFieldName" ); step.processRow( meta, new SFTPPutData() ); assertEquals( 1, step.getErrors() ); }
|
SystemDataMeta extends BaseStepMeta implements StepMetaInterface { @Override public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException { readData( stepnode ); } SystemDataMeta(); String[] getFieldName(); void setFieldName( String[] fieldName ); SystemDataTypes[] getFieldType(); void setFieldType( SystemDataTypes[] fieldType ); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void allocate( int count ); @Override Object clone(); static final SystemDataTypes getType( String type ); static final String getTypeDesc( SystemDataTypes t ); @Override void setDefault(); @Override void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); @Override String getXML(); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); @Override void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); @Override Map<String, String> getUsedArguments(); @Override StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ); @Override StepDataInterface getStepData(); @Override boolean equals( Object o ); @Override int hashCode(); }
|
@Test public void testLoadXML() throws Exception { SystemDataMeta systemDataMeta = new SystemDataMeta(); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document document = documentBuilder.parse( new InputSource( new StringReader( expectedXML ) ) ); Node node = document; IMetaStore store = null; systemDataMeta.loadXML( node, null, store ); assertEquals( expectedSystemDataMeta, systemDataMeta ); }
|
SystemDataMeta extends BaseStepMeta implements StepMetaInterface { @Override public String getXML() { StringBuilder retval = new StringBuilder(); retval.append( " <fields>" + Const.CR ); for ( int i = 0; i < fieldName.length; i++ ) { retval.append( " <field>" + Const.CR ); retval.append( " " + XMLHandler.addTagValue( "name", fieldName[i] ) ); retval.append( " " + XMLHandler.addTagValue( "type", fieldType[i] != null ? fieldType[i].getCode() : "" ) ); retval.append( " </field>" + Const.CR ); } retval.append( " </fields>" + Const.CR ); return retval.toString(); } SystemDataMeta(); String[] getFieldName(); void setFieldName( String[] fieldName ); SystemDataTypes[] getFieldType(); void setFieldType( SystemDataTypes[] fieldType ); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void allocate( int count ); @Override Object clone(); static final SystemDataTypes getType( String type ); static final String getTypeDesc( SystemDataTypes t ); @Override void setDefault(); @Override void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); @Override String getXML(); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); @Override void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); @Override Map<String, String> getUsedArguments(); @Override StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ); @Override StepDataInterface getStepData(); @Override boolean equals( Object o ); @Override int hashCode(); }
|
@Test public void testGetXML() throws Exception { String generatedXML = expectedSystemDataMeta.getXML(); assertEquals( expectedXML.replaceAll( "\n", "" ).replaceAll( "\r", "" ), generatedXML.replaceAll( "\n", "" ) .replaceAll( "\r", "" ) ); }
|
SystemData extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { Object[] row; if ( data.readsRows ) { row = getRow(); if ( row == null ) { setOutputDone(); return false; } if ( first ) { first = false; data.outputRowMeta = getInputRowMeta().clone(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); } } else { row = new Object[] {}; incrementLinesRead(); if ( first ) { first = false; data.outputRowMeta = new RowMeta(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); } } RowMetaInterface imeta = getInputRowMeta(); if ( imeta == null ) { imeta = new RowMeta(); this.setInputRowMeta( imeta ); } row = getSystemData( imeta, row ); if ( log.isRowLevel() ) { logRowlevel( "System info returned: " + data.outputRowMeta.getString( row ) ); } putRow( data.outputRowMeta, row ); if ( !data.readsRows ) { setOutputDone(); return false; } return true; } SystemData( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
|
@Test public void testProcessRow() throws Exception { SystemDataData systemDataData = new SystemDataData(); SystemDataMeta systemDataMeta = new SystemDataMeta(); systemDataMeta.allocate( 2 ); String[] names = systemDataMeta.getFieldName(); SystemDataTypes[] types = systemDataMeta.getFieldType(); names[0] = "hostname"; names[1] = "hostname_real"; types[0] = SystemDataMeta.getType( SystemDataMeta.getTypeDesc( SystemDataTypes.TYPE_SYSTEM_INFO_HOSTNAME ) ); types[1] = SystemDataMeta.getType( SystemDataMeta.getTypeDesc( SystemDataTypes.TYPE_SYSTEM_INFO_HOSTNAME_REAL ) ); SystemDataHandler systemData = new SystemDataHandler( stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans ); Object[] expectedRow = new Object[] { Const.getHostname(), Const.getHostnameReal() }; RowMetaInterface inputRowMeta = mock( RowMetaInterface.class ); when( inputRowMeta.clone() ).thenReturn( inputRowMeta ); when( inputRowMeta.size() ).thenReturn( 2 ); systemDataData.outputRowMeta = inputRowMeta; systemData.init( systemDataMeta, systemDataData ); assertFalse( systemData.processRow( systemDataMeta, systemDataData ) ); Object[] out = systemData.getOutputRow(); assertArrayEquals( expectedRow, out ); }
|
MailInput extends BaseStep implements StepInterface { public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { meta = (MailInputMeta) smi; data = (MailInputData) sdi; if ( !super.init( smi, sdi ) ) { return false; } if ( !meta.isDynamicFolder() ) { try { data.outputRowMeta = new RowMeta(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); } catch ( Exception e ) { logError( BaseMessages.getString( PKG, "MailInput.ErrorInit", e.toString() ) ); logError( Const.getStackTracker( e ) ); return false; } } data.usePOP = meta.getProtocol().equals( MailConnectionMeta.PROTOCOL_STRING_POP3 ); String realserver = environmentSubstitute( meta.getServerName() ); if ( meta.getProtocol().equals( MailConnectionMeta.PROTOCOL_STRING_MBOX ) && StringUtils.startsWith( realserver, "file: realserver = StringUtils.remove( realserver, "file: } String realusername = environmentSubstitute( meta.getUserName() ); String realpassword = Utils.resolvePassword( variables, meta.getPassword() ); int realport = Const.toInt( environmentSubstitute( meta.getPort() ), -1 ); String realProxyUsername = environmentSubstitute( meta.getProxyUsername() ); if ( !meta.isDynamicFolder() ) { String reallimitrow = environmentSubstitute( meta.getRowLimit() ); int limit = Const.toInt( reallimitrow, 0 ); if ( limit == 0 ) { limit = getReadFirst( meta.getProtocol() ); } data.rowlimit = limit; } Date beginDate = null; Date endDate = null; SimpleDateFormat df = new SimpleDateFormat( MailInputMeta.DATE_PATTERN ); try { switch ( meta.getConditionOnReceivedDate() ) { case MailConnectionMeta.CONDITION_DATE_EQUAL: case MailConnectionMeta.CONDITION_DATE_GREATER: case MailConnectionMeta.CONDITION_DATE_SMALLER: String realBeginDate = environmentSubstitute( meta.getReceivedDate1() ); if ( Utils.isEmpty( realBeginDate ) ) { throw new KettleException( BaseMessages.getString( PKG, "MailInput.Error.ReceivedDateSearchTermEmpty" ) ); } beginDate = df.parse( realBeginDate ); break; case MailConnectionMeta.CONDITION_DATE_BETWEEN: realBeginDate = environmentSubstitute( meta.getReceivedDate1() ); if ( Utils.isEmpty( realBeginDate ) ) { throw new KettleException( BaseMessages.getString( PKG, "MailInput.Error.ReceivedDatesSearchTermEmpty" ) ); } beginDate = df.parse( realBeginDate ); String realEndDate = environmentSubstitute( meta.getReceivedDate2() ); if ( Utils.isEmpty( realEndDate ) ) { throw new KettleException( BaseMessages.getString( PKG, "MailInput.Error.ReceivedDatesSearchTermEmpty" ) ); } endDate = df.parse( realEndDate ); break; default: break; } } catch ( Exception e ) { logError( BaseMessages.getString( PKG, "MailInput.Error.SettingSearchTerms", e.getMessage() ) ); setErrors( 1 ); stopAll(); } try { data.mailConn = new MailConnection( log, MailConnectionMeta.getProtocolFromString( meta.getProtocol(), MailConnectionMeta.PROTOCOL_IMAP ), realserver, realport, realusername, realpassword, meta.isUseSSL(), meta.isUseProxy(), realProxyUsername ); data.mailConn.connect(); applySearch( beginDate, endDate ); if ( !meta.isDynamicFolder() ) { String realIMAPFolder = environmentSubstitute( meta.getIMAPFolder() ); data.folders = getFolders( realIMAPFolder ); } } catch ( Exception e ) { logError( BaseMessages.getString( PKG, "MailInput.Error.OpeningConnection", e.getMessage() ) ); setErrors( 1 ); stopAll(); } data.nrFields = meta.getInputFields() != null ? meta.getInputFields().length : 0; return true; } MailInput( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); String[] getFolders( String realIMAPFolder ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
|
@Test public void testInitSetGetFirstForIMAP() { MailInput step = new MailInput( mockHelper.stepMeta, mockHelper.stepDataInterface, 0, mockHelper.transMeta, mockHelper.trans ); MailInputData data = new MailInputData(); MailInputMeta meta = mock( MailInputMeta.class ); when( meta.isDynamicFolder() ).thenReturn( false ); when( meta.getProtocol() ).thenReturn( MailConnectionMeta.PROTOCOL_STRING_IMAP ); when( meta.getFirstIMAPMails() ).thenReturn( "2" ); when( meta.getFirstMails() ).thenReturn( "3" ); step.init( meta, data ); Assert.assertEquals( "Row Limit is set up to 2 rows.", 2, data.rowlimit ); }
@Test public void testInitSetGetFirstForPOP3() { MailInput step = new MailInput( mockHelper.stepMeta, mockHelper.stepDataInterface, 0, mockHelper.transMeta, mockHelper.trans ); MailInputData data = new MailInputData(); MailInputMeta meta = mock( MailInputMeta.class ); when( meta.isDynamicFolder() ).thenReturn( false ); when( meta.getProtocol() ).thenReturn( MailConnectionMeta.PROTOCOL_STRING_POP3 ); when( meta.getFirstIMAPMails() ).thenReturn( "2" ); when( meta.getFirstMails() ).thenReturn( "3" ); step.init( meta, data ); Assert.assertEquals( "Row Limit is set up to 3 rows.", 3, data.rowlimit ); }
@Test public void testInitSetGetFirstLimitOverride() { MailInput step = new MailInput( mockHelper.stepMeta, mockHelper.stepDataInterface, 0, mockHelper.transMeta, mockHelper.trans ); MailInputData data = new MailInputData(); MailInputMeta meta = mock( MailInputMeta.class ); when( meta.isDynamicFolder() ).thenReturn( false ); when( meta.getProtocol() ).thenReturn( MailConnectionMeta.PROTOCOL_STRING_POP3 ); when( meta.getFirstIMAPMails() ).thenReturn( "2" ); when( meta.getFirstMails() ).thenReturn( "3" ); when( meta.getRowLimit() ).thenReturn( "5" ); step.init( meta, data ); Assert.assertEquals( "Row Limit is set up to 5 rows as the Limit has priority.", 5, data.rowlimit ); }
@Test public void testInitSetGetFirstForMBOXIgnored() { MailInput step = new MailInput( mockHelper.stepMeta, mockHelper.stepDataInterface, 0, mockHelper.transMeta, mockHelper.trans ); MailInputData data = new MailInputData(); MailInputMeta meta = mock( MailInputMeta.class ); when( meta.isDynamicFolder() ).thenReturn( false ); when( meta.getProtocol() ).thenReturn( MailConnectionMeta.PROTOCOL_STRING_MBOX ); when( meta.getFirstIMAPMails() ).thenReturn( "2" ); when( meta.getFirstMails() ).thenReturn( "3" ); step.init( meta, data ); Assert.assertEquals( "Row Limit is set up to 0 rows as the Limit has priority.", 0, data.rowlimit ); }
|
DataHandler extends AbstractXulEventHandler { protected void getInfo( DatabaseMeta meta ) { getControls(); if ( this.databaseMeta != null && this.databaseMeta != meta ) { meta.initializeVariablesFrom( this.databaseMeta ); } meta.setName( connectionNameBox.getValue() ); meta.setDisplayName( connectionNameBox.getValue() ); Object connection = connectionBox.getSelectedItem(); if ( connection != null ) { meta.setDatabaseType( (String) connection ); } Object access = accessBox.getSelectedItem(); if ( access != null ) { meta.setAccessType( DatabaseMeta.getAccessType( (String) access ) ); } getConnectionSpecificInfo( meta ); if ( portNumberBox != null ) { meta.setDBPort( portNumberBox.getValue() ); } if ( optionsParameterTree != null ) { Object[][] values = optionsParameterTree.getValues(); for ( int i = 0; i < values.length; i++ ) { String parameter = (String) values[i][0]; String value = (String) values[i][1]; if ( value == null ) { value = ""; } String dbType = meta.getPluginId(); if ( ( parameter != null ) && ( parameter.trim().length() > 0 ) ) { if ( value.trim().length() <= 0 ) { value = DatabaseMeta.EMPTY_OPTIONS_STRING; } meta.addExtraOption( dbType, parameter, value ); } } } if ( supportBooleanDataType != null ) { meta.setSupportsBooleanDataType( supportBooleanDataType.isChecked() ); } if ( supportTimestampDataType != null ) { meta.setSupportsTimestampDataType( supportTimestampDataType.isChecked() ); } if ( quoteIdentifiersCheck != null ) { meta.setQuoteAllFields( quoteIdentifiersCheck.isChecked() ); } if ( lowerCaseIdentifiersCheck != null ) { meta.setForcingIdentifiersToLowerCase( lowerCaseIdentifiersCheck.isChecked() ); } if ( upperCaseIdentifiersCheck != null ) { meta.setForcingIdentifiersToUpperCase( upperCaseIdentifiersCheck.isChecked() ); } if ( preserveReservedCaseCheck != null ) { meta.setPreserveReservedCase( preserveReservedCaseCheck.isChecked() ); } if ( strictBigNumberInterpretaion != null && meta.getDatabaseInterface() instanceof OracleDatabaseMeta ) { ( (OracleDatabaseMeta) meta.getDatabaseInterface() ) .setStrictBigNumberInterpretation( strictBigNumberInterpretaion.isChecked() ); } if ( preferredSchemaName != null ) { meta.setPreferredSchemaName( preferredSchemaName.getValue() ); } if ( sqlBox != null ) { meta.setConnectSQL( sqlBox.getValue() ); } if ( clusteringCheck != null ) { meta.setPartitioned( clusteringCheck.isChecked() ); } if ( ( clusterParameterTree != null ) && ( meta.isPartitioned() ) ) { Object[][] values = clusterParameterTree.getValues(); List<PartitionDatabaseMeta> pdms = new ArrayList<PartitionDatabaseMeta>(); for ( int i = 0; i < values.length; i++ ) { String partitionId = (String) values[i][0]; if ( ( partitionId == null ) || ( partitionId.trim().length() <= 0 ) ) { continue; } String hostname = (String) values[i][1]; String port = (String) values[i][2]; String dbName = (String) values[i][3]; String username = (String) values[i][4]; String password = (String) values[i][5]; PartitionDatabaseMeta pdm = new PartitionDatabaseMeta( partitionId, hostname, port, dbName ); pdm.setUsername( username ); pdm.setPassword( password ); pdms.add( pdm ); } PartitionDatabaseMeta[] pdmArray = new PartitionDatabaseMeta[pdms.size()]; meta.setPartitioningInformation( pdms.toArray( pdmArray ) ); } if ( poolingCheck != null ) { meta.setUsingConnectionPool( poolingCheck.isChecked() ); } if ( meta.isUsingConnectionPool() ) { if ( poolSizeBox != null ) { try { int initialPoolSize = Integer.parseInt( poolSizeBox.getValue() ); meta.setInitialPoolSize( initialPoolSize ); } catch ( NumberFormatException e ) { } } if ( maxPoolSizeBox != null ) { try { int maxPoolSize = Integer.parseInt( maxPoolSizeBox.getValue() ); meta.setMaximumPoolSize( maxPoolSize ); } catch ( NumberFormatException e ) { } } if ( poolParameterTree != null ) { Object[][] values = poolParameterTree.getValues(); Properties properties = new Properties(); for ( int i = 0; i < values.length; i++ ) { boolean isChecked = false; if ( values[i][0] instanceof Boolean ) { isChecked = ( (Boolean) values[i][0] ).booleanValue(); } else { isChecked = Boolean.valueOf( (String) values[i][0] ); } if ( !isChecked ) { continue; } String parameter = (String) values[i][1]; String value = (String) values[i][2]; if ( ( parameter != null ) && ( parameter.trim().length() > 0 ) && ( value != null ) && ( value.trim().length() > 0 ) ) { properties.setProperty( parameter, value ); } } meta.setConnectionPoolingProperties( properties ); } } } DataHandler(); void loadConnectionData(); void loadAccessData(); void editOptions( int index ); void clearOptionsData(); void getOptionHelp(); void setDeckChildIndex(); void onPoolingCheck(); void onClusterCheck(); Object getData(); void setData( Object data ); void pushCache(); void popCache(); void onCancel(); void onOK(); void testDatabaseConnection(); void restoreDefaults(); void poolingRowChange( int idx ); void disablePortIfInstancePopulated(); void handleUseSecurityCheckbox(); static final SortedMap<String, DatabaseInterface> connectionMap; static final Map<String, String> connectionNametoID; }
|
@Test public void testGetInfo() throws Exception { }
|
AccessInputMeta extends BaseStepMeta implements StepMetaInterface { @Override public Object clone() { AccessInputMeta retval = (AccessInputMeta) super.clone(); int nrFiles = fileName.length; int nrFields = inputFields.length; retval.allocate( nrFiles, nrFields ); System.arraycopy( fileName, 0, retval.fileName, 0, nrFiles ); System.arraycopy( fileMask, 0, retval.fileMask, 0, nrFiles ); System.arraycopy( excludeFileMask, 0, retval.excludeFileMask, 0, nrFiles ); System.arraycopy( fileRequired, 0, retval.fileRequired, 0, nrFiles ); System.arraycopy( includeSubFolders, 0, retval.includeSubFolders, 0, nrFiles ); for ( int i = 0; i < nrFields; i++ ) { if ( inputFields[i] != null ) { retval.inputFields[i] = (AccessInputField) inputFields[i].clone(); } } return retval; } AccessInputMeta(); String getExtensionField(); void setExtensionField( String field ); String getSizeField(); void setSizeField( String field ); String getShortFileNameField(); void setShortFileNameField( String field ); String getPathField(); void setPathField( String field ); String isHiddenField(); @Deprecated void setIsHiddenField( String field ); void setHiddenField( String field ); String getLastModificationDateField(); void setLastModificationDateField( String field ); String getUriField(); void setUriField( String field ); String getRootUriField(); void setRootUriField( String field ); AccessInputField[] getInputFields(); void setInputFields( AccessInputField[] inputFields ); String[] getExludeFileMask(); String[] getExcludeFileMask(); void setExcludeFileMask( String[] excludeFileMask ); String[] getFileMask(); String[] getFileRequired(); String getRequiredFilesDesc( String tt ); void setFileMask( String[] fileMask ); void setFileRequired( String[] fileRequiredin ); String getRequiredFilesCode( String tt ); String[] getIncludeSubFolders(); void setIncludeSubFolders( String[] includeSubFoldersin ); String[] getFileName(); void setFileName( String[] fileName ); String getFilenameField(); String getDynamicFilenameField(); void setDynamicFilenameField( String dynamicFilenameField ); void setFilenameField( String filenameField ); @Deprecated boolean includeFilename(); boolean isIncludeFilename(); @Deprecated boolean includeTablename(); boolean isIncludeTablename(); void setIncludeFilename( boolean includeFilename ); void setIncludeTablename( boolean includeTablename ); @Deprecated boolean includeRowNumber(); boolean isIncludeRowNumber(); boolean isFileField(); void setFileField( boolean filefield ); @Deprecated boolean resetRowNumber(); boolean isResetRowNumber(); void setIncludeRowNumber( boolean includeRowNumber ); void setAddResultFile( boolean isaddresult ); boolean isAddResultFile(); void setResetRowNumber( boolean resetRowNumber ); long getRowLimit(); void setRowLimit( long rowLimit ); String getRowNumberField(); @Deprecated String gettablenameField(); String getTablenameField(); String getTableName(); void setRowNumberField( String rowNumberField ); void setTablenameField( String tablenameField ); void setTableName( String TableName ); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); @Override Object clone(); @Override String getXML(); void allocate( int nrfiles, int nrfields ); void allocateFiles( int nrfiles ); void allocateFields( int nrfields ); @Override void setDefault(); @Override void getFields( RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); static final int getTrimTypeByCode( String tt ); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); FileInputList getFiles( VariableSpace space ); @Override void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); static String getFilename( FileObject fileObject ); @Override StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr,
Trans trans ); @Override StepDataInterface getStepData(); @Override boolean supportsErrorHandling(); String exportResources( VariableSpace space, Map<String, ResourceDefinition> definitions,
ResourceNamingInterface resourceNamingInterface, Repository repository, IMetaStore metaStore ); static ValueMetaInterface getValueMeta( Column c ); static ValueMetaAndData getValueMetaAndData( Column c, String name, Object data ); @Override StepMetaInjectionInterface getStepMetaInjectionInterface(); static final String[] RequiredFilesDesc; static final String[] RequiredFilesCode; static final String[] type_trim_code; static final String PREFIX_SYSTEM; }
|
@Test public void testClone() throws KettleException { AccessInputMeta meta = new AccessInputMeta(); meta.allocate( 3, 2 ); meta.setFileName( new String[] { "file1", "file2", "file3" } ); meta.setFileMask( new String[] { "mask1", "mask2", "mask3" } ); meta.setExcludeFileMask( new String[] { "exmask1", "exmask2", "exmask3" } ); meta.setFileRequired( new String[] { "false", "true", "false" } ); meta.setIncludeSubFolders( new String[] { "true", "false", "true" } ); AccessInputField f1 = new AccessInputField( "field1" ); AccessInputField f2 = new AccessInputField( "field2" ); meta.setInputFields( new AccessInputField[] { f1, f2 } ); meta.setFilenameField( "aFileNameField" ); AccessInputMeta aClone = (AccessInputMeta) meta.clone(); assertFalse( aClone == meta ); assertTrue( Arrays.equals( aClone.getFileName(), meta.getFileName() ) ); assertTrue( Arrays.equals( aClone.getFileMask(), meta.getFileMask() ) ); assertTrue( Arrays.equals( aClone.getExcludeFileMask(), meta.getExcludeFileMask() ) ); assertTrue( Arrays.equals( aClone.getFileRequired(), meta.getFileRequired() ) ); assertTrue( Arrays.equals( aClone.getIncludeSubFolders(), meta.getIncludeSubFolders() ) ); AccessInputField[] clFields = aClone.getInputFields(); assertEquals( f1.getName(), clFields[0].getName() ); assertEquals( f2.getName(), clFields[1].getName() ); assertEquals( meta.getFilenameField(), aClone.getFilenameField() ); assertEquals( meta.getXML(), aClone.getXML() ); }
|
MissingTransStep extends DummyTrans { public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { if ( super.init( smi, sdi ) ) { logError( BaseMessages.getString( PKG, "MissingTransStep.Log.CannotRunTrans" ) ); } return false; } MissingTransStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); }
|
@Test public void testInit() { StepMetaInterface stepMetaInterface = new AbstractStepMeta() { @Override public void setDefault() { } @Override public StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta, Trans trans ) { return null; } }; StepMeta stepMeta = new StepMeta(); stepMeta.setName( "TestMetaStep" ); StepDataInterface stepDataInterface = mock( StepDataInterface.class ); Trans trans = new Trans(); LogChannel log = mock( LogChannel.class ); doAnswer( new Answer<Void>() { public Void answer( InvocationOnMock invocation ) { return null; } } ).when( log ).logError( anyString() ); trans.setLog( log ); TransMeta transMeta = new TransMeta(); transMeta.addStep( stepMeta ); MissingTransStep step = createAndInitStep( stepMetaInterface, stepDataInterface ); assertFalse( step.init( stepMetaInterface, stepDataInterface ) ); }
|
TextFileInput extends BaseStep implements StepInterface { public static final String getLine( LogChannelInterface log, InputStreamReader reader, int formatNr, StringBuilder line ) throws KettleFileException { EncodingType type = EncodingType.guessEncodingType( reader.getEncoding() ); return getLine( log, reader, type, formatNr, line ); } TextFileInput( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); static final String getLine( LogChannelInterface log, InputStreamReader reader, int formatNr,
StringBuilder line ); static final String getLine( LogChannelInterface log, InputStreamReader reader, EncodingType encodingType,
int formatNr, StringBuilder line ); @Deprecated static final String[] guessStringsFromLine( LogChannelInterface log, String line, TextFileInputMeta inf,
String delimiter ); static final String[] guessStringsFromLine( VariableSpace space, LogChannelInterface log, String line,
TextFileInputMeta inf, String delimiter, String enclosure, String escapeCharacter ); static final String[] convertLineToStrings( LogChannelInterface log, String line, InputFileMetaInterface inf,
String delimiter, String enclosure, String escapeCharacters ); @Deprecated static final Object[] convertLineToRow( LogChannelInterface log, TextFileLine textFileLine,
InputFileMetaInterface info, RowMetaInterface outputRowMeta, RowMetaInterface convertRowMeta, String fname,
long rowNr, String delimiter, FileErrorHandler errorHandler, boolean addShortFilename, boolean addExtension,
boolean addPath, boolean addSize, boolean addIsHidden, boolean addLastModificationDate, boolean addUri,
boolean addRootUri, String shortFilename, String path, boolean hidden, Date modificationDateTime, String uri,
String rooturi, String extension, long size ); static Object[] convertLineToRow( LogChannelInterface log, TextFileLine textFileLine,
InputFileMetaInterface info, Object[] passThruFields, int nrPassThruFields, RowMetaInterface outputRowMeta,
RowMetaInterface convertRowMeta, String fname, long rowNr, String delimiter, String enclosure,
String escapeCharacter, FileErrorHandler errorHandler, boolean addShortFilename, boolean addExtension,
boolean addPath, boolean addSize, boolean addIsHidden, boolean addLastModificationDate, boolean addUri,
boolean addRootUri, String shortFilename, String path, boolean hidden, Date modificationDateTime, String uri,
String rooturi, String extension, long size ); @Override boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); @Override boolean init( StepMetaInterface smi, StepDataInterface sdi ); @Override void dispose( StepMetaInterface smi, StepDataInterface sdi ); boolean isWaitingForData(); }
|
@Test public void testGetLineDOS() throws KettleFileException, UnsupportedEncodingException { String input = "col1\tcol2\tcol3\r\ndata1\tdata2\tdata3\r\n"; String expected = "col1\tcol2\tcol3"; String output = TextFileInput.getLine( null, getInputStreamReader( input ), TextFileInputMeta.FILE_FORMAT_DOS, new StringBuilder( 1000 ) ); assertEquals( expected, output ); }
@Test public void testGetLineUnix() throws KettleFileException, UnsupportedEncodingException { String input = "col1\tcol2\tcol3\ndata1\tdata2\tdata3\n"; String expected = "col1\tcol2\tcol3"; String output = TextFileInput.getLine( null, getInputStreamReader( input ), TextFileInputMeta.FILE_FORMAT_UNIX, new StringBuilder( 1000 ) ); assertEquals( expected, output ); }
@Test public void testGetLineOSX() throws KettleFileException, UnsupportedEncodingException { String input = "col1\tcol2\tcol3\rdata1\tdata2\tdata3\r"; String expected = "col1\tcol2\tcol3"; String output = TextFileInput.getLine( null, getInputStreamReader( input ), TextFileInputMeta.FILE_FORMAT_UNIX, new StringBuilder( 1000 ) ); assertEquals( expected, output ); }
@Test public void testGetLineMixed() throws KettleFileException, UnsupportedEncodingException { String input = "col1\tcol2\tcol3\r\ndata1\tdata2\tdata3\r"; String expected = "col1\tcol2\tcol3"; String output = TextFileInput.getLine( null, getInputStreamReader( input ), TextFileInputMeta.FILE_FORMAT_MIXED, new StringBuilder( 1000 ) ); assertEquals( expected, output ); }
@Test( timeout = 100 ) public void test_PDI695() throws KettleFileException, UnsupportedEncodingException { String inputDOS = "col1\tcol2\tcol3\r\ndata1\tdata2\tdata3\r\n"; String inputUnix = "col1\tcol2\tcol3\ndata1\tdata2\tdata3\n"; String inputOSX = "col1\tcol2\tcol3\rdata1\tdata2\tdata3\r"; String expected = "col1\tcol2\tcol3"; assertEquals( expected, TextFileInput.getLine( null, getInputStreamReader( inputDOS ), TextFileInputMeta.FILE_FORMAT_UNIX, new StringBuilder( 1000 ) ) ); assertEquals( expected, TextFileInput.getLine( null, getInputStreamReader( inputUnix ), TextFileInputMeta.FILE_FORMAT_UNIX, new StringBuilder( 1000 ) ) ); assertEquals( expected, TextFileInput.getLine( null, getInputStreamReader( inputOSX ), TextFileInputMeta.FILE_FORMAT_UNIX, new StringBuilder( 1000 ) ) ); }
|
TextFileInput extends BaseStep implements StepInterface { private int addValueMeta( RowMetaInterface rowMeta, String fieldName ) { ValueMetaInterface valueMeta = new ValueMetaString( fieldName ); valueMeta.setOrigin( getStepname() ); int index = -1; if ( !rowMeta.exists( valueMeta ) ) { index = rowMeta.size(); rowMeta.addValueMeta( valueMeta ); } else { index = rowMeta.indexOfValue( fieldName ); } return index; } TextFileInput( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); static final String getLine( LogChannelInterface log, InputStreamReader reader, int formatNr,
StringBuilder line ); static final String getLine( LogChannelInterface log, InputStreamReader reader, EncodingType encodingType,
int formatNr, StringBuilder line ); @Deprecated static final String[] guessStringsFromLine( LogChannelInterface log, String line, TextFileInputMeta inf,
String delimiter ); static final String[] guessStringsFromLine( VariableSpace space, LogChannelInterface log, String line,
TextFileInputMeta inf, String delimiter, String enclosure, String escapeCharacter ); static final String[] convertLineToStrings( LogChannelInterface log, String line, InputFileMetaInterface inf,
String delimiter, String enclosure, String escapeCharacters ); @Deprecated static final Object[] convertLineToRow( LogChannelInterface log, TextFileLine textFileLine,
InputFileMetaInterface info, RowMetaInterface outputRowMeta, RowMetaInterface convertRowMeta, String fname,
long rowNr, String delimiter, FileErrorHandler errorHandler, boolean addShortFilename, boolean addExtension,
boolean addPath, boolean addSize, boolean addIsHidden, boolean addLastModificationDate, boolean addUri,
boolean addRootUri, String shortFilename, String path, boolean hidden, Date modificationDateTime, String uri,
String rooturi, String extension, long size ); static Object[] convertLineToRow( LogChannelInterface log, TextFileLine textFileLine,
InputFileMetaInterface info, Object[] passThruFields, int nrPassThruFields, RowMetaInterface outputRowMeta,
RowMetaInterface convertRowMeta, String fname, long rowNr, String delimiter, String enclosure,
String escapeCharacter, FileErrorHandler errorHandler, boolean addShortFilename, boolean addExtension,
boolean addPath, boolean addSize, boolean addIsHidden, boolean addLastModificationDate, boolean addUri,
boolean addRootUri, String shortFilename, String path, boolean hidden, Date modificationDateTime, String uri,
String rooturi, String extension, long size ); @Override boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); @Override boolean init( StepMetaInterface smi, StepDataInterface sdi ); @Override void dispose( StepMetaInterface smi, StepDataInterface sdi ); boolean isWaitingForData(); }
|
@Test public void readWrappedInputWithoutHeaders() throws Exception { final String content = new StringBuilder() .append( "r1c1" ).append( '\n' ).append( ";r1c2\n" ) .append( "r2c1" ).append( '\n' ).append( ";r2c2" ) .toString(); final String virtualFile = createVirtualFile( "pdi-2607.txt", content ); TextFileInputMeta meta = new TextFileInputMeta(); meta.setLineWrapped( true ); meta.setNrWraps( 1 ); meta.setInputFields( new TextFileInputField[] { field( "col1" ), field( "col2" ) } ); meta.setFileCompression( "None" ); meta.setFileType( "CSV" ); meta.setHeader( false ); meta.setNrHeaderLines( -1 ); meta.setFooter( false ); meta.setNrFooterLines( -1 ); TextFileInputData data = new TextFileInputData(); data.setFiles( new FileInputList() ); data.getFiles().addFile( KettleVFS.getFileObject( virtualFile ) ); data.outputRowMeta = new RowMeta(); data.outputRowMeta.addValueMeta( new ValueMetaString( "col1" ) ); data.outputRowMeta.addValueMeta( new ValueMetaString( "col2" ) ); data.dataErrorLineHandler = Mockito.mock( FileErrorHandler.class ); data.fileFormatType = TextFileInputMeta.FILE_FORMAT_UNIX; data.separator = ";"; data.filterProcessor = new TextFileFilterProcessor( new TextFileFilter[ 0 ] ); data.filePlayList = new FilePlayListAll(); TextFileInput input = StepMockUtil.getStep( TextFileInput.class, TextFileInputMeta.class, "test" ); List<Object[]> output = TransTestingUtil.execute( input, meta, data, 2, false ); TransTestingUtil.assertResult( new Object[] { "r1c1", "r1c2" }, output.get( 0 ) ); TransTestingUtil.assertResult( new Object[] { "r2c1", "r2c2" }, output.get( 1 ) ); deleteVfsFile( virtualFile ); }
@Test public void readInputWithMissedValues() throws Exception { final String virtualFile = createVirtualFile( "pdi-14172.txt", "1,1,1\n", "2,,2\n" ); TextFileInputMeta meta = new TextFileInputMeta(); TextFileInputField field2 = field( "col2" ); field2.setRepeated( true ); meta.setInputFields( new TextFileInputField[] { field( "col1" ), field2, field( "col3" ) } ); meta.setFileCompression( "None" ); meta.setFileType( "CSV" ); meta.setHeader( false ); meta.setNrHeaderLines( -1 ); meta.setFooter( false ); meta.setNrFooterLines( -1 ); TextFileInputData data = new TextFileInputData(); data.setFiles( new FileInputList() ); data.getFiles().addFile( KettleVFS.getFileObject( virtualFile ) ); data.outputRowMeta = new RowMeta(); data.outputRowMeta.addValueMeta( new ValueMetaString( "col1" ) ); data.outputRowMeta.addValueMeta( new ValueMetaString( "col2" ) ); data.outputRowMeta.addValueMeta( new ValueMetaString( "col3" ) ); data.dataErrorLineHandler = Mockito.mock( FileErrorHandler.class ); data.fileFormatType = TextFileInputMeta.FILE_FORMAT_UNIX; data.separator = ","; data.filterProcessor = new TextFileFilterProcessor( new TextFileFilter[ 0 ] ); data.filePlayList = new FilePlayListAll(); TextFileInput input = StepMockUtil.getStep( TextFileInput.class, TextFileInputMeta.class, "test" ); List<Object[]> output = TransTestingUtil.execute( input, meta, data, 2, false ); TransTestingUtil.assertResult( new Object[] { "1", "1", "1" }, output.get( 0 ) ); TransTestingUtil.assertResult( new Object[] { "2", "1", "2" }, output.get( 1 ) ); deleteVfsFile( virtualFile ); }
@Test public void readInputWithDefaultValues() throws Exception { final String virtualFile = createVirtualFile( "pdi-14832.txt", "1,\n" ); TextFileInputMeta meta = new TextFileInputMeta(); TextFileInputField field2 = field( "col2" ); field2.setIfNullValue( "DEFAULT" ); meta.setInputFields( new TextFileInputField[] { field( "col1" ), field2 } ); meta.setFileCompression( "None" ); meta.setFileType( "CSV" ); meta.setHeader( false ); meta.setNrHeaderLines( -1 ); meta.setFooter( false ); meta.setNrFooterLines( -1 ); TextFileInputData data = new TextFileInputData(); data.setFiles( new FileInputList() ); data.getFiles().addFile( KettleVFS.getFileObject( virtualFile ) ); data.outputRowMeta = new RowMeta(); data.outputRowMeta.addValueMeta( new ValueMetaString( "col1" ) ); data.outputRowMeta.addValueMeta( new ValueMetaString( "col2" ) ); data.dataErrorLineHandler = Mockito.mock( FileErrorHandler.class ); data.fileFormatType = TextFileInputMeta.FILE_FORMAT_UNIX; data.separator = ","; data.filterProcessor = new TextFileFilterProcessor( new TextFileFilter[ 0 ] ); data.filePlayList = new FilePlayListAll(); TextFileInput input = StepMockUtil.getStep( TextFileInput.class, TextFileInputMeta.class, "test" ); List<Object[]> output = TransTestingUtil.execute( input, meta, data, 1, false ); TransTestingUtil.assertResult( new Object[] { "1", "DEFAULT" }, output.get( 0 ) ); deleteVfsFile( virtualFile ); }
|
DataHandler extends AbstractXulEventHandler { public void restoreDefaults() { if ( poolParameterTree != null ) { for ( int i = 0; i < poolParameterTree.getRootChildren().getItemCount(); i++ ) { XulTreeItem item = poolParameterTree.getRootChildren().getItem( i ); String parameterName = item.getRow().getCell( 1 ).getLabel(); String defaultValue = DatabaseConnectionPoolParameter .findParameter( parameterName, BaseDatabaseMeta.poolingParameters ).getDefaultValue(); if ( ( defaultValue == null ) || ( defaultValue.trim().length() <= 0 ) ) { continue; } item.getRow().addCellText( 2, defaultValue ); } } } DataHandler(); void loadConnectionData(); void loadAccessData(); void editOptions( int index ); void clearOptionsData(); void getOptionHelp(); void setDeckChildIndex(); void onPoolingCheck(); void onClusterCheck(); Object getData(); void setData( Object data ); void pushCache(); void popCache(); void onCancel(); void onOK(); void testDatabaseConnection(); void restoreDefaults(); void poolingRowChange( int idx ); void disablePortIfInstancePopulated(); void handleUseSecurityCheckbox(); static final SortedMap<String, DatabaseInterface> connectionMap; static final Map<String, String> connectionNametoID; }
|
@Test public void testRestoreDefaults() throws Exception { }
|
TextFileInput extends BaseStep implements StepInterface { @Deprecated public static final Object[] convertLineToRow( LogChannelInterface log, TextFileLine textFileLine, InputFileMetaInterface info, RowMetaInterface outputRowMeta, RowMetaInterface convertRowMeta, String fname, long rowNr, String delimiter, FileErrorHandler errorHandler, boolean addShortFilename, boolean addExtension, boolean addPath, boolean addSize, boolean addIsHidden, boolean addLastModificationDate, boolean addUri, boolean addRootUri, String shortFilename, String path, boolean hidden, Date modificationDateTime, String uri, String rooturi, String extension, long size ) throws KettleException { return convertLineToRow( log, textFileLine, info, null, 0, outputRowMeta, convertRowMeta, fname, rowNr, delimiter, StringUtil.substituteHex( info.getEnclosure() ), StringUtil.substituteHex( info.getEscapeCharacter() ), errorHandler, addShortFilename, addExtension, addPath, addSize, addIsHidden, addLastModificationDate, addUri, addRootUri, shortFilename, path, hidden, modificationDateTime, uri, rooturi, extension, size ); } TextFileInput( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); static final String getLine( LogChannelInterface log, InputStreamReader reader, int formatNr,
StringBuilder line ); static final String getLine( LogChannelInterface log, InputStreamReader reader, EncodingType encodingType,
int formatNr, StringBuilder line ); @Deprecated static final String[] guessStringsFromLine( LogChannelInterface log, String line, TextFileInputMeta inf,
String delimiter ); static final String[] guessStringsFromLine( VariableSpace space, LogChannelInterface log, String line,
TextFileInputMeta inf, String delimiter, String enclosure, String escapeCharacter ); static final String[] convertLineToStrings( LogChannelInterface log, String line, InputFileMetaInterface inf,
String delimiter, String enclosure, String escapeCharacters ); @Deprecated static final Object[] convertLineToRow( LogChannelInterface log, TextFileLine textFileLine,
InputFileMetaInterface info, RowMetaInterface outputRowMeta, RowMetaInterface convertRowMeta, String fname,
long rowNr, String delimiter, FileErrorHandler errorHandler, boolean addShortFilename, boolean addExtension,
boolean addPath, boolean addSize, boolean addIsHidden, boolean addLastModificationDate, boolean addUri,
boolean addRootUri, String shortFilename, String path, boolean hidden, Date modificationDateTime, String uri,
String rooturi, String extension, long size ); static Object[] convertLineToRow( LogChannelInterface log, TextFileLine textFileLine,
InputFileMetaInterface info, Object[] passThruFields, int nrPassThruFields, RowMetaInterface outputRowMeta,
RowMetaInterface convertRowMeta, String fname, long rowNr, String delimiter, String enclosure,
String escapeCharacter, FileErrorHandler errorHandler, boolean addShortFilename, boolean addExtension,
boolean addPath, boolean addSize, boolean addIsHidden, boolean addLastModificationDate, boolean addUri,
boolean addRootUri, String shortFilename, String path, boolean hidden, Date modificationDateTime, String uri,
String rooturi, String extension, long size ); @Override boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); @Override boolean init( StepMetaInterface smi, StepDataInterface sdi ); @Override void dispose( StepMetaInterface smi, StepDataInterface sdi ); boolean isWaitingForData(); }
|
@Test public void convertLineToRowTest() throws Exception { LogChannelInterface log = Mockito.mock( LogChannelInterface.class ); TextFileLine textFileLine = Mockito.mock( TextFileLine.class ); textFileLine.line = "testData1;testData2;testData3"; InputFileMetaInterface info = Mockito.mock( InputFileMetaInterface.class ); TextFileInputField[] textFileInputFields = { new TextFileInputField(), new TextFileInputField(), new TextFileInputField() }; Mockito.doReturn( textFileInputFields ).when( info ).getInputFields(); Mockito.doReturn( "CSV" ).when( info ).getFileType(); Mockito.doReturn( "/" ).when( info ).getEscapeCharacter(); Mockito.doReturn( true ).when( info ).isErrorIgnored(); Mockito.doReturn( true ).when( info ).isErrorLineSkipped(); RowMetaInterface outputRowMeta = Mockito.mock( RowMetaInterface.class ); Mockito.doReturn( 15 ).when( outputRowMeta ).size(); ValueMetaInterface valueMetaWithError = Mockito.mock( ValueMetaInterface.class ); Mockito.doThrow( new KettleValueException( "Error converting" ) ).when( valueMetaWithError ).convertDataFromString( Mockito.anyString(), Mockito.any( ValueMetaInterface.class ), Mockito.anyString(), Mockito.anyString(), Mockito.anyInt() ); Mockito.doReturn( valueMetaWithError ).when( outputRowMeta ).getValueMeta( Mockito.anyInt() ); TextFileInput.convertLineToRow( log, textFileLine, info, new Object[3], 1, outputRowMeta, Mockito.mock( RowMetaInterface.class ), null, 1L, ";", null, "/", Mockito.mock( FileErrorHandler.class ), false, false, false, false, false, false, false, false, null, null, false, new Date(), null, null, null, 1L ); }
|
CalculatorMetaFunction implements Cloneable { @Override public boolean equals( Object obj ) { if ( obj != null && ( obj.getClass().equals( this.getClass() ) ) ) { CalculatorMetaFunction mf = (CalculatorMetaFunction) obj; return ( getXML().equals( mf.getXML() ) ); } return false; } CalculatorMetaFunction( String fieldName, int calcType, String fieldA, String fieldB, String fieldC,
int valueType, int valueLength, int valuePrecision, boolean removedFromResult,
String conversionMask,
String decimalSymbol, String groupingSymbol, String currencySymbol ); CalculatorMetaFunction(); CalculatorMetaFunction( Node calcnode ); CalculatorMetaFunction( Repository rep, ObjectId id_step, int nr ); @Override boolean equals( Object obj ); @Override int hashCode(); @Override Object clone(); String getXML(); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step, int nr ); static int getCalcFunctionType( String desc ); static String getCalcFunctionDesc( int type ); static String getCalcFunctionLongDesc( int type ); static int getCalcFunctionDefaultResultType( int type ); int getCalcType(); void setCalcType( int calcType ); String getCalcTypeDesc(); String getCalcTypeLongDesc(); String getFieldA(); void setFieldA( String fieldA ); String getFieldB(); void setFieldB( String fieldB ); String getFieldC(); void setFieldC( String fieldC ); String getFieldName(); void setFieldName( String fieldName ); int getValueLength(); void setValueLength( int valueLength ); int getValuePrecision(); void setValuePrecision( int valuePrecision ); int getValueType(); void setValueType( int valueType ); boolean isRemovedFromResult(); void setRemovedFromResult( boolean removedFromResult ); String getConversionMask(); void setConversionMask( String conversionMask ); String getDecimalSymbol(); void setDecimalSymbol( String decimalSymbol ); String getGroupingSymbol(); void setGroupingSymbol( String groupingSymbol ); String getCurrencySymbol(); void setCurrencySymbol( String currencySymbol ); static final String XML_TAG; static final int CALC_NONE; static final int CALC_CONSTANT; static final int CALC_COPY_OF_FIELD; static final int CALC_ADD; static final int CALC_SUBTRACT; static final int CALC_MULTIPLY; static final int CALC_DIVIDE; static final int CALC_SQUARE; static final int CALC_SQUARE_ROOT; static final int CALC_PERCENT_1; static final int CALC_PERCENT_2; static final int CALC_PERCENT_3; static final int CALC_COMBINATION_1; static final int CALC_COMBINATION_2; static final int CALC_ROUND_1; static final int CALC_ROUND_2; static final int CALC_ROUND_STD_1; static final int CALC_ROUND_STD_2; static final int CALC_CEIL; static final int CALC_FLOOR; static final int CALC_NVL; static final int CALC_ADD_DAYS; static final int CALC_YEAR_OF_DATE; static final int CALC_MONTH_OF_DATE; static final int CALC_DAY_OF_YEAR; static final int CALC_DAY_OF_MONTH; static final int CALC_DAY_OF_WEEK; static final int CALC_WEEK_OF_YEAR; static final int CALC_WEEK_OF_YEAR_ISO8601; static final int CALC_YEAR_OF_DATE_ISO8601; static final int CALC_BYTE_TO_HEX_ENCODE; static final int CALC_HEX_TO_BYTE_DECODE; static final int CALC_CHAR_TO_HEX_ENCODE; static final int CALC_HEX_TO_CHAR_DECODE; static final int CALC_CRC32; static final int CALC_ADLER32; static final int CALC_MD5; static final int CALC_SHA1; static final int CALC_LEVENSHTEIN_DISTANCE; static final int CALC_METAPHONE; static final int CALC_DOUBLE_METAPHONE; static final int CALC_ABS; static final int CALC_REMOVE_TIME_FROM_DATE; static final int CALC_DATE_DIFF; static final int CALC_ADD3; static final int CALC_INITCAP; static final int CALC_UPPER_CASE; static final int CALC_LOWER_CASE; static final int CALC_MASK_XML; static final int CALC_USE_CDATA; static final int CALC_REMOVE_CR; static final int CALC_REMOVE_LF; static final int CALC_REMOVE_CRLF; static final int CALC_REMOVE_TAB; static final int CALC_GET_ONLY_DIGITS; static final int CALC_REMOVE_DIGITS; static final int CALC_STRING_LEN; static final int CALC_LOAD_FILE_CONTENT_BINARY; static final int CALC_ADD_TIME_TO_DATE; static final int CALC_QUARTER_OF_DATE; static final int CALC_SUBSTITUTE_VARIABLE; static final int CALC_UNESCAPE_XML; static final int CALC_ESCAPE_HTML; static final int CALC_UNESCAPE_HTML; static final int CALC_ESCAPE_SQL; static final int CALC_DATE_WORKING_DIFF; static final int CALC_ADD_MONTHS; static final int CALC_CHECK_XML_FILE_WELL_FORMED; static final int CALC_CHECK_XML_WELL_FORMED; static final int CALC_GET_FILE_ENCODING; static final int CALC_DAMERAU_LEVENSHTEIN; static final int CALC_NEEDLEMAN_WUNSH; static final int CALC_JARO; static final int CALC_JARO_WINKLER; static final int CALC_SOUNDEX; static final int CALC_REFINED_SOUNDEX; static final int CALC_ADD_HOURS; static final int CALC_ADD_MINUTES; static final int CALC_DATE_DIFF_MSEC; static final int CALC_DATE_DIFF_SEC; static final int CALC_DATE_DIFF_MN; static final int CALC_DATE_DIFF_HR; static final int CALC_HOUR_OF_DAY; static final int CALC_MINUTE_OF_HOUR; static final int CALC_SECOND_OF_MINUTE; static final int CALC_ROUND_CUSTOM_1; static final int CALC_ROUND_CUSTOM_2; static final int CALC_ADD_SECONDS; static final int CALC_REMAINDER; static final String[] calc_desc; static final String[] calcLongDesc; static final int[] calcDefaultResultType; }
|
@Test public void testEquals() { CalculatorMetaFunction meta1 = new CalculatorMetaFunction(); CalculatorMetaFunction meta2 = (CalculatorMetaFunction) meta1.clone(); assertNotSame( meta1, meta2 ); assertFalse( meta1.equals( null ) ); assertFalse( meta1.equals( new Object() ) ); assertTrue( meta1.equals( meta2 ) ); meta2.setCalcType( CalculatorMetaFunction.CALC_ADD_DAYS ); assertFalse( meta1.equals( meta2 ) ); }
|
CalculatorMetaFunction implements Cloneable { public static String getCalcFunctionLongDesc( int type ) { if ( type < 0 || type >= calcLongDesc.length ) { return null; } return calcLongDesc[ type ]; } CalculatorMetaFunction( String fieldName, int calcType, String fieldA, String fieldB, String fieldC,
int valueType, int valueLength, int valuePrecision, boolean removedFromResult,
String conversionMask,
String decimalSymbol, String groupingSymbol, String currencySymbol ); CalculatorMetaFunction(); CalculatorMetaFunction( Node calcnode ); CalculatorMetaFunction( Repository rep, ObjectId id_step, int nr ); @Override boolean equals( Object obj ); @Override int hashCode(); @Override Object clone(); String getXML(); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step, int nr ); static int getCalcFunctionType( String desc ); static String getCalcFunctionDesc( int type ); static String getCalcFunctionLongDesc( int type ); static int getCalcFunctionDefaultResultType( int type ); int getCalcType(); void setCalcType( int calcType ); String getCalcTypeDesc(); String getCalcTypeLongDesc(); String getFieldA(); void setFieldA( String fieldA ); String getFieldB(); void setFieldB( String fieldB ); String getFieldC(); void setFieldC( String fieldC ); String getFieldName(); void setFieldName( String fieldName ); int getValueLength(); void setValueLength( int valueLength ); int getValuePrecision(); void setValuePrecision( int valuePrecision ); int getValueType(); void setValueType( int valueType ); boolean isRemovedFromResult(); void setRemovedFromResult( boolean removedFromResult ); String getConversionMask(); void setConversionMask( String conversionMask ); String getDecimalSymbol(); void setDecimalSymbol( String decimalSymbol ); String getGroupingSymbol(); void setGroupingSymbol( String groupingSymbol ); String getCurrencySymbol(); void setCurrencySymbol( String currencySymbol ); static final String XML_TAG; static final int CALC_NONE; static final int CALC_CONSTANT; static final int CALC_COPY_OF_FIELD; static final int CALC_ADD; static final int CALC_SUBTRACT; static final int CALC_MULTIPLY; static final int CALC_DIVIDE; static final int CALC_SQUARE; static final int CALC_SQUARE_ROOT; static final int CALC_PERCENT_1; static final int CALC_PERCENT_2; static final int CALC_PERCENT_3; static final int CALC_COMBINATION_1; static final int CALC_COMBINATION_2; static final int CALC_ROUND_1; static final int CALC_ROUND_2; static final int CALC_ROUND_STD_1; static final int CALC_ROUND_STD_2; static final int CALC_CEIL; static final int CALC_FLOOR; static final int CALC_NVL; static final int CALC_ADD_DAYS; static final int CALC_YEAR_OF_DATE; static final int CALC_MONTH_OF_DATE; static final int CALC_DAY_OF_YEAR; static final int CALC_DAY_OF_MONTH; static final int CALC_DAY_OF_WEEK; static final int CALC_WEEK_OF_YEAR; static final int CALC_WEEK_OF_YEAR_ISO8601; static final int CALC_YEAR_OF_DATE_ISO8601; static final int CALC_BYTE_TO_HEX_ENCODE; static final int CALC_HEX_TO_BYTE_DECODE; static final int CALC_CHAR_TO_HEX_ENCODE; static final int CALC_HEX_TO_CHAR_DECODE; static final int CALC_CRC32; static final int CALC_ADLER32; static final int CALC_MD5; static final int CALC_SHA1; static final int CALC_LEVENSHTEIN_DISTANCE; static final int CALC_METAPHONE; static final int CALC_DOUBLE_METAPHONE; static final int CALC_ABS; static final int CALC_REMOVE_TIME_FROM_DATE; static final int CALC_DATE_DIFF; static final int CALC_ADD3; static final int CALC_INITCAP; static final int CALC_UPPER_CASE; static final int CALC_LOWER_CASE; static final int CALC_MASK_XML; static final int CALC_USE_CDATA; static final int CALC_REMOVE_CR; static final int CALC_REMOVE_LF; static final int CALC_REMOVE_CRLF; static final int CALC_REMOVE_TAB; static final int CALC_GET_ONLY_DIGITS; static final int CALC_REMOVE_DIGITS; static final int CALC_STRING_LEN; static final int CALC_LOAD_FILE_CONTENT_BINARY; static final int CALC_ADD_TIME_TO_DATE; static final int CALC_QUARTER_OF_DATE; static final int CALC_SUBSTITUTE_VARIABLE; static final int CALC_UNESCAPE_XML; static final int CALC_ESCAPE_HTML; static final int CALC_UNESCAPE_HTML; static final int CALC_ESCAPE_SQL; static final int CALC_DATE_WORKING_DIFF; static final int CALC_ADD_MONTHS; static final int CALC_CHECK_XML_FILE_WELL_FORMED; static final int CALC_CHECK_XML_WELL_FORMED; static final int CALC_GET_FILE_ENCODING; static final int CALC_DAMERAU_LEVENSHTEIN; static final int CALC_NEEDLEMAN_WUNSH; static final int CALC_JARO; static final int CALC_JARO_WINKLER; static final int CALC_SOUNDEX; static final int CALC_REFINED_SOUNDEX; static final int CALC_ADD_HOURS; static final int CALC_ADD_MINUTES; static final int CALC_DATE_DIFF_MSEC; static final int CALC_DATE_DIFF_SEC; static final int CALC_DATE_DIFF_MN; static final int CALC_DATE_DIFF_HR; static final int CALC_HOUR_OF_DAY; static final int CALC_MINUTE_OF_HOUR; static final int CALC_SECOND_OF_MINUTE; static final int CALC_ROUND_CUSTOM_1; static final int CALC_ROUND_CUSTOM_2; static final int CALC_ADD_SECONDS; static final int CALC_REMAINDER; static final String[] calc_desc; static final String[] calcLongDesc; static final int[] calcDefaultResultType; }
|
@Test public void testGetCalcFunctionLongDesc() { assertNull( CalculatorMetaFunction.getCalcFunctionLongDesc( Integer.MIN_VALUE ) ); assertNull( CalculatorMetaFunction.getCalcFunctionLongDesc( Integer.MAX_VALUE ) ); assertNull( CalculatorMetaFunction.getCalcFunctionLongDesc( CalculatorMetaFunction.calcLongDesc.length ) ); }
|
CalculatorMetaFunction implements Cloneable { public static int getCalcFunctionDefaultResultType( int type ) { if ( type < 0 || type >= calcDefaultResultType.length ) { return ValueMetaInterface.TYPE_NONE; } return calcDefaultResultType[ type ]; } CalculatorMetaFunction( String fieldName, int calcType, String fieldA, String fieldB, String fieldC,
int valueType, int valueLength, int valuePrecision, boolean removedFromResult,
String conversionMask,
String decimalSymbol, String groupingSymbol, String currencySymbol ); CalculatorMetaFunction(); CalculatorMetaFunction( Node calcnode ); CalculatorMetaFunction( Repository rep, ObjectId id_step, int nr ); @Override boolean equals( Object obj ); @Override int hashCode(); @Override Object clone(); String getXML(); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step, int nr ); static int getCalcFunctionType( String desc ); static String getCalcFunctionDesc( int type ); static String getCalcFunctionLongDesc( int type ); static int getCalcFunctionDefaultResultType( int type ); int getCalcType(); void setCalcType( int calcType ); String getCalcTypeDesc(); String getCalcTypeLongDesc(); String getFieldA(); void setFieldA( String fieldA ); String getFieldB(); void setFieldB( String fieldB ); String getFieldC(); void setFieldC( String fieldC ); String getFieldName(); void setFieldName( String fieldName ); int getValueLength(); void setValueLength( int valueLength ); int getValuePrecision(); void setValuePrecision( int valuePrecision ); int getValueType(); void setValueType( int valueType ); boolean isRemovedFromResult(); void setRemovedFromResult( boolean removedFromResult ); String getConversionMask(); void setConversionMask( String conversionMask ); String getDecimalSymbol(); void setDecimalSymbol( String decimalSymbol ); String getGroupingSymbol(); void setGroupingSymbol( String groupingSymbol ); String getCurrencySymbol(); void setCurrencySymbol( String currencySymbol ); static final String XML_TAG; static final int CALC_NONE; static final int CALC_CONSTANT; static final int CALC_COPY_OF_FIELD; static final int CALC_ADD; static final int CALC_SUBTRACT; static final int CALC_MULTIPLY; static final int CALC_DIVIDE; static final int CALC_SQUARE; static final int CALC_SQUARE_ROOT; static final int CALC_PERCENT_1; static final int CALC_PERCENT_2; static final int CALC_PERCENT_3; static final int CALC_COMBINATION_1; static final int CALC_COMBINATION_2; static final int CALC_ROUND_1; static final int CALC_ROUND_2; static final int CALC_ROUND_STD_1; static final int CALC_ROUND_STD_2; static final int CALC_CEIL; static final int CALC_FLOOR; static final int CALC_NVL; static final int CALC_ADD_DAYS; static final int CALC_YEAR_OF_DATE; static final int CALC_MONTH_OF_DATE; static final int CALC_DAY_OF_YEAR; static final int CALC_DAY_OF_MONTH; static final int CALC_DAY_OF_WEEK; static final int CALC_WEEK_OF_YEAR; static final int CALC_WEEK_OF_YEAR_ISO8601; static final int CALC_YEAR_OF_DATE_ISO8601; static final int CALC_BYTE_TO_HEX_ENCODE; static final int CALC_HEX_TO_BYTE_DECODE; static final int CALC_CHAR_TO_HEX_ENCODE; static final int CALC_HEX_TO_CHAR_DECODE; static final int CALC_CRC32; static final int CALC_ADLER32; static final int CALC_MD5; static final int CALC_SHA1; static final int CALC_LEVENSHTEIN_DISTANCE; static final int CALC_METAPHONE; static final int CALC_DOUBLE_METAPHONE; static final int CALC_ABS; static final int CALC_REMOVE_TIME_FROM_DATE; static final int CALC_DATE_DIFF; static final int CALC_ADD3; static final int CALC_INITCAP; static final int CALC_UPPER_CASE; static final int CALC_LOWER_CASE; static final int CALC_MASK_XML; static final int CALC_USE_CDATA; static final int CALC_REMOVE_CR; static final int CALC_REMOVE_LF; static final int CALC_REMOVE_CRLF; static final int CALC_REMOVE_TAB; static final int CALC_GET_ONLY_DIGITS; static final int CALC_REMOVE_DIGITS; static final int CALC_STRING_LEN; static final int CALC_LOAD_FILE_CONTENT_BINARY; static final int CALC_ADD_TIME_TO_DATE; static final int CALC_QUARTER_OF_DATE; static final int CALC_SUBSTITUTE_VARIABLE; static final int CALC_UNESCAPE_XML; static final int CALC_ESCAPE_HTML; static final int CALC_UNESCAPE_HTML; static final int CALC_ESCAPE_SQL; static final int CALC_DATE_WORKING_DIFF; static final int CALC_ADD_MONTHS; static final int CALC_CHECK_XML_FILE_WELL_FORMED; static final int CALC_CHECK_XML_WELL_FORMED; static final int CALC_GET_FILE_ENCODING; static final int CALC_DAMERAU_LEVENSHTEIN; static final int CALC_NEEDLEMAN_WUNSH; static final int CALC_JARO; static final int CALC_JARO_WINKLER; static final int CALC_SOUNDEX; static final int CALC_REFINED_SOUNDEX; static final int CALC_ADD_HOURS; static final int CALC_ADD_MINUTES; static final int CALC_DATE_DIFF_MSEC; static final int CALC_DATE_DIFF_SEC; static final int CALC_DATE_DIFF_MN; static final int CALC_DATE_DIFF_HR; static final int CALC_HOUR_OF_DAY; static final int CALC_MINUTE_OF_HOUR; static final int CALC_SECOND_OF_MINUTE; static final int CALC_ROUND_CUSTOM_1; static final int CALC_ROUND_CUSTOM_2; static final int CALC_ADD_SECONDS; static final int CALC_REMAINDER; static final String[] calc_desc; static final String[] calcLongDesc; static final int[] calcDefaultResultType; }
|
@Test public void testGetCalcFunctionDefaultResultType() { assertEquals( ValueMetaInterface.TYPE_NONE, CalculatorMetaFunction.getCalcFunctionDefaultResultType( Integer.MIN_VALUE ) ); assertEquals( ValueMetaInterface.TYPE_NONE, CalculatorMetaFunction.getCalcFunctionDefaultResultType( Integer.MAX_VALUE ) ); assertEquals( ValueMetaInterface.TYPE_NONE, CalculatorMetaFunction.getCalcFunctionDefaultResultType( -1 ) ); assertEquals( ValueMetaInterface.TYPE_STRING, CalculatorMetaFunction.getCalcFunctionDefaultResultType( CalculatorMetaFunction.CALC_CONSTANT ) ); assertEquals( ValueMetaInterface.TYPE_NUMBER, CalculatorMetaFunction.getCalcFunctionDefaultResultType( CalculatorMetaFunction.CALC_ADD ) ); }
|
CalculatorData extends BaseStepData implements StepDataInterface { public ValueMetaInterface getValueMetaFor( int resultType, String name ) throws KettlePluginException { ValueMetaInterface meta = resultMetaMapping.get( resultType ); if ( meta == null ) { meta = ValueMetaFactory.createValueMeta( name, resultType ); resultMetaMapping.put( resultType, meta ); } return meta; } CalculatorData(); RowMetaInterface getOutputRowMeta(); void setOutputRowMeta( RowMetaInterface outputRowMeta ); RowMetaInterface getCalcRowMeta(); void setCalcRowMeta( RowMetaInterface calcRowMeta ); Calculator.FieldIndexes[] getFieldIndexes(); void setFieldIndexes( Calculator.FieldIndexes[] fieldIndexes ); int[] getTempIndexes(); void setTempIndexes( int[] tempIndexes ); ValueMetaInterface getValueMetaFor( int resultType, String name ); void clearValuesMetaMapping(); }
|
@Test public void dataReturnsCachedValues() throws Exception { KettleEnvironment.init( false ); CalculatorData data = new CalculatorData(); ValueMetaInterface valueMeta = data.getValueMetaFor( ValueMetaInterface.TYPE_INTEGER, null ); ValueMetaInterface shouldBeTheSame = data.getValueMetaFor( ValueMetaInterface.TYPE_INTEGER, null ); assertTrue( "CalculatorData should cache loaded value meta instances", valueMeta == shouldBeTheSame ); }
|
CalculatorMeta extends BaseStepMeta implements StepMetaInterface { @Override public StepDataInterface getStepData() { return new CalculatorData(); } CalculatorMetaFunction[] getCalculation(); void setCalculation( CalculatorMetaFunction[] calcTypes ); void allocate( int nrCalcs ); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); @Override String getXML(); @Override boolean equals( Object obj ); @Override int hashCode(); @Override Object clone(); @Override void setDefault(); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); @Override void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); RowMetaInterface getAllFields( RowMetaInterface inputRowMeta ); @Override void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); @Override StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr,
Trans trans ); @Override StepDataInterface getStepData(); }
|
@Test public void testGetStepData() { CalculatorMeta meta = new CalculatorMeta(); assertTrue( meta.getStepData() instanceof CalculatorData ); }
|
CalculatorMeta extends BaseStepMeta implements StepMetaInterface { @Override public void setDefault() { calculation = new CalculatorMetaFunction[0]; } CalculatorMetaFunction[] getCalculation(); void setCalculation( CalculatorMetaFunction[] calcTypes ); void allocate( int nrCalcs ); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); @Override String getXML(); @Override boolean equals( Object obj ); @Override int hashCode(); @Override Object clone(); @Override void setDefault(); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); @Override void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); RowMetaInterface getAllFields( RowMetaInterface inputRowMeta ); @Override void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); @Override StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr,
Trans trans ); @Override StepDataInterface getStepData(); }
|
@Test public void testSetDefault() { CalculatorMeta meta = new CalculatorMeta(); meta.setDefault(); assertNotNull( meta.getCalculation() ); assertEquals( 0, meta.getCalculation().length ); }
|
StepDefinition implements Cloneable { public Object clone() throws CloneNotSupportedException { StepDefinition retval; retval = (StepDefinition) super.clone(); if ( stepMeta != null ) { retval.stepMeta = (StepMeta) stepMeta.clone(); } return retval; } StepDefinition(); StepDefinition( String tag, String stepName, StepMeta stepMeta, String description ); Object clone(); public String tag; public String stepName; public StepMeta stepMeta; public String description; }
|
@Test public void testClone() throws Exception { try { StepDefinition stepDefinition = new StepDefinition( "tag", "stepName", null, "" ); stepDefinition.clone(); } catch ( NullPointerException npe ) { fail( "Null value is not handled" ); } }
|
PrioritizeStreams extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (PrioritizeStreamsMeta) smi; data = (PrioritizeStreamsData) sdi; if ( first ) { if ( meta.getStepName() != null || meta.getStepName().length > 0 ) { data.stepnrs = meta.getStepName().length; data.rowSets = new RowSet[data.stepnrs]; for ( int i = 0; i < data.stepnrs; i++ ) { data.rowSets[i] = findInputRowSet( meta.getStepName()[i] ); if ( i > 0 ) { checkInputLayoutValid( data.rowSets[0].getRowMeta(), data.rowSets[i].getRowMeta() ); } } } else { throw new KettleException( BaseMessages.getString( PKG, "PrioritizeStreams.Error.NotInputSteps" ) ); } data.currentRowSet = data.rowSets[0]; } Object[] input = getOneRow(); while ( input == null && data.stepnr < data.stepnrs - 1 && !isStopped() ) { input = getOneRow(); } if ( input == null ) { setOutputDone(); return false; } if ( first ) { data.outputRowMeta = data.currentRowSet.getRowMeta(); first = false; } putRow( data.outputRowMeta, input ); return true; } PrioritizeStreams( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr,
TransMeta transMeta, Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
|
@Test public void testProcessRow() throws KettleException { PrioritizeStreamsMeta meta = new PrioritizeStreamsMeta(); meta.setStepName( new String[] { "high", "medium", "low" } ); PrioritizeStreamsData data = new PrioritizeStreamsData(); PrioritizeStreamsInner step = new PrioritizeStreamsInner( stepMockHelper ); try { step.processRow( meta, data ); } catch ( NullPointerException e ) { fail( "NullPointerException detecded, seems that RowMetaInterface was not set for RowSet you are attempting" + "to read from." ); } Assert.assertTrue( "First waiting for row set is 'high'", data.currentRowSet.getClass().equals( SingleRowRowSet.class ) ); }
|
DataHandler extends AbstractXulEventHandler { public void poolingRowChange( int idx ) { if ( idx != -1 ) { if ( idx >= BaseDatabaseMeta.poolingParameters.length ) { idx = BaseDatabaseMeta.poolingParameters.length - 1; } if ( idx < 0 ) { idx = 0; } poolingDescription.setValue( BaseDatabaseMeta.poolingParameters[idx].getDescription() ); XulTreeRow row = poolParameterTree.getRootChildren().getItem( idx ).getRow(); if ( row.getSelectedColumnIndex() == 2 ) { row.addCellText( 0, "true" ); } } } DataHandler(); void loadConnectionData(); void loadAccessData(); void editOptions( int index ); void clearOptionsData(); void getOptionHelp(); void setDeckChildIndex(); void onPoolingCheck(); void onClusterCheck(); Object getData(); void setData( Object data ); void pushCache(); void popCache(); void onCancel(); void onOK(); void testDatabaseConnection(); void restoreDefaults(); void poolingRowChange( int idx ); void disablePortIfInstancePopulated(); void handleUseSecurityCheckbox(); static final SortedMap<String, DatabaseInterface> connectionMap; static final Map<String, String> connectionNametoID; }
|
@Test public void testPoolingRowChange() throws Exception { }
|
FuzzyMatch extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (FuzzyMatchMeta) smi; data = (FuzzyMatchData) sdi; if ( data.readLookupValues ) { data.readLookupValues = false; if ( !readLookupValues() ) { logError( BaseMessages.getString( PKG, "FuzzyMatch.Log.UnableToReadDataFromLookupStream" ) ); setErrors( 1 ); stopAll(); return false; } if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "FuzzyMatch.Log.ReadValuesInMemory", data.look.size() ) ); } } Object[] r = getRow(); if ( r == null ) { if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "FuzzyMatch.Log.StoppedProcessingWithEmpty", getLinesRead() ) ); } setOutputDone(); return false; } try { Object[] outputRow = lookupValues( getInputRowMeta(), r ); if ( outputRow == null ) { setOutputDone(); return false; } putRow( data.outputRowMeta, outputRow ); if ( checkFeedback( getLinesRead() ) ) { if ( log.isBasic() ) { logBasic( BaseMessages.getString( PKG, "FuzzyMatch.Log.LineNumber" ) + getLinesRead() ); } } } catch ( KettleException e ) { boolean sendToErrorRow = false; String errorMessage = null; if ( getStepMeta().isDoingErrorHandling() ) { sendToErrorRow = true; errorMessage = e.toString(); } else { logError( BaseMessages.getString( PKG, "FuzzyMatch.Log.ErrorInStepRunning" ) + e.getMessage() ); setErrors( 1 ); stopAll(); setOutputDone(); return false; } if ( sendToErrorRow ) { putError( getInputRowMeta(), r, 1, errorMessage, meta.getMainStreamField(), "FuzzyMatch001" ); } } return true; } FuzzyMatch( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
|
@SuppressWarnings( "unchecked" ) @Test public void testProcessRow() throws Exception { fuzzyMatch = new FuzzyMatchHandler( mockHelper.stepMeta, mockHelper.stepDataInterface, 0, mockHelper.transMeta, mockHelper.trans ); fuzzyMatch.init( mockHelper.initStepMetaInterface, mockHelper.initStepDataInterface ); fuzzyMatch.getInputRowSets().add( mockHelper.getMockInputRowSet( rows ) ); fuzzyMatch.getInputRowSets().add( mockHelper.getMockInputRowSet( lookupRows ) ); when( mockHelper.processRowsStepMetaInterface.getAlgorithmType() ).thenReturn( 8 ); mockHelper.processRowsStepDataInterface.look = mock( HashSet.class ); when( mockHelper.processRowsStepDataInterface.look.iterator() ).thenReturn( lookupRows.iterator() ); fuzzyMatch.processRow( mockHelper.processRowsStepMetaInterface, mockHelper.processRowsStepDataInterface ); Assert.assertEquals( fuzzyMatch.resultRow[0], row3[0] ); }
@SuppressWarnings( "unchecked" ) @Test public void testProcessRow() throws Exception { fuzzyMatch = new FuzzyMatchHandler( mockHelper.stepMeta, mockHelper.stepDataInterface, 0, mockHelper.transMeta, mockHelper.trans ); fuzzyMatch.init( mockHelper.initStepMetaInterface, mockHelper.initStepDataInterface ); fuzzyMatch.addRowSetToInputRowSets( mockHelper.getMockInputRowSet( rows ) ); fuzzyMatch.addRowSetToInputRowSets( mockHelper.getMockInputRowSet( lookupRows ) ); when( mockHelper.processRowsStepMetaInterface.getAlgorithmType() ).thenReturn( 8 ); mockHelper.processRowsStepDataInterface.look = mock( HashSet.class ); when( mockHelper.processRowsStepDataInterface.look.iterator() ).thenReturn( lookupRows.iterator() ); fuzzyMatch.processRow( mockHelper.processRowsStepMetaInterface, mockHelper.processRowsStepDataInterface ); Assert.assertEquals( fuzzyMatch.resultRow[0], row3[0] ); }
|
FuzzyMatch extends BaseStep implements StepInterface { private boolean readLookupValues() throws KettleException { data.infoStream = meta.getStepIOMeta().getInfoStreams().get( 0 ); if ( data.infoStream.getStepMeta() == null ) { logError( BaseMessages.getString( PKG, "FuzzyMatch.Log.NoLookupStepSpecified" ) ); return false; } if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "FuzzyMatch.Log.ReadingFromStream" ) + data.infoStream.getStepname() + "]" ); } boolean firstRun = true; RowSet rowSet = findInputRowSet( data.infoStream.getStepname() ); Object[] rowData = getRowFrom( rowSet ); while ( rowData != null ) { if ( firstRun ) { data.infoMeta = rowSet.getRowMeta().clone(); int indexOfLookupField = data.infoMeta.indexOfValue( environmentSubstitute( meta.getLookupField() ) ); if ( indexOfLookupField < 0 ) { throw new KettleException( BaseMessages.getString( PKG, "FuzzyMatch.Exception.CouldnotFindLookField", meta.getLookupField() ) ); } data.infoCache = new RowMeta(); ValueMetaInterface keyValueMeta = data.infoMeta.getValueMeta( indexOfLookupField ); keyValueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_NORMAL ); data.infoCache.addValueMeta( keyValueMeta ); data.indexOfCachedFields[0] = indexOfLookupField; if ( data.addAdditionalFields ) { ValueMetaInterface additionalFieldValueMeta; for ( int i = 0; i < meta.getValue().length; i++ ) { int fi = i + 1; data.indexOfCachedFields[fi] = data.infoMeta.indexOfValue( meta.getValue()[i] ); if ( data.indexOfCachedFields[fi] < 0 ) { throw new KettleException( BaseMessages.getString( PKG, "FuzzyMatch.Exception.CouldnotFindLookField", meta.getValue()[i] ) ); } additionalFieldValueMeta = data.infoMeta.getValueMeta( data.indexOfCachedFields[fi] ); additionalFieldValueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_NORMAL ); data.infoCache.addValueMeta( additionalFieldValueMeta ); } data.nrCachedFields += meta.getValue().length; } } if ( log.isRowLevel() ) { logRowlevel( BaseMessages.getString( PKG, "FuzzyMatch.Log.ReadLookupRow" ) + rowSet.getRowMeta().getString( rowData ) ); } Object[] storeData = new Object[data.nrCachedFields]; if ( rowData[data.indexOfCachedFields[0]] == null ) { storeData[0] = ""; } else { ValueMetaInterface fromStreamRowMeta = rowSet.getRowMeta().getValueMeta( data.indexOfCachedFields[0] ); if ( fromStreamRowMeta.isStorageBinaryString() ) { storeData[0] = fromStreamRowMeta.convertToNormalStorageType( rowData[data.indexOfCachedFields[0]] ); } else { storeData[0] = rowData[data.indexOfCachedFields[0]]; } } for ( int i = 1; i < data.nrCachedFields; i++ ) { ValueMetaInterface fromStreamRowMeta = rowSet.getRowMeta().getValueMeta( data.indexOfCachedFields[i] ); if ( fromStreamRowMeta.isStorageBinaryString() ) { storeData[i] = fromStreamRowMeta.convertToNormalStorageType( rowData[data.indexOfCachedFields[i]] ); } else { storeData[i] = rowData[data.indexOfCachedFields[i]]; } } if ( isDebug() ) { logDebug( BaseMessages.getString( PKG, "FuzzyMatch.Log.AddingValueToCache", data.infoCache .getString( storeData ) ) ); } addToCache( storeData ); rowData = getRowFrom( rowSet ); if ( firstRun ) { firstRun = false; } } return true; } FuzzyMatch( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
|
@Test public void testReadLookupValues() throws Exception { FuzzyMatchData data = spy( new FuzzyMatchData() ); data.indexOfCachedFields = new int[2]; data.minimalDistance = 0; data.maximalDistance = 5; FuzzyMatchMeta meta = spy( new FuzzyMatchMeta() ); meta.setOutputMatchField( "I don't want NPE here!" ); data.readLookupValues = true; fuzzyMatch = new FuzzyMatchHandler( mockHelper.stepMeta, mockHelper.stepDataInterface, 0, mockHelper.transMeta, mockHelper.trans ); fuzzyMatch.init( meta, data ); RowSet lookupRowSet = mockHelper.getMockInputRowSet( binaryLookupRows ); fuzzyMatch.getInputRowSets().add( mockHelper.getMockInputRowSet( binaryRows ) ); fuzzyMatch.getInputRowSets().add( lookupRowSet ); fuzzyMatch.rowset = lookupRowSet; RowMetaInterface rowMetaInterface = new RowMeta(); ValueMetaInterface valueMeta = new ValueMetaString( "field1" ); valueMeta.setStorageMetadata( new ValueMetaString( "field1" ) ); valueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_BINARY_STRING ); rowMetaInterface.addValueMeta( valueMeta ); when( lookupRowSet.getRowMeta() ).thenReturn( rowMetaInterface ); when( meta.getLookupField() ).thenReturn( "field1" ); when( meta.getMainStreamField() ).thenReturn( "field1" ); fuzzyMatch.setInputRowMeta( rowMetaInterface.clone() ); when( meta.getAlgorithmType() ).thenReturn( 1 ); StepIOMetaInterface stepIOMetaInterface = mock( StepIOMetaInterface.class ); when( meta.getStepIOMeta() ).thenReturn( stepIOMetaInterface ); StreamInterface streamInterface = mock( StreamInterface.class ); List<StreamInterface> streamInterfaceList = new ArrayList<StreamInterface>(); streamInterfaceList.add( streamInterface ); when( streamInterface.getStepMeta() ).thenReturn( mockHelper.stepMeta ); when( stepIOMetaInterface.getInfoStreams() ).thenReturn( streamInterfaceList ); fuzzyMatch.processRow( meta, data ); Assert.assertEquals( rowMetaInterface.getString( row3B, 0 ), data.outputRowMeta.getString( fuzzyMatch.resultRow, 1 ) ); }
@Test public void testReadLookupValues() throws Exception { FuzzyMatchData data = spy( new FuzzyMatchData() ); data.indexOfCachedFields = new int[2]; data.minimalDistance = 0; data.maximalDistance = 5; FuzzyMatchMeta meta = spy( new FuzzyMatchMeta() ); meta.setOutputMatchField( "I don't want NPE here!" ); data.readLookupValues = true; fuzzyMatch = new FuzzyMatchHandler( mockHelper.stepMeta, mockHelper.stepDataInterface, 0, mockHelper.transMeta, mockHelper.trans ); fuzzyMatch.init( meta, data ); RowSet lookupRowSet = mockHelper.getMockInputRowSet( binaryLookupRows ); fuzzyMatch.addRowSetToInputRowSets( mockHelper.getMockInputRowSet( binaryRows ) ); fuzzyMatch.addRowSetToInputRowSets( lookupRowSet ); fuzzyMatch.rowset = lookupRowSet; RowMetaInterface rowMetaInterface = new RowMeta(); ValueMetaInterface valueMeta = new ValueMetaString( "field1" ); valueMeta.setStorageMetadata( new ValueMetaString( "field1" ) ); valueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_BINARY_STRING ); rowMetaInterface.addValueMeta( valueMeta ); when( lookupRowSet.getRowMeta() ).thenReturn( rowMetaInterface ); when( meta.getLookupField() ).thenReturn( "field1" ); when( meta.getMainStreamField() ).thenReturn( "field1" ); fuzzyMatch.setInputRowMeta( rowMetaInterface.clone() ); when( meta.getAlgorithmType() ).thenReturn( 1 ); StepIOMetaInterface stepIOMetaInterface = mock( StepIOMetaInterface.class ); when( meta.getStepIOMeta() ).thenReturn( stepIOMetaInterface ); StreamInterface streamInterface = mock( StreamInterface.class ); List<StreamInterface> streamInterfaceList = new ArrayList<StreamInterface>(); streamInterfaceList.add( streamInterface ); when( streamInterface.getStepMeta() ).thenReturn( mockHelper.stepMeta ); when( stepIOMetaInterface.getInfoStreams() ).thenReturn( streamInterfaceList ); fuzzyMatch.processRow( meta, data ); Assert.assertEquals( rowMetaInterface.getString( row3B, 0 ), data.outputRowMeta.getString( fuzzyMatch.resultRow, 1 ) ); }
|
Script extends BaseStep implements StepInterface { public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { meta = (ScriptMeta) smi; data = (ScriptData) sdi; if ( super.init( smi, sdi ) ) { jsScripts = meta.getJSScripts(); for ( int j = 0; j < jsScripts.length; j++ ) { switch ( jsScripts[ j ].getScriptType() ) { case ScriptValuesScript.TRANSFORM_SCRIPT: strTransformScript = jsScripts[ j ].getScript(); break; case ScriptValuesScript.START_SCRIPT: strStartScript = jsScripts[ j ].getScript(); break; case ScriptValuesScript.END_SCRIPT: strEndScript = jsScripts[ j ].getScript(); break; default: break; } } return true; } return false; } Script( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); Object getValueFromJScript( Object result, int i ); RowMetaInterface getOutputRowMeta(); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); static final int SKIP_TRANSFORMATION; static final int ABORT_TRANSFORMATION; static final int ERROR_TRANSFORMATION; static final int CONTINUE_TRANSFORMATION; }
|
@Test public void testOutputDoneIfInputEmpty() throws Exception { Script step = new Script( helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans ); step.init( helper.initStepMetaInterface, helper.initStepDataInterface ); RowSet rs = helper.getMockInputRowSet( new Object[ 0 ][ 0 ] ); List<RowSet> in = new ArrayList<RowSet>(); in.add( rs ); step.setInputRowSets( in ); TransTestingUtil.execute( step, helper.processRowsStepMetaInterface, helper.processRowsStepDataInterface, 0, true ); rs.getRow(); }
|
SwitchCase extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (SwitchCaseMeta) smi; data = (SwitchCaseData) sdi; Object[] r = getRow(); if ( r == null ) { setOutputDone(); return false; } if ( first ) { first = false; createOutputValueMapping(); } Object lookupData = data.valueMeta.convertData( data.inputValueMeta, r[data.fieldIndex] ); Set<RowSet> rowSetSet = ( data.valueMeta.isNull( lookupData ) ) ? data.nullRowSetSet : data.outputMap.get( lookupData ); if ( rowSetSet == null ) { rowSetSet = data.defaultRowSetSet; } for ( RowSet rowSet : rowSetSet ) { putRowTo( data.outputRowMeta, r, rowSet ); } if ( checkFeedback( getLinesRead() ) ) { if ( log.isBasic() ) { logBasic( BaseMessages.getString( PKG, "SwitchCase.Log.LineNumber" ) + getLinesRead() ); } } return true; } SwitchCase( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); }
|
@Test public void testProcessRow() throws KettleException { SwitchCaseCustom krasavez = new SwitchCaseCustom( mockHelper ); krasavez.first = false; RowSet rowSetOne = new QueueRowSet(); RowSet rowSetTwo = new QueueRowSet(); krasavez.data.outputMap.put( 3, rowSetOne ); krasavez.data.outputMap.put( 3, rowSetTwo ); RowSet rowSetNullOne = new QueueRowSet(); RowSet rowSetNullTwo = new QueueRowSet(); krasavez.data.nullRowSetSet.add( rowSetNullOne ); krasavez.data.nullRowSetSet.add( rowSetNullTwo ); RowSet def = new QueueRowSet(); krasavez.data.defaultRowSetSet.add( def ); krasavez.generateData( 1, 5, 2 ); krasavez.processRow(); assertEquals( "First row set collects 2 rows", 2, rowSetOne.size() ); assertEquals( "Second row set collects 2 rows", 2, rowSetTwo.size() ); assertEquals( "First null row set collects 5 rows", 6, rowSetNullOne.size() ); assertEquals( "Second null row set collects 5 rows", 6, rowSetNullTwo.size() ); assertEquals( "Default row set collects the rest of rows", 8, def.size() ); assertEquals( "First row set contains only 3: ", true, isRowSetContainsValue( rowSetOne, new Object[] { 3 }, new Object[] { } ) ); assertEquals( "Second row set contains only 3: ", true, isRowSetContainsValue( rowSetTwo, new Object[] { 3 }, new Object[] { } ) ); assertEquals( "First null row set contains only null: ", true, isRowSetContainsValue( rowSetNullOne, new Object[] { null }, new Object[] { } ) ); assertEquals( "Second null row set contains only null: ", true, isRowSetContainsValue( rowSetNullTwo, new Object[] { null }, new Object[] { } ) ); assertEquals( "Default row set do not contains null or 3, but other", true, isRowSetContainsValue( def, new Object[] { 1, 2, 4, 5 }, new Object[] { 3, null } ) ); }
@Test public void processRow_NullsArePutIntoDefaultWhenNotSpecified() throws Exception { SwitchCaseCustom step = new SwitchCaseCustom( mockHelper ); step.meta.loadXML( loadStepXmlMetadata( "SwitchCaseTest_PDI-12671.xml" ), Collections.<DatabaseMeta>emptyList(), mock( IMetaStore.class ) ); List<RowSet> outputRowSets = new LinkedList<RowSet>(); for ( SwitchCaseTarget item : step.meta.getCaseTargets() ) { StepMetaInterface smInt = new DummyTransMeta(); item.caseTargetStep = new StepMeta( item.caseTargetStepname, smInt ); RowSet rw = new QueueRowSet(); step.map.put( item.caseTargetStepname, rw ); outputRowSets.add( rw ); } StepMetaInterface smInt = new DummyTransMeta(); StepMeta stepMeta = new StepMeta( step.meta.getDefaultTargetStepname(), smInt ); step.meta.setDefaultTargetStep( stepMeta ); RowSet defaultRowSet = new QueueRowSet(); step.map.put( step.meta.getDefaultTargetStepname(), defaultRowSet ); step.input.add( new Object[] { null } ); step.processRow(); assertEquals( 1, defaultRowSet.size() ); for ( RowSet rowSet : outputRowSets ) { assertEquals( 0, rowSet.size() ); } assertNull( defaultRowSet.getRow()[0] ); }
|
SwitchCase extends BaseStep implements StepInterface { void createOutputValueMapping() throws KettleException { data.outputRowMeta = getInputRowMeta().clone(); meta.getFields( getInputRowMeta(), getStepname(), null, null, this, repository, metaStore ); data.fieldIndex = getInputRowMeta().indexOfValue( meta.getFieldname() ); if ( data.fieldIndex < 0 ) { throw new KettleException( BaseMessages.getString( PKG, "SwitchCase.Exception.UnableToFindFieldName", meta .getFieldname() ) ); } data.inputValueMeta = getInputRowMeta().getValueMeta( data.fieldIndex ); try { StepIOMetaInterface ioMeta = meta.getStepIOMeta(); List<StreamInterface> targetStreams = ioMeta.getTargetStreams(); for ( int i = 0; i < targetStreams.size(); i++ ) { SwitchCaseTarget target = (SwitchCaseTarget) targetStreams.get( i ).getSubject(); if ( target == null ) { break; } if ( target.caseTargetStep == null ) { throw new KettleException( BaseMessages.getString( PKG, "SwitchCase.Log.NoTargetStepSpecifiedForValue", target.caseValue ) ); } RowSet rowSet = findOutputRowSet( target.caseTargetStep.getName() ); if ( rowSet == null ) { throw new KettleException( BaseMessages.getString( PKG, "SwitchCase.Log.UnableToFindTargetRowSetForStep", target.caseTargetStep ) ); } try { Object value = data.valueMeta.convertDataFromString( target.caseValue, data.stringValueMeta, null, null, ValueMetaInterface.TRIM_TYPE_NONE ); if ( data.valueMeta.isNull( value ) ) { data.nullRowSetSet.add( rowSet ); } else { data.outputMap.put( value, rowSet ); } } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "SwitchCase.Log.UnableToConvertValue", target.caseValue ), e ); } } if ( meta.getDefaultTargetStep() != null ) { RowSet rowSet = findOutputRowSet( meta.getDefaultTargetStep().getName() ); if ( rowSet != null ) { data.defaultRowSetSet.add( rowSet ); if ( data.nullRowSetSet.isEmpty() ) { data.nullRowSetSet.add( rowSet ); } } } } catch ( Exception e ) { throw new KettleException( e ); } } SwitchCase( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); }
|
@Test public void testCreateOutputValueMapping() throws KettleException, URISyntaxException, ParserConfigurationException, SAXException, IOException { SwitchCaseCustom krasavez = new SwitchCaseCustom( mockHelper ); List<DatabaseMeta> emptyList = new ArrayList<DatabaseMeta>(); krasavez.meta.loadXML( loadStepXmlMetadata( "SwitchCaseTest.xml" ), emptyList, mock( IMetaStore.class ) ); KeyToRowSetMap expectedNN = new KeyToRowSetMap(); Set<RowSet> nulls = new HashSet<RowSet>(); List<SwitchCaseTarget> list = krasavez.meta.getCaseTargets(); for ( SwitchCaseTarget item : list ) { StepMetaInterface smInt = new DummyTransMeta(); StepMeta stepMeta = new StepMeta( item.caseTargetStepname, smInt ); item.caseTargetStep = stepMeta; RowSet rw = new QueueRowSet(); krasavez.map.put( item.caseTargetStepname, rw ); if ( item.caseValue != null ) { expectedNN.put( item.caseValue, rw ); } else { nulls.add( rw ); } } StepMetaInterface smInt = new DummyTransMeta(); StepMeta stepMeta = new StepMeta( krasavez.meta.getDefaultTargetStepname(), smInt ); krasavez.meta.setDefaultTargetStep( stepMeta ); RowSet rw = new QueueRowSet(); krasavez.map.put( krasavez.meta.getDefaultTargetStepname(), rw ); krasavez.createOutputValueMapping(); Set<RowSet> ones = krasavez.data.outputMap.get( "1" ); assertEquals( "Output map for 1 values contains 2 row sets", 2, ones.size() ); Set<RowSet> twos = krasavez.data.outputMap.get( "2" ); assertEquals( "Output map for 2 values contains 1 row sets", 1, twos.size() ); assertEquals( "Null row set contains 2 items: ", 2, krasavez.data.nullRowSetSet.size() ); assertEquals( "We have at least one default rowset", 1, krasavez.data.defaultRowSetSet.size() ); Set<RowSet> rowsets = expectedNN.get( "1" ); for ( RowSet rowset : rowsets ) { assertTrue( "Output map for 1 values contains expected row set", ones.contains( rowset ) ); } rowsets = expectedNN.get( "2" ); for ( RowSet rowset : rowsets ) { assertTrue( "Output map for 2 values contains expected row set", twos.contains( rowset ) ); } for ( RowSet rowset : krasavez.data.nullRowSetSet ) { assertTrue( "Output map for null values contains expected row set", nulls.contains( rowset ) ); } for ( RowSet rowset : krasavez.data.defaultRowSetSet ) { assertTrue( "Output map for default case contains expected row set", rowset.equals( rw ) ); } }
|
TableInputMeta extends BaseStepMeta implements StepMetaInterface { public void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { if ( databaseMeta == null ) { return; } boolean param = false; Database db = getDatabase(); databases = new Database[] { db }; String sNewSQL = sql; if ( isVariableReplacementActive() ) { sNewSQL = db.environmentSubstitute( sql ); if ( space != null ) { sNewSQL = space.environmentSubstitute( sNewSQL ); } } RowMetaInterface add = null; try { add = db.getQueryFields( sNewSQL, param ); } catch ( KettleDatabaseException dbe ) { throw new KettleStepException( "Unable to get queryfields for SQL: " + Const.CR + sNewSQL, dbe ); } if ( add != null ) { for ( int i = 0; i < add.size(); i++ ) { ValueMetaInterface v = add.getValueMeta( i ); v.setOrigin( origin ); } row.addRowMeta( add ); } else { try { db.connect(); RowMetaInterface paramRowMeta = null; Object[] paramData = null; StreamInterface infoStream = getStepIOMeta().getInfoStreams().get( 0 ); if ( !Utils.isEmpty( infoStream.getStepname() ) ) { param = true; if ( info.length >= 0 && info[0] != null ) { paramRowMeta = info[0]; paramData = RowDataUtil.allocateRowData( paramRowMeta.size() ); } } add = db.getQueryFields( sNewSQL, param, paramRowMeta, paramData ); if ( add == null ) { return; } for ( int i = 0; i < add.size(); i++ ) { ValueMetaInterface v = add.getValueMeta( i ); v.setOrigin( origin ); } row.addRowMeta( add ); } catch ( KettleException ke ) { throw new KettleStepException( "Unable to get queryfields for SQL: " + Const.CR + sNewSQL, ke ); } finally { db.disconnect(); } } if ( isLazyConversionActive() ) { for ( int i = 0; i < row.size(); i++ ) { ValueMetaInterface v = row.getValueMeta( i ); try { if ( v.getType() == ValueMetaInterface.TYPE_STRING ) { ValueMetaInterface storageMeta = ValueMetaFactory.cloneValueMeta( v ); storageMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_NORMAL ); v.setStorageMetadata( storageMeta ); v.setStorageType( ValueMetaInterface.STORAGE_TYPE_BINARY_STRING ); } } catch ( KettlePluginException e ) { throw new KettleStepException( "Unable to clone meta for lazy conversion: " + Const.CR + v, e ); } } } } TableInputMeta(); boolean isExecuteEachInputRow(); void setExecuteEachInputRow( boolean oncePerRow ); DatabaseMeta getDatabaseMeta(); void setDatabaseMeta( DatabaseMeta database ); String getRowLimit(); void setRowLimit( String rowLimit ); String getSQL(); void setSQL( String sql ); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); Object clone(); void setDefault(); void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); String getXML(); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); void searchInfoAndTargetSteps( List<StepMeta> steps ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ); StepDataInterface getStepData(); @Override void analyseImpact( List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, Repository repository,
IMetaStore metaStore ); DatabaseMeta[] getUsedDatabaseConnections(); boolean isVariableReplacementActive(); void setVariableReplacementActive( boolean variableReplacementActive ); boolean isLazyConversionActive(); void setLazyConversionActive( boolean lazyConversionActive ); StepIOMetaInterface getStepIOMeta(); void resetStepIoMeta(); void setLookupFromStep( StepMeta stepMeta ); StepMeta getLookupFromStep(); @Override TableInputMetaInjection getStepMetaInjectionInterface(); List<StepInjectionMetaEntry> extractStepMetadataEntries(); }
|
@Test public void testGetFields() throws Exception { TableInputMetaHandler meta = new TableInputMetaHandler(); meta.setLazyConversionActive( true ); DatabaseMeta dbMeta = mock( DatabaseMeta.class ); meta.setDatabaseMeta( dbMeta ); Database mockDB = meta.getDatabase(); when( mockDB.getQueryFields( anyString(), anyBoolean() ) ).thenReturn( createMockFields() ); RowMetaInterface expectedRowMeta = new RowMeta(); ValueMetaInterface valueMeta = new ValueMetaString( "field1" ); valueMeta.setStorageMetadata( new ValueMetaString( "field1" ) ); valueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_BINARY_STRING ); expectedRowMeta.addValueMeta( valueMeta ); VariableSpace space = mock( VariableSpace.class ); RowMetaInterface rowMetaInterface = new RowMeta(); meta.getFields( rowMetaInterface, "TABLE_INPUT_META", null, null, space, null, null ); assertEquals( expectedRowMeta.toString(), rowMetaInterface.toString() ); }
|
FilterRowsMeta extends BaseStepMeta implements StepMetaInterface { public Object clone() { FilterRowsMeta retval = (FilterRowsMeta) super.clone(); retval.setTrueStepname( getTrueStepname() ); retval.setFalseStepname( getFalseStepname() ); if ( condition != null ) { retval.condition = (Condition) condition.clone(); } else { retval.condition = null; } return retval; } FilterRowsMeta(); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); Condition getCondition(); void setCondition( Condition condition ); void allocate(); Object clone(); String getXML(); void setDefault(); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void searchInfoAndTargetSteps( List<StepMeta> steps ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void getFields( RowMetaInterface rowMeta, String origin, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr,
Trans trans ); StepDataInterface getStepData(); StepIOMetaInterface getStepIOMeta(); @Override void resetStepIoMeta(); void handleStreamSelection( StreamInterface stream ); @Override boolean excludeFromCopyDistributeVerification(); List<String> getOrphanFields( Condition condition, RowMetaInterface prev ); String getTrueStepname(); @Injection( name = "SEND_TRUE_STEP" ) void setTrueStepname( String trueStepname ); String getFalseStepname(); @Injection( name = "SEND_FALSE_STEP" ) void setFalseStepname( String falseStepname ); String getConditionXML(); @Injection( name = "CONDITION" ) void setConditionXML( String conditionXML ); }
|
@Test public void testClone() { FilterRowsMeta filterRowsMeta = new FilterRowsMeta(); filterRowsMeta.setCondition( new Condition() ); filterRowsMeta.setTrueStepname( "true" ); filterRowsMeta.setFalseStepname( "false" ); FilterRowsMeta clone = (FilterRowsMeta) filterRowsMeta.clone(); assertNotNull( clone.getCondition() ); assertEquals( "true", clone.getTrueStepname() ); assertEquals( "false", clone.getFalseStepname() ); }
|
CombinationLookup extends BaseStep implements StepInterface { public Long combiInsert( RowMetaInterface rowMeta, Object[] row, Long val_key, Long val_crc ) throws KettleDatabaseException { String debug = "Combination insert"; DatabaseMeta databaseMeta = meta.getDatabaseMeta(); try { if ( data.prepStatementInsert == null ) { debug = "First: construct prepared statement"; data.insertRowMeta = new RowMeta(); String sql = ""; sql += "INSERT INTO " + data.schemaTable + ( "( " ); boolean comma = false; if ( !isAutoIncrement() ) { sql += databaseMeta.quoteField( meta.getTechnicalKeyField() ); data.insertRowMeta.addValueMeta( new ValueMetaInteger( meta.getTechnicalKeyField() ) ); comma = true; } else if ( databaseMeta.needsPlaceHolder() ) { sql += "0"; data.insertRowMeta.addValueMeta( new ValueMetaInteger( meta.getTechnicalKeyField() ) ); comma = true; } if ( meta.useHash() ) { if ( comma ) { sql += ", "; } sql += databaseMeta.quoteField( meta.getHashField() ); data.insertRowMeta.addValueMeta( new ValueMetaInteger( meta.getHashField() ) ); comma = true; } if ( !Utils.isEmpty( meta.getLastUpdateField() ) ) { if ( comma ) { sql += ", "; } sql += databaseMeta.quoteField( meta.getLastUpdateField() ); data.insertRowMeta .addValueMeta( new ValueMetaDate( meta.getLastUpdateField() ) ); comma = true; } for ( int i = 0; i < meta.getKeyLookup().length; i++ ) { if ( comma ) { sql += ", "; } sql += databaseMeta.quoteField( meta.getKeyLookup()[i] ); data.insertRowMeta.addValueMeta( rowMeta.getValueMeta( data.keynrs[i] ) ); comma = true; } sql += ") VALUES ("; comma = false; if ( !isAutoIncrement() ) { sql += '?'; comma = true; } if ( meta.useHash() ) { if ( comma ) { sql += ','; } sql += '?'; comma = true; } if ( !Utils.isEmpty( meta.getLastUpdateField() ) ) { if ( comma ) { sql += ','; } sql += '?'; comma = true; } for ( int i = 0; i < meta.getKeyLookup().length; i++ ) { if ( comma ) { sql += ','; } else { comma = true; } sql += '?'; } sql += " )"; String sqlStatement = sql; try { debug = "First: prepare statement"; if ( isAutoIncrement() && databaseMeta.supportsAutoGeneratedKeys() ) { logDetailed( "SQL with return keys: " + sqlStatement ); data.prepStatementInsert = data.db.getConnection().prepareStatement( databaseMeta.stripCR( sqlStatement ), Statement.RETURN_GENERATED_KEYS ); } else { logDetailed( "SQL without return keys: " + sqlStatement ); data.prepStatementInsert = data.db.getConnection().prepareStatement( databaseMeta.stripCR( sqlStatement ) ); } } catch ( SQLException ex ) { throw new KettleDatabaseException( "Unable to prepare combi insert statement : " + Const.CR + sqlStatement, ex ); } catch ( Exception ex ) { throw new KettleDatabaseException( "Unable to prepare combi insert statement : " + Const.CR + sqlStatement, ex ); } } debug = "Create new insert row rins"; Object[] insertRow = new Object[data.insertRowMeta.size()]; int insertIndex = 0; if ( !isAutoIncrement() ) { insertRow[insertIndex] = val_key; insertIndex++; } if ( meta.useHash() ) { insertRow[insertIndex] = val_crc; insertIndex++; } if ( !Utils.isEmpty( meta.getLastUpdateField() ) ) { insertRow[insertIndex] = new Date(); insertIndex++; } for ( int i = 0; i < data.keynrs.length; i++ ) { insertRow[insertIndex] = row[data.keynrs[i]]; insertIndex++; } if ( isRowLevel() ) { logRowlevel( "rins=" + data.insertRowMeta.getString( insertRow ) ); } debug = "Set values on insert"; data.db.setValues( data.insertRowMeta, insertRow, data.prepStatementInsert ); debug = "Insert row"; data.db.insertRow( data.prepStatementInsert ); debug = "Retrieve key"; if ( isAutoIncrement() && databaseMeta.supportsAutoGeneratedKeys() ) { ResultSet keys = null; try { keys = data.prepStatementInsert.getGeneratedKeys(); if ( keys.next() ) { val_key = new Long( keys.getLong( 1 ) ); } else { throw new KettleDatabaseException( "Unable to retrieve auto-increment of combi insert key : " + meta.getTechnicalKeyField() + ", no fields in resultset" ); } } catch ( SQLException ex ) { throw new KettleDatabaseException( "Unable to retrieve auto-increment of combi insert key : " + meta.getTechnicalKeyField(), ex ); } finally { try { if ( keys != null ) { keys.close(); } } catch ( SQLException ex ) { throw new KettleDatabaseException( "Unable to retrieve auto-increment of combi insert key : " + meta.getTechnicalKeyField(), ex ); } } } } catch ( Exception e ) { logError( Const.getStackTracker( e ) ); throw new KettleDatabaseException( "Unexpected error in combination insert in part [" + debug + "] : " + e.toString(), e ); } return val_key; } CombinationLookup( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr,
TransMeta transMeta, Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); void setCombiLookup( RowMetaInterface inputRowMeta ); Long combiInsert( RowMetaInterface rowMeta, Object[] row, Long val_key, Long val_crc ); boolean isRowLevel(); boolean init( StepMetaInterface sii, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
|
@Test public void testCombiInsert() throws Exception { combinationLookupSpy.combiInsert( any( RowMetaInterface.class ), any( Object[].class ), anyLong(), anyLong() ); verify( databaseMeta, times( 2 ) ).supportsAutoGeneratedKeys(); }
|
TableOutputMeta extends BaseStepMeta implements StepMetaInterface, ProvidesModelerMeta { public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException { try { databaseMeta = rep.loadDatabaseMetaFromStepAttribute( id_step, "id_connection", databases ); schemaName = rep.getStepAttributeString( id_step, "schema" ); tableName = rep.getStepAttributeString( id_step, "table" ); commitSize = rep.getStepAttributeString( id_step, "commit" ); truncateTable = rep.getStepAttributeBoolean( id_step, "truncate" ); ignoreErrors = rep.getStepAttributeBoolean( id_step, "ignore_errors" ); useBatchUpdate = rep.getStepAttributeBoolean( id_step, "use_batch" ); specifyFields = rep.getStepAttributeBoolean( id_step, "specify_fields" ); partitioningEnabled = rep.getStepAttributeBoolean( id_step, "partitioning_enabled" ); partitioningField = rep.getStepAttributeString( id_step, "partitioning_field" ); partitioningDaily = rep.getStepAttributeBoolean( id_step, "partitioning_daily" ); partitioningMonthly = rep.getStepAttributeBoolean( id_step, "partitioning_monthly" ); tableNameInField = rep.getStepAttributeBoolean( id_step, "tablename_in_field" ); tableNameField = rep.getStepAttributeString( id_step, "tablename_field" ); tableNameInTable = rep.getStepAttributeBoolean( id_step, "tablename_in_table" ); returningGeneratedKeys = rep.getStepAttributeBoolean( id_step, "return_keys" ); generatedKeyField = rep.getStepAttributeString( id_step, "return_field" ); int nrCols = rep.countNrStepAttributes( id_step, "column_name" ); int nrStreams = rep.countNrStepAttributes( id_step, "stream_name" ); int nrRows = ( nrCols < nrStreams ? nrStreams : nrCols ); allocate( nrRows ); for ( int idx = 0; idx < nrRows; idx++ ) { fieldDatabase[idx] = Const.NVL( rep.getStepAttributeString( id_step, idx, "column_name" ), "" ); fieldStream[idx] = Const.NVL( rep.getStepAttributeString( id_step, idx, "stream_name" ), "" ); } } catch ( Exception e ) { throw new KettleException( "Unexpected error reading step information from the repository", e ); } } TableOutputMeta(); String getGeneratedKeyField(); void setGeneratedKeyField( String generatedKeyField ); boolean isReturningGeneratedKeys(); void setReturningGeneratedKeys( boolean returningGeneratedKeys ); boolean isTableNameInTable(); void setTableNameInTable( boolean tableNameInTable ); String getTableNameField(); void setTableNameField( String tableNameField ); boolean isTableNameInField(); void setTableNameInField( boolean tableNameInField ); boolean isPartitioningDaily(); void setPartitioningDaily( boolean partitioningDaily ); boolean isPartitioningMonthly(); void setPartitioningMonthly( boolean partitioningMontly ); boolean isPartitioningEnabled(); void setPartitioningEnabled( boolean partitioningEnabled ); String getPartitioningField(); void setPartitioningField( String partitioningField ); void allocate( int nrRows ); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); Object clone(); DatabaseMeta getDatabaseMeta(); void setDatabaseMeta( DatabaseMeta database ); String getCommitSize(); void setCommitSize( int commitSizeInt ); void setCommitSize( String commitSize ); String getTableName(); void setTableName( String tableName ); @Deprecated String getTablename(); @Deprecated void setTablename( String tablename ); boolean truncateTable(); void setTruncateTable( boolean truncateTable ); void setIgnoreErrors( boolean ignoreErrors ); boolean ignoreErrors(); void setSpecifyFields( boolean specifyFields ); boolean specifyFields(); void setUseBatchUpdate( boolean useBatchUpdate ); boolean useBatchUpdate(); void setDefault(); String getXML(); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ); StepDataInterface getStepData(); void analyseImpact( List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, Repository repository,
IMetaStore metaStore ); SQLStatement getSQLStatements( TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
Repository repository, IMetaStore metaStore ); SQLStatement getSQLStatements( TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev, String tk,
boolean use_autoinc, String pk ); RowMetaInterface getRequiredFields( VariableSpace space ); DatabaseMeta[] getUsedDatabaseConnections(); String[] getFieldStream(); void setFieldStream( String[] fieldStream ); @Override RowMeta getRowMeta( StepDataInterface stepData ); @Override List<String> getDatabaseFields(); @Override List<String> getStreamFields(); String[] getFieldDatabase(); void setFieldDatabase( String[] fieldDatabase ); String getSchemaName(); void setSchemaName( String schemaName ); boolean supportsErrorHandling(); @Override String getMissingDatabaseConnectionInformationMessage(); @Override TableOutputMetaInjection getStepMetaInjectionInterface(); List<StepInjectionMetaEntry> extractStepMetadataEntries(); }
|
@Test public void testReadRep() throws KettleException { String commitSize = "${test}"; Repository rep = new MemoryRepository(); rep.saveStepAttribute( null, null, "commit", commitSize ); TableOutputMeta tableOutputMeta = new TableOutputMeta(); tableOutputMeta.readRep( rep, metaStore, null, databases ); assertEquals( commitSize, tableOutputMeta.getCommitSize() ); int commitSizeInt = 1; Repository rep2 = new MemoryRepository(); rep2.saveStepAttribute( null, null, "commit", commitSizeInt ); TableOutputMeta tableOutputMeta2 = new TableOutputMeta(); tableOutputMeta2.readRep( rep2, metaStore, null, databases ); assertEquals( String.valueOf( commitSizeInt ), tableOutputMeta2.getCommitSize() ); }
|
DataHandler extends AbstractXulEventHandler { protected void getControls() { dialogDeck = (XulDeck) document.getElementById( "dialog-panel-deck" ); deckOptionsBox = (XulListbox) document.getElementById( "deck-options-list" ); connectionBox = (XulListbox) document.getElementById( "connection-type-list" ); accessBox = (XulListbox) document.getElementById( "access-type-list" ); connectionNameBox = (XulTextbox) document.getElementById( "connection-name-text" ); hostNameBox = (XulTextbox) document.getElementById( "server-host-name-text" ); databaseNameBox = (XulTextbox) document.getElementById( "database-name-text" ); portNumberBox = (XulTextbox) document.getElementById( "port-number-text" ); userNameBox = (XulTextbox) document.getElementById( "username-text" ); passwordBox = (XulTextbox) document.getElementById( "password-text" ); dataTablespaceBox = (XulTextbox) document.getElementById( "data-tablespace-text" ); indexTablespaceBox = (XulTextbox) document.getElementById( "index-tablespace-text" ); serverInstanceBox = (XulTextbox) document.getElementById( "instance-text" ); serverNameBox = (XulTextbox) document.getElementById( "server-name-text" ); customUrlBox = (XulTextbox) document.getElementById( "custom-url-text" ); customDriverClassBox = (XulTextbox) document.getElementById( "custom-driver-class-text" ); languageBox = (XulTextbox) document.getElementById( "language-text" ); systemNumberBox = (XulTextbox) document.getElementById( "system-number-text" ); clientBox = (XulTextbox) document.getElementById( "client-text" ); doubleDecimalSeparatorCheck = (XulCheckbox) document.getElementById( "decimal-separator-check" ); resultStreamingCursorCheck = (XulCheckbox) document.getElementById( "result-streaming-check" ); webAppName = (XulTextbox) document.getElementById( "web-application-name-text" ); poolingCheck = (XulCheckbox) document.getElementById( "use-pool-check" ); clusteringCheck = (XulCheckbox) document.getElementById( "use-cluster-check" ); clusterParameterDescriptionLabel = (XulLabel) document.getElementById( "cluster-parameter-description-label" ); poolSizeLabel = (XulLabel) document.getElementById( "pool-size-label" ); poolSizeBox = (XulTextbox) document.getElementById( "pool-size-text" ); maxPoolSizeLabel = (XulLabel) document.getElementById( "max-pool-size-label" ); maxPoolSizeBox = (XulTextbox) document.getElementById( "max-pool-size-text" ); poolParameterTree = (XulTree) document.getElementById( "pool-parameter-tree" ); clusterParameterTree = (XulTree) document.getElementById( "cluster-parameter-tree" ); optionsParameterTree = (XulTree) document.getElementById( "options-parameter-tree" ); poolingDescription = (XulTextbox) document.getElementById( "pooling-description" ); poolingParameterDescriptionLabel = (XulLabel) document.getElementById( "pool-parameter-description-label" ); poolingDescriptionLabel = (XulLabel) document.getElementById( "pooling-description-label" ); supportBooleanDataType = (XulCheckbox) document.getElementById( "supports-boolean-data-type" ); supportTimestampDataType = (XulCheckbox) document.getElementById( "supports-timestamp-data-type" ); quoteIdentifiersCheck = (XulCheckbox) document.getElementById( "quote-identifiers-check" ); lowerCaseIdentifiersCheck = (XulCheckbox) document.getElementById( "force-lower-case-check" ); upperCaseIdentifiersCheck = (XulCheckbox) document.getElementById( "force-upper-case-check" ); preserveReservedCaseCheck = (XulCheckbox) document.getElementById( "preserve-reserved-case" ); strictBigNumberInterpretaion = (XulCheckbox) document.getElementById( "strict-bignum-interpretation" ); preferredSchemaName = (XulTextbox) document.getElementById( "preferred-schema-name-text" ); sqlBox = (XulTextbox) document.getElementById( "sql-text" ); useIntegratedSecurityCheck = (XulCheckbox) document.getElementById( "use-integrated-security-check" ); acceptButton = (XulButton) document.getElementById( "general-datasource-window_accept" ); cancelButton = (XulButton) document.getElementById( "general-datasource-window_cancel" ); testButton = (XulButton) document.getElementById( "test-button" ); noticeLabel = (XulLabel) document.getElementById( "notice-label" ); if ( portNumberBox != null && serverInstanceBox != null ) { if ( Boolean.parseBoolean( serverInstanceBox.getAttributeValue( "shouldDisablePortIfPopulated" ) ) ) { serverInstanceBox.addPropertyChangeListener( new PropertyChangeListener() { @Override public void propertyChange( PropertyChangeEvent evt ) { if ( "value".equals( evt.getPropertyName() ) ) { disablePortIfInstancePopulated(); } } } ); } } } DataHandler(); void loadConnectionData(); void loadAccessData(); void editOptions( int index ); void clearOptionsData(); void getOptionHelp(); void setDeckChildIndex(); void onPoolingCheck(); void onClusterCheck(); Object getData(); void setData( Object data ); void pushCache(); void popCache(); void onCancel(); void onOK(); void testDatabaseConnection(); void restoreDefaults(); void poolingRowChange( int idx ); void disablePortIfInstancePopulated(); void handleUseSecurityCheckbox(); static final SortedMap<String, DatabaseInterface> connectionMap; static final Map<String, String> connectionNametoID; }
|
@Test public void testGetControls() throws Exception { dataHandler.getControls(); assertNotNull( dataHandler.hostNameBox ); assertNotNull( dataHandler.portNumberBox ); assertNotNull( dataHandler.userNameBox ); assertNotNull( dataHandler.passwordBox ); }
|
DatabaseConnectionDialog { public XulDomContainer getSwtInstance( Shell shell ) throws XulException { SwtXulLoader loader = new SwtXulLoader(); return getSwtInstance( loader, shell ); } DatabaseConnectionDialog(); void registerClass( String key, String className ); XulDomContainer getSwtInstance( Shell shell ); XulDomContainer getSwtInstance( SwtXulLoader loader, Shell shell ); static final String DIALOG_DEFINITION_FILE; }
|
@Test public void testGetSwtInstance() throws Exception { }
|
TableOutputMeta extends BaseStepMeta implements StepMetaInterface, ProvidesModelerMeta { public boolean isReturningGeneratedKeys() { if ( getDatabaseMeta() != null ) { return getDatabaseMeta().supportsAutoGeneratedKeys() && returningGeneratedKeys; } return false; } TableOutputMeta(); String getGeneratedKeyField(); void setGeneratedKeyField( String generatedKeyField ); boolean isReturningGeneratedKeys(); void setReturningGeneratedKeys( boolean returningGeneratedKeys ); boolean isTableNameInTable(); void setTableNameInTable( boolean tableNameInTable ); String getTableNameField(); void setTableNameField( String tableNameField ); boolean isTableNameInField(); void setTableNameInField( boolean tableNameInField ); boolean isPartitioningDaily(); void setPartitioningDaily( boolean partitioningDaily ); boolean isPartitioningMonthly(); void setPartitioningMonthly( boolean partitioningMontly ); boolean isPartitioningEnabled(); void setPartitioningEnabled( boolean partitioningEnabled ); String getPartitioningField(); void setPartitioningField( String partitioningField ); void allocate( int nrRows ); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); Object clone(); DatabaseMeta getDatabaseMeta(); void setDatabaseMeta( DatabaseMeta database ); String getCommitSize(); void setCommitSize( int commitSizeInt ); void setCommitSize( String commitSize ); String getTableName(); void setTableName( String tableName ); @Deprecated String getTablename(); @Deprecated void setTablename( String tablename ); boolean truncateTable(); void setTruncateTable( boolean truncateTable ); void setIgnoreErrors( boolean ignoreErrors ); boolean ignoreErrors(); void setSpecifyFields( boolean specifyFields ); boolean specifyFields(); void setUseBatchUpdate( boolean useBatchUpdate ); boolean useBatchUpdate(); void setDefault(); String getXML(); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ); StepDataInterface getStepData(); void analyseImpact( List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, Repository repository,
IMetaStore metaStore ); SQLStatement getSQLStatements( TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
Repository repository, IMetaStore metaStore ); SQLStatement getSQLStatements( TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev, String tk,
boolean use_autoinc, String pk ); RowMetaInterface getRequiredFields( VariableSpace space ); DatabaseMeta[] getUsedDatabaseConnections(); String[] getFieldStream(); void setFieldStream( String[] fieldStream ); @Override RowMeta getRowMeta( StepDataInterface stepData ); @Override List<String> getDatabaseFields(); @Override List<String> getStreamFields(); String[] getFieldDatabase(); void setFieldDatabase( String[] fieldDatabase ); String getSchemaName(); void setSchemaName( String schemaName ); boolean supportsErrorHandling(); @Override String getMissingDatabaseConnectionInformationMessage(); @Override TableOutputMetaInjection getStepMetaInjectionInterface(); List<StepInjectionMetaEntry> extractStepMetadataEntries(); }
|
@Test public void testIsReturningGeneratedKeys() throws Exception { TableOutputMeta tableOutputMeta = new TableOutputMeta(), tableOutputMetaSpy = spy( tableOutputMeta ); DatabaseMeta databaseMeta = mock( DatabaseMeta.class ); doReturn( true ).when( databaseMeta ).supportsAutoGeneratedKeys(); doReturn( databaseMeta ).when( tableOutputMetaSpy ).getDatabaseMeta(); tableOutputMetaSpy.setReturningGeneratedKeys( true ); assertTrue( tableOutputMetaSpy.isReturningGeneratedKeys() ); doReturn( false ).when( databaseMeta ).supportsAutoGeneratedKeys(); assertFalse( tableOutputMetaSpy.isReturningGeneratedKeys() ); tableOutputMetaSpy.setReturningGeneratedKeys( true ); assertFalse( tableOutputMetaSpy.isReturningGeneratedKeys() ); tableOutputMetaSpy.setReturningGeneratedKeys( false ); assertFalse( tableOutputMetaSpy.isReturningGeneratedKeys() ); }
|
TableOutputMeta extends BaseStepMeta implements StepMetaInterface, ProvidesModelerMeta { public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException { readData( stepnode, databases ); } TableOutputMeta(); String getGeneratedKeyField(); void setGeneratedKeyField( String generatedKeyField ); boolean isReturningGeneratedKeys(); void setReturningGeneratedKeys( boolean returningGeneratedKeys ); boolean isTableNameInTable(); void setTableNameInTable( boolean tableNameInTable ); String getTableNameField(); void setTableNameField( String tableNameField ); boolean isTableNameInField(); void setTableNameInField( boolean tableNameInField ); boolean isPartitioningDaily(); void setPartitioningDaily( boolean partitioningDaily ); boolean isPartitioningMonthly(); void setPartitioningMonthly( boolean partitioningMontly ); boolean isPartitioningEnabled(); void setPartitioningEnabled( boolean partitioningEnabled ); String getPartitioningField(); void setPartitioningField( String partitioningField ); void allocate( int nrRows ); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); Object clone(); DatabaseMeta getDatabaseMeta(); void setDatabaseMeta( DatabaseMeta database ); String getCommitSize(); void setCommitSize( int commitSizeInt ); void setCommitSize( String commitSize ); String getTableName(); void setTableName( String tableName ); @Deprecated String getTablename(); @Deprecated void setTablename( String tablename ); boolean truncateTable(); void setTruncateTable( boolean truncateTable ); void setIgnoreErrors( boolean ignoreErrors ); boolean ignoreErrors(); void setSpecifyFields( boolean specifyFields ); boolean specifyFields(); void setUseBatchUpdate( boolean useBatchUpdate ); boolean useBatchUpdate(); void setDefault(); String getXML(); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ); StepDataInterface getStepData(); void analyseImpact( List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, Repository repository,
IMetaStore metaStore ); SQLStatement getSQLStatements( TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
Repository repository, IMetaStore metaStore ); SQLStatement getSQLStatements( TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev, String tk,
boolean use_autoinc, String pk ); RowMetaInterface getRequiredFields( VariableSpace space ); DatabaseMeta[] getUsedDatabaseConnections(); String[] getFieldStream(); void setFieldStream( String[] fieldStream ); @Override RowMeta getRowMeta( StepDataInterface stepData ); @Override List<String> getDatabaseFields(); @Override List<String> getStreamFields(); String[] getFieldDatabase(); void setFieldDatabase( String[] fieldDatabase ); String getSchemaName(); void setSchemaName( String schemaName ); boolean supportsErrorHandling(); @Override String getMissingDatabaseConnectionInformationMessage(); @Override TableOutputMetaInjection getStepMetaInjectionInterface(); List<StepInjectionMetaEntry> extractStepMetadataEntries(); }
|
@Test public void testLoadXml() throws Exception { TableOutputMeta tableOutputMeta = new TableOutputMeta(); tableOutputMeta.loadXML( getTestNode(), databases, metaStore ); assertEquals( "1000", tableOutputMeta.getCommitSize() ); assertEquals( null, tableOutputMeta.getGeneratedKeyField() ); assertEquals( "public", tableOutputMeta.getSchemaName() ); assertEquals( "sales_csv", tableOutputMeta.getTableName() ); assertEquals( null, tableOutputMeta.getPartitioningField() ); assertTrue( tableOutputMeta.truncateTable() ); assertTrue( tableOutputMeta.specifyFields() ); assertFalse( tableOutputMeta.ignoreErrors() ); assertFalse( tableOutputMeta.isPartitioningEnabled() ); assertTrue( tableOutputMeta.useBatchUpdate() ); assertFalse( tableOutputMeta.isTableNameInField() ); assertTrue( tableOutputMeta.isTableNameInTable() ); assertFalse( tableOutputMeta.isReturningGeneratedKeys() ); String expectedXml = "" + " <connection/>\n" + " <schema>public</schema>\n" + " <table>sales_csv</table>\n" + " <commit>1000</commit>\n" + " <truncate>Y</truncate>\n" + " <ignore_errors>N</ignore_errors>\n" + " <use_batch>Y</use_batch>\n" + " <specify_fields>Y</specify_fields>\n" + " <partitioning_enabled>N</partitioning_enabled>\n" + " <partitioning_field/>\n" + " <partitioning_daily>N</partitioning_daily>\n" + " <partitioning_monthly>Y</partitioning_monthly>\n" + " <tablename_in_field>N</tablename_in_field>\n" + " <tablename_field/>\n" + " <tablename_in_table>Y</tablename_in_table>\n" + " <return_keys>N</return_keys>\n" + " <return_field/>\n" + " <fields>\n" + " <field>\n" + " <column_name>ORDERNUMBER</column_name>\n" + " <stream_name>ORDERNUMBER</stream_name>\n" + " </field>\n" + " <field>\n" + " <column_name>QUANTITYORDERED</column_name>\n" + " <stream_name>QUANTITYORDERED</stream_name>\n" + " </field>\n" + " <field>\n" + " <column_name>PRICEEACH</column_name>\n" + " <stream_name>PRICEEACH</stream_name>\n" + " </field>\n" + " </fields>\n"; String actualXml = TestUtils.toUnixLineSeparators( tableOutputMeta.getXML() ); assertEquals( expectedXml, actualXml ); }
|
TableOutputMeta extends BaseStepMeta implements StepMetaInterface, ProvidesModelerMeta { public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ) throws KettleException { try { rep.saveDatabaseMetaStepAttribute( id_transformation, id_step, "id_connection", databaseMeta ); rep.saveStepAttribute( id_transformation, id_step, "schema", schemaName ); rep.saveStepAttribute( id_transformation, id_step, "table", tableName ); rep.saveStepAttribute( id_transformation, id_step, "commit", commitSize ); rep.saveStepAttribute( id_transformation, id_step, "truncate", truncateTable ); rep.saveStepAttribute( id_transformation, id_step, "ignore_errors", ignoreErrors ); rep.saveStepAttribute( id_transformation, id_step, "use_batch", useBatchUpdate ); rep.saveStepAttribute( id_transformation, id_step, "specify_fields", specifyFields ); rep.saveStepAttribute( id_transformation, id_step, "partitioning_enabled", partitioningEnabled ); rep.saveStepAttribute( id_transformation, id_step, "partitioning_field", partitioningField ); rep.saveStepAttribute( id_transformation, id_step, "partitioning_daily", partitioningDaily ); rep.saveStepAttribute( id_transformation, id_step, "partitioning_monthly", partitioningMonthly ); rep.saveStepAttribute( id_transformation, id_step, "tablename_in_field", tableNameInField ); rep.saveStepAttribute( id_transformation, id_step, "tablename_field", tableNameField ); rep.saveStepAttribute( id_transformation, id_step, "tablename_in_table", tableNameInTable ); rep.saveStepAttribute( id_transformation, id_step, "return_keys", returningGeneratedKeys ); rep.saveStepAttribute( id_transformation, id_step, "return_field", generatedKeyField ); int nrRows = ( fieldDatabase.length < fieldStream.length ? fieldStream.length : fieldDatabase.length ); for ( int idx = 0; idx < nrRows; idx++ ) { String columnName = ( idx < fieldDatabase.length ? fieldDatabase[idx] : "" ); String streamName = ( idx < fieldStream.length ? fieldStream[idx] : "" ); rep.saveStepAttribute( id_transformation, id_step, idx, "column_name", columnName ); rep.saveStepAttribute( id_transformation, id_step, idx, "stream_name", streamName ); } if ( databaseMeta != null ) { rep.insertStepDatabase( id_transformation, id_step, databaseMeta.getObjectId() ); } } catch ( Exception e ) { throw new KettleException( "Unable to save step information to the repository for id_step=" + id_step, e ); } } TableOutputMeta(); String getGeneratedKeyField(); void setGeneratedKeyField( String generatedKeyField ); boolean isReturningGeneratedKeys(); void setReturningGeneratedKeys( boolean returningGeneratedKeys ); boolean isTableNameInTable(); void setTableNameInTable( boolean tableNameInTable ); String getTableNameField(); void setTableNameField( String tableNameField ); boolean isTableNameInField(); void setTableNameInField( boolean tableNameInField ); boolean isPartitioningDaily(); void setPartitioningDaily( boolean partitioningDaily ); boolean isPartitioningMonthly(); void setPartitioningMonthly( boolean partitioningMontly ); boolean isPartitioningEnabled(); void setPartitioningEnabled( boolean partitioningEnabled ); String getPartitioningField(); void setPartitioningField( String partitioningField ); void allocate( int nrRows ); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); Object clone(); DatabaseMeta getDatabaseMeta(); void setDatabaseMeta( DatabaseMeta database ); String getCommitSize(); void setCommitSize( int commitSizeInt ); void setCommitSize( String commitSize ); String getTableName(); void setTableName( String tableName ); @Deprecated String getTablename(); @Deprecated void setTablename( String tablename ); boolean truncateTable(); void setTruncateTable( boolean truncateTable ); void setIgnoreErrors( boolean ignoreErrors ); boolean ignoreErrors(); void setSpecifyFields( boolean specifyFields ); boolean specifyFields(); void setUseBatchUpdate( boolean useBatchUpdate ); boolean useBatchUpdate(); void setDefault(); String getXML(); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ); StepDataInterface getStepData(); void analyseImpact( List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, Repository repository,
IMetaStore metaStore ); SQLStatement getSQLStatements( TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
Repository repository, IMetaStore metaStore ); SQLStatement getSQLStatements( TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev, String tk,
boolean use_autoinc, String pk ); RowMetaInterface getRequiredFields( VariableSpace space ); DatabaseMeta[] getUsedDatabaseConnections(); String[] getFieldStream(); void setFieldStream( String[] fieldStream ); @Override RowMeta getRowMeta( StepDataInterface stepData ); @Override List<String> getDatabaseFields(); @Override List<String> getStreamFields(); String[] getFieldDatabase(); void setFieldDatabase( String[] fieldDatabase ); String getSchemaName(); void setSchemaName( String schemaName ); boolean supportsErrorHandling(); @Override String getMissingDatabaseConnectionInformationMessage(); @Override TableOutputMetaInjection getStepMetaInjectionInterface(); List<StepInjectionMetaEntry> extractStepMetadataEntries(); }
|
@Test public void testSaveRep() throws Exception { TableOutputMeta tableOutputMeta = new TableOutputMeta(); tableOutputMeta.loadXML( getTestNode(), databases, metaStore ); StringObjectId id_step = new StringObjectId( "stepid" ); StringObjectId id_transformation = new StringObjectId( "transid" ); Repository rep = mock( Repository.class ); tableOutputMeta.saveRep( rep, metaStore, id_transformation, id_step ); verify( rep ).saveDatabaseMetaStepAttribute( id_transformation, id_step, "id_connection", null ); verify( rep ).saveStepAttribute( id_transformation, id_step, "schema", "public" ); verify( rep ).saveStepAttribute( id_transformation, id_step, "table", "sales_csv" ); verify( rep ).saveStepAttribute( id_transformation, id_step, "commit", "1000" ); verify( rep ).saveStepAttribute( id_transformation, id_step, "truncate", true ); verify( rep ).saveStepAttribute( id_transformation, id_step, "ignore_errors", false ); verify( rep ).saveStepAttribute( id_transformation, id_step, "use_batch", true ); verify( rep ).saveStepAttribute( id_transformation, id_step, "specify_fields", true ); verify( rep ).saveStepAttribute( id_transformation, id_step, "partitioning_enabled", false ); verify( rep ).saveStepAttribute( id_transformation, id_step, "partitioning_field", null ); verify( rep ).saveStepAttribute( id_transformation, id_step, "partitioning_daily", false ); verify( rep ).saveStepAttribute( id_transformation, id_step, "partitioning_monthly", true ); verify( rep ).saveStepAttribute( id_transformation, id_step, "tablename_in_field", false ); verify( rep ).saveStepAttribute( id_transformation, id_step, "tablename_field", null ); verify( rep ).saveStepAttribute( id_transformation, id_step, "tablename_in_table", true ); verify( rep ).saveStepAttribute( id_transformation, id_step, "return_keys", false ); verify( rep ).saveStepAttribute( id_transformation, id_step, "return_field", null ); verify( rep ).saveStepAttribute( id_transformation, id_step, 0, "column_name", "ORDERNUMBER" ); verify( rep ).saveStepAttribute( id_transformation, id_step, 0, "stream_name", "ORDERNUMBER" ); verify( rep ).saveStepAttribute( id_transformation, id_step, 1, "column_name", "QUANTITYORDERED" ); verify( rep ).saveStepAttribute( id_transformation, id_step, 1, "stream_name", "QUANTITYORDERED" ); verify( rep ).saveStepAttribute( id_transformation, id_step, 2, "column_name", "PRICEEACH" ); verify( rep ).saveStepAttribute( id_transformation, id_step, 2, "stream_name", "PRICEEACH" ); verifyNoMoreInteractions( rep ); }
|
TableOutputMeta extends BaseStepMeta implements StepMetaInterface, ProvidesModelerMeta { public Object clone() { Preconditions.checkState( fieldStream.length == fieldDatabase.length, "Table fields and stream fields are not of equal length." ); TableOutputMeta retval = (TableOutputMeta) super.clone(); int nrRows = fieldStream.length; retval.allocate( nrRows ); System.arraycopy( fieldStream, 0, retval.fieldStream, 0, nrRows ); System.arraycopy( fieldDatabase, 0, retval.fieldDatabase, 0, nrRows ); return retval; } TableOutputMeta(); String getGeneratedKeyField(); void setGeneratedKeyField( String generatedKeyField ); boolean isReturningGeneratedKeys(); void setReturningGeneratedKeys( boolean returningGeneratedKeys ); boolean isTableNameInTable(); void setTableNameInTable( boolean tableNameInTable ); String getTableNameField(); void setTableNameField( String tableNameField ); boolean isTableNameInField(); void setTableNameInField( boolean tableNameInField ); boolean isPartitioningDaily(); void setPartitioningDaily( boolean partitioningDaily ); boolean isPartitioningMonthly(); void setPartitioningMonthly( boolean partitioningMontly ); boolean isPartitioningEnabled(); void setPartitioningEnabled( boolean partitioningEnabled ); String getPartitioningField(); void setPartitioningField( String partitioningField ); void allocate( int nrRows ); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); Object clone(); DatabaseMeta getDatabaseMeta(); void setDatabaseMeta( DatabaseMeta database ); String getCommitSize(); void setCommitSize( int commitSizeInt ); void setCommitSize( String commitSize ); String getTableName(); void setTableName( String tableName ); @Deprecated String getTablename(); @Deprecated void setTablename( String tablename ); boolean truncateTable(); void setTruncateTable( boolean truncateTable ); void setIgnoreErrors( boolean ignoreErrors ); boolean ignoreErrors(); void setSpecifyFields( boolean specifyFields ); boolean specifyFields(); void setUseBatchUpdate( boolean useBatchUpdate ); boolean useBatchUpdate(); void setDefault(); String getXML(); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ); StepDataInterface getStepData(); void analyseImpact( List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, Repository repository,
IMetaStore metaStore ); SQLStatement getSQLStatements( TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
Repository repository, IMetaStore metaStore ); SQLStatement getSQLStatements( TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev, String tk,
boolean use_autoinc, String pk ); RowMetaInterface getRequiredFields( VariableSpace space ); DatabaseMeta[] getUsedDatabaseConnections(); String[] getFieldStream(); void setFieldStream( String[] fieldStream ); @Override RowMeta getRowMeta( StepDataInterface stepData ); @Override List<String> getDatabaseFields(); @Override List<String> getStreamFields(); String[] getFieldDatabase(); void setFieldDatabase( String[] fieldDatabase ); String getSchemaName(); void setSchemaName( String schemaName ); boolean supportsErrorHandling(); @Override String getMissingDatabaseConnectionInformationMessage(); @Override TableOutputMetaInjection getStepMetaInjectionInterface(); List<StepInjectionMetaEntry> extractStepMetadataEntries(); }
|
@Test public void testClone() throws Exception { TableOutputMeta tableOutputMeta = new TableOutputMeta(); tableOutputMeta.setDefault(); tableOutputMeta.setFieldStream( new String[] {"1", "2", "3"} ); tableOutputMeta.setFieldDatabase( new String[] {"d1", "d2", "d3"} ); TableOutputMeta clone = (TableOutputMeta) tableOutputMeta.clone(); assertNotSame( clone, tableOutputMeta ); assertEquals( clone.getXML(), tableOutputMeta.getXML() ); }
|
TableOutputMeta extends BaseStepMeta implements StepMetaInterface, ProvidesModelerMeta { public boolean supportsErrorHandling() { if ( databaseMeta != null ) { return databaseMeta.getDatabaseInterface().supportsErrorHandling(); } else { return true; } } TableOutputMeta(); String getGeneratedKeyField(); void setGeneratedKeyField( String generatedKeyField ); boolean isReturningGeneratedKeys(); void setReturningGeneratedKeys( boolean returningGeneratedKeys ); boolean isTableNameInTable(); void setTableNameInTable( boolean tableNameInTable ); String getTableNameField(); void setTableNameField( String tableNameField ); boolean isTableNameInField(); void setTableNameInField( boolean tableNameInField ); boolean isPartitioningDaily(); void setPartitioningDaily( boolean partitioningDaily ); boolean isPartitioningMonthly(); void setPartitioningMonthly( boolean partitioningMontly ); boolean isPartitioningEnabled(); void setPartitioningEnabled( boolean partitioningEnabled ); String getPartitioningField(); void setPartitioningField( String partitioningField ); void allocate( int nrRows ); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); Object clone(); DatabaseMeta getDatabaseMeta(); void setDatabaseMeta( DatabaseMeta database ); String getCommitSize(); void setCommitSize( int commitSizeInt ); void setCommitSize( String commitSize ); String getTableName(); void setTableName( String tableName ); @Deprecated String getTablename(); @Deprecated void setTablename( String tablename ); boolean truncateTable(); void setTruncateTable( boolean truncateTable ); void setIgnoreErrors( boolean ignoreErrors ); boolean ignoreErrors(); void setSpecifyFields( boolean specifyFields ); boolean specifyFields(); void setUseBatchUpdate( boolean useBatchUpdate ); boolean useBatchUpdate(); void setDefault(); String getXML(); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ); StepDataInterface getStepData(); void analyseImpact( List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, Repository repository,
IMetaStore metaStore ); SQLStatement getSQLStatements( TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
Repository repository, IMetaStore metaStore ); SQLStatement getSQLStatements( TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev, String tk,
boolean use_autoinc, String pk ); RowMetaInterface getRequiredFields( VariableSpace space ); DatabaseMeta[] getUsedDatabaseConnections(); String[] getFieldStream(); void setFieldStream( String[] fieldStream ); @Override RowMeta getRowMeta( StepDataInterface stepData ); @Override List<String> getDatabaseFields(); @Override List<String> getStreamFields(); String[] getFieldDatabase(); void setFieldDatabase( String[] fieldDatabase ); String getSchemaName(); void setSchemaName( String schemaName ); boolean supportsErrorHandling(); @Override String getMissingDatabaseConnectionInformationMessage(); @Override TableOutputMetaInjection getStepMetaInjectionInterface(); List<StepInjectionMetaEntry> extractStepMetadataEntries(); }
|
@Test public void testSupportsErrorHandling() throws Exception { TableOutputMeta tableOutputMeta = new TableOutputMeta(); DatabaseMeta dbMeta = mock( DatabaseMeta.class ); tableOutputMeta.setDatabaseMeta( dbMeta ); DatabaseInterface databaseInterface = mock( DatabaseInterface.class ); when( dbMeta.getDatabaseInterface() ).thenReturn( databaseInterface ); when( databaseInterface.supportsErrorHandling() ).thenReturn( true, false ); assertTrue( tableOutputMeta.supportsErrorHandling() ); assertFalse( tableOutputMeta.supportsErrorHandling() ); tableOutputMeta.setDatabaseMeta( null ); assertTrue( tableOutputMeta.supportsErrorHandling() ); }
|
TableOutput extends BaseStep implements StepInterface { protected Object[] writeToTable( RowMetaInterface rowMeta, Object[] r ) throws KettleException { if ( r == null ) { if ( log.isDetailed() ) { logDetailed( "Last line inserted: stop" ); } return null; } PreparedStatement insertStatement = null; Object[] insertRowData; Object[] outputRowData = r; String tableName = null; boolean sendToErrorRow = false; String errorMessage = null; boolean rowIsSafe = false; int[] updateCounts = null; List<Exception> exceptionsList = null; boolean batchProblem = false; Object generatedKey = null; if ( meta.isTableNameInField() ) { if ( data.indexOfTableNameField < 0 ) { String realTablename = environmentSubstitute( meta.getTableNameField() ); data.indexOfTableNameField = rowMeta.indexOfValue( realTablename ); if ( data.indexOfTableNameField < 0 ) { String message = "Unable to find table name field [" + realTablename + "] in input row"; logError( message ); throw new KettleStepException( message ); } if ( !meta.isTableNameInTable() && !meta.specifyFields() ) { data.insertRowMeta.removeValueMeta( data.indexOfTableNameField ); } } tableName = rowMeta.getString( r, data.indexOfTableNameField ); if ( !meta.isTableNameInTable() && !meta.specifyFields() ) { insertRowData = RowDataUtil.removeItem( rowMeta.cloneRow( r ), data.indexOfTableNameField ); } else { insertRowData = r; } } else if ( meta.isPartitioningEnabled() && ( meta.isPartitioningDaily() || meta.isPartitioningMonthly() ) && ( meta.getPartitioningField() != null && meta.getPartitioningField().length() > 0 ) ) { if ( data.indexOfPartitioningField < 0 ) { data.indexOfPartitioningField = rowMeta.indexOfValue( environmentSubstitute( meta.getPartitioningField() ) ); if ( data.indexOfPartitioningField < 0 ) { throw new KettleStepException( "Unable to find field [" + meta.getPartitioningField() + "] in the input row!" ); } if ( meta.isPartitioningDaily() ) { data.dateFormater = new SimpleDateFormat( "yyyyMMdd" ); } else { data.dateFormater = new SimpleDateFormat( "yyyyMM" ); } } ValueMetaInterface partitioningValue = rowMeta.getValueMeta( data.indexOfPartitioningField ); if ( !partitioningValue.isDate() || r[data.indexOfPartitioningField] == null ) { throw new KettleStepException( "Sorry, the partitioning field needs to contain a data value and can't be empty!" ); } Object partitioningValueData = rowMeta.getDate( r, data.indexOfPartitioningField ); tableName = environmentSubstitute( meta.getTableName() ) + "_" + data.dateFormater.format( (Date) partitioningValueData ); insertRowData = r; } else { tableName = data.tableName; insertRowData = r; } if ( meta.specifyFields() ) { insertRowData = new Object[data.valuenrs.length]; for ( int idx = 0; idx < data.valuenrs.length; idx++ ) { insertRowData[idx] = r[data.valuenrs[idx]]; } } if ( Utils.isEmpty( tableName ) ) { throw new KettleStepException( "The tablename is not defined (empty)" ); } insertStatement = data.preparedStatements.get( tableName ); if ( insertStatement == null ) { String sql = data.db .getInsertStatement( environmentSubstitute( meta.getSchemaName() ), tableName, data.insertRowMeta ); if ( log.isDetailed() ) { logDetailed( "Prepared statement : " + sql ); } if(meta.getDatabaseMeta().getURL().contains("phoenix")){ sql=sql.replace("insert", "upsert"); sql=sql.replace("INSERT", "UPSERT"); sql=sql.replace("update", "upsert"); sql=sql.replace("UPDATE", "UPSERT"); } try { insertStatement = data.db.prepareSQL( sql, meta.isReturningGeneratedKeys() ); } catch ( Exception e ) { logError( e.toString() ); } data.preparedStatements.put( tableName, insertStatement ); } try { if ( data.useSafePoints ) { data.savepoint = data.db.setSavepoint(); } data.db.setValues( data.insertRowMeta, insertRowData, insertStatement ); data.db.insertRow( insertStatement, data.batchMode, false ); if ( isRowLevel() ) { logRowlevel( "Written row: " + data.insertRowMeta.getString( insertRowData ) ); } Integer commitCounter = data.commitCounterMap.get( tableName ); if ( commitCounter == null ) { commitCounter = Integer.valueOf( 1 ); } else { commitCounter++; } data.commitCounterMap.put( tableName, Integer.valueOf( commitCounter.intValue() ) ); if ( data.useSafePoints ) { if ( data.releaseSavepoint ) { data.db.releaseSavepoint( data.savepoint ); } } if ( ( data.commitSize > 0 ) && ( ( commitCounter % data.commitSize ) == 0 ) ) { if ( data.db.getUseBatchInsert( data.batchMode ) ) { try { insertStatement.executeBatch(); data.db.commit(); insertStatement.clearBatch(); } catch ( SQLException ex ) { throw Database.createKettleDatabaseBatchException( "Error updating batch", ex ); } catch ( Exception ex ) { throw new KettleDatabaseException( "Unexpected error inserting row", ex ); } } else { data.db.commit(); } data.commitCounterMap.put( tableName, Integer.valueOf( 0 ) ); rowIsSafe = true; } else { rowIsSafe = false; } if ( meta.isReturningGeneratedKeys() ) { RowMetaAndData extraKeys = data.db.getGeneratedKeys( insertStatement ); if ( extraKeys.getRowMeta().size() > 0 ) { generatedKey = extraKeys.getRowMeta().getInteger( extraKeys.getData(), 0 ); } else { throw new KettleStepException( "No generated keys while \"return generated keys\" is active!" ); } } } catch ( KettleDatabaseBatchException be ) { errorMessage = be.toString(); batchProblem = true; sendToErrorRow = true; updateCounts = be.getUpdateCounts(); exceptionsList = be.getExceptionsList(); if ( getStepMeta().isDoingErrorHandling() ) { data.db.clearBatch( insertStatement ); data.db.commit( true ); } else { data.db.clearBatch( insertStatement ); data.db.rollback(); StringBuilder msg = new StringBuilder( "Error batch inserting rows into table [" + tableName + "]." ); msg.append( Const.CR ); msg.append( "Errors encountered (first 10):" ).append( Const.CR ); for ( int x = 0; x < be.getExceptionsList().size() && x < 10; x++ ) { Exception exception = be.getExceptionsList().get( x ); if ( exception.getMessage() != null ) { msg.append( exception.getMessage() ).append( Const.CR ); } } throw new KettleException( msg.toString(), be ); } } catch ( KettleDatabaseException dbe ) { if ( getStepMeta().isDoingErrorHandling() ) { if ( isRowLevel() ) { logRowlevel( "Written row to error handling : " + getInputRowMeta().getString( r ) ); } if ( data.useSafePoints ) { data.db.rollback( data.savepoint ); if ( data.releaseSavepoint ) { data.db.releaseSavepoint( data.savepoint ); } } sendToErrorRow = true; errorMessage = dbe.toString(); } else { if ( meta.ignoreErrors() ) { if ( data.warnings < 20 ) { if ( log.isBasic() ) { logBasic( "WARNING: Couldn't insert row into table: " + rowMeta.getString( r ) + Const.CR + dbe.getMessage() ); } } else if ( data.warnings == 20 ) { if ( log.isBasic() ) { logBasic( "FINAL WARNING (no more then 20 displayed): Couldn't insert row into table: " + rowMeta.getString( r ) + Const.CR + dbe.getMessage() ); } } data.warnings++; } else { setErrors( getErrors() + 1 ); data.db.rollback(); throw new KettleException( "Error inserting row into table [" + tableName + "] with values: " + rowMeta.getString( r ), dbe ); } } } if ( generatedKey != null ) { outputRowData = RowDataUtil.addValueData( outputRowData, rowMeta.size(), generatedKey ); } if ( data.batchMode ) { if ( sendToErrorRow ) { if ( batchProblem ) { data.batchBuffer.add( outputRowData ); outputRowData = null; processBatchException( errorMessage, updateCounts, exceptionsList ); } else { putError( rowMeta, r, 1L, errorMessage, null, "TOP001" ); outputRowData = null; } } else { data.batchBuffer.add( outputRowData ); outputRowData = null; if ( rowIsSafe ) { for ( int i = 0; i < data.batchBuffer.size(); i++ ) { Object[] row = data.batchBuffer.get( i ); putRow( data.outputRowMeta, row ); incrementLinesOutput(); } data.batchBuffer.clear(); } } } else { if ( sendToErrorRow ) { putError( rowMeta, r, 1, errorMessage, null, "TOP001" ); outputRowData = null; } } return outputRowData; } TableOutput( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean isRowLevel(); boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
|
@Test public void testWriteToTable() throws Exception { tableOutputSpy.writeToTable( mock( RowMetaInterface.class ), new Object[]{} ); }
|
TableOutput extends BaseStep implements StepInterface { void truncateTable() throws KettleDatabaseException { if ( !meta.isPartitioningEnabled() && !meta.isTableNameInField() ) { if ( meta.truncateTable() && ( ( getCopy() == 0 && getUniqueStepNrAcrossSlaves() == 0 ) || !Utils.isEmpty( getPartitionID() ) ) ) { data.db.truncateTable( environmentSubstitute( meta.getSchemaName() ), environmentSubstitute( meta .getTableName() ) ); } } } TableOutput( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean isRowLevel(); boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
|
@Test public void testTruncateTable_off() throws Exception { tableOutputSpy.truncateTable(); verify( db, never() ).truncateTable( anyString(), anyString() ); }
@Test public void testTruncateTable_on() throws Exception { when( tableOutputMeta.truncateTable() ).thenReturn( true ); when( tableOutputSpy.getCopy() ).thenReturn( 0 ); when( tableOutputSpy.getUniqueStepNrAcrossSlaves() ).thenReturn( 0 ); tableOutputSpy.truncateTable(); verify( db ).truncateTable( anyString(), anyString() ); }
@Test public void testTruncateTable_on_PartitionId() throws Exception { when( tableOutputMeta.truncateTable() ).thenReturn( true ); when( tableOutputSpy.getCopy() ).thenReturn( 1 ); when( tableOutputSpy.getUniqueStepNrAcrossSlaves() ).thenReturn( 0 ); when( tableOutputSpy.getPartitionID() ).thenReturn( "partition id" ); tableOutputSpy.truncateTable(); verify( db ).truncateTable( anyString(), anyString() ); }
|
SplitFieldToRows extends BaseStep implements StepInterface { public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { meta = (SplitFieldToRowsMeta) smi; data = (SplitFieldToRowsData) sdi; if ( super.init( smi, sdi ) ) { data.rownr = 1L; try { String delimiter = Const.nullToEmpty( meta.getDelimiter() ); if ( meta.isDelimiterRegex() ) { data.delimiterPattern = Pattern.compile( environmentSubstitute( delimiter ) ); } else { data.delimiterPattern = Pattern.compile( Pattern.quote( environmentSubstitute( delimiter ) ) ); } } catch ( PatternSyntaxException pse ) { log.logError( pse.getMessage() ); throw pse; } return true; } return false; } SplitFieldToRows( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr,
TransMeta transMeta, Trans trans ); synchronized boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); }
|
@Test public void interpretsNullDelimiterAsEmpty() throws Exception { SplitFieldToRows step = StepMockUtil.getStep( SplitFieldToRows.class, SplitFieldToRowsMeta.class, "handlesNullDelimiter" ); SplitFieldToRowsMeta meta = new SplitFieldToRowsMeta(); meta.setDelimiter( null ); meta.setDelimiterRegex( false ); SplitFieldToRowsData data = new SplitFieldToRowsData(); step.init( meta, data ); assertEquals( "\\Q\\E", data.delimiterPattern.pattern() ); }
|
DataHandler extends AbstractXulEventHandler { public void disablePortIfInstancePopulated() { String serverInstance = serverInstanceBox.getValue(); if ( serverInstance != null && serverInstance.length() > 0 ) { portNumberBox.setDisabled( true ); } else { portNumberBox.setDisabled( false ); } } DataHandler(); void loadConnectionData(); void loadAccessData(); void editOptions( int index ); void clearOptionsData(); void getOptionHelp(); void setDeckChildIndex(); void onPoolingCheck(); void onClusterCheck(); Object getData(); void setData( Object data ); void pushCache(); void popCache(); void onCancel(); void onOK(); void testDatabaseConnection(); void restoreDefaults(); void poolingRowChange( int idx ); void disablePortIfInstancePopulated(); void handleUseSecurityCheckbox(); static final SortedMap<String, DatabaseInterface> connectionMap; static final Map<String, String> connectionNametoID; }
|
@Test public void testDisablePortIfInstancePopulated() throws Exception { dataHandler.getControls(); dataHandler.disablePortIfInstancePopulated(); when( serverInstanceBox.getValue() ).thenReturn( null ); dataHandler.disablePortIfInstancePopulated(); assertFalse( dataHandler.portNumberBox.isDisabled() ); }
|
MonetDbVersion implements Comparable<MonetDbVersion> { @Override public int compareTo( MonetDbVersion mDbVersion ) { int result = majorVersion.compareTo( mDbVersion.majorVersion ); if ( result != 0 ) { return result; } result = minorVersion.compareTo( mDbVersion.minorVersion ); if ( result != 0 ) { return result; } result = patchVersion.compareTo( mDbVersion.patchVersion ); if ( result != 0 ) { return result; } return result; } MonetDbVersion(); MonetDbVersion( int majorVersion, int minorVersion, int patchVersion ); MonetDbVersion( String productVersion ); Integer getMinorVersion(); Integer getMajorVersion(); Integer getPatchVersion(); @Override int compareTo( MonetDbVersion mDbVersion ); @Override String toString(); static final MonetDbVersion JAN_2014_SP2_DB_VERSION; }
|
@Test public void testCompareVersions_DiffInPatch() throws Exception { String dbVersionBigger = "785.2.3"; String dbVersion = "785.2.2"; assertEquals( 1, new MonetDbVersion( dbVersionBigger ).compareTo( new MonetDbVersion( dbVersion ) ) ); }
@Test public void testCompareVersions_DiffInMinor() throws Exception { String dbVersionBigger = "785.5.3"; String dbVersion = "785.2.2"; assertEquals( 1, new MonetDbVersion( dbVersionBigger ).compareTo( new MonetDbVersion( dbVersion ) ) ); }
@Test public void testCompareVersions_DiffInMajor() throws Exception { String dbVersionBigger = "786.5.3"; String dbVersion = "785.2.2"; assertEquals( 1, new MonetDbVersion( dbVersionBigger ).compareTo( new MonetDbVersion( dbVersion ) ) ); }
@Test public void testCompareVersions_DiffInMajor_LongVersion() throws Exception { String dbVersionBigger = "788.5.3.8.9.7.5"; String dbVersion = "785.2.2"; assertEquals( 1, new MonetDbVersion( dbVersionBigger ).compareTo( new MonetDbVersion( dbVersion ) ) ); }
@Test public void testCompareVersions_TheSame() throws Exception { String dbVersionBigger = "11.11.7"; String dbVersion = "11.11.7"; assertEquals( 0, new MonetDbVersion( dbVersionBigger ).compareTo( new MonetDbVersion( dbVersion ) ) ); }
@Test public void testCompareVersions_NoPatch() throws Exception { String dbVersionBigger = "11.18"; String dbVersion = "11.17.17"; assertEquals( 1, new MonetDbVersion( dbVersionBigger ).compareTo( new MonetDbVersion( dbVersion ) ) ); }
|
BlockUntilStepsFinishMeta extends BaseStepMeta implements StepMetaInterface { public Object clone() { BlockUntilStepsFinishMeta retval = (BlockUntilStepsFinishMeta) super.clone(); int nrfields = stepName.length; retval.allocate( nrfields ); System.arraycopy( stepName, 0, retval.stepName, 0, nrfields ); System.arraycopy( stepCopyNr, 0, retval.stepCopyNr, 0, nrfields ); return retval; } BlockUntilStepsFinishMeta(); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); Object clone(); void allocate( int nrfields ); String[] getStepName(); String[] getStepCopyNr(); void setStepName( String[] stepName ); void setStepCopyNr( String[] stepCopyNr ); void getFields( RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); String getXML(); void setDefault(); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr,
Trans trans ); StepDataInterface getStepData(); TransformationType[] getSupportedTransformationTypes(); }
|
@Test public void cloneTest() throws Exception { BlockUntilStepsFinishMeta meta = new BlockUntilStepsFinishMeta(); meta.allocate( 2 ); meta.setStepName( new String[] { "step1", "step2" } ); meta.setStepCopyNr( new String[] { "copy1", "copy2" } ); BlockUntilStepsFinishMeta aClone = (BlockUntilStepsFinishMeta) meta.clone(); assertFalse( aClone == meta ); assertTrue( Arrays.equals( meta.getStepName(), aClone.getStepName() ) ); assertTrue( Arrays.equals( meta.getStepCopyNr(), aClone.getStepCopyNr() ) ); assertEquals( meta.getXML(), aClone.getXML() ); }
|
MultiMergeJoinMeta extends BaseStepMeta implements StepMetaInterface { @Override public String getXML() { StringBuilder retval = new StringBuilder(); String[] inputStepsNames = inputSteps != null ? inputSteps : ArrayUtils.EMPTY_STRING_ARRAY; retval.append( " " ).append( XMLHandler.addTagValue( "join_type", getJoinType() ) ); for ( int i = 0; i < inputStepsNames.length; i++ ) { retval.append( " " ).append( XMLHandler.addTagValue( "step" + i, inputStepsNames[ i ] ) ); } retval.append( " " ).append( XMLHandler.addTagValue( "number_input", inputStepsNames.length ) ); retval.append( " " ).append( XMLHandler.openTag( "keys" ) ).append( Const.CR ); for ( int i = 0; i < keyFields.length; i++ ) { retval.append( " " ).append( XMLHandler.addTagValue( "key", keyFields[i] ) ); } retval.append( " " ).append( XMLHandler.closeTag( "keys" ) ).append( Const.CR ); return retval.toString(); } MultiMergeJoinMeta(); String getJoinType(); void setJoinType( String joinType ); String[] getKeyFields(); void setKeyFields( String[] keyFields ); @Override boolean excludeFromRowLayoutVerification(); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void allocateKeys( int nrKeys ); @Override Object clone(); @Override String getXML(); @Override void setDefault(); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void searchInfoAndTargetSteps( List<StepMeta> steps ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); @Override void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
IMetaStore metaStore ); @Override void getFields( RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); @Override StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr,
Trans trans ); @Override StepDataInterface getStepData(); @Override void resetStepIoMeta(); void setInputSteps( String[] inputSteps ); String[] getInputSteps(); void allocateInputSteps( int count ); static final String[] join_types; static final boolean[] optionals; }
|
@Test public void testGetXml() { String[] inputSteps = new String[] { "Step1", "Step2" }; multiMergeMeta.setInputSteps( inputSteps ); multiMergeMeta.setKeyFields( new String[] {"Key1", "Key2"} ); String xml = multiMergeMeta.getXML(); Assert.assertTrue( xml.contains( "step0" ) ); Assert.assertTrue( xml.contains( "step1" ) ); }
|
MultiMergeJoinMeta extends BaseStepMeta implements StepMetaInterface { @Override public Object clone() { MultiMergeJoinMeta retval = (MultiMergeJoinMeta) super.clone(); int nrKeys = keyFields == null ? 0 : keyFields.length; int nrSteps = inputSteps == null ? 0 : inputSteps.length; retval.allocateKeys( nrKeys ); retval.allocateInputSteps( nrSteps ); System.arraycopy( keyFields, 0, retval.keyFields, 0, nrKeys ); System.arraycopy( inputSteps, 0, retval.inputSteps, 0, nrSteps ); return retval; } MultiMergeJoinMeta(); String getJoinType(); void setJoinType( String joinType ); String[] getKeyFields(); void setKeyFields( String[] keyFields ); @Override boolean excludeFromRowLayoutVerification(); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void allocateKeys( int nrKeys ); @Override Object clone(); @Override String getXML(); @Override void setDefault(); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void searchInfoAndTargetSteps( List<StepMeta> steps ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); @Override void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
IMetaStore metaStore ); @Override void getFields( RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); @Override StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr,
Trans trans ); @Override StepDataInterface getStepData(); @Override void resetStepIoMeta(); void setInputSteps( String[] inputSteps ); String[] getInputSteps(); void allocateInputSteps( int count ); static final String[] join_types; static final boolean[] optionals; }
|
@Test public void cloneTest() throws Exception { MultiMergeJoinMeta meta = new MultiMergeJoinMeta(); meta.allocateKeys( 2 ); meta.allocateInputSteps( 3 ); meta.setKeyFields( new String[] { "key1", "key2" } ); meta.setInputSteps( new String[] { "step1", "step2", "step3" } ); meta.setJoinType( "INNER" ); MultiMergeJoinMeta aClone = (MultiMergeJoinMeta) meta.clone(); Assert.assertFalse( aClone == meta ); Assert.assertTrue( Arrays.equals( meta.getKeyFields(), aClone.getKeyFields() ) ); Assert.assertTrue( Arrays.equals( meta.getInputSteps(), aClone.getInputSteps() ) ); Assert.assertEquals( meta.getJoinType(), aClone.getJoinType() ); }
|
ConcatFields extends TextFileOutput implements StepInterface { Object[] prepareOutputRow( Object[] r ) { Object[] outputRowData = null; if ( !meta.isRemoveSelectedFields() ) { outputRowData = RowDataUtil.resizeArray( r, data.outputRowMeta.size() ); } else { outputRowData = new Object[data.outputRowMeta.size() + RowDataUtil.OVER_ALLOCATE_SIZE]; if ( r != null ) { for ( int i = 0; i < data.remainingFieldsInputOutputMapping.length; i++ ) { outputRowData[i] = r[data.remainingFieldsInputOutputMapping[i]]; } } } return outputRowData; } ConcatFields( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); @Override synchronized boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); @Override boolean init( StepMetaInterface smi, StepDataInterface sdi ); @Override void dispose( StepMetaInterface smi, StepDataInterface sdi ); public ConcatFieldsMeta meta; public ConcatFieldsData data; }
|
@Test public void testPrepareOutputRow() throws Exception { ConcatFieldsHandler concatFields = new ConcatFieldsHandler( stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans ); Object[] row = new Object[] { "one", "two" }; String[] fieldNames = new String[] { "one", "two" }; concatFields.setRow( row ); RowMetaInterface inputRowMeta = mock( RowMetaInterface.class ); when( inputRowMeta.clone() ).thenReturn( inputRowMeta ); when( inputRowMeta.size() ).thenReturn( 2 ); when( inputRowMeta.getFieldNames() ).thenReturn( fieldNames ); when( stepMockHelper.processRowsStepMetaInterface.getOutputFields() ).thenReturn( textFileFields ); when( stepMockHelper.processRowsStepMetaInterface.isFastDump() ).thenReturn( Boolean.TRUE ); when( stepMockHelper.processRowsStepMetaInterface.isFileAppended() ).thenReturn( Boolean.FALSE ); when( stepMockHelper.processRowsStepMetaInterface.isFileNameInField() ).thenReturn( Boolean.FALSE ); when( stepMockHelper.processRowsStepMetaInterface.isHeaderEnabled() ).thenReturn( Boolean.TRUE ); when( stepMockHelper.processRowsStepMetaInterface.isRemoveSelectedFields() ).thenReturn( Boolean.TRUE ); concatFields.setInputRowMeta( inputRowMeta ); try { concatFields.processRow( stepMockHelper.processRowsStepMetaInterface, stepMockHelper.processRowsStepDataInterface ); concatFields.prepareOutputRow( row ); } catch ( NullPointerException npe ) { fail( "NullPointerException issue PDI-8870 still reproduced " ); } }
|
DataHandler extends AbstractXulEventHandler { protected void showMessage( String message, boolean scroll ) { try { XulMessageBox box = (XulMessageBox) document.createElement( "messagebox" ); box.setMessage( message ); box.setModalParent( ( (XulRoot) document.getElementById( "general-datasource-window" ) ).getRootObject() ); if ( scroll ) { box.setScrollable( true ); box.setWidth( 500 ); box.setHeight( 400 ); } box.open(); } catch ( XulException e ) { System.out.println( "Error creating messagebox " + e.getMessage() ); } } DataHandler(); void loadConnectionData(); void loadAccessData(); void editOptions( int index ); void clearOptionsData(); void getOptionHelp(); void setDeckChildIndex(); void onPoolingCheck(); void onClusterCheck(); Object getData(); void setData( Object data ); void pushCache(); void popCache(); void onCancel(); void onOK(); void testDatabaseConnection(); void restoreDefaults(); void poolingRowChange( int idx ); void disablePortIfInstancePopulated(); void handleUseSecurityCheckbox(); static final SortedMap<String, DatabaseInterface> connectionMap; static final Map<String, String> connectionNametoID; }
|
@Test public void testShowMessage() throws Exception { dataHandler.showMessage( "MyMessage", false ); dataHandler.showMessage( "MyMessage", true ); when( document.createElement( "messagebox" ) ).thenThrow( new XulException() ); dataHandler.showMessage( "MyMessage", false ); }
|
ExcelWriterStep extends BaseStep implements StepInterface { protected void protectSheet( Sheet sheet, String password ) { if ( sheet instanceof HSSFSheet ) { sheet.protectSheet( password ); } } ExcelWriterStep( StepMeta s, StepDataInterface stepDataInterface, int c, TransMeta t, Trans dis ); @Override boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); void writeNextLine( Object[] r ); String buildFilename( int splitNr ); static void copyFile( FileObject in, FileObject out ); void prepareNextOutputFile(); @Override boolean init( StepMetaInterface smi, StepDataInterface sdi ); @Override void dispose( StepMetaInterface smi, StepDataInterface sdi ); static final String STREAMER_FORCE_RECALC_PROP_NAME; }
|
@Test public void testProtectSheet() throws Exception { step.protectSheet( wb.getSheet( SHEET_NAME ), "aa" ); assertTrue( wb.getSheet( SHEET_NAME ).getProtect() ); }
|
StreamLookupMeta extends BaseStepMeta implements StepMetaInterface { @Override public String getXML() { StringBuilder retval = new StringBuilder(); StreamInterface infoStream = getStepIOMeta().getInfoStreams().get( 0 ); retval.append( " " ).append( XMLHandler.addTagValue( "from", infoStream.getStepname() ) ); retval.append( " " ).append( XMLHandler.addTagValue( "input_sorted", isInputSorted() ) ); retval.append( " " ).append( XMLHandler.addTagValue( "preserve_memory", isMemoryPreservationActive() ) ); retval.append( " " ).append( XMLHandler.addTagValue( "sorted_list", isUsingSortedList() ) ); retval.append( " " ).append( XMLHandler.addTagValue( "integer_pair", isUsingIntegerPair() ) ); retval.append( " <lookup>" ).append( Const.CR ); for ( int i = 0; i < getKeystream().length; i++ ) { retval.append( " <key>" ).append( Const.CR ); retval.append( " " ).append( XMLHandler.addTagValue( "name", getKeystream()[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "field", getKeylookup()[i] ) ); retval.append( " </key>" ).append( Const.CR ); } for ( int i = 0; i < getValue().length; i++ ) { retval.append( " <value>" ).append( Const.CR ); retval.append( " " ).append( XMLHandler.addTagValue( "name", getValue()[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "rename", getValueName()[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "default", getValueDefault()[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "type", ValueMetaFactory.getValueMetaName( getValueDefaultType()[i] ) ) ); retval.append( " </value>" ).append( Const.CR ); } retval.append( " </lookup>" ).append( Const.CR ); return retval.toString(); } StreamLookupMeta(); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void allocate( int nrkeys, int nrvalues ); @Override Object clone(); @Override void searchInfoAndTargetSteps( List<StepMeta> steps ); @Override void setDefault(); @Override void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); @Override String getXML(); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); @Override void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); @Override StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ); @Override StepDataInterface getStepData(); @Override boolean excludeFromRowLayoutVerification(); @Override StepIOMetaInterface getStepIOMeta(); @Override void resetStepIoMeta(); boolean isInputSorted(); void setInputSorted( boolean inputSorted ); String[] getKeylookup(); void setKeylookup( String[] keylookup ); String[] getKeystream(); void setKeystream( String[] keystream ); String[] getValue(); void setValue( String[] value ); String[] getValueDefault(); void setValueDefault( String[] valueDefault ); int[] getValueDefaultType(); void setValueDefaultType( int[] valueDefaultType ); String[] getValueName(); void setValueName( String[] valueName ); boolean isMemoryPreservationActive(); void setMemoryPreservationActive( boolean memoryPreservationActive ); boolean isUsingSortedList(); void setUsingSortedList( boolean usingSortedList ); boolean isUsingIntegerPair(); void setUsingIntegerPair( boolean usingIntegerPair ); @AfterInjection void afterInjectionSynchronization(); }
|
@Test public void testGetXML() { StreamLookupMeta streamLookupMeta = new StreamLookupMeta(); streamLookupMeta.setKeystream( new String[] { "testKeyStreamValue" } ); streamLookupMeta.setKeylookup( new String[] { "testKeyLookupValue" } ); streamLookupMeta.setValue( new String[] { "testValue" } ); streamLookupMeta.setValueName( new String[] {} ); streamLookupMeta.setValueDefault( new String[] {} ); streamLookupMeta.setValueDefaultType( new int[] {} ); streamLookupMeta.afterInjectionSynchronization(); streamLookupMeta.getXML(); Assert.assertEquals( streamLookupMeta.getKeystream().length, streamLookupMeta.getValueName().length ); Assert.assertEquals( streamLookupMeta.getKeystream().length, streamLookupMeta.getValueDefault().length ); Assert.assertEquals( streamLookupMeta.getKeystream().length, streamLookupMeta.getValueDefaultType().length ); }
|
LdapProtocolFactory { public LdapProtocol createLdapProtocol( VariableSpace variableSpace, LdapMeta meta, Collection<String> binaryAttributes ) throws KettleException { String connectionType = variableSpace.environmentSubstitute( meta.getProtocol() ); synchronized ( protocols ) { for ( Class<? extends LdapProtocol> protocol : protocols ) { if ( getName( protocol ).equals( connectionType ) ) { try { return protocol.getConstructor( LogChannelInterface.class, VariableSpace.class, LdapMeta.class, Collection.class ).newInstance( log, variableSpace, meta, binaryAttributes ); } catch ( Exception e ) { throw new KettleException( e ); } } } } return null; } LdapProtocolFactory( LogChannelInterface log ); static final List<String> getConnectionTypes( LogChannelInterface log ); LdapProtocol createLdapProtocol( VariableSpace variableSpace, LdapMeta meta,
Collection<String> binaryAttributes ); }
|
@Test public void createLdapProtocol() throws Exception { String ldapVariable = "${ldap_protocol_variable}"; String ldap = "LDAP"; String host = "localhost"; LdapProtocolFactory ldapProtocolFactory = new LdapProtocolFactory( Mockito.mock( LogChannelInterface.class ) ); VariableSpace variableSpace = Mockito.mock( VariableSpace.class ); LdapMeta meta = Mockito.mock( LdapMeta.class ); Mockito.doReturn( ldapVariable ).when( meta ).getProtocol(); Mockito.doReturn( ldap ).when( variableSpace ).environmentSubstitute( ldapVariable ); Mockito.doReturn( host ).when( meta ).getHost(); Mockito.doReturn( host ).when( variableSpace ).environmentSubstitute( host ); ldapProtocolFactory.createLdapProtocol( variableSpace, meta, Collections.emptyList() ); Mockito.verify( variableSpace, Mockito.times( 1 ) ).environmentSubstitute( ldapVariable ); }
|
LDAPInput extends BaseStep implements StepInterface { public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { meta = (LDAPInputMeta) smi; data = (LDAPInputData) sdi; if ( super.init( smi, sdi ) ) { data.rownr = 1L; data.multi_valuedFieldSeparator = environmentSubstitute( meta.getMultiValuedSeparator() ); data.nrfields = meta.getInputFields().length; data.staticFilter = environmentSubstitute( meta.getFilterString() ); data.staticSearchBase = environmentSubstitute( meta.getSearchBase() ); data.dynamic = ( meta.isDynamicSearch() || meta.isDynamicFilter() ); try { connectServerLdap(); return true; } catch ( Exception e ) { logError( BaseMessages.getString( PKG, "LDAPInput.ErrorInit", e.toString() ) ); stopAll(); setErrors( 1 ); } } return false; } LDAPInput( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
|
@Test public void testRowProcessing() throws Exception { LDAPInput ldapInput = new LDAPInput( stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans ); LDAPInputData data = new LDAPInputData(); LDAPInputMeta meta = mockMeta(); LDAPInputField[] fields = new LDAPInputField[] { new LDAPInputField( "dn" ), new LDAPInputField( "cn" ), new LDAPInputField( "role" ) }; int sortedField = 1; fields[sortedField].setSortedKey( true ); when( meta.getInputFields() ).thenReturn( fields ); when( meta.getProtocol() ).thenReturn( LdapMockProtocol.getName() ); when( meta.getHost() ).thenReturn( "host.mock" ); when( meta.getDerefAliases() ).thenReturn( "never" ); when( meta.getReferrals() ).thenReturn( "ignore" ); LdapMockProtocol.setup(); try { assertTrue( "Input Initialization Failed", ldapInput.init( meta, data ) ); assertEquals( "Field not marked as sorted", 1, data.connection.getSortingAttributes().size() ); assertEquals( "Field not marked as sorted", data.attrReturned[sortedField], data.connection.getSortingAttributes().get( 0 ) ); assertNotNull( data.attrReturned[sortedField] ); } finally { LdapMockProtocol.cleanup(); } }
|
CsvInputData extends BaseStepData implements StepDataInterface { byte[] removeEscapedEnclosures( byte[] field, int nrEnclosuresFound ) { byte[] result = new byte[field.length - nrEnclosuresFound]; int resultIndex = 0; for ( int i = 0; i < field.length; i++ ) { result[resultIndex++] = field[i]; if ( field[i] == enclosure[0] && i + 1 < field.length && field[i + 1] == enclosure[0] ) { i++; } } return result; } CsvInputData(); public FileChannel fc; public ByteBuffer bb; public RowMetaInterface convertRowMeta; public RowMetaInterface outputRowMeta; public byte[] delimiter; public byte[] enclosure; public int preferredBufferSize; public String[] filenames; public int filenr; public int startFilenr; public byte[] binaryFilename; public FileInputStream fis; public boolean isAddingRowNumber; public long rowNumber; public boolean stopReading; public int stepNumber; public int totalNumberOfSteps; public List<Long> fileSizes; public long totalFileSize; public long blockToRead; public long startPosition; public long endPosition; public long bytesToSkipInFirstFile; public long totalBytesRead; public boolean parallel; public int filenameFieldIndex; public int rownumFieldIndex; public EncodingType encodingType; public PatternMatcherInterface delimiterMatcher; public PatternMatcherInterface enclosureMatcher; public CrLfMatcherInterface crLfMatcher; public FieldsMapping fieldsMapping; }
|
@Test public void testRemoveEscapedEnclosuresWithOneEscapedInMiddle() { CsvInputData csvInputData = new CsvInputData(); csvInputData.enclosure = "\"".getBytes(); String result = new String( csvInputData.removeEscapedEnclosures( "abcd \"\" defg".getBytes(), 1 ) ); assertEquals( "abcd \" defg", result ); }
@Test public void testRemoveEscapedEnclosuresWithTwoEscapedInMiddle() { CsvInputData csvInputData = new CsvInputData(); csvInputData.enclosure = "\"".getBytes(); String result = new String( csvInputData.removeEscapedEnclosures( "abcd \"\"\"\" defg".getBytes(), 2 ) ); assertEquals( "abcd \"\" defg", result ); }
@Test public void testRemoveEscapedEnclosuresWithOneByItself() { CsvInputData csvInputData = new CsvInputData(); csvInputData.enclosure = "\"".getBytes(); String result = new String( csvInputData.removeEscapedEnclosures( "\"\"".getBytes(), 1 ) ); assertEquals( "\"", result ); }
@Test public void testRemoveEscapedEnclosuresWithTwoByThemselves() { CsvInputData csvInputData = new CsvInputData(); csvInputData.enclosure = "\"".getBytes(); String result = new String( csvInputData.removeEscapedEnclosures( "\"\"\"\"".getBytes(), 2 ) ); assertEquals( "\"\"", result ); }
@Test public void testRemoveEscapedEnclosuresWithCharacterInTheMiddleOfThem() { CsvInputData csvInputData = new CsvInputData(); csvInputData.enclosure = "\"".getBytes(); String result = new String( csvInputData.removeEscapedEnclosures( "345\"\"1\"\"abc".getBytes(), 2 ) ); assertEquals( "345\"1\"abc", result ); }
|
NamedFieldsMapping implements FieldsMapping { @Override public int fieldMetaIndex( int index ) { if ( index >= size() || index < 0 ) { return FIELD_DOES_NOT_EXIST; } return actualToMetaFieldMapping[index]; } NamedFieldsMapping( int[] actualToMetaFieldMapping ); @Override int fieldMetaIndex( int index ); @Override int size(); static NamedFieldsMapping mapping( String[] actualFieldNames, String[] metaFieldNames ); }
|
@Test public void fieldMetaIndex() { assertEquals( 3, fieldsMapping.fieldMetaIndex( 0 ) ); }
@Test public void fieldMetaIndexWithUnexistingField() { assertEquals( FieldsMapping.FIELD_DOES_NOT_EXIST, fieldsMapping.fieldMetaIndex( 4 ) ); }
|
DataHandler extends AbstractXulEventHandler { public void handleUseSecurityCheckbox() { if ( useIntegratedSecurityCheck != null ) { if ( useIntegratedSecurityCheck.isChecked() ) { userNameBox.setDisabled( true ); passwordBox.setDisabled( true ); } else { userNameBox.setDisabled( false ); passwordBox.setDisabled( false ); } } } DataHandler(); void loadConnectionData(); void loadAccessData(); void editOptions( int index ); void clearOptionsData(); void getOptionHelp(); void setDeckChildIndex(); void onPoolingCheck(); void onClusterCheck(); Object getData(); void setData( Object data ); void pushCache(); void popCache(); void onCancel(); void onOK(); void testDatabaseConnection(); void restoreDefaults(); void poolingRowChange( int idx ); void disablePortIfInstancePopulated(); void handleUseSecurityCheckbox(); static final SortedMap<String, DatabaseInterface> connectionMap; static final Map<String, String> connectionNametoID; }
|
@Test public void testHandleUseSecurityCheckbox() throws Exception { dataHandler.handleUseSecurityCheckbox(); XulCheckbox useIntegratedSecurityCheck = mock( XulCheckbox.class ); when( useIntegratedSecurityCheck.isChecked() ).thenReturn( false ); when( document.getElementById( "use-integrated-security-check" ) ).thenReturn( useIntegratedSecurityCheck ); dataHandler.getControls(); dataHandler.handleUseSecurityCheckbox(); when( useIntegratedSecurityCheck.isChecked() ).thenReturn( true ); dataHandler.handleUseSecurityCheckbox(); }
|
NamedFieldsMapping implements FieldsMapping { @Override public int size() { return actualToMetaFieldMapping.length; } NamedFieldsMapping( int[] actualToMetaFieldMapping ); @Override int fieldMetaIndex( int index ); @Override int size(); static NamedFieldsMapping mapping( String[] actualFieldNames, String[] metaFieldNames ); }
|
@Test public void size() { assertEquals( 2, fieldsMapping.size() ); }
|
NamedFieldsMapping implements FieldsMapping { public static NamedFieldsMapping mapping( String[] actualFieldNames, String[] metaFieldNames ) { LinkedHashMap<String, List<Integer>> metaNameToIndex = new LinkedHashMap<>(); List<Integer> unmatchedMetaFields = new ArrayList<>(); int[] actualToMetaFieldMapping = new int[actualFieldNames.length]; for ( int i = 0; i < metaFieldNames.length; i++ ) { List<Integer> coll = metaNameToIndex.getOrDefault( metaFieldNames[i], new ArrayList<>() ); coll.add( i ); metaNameToIndex.put( metaFieldNames[i], coll ); } for ( int i = 0; i < actualFieldNames.length; i++ ) { List<Integer> columnIndexes = metaNameToIndex.get( actualFieldNames[i] ); if ( columnIndexes == null || columnIndexes.isEmpty() ) { unmatchedMetaFields.add( i ); actualToMetaFieldMapping[i] = FIELD_DOES_NOT_EXIST; continue; } actualToMetaFieldMapping[i] = columnIndexes.remove( 0 ); } Iterator<Integer> remainingMetaIndexes = metaNameToIndex.values().stream() .flatMap( List::stream ) .sorted() .iterator(); for ( int idx : unmatchedMetaFields ) { if ( !remainingMetaIndexes.hasNext() ) { break; } actualToMetaFieldMapping[ idx ] = remainingMetaIndexes.next(); } return new NamedFieldsMapping( actualToMetaFieldMapping ); } NamedFieldsMapping( int[] actualToMetaFieldMapping ); @Override int fieldMetaIndex( int index ); @Override int size(); static NamedFieldsMapping mapping( String[] actualFieldNames, String[] metaFieldNames ); }
|
@Test public void mapping() { NamedFieldsMapping mapping = NamedFieldsMapping.mapping( new String[] { "FIRST", "SECOND", "THIRD" }, new String[] { "SECOND", "THIRD" } ); assertEquals( 0, mapping.fieldMetaIndex( 1 ) ); }
|
UnnamedFieldsMapping implements FieldsMapping { @Override public int fieldMetaIndex( int index ) { return ( index >= fieldsCount || index < 0 ) ? FieldsMapping.FIELD_DOES_NOT_EXIST : index; } UnnamedFieldsMapping( int fieldsCount ); @Override int fieldMetaIndex( int index ); @Override int size(); static UnnamedFieldsMapping mapping( int fieldsCount ); }
|
@Test public void fieldMetaIndex() { assertEquals( 1, fieldsMapping.fieldMetaIndex( 1 ) ); }
@Test public void fieldMetaIndexWithUnexistingField() { assertEquals( FieldsMapping.FIELD_DOES_NOT_EXIST, fieldsMapping.fieldMetaIndex( 2 ) ); }
|
UnnamedFieldsMapping implements FieldsMapping { @Override public int size() { return fieldsCount; } UnnamedFieldsMapping( int fieldsCount ); @Override int fieldMetaIndex( int index ); @Override int size(); static UnnamedFieldsMapping mapping( int fieldsCount ); }
|
@Test public void size() { assertEquals( 2, fieldsMapping.size() ); }
|
UnnamedFieldsMapping implements FieldsMapping { public static UnnamedFieldsMapping mapping( int fieldsCount ) { return new UnnamedFieldsMapping( fieldsCount ); } UnnamedFieldsMapping( int fieldsCount ); @Override int fieldMetaIndex( int index ); @Override int size(); static UnnamedFieldsMapping mapping( int fieldsCount ); }
|
@Test public void mapping() { UnnamedFieldsMapping mapping = UnnamedFieldsMapping.mapping( 2 ); assertEquals( 1, mapping.fieldMetaIndex( 1 ) ); }
|
CreditCardVerifier { public static boolean isNumber( String n ) { try { Double.valueOf( n ).doubleValue(); return true; } catch ( NumberFormatException e ) { return false; } } static String getCardName( int id ); static String getNotValidCardNames( int id ); static ReturnIndicator CheckCC( String CardNumber ); static boolean luhnValidate( String numberString ); static int getCardID( String number ); static boolean isNumber( String n ); static final int INVALID; static final int VISA; static final int MASTERCARD; static final int AMERICAN_EXPRESS; static final int EN_ROUTE; static final int DINERS_CLUB; static final int DISCOVER; static final int JCB1; static final int JCB2; static final int BANKCARD; static final int MAESTRO; static final int SOLO; static final int SWITCH; static final int AIRPLUS; static final int LASER; static final int VOYAGER; }
|
@Test public void testIsNumber() { assertFalse( CreditCardVerifier.isNumber( "" ) ); assertFalse( CreditCardVerifier.isNumber( "a" ) ); assertTrue( CreditCardVerifier.isNumber( "1" ) ); assertTrue( CreditCardVerifier.isNumber( "1.01" ) ); }
|
CreditCardValidatorMeta extends BaseStepMeta implements StepMetaInterface { public boolean supportsErrorHandling() { return true; } CreditCardValidatorMeta(); String getDynamicField(); void setDynamicField( String fieldname ); String getResultFieldName(); void setOnlyDigits( boolean onlydigits ); boolean isOnlyDigits(); void setResultFieldName( String resultfieldname ); void setCardType( String cardtype ); String getCardType(); void setNotValidMsg( String notvalidmsg ); String getNotValidMsg(); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); Object clone(); void setDefault(); void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); String getXML(); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ); StepDataInterface getStepData(); boolean supportsErrorHandling(); }
|
@Test public void testSupportsErrorHandling() { assertTrue( new CreditCardValidatorMeta().supportsErrorHandling() ); }
|
CreditCardValidatorMeta extends BaseStepMeta implements StepMetaInterface { public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { String realresultfieldname = space.environmentSubstitute( resultfieldname ); if ( !Utils.isEmpty( realresultfieldname ) ) { ValueMetaInterface v = new ValueMetaBoolean( realresultfieldname ); v.setOrigin( name ); inputRowMeta.addValueMeta( v ); } String realcardtype = space.environmentSubstitute( cardtype ); if ( !Utils.isEmpty( realcardtype ) ) { ValueMetaInterface v = new ValueMetaString( realcardtype ); v.setOrigin( name ); inputRowMeta.addValueMeta( v ); } String realnotvalidmsg = space.environmentSubstitute( notvalidmsg ); if ( !Utils.isEmpty( notvalidmsg ) ) { ValueMetaInterface v = new ValueMetaString( realnotvalidmsg ); v.setOrigin( name ); inputRowMeta.addValueMeta( v ); } } CreditCardValidatorMeta(); String getDynamicField(); void setDynamicField( String fieldname ); String getResultFieldName(); void setOnlyDigits( boolean onlydigits ); boolean isOnlyDigits(); void setResultFieldName( String resultfieldname ); void setCardType( String cardtype ); String getCardType(); void setNotValidMsg( String notvalidmsg ); String getNotValidMsg(); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); Object clone(); void setDefault(); void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); String getXML(); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ); StepDataInterface getStepData(); boolean supportsErrorHandling(); }
|
@Test public void testGetFields() throws KettleStepException { CreditCardValidatorMeta meta = new CreditCardValidatorMeta(); meta.setDefault(); meta.setResultFieldName( "The Result Field" ); meta.setCardType( "The Card Type Field" ); meta.setNotValidMsg( "Is Card Valid" ); RowMeta rowMeta = new RowMeta(); meta.getFields( rowMeta, "this step", null, null, new Variables(), null, null ); assertEquals( 3, rowMeta.size() ); assertEquals( "The Result Field", rowMeta.getValueMeta( 0 ).getName() ); assertEquals( ValueMetaInterface.TYPE_BOOLEAN, rowMeta.getValueMeta( 0 ).getType() ); assertEquals( "this step", rowMeta.getValueMeta( 0 ).getOrigin() ); assertEquals( "The Card Type Field", rowMeta.getValueMeta( 1 ).getName() ); assertEquals( ValueMetaInterface.TYPE_STRING, rowMeta.getValueMeta( 1 ).getType() ); assertEquals( "this step", rowMeta.getValueMeta( 1 ).getOrigin() ); assertEquals( "Is Card Valid", rowMeta.getValueMeta( 2 ).getName() ); assertEquals( ValueMetaInterface.TYPE_STRING, rowMeta.getValueMeta( 2 ).getType() ); assertEquals( "this step", rowMeta.getValueMeta( 2 ).getOrigin() ); }
|
FragmentHandler extends AbstractXulEventHandler { public void refreshOptions() { connectionBox = (XulListbox) document.getElementById( "connection-type-list" ); accessBox = (XulListbox) document.getElementById( "access-type-list" ); Object connectionKey = DataHandler.connectionNametoID.get( connectionBox.getSelectedItem() ); String databaseName = null; try { databaseName = PluginRegistry.getInstance().getPlugin( DatabasePluginType.class, "" + connectionKey ).getIds()[0]; } catch ( Exception e ) { e.printStackTrace(); } DatabaseInterface database = DataHandler.connectionMap.get( connectionBox.getSelectedItem() ); Object accessKey = accessBox.getSelectedItem(); int access = DatabaseMeta.getAccessType( (String) accessKey ); String fragment = null; DataHandler dataHandler = null; try { dataHandler = (DataHandler) xulDomContainer.getEventHandler( "dataHandler" ); dataHandler.pushCache(); } catch ( XulException e ) { } switch ( access ) { case DatabaseMeta.TYPE_ACCESS_JNDI: fragment = getFragment( database, databaseName, "_jndi.xul", "common_jndi.xul" ); break; case DatabaseMeta.TYPE_ACCESS_NATIVE: fragment = getFragment( database, databaseName, "_native.xul", "common_native.xul" ); break; case DatabaseMeta.TYPE_ACCESS_OCI: fragment = getFragment( database, databaseName, "_oci.xul", "common_native.xul" ); break; case DatabaseMeta.TYPE_ACCESS_ODBC: fragment = getFragment( database, databaseName, "_odbc.xul", "common_odbc.xul" ); break; case DatabaseMeta.TYPE_ACCESS_PLUGIN: fragment = getFragment( database, databaseName, "_plugin.xul", "common_native.xul" ); break; default: break; } try { loadDatabaseOptionsFragment( fragment.toLowerCase() ); } catch ( XulException e ) { showMessage( Messages.getString( "FragmentHandler.USER.CANT_LOAD_OPTIONS", databaseName ) ); } XulTextbox portBox = (XulTextbox) document.getElementById( "port-number-text" ); if ( portBox != null ) { int port = database.getDefaultDatabasePort(); if ( port > 0 ) { portBox.setValue( Integer.toString( port ) ); } } if ( dataHandler != null ) { dataHandler.popCache(); } } FragmentHandler(); void refreshOptions(); Object getData(); void setData( Object arg0 ); }
|
@Test public void testRefreshOptions() throws Exception { XulListbox connectionBox = mock( XulListbox.class ); when( document.getElementById( "connection-type-list" ) ).thenReturn( connectionBox ); when( connectionBox.getSelectedItem() ).thenReturn( "myDb" ); XulListbox accessBox = mock( XulListbox.class ); when( document.getElementById( "access-type-list" ) ).thenReturn( accessBox ); when( accessBox.getSelectedItem() ).thenReturn( "Native" ); DataHandler dataHandler = mock( DataHandler.class ); when( xulDomContainer.getEventHandler( "dataHandler" ) ).thenReturn( dataHandler ); DatabaseInterface dbInterface = mock( DatabaseInterface.class ); when( dbInterface.getDefaultDatabasePort() ).thenReturn( 5309 ); DataHandler.connectionMap.put( "myDb", dbInterface ); XulComponent component = mock( XulComponent.class ); XulComponent parent = mock( XulComponent.class ); when( component.getParent() ).thenReturn( parent ); when( document.getElementById( "database-options-box" ) ).thenReturn( component ); XulDomContainer fragmentContainer = mock( XulDomContainer.class ); Document mockDoc = mock( Document.class ); XulComponent firstChild = mock( XulComponent.class ); when( mockDoc.getFirstChild() ).thenReturn( firstChild ); when( fragmentContainer.getDocumentRoot() ).thenReturn( mockDoc ); when( xulDomContainer.loadFragment( anyString(), any( Object.class ) ) ).thenReturn( fragmentContainer ); XulTextbox portBox = mock( XulTextbox.class ); when( document.getElementById( "port-number-text" ) ).thenReturn( portBox ); fragmentHandler.refreshOptions(); when( accessBox.getSelectedItem() ).thenReturn( "JNDI" ); fragmentHandler.refreshOptions(); when( accessBox.getSelectedItem() ).thenReturn( "ODBC" ); fragmentHandler.refreshOptions(); when( accessBox.getSelectedItem() ).thenReturn( "OCI" ); fragmentHandler.refreshOptions(); when( accessBox.getSelectedItem() ).thenReturn( "Plugin" ); fragmentHandler.refreshOptions(); }
|
TransExecutorMeta extends StepWithMappingMeta implements StepMetaInterface, HasRepositoryInterface { void prepareExecutionResultsFields( RowMetaInterface row, StepMeta nextStep ) throws KettleStepException { if ( nextStep != null && executionResultTargetStepMeta != null ) { addFieldToRow( row, executionTimeField, ValueMetaInterface.TYPE_INTEGER, 15, 0 ); addFieldToRow( row, executionResultField, ValueMetaInterface.TYPE_BOOLEAN ); addFieldToRow( row, executionNrErrorsField, ValueMetaInterface.TYPE_INTEGER, 9, 0 ); addFieldToRow( row, executionLinesReadField, ValueMetaInterface.TYPE_INTEGER, 9, 0 ); addFieldToRow( row, executionLinesWrittenField, ValueMetaInterface.TYPE_INTEGER, 9, 0 ); addFieldToRow( row, executionLinesInputField, ValueMetaInterface.TYPE_INTEGER, 9, 0 ); addFieldToRow( row, executionLinesOutputField, ValueMetaInterface.TYPE_INTEGER, 9, 0 ); addFieldToRow( row, executionLinesRejectedField, ValueMetaInterface.TYPE_INTEGER, 9, 0 ); addFieldToRow( row, executionLinesUpdatedField, ValueMetaInterface.TYPE_INTEGER, 9, 0 ); addFieldToRow( row, executionLinesDeletedField, ValueMetaInterface.TYPE_INTEGER, 9, 0 ); addFieldToRow( row, executionFilesRetrievedField, ValueMetaInterface.TYPE_INTEGER, 9, 0 ); addFieldToRow( row, executionExitStatusField, ValueMetaInterface.TYPE_INTEGER, 3, 0 ); addFieldToRow( row, executionLogTextField, ValueMetaInterface.TYPE_STRING ); addFieldToRow( row, executionLogChannelIdField, ValueMetaInterface.TYPE_STRING, 50, 0 ); } } TransExecutorMeta(); void allocate( int nrFields ); Object clone(); String getXML(); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void setDefault(); @Override void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); String[] getInfoSteps(); @Deprecated static synchronized TransMeta loadTransMeta( TransExecutorMeta executorMeta, Repository rep,
VariableSpace space ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepinfo, RowMetaInterface prev,
String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr,
Trans trans ); @Override List<ResourceReference> getResourceDependencies( TransMeta transMeta, StepMeta stepInfo ); @Override String exportResources( VariableSpace space, Map<String, ResourceDefinition> definitions,
ResourceNamingInterface resourceNamingInterface, Repository repository, IMetaStore metaStore ); StepDataInterface getStepData(); @Override StepIOMetaInterface getStepIOMeta(); void handleStreamSelection( StreamInterface stream ); void resetStepIoMeta(); @Override void searchInfoAndTargetSteps( List<StepMeta> steps ); TransformationType[] getSupportedTransformationTypes(); @Override boolean hasRepositoryReferences(); @Override void lookupRepositoryReferences( Repository repository ); TransExecutorParameters getMappingParameters(); void setMappingParameters( TransExecutorParameters mappingParameters ); Repository getRepository(); void setRepository( Repository repository ); TransExecutorParameters getParameters(); void setParameters( TransExecutorParameters parameters ); String getExecutionTimeField(); void setExecutionTimeField( String executionTimeField ); String getExecutionResultField(); void setExecutionResultField( String executionResultField ); String getExecutionNrErrorsField(); void setExecutionNrErrorsField( String executionNrErrorsField ); String getExecutionLinesReadField(); void setExecutionLinesReadField( String executionLinesReadField ); String getExecutionLinesWrittenField(); void setExecutionLinesWrittenField( String executionLinesWrittenField ); String getExecutionLinesInputField(); void setExecutionLinesInputField( String executionLinesInputField ); String getExecutionLinesOutputField(); void setExecutionLinesOutputField( String executionLinesOutputField ); String getExecutionLinesRejectedField(); void setExecutionLinesRejectedField( String executionLinesRejectedField ); String getExecutionLinesUpdatedField(); void setExecutionLinesUpdatedField( String executionLinesUpdatedField ); String getExecutionLinesDeletedField(); void setExecutionLinesDeletedField( String executionLinesDeletedField ); String getExecutionFilesRetrievedField(); void setExecutionFilesRetrievedField( String executionFilesRetrievedField ); String getExecutionExitStatusField(); void setExecutionExitStatusField( String executionExitStatusField ); String getExecutionLogTextField(); void setExecutionLogTextField( String executionLogTextField ); String getExecutionLogChannelIdField(); void setExecutionLogChannelIdField( String executionLogChannelIdField ); String getGroupSize(); void setGroupSize( String groupSize ); String getGroupField(); void setGroupField( String groupField ); String getGroupTime(); void setGroupTime( String groupTime ); @Override boolean excludeFromCopyDistributeVerification(); String getExecutionResultTargetStep(); void setExecutionResultTargetStep( String executionResultTargetStep ); StepMeta getExecutionResultTargetStepMeta(); void setExecutionResultTargetStepMeta( StepMeta executionResultTargetStepMeta ); String getResultFilesFileNameField(); void setResultFilesFileNameField( String resultFilesFileNameField ); String[] getReferencedObjectDescriptions(); boolean[] isReferencedObjectEnabled(); Object loadReferencedObject( int index, Repository rep, IMetaStore metaStore, VariableSpace space ); IMetaStore getMetaStore(); void setMetaStore( IMetaStore metaStore ); String getOutputRowsSourceStep(); void setOutputRowsSourceStep( String outputRowsSourceStep ); StepMeta getOutputRowsSourceStepMeta(); void setOutputRowsSourceStepMeta( StepMeta outputRowsSourceStepMeta ); String[] getOutputRowsField(); void setOutputRowsField( String[] outputRowsField ); int[] getOutputRowsType(); void setOutputRowsType( int[] outputRowsType ); int[] getOutputRowsLength(); void setOutputRowsLength( int[] outputRowsLength ); int[] getOutputRowsPrecision(); void setOutputRowsPrecision( int[] outputRowsPrecision ); String getResultFilesTargetStep(); void setResultFilesTargetStep( String resultFilesTargetStep ); StepMeta getResultFilesTargetStepMeta(); void setResultFilesTargetStepMeta( StepMeta resultFilesTargetStepMeta ); String getExecutorsOutputStep(); void setExecutorsOutputStep( String executorsOutputStep ); StepMeta getExecutorsOutputStepMeta(); void setExecutorsOutputStepMeta( StepMeta executorsOutputStepMeta ); @Override boolean cleanAfterHopFromRemove(); }
|
@Test public void testPrepareExecutionResultsFields() throws Exception { TransExecutorMeta meta = new TransExecutorMeta(); meta = spy( meta ); RowMetaInterface row = mock( RowMetaInterface.class ); StepMeta nextStep = mock( StepMeta.class ); meta.setExecutionResultTargetStepMeta( nextStep ); meta.setExecutionTimeField( "time" ); StepMeta parent = mock( StepMeta.class ); doReturn( parent ).when( meta ).getParentStepMeta(); when( parent.getName() ).thenReturn( "parent step" ); meta.prepareExecutionResultsFields( row, nextStep ); verify( parent ).getName(); ArgumentCaptor<ValueMetaInterface> argumentCaptor = ArgumentCaptor.forClass( ValueMetaInterface.class ); verify( row ).addValueMeta( argumentCaptor.capture() ); assertEquals( "parent step", argumentCaptor.getValue().getOrigin() ); }
|
TransExecutorMeta extends StepWithMappingMeta implements StepMetaInterface, HasRepositoryInterface { void prepareExecutionResultsFileFields( RowMetaInterface row, StepMeta nextStep ) throws KettleStepException { if ( nextStep != null && resultFilesTargetStepMeta != null && nextStep.equals( resultFilesTargetStepMeta ) ) { addFieldToRow( row, resultFilesFileNameField, ValueMetaInterface.TYPE_STRING ); } } TransExecutorMeta(); void allocate( int nrFields ); Object clone(); String getXML(); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void setDefault(); @Override void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); String[] getInfoSteps(); @Deprecated static synchronized TransMeta loadTransMeta( TransExecutorMeta executorMeta, Repository rep,
VariableSpace space ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepinfo, RowMetaInterface prev,
String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr,
Trans trans ); @Override List<ResourceReference> getResourceDependencies( TransMeta transMeta, StepMeta stepInfo ); @Override String exportResources( VariableSpace space, Map<String, ResourceDefinition> definitions,
ResourceNamingInterface resourceNamingInterface, Repository repository, IMetaStore metaStore ); StepDataInterface getStepData(); @Override StepIOMetaInterface getStepIOMeta(); void handleStreamSelection( StreamInterface stream ); void resetStepIoMeta(); @Override void searchInfoAndTargetSteps( List<StepMeta> steps ); TransformationType[] getSupportedTransformationTypes(); @Override boolean hasRepositoryReferences(); @Override void lookupRepositoryReferences( Repository repository ); TransExecutorParameters getMappingParameters(); void setMappingParameters( TransExecutorParameters mappingParameters ); Repository getRepository(); void setRepository( Repository repository ); TransExecutorParameters getParameters(); void setParameters( TransExecutorParameters parameters ); String getExecutionTimeField(); void setExecutionTimeField( String executionTimeField ); String getExecutionResultField(); void setExecutionResultField( String executionResultField ); String getExecutionNrErrorsField(); void setExecutionNrErrorsField( String executionNrErrorsField ); String getExecutionLinesReadField(); void setExecutionLinesReadField( String executionLinesReadField ); String getExecutionLinesWrittenField(); void setExecutionLinesWrittenField( String executionLinesWrittenField ); String getExecutionLinesInputField(); void setExecutionLinesInputField( String executionLinesInputField ); String getExecutionLinesOutputField(); void setExecutionLinesOutputField( String executionLinesOutputField ); String getExecutionLinesRejectedField(); void setExecutionLinesRejectedField( String executionLinesRejectedField ); String getExecutionLinesUpdatedField(); void setExecutionLinesUpdatedField( String executionLinesUpdatedField ); String getExecutionLinesDeletedField(); void setExecutionLinesDeletedField( String executionLinesDeletedField ); String getExecutionFilesRetrievedField(); void setExecutionFilesRetrievedField( String executionFilesRetrievedField ); String getExecutionExitStatusField(); void setExecutionExitStatusField( String executionExitStatusField ); String getExecutionLogTextField(); void setExecutionLogTextField( String executionLogTextField ); String getExecutionLogChannelIdField(); void setExecutionLogChannelIdField( String executionLogChannelIdField ); String getGroupSize(); void setGroupSize( String groupSize ); String getGroupField(); void setGroupField( String groupField ); String getGroupTime(); void setGroupTime( String groupTime ); @Override boolean excludeFromCopyDistributeVerification(); String getExecutionResultTargetStep(); void setExecutionResultTargetStep( String executionResultTargetStep ); StepMeta getExecutionResultTargetStepMeta(); void setExecutionResultTargetStepMeta( StepMeta executionResultTargetStepMeta ); String getResultFilesFileNameField(); void setResultFilesFileNameField( String resultFilesFileNameField ); String[] getReferencedObjectDescriptions(); boolean[] isReferencedObjectEnabled(); Object loadReferencedObject( int index, Repository rep, IMetaStore metaStore, VariableSpace space ); IMetaStore getMetaStore(); void setMetaStore( IMetaStore metaStore ); String getOutputRowsSourceStep(); void setOutputRowsSourceStep( String outputRowsSourceStep ); StepMeta getOutputRowsSourceStepMeta(); void setOutputRowsSourceStepMeta( StepMeta outputRowsSourceStepMeta ); String[] getOutputRowsField(); void setOutputRowsField( String[] outputRowsField ); int[] getOutputRowsType(); void setOutputRowsType( int[] outputRowsType ); int[] getOutputRowsLength(); void setOutputRowsLength( int[] outputRowsLength ); int[] getOutputRowsPrecision(); void setOutputRowsPrecision( int[] outputRowsPrecision ); String getResultFilesTargetStep(); void setResultFilesTargetStep( String resultFilesTargetStep ); StepMeta getResultFilesTargetStepMeta(); void setResultFilesTargetStepMeta( StepMeta resultFilesTargetStepMeta ); String getExecutorsOutputStep(); void setExecutorsOutputStep( String executorsOutputStep ); StepMeta getExecutorsOutputStepMeta(); void setExecutorsOutputStepMeta( StepMeta executorsOutputStepMeta ); @Override boolean cleanAfterHopFromRemove(); }
|
@Test public void testPrepareExecutionResultsFileFields() throws Exception { TransExecutorMeta meta = new TransExecutorMeta(); meta = spy( meta ); RowMetaInterface row = mock( RowMetaInterface.class ); StepMeta nextStep = mock( StepMeta.class ); meta.setResultFilesTargetStepMeta( nextStep ); meta.setResultFilesFileNameField( "file_name" ); StepMeta parent = mock( StepMeta.class ); doReturn( parent ).when( meta ).getParentStepMeta(); when( parent.getName() ).thenReturn( "parent step" ); meta.prepareExecutionResultsFileFields( row, nextStep ); verify( parent ).getName(); ArgumentCaptor<ValueMetaInterface> argumentCaptor = ArgumentCaptor.forClass( ValueMetaInterface.class ); verify( row ).addValueMeta( argumentCaptor.capture() ); assertEquals( "parent step", argumentCaptor.getValue().getOrigin() ); }
|
TransExecutorMeta extends StepWithMappingMeta implements StepMetaInterface, HasRepositoryInterface { void prepareResultsRowsFields( RowMetaInterface row ) throws KettleStepException { for ( int i = 0; i < outputRowsField.length; i++ ) { addFieldToRow( row, outputRowsField[i], outputRowsType[i], outputRowsLength[i], outputRowsPrecision[i] ); } } TransExecutorMeta(); void allocate( int nrFields ); Object clone(); String getXML(); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void setDefault(); @Override void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); String[] getInfoSteps(); @Deprecated static synchronized TransMeta loadTransMeta( TransExecutorMeta executorMeta, Repository rep,
VariableSpace space ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepinfo, RowMetaInterface prev,
String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr,
Trans trans ); @Override List<ResourceReference> getResourceDependencies( TransMeta transMeta, StepMeta stepInfo ); @Override String exportResources( VariableSpace space, Map<String, ResourceDefinition> definitions,
ResourceNamingInterface resourceNamingInterface, Repository repository, IMetaStore metaStore ); StepDataInterface getStepData(); @Override StepIOMetaInterface getStepIOMeta(); void handleStreamSelection( StreamInterface stream ); void resetStepIoMeta(); @Override void searchInfoAndTargetSteps( List<StepMeta> steps ); TransformationType[] getSupportedTransformationTypes(); @Override boolean hasRepositoryReferences(); @Override void lookupRepositoryReferences( Repository repository ); TransExecutorParameters getMappingParameters(); void setMappingParameters( TransExecutorParameters mappingParameters ); Repository getRepository(); void setRepository( Repository repository ); TransExecutorParameters getParameters(); void setParameters( TransExecutorParameters parameters ); String getExecutionTimeField(); void setExecutionTimeField( String executionTimeField ); String getExecutionResultField(); void setExecutionResultField( String executionResultField ); String getExecutionNrErrorsField(); void setExecutionNrErrorsField( String executionNrErrorsField ); String getExecutionLinesReadField(); void setExecutionLinesReadField( String executionLinesReadField ); String getExecutionLinesWrittenField(); void setExecutionLinesWrittenField( String executionLinesWrittenField ); String getExecutionLinesInputField(); void setExecutionLinesInputField( String executionLinesInputField ); String getExecutionLinesOutputField(); void setExecutionLinesOutputField( String executionLinesOutputField ); String getExecutionLinesRejectedField(); void setExecutionLinesRejectedField( String executionLinesRejectedField ); String getExecutionLinesUpdatedField(); void setExecutionLinesUpdatedField( String executionLinesUpdatedField ); String getExecutionLinesDeletedField(); void setExecutionLinesDeletedField( String executionLinesDeletedField ); String getExecutionFilesRetrievedField(); void setExecutionFilesRetrievedField( String executionFilesRetrievedField ); String getExecutionExitStatusField(); void setExecutionExitStatusField( String executionExitStatusField ); String getExecutionLogTextField(); void setExecutionLogTextField( String executionLogTextField ); String getExecutionLogChannelIdField(); void setExecutionLogChannelIdField( String executionLogChannelIdField ); String getGroupSize(); void setGroupSize( String groupSize ); String getGroupField(); void setGroupField( String groupField ); String getGroupTime(); void setGroupTime( String groupTime ); @Override boolean excludeFromCopyDistributeVerification(); String getExecutionResultTargetStep(); void setExecutionResultTargetStep( String executionResultTargetStep ); StepMeta getExecutionResultTargetStepMeta(); void setExecutionResultTargetStepMeta( StepMeta executionResultTargetStepMeta ); String getResultFilesFileNameField(); void setResultFilesFileNameField( String resultFilesFileNameField ); String[] getReferencedObjectDescriptions(); boolean[] isReferencedObjectEnabled(); Object loadReferencedObject( int index, Repository rep, IMetaStore metaStore, VariableSpace space ); IMetaStore getMetaStore(); void setMetaStore( IMetaStore metaStore ); String getOutputRowsSourceStep(); void setOutputRowsSourceStep( String outputRowsSourceStep ); StepMeta getOutputRowsSourceStepMeta(); void setOutputRowsSourceStepMeta( StepMeta outputRowsSourceStepMeta ); String[] getOutputRowsField(); void setOutputRowsField( String[] outputRowsField ); int[] getOutputRowsType(); void setOutputRowsType( int[] outputRowsType ); int[] getOutputRowsLength(); void setOutputRowsLength( int[] outputRowsLength ); int[] getOutputRowsPrecision(); void setOutputRowsPrecision( int[] outputRowsPrecision ); String getResultFilesTargetStep(); void setResultFilesTargetStep( String resultFilesTargetStep ); StepMeta getResultFilesTargetStepMeta(); void setResultFilesTargetStepMeta( StepMeta resultFilesTargetStepMeta ); String getExecutorsOutputStep(); void setExecutorsOutputStep( String executorsOutputStep ); StepMeta getExecutorsOutputStepMeta(); void setExecutorsOutputStepMeta( StepMeta executorsOutputStepMeta ); @Override boolean cleanAfterHopFromRemove(); }
|
@Test public void testPrepareResultsRowsFields() throws Exception { TransExecutorMeta meta = new TransExecutorMeta(); String[] outputFieldNames = new String[]{ "one", "two" }; int[] outputFieldTypes = new int[]{ 0, 1 }; int[] outputFieldLength = new int[]{ 4, 8 }; int[] outputFieldPrecision = new int[]{ 2, 4 }; meta.setOutputRowsField( outputFieldNames ); meta.setOutputRowsType( outputFieldTypes ); meta.setOutputRowsLength( outputFieldLength ); meta.setOutputRowsPrecision( outputFieldPrecision ); meta = spy( meta ); RowMetaInterface row = mock( RowMetaInterface.class ); StepMeta parent = mock( StepMeta.class ); doReturn( parent ).when( meta ).getParentStepMeta(); when( parent.getName() ).thenReturn( "parent step" ); meta.prepareResultsRowsFields( row ); verify( parent, times( outputFieldNames.length ) ).getName(); ArgumentCaptor<ValueMetaInterface> argumentCaptor = ArgumentCaptor.forClass( ValueMetaInterface.class ); verify( row, times( outputFieldNames.length ) ).addValueMeta( argumentCaptor.capture() ); assertEquals( "parent step", argumentCaptor.getValue().getOrigin() ); }
|
TransExecutorMeta extends StepWithMappingMeta implements StepMetaInterface, HasRepositoryInterface { @Override public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { if ( nextStep != null ) { if ( nextStep.equals( executionResultTargetStepMeta ) ) { inputRowMeta.clear(); prepareExecutionResultsFields( inputRowMeta, nextStep ); } else if ( nextStep.equals( resultFilesTargetStepMeta ) ) { inputRowMeta.clear(); prepareExecutionResultsFileFields( inputRowMeta, nextStep ); } else if ( nextStep.equals( outputRowsSourceStepMeta ) ) { inputRowMeta.clear(); prepareResultsRowsFields( inputRowMeta ); } } } TransExecutorMeta(); void allocate( int nrFields ); Object clone(); String getXML(); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void setDefault(); @Override void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); String[] getInfoSteps(); @Deprecated static synchronized TransMeta loadTransMeta( TransExecutorMeta executorMeta, Repository rep,
VariableSpace space ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepinfo, RowMetaInterface prev,
String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr,
Trans trans ); @Override List<ResourceReference> getResourceDependencies( TransMeta transMeta, StepMeta stepInfo ); @Override String exportResources( VariableSpace space, Map<String, ResourceDefinition> definitions,
ResourceNamingInterface resourceNamingInterface, Repository repository, IMetaStore metaStore ); StepDataInterface getStepData(); @Override StepIOMetaInterface getStepIOMeta(); void handleStreamSelection( StreamInterface stream ); void resetStepIoMeta(); @Override void searchInfoAndTargetSteps( List<StepMeta> steps ); TransformationType[] getSupportedTransformationTypes(); @Override boolean hasRepositoryReferences(); @Override void lookupRepositoryReferences( Repository repository ); TransExecutorParameters getMappingParameters(); void setMappingParameters( TransExecutorParameters mappingParameters ); Repository getRepository(); void setRepository( Repository repository ); TransExecutorParameters getParameters(); void setParameters( TransExecutorParameters parameters ); String getExecutionTimeField(); void setExecutionTimeField( String executionTimeField ); String getExecutionResultField(); void setExecutionResultField( String executionResultField ); String getExecutionNrErrorsField(); void setExecutionNrErrorsField( String executionNrErrorsField ); String getExecutionLinesReadField(); void setExecutionLinesReadField( String executionLinesReadField ); String getExecutionLinesWrittenField(); void setExecutionLinesWrittenField( String executionLinesWrittenField ); String getExecutionLinesInputField(); void setExecutionLinesInputField( String executionLinesInputField ); String getExecutionLinesOutputField(); void setExecutionLinesOutputField( String executionLinesOutputField ); String getExecutionLinesRejectedField(); void setExecutionLinesRejectedField( String executionLinesRejectedField ); String getExecutionLinesUpdatedField(); void setExecutionLinesUpdatedField( String executionLinesUpdatedField ); String getExecutionLinesDeletedField(); void setExecutionLinesDeletedField( String executionLinesDeletedField ); String getExecutionFilesRetrievedField(); void setExecutionFilesRetrievedField( String executionFilesRetrievedField ); String getExecutionExitStatusField(); void setExecutionExitStatusField( String executionExitStatusField ); String getExecutionLogTextField(); void setExecutionLogTextField( String executionLogTextField ); String getExecutionLogChannelIdField(); void setExecutionLogChannelIdField( String executionLogChannelIdField ); String getGroupSize(); void setGroupSize( String groupSize ); String getGroupField(); void setGroupField( String groupField ); String getGroupTime(); void setGroupTime( String groupTime ); @Override boolean excludeFromCopyDistributeVerification(); String getExecutionResultTargetStep(); void setExecutionResultTargetStep( String executionResultTargetStep ); StepMeta getExecutionResultTargetStepMeta(); void setExecutionResultTargetStepMeta( StepMeta executionResultTargetStepMeta ); String getResultFilesFileNameField(); void setResultFilesFileNameField( String resultFilesFileNameField ); String[] getReferencedObjectDescriptions(); boolean[] isReferencedObjectEnabled(); Object loadReferencedObject( int index, Repository rep, IMetaStore metaStore, VariableSpace space ); IMetaStore getMetaStore(); void setMetaStore( IMetaStore metaStore ); String getOutputRowsSourceStep(); void setOutputRowsSourceStep( String outputRowsSourceStep ); StepMeta getOutputRowsSourceStepMeta(); void setOutputRowsSourceStepMeta( StepMeta outputRowsSourceStepMeta ); String[] getOutputRowsField(); void setOutputRowsField( String[] outputRowsField ); int[] getOutputRowsType(); void setOutputRowsType( int[] outputRowsType ); int[] getOutputRowsLength(); void setOutputRowsLength( int[] outputRowsLength ); int[] getOutputRowsPrecision(); void setOutputRowsPrecision( int[] outputRowsPrecision ); String getResultFilesTargetStep(); void setResultFilesTargetStep( String resultFilesTargetStep ); StepMeta getResultFilesTargetStepMeta(); void setResultFilesTargetStepMeta( StepMeta resultFilesTargetStepMeta ); String getExecutorsOutputStep(); void setExecutorsOutputStep( String executorsOutputStep ); StepMeta getExecutorsOutputStepMeta(); void setExecutorsOutputStepMeta( StepMeta executorsOutputStepMeta ); @Override boolean cleanAfterHopFromRemove(); }
|
@Test public void testGetFields() throws Exception { TransExecutorMeta meta = new TransExecutorMeta(); meta = spy( meta ); StepMeta nextStep = mock( StepMeta.class ); meta.getFields( null, null, null, nextStep, null, null, null ); verify( meta, never() ).addFieldToRow( any( RowMetaInterface.class ), anyString(), anyInt() ); RowMetaInterface rowMeta = mock( RowMetaInterface.class ); meta.getFields( rowMeta, null, null, nextStep, null, null, null ); verify( rowMeta, never() ).clear(); StepMeta executionResultTargetStepMeta = mock( StepMeta.class ); meta.setExecutionResultTargetStepMeta( executionResultTargetStepMeta ); meta.getFields( rowMeta, null, null, nextStep, null, null, null ); verify( rowMeta, atMost( 1 ) ).clear(); meta.setExecutionResultTargetStepMeta( null ); StepMeta resultFilesTargetStepMeta = mock( StepMeta.class ); meta.setResultFilesTargetStepMeta( resultFilesTargetStepMeta ); meta.getFields( rowMeta, null, null, nextStep, null, null, null ); verify( rowMeta, atMost( 1 ) ).clear(); meta.setResultFilesTargetStepMeta( null ); StepMeta outputRowsSourceStepMeta = mock( StepMeta.class ); meta.setOutputRowsSourceStepMeta( outputRowsSourceStepMeta ); meta.getFields( rowMeta, null, null, nextStep, null, null, null ); verify( rowMeta, atMost( 1 ) ).clear(); meta.setOutputRowsSourceStepMeta( null ); }
|
TransExecutorMeta extends StepWithMappingMeta implements StepMetaInterface, HasRepositoryInterface { public Object clone() { TransExecutorMeta retval = (TransExecutorMeta) super.clone(); int nrFields = outputRowsField.length; retval.allocate( nrFields ); System.arraycopy( outputRowsField, 0, retval.outputRowsField, 0, nrFields ); System.arraycopy( outputRowsType, 0, retval.outputRowsType, 0, nrFields ); System.arraycopy( outputRowsLength, 0, retval.outputRowsLength, 0, nrFields ); System.arraycopy( outputRowsPrecision, 0, retval.outputRowsPrecision, 0, nrFields ); return retval; } TransExecutorMeta(); void allocate( int nrFields ); Object clone(); String getXML(); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void setDefault(); @Override void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); String[] getInfoSteps(); @Deprecated static synchronized TransMeta loadTransMeta( TransExecutorMeta executorMeta, Repository rep,
VariableSpace space ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepinfo, RowMetaInterface prev,
String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr,
Trans trans ); @Override List<ResourceReference> getResourceDependencies( TransMeta transMeta, StepMeta stepInfo ); @Override String exportResources( VariableSpace space, Map<String, ResourceDefinition> definitions,
ResourceNamingInterface resourceNamingInterface, Repository repository, IMetaStore metaStore ); StepDataInterface getStepData(); @Override StepIOMetaInterface getStepIOMeta(); void handleStreamSelection( StreamInterface stream ); void resetStepIoMeta(); @Override void searchInfoAndTargetSteps( List<StepMeta> steps ); TransformationType[] getSupportedTransformationTypes(); @Override boolean hasRepositoryReferences(); @Override void lookupRepositoryReferences( Repository repository ); TransExecutorParameters getMappingParameters(); void setMappingParameters( TransExecutorParameters mappingParameters ); Repository getRepository(); void setRepository( Repository repository ); TransExecutorParameters getParameters(); void setParameters( TransExecutorParameters parameters ); String getExecutionTimeField(); void setExecutionTimeField( String executionTimeField ); String getExecutionResultField(); void setExecutionResultField( String executionResultField ); String getExecutionNrErrorsField(); void setExecutionNrErrorsField( String executionNrErrorsField ); String getExecutionLinesReadField(); void setExecutionLinesReadField( String executionLinesReadField ); String getExecutionLinesWrittenField(); void setExecutionLinesWrittenField( String executionLinesWrittenField ); String getExecutionLinesInputField(); void setExecutionLinesInputField( String executionLinesInputField ); String getExecutionLinesOutputField(); void setExecutionLinesOutputField( String executionLinesOutputField ); String getExecutionLinesRejectedField(); void setExecutionLinesRejectedField( String executionLinesRejectedField ); String getExecutionLinesUpdatedField(); void setExecutionLinesUpdatedField( String executionLinesUpdatedField ); String getExecutionLinesDeletedField(); void setExecutionLinesDeletedField( String executionLinesDeletedField ); String getExecutionFilesRetrievedField(); void setExecutionFilesRetrievedField( String executionFilesRetrievedField ); String getExecutionExitStatusField(); void setExecutionExitStatusField( String executionExitStatusField ); String getExecutionLogTextField(); void setExecutionLogTextField( String executionLogTextField ); String getExecutionLogChannelIdField(); void setExecutionLogChannelIdField( String executionLogChannelIdField ); String getGroupSize(); void setGroupSize( String groupSize ); String getGroupField(); void setGroupField( String groupField ); String getGroupTime(); void setGroupTime( String groupTime ); @Override boolean excludeFromCopyDistributeVerification(); String getExecutionResultTargetStep(); void setExecutionResultTargetStep( String executionResultTargetStep ); StepMeta getExecutionResultTargetStepMeta(); void setExecutionResultTargetStepMeta( StepMeta executionResultTargetStepMeta ); String getResultFilesFileNameField(); void setResultFilesFileNameField( String resultFilesFileNameField ); String[] getReferencedObjectDescriptions(); boolean[] isReferencedObjectEnabled(); Object loadReferencedObject( int index, Repository rep, IMetaStore metaStore, VariableSpace space ); IMetaStore getMetaStore(); void setMetaStore( IMetaStore metaStore ); String getOutputRowsSourceStep(); void setOutputRowsSourceStep( String outputRowsSourceStep ); StepMeta getOutputRowsSourceStepMeta(); void setOutputRowsSourceStepMeta( StepMeta outputRowsSourceStepMeta ); String[] getOutputRowsField(); void setOutputRowsField( String[] outputRowsField ); int[] getOutputRowsType(); void setOutputRowsType( int[] outputRowsType ); int[] getOutputRowsLength(); void setOutputRowsLength( int[] outputRowsLength ); int[] getOutputRowsPrecision(); void setOutputRowsPrecision( int[] outputRowsPrecision ); String getResultFilesTargetStep(); void setResultFilesTargetStep( String resultFilesTargetStep ); StepMeta getResultFilesTargetStepMeta(); void setResultFilesTargetStepMeta( StepMeta resultFilesTargetStepMeta ); String getExecutorsOutputStep(); void setExecutorsOutputStep( String executorsOutputStep ); StepMeta getExecutorsOutputStepMeta(); void setExecutorsOutputStepMeta( StepMeta executorsOutputStepMeta ); @Override boolean cleanAfterHopFromRemove(); }
|
@Test public void testClone() throws Exception { TransExecutorMeta meta = new TransExecutorMeta(); meta.setOutputRowsField( new String[] { "field1", "field2" } ); meta.setOutputRowsLength( new int[] { 5, 5 } ); meta.setOutputRowsPrecision( new int[] { 5, 5 } ); meta.setOutputRowsType( new int[] { 0, 0 } ); TransExecutorMeta cloned = (TransExecutorMeta) meta.clone(); assertFalse( cloned.getOutputRowsField() == meta.getOutputRowsField() ); assertTrue( Arrays.equals( cloned.getOutputRowsField(), meta.getOutputRowsField() ) ); assertFalse( cloned.getOutputRowsLength() == meta.getOutputRowsLength() ); assertTrue( Arrays.equals( cloned.getOutputRowsLength(), meta.getOutputRowsLength() ) ); assertFalse( cloned.getOutputRowsPrecision() == meta.getOutputRowsPrecision() ); assertTrue( Arrays.equals( cloned.getOutputRowsPrecision(), meta.getOutputRowsPrecision() ) ); assertFalse( cloned.getOutputRowsType() == meta.getOutputRowsType() ); assertTrue( Arrays.equals( cloned.getOutputRowsType(), meta.getOutputRowsType() ) ); }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.