[SOLVED]operator.setParameter method

AleAle MemberPosts:6Contributor I
edited November 2018 inHelp
Hi, I'm new to rapidminer. I'm trying to execute this simple process using java code





<宏/ >




<参数键=“repository_entry”值= " / /当地Repository/data/model"/>


<参数键=“repository_entry”值= " / /当地Repository/data/testing"/>













I need to change the repository_entry value of the two retrieve operators. I'm using the setParameter method
Operator opRetModel = process.getOperator("Retrieve model");
opRetModel.setParameter(???,model path)
but I don't understand what to use as first parameter to specify the path of the saved model.

I've read the question n 6 at this pagehttp://rapid-i.com/rapidforum/index.php/topic,5807.0.htmlbut I don't understand what is that class SingleDocumentInputOperator.
Thanks for your help.
Tagged:

Answers

  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee, Member, University ProfessorPosts:1,984RM Engineering
    Hi,

    I have updated the question in the FAQ because the operator used was from an extension and thus not the best example.
    I'll rewrite this here anyway:

    Step 1) Open the "OperatorsCore.xml" file and search for the name of the operator. In your case, retrieve is the one you're looking for. Note how that key is the same as the 'class' attribute in the process XML. Now you know that "com.rapidminer.operator.io.RepositorySource" is the implementation class of the operator.
    Step 2) You can then check said class for string constants and you will find "PARAMETER_REPOSITORY_ENTRY". This is the key you need to use.

    Regards,
    Marco
  • AleAle MemberPosts:6Contributor I
    非常感谢你,现在I understand how it works.
    I'm still having problems calling this method when the parameter to set is the path to a file.
    This code

    Operator opReadModel = process.getOperator("Read model");
    String path="/home/alessia/Scrivania/model.mod";
    opReadModel.setParameter(com.rapidminer.operator.io.ModelLoader.PARAMETER_MODEL_FILE,path);
    gives me a null pointer exception on the third row even if the path is correct and the file exists. If I execute the process through rapidminer gui with the same parameter it works ???
  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee, Member, University ProfessorPosts:1,984RM Engineering
    Hi,

    in the 3rd row of your code the only possiblity for a NullPointerException is when "opReadModel" is null. This is also quite likely given your process xml: The operator is called "Retrieve model" in your process, not "Read model". The call "process.getOperator("name") returns null if no operator is found with the given name.

    Regards,
    Marco
  • AleAle MemberPosts:6Contributor I
    You were right, the operator object was null.
    Thank you very much. ;D
Sign InorRegisterto comment.