@Override public String toString() { return String.format( "ScriptValuesScript: (%d, %s, %s, %b)", getScriptType(), getScriptName(), getScript(), isActive() ); } }
public String getXML() { StringBuilder retval = new StringBuilder( 300 ); retval.append( " <jsScripts>" ); for ( int i = 0; i < jsScripts.length; i++ ) { retval.append( " <jsScript>" ); retval .append( " " ).append( XMLHandler.addTagValue( JSSCRIPT_TAG_TYPE, jsScripts[i].getScriptType() ) ); retval .append( " " ).append( XMLHandler.addTagValue( JSSCRIPT_TAG_NAME, jsScripts[i].getScriptName() ) ); retval.append( " " ).append( XMLHandler.addTagValue( JSSCRIPT_TAG_SCRIPT, jsScripts[i].getScript() ) ); retval.append( " </jsScript>" ); } retval.append( " </jsScripts>" ); retval.append( " <fields>" ); for ( int i = 0; i < fieldname.length; i++ ) { retval.append( " <field>" ); retval.append( " " ).append( XMLHandler.addTagValue( "name", fieldname[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "rename", rename[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "type", ValueMetaFactory.getValueMetaName( type[i] ) ) ); retval.append( " " ).append( XMLHandler.addTagValue( "length", length[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "precision", precision[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "replace", replace[i] ) ); retval.append( " </field>" ); } retval.append( " </fields>" ); return retval.toString(); }
public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { meta = (ScriptMeta) smi; data = (ScriptData) sdi; if ( super.init( smi, sdi ) ) { // Add init code here. // Get the actual Scripts from our MetaData 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; }
public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ) throws KettleException { try { for ( int i = 0; i < jsScripts.length; i++ ) { rep.saveStepAttribute( id_transformation, id_step, i, JSSCRIPT_TAG_NAME, jsScripts[i].getScriptName() ); rep.saveStepAttribute( id_transformation, id_step, i, JSSCRIPT_TAG_SCRIPT, jsScripts[i].getScript() ); rep.saveStepAttribute( id_transformation, id_step, i, JSSCRIPT_TAG_TYPE, jsScripts[i].getScriptType() ); } for ( int i = 0; i < fieldname.length; i++ ) { rep.saveStepAttribute( id_transformation, id_step, i, "field_name", fieldname[i] ); rep.saveStepAttribute( id_transformation, id_step, i, "field_rename", rename[i] ); rep.saveStepAttribute( id_transformation, id_step, i, "field_type", ValueMetaFactory.getValueMetaName( type[i] ) ); rep.saveStepAttribute( id_transformation, id_step, i, "field_length", length[i] ); rep.saveStepAttribute( id_transformation, id_step, i, "field_precision", precision[i] ); rep.saveStepAttribute( id_transformation, id_step, i, "field_replace", replace[i] ); } } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "ScriptMeta.Exception.UnableToSaveStepInfo" ) + id_step, e ); } }