The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

Passing values from Java to .rmp

SeldimiSeldimi Member Posts: 5 Contributor II
edited June 2019 in Help
Hello,
I want to make a proccess that will call RM process from java that reads a mysql table. My problem is that I want to define the name of the table outside the RM proccess file. Is there any way of passing any values from my java app to the .rmp with RM functions or i would load .rmp as text, made modifications with regural expressions and then call the process() ?

I need to share the table name from java app to .rmp. or use a java defined mysql shared connection to avoid edditing...
Another solution, is to custom make an operator but I couldnt find any usable examples.

Thx in advance.
Tagged:

Answers

  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee-RapidMiner, Member, University Professor Posts: 1,996 RM Engineering
    Hi,

    please have a look here first, there you can see how to execute processes via java.
    On to your question: Yes you can easily ceate the process as described above, then set the parameters of any operators you like via for example

    process.getOperator("operatorName").setParameter("key", "value");
    Regards,
    Marco
  • SeldimiSeldimi Member Posts: 5 Contributor II
    Yea I read the API etc but that small quote doesn't solve my problem. I wanted to pass a java mysql connection variable to RM but couldn't find the 'read from mysql' class... anyways I did something else.

    I read a 'rmp file', find the xml for the mysql table and change the table name then save file and run().
    Thats not the best solution but gave me a hand to move on.

    Now I have another poblem... I want to use kMeans from a java Array. Can I have some help on that?
    As I thought i should make the array an example table, then exampleSet, then pass it to the kMeans cluster object?
  • SeldimiSeldimi Member Posts: 5 Contributor II
    I manaed to create an examplset set (with MemoryExampleTable and I try to get it work with a kMeans clusterer)
    My problem is how can I tell kMeans to get the ExampleSet I ve got as input ? How can I connect the input port with the kmeans?

    I found the solution myself  (in case everyone else wants to)

    IOContainer ioInput = new IOContainer(new IOObject[] {exampleSet});
               Operator kMeans = OperatorService.createOperator(KMeans.class);
               myprocess.getRootOperator().getSubprocess(0).addOperator(kMeans);
               myprocess.getRootOperator().getSubprocess(0).getInnerSources().getPortByName("input 1").connectTo(kMeans.getInputPorts().getPortByName("example set"));
               
               kMeans.getInputPorts().getPortByName("example set").receive(exSet);
               kMeans.getOutputPorts().getPortByName("cluster model").connectTo(myprocess.getRootOperator().getSubprocess(0).getInnerSinks().getPortByName("result 1"));
               
               IOContainer ioResult=myprocess.run(ioInput);
Sign In or Register to comment.