Hitachi Vantara Pentaho Community Forums
Results 1 to 9 of 9

Thread: str2num

  1. #1
    Join Date
    Oct 2006
    Posts
    9

    Default str2num

    Hi,

    I'm having troubles with type conversion.
    I want to convert a string into a number and therefor
    I placed a JS transform on the canvas of spoon 2.3.1
    with this code:

    Code:
    var x_coord = xcoord.Clone().str2num().getInteger();
    When testing or running I get an exception/error:

    General executing script:
    org.mozilla.javascript.WrappedException: WrappedException of
    Couldn't convert string to number java.text.ParseException:
    Unparseable number: "test value test value ... test value test value"

    An other mapping with num2str() is succesfull

    What am I doing wrong?

    Rutger

  2. #2
    Join Date
    Nov 1999
    Posts
    9,729

    Default Re:str2num

    Rutger, you didn't do anything wrong.
    The real values are known only at runtime, so we use some test value instead.

    As you might have guessed: "test value test value ... test value test value" is that test value.

    HTH,

    Matt

  3. #3
    Join Date
    Oct 2006
    Posts
    9

    Default Re:str2num

    Hi Matt,

    I got a test mapping working.
    But the error messages keeps appearing with testing
    in the JS step (and the Get variables function doesn't work)
    and at validating the transformation.

    It isn't really a bug, but also it isn't "friendly".
    Maybe this can be solved in an update?

    Rutger

  4. #4
    Join Date
    Nov 1999
    Posts
    9,729

    Default Re:str2num

    Yes, this will be fixed.

    At the moment there is someone writing a complete colour-coding-and-everything javascript editor for Kettle.

    You can imagine, for that reason, I'm not touching the old code anymore. :-)

    All the best,

    Matt

  5. #5
    Join Date
    Oct 2006
    Posts
    9

    Default Re:str2num

    Matt,

    That's wonderfull news!

    Can you tell something about the release date of this
    new feature?

    I'm working on a project and need to build a custom
    text decoding function in Kettle. I've done this already
    for OWB in PLSQL and I'm now investigating how to
    parse his to Kettle.

    Rutger

  6. #6
    Join Date
    Nov 1999
    Posts
    9,729

    Default Re:str2num

    Can you tell something about the release date of this
    new feature?
    No sorry, but it should not be too long.

    I'm working on a project and need to build a custom text decoding function in Kettle. I've done this already for OWB in PLSQL and I'm now investigating how to parse his to Kettle.
    Well, you could do it in JavaScript using functions and what not.
    The second option, if you know a bit of java, is to write your own plugin that handles the more complex stuff.
    Third option is to call the PL/SQL functions/procedures you already have.

    HTH,

    Matt

  7. #7
    Join Date
    Nov 1999
    Posts
    9,729

    Default Re:str2num

    Actually, if you want to help out or even just test, why not send me your e-mail address and I'll put you in contact with the developer.

    --> mcasters (at) pentaho (dot) org.

    All the best,

    Matt

  8. #8
    Join Date
    Oct 2006
    Posts
    9

    Default Re:str2num

    MattCasters wrote:
    The second option, if you know a bit of java, is to write your own plugin that handles the more complex stuff.
    I'm quite familiar with java. Can I find somewhere the documentation
    about making a plugin for kettle?

    Rutger

    PS. I send you my email address

    Post edited by: RutgerDOW, at: 2006/10/24 03:52

  9. #9
    Join Date
    Nov 1999
    Posts
    9,729

    Default Re:str2num

    The plugin stuff is kept simple: you need to implement 4 interfaces:

    (package be.ibridge.kettle.trans.step)

    1) StepMetInterface : it defines the metadata and takes care of XML representation, saving loading from/to repository, checks, etc.

    2) StepInterface : makes the step execute: inherit from BaseStep to make your life easier.

    3) StepDataInterface : holds open cursors, resultsets, files, etc.

    4) StepDialogInterface : GUI/dialog code to edit the meta-data

    You have 50+ samples in the source code as this is the way all steps are constructed.
    What you need to do is add a plugin.xml file and an Icon to represent the step. Then you throw the 4 classes in a jar file.
    Throw all this :someplugin.jar, plugin.xml, someplugin.png in a directory under a kettle sub-directory : plugins/transformations/steps/SomePlugin
    You can also throw extra jar files you need in there and specify it's use in the plugin.xml file. (very simple)

    The sample plugin to get you started called "DummyPlugin" can be found here: http://www.javaforge.com/proj/doc.do?doc_id=3701

    That's pretty much all there is to it. If you modify existing code and start from there, it's extremely easy to do.

    Obviously you need to look around a bit, but a few years ago we wrote the SAP plugin in a couple of hours ;-)

    All the best,

    Matt

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.