example javascript:
var trans_Status= CONTINUE_TRANSFORMATION;
var zz=Packages.be.ibridge.kettle.core.KettleVariables.getInstance();
var nameStr = "run.root";
var valueStr = "/test"
zz.setVariable(nameStr,valueStr);
-jay
Regards,
Sven
What I did add are 2 new functions in the modified javascript step:
setVariable(key, value, type) and getVariable(key, default)
The type is either "s" system-wide, "r" upto the root, "p" upto the
parent, "g" up to the grandparent. The snippet in the original post
has to become something as:
var trans_Status= CONTINUE_TRANSFORMATION;
var zz=Packages.be.ibridge.kettle.core.KettleVariables.getInstance();
var nameStr = "run.root";
var valueStr = "/test"
setVariable(nameStr,valueStr, "r");
thanks,
jay
I am currently working on a deployment over the next month or so, so i
can't wait for 3.0 to be ready.
I have been testing my scripts under 3.0 to help catch any
inconsistencies between 2.5.1 and 3.0.
it would be nice to not have to start managing different repositories,
etc.
comments, please
-jay
Regards,
Sven
General error executing script:
org.mozilla.javascript.EvaluatorException:
org.mozilla.javascript.EvaluatorException: Cannot convert
org.pentaho.di.ui.trans.steps.scriptvalues_mod.ScriptValuesModDialog
$ScriptValuesModDummy@1b8b3bb to
org.pentaho.di.trans.steps.scriptvalues_mod.ScriptValuesMod (script
#5) (script #5)
Code:
var nameStr = "run.root";
var valueStr = "/test"
setVariable(nameStr,valueStr, "r");
Regards,
Sven
Matt
--
Matt
____________________________________________
Matt Casters
Pentaho, Open Source Business Intelligence
http://www.pentaho.org -- mcas...@pentaho.org
Tel. +32 (0) 486 97 29 37
this code:
var value = "valuea";
Will do the trick just as well.
The difference being that the change in metadata only has to be calculated
once, not for every row.
Because of the changes we made in 3.0, the Value object no longer exists.
HTH,
Matt
Both in version 2 or 3 you can add values to the rows simply by specifying the
variables you created in your scripts in the Fields section at the bottom of
the "Script values" dialog.
For example, you can create a variable as such:
var value = "valueA";
Adding that value to the row is simply a case of specifying that field as in
the attached screenshot.
BTW, the decision to not add values one by one to the rows is one of the
things that makes version 3 fly compared to version 2. If you are processing
rows, you should not be adding the same metadata to the values in every row.
By definition, all the rows are the same. That de-coupling of data and
metadata is why you can't trick the JS step anymore :-)
Now, all that being said, it might very well be possible that you need
functionality on top of the defaults. I appreciate that DII might be doing
some very complex things. In that case, I would much rather see those things
wrapped in a JS function somehow. Let me know your requirements and I'll
help out our data mining friends as much as possible.
All the best,
Matt
Renaming a field via javascript:
The code I had still "tests" ok in the node, but does not actually
rename the column.
<old field name>.setName("<new field name>");
Removing a field via javascript:
The code I had still "tests" ok in the node, but does not actually
remove the column.
row.removeValue("<field name>");
Is it possible to still implement this functionality through the java
script node? I tried using the bottom section of the screen to do the
rename, but I couldn't get that to work (am I missing the obvious?).
Thanks again,
Bruce
Decision Intelligence, Inc.
On Sep 13, 1:24 pm, "Bruce Linn" <bwlst...@gmail.com> wrote:
> I think this should work just fine (actually better) in our case. I didn't
> understand that I could create a new variable in the lower section and then
> reference it in the script. I thought this section was exclusively for
> modifying meta data of existing fields.
>
> Thanks again for your help,
> Bruce
> Decision Intelligence, Inc.
>
> > ? That
> > > is the functionality that I am attempting to recreate in 3.0.
>
> > > If it is not available, what other options would you recommend? Java
> > > script fit well into our application of PDI, as we could dynamically
> > > generate the java script to create a dynamic set of fields on our data
> > > stream.
>
> > > Bruce
> > > Decision Intelligence, Inc.
>
> > > On 9/13/07, Matt Casters <mcast...@pentaho.org> wrote:
> > > > There is no replacement code possible.
> > > > That is because it is highly inefficient and even in verison
> > > > 2.xundocumented.
>
> > > > this code:
>
> > > > var value = "valuea";
>
> > > > Will do the trick just as well.
> > > > The difference being that the change in metadata only has to be
> > > > calculated once, not for every row.
>
> > > > Because of the changes we made in 3.0, the Value object no longer
> > exists.
>
> > > > HTH,
>
> > > > Matt
>
> > > > On Thursday 13 September 2007 15:54:15 Bruce Linn wrote:
> > > > > Thanks!
>
> > > > > Is there also a replacement function to handle this example?
>
> > > > > var value = Packages.be.ibridge.kettle.core.value.Value.getInstance
> > ();
> > > > > value.setName("fielda");
> > > > > value.setValue("valuea");
> > > > > row.addValue(value);
>
> > > > > -Bruce
>
> > > > > On 9/12/07, Sven Boden <list...@pandora.be> wrote:
> > > > > > Running works, test doesn't. So run, don't test for now. Test is
> > > > > > always a bit tricky as some fields will be defaulted.
>
> > > > > > Regards,
> > > > > > Sven
>
> > > > > > On Jul 28, 12:59 pm, Sven Boden <list...@pandora.be> wrote:
> > > > > > > Since variables are moderately changed ;-) that snippet of code
>
> > > > won't
>
> > > > > > > work anymore. It's also not really possible to make it backwards
> > > > > > > compatible, this will be the case for any use of "Package.... "
> > > > > > > when the implementation of the called functionality changes
> > (inside
> > > > > > > or outside of Kettle).
>
> > > > > > > What I did add are 2 new functions in the modified javascript
> > step:
>
> > > > > > > setVariable(key, value, type) and getVariable(key, default)
>
> > > > > > > The type is either "s" system-wide, "r" upto the root, "p" upto
> > the
> > > > > > > parent, "g" up to the grandparent. The snippet in the original
> > post
> > > > > > > has to become something as:
>
> > > > > > > var trans_Status= CONTINUE_TRANSFORMATION;
> > > >http://www.pentaho.org -- mcast...@pentaho.org
> > > > Tel. +32 (0) 486 97 29 37
>
> > --
> > Matt
> > ____________________________________________
> > Matt Casters
> > Pentaho, Open Source Business Intelligence
> >http://www.pentaho.org -- mcast...@pentaho.org
That doesn't work anymore either for the same reasons as before.
But... we have a dedicated step called "Select Values" that performs the trick
faster and better. The "Metadata" tab allows you to rename fields in a clean
and fast way.
IMHO, the isolation of functionality is good thing. Let's take for example a
situation where you would rename a fieldname in some rows and not in others.
That sort of thing is mayhem waiting to happen.
All the best,
Matt
http://www.pentaho.org -- mcas...@pentaho.org