Java Code Examples for org.pentaho.di.trans.TransMeta#setDescription()

The following examples show how to use org.pentaho.di.trans.TransMeta#setDescription() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransformationHasDescriptionImportRuleTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testVerifyRule_SameAsMinimumLenghtDescription_EnabledRule() {
  TransformationHasDescriptionImportRule importRule = getImportRule( 10, true );
  TransMeta transMeta = new TransMeta();
  transMeta.setDescription(
    "1234567890" );

  List<ImportValidationFeedback> feedbackList = importRule.verifyRule( transMeta );

  assertNotNull( feedbackList );
  assertFalse( feedbackList.isEmpty() );
  ImportValidationFeedback feedback = feedbackList.get( 0 );
  assertNotNull( feedback );
  assertEquals( ImportValidationResultType.APPROVAL, feedback.getResultType() );
  assertTrue( feedback.isApproval() );
}
 
Example 2
Source File: TransformationHasDescriptionImportRuleTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testVerifyRule_LongDescription_EnabledRule() {
  TransformationHasDescriptionImportRule importRule = getImportRule( 10, true );
  TransMeta transMeta = new TransMeta();
  transMeta.setDescription(
    "A very long description that has more characters than the minimum required to be a valid one!" );

  List<ImportValidationFeedback> feedbackList = importRule.verifyRule( transMeta );

  assertNotNull( feedbackList );
  assertFalse( feedbackList.isEmpty() );
  ImportValidationFeedback feedback = feedbackList.get( 0 );
  assertNotNull( feedback );
  assertEquals( ImportValidationResultType.APPROVAL, feedback.getResultType() );
  assertTrue( feedback.isApproval() );
}
 
Example 3
Source File: PurRepository.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private TransMeta buildTransMeta( final RepositoryFile file, final RepositoryDirectoryInterface parentDir,
                                  final NodeRepositoryFileData data, final ObjectRevision revision )
  throws KettleException {
  TransMeta transMeta = new TransMeta();
  transMeta.setName( file.getTitle() );
  transMeta.setFilename( file.getName() );
  transMeta.setDescription( file.getDescription() );
  transMeta.setObjectId( new StringObjectId( file.getId().toString() ) );
  transMeta.setObjectRevision( revision );
  transMeta.setRepository( this );
  transMeta.setRepositoryDirectory( parentDir );
  transMeta.setMetaStore( getMetaStore() );
  readTransSharedObjects( transMeta ); // This should read from the local cache
  transDelegate.dataNodeToElement( data.getNode(), transMeta );
  transMeta.clearChanged();
  return transMeta;
}
 
Example 4
Source File: TransformationHasDescriptionImportRuleTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testVerifyRule_NullDescription_EnabledRule() {
  TransformationHasDescriptionImportRule importRule = getImportRule( 10, true );
  TransMeta transMeta = new TransMeta();
  transMeta.setDescription( null );

  List<ImportValidationFeedback> feedbackList = importRule.verifyRule( transMeta );

  assertNotNull( feedbackList );
  assertFalse( feedbackList.isEmpty() );
  ImportValidationFeedback feedback = feedbackList.get( 0 );
  assertNotNull( feedback );
  assertEquals( ImportValidationResultType.ERROR, feedback.getResultType() );
  assertTrue( feedback.isError() );
}
 
Example 5
Source File: TransformationHasDescriptionImportRuleTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testVerifyRule_EmptyDescription_EnabledRule() {
  TransformationHasDescriptionImportRule importRule = getImportRule( 10, true );
  TransMeta transMeta = new TransMeta();
  transMeta.setDescription( "" );

  List<ImportValidationFeedback> feedbackList = importRule.verifyRule( transMeta );

  assertNotNull( feedbackList );
  assertFalse( feedbackList.isEmpty() );
  ImportValidationFeedback feedback = feedbackList.get( 0 );
  assertNotNull( feedback );
  assertEquals( ImportValidationResultType.ERROR, feedback.getResultType() );
  assertTrue( feedback.isError() );
}
 
Example 6
Source File: TransformationHasDescriptionImportRuleTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testVerifyRule_ShortDescription_EnabledRule() {
  TransformationHasDescriptionImportRule importRule = getImportRule( 10, true );
  TransMeta transMeta = new TransMeta();
  transMeta.setDescription( "short" );

  List<ImportValidationFeedback> feedbackList = importRule.verifyRule( transMeta );

  assertNotNull( feedbackList );
  assertFalse( feedbackList.isEmpty() );
  ImportValidationFeedback feedback = feedbackList.get( 0 );
  assertNotNull( feedback );
  assertEquals( ImportValidationResultType.ERROR, feedback.getResultType() );
  assertTrue( feedback.isError() );
}
 
Example 7
Source File: TransformationHasDescriptionImportRuleTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testVerifyRule_NullDescription_DisabledRule() {
  TransformationHasDescriptionImportRule importRule = getImportRule( 10, false );
  TransMeta transMeta = new TransMeta();
  transMeta.setDescription( null );

  List<ImportValidationFeedback> feedbackList = importRule.verifyRule( null );

  assertNotNull( feedbackList );
  assertTrue( feedbackList.isEmpty() );
}
 
Example 8
Source File: TransformationHasDescriptionImportRuleTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testVerifyRule_EmptyDescription_DisabledRule() {
  TransformationHasDescriptionImportRule importRule = getImportRule( 10, false );
  TransMeta transMeta = new TransMeta();
  transMeta.setDescription( "" );

  List<ImportValidationFeedback> feedbackList = importRule.verifyRule( null );

  assertNotNull( feedbackList );
  assertTrue( feedbackList.isEmpty() );
}
 
Example 9
Source File: TransformationHasDescriptionImportRuleTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testVerifyRule_ShortDescription_DisabledRule() {
  TransformationHasDescriptionImportRule importRule = getImportRule( 10, false );
  TransMeta transMeta = new TransMeta();
  transMeta.setDescription( "short" );

  List<ImportValidationFeedback> feedbackList = importRule.verifyRule( null );

  assertNotNull( feedbackList );
  assertTrue( feedbackList.isEmpty() );
}
 
Example 10
Source File: TransformationHasDescriptionImportRuleTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testVerifyRule_SameAsMinimumLenghtDescription_DisabledRule() {
  TransformationHasDescriptionImportRule importRule = getImportRule( 10, false );
  TransMeta transMeta = new TransMeta();
  transMeta.setDescription(
    "1234567890" );

  List<ImportValidationFeedback> feedbackList = importRule.verifyRule( null );

  assertNotNull( feedbackList );
  assertTrue( feedbackList.isEmpty() );
}
 
Example 11
Source File: TransformationHasDescriptionImportRuleTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testVerifyRule_LongDescription_DisabledRule() {
  TransformationHasDescriptionImportRule importRule = getImportRule( 10, false );
  TransMeta transMeta = new TransMeta();
  transMeta.setDescription(
    "A very long description that has more characters than the minimum required to be a valid one!" );

  List<ImportValidationFeedback> feedbackList = importRule.verifyRule( null );

  assertNotNull( feedbackList );
  assertTrue( feedbackList.isEmpty() );
}
 
Example 12
Source File: TransformationHasDescriptionImportRuleIT.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void testRule() throws Exception {

    TransMeta transMeta = new TransMeta();
    transMeta.setDescription( "This transformation is used for testing an import rule" );

    PluginRegistry registry = PluginRegistry.getInstance();

    PluginInterface plugin =
      registry.findPluginWithId( ImportRulePluginType.class, "TransformationHasDescription" );
    assertNotNull( "The 'transformation has description' rule could not be found in the plugin registry!", plugin );

    TransformationHasDescriptionImportRule rule =
      (TransformationHasDescriptionImportRule) registry.loadClass( plugin );
    assertNotNull(
      "The 'transformation has description rule' class could not be loaded by the plugin registry!", plugin );

    rule.setMinLength( 20 );
    rule.setEnabled( true );

    List<ImportValidationFeedback> feedback = rule.verifyRule( transMeta );
    assertTrue( "We didn't get any feedback from the 'transformation has description rule'", !feedback.isEmpty() );
    assertTrue(
      "An approval ruling was expected",
      feedback.get( 0 ).getResultType() == ImportValidationResultType.APPROVAL );

    rule.setMinLength( 2000 );
    rule.setEnabled( true );

    feedback = rule.verifyRule( transMeta );
    assertTrue( "We didn't get any feedback from the 'transformation has description rule'", !feedback.isEmpty() );
    assertTrue(
      "An error ruling was expected", feedback.get( 0 ).getResultType() == ImportValidationResultType.ERROR );

    rule.setEnabled( false );

    feedback = rule.verifyRule( transMeta );
    assertTrue(
      "We didn't expect any feedback from the 'transformation has description rule' while disabled", feedback
        .isEmpty() );

  }
 
Example 13
Source File: RepositoryTestBase.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
protected TransMeta createTransMeta( final String dbName ) throws Exception {
  RepositoryDirectoryInterface rootDir = loadStartDirectory();
  TransMeta transMeta = new TransMeta();
  transMeta.setName( EXP_TRANS_NAME.concat( dbName ) );
  transMeta.setDescription( EXP_TRANS_DESC );
  transMeta.setExtendedDescription( EXP_TRANS_EXTENDED_DESC );
  transMeta.setRepositoryDirectory( rootDir.findDirectory( DIR_TRANSFORMATIONS ) );
  transMeta.setTransversion( EXP_TRANS_VERSION );
  transMeta.setTransstatus( EXP_TRANS_STATUS );
  transMeta.setCreatedUser( EXP_TRANS_CREATED_USER );
  transMeta.setCreatedDate( EXP_TRANS_CREATED_DATE );
  transMeta.setModifiedUser( EXP_TRANS_MOD_USER );
  transMeta.setModifiedDate( EXP_TRANS_MOD_DATE );
  transMeta.addParameterDefinition( EXP_TRANS_PARAM_1_NAME, EXP_TRANS_PARAM_1_DEF, EXP_TRANS_PARAM_1_DESC );

  // TODO mlowery other transLogTable fields could be set for testing here
  TransLogTable transLogTable = TransLogTable.getDefault( transMeta, transMeta, new ArrayList<StepMeta>( 0 ) );
  transLogTable.setConnectionName( EXP_TRANS_LOG_TABLE_CONN_NAME );
  transLogTable.setLogInterval( EXP_TRANS_LOG_TABLE_INTERVAL );
  transLogTable.setSchemaName( EXP_TRANS_LOG_TABLE_SCHEMA_NAME );
  transLogTable.setLogSizeLimit( EXP_TRANS_LOG_TABLE_SIZE_LIMIT );
  transLogTable.setTableName( EXP_TRANS_LOG_TABLE_TABLE_NAME );
  transLogTable.setTimeoutInDays( EXP_TRANS_LOG_TABLE_TIMEOUT_IN_DAYS );
  transMeta.setTransLogTable( transLogTable );
  // TODO mlowery other perfLogTable fields could be set for testing here
  PerformanceLogTable perfLogTable = PerformanceLogTable.getDefault( transMeta, transMeta );
  perfLogTable.setConnectionName( EXP_TRANS_LOG_TABLE_CONN_NAME );
  perfLogTable.setLogInterval( EXP_TRANS_LOG_TABLE_INTERVAL );
  perfLogTable.setSchemaName( EXP_TRANS_LOG_TABLE_SCHEMA_NAME );
  perfLogTable.setTableName( EXP_TRANS_LOG_TABLE_TABLE_NAME );
  perfLogTable.setTimeoutInDays( EXP_TRANS_LOG_TABLE_TIMEOUT_IN_DAYS );
  transMeta.setPerformanceLogTable( perfLogTable );
  // TODO mlowery other channelLogTable fields could be set for testing here
  ChannelLogTable channelLogTable = ChannelLogTable.getDefault( transMeta, transMeta );
  channelLogTable.setConnectionName( EXP_TRANS_LOG_TABLE_CONN_NAME );
  channelLogTable.setSchemaName( EXP_TRANS_LOG_TABLE_SCHEMA_NAME );
  channelLogTable.setTableName( EXP_TRANS_LOG_TABLE_TABLE_NAME );
  channelLogTable.setTimeoutInDays( EXP_TRANS_LOG_TABLE_TIMEOUT_IN_DAYS );
  transMeta.setChannelLogTable( channelLogTable );
  // TODO mlowery other stepLogTable fields could be set for testing here
  StepLogTable stepLogTable = StepLogTable.getDefault( transMeta, transMeta );
  stepLogTable.setConnectionName( EXP_TRANS_LOG_TABLE_CONN_NAME );
  stepLogTable.setSchemaName( EXP_TRANS_LOG_TABLE_SCHEMA_NAME );
  stepLogTable.setTableName( EXP_TRANS_LOG_TABLE_TABLE_NAME );
  stepLogTable.setTimeoutInDays( EXP_TRANS_LOG_TABLE_TIMEOUT_IN_DAYS );
  transMeta.setStepLogTable( stepLogTable );
  DatabaseMeta dbMeta = createDatabaseMeta( dbName );
  // dbMeta must be saved so that it gets an ID
  repository.save( dbMeta, VERSION_COMMENT_V1, null );
  deleteStack.push( dbMeta );
  transMeta.setMaxDateConnection( dbMeta );
  transMeta.setMaxDateTable( EXP_TRANS_MAX_DATE_TABLE );
  transMeta.setMaxDateField( EXP_TRANS_MAX_DATE_FIELD );
  transMeta.setMaxDateOffset( EXP_TRANS_MAX_DATE_OFFSET );
  transMeta.setMaxDateDifference( EXP_TRANS_MAX_DATE_DIFF );
  transMeta.setSizeRowset( EXP_TRANS_SIZE_ROWSET );
  transMeta.setSleepTimeEmpty( EXP_TRANS_SLEEP_TIME_EMPTY );
  transMeta.setSleepTimeFull( EXP_TRANS_SLEEP_TIME_FULL );
  transMeta.setUsingUniqueConnections( EXP_TRANS_USING_UNIQUE_CONN );
  transMeta.setFeedbackShown( EXP_TRANS_FEEDBACK_SHOWN );
  transMeta.setFeedbackSize( EXP_TRANS_FEEDBACK_SIZE );
  transMeta.setUsingThreadPriorityManagment( EXP_TRANS_USING_THREAD_PRIORITY_MGMT );
  transMeta.setSharedObjectsFile( EXP_TRANS_SHARED_OBJECTS_FILE );
  transMeta.setCapturingStepPerformanceSnapShots( EXP_TRANS_CAPTURE_STEP_PERF_SNAPSHOTS );
  transMeta.setStepPerformanceCapturingDelay( EXP_TRANS_STEP_PERF_CAP_DELAY );
  transMeta.addDependency( new TransDependency( dbMeta, EXP_TRANS_DEP_TABLE_NAME, EXP_TRANS_DEP_FIELD_NAME ) );
  DatabaseMeta stepDbMeta = createDatabaseMeta( EXP_DBMETA_NAME_STEP.concat( dbName ) );
  repository.save( stepDbMeta, VERSION_COMMENT_V1, null );
  deleteStack.push( stepDbMeta );
  Condition cond = new Condition();
  StepMeta step1 = createStepMeta1( transMeta, stepDbMeta, cond );
  transMeta.addStep( step1 );
  StepMeta step2 = createStepMeta2( stepDbMeta, cond );
  transMeta.addStep( step2 );
  transMeta.addTransHop( createTransHopMeta( step1, step2 ) );

  SlaveServer slaveServer = createSlaveServer( dbName );
  PartitionSchema partSchema = createPartitionSchema( dbName );
  // slaveServer, partSchema must be saved so that they get IDs
  repository.save( slaveServer, VERSION_COMMENT_V1, null );
  deleteStack.push( slaveServer );
  repository.save( partSchema, VERSION_COMMENT_V1, null );
  deleteStack.push( partSchema );

  SlaveStepCopyPartitionDistribution slaveStepCopyPartitionDistribution = new SlaveStepCopyPartitionDistribution();
  slaveStepCopyPartitionDistribution.addPartition( EXP_SLAVE_NAME, EXP_PART_SCHEMA_NAME, 0 );
  slaveStepCopyPartitionDistribution.setOriginalPartitionSchemas( Arrays
      .asList( new PartitionSchema[] { partSchema } ) );
  transMeta.setSlaveStepCopyPartitionDistribution( slaveStepCopyPartitionDistribution );
  transMeta.setSlaveTransformation( EXP_TRANS_SLAVE_TRANSFORMATION );
  return transMeta;
}
 
Example 14
Source File: JobGenerator.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
/**
 * Generates a template
 * @param databaseMeta
 * @param logicalModel
 * @return
 */
public TransMeta generateDimensionTransformation(DatabaseMeta databaseMeta, LogicalTable logicalTable) {
  TransMeta transMeta = new TransMeta();

  String tableName = ConceptUtil.getName(logicalTable, locale);
  String tableDescription = ConceptUtil.getDescription(logicalTable, locale);
  DimensionType dimensionType = ConceptUtil.getDimensionType(logicalTable);

  transMeta.setName("Update dimension '"+tableName+"'");
  transMeta.setDescription(tableDescription);

  // Let's not forget to add the target database
  //
  transMeta.addDatabase(databaseMeta);

  Point location = new Point(GRAPH_LEFT, GRAPH_TOP);

  // Find all the source columns and source tables and put them into a table input step...
  //
  StepMeta inputStep = generateTableInputStepFromLogicalTable(logicalTable);
  DatabaseMeta sourceDatabaseMeta = ((TableInputMeta)inputStep.getStepMetaInterface()).getDatabaseMeta();
  if (sourceDatabaseMeta!=null) transMeta.addOrReplaceDatabase(sourceDatabaseMeta);
  inputStep.setLocation(location.x, location.y);
  nextLocation(location);
  transMeta.addStep(inputStep);
  StepMeta lastStep = inputStep;

  // Generate an dimension lookup/update step for each table
  //
  StepMeta dimensionStep;
  if (dimensionType==DimensionType.SLOWLY_CHANGING_DIMENSION) {
    dimensionStep = generateDimensionLookupStepFromLogicalTable(databaseMeta, logicalTable);
  } else {
    dimensionStep = generateCombinationLookupStepFromLogicalTable(databaseMeta, logicalTable);
  }
  dimensionStep.setLocation(location.x, location.y);
  nextLocation(location);
  transMeta.addStep(dimensionStep);

  TransHopMeta transHop = new TransHopMeta(lastStep, dimensionStep);
  transMeta.addTransHop(transHop);

  return transMeta;
}