本文整理汇总了Java中org.pentaho.di.openerp.core.FieldMapping类的典型用法代码示例。如果您正苦于以下问题:Java FieldMapping类的具体用法?Java FieldMapping怎么用?Java FieldMapping使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FieldMapping类属于org.pentaho.di.openerp.core包,在下文中一共展示了FieldMapping类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: putRow
import org.pentaho.di.openerp.core.FieldMapping; //导入依赖的package包/类
private void putRow(Row row, RowMetaInterface rowMeta) throws KettleStepException {
ArrayList<FieldMapping> mappings = meta.getMappings();
Object [] copyRow = new Object[mappings.size()];
int i = 0;
for (FieldMapping map : mappings){
Object value = row.get(map.source_field);
if (map.source_index >= 0 && value != null && value instanceof Object [])
copyRow[i] = (((Object []) value).length == 0 ? null : ((Object []) value)[map.source_index]);
else
copyRow[i] = value;
copyRow[i] = fixType(map, copyRow[i]);
i++;
}
putRow(rowMeta, copyRow);
}
示例2: fixType
import org.pentaho.di.openerp.core.FieldMapping; //导入依赖的package包/类
private Object fixType(FieldMapping map, Object value){
// Nothing to fix
if (value == null)
return null;
Object fixedValue = value;
if (map.target_field_type == ValueMetaInterface.TYPE_INTEGER)
fixedValue = Long.parseLong(value.toString());
else if (map.target_field_type == ValueMetaInterface.TYPE_NUMBER)
fixedValue = Double.parseDouble(value.toString());
// ONE2MANY and MANY2MANY fields
else if (map.target_field_type == ValueMetaInterface.TYPE_STRING && value instanceof Object []){
String stringValue = "";
for(Object singleValue : (Object []) value)
stringValue += "," + singleValue.toString();
fixedValue = stringValue.substring(1);
}
return fixedValue;
}
示例3: getFieldMappings
import org.pentaho.di.openerp.core.FieldMapping; //导入依赖的package包/类
private ArrayList<FieldMapping> getFieldMappings(boolean showError){
if (addConnectionLine.getText() != null) {
DatabaseMeta dbMeta = transMeta.findDatabase(addConnectionLine.getText());
if (dbMeta != null) {
try {
OpenERPObjectInputData data = new OpenERPObjectInputData(dbMeta);
data.helper.StartSession();
ArrayList<FieldMapping> mappings = data.helper.getDefaultFieldMappings(comboModelName.getText());
return mappings;
} catch (Exception e) {
if (showError)
new ErrorDialog(shell, BaseMessages.getString(PKG, "OpenERPObjectInputDialog.ConnectionErrorTitle"), BaseMessages.getString(PKG, "OpenERPObjectInputDialog.ConnectionErrorString"), e);
return null;
}
}
}
return null;
}
示例4: putRow
import org.pentaho.di.openerp.core.FieldMapping; //导入依赖的package包/类
private void putRow( Row row, RowMetaInterface rowMeta ) throws KettleStepException {
ArrayList<FieldMapping> mappings = meta.getMappings();
Object[] copyRow = new Object[mappings.size()];
int i = 0;
for ( FieldMapping map : mappings ) {
Object value = row.get( map.source_field );
if ( map.source_index >= 0 && value != null && value instanceof Object[] ) {
copyRow[i] = ( ( (Object[]) value ).length == 0 ? null : ( (Object[]) value )[map.source_index] );
} else {
copyRow[i] = value;
}
copyRow[i] = fixType( map, copyRow[i] );
i++;
}
putRow( rowMeta, copyRow );
}
示例5: fixType
import org.pentaho.di.openerp.core.FieldMapping; //导入依赖的package包/类
private Object fixType( FieldMapping map, Object value ) {
// Nothing to fix
if ( value == null ) {
return null;
}
Object fixedValue = value;
if ( map.target_field_type == ValueMetaInterface.TYPE_INTEGER ) {
fixedValue = Long.parseLong( value.toString() );
} else if ( map.target_field_type == ValueMetaInterface.TYPE_NUMBER ) {
fixedValue = Double.parseDouble( value.toString() );
// ONE2MANY and MANY2MANY fields
} else if ( map.target_field_type == ValueMetaInterface.TYPE_STRING && value instanceof Object[] ) {
String stringValue = "";
for ( Object singleValue : (Object[]) value ) {
stringValue += "," + singleValue.toString();
}
fixedValue = stringValue.substring( 1 );
}
return fixedValue;
}
示例6: fillFilterCombos
import org.pentaho.di.openerp.core.FieldMapping; //导入依赖的package包/类
private void fillFilterCombos( ArrayList<FieldMapping> mappings ) {
ArrayList<String> fieldList = new ArrayList<String>();
for ( FieldMapping map : mappings ) {
if ( !fieldList.contains( map.source_field ) ) {
fieldList.add( map.source_field );
}
}
String[] fieldStringList = new String[fieldList.size()];
fieldStringList = fieldList.toArray( fieldStringList );
Arrays.sort( fieldStringList, String.CASE_INSENSITIVE_ORDER );
filterViewColinf[0].setComboValues( FilterHelper.getOperators() );
filterViewColinf[1].setComboValues( fieldStringList );
filterViewColinf[2].setComboValues( FilterHelper.getComparators() );
tableViewFilter.optWidth( true );
}
示例7: getFieldMappings
import org.pentaho.di.openerp.core.FieldMapping; //导入依赖的package包/类
private ArrayList<FieldMapping> getFieldMappings( boolean showError ) {
if ( addConnectionLine.getText() != null ) {
DatabaseMeta dbMeta = transMeta.findDatabase( addConnectionLine.getText() );
if ( dbMeta != null ) {
try {
OpenERPObjectInputData data = new OpenERPObjectInputData( dbMeta );
data.helper.StartSession();
ArrayList<FieldMapping> mappings = data.helper.getDefaultFieldMappings( comboModelName.getText() );
return mappings;
} catch ( Exception e ) {
if ( showError ) {
new ErrorDialog( shell, BaseMessages.getString( PKG, "OpenERPObjectInputDialog.ConnectionErrorTitle" ),
BaseMessages.getString( PKG, "OpenERPObjectInputDialog.ConnectionErrorString" ), e );
}
return null;
}
}
}
return null;
}
示例8: getRowMeta
import org.pentaho.di.openerp.core.FieldMapping; //导入依赖的package包/类
public RowMetaInterface getRowMeta(){
RowMetaInterface rowMeta = new RowMeta();
for (FieldMapping map : this.getMappings()){
rowMeta.addValueMeta(new ValueMeta(map.target_field, map.target_field_type));
}
return rowMeta;
}
示例9: getXML
import org.pentaho.di.openerp.core.FieldMapping; //导入依赖的package包/类
public final String getXML() {
StringBuffer retval = new StringBuffer();
retval.append(" ").append(XMLHandler.addTagValue("connection", this.databaseMeta == null ? "": this.databaseMeta.getName()));
retval.append(" ").append(XMLHandler.addTagValue("modelName", this.modelName));
retval.append(" ").append(XMLHandler.addTagValue("readBatchSize", this.readBatchSize));
retval.append(" <mappings>").append(Const.CR);
for (FieldMapping map : this.getMappings()) {
retval.append(" <mapping>").append(Const.CR);
retval.append(" ").append(XMLHandler.addTagValue("source_model",map.source_model));
retval.append(" ").append(XMLHandler.addTagValue("source_field",map.source_field));
retval.append(" ").append(XMLHandler.addTagValue("source_index",map.source_index));
retval.append(" ").append(XMLHandler.addTagValue("target_model",map.target_model));
retval.append(" ").append(XMLHandler.addTagValue("target_field",map.target_field));
retval.append(" ").append(XMLHandler.addTagValue("target_field_label",map.target_field_label));
retval.append(" ").append(XMLHandler.addTagValue("target_field_type",map.target_field_type));
retval.append(" </mapping>").append(Const.CR);
}
retval.append(" </mappings>").append(Const.CR);
retval.append(" <filters>").append(Const.CR);
for (ReadFilter filter : this.getFilterList()) {
retval.append(" <filter>").append(Const.CR);
retval.append(" ").append(XMLHandler.addTagValue("operator",filter.getOperator()));
retval.append(" ").append(XMLHandler.addTagValue("field_name",filter.getFieldName()));
retval.append(" ").append(XMLHandler.addTagValue("comparator",filter.getComparator()));
retval.append(" ").append(XMLHandler.addTagValue("value",filter.getValue()));
retval.append(" </filter>").append(Const.CR);
}
retval.append(" </filters>").append(Const.CR);
return retval.toString();
}
示例10: saveRep
import org.pentaho.di.openerp.core.FieldMapping; //导入依赖的package包/类
@Override
public void saveRep(Repository rep, ObjectId idTransformation,
ObjectId idStep) throws KettleException {
try {
rep.saveDatabaseMetaStepAttribute(idTransformation, idStep, "connection", this.databaseMeta);
rep.saveStepAttribute(idTransformation, idStep, "modelName", this.modelName);
rep.saveStepAttribute(idTransformation, idStep, "readBatchSize", this.readBatchSize);
for (int i=0;i<getMappings().size();i++) {
FieldMapping map = this.getMappings().get(i);
rep.saveStepAttribute(idTransformation, idStep, i, "source_model", map.source_model);
rep.saveStepAttribute(idTransformation, idStep, i, "source_field", map.source_field);
rep.saveStepAttribute(idTransformation, idStep, i, "source_index", map.source_index);
rep.saveStepAttribute(idTransformation, idStep, i, "target_model", map.target_model);
rep.saveStepAttribute(idTransformation, idStep, i, "target_field", map.target_field);
rep.saveStepAttribute(idTransformation, idStep, i, "target_field_label", map.target_field_label);
rep.saveStepAttribute(idTransformation, idStep, i, "target_field_type", map.target_field_type);
}
for (int i=0;i<getFilterList().size();i++) {
ReadFilter filter = this.getFilterList().get(i);
rep.saveStepAttribute(idTransformation, idStep, i, "operator", filter.getOperator());
rep.saveStepAttribute(idTransformation, idStep, i, "field_name", filter.getFieldName());
rep.saveStepAttribute(idTransformation, idStep, i, "comparator", filter.getComparator());
rep.saveStepAttribute(idTransformation, idStep, i, "value", filter.getValue());
}
} catch (Exception e) {
throw new KettleException("Unable to save step information to the repository for idStep=" + idStep, e);
}
}
示例11: getFields
import org.pentaho.di.openerp.core.FieldMapping; //导入依赖的package包/类
private void getFields(){
ArrayList<FieldMapping> mappings = getFieldMappings(false);
if (mappings != null)
populateFielsTable(mappings);
else {
// See if the model exists in the database
String [] modelList = getModelList();
// Server connect problem
if (modelList == null){
getFieldMappings(true);
return;
}
boolean found = false;
for (String model : modelList)
if (model.equals(comboModelName.getText())){
found = true;
break;
}
if (!found){
new ErrorDialog(shell, BaseMessages.getString(PKG, "OpenERPObjectInputDialog.ConnectionErrorTitle"),
BaseMessages.getString(PKG, "OpenERPObjectInputDialog.ConnectionErrorString"),
new Exception(BaseMessages.getString(PKG, "OpenERPObjectInputDialog.ModelNotFoundError", comboModelName.getText())));
return;
}
}
}
示例12: fillFilterCombos
import org.pentaho.di.openerp.core.FieldMapping; //导入依赖的package包/类
private void fillFilterCombos(ArrayList<FieldMapping> mappings){
ArrayList<String> fieldList = new ArrayList<String>();
for(FieldMapping map : mappings)
if (!fieldList.contains(map.source_field))
fieldList.add(map.source_field);
String [] fieldStringList = new String[fieldList.size()];
fieldStringList = fieldList.toArray(fieldStringList);
Arrays.sort(fieldStringList,String.CASE_INSENSITIVE_ORDER);
filterViewColinf[0].setComboValues(FilterHelper.getOperators());
filterViewColinf[1].setComboValues(fieldStringList);
filterViewColinf[2].setComboValues(FilterHelper.getComparators());
tableViewFilter.optWidth(true);
}
示例13: getRowMeta
import org.pentaho.di.openerp.core.FieldMapping; //导入依赖的package包/类
public RowMetaInterface getRowMeta() throws KettlePluginException {
RowMetaInterface rowMeta = new RowMeta();
for ( FieldMapping map : this.getMappings() ) {
rowMeta.addValueMeta( ValueMetaFactory.createValueMeta( map.target_field, map.target_field_type ) );
}
return rowMeta;
}
示例14: getXML
import org.pentaho.di.openerp.core.FieldMapping; //导入依赖的package包/类
public final String getXML() {
StringBuffer retval = new StringBuffer();
retval.append( " " ).append(
XMLHandler.addTagValue( "connection", this.databaseMeta == null ? "" : this.databaseMeta.getName() ) );
retval.append( " " ).append( XMLHandler.addTagValue( "modelName", this.modelName ) );
retval.append( " " ).append( XMLHandler.addTagValue( "readBatchSize", this.readBatchSize ) );
retval.append( " <mappings>" ).append( Const.CR );
for ( FieldMapping map : this.getMappings() ) {
retval.append( " <mapping>" ).append( Const.CR );
retval.append( " " ).append( XMLHandler.addTagValue( "source_model", map.source_model ) );
retval.append( " " ).append( XMLHandler.addTagValue( "source_field", map.source_field ) );
retval.append( " " ).append( XMLHandler.addTagValue( "source_index", map.source_index ) );
retval.append( " " ).append( XMLHandler.addTagValue( "target_model", map.target_model ) );
retval.append( " " ).append( XMLHandler.addTagValue( "target_field", map.target_field ) );
retval.append( " " ).append( XMLHandler.addTagValue( "target_field_label", map.target_field_label ) );
retval.append( " " ).append( XMLHandler.addTagValue( "target_field_type", map.target_field_type ) );
retval.append( " </mapping>" ).append( Const.CR );
}
retval.append( " </mappings>" ).append( Const.CR );
retval.append( " <filters>" ).append( Const.CR );
for ( ReadFilter filter : this.getFilterList() ) {
retval.append( " <filter>" ).append( Const.CR );
retval.append( " " ).append( XMLHandler.addTagValue( "operator", filter.getOperator() ) );
retval.append( " " ).append( XMLHandler.addTagValue( "field_name", filter.getFieldName() ) );
retval.append( " " ).append( XMLHandler.addTagValue( "comparator", filter.getComparator() ) );
retval.append( " " ).append( XMLHandler.addTagValue( "value", filter.getValue() ) );
retval.append( " </filter>" ).append( Const.CR );
}
retval.append( " </filters>" ).append( Const.CR );
return retval.toString();
}
示例15: readRep
import org.pentaho.di.openerp.core.FieldMapping; //导入依赖的package包/类
@Override
public void readRep( Repository rep, IMetaStore metaStore, ObjectId idStep, List<DatabaseMeta> databases )
throws KettleException {
try {
this.databaseMeta = rep.loadDatabaseMetaFromStepAttribute( idStep, "connection", databases );
this.modelName = rep.getStepAttributeString( idStep, "modelName" );
this.readBatchSize = Integer.parseInt( rep.getStepAttributeString( idStep, "readBatchSize" ) );
int nrMappings = rep.countNrStepAttributes( idStep, "source_model" );
for ( int i = 0; i < nrMappings; i++ ) {
FieldMapping map = new FieldMapping();
map.source_model = rep.getStepAttributeString( idStep, i, "source_model" );
map.source_field = rep.getStepAttributeString( idStep, i, "source_field" );
map.source_index = Integer.valueOf( rep.getStepAttributeString( idStep, i, "source_index" ) );
map.target_model = rep.getStepAttributeString( idStep, i, "target_model" );
map.target_field = rep.getStepAttributeString( idStep, i, "target_field" );
map.target_field_label = rep.getStepAttributeString( idStep, i, "target_field_label" );
map.target_field_type = Integer.valueOf( rep.getStepAttributeString( idStep, i, "target_field_type" ) );
this.getMappings().add( map );
}
int nrFilters = rep.countNrStepAttributes( idStep, "field_name" );
for ( int i = 0; i < nrFilters; i++ ) {
ReadFilter filter = new ReadFilter();
filter.setOperator( rep.getStepAttributeString( idStep, i, "operator" ) );
filter.setFieldName( rep.getStepAttributeString( idStep, i, "field_name" ) );
filter.setComparator( rep.getStepAttributeString( idStep, i, "comparator" ) );
filter.setValue( rep.getStepAttributeString( idStep, i, "value" ) );
this.getFilterList().add( filter );
}
} catch ( Exception e ) {
throw new KettleException( "Unexpected error reading step information from the repository", e );
}
}