Options

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

  • Options
    Marco_BoeckMarco_Boeck Administrator, Moderator, Employee, 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
  • Options
    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?
  • Options
    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.