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

"using a 3rd party API"

sgenzersgenzer Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, Community Manager, Member, University Professor, PM Moderator Posts: 2,959 Community Manager
edited June 2019 in Help
Hi...I am foolishly trying to do something beyond my comp sci abilities - extending RM.  Specifically I am trying to use this API within "Execute Script" in order to pull data into RM:
import com.benwaffle.pslib.PSlib;
PSlib api = new PSlib("https://ps01.bergen.org");
api.login("username","password");
Grade[] grades = api.getCourses()[0].getGrades();

for (Grade g : grades)
 System.out.printf("%s - %d%%", g.name(), g.score());
I put the PSlib.jar file into the /lib folder and I get an error that says..."unable to resolve class com.benwaffle.pslib.PSlib..."
 
Help?  I have NOT done the tutorial on how to build RM extensions as I am not a programmer and certainly do not know how to program in Groovy or Gradle.  The API was pulled from here: https://github.com/benwaffle/PSlib

Thanks!

Answers

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

    you are on the right track - however the .jar you added to your /lib folder does not contain the class "com.benwaffle.pslib.PSlib". You can open a .jar with any tool used to extract .zip files. You can then have a look at the folders and .class files in there. Folders represent the package structure (e.g. "com.benwaffle.pslib"), and the .class files are the actual Java classes (e.g. "PSlib").
    You will see that neither the folders nor the class exist in the .jar which is why you Studio complained it knew nothing about the imported class.

    Regards,
    Marco
  • sgenzersgenzer Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, Community Manager, Member, University Professor, PM Moderator Posts: 2,959 Community Manager
    HI Marco -

    I was hoping you would chime in to help.  :)

    Yes that part I understand but I believe the file is in the jar file.  Here is a screenshot of the file structure when I unzip:

    http://bit.ly/17b8snJ

    so as far as I can see, the class "com.benwaffle.pslib.PSlib" seems to be in psapi.jar.  Am I missing something?

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

    I cannot access that link. I checked the jar available for download on github. Anyway, I quickly threw together an example. Simply place the test.jar in the lib folder and execute the process below. A popup dialog should appear and convince you that it works ;)
    Download: test.jar

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="6.3.000">
     <context>
       <input/>
       <output/>
       <macros/>
     </context>
     <operator activated="true" class="process" compatibility="6.3.000" expanded="true" name="Process">
       <process expanded="true">
         <operator activated="true" class="retrieve" compatibility="6.3.000" expanded="true" height="60" name="Retrieve Deals" width="90" x="45" y="30">
           <parameter key="repository_entry" value="//Samples/data/Deals"/>
         </operator>
         <operator activated="true" class="execute_script" compatibility="6.3.000" expanded="true" height="76" name="Execute Script" width="90" x="179" y="30">
           <parameter key="script" value="import com.test.Test;&#10;&#10;Test.test();&#10;&#10;return input[0];"/>
         </operator>
         <connect from_op="Retrieve Deals" from_port="output" to_op="Execute Script" to_port="input 1"/>
         <connect from_op="Execute Script" from_port="output 1" to_port="result 1"/>
         <portSpacing port="source_input 1" spacing="0"/>
         <portSpacing port="sink_result 1" spacing="0"/>
         <portSpacing port="sink_result 2" spacing="0"/>
       </process>
     </operator>
    </process>
    Regards,
    Marco
  • sgenzersgenzer Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, Community Manager, Member, University Professor, PM Moderator Posts: 2,959 Community Manager
    Hi Marco -

    Thanks so much - I got that to work easily and will go back and see why this other file does not work.  The template is very useful.

    Scott
  • sgenzersgenzer Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, Community Manager, Member, University Professor, PM Moderator Posts: 2,959 Community Manager
    OK this is too hard for me.  Are there any developers out there who can help adapt an educational API to RapidMiner?  I have all the API documentation; I just do not have the skill set to make it happen.

    Thanks!!

    Scott
Sign In or Register to comment.