Java Code Examples for org.pentaho.di.core.Const

The following are top voted examples for showing how to use org.pentaho.di.core.Const. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: aliyun-maxcompute-data-collectors   File: OdpsOutputMeta.java   View source code 6 votes vote down vote up
@Override public String getXML() throws KettleException {

        StringBuilder retVal = new StringBuilder();
        retVal.append(super.getXML());

        retVal.append("  ")
            .append(XMLHandler.addTagValue("truncate", isTruncate() ? "true" : "false"));

        for (int i = 0; i < streamFields.size(); i++) {
            String streamField = streamFields.get(i);
            retVal.append("  <stream_fields>").append(Const.CR);
            retVal.append("  ").append(XMLHandler.addTagValue("name", streamField.toLowerCase()));
            retVal.append("  </stream_fields>").append(Const.CR);
        }

        return retVal.toString();
    }
 
Example 2
Project: aliyun-maxcompute-data-collectors   File: OdpsMeta.java   View source code 6 votes vote down vote up
@Override public String getXML() throws KettleException {
    StringBuilder retVal = new StringBuilder();
    retVal.append("  ").append(XMLHandler.addTagValue("endpoint", getEndpoint())).append("  ")
            .append("  ").append(XMLHandler.addTagValue("tunnelEndpoint", getTunnelEndpoint()))
        .append(XMLHandler.addTagValue("accessId", getAccessId())).append("  ")
        .append(XMLHandler.addTagValue("accessKey", getAccessKey())).append("  ")
        .append(XMLHandler.addTagValue("projectName", getProjectName())).append("  ")
        .append(XMLHandler.addTagValue("tableName", getTableName())).append("  ")
        .append(XMLHandler.addTagValue("partition", getPartition()));

    for (int i = 0; i < odpsFields.size(); i++) {
        OdpsField field = odpsFields.get(i);
        retVal.append("  <fields>").append(Const.CR);
        retVal.append("  ")
            .append(XMLHandler.addTagValue("name", field.getName().toLowerCase()));
        retVal.append("  ").append(XMLHandler.addTagValue("type", field.getType()));
        retVal.append("  ").append(XMLHandler.addTagValue("comment", field.getComment()));
        retVal.append("  </fields>").append(Const.CR);
    }

    return retVal.toString();
}
 
Example 3
Project: pentaho-cassandra-plugin   File: CassandraInputDialog.java   View source code 6 votes vote down vote up
private void getData() {
    this.wCompression.setText(this.meta.getCompression().toString());

    if (!Const.isEmpty(this.meta.getCqlStatement())) {
        this.wtCql.setText(this.meta.getCqlStatement());
    }
    this.wLimit.setText(String.valueOf(this.meta.getRowLimit()));

    boolean hasInfo = (this.meta.getStepIOMeta().getInfoStreams() != null) && (!this.meta.getStepIOMeta().getInfoStreams().isEmpty());
    this.wEachRow.setEnabled(hasInfo);
    this.wlEachRow.setEnabled(hasInfo);

    setCQLToolTip();
    setFlags();

    this.wStepname.selectAll();
    this.wStepname.setFocus();
}
 
Example 4
Project: pentaho-pdi-streaming   File: GetStreamingCacheDialog.java   View source code 6 votes vote down vote up
private void getData() {
  
  try {
    MetaStoreFactory<StreamingService> factory = new MetaStoreFactory<StreamingService>(StreamingService.class, metaStore, PentahoDefaults.NAMESPACE);
    List<String> names = factory.getElementNames();
    Collections.sort(names);
    wServiceName.setItems(names.toArray(new String[names.size()]));
  } catch(MetaStoreException e) {
    LogChannel.GENERAL.logError("Error reading streaming service names from the metastore", e);
  }
  
  wServiceName.setText( Const.NVL(input.getServiceName(), ""));
  wIdField.setText(Const.NVL(input.getIdField(), ""));
  wTimeStampField.setText(Const.NVL(input.getTimestampField(), ""));
  
  String[] slaves = transMeta.getSlaveServerNames();
  Arrays.sort(slaves);
  wSlaveServer.setItems(slaves);
  wSlaveServer.setText(Const.NVL(input.getSlaveServer(), ""));
  
  wStepname.selectAll();
  wStepname.setFocus();
}
 
Example 5
Project: pentaho-pdi-streaming   File: GetStreamingCacheDialog.java   View source code 6 votes vote down vote up
private void ok() {
  if ( Const.isEmpty( wStepname.getText() ) ) {
    return;
  }

  stepname = wStepname.getText(); // return value

  input.setChanged();
  
  input.setServiceName( wServiceName.getText() );
  input.setIdField( wIdField.getText() );
  input.setTimestampField( wTimeStampField.getText() );
  input.setSlaveServer( wSlaveServer.getText() );
  
  dispose();
}
 
Example 6
Project: pentaho-pdi-streaming   File: StreamingService.java   View source code 6 votes vote down vote up
/**
 * Try to look up the transObjectId for transformation which are referenced by path 
 * @param repository The repository to use.
 * @throws KettleException
 */
public void lookupTransObjectId( Repository repository ) throws KettleException {
  if ( repository == null )
    return;

  if ( Const.isEmpty( transFilename ) && transObjectId == null && !Const.isEmpty( transRepositoryPath ) ) {
    // see if there is a path specified to a repository name
    //
    String path = "/";
    String name = transRepositoryPath;
    int lastSlashIndex = name.lastIndexOf( '/' );
    if ( lastSlashIndex >= 0 ) {
      path = transRepositoryPath.substring( 0, lastSlashIndex + 1 );
      name = transRepositoryPath.substring( lastSlashIndex + 1 );
    }
    RepositoryDirectoryInterface tree = repository.loadRepositoryDirectoryTree();
    RepositoryDirectoryInterface rd = tree.findDirectory( path );
    if ( rd == null )
      rd = tree; // root

    ObjectId transformationID = repository.getTransformationID( name, rd );
    transObjectId = transformationID == null ? null : transformationID.getId();
  }
}
 
Example 7
Project: sdmx-kettle   File: SdmxStepDialog.java   View source code 6 votes vote down vote up
/**
 * Called when the user confirms the dialog
 */
private void ok() {
   if ( Const.isEmpty( wStepname.getText() ) ) {
     return;
   }

	// The "stepname" variable will be the return value for the open() method. 
	// Setting to step name from the dialog control
	stepname = wStepname.getText(); 
	// Setting the  settings to the meta object

	// close the SWT dialog window

   saveMeta( meta );

	dispose();
}
 
Example 8
Project: sdmx-kettle   File: PreviewTimeSeriesDialog.java   View source code 6 votes vote down vote up
private void addTableView() {
  int margin = Const.MARGIN;
  ColumnInfo[] colinf = new ColumnInfo[rowMeta.size()];
  for ( int i = 0; i < rowMeta.size(); i++ ) {
    ValueMetaInterface v = rowMeta.getValueMeta( i );
    colinf[i] = new ColumnInfo( v.getName(), ColumnInfo.COLUMN_TYPE_TEXT, v.isNumeric() );
    colinf[i].setToolTip( v.toStringMeta() );
    colinf[i].setValueMeta( v );
  }

  wSeriesTable =
      new TableView( variables, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, 0, null, props );
  wSeriesTable.setShowingBlueNullValues( true ); //// TODO: 25/05/16 wat?

  fdSeriesTable = new FormData();
  fdSeriesTable.left = new FormAttachment( 0, 0 );
  fdSeriesTable.top = new FormAttachment( 0, margin );
  fdSeriesTable.right = new FormAttachment( 100, 0 );
  fdSeriesTable.bottom = new FormAttachment( 100, -50 );
  wSeriesTable.setLayoutData( fdSeriesTable );

  fillTableView();
}
 
Example 9
Project: sdmx-kettle   File: SdmxStepMeta.java   View source code 6 votes vote down vote up
private void appendFields( StringBuilder sb ) {
  sb.append( "    <fields>" ).append( Const.CR );
  for ( int i = 0; i < fields.length; i++ ) {
    sb.append( "      <field>" ).append( Const.CR );
    sb.append( "        " ).append( XMLHandler.addTagValue( "name", fields[i].getName() ) );
    sb.append( "        " ).append( XMLHandler.addTagValue( "type", fields[i].getTypeDesc() ) );
    sb.append( "        " ).append( XMLHandler.addTagValue( "length", fields[i].getLength() ) );
    sb.append( "        " ).append( XMLHandler.addTagValue( "precision", fields[i].getPrecision() ) );
    sb.append( "        " ).append( XMLHandler.addTagValue( "trim_type", fields[i].getTrimTypeCode() ) );
    sb.append( "        " ).append( XMLHandler.addTagValue( "repeat", fields[i].isRepeated() ) );
    sb.append( "        " ).append( XMLHandler.addTagValue( "format", fields[i].getFormat() ) );
    sb.append( "        " ).append( XMLHandler.addTagValue( "currency", fields[i].getCurrencySymbol() ) );
    sb.append( "        " ).append( XMLHandler.addTagValue( "decimal", fields[i].getDecimalSymbol() ) );
    sb.append( "        " ).append( XMLHandler.addTagValue( "group", fields[i].getGroupSymbol() ) );
    sb.append( "      </field>" ).append( Const.CR );
  }
  sb.append( "    </fields>" ).append( Const.CR );
}
 
Example 10
Project: pdi-hcp-plugin   File: HCPDeleteDialog.java   View source code 6 votes vote down vote up
private void ok() {
  if ( Const.isEmpty( wStepname.getText() ) ) {
    return;
  }

  stepname = wStepname.getText(); // return value

  input.setConnection(null);
  String connectionName = wConnection.getText();
  if (StringUtils.isNotEmpty(connectionName)) {
    try{
      HCPConnection connection = HCPConnectionUtils.getConnectionFactory(metaStore).loadElement(connectionName);
      input.setConnection(connection);
    } catch(Exception exception) {
      new ErrorDialog(shell, 
          BaseMessages.getString(PKG, "HCPDeleteDialog.Error.ErrorLoadingConnectionWithName.Title"), 
          BaseMessages.getString(PKG, "HCPDeleteDialog.Error.ErrorLoadingConnectionWithName.Message", connectionName), exception);
    }
  }
  input.setTargetFileField(wTargetFileField.getText() );
  input.setResponseCodeField(wResponseCodeField.getText());
  input.setResponseTimeField(wResponseTimeField.getText());
  
  dispose();
}
 
Example 11
Project: pentaho-mqtt-plugin   File: MQTTPublisherDialog.java   View source code 6 votes vote down vote up
private void updateTopicCombo( RowMetaInterface previousFields ) {
  if ( m_wTopicFromIncomingField.getSelection() ) {
    m_wlTopicName.setText( BaseMessages.getString( MQTTPublisherMeta.PKG, "MQTTClientDialog.TopicNameFromField" ) );
  } else {
    m_wlTopicName.setText( BaseMessages
        .getString( org.pentaho.di.trans.steps.pentahomqttpublisher.MQTTPublisherMeta.PKG,
            "MQTTClientDialog.TopicName.Label" ) );
  }

  String current = m_wTopicName.getText();
  m_wTopicName.removeAll();
  if ( m_wTopicFromIncomingField.getSelection() ) {
    m_wTopicName.setItems( previousFields.getFieldNames() );
  }

  if ( !Const.isEmpty( current ) ) {
    m_wTopicName.setText( current );
  }
}
 
Example 12
Project: PentahoSnowflakePlugin   File: SnowflakeBulkLoaderDialog.java   View source code 6 votes vote down vote up
/**
 * Sets the input stream field names in the JSON field drop down, and the Stream field drop down in the field
 * mapping table.
 */
private void setComboBoxes() {
  // Something was changed in the row.
  //
  final Map<String, Integer> fields = new HashMap<>();

  // Add the currentMeta fields...
  fields.putAll( inputFields );

  Set<String> keySet = fields.keySet();
  List<String> entries = new ArrayList<>( keySet );

  String[] fieldNames = entries.toArray( new String[entries.size()] );

  Const.sortStrings( fieldNames );
  colinf[0].setComboValues( fieldNames );
}
 
Example 13
Project: PentahoSnowflakePlugin   File: SnowflakeBulkLoaderDialog.java   View source code 6 votes vote down vote up
/**
 * Opens a dialog to select a table name
 */
private void getTableName() {
  // New class: SelectTableDialog
  int connr = wConnection.getSelectionIndex();
  if ( connr >= 0 ) {
    DatabaseMeta inf = transMeta.getDatabase( connr );

    if ( log.isDebug() ) {
      logDebug( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog..Log.LookingAtConnection", inf.toString() ) );
    }

    DatabaseExplorerDialog std = new DatabaseExplorerDialog( shell, SWT.NONE, inf, transMeta.getDatabases() );
    std.setSelectedSchemaAndTable( wSchema.getText(), wTable.getText() );
    if ( std.open() ) {
      wSchema.setText( Const.NVL( std.getSchemaName(), "" ) );
      wTable.setText( Const.NVL( std.getTableName(), "" ) );
      setTableFieldCombo();
    }
  } else {
    MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
    mb.setMessage( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.ConnectionError2.DialogMessage" ) );
    mb.setText( BaseMessages.getString( PKG, "System.Dialog.Error.Title" ) );
    mb.open();
  }

}
 
Example 14
Project: PentahoSnowflakePlugin   File: SnowflakeBulkLoader.java   View source code 6 votes vote down vote up
/**
 * Takes an input field and converts it to bytes to be stored in the temp file.
 * @param v The metadata about the column
 * @param valueData The column data
 * @return The bytes for the value
 * @throws KettleValueException
 */
private byte[] formatField( ValueMetaInterface v, Object valueData ) throws KettleValueException {
  if ( v.isString() ) {
    if ( v.isStorageBinaryString() && v.getTrimType() == ValueMetaInterface.TRIM_TYPE_NONE && v.getLength() < 0
      && Const.isEmpty( v.getStringEncoding() ) ) {
      return (byte[]) valueData;
    } else {
      String svalue = ( valueData instanceof String ) ? (String) valueData : v.getString( valueData );

      // trim or cut to size if needed.
      //
      return convertStringToBinaryString( v, Const.trimToType( svalue, v.getTrimType() ) );
    }
  } else {
    return v.getBinaryString( valueData );
  }
}
 
Example 15
Project: PentahoSnowflakePlugin   File: SnowflakeBulkLoaderMeta.java   View source code 6 votes vote down vote up
/**
 * Gets the Snowflake stage name based on the configured metadata
 * @param space The variable space
 * @return The Snowflake stage name to use
 */
public String getStage( VariableSpace space ) {
  if ( locationType.equals( LOCATION_TYPE_CODES[LOCATION_TYPE_USER] ) ) {
    return "@~/" + space.environmentSubstitute( targetTable );
  } else if ( locationType.equals( LOCATION_TYPE_CODES[LOCATION_TYPE_TABLE] ) ) {
    if ( !Const.isEmpty( space.environmentSubstitute( targetSchema ) ) ) {
      return "@" + space.environmentSubstitute( targetSchema ) + ".%" + space.environmentSubstitute( targetTable );
    } else {
      return "@%" + space.environmentSubstitute( targetTable );
    }
  } else if ( locationType.equals( LOCATION_TYPE_CODES[LOCATION_TYPE_INTERNAL_STAGE] ) ) {
    if ( !Const.isEmpty( space.environmentSubstitute( targetSchema ) ) ) {
      return "@" + space.environmentSubstitute( targetSchema ) + "." + space.environmentSubstitute( stageName );
    } else {
      return "@" + space.environmentSubstitute( stageName );
    }
  }
  return null;
}
 
Example 16
Project: PentahoSnowflakePlugin   File: SnowflakeDatabaseMeta.java   View source code 6 votes vote down vote up
@Override
public String getURL( String hostname, String port, String databaseName ) {
  if ( getAccessType() == DatabaseMeta.TYPE_ACCESS_ODBC ) {
    return "jdbc:odbc:" + databaseName;
  } else {
    String realHostname = hostname;
    String account = hostname;
    if ( !realHostname.contains( "." ) ) {
      realHostname = hostname + ".snowflakecomputing.com";
    } else {
      account = hostname.substring( 0, hostname.indexOf( "." ) );
    }
    if ( Const.isEmpty( port ) ) {
      return "jdbc:snowflake://" + realHostname + "/?account=" + account + "&db=" + databaseName
        + "&user=" + getUsername() + "&password=" + getPassword();
    } else {
      return "jdbc:snowflake://" + realHostname + ":" + port + "/?account=" + account + "&db=" + databaseName
        + "&user=" + getUsername() + "&password=" + getPassword();
    }
  }
}
 
Example 17
Project: ARXPlugin   File: ARXPlugin.java   View source code 6 votes vote down vote up
/**
 * Generates the Object and runs it
 */
public void run() {
	logBasic("Starting to run...");
	try {
		while (processRow(meta, data) && !isStopped())
			;

	} catch (Exception e) {
		logError("Unexpected error : " + e.toString());
		logError(Const.getStackTracker(e));
		setErrors(1);
		stopAll();
	} finally {
		dispose(meta, data);
		logBasic("Finished, processing " + getLinesRead() + " rows");
		markStop();
	}
}
 
Example 18
Project: pdi-zendesk-plugin   File: ZendeskInputOrganizations.java   View source code 6 votes vote down vote up
private void outputOrganizationDomainRow( Organization org ) throws KettleStepException {
  if ( data.organizationDomainRowMeta == null || data.organizationDomainRowMeta.isEmpty() ) {
    return;
  }

  for ( String domain : org.getDomainNames() ) {
    if ( !Const.isEmpty( domain ) ) {
      Object[] outputRow = RowDataUtil.allocateRowData( data.organizationDomainRowMeta.size() );

      if ( data.domainOrganizationIdIndex >= 0 ) {
        outputRow[data.domainOrganizationIdIndex] = org.getId();
      }
      if ( data.domainNameIndex >= 0 ) {
        outputRow[data.domainNameIndex] = domain;
      }
      putRowTo( data.organizationDomainRowMeta, outputRow, data.organizationDomainOutputRowSet );
    }
  }
}
 
Example 19
Project: pdi-zendesk-plugin   File: ZendeskInput.java   View source code 6 votes vote down vote up
@Override
public boolean init( StepMetaInterface smi, StepDataInterface sdi ) {
  if ( !super.init( smi, sdi ) ) {
    return false;
  }
  meta = (ZendeskInputMeta) smi;
  data = (ZendeskInputData) sdi;

  String subDomain = environmentSubstitute( meta.getSubDomain() );
  String username = environmentSubstitute( meta.getUsername() );
  String password = Encr.decryptPasswordOptionallyEncrypted( environmentSubstitute( meta.getPassword() ) );

  if ( Const.isEmpty( subDomain ) || Const.isEmpty( username ) || Const.isEmpty( password ) ) {
    logError( BaseMessages.getString( PKG, "ZendeskInput.Error.MissingCredentials" ) );
    return false;
  }

  data.conn = createConnection( subDomain, username, password, meta.isToken() );
  if ( data.conn == null || data.conn.isClosed() ) {
    return false;
  }
  return true;
}
 
Example 20
Project: pdi-fastjsoninput-plugin   File: FastJsonInputField.java   View source code 6 votes vote down vote up
public FastJsonInputField(Node fnode) throws KettleValueException {
	setName(XMLHandler.getTagValue(fnode, "name"));
	setPath(XMLHandler.getTagValue(fnode, "path"));
	setType(ValueMeta.getType(XMLHandler.getTagValue(fnode, "type")));
	setFormat(XMLHandler.getTagValue(fnode, "format"));
	setCurrencySymbol(XMLHandler.getTagValue(fnode, "currency"));
	setDecimalSymbol(XMLHandler.getTagValue(fnode, "decimal"));
	setGroupSymbol(XMLHandler.getTagValue(fnode, "group"));
	setLength(Const.toInt(XMLHandler.getTagValue(fnode, "length"), -1));
	setPrecision(Const
			.toInt(XMLHandler.getTagValue(fnode, "precision"), -1));
	setTrimType(getTrimTypeByCode(XMLHandler
			.getTagValue(fnode, "trim_type")));
	setRepeated(!"N".equalsIgnoreCase(XMLHandler.getTagValue(fnode,
			"repeat")));
}
 
Example 21
Project: pdi-zendesk-plugin   File: ZendeskInputGroupMembershipsDialog.java   View source code 6 votes vote down vote up
/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
  wSubDomain.setText( Const.NVL( input.getSubDomain(), "" ) );
  wUsername.setText( Const.NVL( input.getUsername(), "" ) );
  wPassword.setText( Const.NVL( input.getPassword(), "" ) );
  wToken.setSelection( input.isToken() );
  wGroupMembershipIdFieldname.setText( Const.NVL( input.getGroupMembershipIdFieldname() , "" ) );
  wGroupMembershipUrlFieldname.setText( Const.NVL( input.getGroupMembershipUrlFieldname() , "" ) );
  wUserIdFieldname.setText( Const.NVL( input.getUserIdFieldname() , "" ) );
  wGroupIdFieldname.setText( Const.NVL( input.getGroupIdFieldname() , "" ) );
  wCreatedAtFieldname.setText( Const.NVL( input.getCreatedAtFieldname() , "" ) );
  wUpdatedAtFieldname.setText( Const.NVL( input.getUpdatedAtFieldname() , "" ) );
  wDefaultGroupFieldname.setText( Const.NVL( input.getDefaultGroupFieldname() , "" ) );

  wStepname.selectAll();
  wStepname.setFocus();
}
 
Example 22
Project: pdi-zendesk-plugin   File: ZendeskInputHCCategoryDialog.java   View source code 6 votes vote down vote up
/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
  wSubDomain.setText( Const.NVL( input.getSubDomain(), "" ) );
  wUsername.setText( Const.NVL( input.getUsername(), "" ) );
  wPassword.setText( Const.NVL( input.getPassword(), "" ) );
  wToken.setSelection( input.isToken() );
  wCategoryIdFieldname.setText( Const.NVL( input.getCategoryIdFieldname(), "" ) );
  wCategoryUrlFieldname.setText( Const.NVL( input.getCategoryUrlFieldname(), "" ) );
  wCategoryNameFieldname.setText( Const.NVL( input.getCategoryNameFieldname(), "" ) );
  wDescriptionFieldname.setText( Const.NVL( input.getDescriptionFieldname(), "" ) );
  wLocaleFieldname.setText( Const.NVL( input.getLocaleFieldname(), "" ) );
  wSourceLocaleFieldname.setText( Const.NVL( input.getSourceLocaleFieldname(), "" ) );
  wCategoryHtmlUrlFieldname.setText( Const.NVL( input.getCategoryHtmlUrlFieldname(), "" ) );
  wOutdatedFieldname.setText( Const.NVL( input.getOutdatedFieldname(), "" ) );
  wPositionFieldname.setText( Const.NVL( input.getPositionFieldname(), "" ) );
  wCreatedAtFieldname.setText( Const.NVL( input.getCreatedAtFieldname() , "" ) );
  wUpdatedAtFieldname.setText( Const.NVL( input.getUpdatedAtFieldname() , "" ) );

  wStepname.selectAll();
  wStepname.setFocus();
}
 
Example 23
Project: pdi-zendesk-plugin   File: ZendeskInputGroupsDialog.java   View source code 6 votes vote down vote up
/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
  wSubDomain.setText( Const.NVL( input.getSubDomain(), "" ) );
  wUsername.setText( Const.NVL( input.getUsername(), "" ) );
  wPassword.setText( Const.NVL( input.getPassword(), "" ) );
  wToken.setSelection( input.isToken() );
  wGroupIdFieldname.setText( Const.NVL( input.getGroupIdFieldname() , "" ) );
  wGroupUrlFieldname.setText( Const.NVL( input.getGroupUrlFieldname() , "" ) );
  wGroupNameFieldname.setText( Const.NVL( input.getGroupNameFieldname() , "" ) );
  wDeletedFieldname.setText( Const.NVL( input.getDeletedFieldname() , "" ) );
  wCreatedAtFieldname.setText( Const.NVL( input.getCreatedAtFieldname() , "" ) );
  wUpdatedAtFieldname.setText( Const.NVL( input.getUpdatedAtFieldname() , "" ) );

  wStepname.selectAll();
  wStepname.setFocus();
}
 
Example 24
Project: pdi-zendesk-plugin   File: ZendeskInputSuspendedTicketsDialog.java   View source code 6 votes vote down vote up
/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
  wSubDomain.setText( Const.NVL( input.getSubDomain(), "" ) );
  wUsername.setText( Const.NVL( input.getUsername(), "" ) );
  wPassword.setText( Const.NVL( input.getPassword(), "" ) );
  wToken.setSelection( input.isToken() );
  wSuspendedTicketIdFieldname.setText( Const.NVL( input.getSuspendedTicketIdFieldname(), "" ) );
  wSuspendedTicketUrlFieldname.setText( Const.NVL( input.getSuspendedTicketUrlFieldname(), "" ) );
  wAuthorFieldname.setText( Const.NVL( input.getAuthorFieldname(), "" ) );
  wSubjectFieldname.setText( Const.NVL( input.getSubjectFieldname(), "" ) );
  wContentFieldname.setText( Const.NVL( input.getContentFieldname(), "" ) );
  wCauseFieldname.setText( Const.NVL( input.getCauseFieldname(), "" ) );
  wMessageIdFieldname.setText( Const.NVL( input.getMessageIdFieldname(), "" ) );
  wTicketIdFieldname.setText( Const.NVL( input.getTicketIdFieldname(), "" ) );
  wRecipientFieldname.setText( Const.NVL( input.getRecipientFieldname(), "" ) );
  wCreatedAtFieldname.setText( Const.NVL( input.getCreatedAtFieldname(), "" ) );
  wUpdatedAtFieldname.setText( Const.NVL( input.getUpdatedAtFieldname(), "" ) );
  wViaFieldname.setText( Const.NVL( input.getViaFieldname(), "" ) );
  wBrandIdFieldname.setText( Const.NVL( input.getBrandIdFieldname(), "" ) );

  wStepname.selectAll();
  wStepname.setFocus();
}
 
Example 25
Project: pdi-zendesk-plugin   File: ZendeskInputIncrementalDialog.java   View source code 6 votes vote down vote up
/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
  wSubDomain.setText( Const.NVL( input.getSubDomain(), "" ) );
  wUsername.setText( Const.NVL( input.getUsername(), "" ) );
  wPassword.setText( Const.NVL( input.getPassword(), "" ) );
  wToken.setSelection( input.isToken() );
  if ( null == input.getDownloadType() ) {
    input.setChanged();
    wDownloadType.setText( IncrementalType.TICKETS.toString() );
  } else {
    wDownloadType.setText( input.getDownloadType().toString() );
  }
  wFieldname.setText( Const.NVL( input.getTimestampFieldName(), "" ) );
  wOutputFieldname.setText( Const.NVL( input.getOutputFieldName(), "" ) );

  setOutputLabel();
  wStepname.selectAll();
  wStepname.setFocus();
}
 
Example 26
Project: pdi-zendesk-plugin   File: ZendeskInputTicketFieldsDialog.java   View source code 6 votes vote down vote up
/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
  wSubDomain.setText( Const.NVL( input.getSubDomain(), "" ) );
  wUsername.setText( Const.NVL( input.getUsername(), "" ) );
  wPassword.setText( Const.NVL( input.getPassword(), "" ) );
  wToken.setSelection( input.isToken() );
  wTicketFieldIdFieldname.setText( Const.NVL( input.getTicketFieldIdFieldname(), "" ) );
  wTicketFieldUrlFieldname.setText( Const.NVL( input.getTicketFieldUrlFieldname(), "" ) );
  wTicketFieldTypeFieldname.setText( Const.NVL( input.getTicketFieldTypeFieldname(), "" ) );
  wTicketFieldTitleFieldname.setText( Const.NVL( input.getTicketFieldTitleFieldname(), "" ) );
  wTicketFieldActiveFieldname.setText( Const.NVL( input.getTicketFieldActiveFieldname(), "" ) );
  wTicketFieldRequiredFieldname.setText( Const.NVL( input.getTicketFieldRequiredFieldname(), "" ) );
  wTicketFieldVisibleEndUsersFieldname.setText( Const.NVL( input.getTicketFieldVisibleEndUsersFieldname(), "" ) );
  wCreatedAtFieldname.setText( Const.NVL( input.getCreatedAtFieldname(), "" ) );
  wUpdatedAtFieldname.setText( Const.NVL( input.getUpdatedAtFieldname(), "" ) );

  wStepname.selectAll();
  wStepname.setFocus();
}
 
Example 27
Project: pdi-zendesk-plugin   File: ZendeskInputHCSectionDialog.java   View source code 6 votes vote down vote up
/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
  wSubDomain.setText( Const.NVL( input.getSubDomain(), "" ) );
  wUsername.setText( Const.NVL( input.getUsername(), "" ) );
  wPassword.setText( Const.NVL( input.getPassword(), "" ) );
  wToken.setSelection( input.isToken() );
  wSectionIdFieldname.setText( Const.NVL( input.getSectionIdFieldname(), "" ) );
  wSectionUrlFieldname.setText( Const.NVL( input.getSectionUrlFieldname(), "" ) );
  wSectionNameFieldname.setText( Const.NVL( input.getSectionNameFieldname(), "" ) );
  wCategoryIdFieldname.setText( Const.NVL( input.getCategoryIdFieldname(), "" ) );
  wLocaleFieldname.setText( Const.NVL( input.getLocaleFieldname(), "" ) );
  wSourceLocaleFieldname.setText( Const.NVL( input.getSourceLocaleFieldname(), "" ) );
  wSectionHtmlUrlFieldname.setText( Const.NVL( input.getSectionHtmlUrlFieldname(), "" ) );
  wOutdatedFieldname.setText( Const.NVL( input.getOutdatedFieldname(), "" ) );
  wPositionFieldname.setText( Const.NVL( input.getPositionFieldname(), "" ) );
  wCreatedAtFieldname.setText( Const.NVL( input.getCreatedAtFieldname() , "" ) );
  wUpdatedAtFieldname.setText( Const.NVL( input.getUpdatedAtFieldname() , "" ) );

  wStepname.selectAll();
  wStepname.setFocus();
}
 
Example 28
Project: pdi-zendesk-plugin   File: ZendeskOutputSuspendedTicketsDialog.java   View source code 6 votes vote down vote up
/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
  wSubDomain.setText( Const.NVL( input.getSubDomain(), "" ) );
  wUsername.setText( Const.NVL( input.getUsername(), "" ) );
  wPassword.setText( Const.NVL( input.getPassword(), "" ) );
  wToken.setSelection( input.isToken() );
  if ( null == input.getAction() ) {
    input.setChanged();
    wActionType.setText( SuspendedTicketAction.DELETE.toString() );
  } else {
    wActionType.setText( input.getAction().toString() );
  }
  wFieldname.setText( Const.NVL( input.getTicketFieldName(), "" ) );
  wResult.setText( Const.NVL( input.getResultFieldName(), "" ) );

  wStepname.selectAll();
  wStepname.setFocus();
}
 
Example 29
Project: socrata-kettle   File: SocrataPlugin.java   View source code 6 votes vote down vote up
public boolean init(StepMetaInterface smi, StepDataInterface sdi) {
    meta = (SocrataPluginMeta) smi;
    data = (SocrataPluginData) sdi;

    if (super.init(smi, sdi)) {
        try {
            binaryNullValue = new byte[meta.getOutputFields().length][];
            for (int i = 0; i < meta.getOutputFields().length; i++) {
                binaryNullValue[i] = null;
                String nullString = meta.getOutputFields()[i].getNullString();
                if (!Const.isEmpty(nullString)) {
                    binaryNullValue[i] = nullString.getBytes();
                }
            }
        } catch (Exception e) {
            logError("Couldn't initialize binary data fields", e);
            setErrors(1);
            stopAll();
        }

        return true;

    }

    return false;
}
 
Example 30
Project: pentaho-pdi-dataset   File: ExecuteTestsDialog.java   View source code 6 votes vote down vote up
private void ok() {
  if ( Const.isEmpty( wStepname.getText() ) ) {
    return;
  }

  stepname = wStepname.getText(); // return value

  input.setChanged();
  
  input.setTypeToExecute( DataSetConst.getTestTypeForDescription(wTypeToExecute.getText()) );
  input.setTransformationNameField( wTransformationNameField.getText() );
  input.setUnitTestNameField( wUnitTestNameField.getText() );
  input.setDataSetNameField( wDataSetNameField.getText() );
  input.setStepNameField( wStepNameField.getText() );
  input.setErrorField( wErrorField.getText() );
  input.setCommentField( wCommentField.getText() );
  
  dispose();
}
 
Example 31
Project: pentaho-pdi-dataset   File: TransUnitTestDialog.java   View source code 6 votes vote down vote up
public void getData() {

    wName.setText( Const.NVL( transUnitTest.getName(), "" ) );
    wDescription.setText( Const.NVL( transUnitTest.getDescription(), "" ) );
    wTestType.setText( Const.NVL( DataSetConst.getTestTypeDescription(transUnitTest.getType()), "") );
    wFilename.setText( Const.NVL( transUnitTest.getFilename(), ""));
    
    for ( int i = 0; i < transUnitTest.getDatabaseReplacements().size(); i++ ) {
      TransUnitTestDatabaseReplacement dbReplacement = transUnitTest.getDatabaseReplacements().get( i );
      int colnr = 1;
      wDbReplacements.setText( Const.NVL( dbReplacement.getOriginalDatabaseName(), ""), colnr++, i );
      wDbReplacements.setText( Const.NVL( dbReplacement.getReplacementDatabaseName(), "" ), colnr++, i );
    }
    wDbReplacements.removeEmptyRows();
    wDbReplacements.setRowNums();

    wName.setFocus();
  }
 
Example 32
Project: pentaho-pdi-dataset   File: DataSetDialog.java   View source code 6 votes vote down vote up
public void getData() {

    for ( DataSetGroup group : groups ) {
      wDataSetGroup.add( group.getName() );
    }

    wName.setText( Const.NVL( dataSet.getName(), "" ) );
    wDescription.setText( Const.NVL( dataSet.getDescription(), "" ) );
    wDataSetGroup.setText( Const.NVL( dataSet.getGroup() == null ? null : dataSet.getGroup().getName(), "" ) );
    wTableName.setText( Const.NVL( dataSet.getTableName(), "" ) );
    for ( int i = 0; i < dataSet.getFields().size(); i++ ) {
      DataSetField field = dataSet.getFields().get( i );
      int colnr = 1;
      wFieldMapping.setText( Const.NVL( field.getFieldName(), "" ), colnr++, i );
      wFieldMapping.setText( Const.NVL( field.getColumnName(), "" ), colnr++, i );
      wFieldMapping.setText( ValueMetaFactory.getValueMetaName( field.getType() ), colnr++, i );
      wFieldMapping.setText( field.getLength() >= 0 ? Integer.toString( field.getLength() ) : "", colnr++, i );
      wFieldMapping.setText( field.getPrecision() >= 0 ? Integer.toString( field.getPrecision() ) : "", colnr++, i );
      wFieldMapping.setText( Const.NVL( field.getComment(), "" ), colnr++, i );
    }
    wName.setFocus();
  }
 
Example 33
Project: pentaho-pdi-dataset   File: DataSetDialog.java   View source code 6 votes vote down vote up
/**
 * @param set The data set to load the dialog information into
 */
public void getInfo( DataSet set ) {

  set.setName( wName.getText() );
  set.setDescription( wDescription.getText() );
  set.setGroup( DataSetConst.findDataSetGroup( groups, wDataSetGroup.getText() ) );
  set.setTableName( wTableName.getText() );
  set.getFields().clear();
  int nrFields = wFieldMapping.nrNonEmpty();
  for ( int i = 0; i < nrFields; i++ ) {
    TableItem item = wFieldMapping.getNonEmpty( i );
    int colnr = 1;
    String fieldName = item.getText( colnr++ );
    String columnName = item.getText( colnr++ );
    int type = ValueMetaFactory.getIdForValueMeta( item.getText( colnr++ ) );
    int length = Const.toInt( item.getText( colnr++ ), -1 );
    int precision = Const.toInt( item.getText( colnr++ ), -1 );
    String comment = item.getText( colnr++ );

    DataSetField field = new DataSetField( fieldName, columnName, type, length, precision, comment );
    set.getFields().add( field );
  }

}
 
Example 34
Project: pentaho-pdi-dataset   File: SpoonFlagUnitTestExtensionPoint.java   View source code 6 votes vote down vote up
@Override
public void callExtensionPoint( LogChannelInterface log, Object object ) throws KettleException {
  if ( !( object instanceof TransMeta ) ) {
    return;
  }
  
  TransMeta transMeta = (TransMeta) object;
  
  String unitTestName = transMeta.getAttribute( DataSetConst.ATTR_GROUP_DATASET, DataSetConst.ATTR_TRANS_SELECTED_UNIT_TEST_NAME );
  
  if (!Const.isEmpty( unitTestName )) {
    // We're running in Spoon and there's a unit test selected : test it
    //
    System.out.println( "==== Running unit test on this transformation ====" );
    transMeta.setVariable( DataSetConst.VAR_RUN_UNIT_TEST, "Y" );
  }
}
 
Example 35
Project: pentaho-pdi-dataset   File: DataSetHelper.java   View source code 6 votes vote down vote up
private String validateDataSetGroup( DataSetGroup dataSetGroup, String previousName, List<String> groupNames ) {

    String message = null;

    String newName = dataSetGroup.getName();
    if ( Const.isEmpty( newName ) ) {
      message = BaseMessages.getString( PKG, "DataSetHelper.DataSetGroup.NoNameSpecified.Message" );
    } else if ( !Const.isEmpty( previousName ) && !previousName.equals( newName ) ) {
      message = BaseMessages.getString( PKG, "DataSetHelper.DataSetGroup.RenamingOfADataSetNotSupported.Message" );
    } else if ( dataSetGroup.getDatabaseMeta() == null ) {
      message = BaseMessages.getString( PKG, "DataSetHelper.DataSetGroup.NoDatabaseSpecified.Message" );
    } else {
      if ( Const.isEmpty( previousName ) && Const.indexOfString( newName, groupNames ) >= 0 ) {
        message = BaseMessages.getString( PKG, "DataSetHelper.DataSetGroup.AGroupWithNameExists.Message", newName );
      }
    }

    return message;
  }
 
Example 36
Project: pentaho-pdi-dataset   File: DataSetHelper.java   View source code 6 votes vote down vote up
private String validateDataSet( DataSet dataSet, String previousName, List<String> setNames ) {

    String message = null;

    String newName = dataSet.getName();
    if ( Const.isEmpty( newName ) ) {
      message = BaseMessages.getString( PKG, "DataSetHelper.DataSet.NoNameSpecified.Message" );
    } else if ( !Const.isEmpty( previousName ) && !previousName.equals( newName ) ) {
      message = BaseMessages.getString( PKG, "DataSetHelper.DataSet.RenamingOfADataSetsNotSupported.Message" );
    } else if ( dataSet.getGroup() == null ) {
      message = BaseMessages.getString( PKG, "DataSetHelper.DataSet.NoGroupSpecified.Message" );
    } else {
      if ( Const.isEmpty( previousName ) && Const.indexOfString( newName, setNames ) >= 0 ) {
        message = BaseMessages.getString( PKG, "DataSetHelper.DataSet.ADataSetWithNameExists.Message", newName );
      }
    }

    return message;
  }
 
Example 37
Project: pentaho-pdi-dataset   File: DataSetHelper.java   View source code 6 votes vote down vote up
private boolean checkTestPresent(Spoon spoon, TransMeta transMeta) {
  
  spoon.getLog().logBasic("Check test present...");
  
  String testName = transMeta.getAttribute( DataSetConst.ATTR_GROUP_DATASET, DataSetConst.ATTR_TRANS_SELECTED_UNIT_TEST_NAME );
  if (!Const.isEmpty( testName )) {
    return false;
  }
  
  // there is no test defined of selected in the transformation.
  // Show a warning
  //
  MessageBox box = new MessageBox(spoon.getShell(), SWT.OK | SWT.ICON_INFORMATION );
  box.setMessage("Please create a test-case first by left clicking on the test icon.");
  box.setText("First create a test-case");
  box.open();
  
  return true;
}
 
Example 38
Project: pentaho-cpython-plugin   File: CPythonScriptExecutorData.java   View source code 6 votes vote down vote up
public static void initPython() throws KettleException {
  // check python availability
  if ( !PythonSession.pythonAvailable() ) {
    // initialize...
    PythonSession.initSession( "python" );
  } else {
    return;
  }
  if ( !PythonSession.pythonAvailable() ) {
    String pyCheckResults = PythonSession.getPythonEnvCheckResults();
    if ( !Const.isEmpty( pyCheckResults ) ) {
      throw new KettleException(
          BaseMessages.getString( PKG, "CPythonScriptExecutor.Error.PythonInitializationProblem" ) + ":\n\n"
              + pyCheckResults );
    } else {
      throw new KettleException(
          BaseMessages.getString( PKG, "CPythonScriptExecutor.Error.PythonInitializationProblem" ) );
    }
  }
}
 
Example 39
Project: pentaho-cpython-plugin   File: CPythonScriptExecutorDialog.java   View source code 6 votes vote down vote up
protected void checkWidgets() {
  wtvScriptLocation.setEnabled( wbLoadScriptFile.getSelection() );
  wstcScriptEditor.setEnabled( !wbLoadScriptFile.getSelection() );
  if ( wbLoadScriptFile.getSelection() ) {
    wtvScriptLocation.setEditable( true );
    wstcScriptEditor.getStyledText().setBackground( GUIResource.getInstance().getColorDemoGray() );
  } else {
    wtvScriptLocation.setEditable( false );
    wstcScriptEditor.getStyledText().setBackground( GUIResource.getInstance().getColorWhite() );
  }
  wbScriptBrowse.setEnabled( wbLoadScriptFile.getSelection() );

  String currVars = wtvPyVarsToGet.getText();
  if ( !Const.isEmpty( currVars ) ) {
    List<String> varList = stringToList( currVars );
    wbGetFields.setEnabled( varList.size() == 1 );
    wbIncludeRowIndex.setEnabled( varList.size() == 1 );
  }
}
 
Example 40
Project: pentaho-cpython-plugin   File: CPythonScriptExecutorDialog.java   View source code 6 votes vote down vote up
protected void setInputToFramesTableFields( CPythonScriptExecutorMeta meta ) {
  List<String> frameNames = meta.getFrameNames();
  List<StreamInterface> infoStreams = meta.getStepIOMeta().getInfoStreams();

  wtvInputFrames.clearAll();
  for ( int i = 0; i < infoStreams.size(); i++ ) {
    String stepName = infoStreams.get( i ).getStepname();
    String frameName = frameNames.get( i );

    TableItem item = new TableItem( wtvInputFrames.table, SWT.NONE );
    item.setText( 1, Const.NVL( stepName, "" ) ); //$NON-NLS-1$
    item.setText( 2, Const.NVL( frameName, "" ) ); //$NON-NLS-1$
  }

  wtvInputFrames.removeEmptyRows();
  wtvInputFrames.setRowNums();
  wtvInputFrames.optWidth( true );
}