"Java API and predefined processes"

colocolo Member Posts: 236 Maven
edited May 2019 in Help
Hi everybody,

I am developing some generic processes that shall be configured by a minimal GUI. So I have to do some parameter settings using the Java API.
I just wrote some wrapper classes to easily use different data sources (DB, Repository or File). I first thought of adding the relevant operator from my Java code, but then I have to take care of connections and such things. My last idea was to use the "Select Subprocess" operator and add the three alternatives as already connected operators inside. This way I will just have to choose the correct subprocess and set the corresponding operator's parameters. Do you see any disadvantages for this approach?

Working on this, some specific questions came to my mind:
  • Which way of addressing operators from Java do you suggest? Assigning unique names in the RapidMiner GUI and use them for getOperator()?
  • Is there a way to get the names of the predefined database connections? I couldn't find the place, where they are loaded for the ParameterTypeDatabaseConnection.
  • What is the best way for loading a process from repository and store it at another location? I am currently loading the process as described here
I'd be glad if someone could answer some of the questions.

Thanks and best regards
Matthias

Answers

  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee, Member, University Professor Posts: 1,993 RM Engineering
    Hi,
    • Operator names are indeed unique in RapidMiner processes (enforced via the GUI), so that should be fine
    • You can get them via DatabaseConnectionService.getConnectionEntries(), this will return a collection of FieldConnectionEntry objects, getName() will get you the name for them
    • See below:
    You can use

    Process process = new RepositoryProcessLocation(location).load(null);
    to load the process, set a ProcessLocation via

    process.setProcessLocation(new RepositoryProcessLocation(location));
    and then you can simply call

    process.save();
    That's how it's done in RapidMiner, so you should be fine :D

    Regards,
    Marco
  • colocolo Member Posts: 236 Maven
    Hi Marco,

    thank you very much for the quick and enlightening response. Since time is getting short for completing my thesis this was very welcome :)

    The way you described the loading of existing processes via their XML description (linked posting) seemed a bit confusing. The steps described above seem a bit more promising ;)

    Best regards
    Matthias
  • colocolo Member Posts: 236 Maven
    Hi,

    here is an issue, that I just discovered. If German umlaute are present somewhere in the operators' parameter values (in my case it was a repository location), they seem to be set properly from Java. When executing the process via process.run() they also seem to work. When process.save() is called they seem to be written with UTF-8 encoding which is also working. But when I open this process in RapidMiner GUI, these characters are messed up (and in my case the location isn't valid any more). The original process was also set to UTF-8 but this doesn't show any effect.

    In addition to this the nice arrangement of the operators from the process template gets also lost after reading the predefined template, making some settings and storing it again from Java. This is definetely a minor issue, but I don't know if it should happen.

    Well, I try to avoid umlaute but perhaps you might want check what happens when loading a process to the GUI (in case you can confirm this issue).

    Edit: Since the Umlaut issue also affects regular expressions and other relevant parameter values, this is a serious problem for me. I also experienced that symbols already contained in my original process template (like in operator comments) are also messed up, only the things set via API appear correctly when opening the generated XML in a text editor. It's vice versa for RapidMiner GUI :(
    It seems like the encoding setting of the process is ignored, while the storage of the XML file uses UTF-8 anyway.

    Best regards
    Matthias

    P.S. I didn't edit my last post, since I fear you will not be aware of the change and will perhaps never look into this topic again ;)
  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee, Member, University Professor Posts: 1,993 RM Engineering
    Hi,

    please file a bug report on the issue.

    Regards,
    Marco
Sign In or Register to comment.