本文整理汇总了Java中org.pentaho.di.core.SourceToTargetMapping类的典型用法代码示例。如果您正苦于以下问题:Java SourceToTargetMapping类的具体用法?Java SourceToTargetMapping怎么用?Java SourceToTargetMapping使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SourceToTargetMapping类属于org.pentaho.di.core包,在下文中一共展示了SourceToTargetMapping类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateFieldMapping
import org.pentaho.di.core.SourceToTargetMapping; //导入依赖的package包/类
/**
* Create a new field mapping between source and target steps.
*
* @param shell the shell of the parent window
* @param sourceFields the source fields
* @param targetFields the target fields
* @param fieldMapping the list of source to target mappings to default to (can be empty but not null)
*
* @throws KettleException in case something goes wrong during the field mapping
*
*/
public static final void generateFieldMapping(Shell shell, RowMetaInterface sourceFields, RowMetaInterface targetFields, List<SourceToTargetMapping> fieldMapping) throws KettleException {
// Build the mapping: let the user decide!!
String[] source = sourceFields.getFieldNames();
for (int i = 0; i < source.length; i++) {
ValueMetaInterface v = sourceFields.getValueMeta(i);
source[i] += EnterMappingDialog.STRING_ORIGIN_SEPARATOR + v.getOrigin() + ")";
}
String[] target = targetFields.getFieldNames();
EnterMappingDialog dialog = new EnterMappingDialog(shell, source, target, fieldMapping);
List<SourceToTargetMapping> newMapping = dialog.open();
if (newMapping!=null) {
fieldMapping.clear();
fieldMapping.addAll(newMapping);
}
}
示例2: add
import org.pentaho.di.core.SourceToTargetMapping; //导入依赖的package包/类
private void add()
{
if (wSource.getSelectionCount()==1 && wTarget.getSelectionCount()==1)
{
String sourceString = wSource.getSelection()[0];
String targetString = wTarget.getSelection()[0];
int srcIndex = Const.indexOfString(sourceString, sourceList);
int tgtIndex = Const.indexOfString(targetString, targetList);
if (srcIndex >= 0 && tgtIndex >= 0)
{
// New mapping: add it to the list...
SourceToTargetMapping mapping = new SourceToTargetMapping(srcIndex, tgtIndex);
mappings.add(mapping);
refreshMappings();
}
}
}
示例3: generateFieldMapping
import org.pentaho.di.core.SourceToTargetMapping; //导入依赖的package包/类
/**
* Create a new field mapping between source and target steps.
*
* @param shell the shell of the parent window
* @param sourceFields the source fields
* @param targetFields the target fields
* @param fieldMapping the list of source to target mappings to default to (can be empty but not null)
* @throws KettleException in case something goes wrong during the field mapping
*/
public static final void generateFieldMapping( Shell shell, RowMetaInterface sourceFields,
RowMetaInterface targetFields,
java.util.List<SourceToTargetMapping> fieldMapping ) throws
KettleException {
// Build the mapping: let the user decide!!
String[] source = sourceFields.getFieldNames();
for (int i = 0; i < source.length; i++) {
ValueMetaInterface v = sourceFields.getValueMeta(i);
source[i] += EnterMappingDialog.STRING_ORIGIN_SEPARATOR + v.getOrigin() + ")";
}
String[] target = targetFields.getFieldNames();
EnterMappingDialog dialog = new EnterMappingDialog(shell, source, target, fieldMapping);
java.util.List<SourceToTargetMapping> newMapping = dialog.open();
if (newMapping != null) {
fieldMapping.clear();
fieldMapping.addAll(newMapping);
}
}
示例4: generateFieldMapping
import org.pentaho.di.core.SourceToTargetMapping; //导入依赖的package包/类
/**
* Create a new field mapping between source and target steps.
*
* @param shell
* the shell of the parent window
* @param sourceFields
* the source fields
* @param targetFields
* the target fields
* @param fieldMapping
* the list of source to target mappings to default to (can be empty but not null)
* @throws KettleException
* in case something goes wrong during the field mapping
*/
public static final void generateFieldMapping( Shell shell, RowMetaInterface sourceFields,
RowMetaInterface targetFields, java.util.List<SourceToTargetMapping> fieldMapping ) throws KettleException {
// Build the mapping: let the user decide!!
String[] source = sourceFields.getFieldNames();
for ( int i = 0; i < source.length; i++ ) {
ValueMetaInterface v = sourceFields.getValueMeta( i );
source[i] += EnterMappingDialog.STRING_ORIGIN_SEPARATOR + v.getOrigin() + ")";
}
String[] target = targetFields.getFieldNames();
EnterMappingDialog dialog = new EnterMappingDialog( shell, source, target, fieldMapping );
java.util.List<SourceToTargetMapping> newMapping = dialog.open();
if ( newMapping != null ) {
fieldMapping.clear();
fieldMapping.addAll( newMapping );
}
}
示例5: generateFieldMapping
import org.pentaho.di.core.SourceToTargetMapping; //导入依赖的package包/类
/**
* Create a new field mapping between source and target steps.
*
* @param shell the shell of the parent window
* @param sourceFields the source fields
* @param targetFields the target fields
* @param fieldMapping the list of source to target mappings to default to (can be empty but not null)
* @throws KettleException in case something goes wrong during the field mapping
*/
public static final void generateFieldMapping( Shell shell, RowMetaInterface sourceFields,
RowMetaInterface targetFields,
List<SourceToTargetMapping> fieldMapping ) throws KettleException {
// Build the mapping: let the user decide!!
String[] source = sourceFields.getFieldNames();
for ( int i = 0; i < source.length; i++ ) {
ValueMetaInterface v = sourceFields.getValueMeta( i );
source[ i ] += EnterMappingDialog.STRING_ORIGIN_SEPARATOR + v.getOrigin() + ")";
}
String[] target = targetFields.getFieldNames();
EnterMappingDialog dialog = new EnterMappingDialog( shell, source, target, fieldMapping );
List<SourceToTargetMapping> newMapping = dialog.open();
if ( newMapping != null ) {
fieldMapping.clear();
fieldMapping.addAll( newMapping );
}
}
示例6: add
import org.pentaho.di.core.SourceToTargetMapping; //导入依赖的package包/类
private void add() {
if ( wSource.getSelectionCount() == 1 && wTarget.getSelectionCount() == 1 ) {
String sourceString = wSource.getSelection()[0];
String targetString = wTarget.getSelection()[0];
int srcIndex = Const.indexOfString( sourceString, sourceList );
int tgtIndex = Const.indexOfString( targetString, targetList );
if ( srcIndex >= 0 && tgtIndex >= 0 ) {
// New mapping: add it to the list...
SourceToTargetMapping mapping = new SourceToTargetMapping( srcIndex, tgtIndex );
mappings.add( mapping );
refreshMappings();
}
}
}
示例7: EnterMappingDialog
import org.pentaho.di.core.SourceToTargetMapping; //导入依赖的package包/类
/**
* Create a new dialog allowing the user to enter a mapping
*
* @param parent the parent shell
* @param source the source values
* @param target the target values
* @param mappings the already selected mappings (ArrayList containing <code>SourceToTargetMapping</code>s)
*/
public EnterMappingDialog(Shell parent, String source[], String target[], java.util.List<SourceToTargetMapping> mappings)
{
super(parent, SWT.NONE);
props = PropsUI.getInstance();
this.sourceList = source;
this.targetList = target;
this.mappings = mappings;
}
示例8: generateFieldMapping
import org.pentaho.di.core.SourceToTargetMapping; //导入依赖的package包/类
/**
* Create a new SelectValues step in between this step and the previous. If
* the previous fields are not there, no mapping can be made, same with the
* required fields.
*
* @param stepMeta
* The target step to map against.
*/
@SuppressWarnings("deprecation") // retry of required fields acquisition
public void generateFieldMapping(TransMeta transMeta, StepMeta stepMeta) {
try {
if (stepMeta != null) {
StepMetaInterface smi = stepMeta.getStepMetaInterface();
RowMetaInterface targetFields = smi.getRequiredFields(transMeta);
if (targetFields.isEmpty()) smi.getRequiredFields(); // retry, get rid of this method in 4.x
RowMetaInterface sourceFields = transMeta.getPrevStepFields(stepMeta);
// Build the mapping: let the user decide!!
String[] source = sourceFields.getFieldNames();
for (int i = 0; i < source.length; i++) {
ValueMetaInterface v = sourceFields.getValueMeta(i);
source[i] += EnterMappingDialog.STRING_ORIGIN_SEPARATOR + v.getOrigin() + ")";
}
String[] target = targetFields.getFieldNames();
EnterMappingDialog dialog = new EnterMappingDialog(shell, source, target);
List<SourceToTargetMapping> mappings = dialog.open();
if (mappings != null) {
// OK, so we now know which field maps where.
// This allows us to generate the mapping using a
// SelectValues Step...
SelectValuesMeta svm = new SelectValuesMeta();
svm.allocate(mappings.size(), 0, 0);
for (int i = 0; i < mappings.size(); i++) {
SourceToTargetMapping mapping = mappings.get(i);
svm.getSelectName()[i] = sourceFields.getValueMeta(mapping.getSourcePosition()).getName();
svm.getSelectRename()[i] = target[mapping.getTargetPosition()];
svm.getSelectLength()[i] = -1;
svm.getSelectPrecision()[i] = -1;
}
// a new comment
// Now that we have the meta-data, create a new step info
// object
String stepName = stepMeta.getName() + " Mapping";
stepName = transMeta.getAlternativeStepname(stepName); // if it's already there, rename it.
StepMeta newStep = new StepMeta("SelectValues", stepName, svm);
newStep.setLocation(stepMeta.getLocation().x + 20, stepMeta.getLocation().y + 20);
newStep.setDraw(true);
transMeta.addStep(newStep);
addUndoNew(transMeta, new StepMeta[] { newStep }, new int[] { transMeta.indexOfStep(newStep) });
// Redraw stuff...
refreshTree();
refreshGraph();
}
} else {
throw new KettleException("There is no target to do a field mapping against!");
}
} catch (KettleException e) {
new ErrorDialog(shell, "Error creating mapping", "There was an error when Kettle tried to generate a field mapping against the target step", e);
}
}
示例9: generateFieldMapping
import org.pentaho.di.core.SourceToTargetMapping; //导入依赖的package包/类
/**
* Create a new SelectValues step in between this step and the previous. If
* the previous fields are not there, no mapping can be made, same with the
* required fields.
*
* @param stepMeta
* The target step to map against.
*/
// retry of required fields acquisition
public void generateFieldMapping(TransMeta transMeta, StepMeta stepMeta) {
try {
if (stepMeta != null) {
StepMetaInterface smi = stepMeta.getStepMetaInterface();
RowMetaInterface targetFields = smi.getRequiredFields(transMeta);
RowMetaInterface sourceFields = transMeta.getPrevStepFields(stepMeta);
// Build the mapping: let the user decide!!
String[] source = sourceFields.getFieldNames();
for (int i = 0; i < source.length; i++) {
ValueMetaInterface v = sourceFields.getValueMeta(i);
source[i] += EnterMappingDialog.STRING_ORIGIN_SEPARATOR + v.getOrigin() + ")";
}
String[] target = targetFields.getFieldNames();
EnterMappingDialog dialog = new EnterMappingDialog(shell, source, target);
List<SourceToTargetMapping> mappings = dialog.open();
if (mappings != null) {
// OK, so we now know which field maps where.
// This allows us to generate the mapping using a
// SelectValues Step...
SelectValuesMeta svm = new SelectValuesMeta();
svm.allocate(mappings.size(), 0, 0);
for (int i = 0; i < mappings.size(); i++) {
SourceToTargetMapping mapping = mappings.get(i);
svm.getSelectName()[i] = sourceFields.getValueMeta(mapping.getSourcePosition()).getName();
svm.getSelectRename()[i] = target[mapping.getTargetPosition()];
svm.getSelectLength()[i] = -1;
svm.getSelectPrecision()[i] = -1;
}
// a new comment
// Now that we have the meta-data, create a new step info
// object
String stepName = stepMeta.getName() + " Mapping";
stepName = transMeta.getAlternativeStepname(stepName); // if
// it's
// already
// there,
// rename
// it.
StepMeta newStep = new StepMeta("SelectValues", stepName, svm);
newStep.setLocation(stepMeta.getLocation().x + 20, stepMeta.getLocation().y + 20);
newStep.setDraw(true);
transMeta.addStep(newStep);
addUndoNew(transMeta, new StepMeta[] { newStep }, new int[] { transMeta.indexOfStep(newStep) });
// Redraw stuff...
refreshTree();
refreshGraph();
}
} else {
throw new KettleException("There is no target to do a field mapping against!");
}
} catch (KettleException e) {
new ErrorDialog(shell, "Error creating mapping",
"There was an error when Kettle tried to generate a field mapping against the target step", e);
}
}
示例10: generateFieldMapping
import org.pentaho.di.core.SourceToTargetMapping; //导入依赖的package包/类
/**
* Create a new SelectValues step in between this step and the previous. If the previous fields are not there, no
* mapping can be made, same with the required fields.
*
* @param stepMeta
* The target step to map against.
*/
// retry of required fields acquisition
public void generateFieldMapping( TransMeta transMeta, StepMeta stepMeta ) {
try {
if ( stepMeta != null ) {
StepMetaInterface smi = stepMeta.getStepMetaInterface();
RowMetaInterface targetFields = smi.getRequiredFields( transMeta );
RowMetaInterface sourceFields = transMeta.getPrevStepFields( stepMeta );
// Build the mapping: let the user decide!!
String[] source = sourceFields.getFieldNames();
for ( int i = 0; i < source.length; i++ ) {
ValueMetaInterface v = sourceFields.getValueMeta( i );
source[i] += EnterMappingDialog.STRING_ORIGIN_SEPARATOR + v.getOrigin() + ")";
}
String[] target = targetFields.getFieldNames();
EnterMappingDialog dialog = new EnterMappingDialog( shell, source, target );
List<SourceToTargetMapping> mappings = dialog.open();
if ( mappings != null ) {
// OK, so we now know which field maps where.
// This allows us to generate the mapping using a
// SelectValues Step...
SelectValuesMeta svm = new SelectValuesMeta();
svm.allocate( mappings.size(), 0, 0 );
//CHECKSTYLE:Indentation:OFF
for ( int i = 0; i < mappings.size(); i++ ) {
SourceToTargetMapping mapping = mappings.get( i );
svm.getSelectFields()[i].setName( sourceFields.getValueMeta( mapping.getSourcePosition() ).getName() );
svm.getSelectFields()[i].setRename( target[mapping.getTargetPosition()] );
svm.getSelectFields()[i].setLength( -1 );
svm.getSelectFields()[i].setPrecision( -1 );
}
// a new comment. Sincerely yours CO ;)
// Now that we have the meta-data, create a new step info object
String stepName = stepMeta.getName() + " Mapping";
stepName = transMeta.getAlternativeStepname( stepName ); // if
// it's already there, rename it.
StepMeta newStep = new StepMeta( "SelectValues", stepName, svm );
newStep.setLocation( stepMeta.getLocation().x + 20, stepMeta.getLocation().y + 20 );
newStep.setDraw( true );
transMeta.addStep( newStep );
addUndoNew( transMeta, new StepMeta[] { newStep }, new int[] { transMeta.indexOfStep( newStep ) } );
// Redraw stuff...
refreshTree();
refreshGraph();
}
} else {
throw new KettleException( "There is no target to do a field mapping against!" );
}
} catch ( KettleException e ) {
new ErrorDialog(
shell, "Error creating mapping",
"There was an error when Kettle tried to generate a field mapping against the target step", e );
}
}
示例11: EnterMappingDialog
import org.pentaho.di.core.SourceToTargetMapping; //导入依赖的package包/类
/**
* Create a new dialog allowing the user to enter a mapping
*
* @param parent
* the parent shell
* @param source
* the source values
* @param target
* the target values
* @param mappings
* the already selected mappings (ArrayList containing <code>SourceToTargetMapping</code>s)
*/
public EnterMappingDialog( Shell parent, String[] source, String[] target,
java.util.List<SourceToTargetMapping> mappings ) {
super( parent, SWT.NONE );
props = PropsUI.getInstance();
this.sourceList = source;
this.targetList = target;
this.mappings = mappings;
}